mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-10-19 03:32:41 +00:00
Handle shader overflow cases
This commit is contained in:
parent
8a7778bbff
commit
7623753e68
6 changed files with 25 additions and 12 deletions
|
@ -6,8 +6,6 @@
|
||||||
static u8 sAllowCCPrint = 1;
|
static u8 sAllowCCPrint = 1;
|
||||||
|
|
||||||
void gfx_cc_get_features(struct ColorCombiner* cc, struct CCFeatures* ccf) {
|
void gfx_cc_get_features(struct ColorCombiner* cc, struct CCFeatures* ccf) {
|
||||||
// DO NOT COMMIT: TODO - need to convert dx and regular gl
|
|
||||||
|
|
||||||
// reset ccf
|
// reset ccf
|
||||||
memset(ccf, 0, sizeof(struct CCFeatures));
|
memset(ccf, 0, sizeof(struct CCFeatures));
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ struct CombineMode {
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#define SHADER_CMD_LENGTH 16
|
#define SHADER_CMD_LENGTH 16
|
||||||
|
#define CC_MAX_SHADERS 64
|
||||||
|
|
||||||
struct ColorCombiner {
|
struct ColorCombiner {
|
||||||
struct CombineMode cm;
|
struct CombineMode cm;
|
||||||
|
|
|
@ -103,8 +103,9 @@ static struct {
|
||||||
PerFrameCB per_frame_cb_data;
|
PerFrameCB per_frame_cb_data;
|
||||||
PerDrawCB per_draw_cb_data;
|
PerDrawCB per_draw_cb_data;
|
||||||
|
|
||||||
struct ShaderProgramD3D11 shader_program_pool[64];
|
struct ShaderProgramD3D11 shader_program_pool[CC_MAX_SHADERS];
|
||||||
uint8_t shader_program_pool_size;
|
uint8_t shader_program_pool_size;
|
||||||
|
uint8_t shader_program_pool_index;
|
||||||
|
|
||||||
std::vector<struct TextureData> textures;
|
std::vector<struct TextureData> textures;
|
||||||
int current_tile;
|
int current_tile;
|
||||||
|
@ -355,7 +356,9 @@ static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(struct ColorCo
|
||||||
throw hr;
|
throw hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ShaderProgramD3D11 *prg = &d3d.shader_program_pool[d3d.shader_program_pool_size++];
|
struct ShaderProgramD3D11 *prg = &d3d.shader_program_pool[d3d.shader_program_pool_index];
|
||||||
|
d3d.shader_program_pool_index = (d3d.shader_program_pool_index + 1) % CC_MAX_SHADERS;
|
||||||
|
if (d3d.shader_program_pool_size < CC_MAX_SHADERS) { d3d.shader_program_pool_size++; }
|
||||||
|
|
||||||
ThrowIfFailed(d3d.device->CreateVertexShader(vs->GetBufferPointer(), vs->GetBufferSize(), nullptr, prg->vertex_shader.GetAddressOf()));
|
ThrowIfFailed(d3d.device->CreateVertexShader(vs->GetBufferPointer(), vs->GetBufferSize(), nullptr, prg->vertex_shader.GetAddressOf()));
|
||||||
ThrowIfFailed(d3d.device->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), nullptr, prg->pixel_shader.GetAddressOf()));
|
ThrowIfFailed(d3d.device->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), nullptr, prg->pixel_shader.GetAddressOf()));
|
||||||
|
|
|
@ -108,8 +108,9 @@ static struct {
|
||||||
HMODULE d3dcompiler_module;
|
HMODULE d3dcompiler_module;
|
||||||
pD3DCompile D3DCompile;
|
pD3DCompile D3DCompile;
|
||||||
|
|
||||||
struct ShaderProgramD3D12 shader_program_pool[64];
|
struct ShaderProgramD3D12 shader_program_pool[CC_MAX_SHADERS];
|
||||||
uint8_t shader_program_pool_size;
|
uint8_t shader_program_pool_size;
|
||||||
|
uint8_t shader_program_pool_index;
|
||||||
|
|
||||||
uint32_t current_width, current_height;
|
uint32_t current_width, current_height;
|
||||||
|
|
||||||
|
@ -236,7 +237,9 @@ static void gfx_direct3d12_load_shader(struct ShaderProgram *new_prg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ShaderProgram *gfx_direct3d12_create_and_load_new_shader(struct ColorCombiner* cc) {
|
static struct ShaderProgram *gfx_direct3d12_create_and_load_new_shader(struct ColorCombiner* cc) {
|
||||||
struct ShaderProgramD3D12 *prg = &d3d.shader_program_pool[d3d.shader_program_pool_size++];
|
struct ShaderProgramD3D12 *prg = &d3d.shader_program_pool[d3d.shader_program_pool_index];
|
||||||
|
d3d.shader_program_pool_index = (d3d.shader_program_pool_index + 1) % CC_MAX_SHADERS;
|
||||||
|
if (d3d.shader_program_pool_size < CC_MAX_SHADERS) { d3d.shader_program_pool_size++; }
|
||||||
|
|
||||||
CCFeatures cc_features = { 0 };
|
CCFeatures cc_features = { 0 };
|
||||||
gfx_cc_get_features(cc, &cc_features);
|
gfx_cc_get_features(cc, &cc_features);
|
||||||
|
|
|
@ -61,8 +61,9 @@ struct GLTexture {
|
||||||
bool filter;
|
bool filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ShaderProgram shader_program_pool[64];
|
static struct ShaderProgram shader_program_pool[CC_MAX_SHADERS];
|
||||||
static uint8_t shader_program_pool_size;
|
static uint8_t shader_program_pool_size = 0;
|
||||||
|
static uint8_t shader_program_pool_index = 0;
|
||||||
static GLuint opengl_vbo;
|
static GLuint opengl_vbo;
|
||||||
|
|
||||||
static int tex_cache_size = 0;
|
static int tex_cache_size = 0;
|
||||||
|
@ -473,7 +474,10 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
|
||||||
|
|
||||||
size_t cnt = 0;
|
size_t cnt = 0;
|
||||||
|
|
||||||
struct ShaderProgram *prg = &shader_program_pool[shader_program_pool_size++];
|
struct ShaderProgram *prg = &shader_program_pool[shader_program_pool_index];
|
||||||
|
shader_program_pool_index = (shader_program_pool_index + 1) % CC_MAX_SHADERS;
|
||||||
|
if (shader_program_pool_size < CC_MAX_SHADERS) { shader_program_pool_size++; }
|
||||||
|
|
||||||
prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, "aVtxPos");
|
prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, "aVtxPos");
|
||||||
prg->attrib_sizes[cnt] = 4;
|
prg->attrib_sizes[cnt] = 4;
|
||||||
++cnt;
|
++cnt;
|
||||||
|
|
|
@ -94,8 +94,9 @@ static struct {
|
||||||
uint32_t pool_pos;
|
uint32_t pool_pos;
|
||||||
} gfx_texture_cache;
|
} gfx_texture_cache;
|
||||||
|
|
||||||
static struct ColorCombiner color_combiner_pool[64] = { 0 };
|
static struct ColorCombiner color_combiner_pool[CC_MAX_SHADERS] = { 0 };
|
||||||
static uint8_t color_combiner_pool_size;
|
static uint8_t color_combiner_pool_size = 0;
|
||||||
|
static uint8_t color_combiner_pool_index = 0;
|
||||||
|
|
||||||
static struct RSP {
|
static struct RSP {
|
||||||
float modelview_matrix_stack[11][4][4];
|
float modelview_matrix_stack[11][4][4];
|
||||||
|
@ -345,7 +346,10 @@ static struct ColorCombiner *gfx_lookup_or_create_color_combiner(struct CombineM
|
||||||
|
|
||||||
gfx_flush();
|
gfx_flush();
|
||||||
|
|
||||||
struct ColorCombiner *comb = &color_combiner_pool[color_combiner_pool_size++];
|
struct ColorCombiner *comb = &color_combiner_pool[color_combiner_pool_index];
|
||||||
|
color_combiner_pool_index = (color_combiner_pool_index + 1) % CC_MAX_SHADERS;
|
||||||
|
if (color_combiner_pool_size < CC_MAX_SHADERS) { color_combiner_pool_size++; }
|
||||||
|
|
||||||
memcpy(&comb->cm, cm, sizeof(struct CombineMode));
|
memcpy(&comb->cm, cm, sizeof(struct CombineMode));
|
||||||
gfx_generate_cc(comb);
|
gfx_generate_cc(comb);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue