From: Connor McAdams Subject: [PATCH 10/10] d3d10: Apply shader resources for shaders used in pass. Message-Id: <20191207182300.3084-11-conmanx360@gmail.com> Date: Sat, 7 Dec 2019 13:23:00 -0500 In-Reply-To: <20191207182300.3084-1-conmanx360@gmail.com> References: <20191207182300.3084-1-conmanx360@gmail.com> Apply resources that are used by the shaders within the effect pass. Signed-off-by: Connor McAdams --- dlls/d3d10/effect.c | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index df95724f95..235d7ed9b2 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -3651,9 +3651,102 @@ static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnno return &null_variable.ID3D10EffectVariable_iface; } +static void write_localbuffer(ID3D10Device *device, struct d3d10_effect_variable *v) +{ + struct d3d10_effect_buffer_variable *b = &v->u.buffer; + + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)b->buffer, 0, NULL, (const void *)b->local_buffer, + v->data_size, 0); + + b->changed = 0; +} + +static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShaderVariable *variable) +{ + struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)variable); + struct d3d10_effect_shader_variable *sv = &v->u.shader; + struct d3d10_effect_shader_resource *sr; + ID3D10ShaderResourceView *const *srv; + + unsigned int i; + + for (i = 0; i < sv->resources; i++) + { + sr = &sv->shader_resource[i]; + + switch (sr->in_type) + { + case D3D10_SIT_CBUFFER: + switch (v->type->basetype) + { + case D3D10_SVT_VERTEXSHADER: + ID3D10Device_VSSetConstantBuffers(device, sr->bind_point, sr->bind_count, + (ID3D10Buffer *const *)&sr->resource_variable->u.buffer.buffer); + break; + case D3D10_SVT_PIXELSHADER: + ID3D10Device_PSSetConstantBuffers(device, sr->bind_point, sr->bind_count, + (ID3D10Buffer *const *)&sr->resource_variable->u.buffer.buffer); + break; + case D3D10_SVT_GEOMETRYSHADER: + ID3D10Device_GSSetConstantBuffers(device, sr->bind_point, sr->bind_count, + (ID3D10Buffer *const *)&sr->resource_variable->u.buffer.buffer); + break; + default: + break; + } + break; + case D3D10_SIT_TEXTURE: + case D3D10_SIT_TBUFFER: + if (sr->in_type == D3D10_SIT_TBUFFER) + srv = (ID3D10ShaderResourceView *const *)&sr->resource_variable->u.buffer.resource_view; + else + srv = (ID3D10ShaderResourceView *const *)sr->resource_variable->u.resource.resource_view; + + switch (v->type->basetype) + { + case D3D10_SVT_VERTEXSHADER: + ID3D10Device_VSSetShaderResources(device, sr->bind_point, sr->bind_count, srv); + break; + case D3D10_SVT_PIXELSHADER: + ID3D10Device_PSSetShaderResources(device, sr->bind_point, sr->bind_count, srv); + break; + case D3D10_SVT_GEOMETRYSHADER: + ID3D10Device_GSSetShaderResources(device, sr->bind_point, sr->bind_count, srv); + break; + default: + break; + } + break; + case D3D10_SIT_SAMPLER: + switch (v->type->basetype) + { + case D3D10_SVT_VERTEXSHADER: + ID3D10Device_VSSetSamplers(device, sr->bind_point, sr->bind_count, + (ID3D10SamplerState *const *)&sr->resource_variable->u.state.object.sampler); + break; + case D3D10_SVT_PIXELSHADER: + ID3D10Device_PSSetSamplers(device, sr->bind_point, sr->bind_count, + (ID3D10SamplerState *const *)&sr->resource_variable->u.state.object.sampler); + break; + case D3D10_SVT_GEOMETRYSHADER: + ID3D10Device_GSSetSamplers(device, sr->bind_point, sr->bind_count, + (ID3D10SamplerState *const *)&sr->resource_variable->u.state.object.sampler); + break; + default: + break; + } + break; + default: + break; + } + } +} + static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface, UINT flags) { struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface); + struct d3d10_effect *effect = This->technique->effect; + ID3D10Device *device = This->technique->effect->device; HRESULT hr = S_OK; unsigned int i; @@ -3661,6 +3754,19 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface if (flags) FIXME("Ignoring flags (%#x)\n", flags); + for (i = 0; i < effect->local_buffer_count; i++) + { + if (effect->local_buffers[i].u.buffer.changed) + write_localbuffer(device, &effect->local_buffers[i]); + } + + if (This->vs.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface) + apply_shader_resources(device, This->vs.pShaderVariable); + if (This->gs.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface) + apply_shader_resources(device, This->gs.pShaderVariable); + if (This->ps.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface) + apply_shader_resources(device, This->ps.pShaderVariable); + for (i = 0; i < This->object_count; ++i) { hr = d3d10_effect_object_apply(&This->objects[i]); -- 2.20.1