(D3D11) clear out all unused texture/sampler bindings each pass to avoid

hazards with SetRenderTargets.
This commit is contained in:
aliaspider 2018-01-31 17:05:48 +01:00
parent f7b5baccb6
commit d8924d6fbb
4 changed files with 4 additions and 24 deletions

View File

@ -2559,7 +2559,6 @@ typedef struct
pass_semantics_t semantics;
D3D11ShaderResourceViewRef textures[SLANG_NUM_BINDINGS];
D3D11SamplerStateRef samplers[SLANG_NUM_BINDINGS];
int num_bindings;
float frame_count;
} pass[GFX_MAX_SHADERS];

View File

@ -780,13 +780,10 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi
texture_sem_t* texture_sem = &d3d11->pass[i].semantics.textures[j];
D3D11ShaderResourceView view = ((d3d11_texture_t*)texture_sem->texture_data)->view;
D3D11SamplerStateRef sampler = *(D3D11SamplerStateRef*)texture_sem->sampler_data;
int slot = texture_sem->binding - d3d11->pass[i].semantics.min_binding;
d3d11->pass[i].textures[slot] = view;
d3d11->pass[i].samplers[slot] = sampler;
d3d11->pass[i].textures[texture_sem->binding] = view;
d3d11->pass[i].samplers[texture_sem->binding] = sampler;
}
d3d11->pass[i].num_bindings =
d3d11->pass[i].semantics.max_binding - d3d11->pass[i].semantics.min_binding + 1;
}
}
@ -903,12 +900,8 @@ static bool d3d11_gfx_frame(
D3D11RenderTargetView null_rt = NULL;
D3D11SetRenderTargets(d3d11->ctx, 1, &null_rt, NULL);
D3D11SetPShaderResources(
d3d11->ctx, d3d11->pass[i].semantics.min_binding, d3d11->pass[i].num_bindings,
d3d11->pass[i].textures);
D3D11SetPShaderSamplers(
d3d11->ctx, d3d11->pass[i].semantics.min_binding, d3d11->pass[i].num_bindings,
d3d11->pass[i].samplers);
D3D11SetPShaderResources(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].textures);
D3D11SetPShaderSamplers(d3d11->ctx, 0, SLANG_NUM_BINDINGS, d3d11->pass[i].samplers);
if (d3d11->pass[i].rt.handle)
{

View File

@ -208,7 +208,6 @@ static bool slang_process_reflection(
}
}
out->min_binding = SLANG_NUM_BINDINGS;
texture_map_t* texture_map = semantics_map->texture_map;
while (texture_map->texture_data)
@ -228,12 +227,6 @@ static bool slang_process_reflection(
strncpy(texture.id, id.c_str(), sizeof(texture.id));
if (out->max_binding < src.binding)
out->max_binding = src.binding;
if (out->min_binding > src.binding)
out->min_binding = src.binding;
textures.push_back(texture);
uniform_sem_t uniform = { texture_map->size_data, texture_map->size_id,
@ -259,9 +252,6 @@ static bool slang_process_reflection(
texture_map++;
}
if (out->min_binding > out->max_binding)
out->min_binding = out->max_binding;
out->texture_count = textures.size();
textures.push_back({ NULL });

View File

@ -93,8 +93,6 @@ typedef struct
{
int texture_count;
texture_sem_t* textures;
int max_binding;
int min_binding;
cbuffer_sem_t cbuffers[SLANG_CBUFFER_MAX];
} pass_semantics_t;