Patch series to implement the functions that are used by steam big picture mode. Submitting for feedback/ideas on how to improve/change things.
Connor McAdams (10): d3d10: Allocate buffers for effect interface local_buffers. d3d10: Implement scalar effect variable set methods. d3d10: Implement scalar effect variable get methods. d3d10: Implement vector effect variable set methods. d3d10: Implement vector effect variable get methods. d3d10: Implement matrix effect variable set methods. d3d10: Implement matrix effect variable get methods. d3d10: Implement ShaderResource effect variable set method. d3d10: Get resources used by effect shaders. d3d10: Apply shader resources for shaders used in pass.
dlls/d3d10/d3d10_private.h | 28 ++ dlls/d3d10/effect.c | 758 +++++++++++++++++++++++++++++++++---- 2 files changed, 718 insertions(+), 68 deletions(-)
Create ID3D10Buffer interfaces for the constant buffers within the effect shader.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/d3d10_private.h | 10 ++++++ dlls/d3d10/effect.c | 62 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 96020cd4a0..5c6c7a2d72 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -114,6 +114,15 @@ struct d3d10_effect_state_object_variable } object; };
+struct d3d10_effect_buffer_variable +{ + ID3D10Buffer *buffer; + ID3D10ShaderResourceView *resource_view; + + UINT changed; + char *local_buffer; +}; + /* ID3D10EffectType */ struct d3d10_effect_type { @@ -169,6 +178,7 @@ struct d3d10_effect_variable { struct d3d10_effect_state_object_variable state; struct d3d10_effect_shader_variable shader; + struct d3d10_effect_buffer_variable buffer; } u; };
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 91e713bdf5..f0932409b1 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -2096,6 +2096,53 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size, return S_OK; }
+static HRESULT create_variable_buffer(struct d3d10_effect_variable *l, D3D10_CBUFFER_TYPE d3d10_cbuffer_type) +{ + D3D10_BUFFER_DESC buffer_desc; + D3D10_SUBRESOURCE_DATA subresource_data; + D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc; + ID3D10Device *device = l->effect->device; + HRESULT hr; + + if (!(l->u.buffer.local_buffer = heap_calloc(l->type->size_unpacked, sizeof(unsigned char)))) + { + ERR("Failed to allocate local constant buffer memory.\n"); + return E_OUTOFMEMORY; + } + + buffer_desc.ByteWidth = l->type->size_unpacked; + buffer_desc.Usage = D3D10_USAGE_DEFAULT; + buffer_desc.CPUAccessFlags = 0; + buffer_desc.MiscFlags = 0; + if (d3d10_cbuffer_type == D3D10_CT_CBUFFER) + buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; + else if (d3d10_cbuffer_type == D3D10_CT_TBUFFER) + buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; + + subresource_data.pSysMem = (const void *)l->u.buffer.local_buffer; + subresource_data.SysMemPitch = 0; + subresource_data.SysMemSlicePitch = 0; + + if (FAILED(hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &subresource_data, &l->u.buffer.buffer))) + return hr; + + if (d3d10_cbuffer_type == D3D10_CT_TBUFFER) + { + srv_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT; + srv_desc.ViewDimension = D3D_SRV_DIMENSION_BUFFER; + srv_desc.Buffer.ElementOffset = 0; + srv_desc.Buffer.ElementWidth = l->type->size_unpacked / 16; + + if (FAILED(hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)l->u.buffer.buffer, + (const D3D10_SHADER_RESOURCE_VIEW_DESC *)&srv_desc, &l->u.buffer.resource_view))) + return hr; + } + else + l->u.buffer.resource_view = NULL; + + return S_OK; +} + static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_variable *l) { @@ -2282,6 +2329,12 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype)); TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
+ if (l->type->size_unpacked && l->type->size_packed) + { + if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type))) + return hr; + } + return S_OK; }
@@ -2760,6 +2813,15 @@ static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l) } heap_free(l->annotations); } + + if (l->u.buffer.buffer) + ID3D10Buffer_Release(l->u.buffer.buffer); + + if (l->u.buffer.local_buffer) + heap_free(l->u.buffer.local_buffer); + + if (l->u.buffer.resource_view) + ID3D10ShaderResourceView_Release(l->u.buffer.resource_view); }
/* IUnknown methods */
On Sat, Dec 7, 2019 at 7:23 PM Connor McAdams conmanx360@gmail.com wrote:
static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_variable *l) { @@ -2282,6 +2329,12 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype)); TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
- if (l->type->size_unpacked && l->type->size_packed)
- {
if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
return hr;
- }
Mostly curious, is there any case where size_unpacked is non-zero but size_packed is?
Not that I'm aware of, it's been a little while but I think since there was two different size values, I was making sure that both actually had a non-zero size. It would probably work fine basing constant buffer creation on one or the other, and which one is probably a matter of opinion. size_unpacked makes the most sense to me, but it's up to you.
On Wed, Jan 22, 2020 at 10:29 AM Matteo Bruni matteo.mystral@gmail.com wrote:
On Sat, Dec 7, 2019 at 7:23 PM Connor McAdams conmanx360@gmail.com wrote:
static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_variable *l) { @@ -2282,6 +2329,12 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype)); TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
- if (l->type->size_unpacked && l->type->size_packed)
- {
if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
return hr;
- }
Mostly curious, is there any case where size_unpacked is non-zero but size_packed is?
On Wed, Jan 22, 2020 at 7:05 PM Connor McAdams conmanx360@gmail.com wrote:
Not that I'm aware of, it's been a little while but I think since there was two different size values, I was making sure that both actually had a non-zero size. It would probably work fine basing constant buffer creation on one or the other, and which one is probably a matter of opinion. size_unpacked makes the most sense to me, but it's up to you.
Yeah, just size_unpacked seems right to me.
Implement SetFloat/SetFloatArray, SetInt/SetIntArray, and SetBool/SetBoolArray methods for the scalar effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/effect.c | 83 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 71 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index f0932409b1..4ecc0753de 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4212,6 +4212,43 @@ static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_ d3d10_effect_constant_buffer_GetTextureBuffer, };
+static inline void write_variable_to_cbuffer(struct d3d10_effect_variable *variable, void *data) +{ + memcpy(variable->buffer->u.buffer.local_buffer + variable->buffer_offset, data, variable->type->size_packed); + + variable->buffer->u.buffer.changed = 1; +} + +static void write_variable_array_to_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT count) +{ + char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + char *cur_element = data; + DWORD element_size; + UINT i; + + /* + * If for some reason we try to use an array write on a variable that + * isn't an array, just default back to the normal variable write. + */ + if (!variable->type->element_count) + { + write_variable_to_cbuffer(variable, data); + return; + } + + element_size = variable->type->elementtype->size_packed; + + for (i = 0; i < count; i++) + { + memcpy(cbuf, cur_element, element_size); + + cur_element += element_size; + cbuf += variable->type->stride; + } + + variable->buffer->u.buffer.changed = 1; +} + /* ID3D10EffectVariable methods */
static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface) @@ -4370,9 +4407,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetRawValue(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable *iface, float value) { - FIXME("iface %p, value %.8e stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %.8e.\n", iface, value); + write_variable_to_cbuffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface, @@ -4383,12 +4423,19 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10Eff return E_NOTIMPL; }
+/* + * According to MSDN, array writing functions for Scalar/Vector effect + * variables have offset go unused. + */ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable *iface, float *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface, @@ -4402,9 +4449,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface, int value) { - FIXME("iface %p, value %d stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %d.\n", iface, value); + write_variable_to_cbuffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable *iface, @@ -4418,9 +4468,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10Effec static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface, int *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface, @@ -4434,9 +4487,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface, BOOL value) { - FIXME("iface %p, value %d stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %d.\n", iface, value); + write_variable_to_cbuffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable *iface, @@ -4450,9 +4506,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10Effe static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface, BOOL *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface,
On Sat, Dec 7, 2019 at 7:23 PM Connor McAdams conmanx360@gmail.com wrote:
Implement SetFloat/SetFloatArray, SetInt/SetIntArray, and SetBool/SetBoolArray methods for the scalar effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/effect.c | 83 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 71 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index f0932409b1..4ecc0753de 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4212,6 +4212,43 @@ static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_ d3d10_effect_constant_buffer_GetTextureBuffer, };
+static inline void write_variable_to_cbuffer(struct d3d10_effect_variable *variable, void *data)
I'm not too happy about the name of this function but I'm not sure about a better alternative. Maybe just _buffer (no c)?
Also I'd drop the inline.
+{
- memcpy(variable->buffer->u.buffer.local_buffer + variable->buffer_offset, data, variable->type->size_packed);
- variable->buffer->u.buffer.changed = 1;
+}
+static void write_variable_array_to_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT count) +{
- char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
- char *cur_element = data;
- DWORD element_size;
- UINT i;
No reason to use UINT or DWORD here and in the function arguments.
- /*
* If for some reason we try to use an array write on a variable that
* isn't an array, just default back to the normal variable write.
*/
- if (!variable->type->element_count)
- {
write_variable_to_cbuffer(variable, data);
return;
- }
I don't think this comment should be there, there isn't anything special about using array methods to write to non-array variables.
- element_size = variable->type->elementtype->size_packed;
- for (i = 0; i < count; i++)
- {
memcpy(cbuf, cur_element, element_size);
cur_element += element_size;
cbuf += variable->type->stride;
- }
- variable->buffer->u.buffer.changed = 1;
+}
/* ID3D10EffectVariable methods */
static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface) @@ -4370,9 +4407,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetRawValue(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable *iface, float value) {
- FIXME("iface %p, value %.8e stub!\n", iface, value);
- struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
There are already a few instances of this (i.e. upcasting to ID3D10EffectVariable) and I'm not sure that the alternative is necessarily better, but another option would be to introduce separate impl_from_ID3D10Effect*Variable() for each variable type.
- return E_NOTIMPL;
- TRACE("iface %p, value %.8e.\n", iface, value);
- write_variable_to_cbuffer(effect_var, &value);
- return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface, @@ -4383,12 +4423,19 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10Eff return E_NOTIMPL; }
+/*
- According to MSDN, array writing functions for Scalar/Vector effect
- variables have offset go unused.
- */
We want a test for that specifically (and for all of those additions in general).
Implement GetFloat/GetFloatArray, GetInt/GetIntArray, and GetBool/GetBoolArray methods for the scalar effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/effect.c | 71 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4ecc0753de..4ab882c1dc 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4249,6 +4249,35 @@ static void write_variable_array_to_cbuffer(struct d3d10_effect_variable *variab variable->buffer->u.buffer.changed = 1; }
+static inline void read_variable_from_cbuffer(struct d3d10_effect_variable *variable, void *data) +{ + memcpy(data, variable->buffer->u.buffer.local_buffer + variable->buffer_offset, variable->type->size_packed); +} + +static void read_variable_array_from_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT count) +{ + char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + char *cur_element = data; + DWORD element_size; + UINT i; + + if (!variable->type->element_count) + { + write_variable_to_cbuffer(variable, data); + return; + } + + element_size = variable->type->elementtype->size_packed; + + for (i = 0; i < count; i++) + { + memcpy(cur_element, cbuf, element_size); + + cur_element += element_size; + cbuf += variable->type->stride; + } +} + /* ID3D10EffectVariable methods */
static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface) @@ -4418,9 +4447,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10Eff static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface, float *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_cbuffer(effect_var, value); + + return S_OK; }
/* @@ -4441,9 +4473,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloatArray(ID3D static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface, float *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface, @@ -4460,9 +4495,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10Effec static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable *iface, int *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_cbuffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface, @@ -4479,9 +4517,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface, int *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface, @@ -4498,9 +4539,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10Effe static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable *iface, BOOL *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_cbuffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface, @@ -4517,9 +4561,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D1 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface, BOOL *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_cbuffer(effect_var, values, count); + + return S_OK; }
static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl =
On Sat, Dec 7, 2019 at 7:23 PM Connor McAdams conmanx360@gmail.com wrote:
Implement GetFloat/GetFloatArray, GetInt/GetIntArray, and GetBool/GetBoolArray methods for the scalar effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/effect.c | 71 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4ecc0753de..4ab882c1dc 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4249,6 +4249,35 @@ static void write_variable_array_to_cbuffer(struct d3d10_effect_variable *variab variable->buffer->u.buffer.changed = 1; }
+static inline void read_variable_from_cbuffer(struct d3d10_effect_variable *variable, void *data) +{
- memcpy(data, variable->buffer->u.buffer.local_buffer + variable->buffer_offset, variable->type->size_packed);
+}
+static void read_variable_array_from_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT count) +{
- char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
- char *cur_element = data;
- DWORD element_size;
- UINT i;
- if (!variable->type->element_count)
- {
write_variable_to_cbuffer(variable, data);
return;
- }
I suppose you meant to use read_variable_from_cbuffer().
Yes, good catch. Must have missed that one. Thanks.
On Wed, Jan 22, 2020 at 10:37 AM Matteo Bruni matteo.mystral@gmail.com wrote:
On Sat, Dec 7, 2019 at 7:23 PM Connor McAdams conmanx360@gmail.com wrote:
Implement GetFloat/GetFloatArray, GetInt/GetIntArray, and GetBool/GetBoolArray methods for the scalar effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/effect.c | 71 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4ecc0753de..4ab882c1dc 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4249,6 +4249,35 @@ static void write_variable_array_to_cbuffer(struct d3d10_effect_variable *variab variable->buffer->u.buffer.changed = 1; }
+static inline void read_variable_from_cbuffer(struct d3d10_effect_variable *variable, void *data) +{
- memcpy(data, variable->buffer->u.buffer.local_buffer + variable->buffer_offset, variable->type->size_packed);
+}
+static void read_variable_array_from_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT count) +{
- char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
- char *cur_element = data;
- DWORD element_size;
- UINT i;
- if (!variable->type->element_count)
- {
write_variable_to_cbuffer(variable, data);
return;
- }
I suppose you meant to use read_variable_from_cbuffer().
Implement SetFloatVector/SetFloatVectorArray, SetIntVector/SetIntVectorArray, and SetBoolVector/SetBoolVectorArray methods for the vector effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/effect.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4ab882c1dc..4475fafe41 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4770,25 +4770,34 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetRawValue(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable *iface, BOOL *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + write_variable_to_cbuffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable *iface, int *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + write_variable_to_cbuffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable *iface, float *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + write_variable_to_cbuffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface, @@ -4818,25 +4827,34 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVector(ID3 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface, BOOL *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable *iface, int *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable *iface, float *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable *iface,
Implement GetFloatVector/GetFloatVectorArray, GetIntVector/GetIntVectorArray, and GetBoolVector/GetBoolVectorArray methods for the vector effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/effect.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4475fafe41..4e51e43a01 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4803,25 +4803,34 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVector(ID3 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface, BOOL *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_cbuffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable *iface, int *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_cbuffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable *iface, float *value) { - FIXME("iface %p, value %p stub!\n", iface, value); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_cbuffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface, @@ -4860,25 +4869,34 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVectorArra static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable *iface, BOOL *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable *iface, int *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_cbuffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable *iface, float *values, UINT offset, UINT count) { - FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_cbuffer(effect_var, values, count); + + return S_OK; }
static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
Implement SetMatrix/SetMatrixArray and SetMatrixTranspose/SetMatrixTransposeArray methods for the matrix effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/effect.c | 114 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4e51e43a01..0f08fb11e9 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -19,6 +19,7 @@ */
#include "d3d10_private.h" +#include "d3d9types.h"
#include <float.h>
@@ -4942,6 +4943,89 @@ static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_ d3d10_effect_vector_variable_GetFloatVectorArray, };
+static void transpose_matrix(D3DMATRIX *matrix) +{ + UINT row, col; + D3DMATRIX tmp; + + for (col = 0; col < 4; col++) + { + for (row = 0; row < 4; row++) + { + memcpy(&tmp.m[col][row], &matrix->m[row][col], sizeof(float)); + } + } + + memcpy(matrix, &tmp, sizeof(D3DMATRIX)); +} + +static void write_matrix_to_cbuffer(struct d3d10_effect_variable *variable, float *cbuf, D3DMATRIX *matrix) +{ + UINT row, col; + + if (variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS) + { + for (col = 0; col < variable->type->column_count; col++) + { + for (row = 0; row < variable->type->row_count; row++) + { + memcpy(cbuf + ((col * 4) + row), &matrix->m[row][col], sizeof(float)); + } + } + } + else + { + for (col = 0; col < variable->type->column_count; col++) + { + for (row = 0; row < variable->type->row_count; row++) + { + memcpy(cbuf + ((row * 4) + col), &matrix->m[row][col], sizeof(float)); + } + } + } +} + +static void write_matrix_variable_to_cbuffer(struct d3d10_effect_variable *variable, void *data) +{ + char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + + write_matrix_to_cbuffer(variable, (float *)cbuf, data); + + variable->buffer->u.buffer.changed = 1; +} + +static void write_matrix_variable_array_to_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT offset, + UINT count, BOOL transpose) +{ + char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + D3DMATRIX *input_data = data; + D3DMATRIX tmp; + UINT i; + + if (!variable->type->element_count) + { + write_matrix_variable_to_cbuffer(variable, data); + return; + } + + if (offset) + cbuf += variable->type->stride * offset; + + for (i = 0; i < count; i++) + { + tmp = input_data[i]; + + if (transpose) + transpose_matrix(&tmp); + + write_matrix_to_cbuffer(variable, (float *)cbuf, &tmp); + + cbuf += variable->type->stride; + } + + variable->buffer->u.buffer.changed = 1; +} + /* ID3D10EffectVariable methods */
static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface) @@ -5100,9 +5184,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetRawValue(ID3D10 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable *iface, float *data) { - FIXME("iface %p, data %p stub!\n", iface, data); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p.\n", iface, data); + write_matrix_variable_to_cbuffer(effect_var, data); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface, @@ -5116,9 +5203,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10Ef static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface, float *data, UINT offset, UINT count) { - FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count); + write_matrix_variable_array_to_cbuffer(effect_var, data, offset, count, FALSE); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface, @@ -5132,9 +5222,14 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface, float *data) { - FIXME("iface %p, data %p stub!\n", iface, data); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface); + D3DMATRIX tmp = *(D3DMATRIX *)data;
- return E_NOTIMPL; + TRACE("iface %p, data %p.\n", iface, data); + transpose_matrix(&tmp); + write_matrix_variable_to_cbuffer(effect_var, &tmp); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface, @@ -5148,9 +5243,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface, float *data, UINT offset, UINT count) { - FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count); + write_matrix_variable_array_to_cbuffer(effect_var, data, offset, count, TRUE); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
On Sat, Dec 7, 2019 at 7:24 PM Connor McAdams conmanx360@gmail.com wrote:
Implement SetMatrix/SetMatrixArray and SetMatrixTranspose/SetMatrixTransposeArray methods for the matrix effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/effect.c | 114 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 4e51e43a01..0f08fb11e9 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -19,6 +19,7 @@ */
#include "d3d10_private.h" +#include "d3d9types.h"
No, just define a local matrix struct.
#include <float.h>
@@ -4942,6 +4943,89 @@ static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_ d3d10_effect_vector_variable_GetFloatVectorArray, };
+static void transpose_matrix(D3DMATRIX *matrix) +{
- UINT row, col;
- D3DMATRIX tmp;
- for (col = 0; col < 4; col++)
- {
for (row = 0; row < 4; row++)
{
memcpy(&tmp.m[col][row], &matrix->m[row][col], sizeof(float));
No need to use an explicit memcpy here.
}
- }
- memcpy(matrix, &tmp, sizeof(D3DMATRIX));
Looking at the two users of the function, you probably want to transpose the matrix in-place instead. The usual trick is to only loop through half the matrix and swap elements.
Or, probably better, just use the "wrong" side of the branch in write_matrix_to_cbuffer() below whenever you need to transpose.
+}
+static void write_matrix_to_cbuffer(struct d3d10_effect_variable *variable, float *cbuf, D3DMATRIX *matrix) +{
- UINT row, col;
- if (variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS)
- {
for (col = 0; col < variable->type->column_count; col++)
{
for (row = 0; row < variable->type->row_count; row++)
{
memcpy(cbuf + ((col * 4) + row), &matrix->m[row][col], sizeof(float));
}
}
- }
- else
- {
for (col = 0; col < variable->type->column_count; col++)
{
for (row = 0; row < variable->type->row_count; row++)
{
memcpy(cbuf + ((row * 4) + col), &matrix->m[row][col], sizeof(float));
}
}
It maybe doesn't matter for a 4x4 matrix and the arguably rare case of row-major storage but, generally, you want to go in row, column order (i.e. move sequentially in memory). Also mostly for general consistency, sizeof(*cbuf) would be preferred.
Implement GetMatrix/GetMatrixArray and GetMatrixTranspose/GetMatrixTransposeArray methods for the matrix effect variable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/effect.c | 85 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 0f08fb11e9..1e1d5d7f4c 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -5026,6 +5026,63 @@ static void write_matrix_variable_array_to_cbuffer(struct d3d10_effect_variable variable->buffer->u.buffer.changed = 1; }
+static void read_matrix_from_cbuffer(struct d3d10_effect_variable *variable, float *cbuf, D3DMATRIX *matrix) +{ + UINT row, col; + + if (variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS) + { + for (col = 0; col < variable->type->column_count; col++) + { + for (row = 0; row < variable->type->row_count; row++) + { + memcpy(&matrix->m[row][col], cbuf + ((col * 4) + row), sizeof(float)); + } + } + } + else + { + for (col = 0; col < variable->type->column_count; col++) + { + for (row = 0; row < variable->type->row_count; row++) + { + memcpy(&matrix->m[row][col], cbuf + ((row * 4) + col), sizeof(float)); + } + } + } +} + +static void read_matrix_variable_from_cbuffer(struct d3d10_effect_variable *variable, void *data, BOOL transpose) +{ + char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + + read_matrix_from_cbuffer(variable, (float *)cbuf, data); + + if (transpose) + transpose_matrix(data); +} + +static void read_matrix_variable_array_from_cbuffer(struct d3d10_effect_variable *variable, void *data, UINT offset, + UINT count, BOOL transpose) +{ + char *cbuf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + D3DMATRIX *input_data = data; + UINT i; + + if (offset) + cbuf += variable->type->stride * offset; + + for (i = 0; i < count; i++) + { + read_matrix_from_cbuffer(variable, (float *)cbuf, &input_data[i]); + + if (transpose) + transpose_matrix(&input_data[i]); + + cbuf += variable->type->stride; + } +} + /* ID3D10EffectVariable methods */
static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface) @@ -5195,9 +5252,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10Ef static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface, float *data) { - FIXME("iface %p, data %p stub!\n", iface, data); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p.\n", iface, data); + read_matrix_variable_from_cbuffer(effect_var, data, FALSE); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface, @@ -5214,9 +5274,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface, float *data, UINT offset, UINT count) { - FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count); + read_matrix_variable_array_from_cbuffer(effect_var, data, offset, count, FALSE); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface, @@ -5235,9 +5298,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface, float *data) { - FIXME("iface %p, data %p stub!\n", iface, data); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p.\n", iface, data); + read_matrix_variable_from_cbuffer(effect_var, data, TRUE); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface, @@ -5254,9 +5320,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface, float *data, UINT offset, UINT count) { - FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count); + read_matrix_variable_array_from_cbuffer(effect_var, data, offset, count, TRUE); + + return S_OK; }
Implement the SetResource method for the ID3D10EffectShaderResourceVariable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/d3d10_private.h | 6 ++++ dlls/d3d10/effect.c | 71 +++++++++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 5c6c7a2d72..f3b4e65e1c 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -114,6 +114,11 @@ struct d3d10_effect_state_object_variable } object; };
+struct d3d10_effect_resource_variable +{ + ID3D10ShaderResourceView **resource_view; +}; + struct d3d10_effect_buffer_variable { ID3D10Buffer *buffer; @@ -179,6 +184,7 @@ struct d3d10_effect_variable struct d3d10_effect_state_object_variable state; struct d3d10_effect_shader_variable shader; struct d3d10_effect_buffer_variable buffer; + struct d3d10_effect_resource_variable resource; } u; };
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 1e1d5d7f4c..9898b7f79f 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1994,6 +1994,19 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size, case D3D10_SVT_TEXTURE2DMSARRAY: case D3D10_SVT_TEXTURE3D: case D3D10_SVT_TEXTURECUBE: + TRACE("SVT could not have elements.\n"); + if (!v->type->element_count) + i = 1; + else + i = v->type->element_count; + + if (!(v->u.resource.resource_view = heap_calloc(i, sizeof(ID3D10ShaderResourceView *)))) + { + ERR("Failed to allocate shader resource view array memory.\n"); + return E_OUTOFMEMORY; + } + break; + case D3D10_SVT_RENDERTARGETVIEW: case D3D10_SVT_DEPTHSTENCILVIEW: case D3D10_SVT_BUFFER: @@ -2689,6 +2702,31 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v) ID3D10SamplerState_Release(v->u.state.object.sampler); break;
+ case D3D10_SVT_TEXTURE1D: + case D3D10_SVT_TEXTURE1DARRAY: + case D3D10_SVT_TEXTURE2D: + case D3D10_SVT_TEXTURE2DARRAY: + case D3D10_SVT_TEXTURE2DMS: + case D3D10_SVT_TEXTURE2DMSARRAY: + case D3D10_SVT_TEXTURE3D: + case D3D10_SVT_TEXTURECUBE: + if (!v->type->element_count) + { + if (*v->u.resource.resource_view) + ID3D10ShaderResourceView_Release(*v->u.resource.resource_view); + } + else + { + for (i = 0; i < v->type->element_count; i++) + { + if (v->u.resource.resource_view[i]) + ID3D10ShaderResourceView_Release(v->u.resource.resource_view[i]); + + } + } + heap_free(v->u.resource.resource_view); + break; + default: break; } @@ -5731,9 +5769,19 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetRawVal static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResource( ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView *resource) { - FIXME("iface %p, resource %p stub!\n", iface, resource); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
- return E_NOTIMPL; + TRACE("iface %p, resource %p.\n", iface, resource); + + if (*effect_var->u.resource.resource_view) + ID3D10ShaderResourceView_Release(*effect_var->u.resource.resource_view); + + if (resource) + ID3D10ShaderResourceView_AddRef(resource); + + *effect_var->u.resource.resource_view = resource; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResource( @@ -5747,9 +5795,24 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResour static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResourceArray( ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count) { - FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count); + struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface); + UINT i;
- return E_NOTIMPL; + TRACE("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count); + + if (!effect_var->type->element_count) + return d3d10_effect_shader_resource_variable_SetResource(iface, *resources); + + for (i = 0; i < count; i++) + { + if (effect_var->u.resource.resource_view[i + offset]) + ID3D10ShaderResourceView_Release(effect_var->u.resource.resource_view[i + offset]); + if (resources[i]) + ID3D10ShaderResourceView_AddRef(resources[i]); + effect_var->u.resource.resource_view[i + offset] = resources[i]; + } + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResourceArray(
On Sat, Dec 7, 2019 at 7:24 PM Connor McAdams conmanx360@gmail.com wrote:
Implement the SetResource method for the ID3D10EffectShaderResourceVariable interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/d3d10_private.h | 6 ++++ dlls/d3d10/effect.c | 71 +++++++++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 5c6c7a2d72..f3b4e65e1c 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -114,6 +114,11 @@ struct d3d10_effect_state_object_variable } object; };
+struct d3d10_effect_resource_variable +{
- ID3D10ShaderResourceView **resource_view;
+};
struct d3d10_effect_buffer_variable { ID3D10Buffer *buffer; @@ -179,6 +184,7 @@ struct d3d10_effect_variable struct d3d10_effect_state_object_variable state; struct d3d10_effect_shader_variable shader; struct d3d10_effect_buffer_variable buffer;
} u;struct d3d10_effect_resource_variable resource;
};
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 1e1d5d7f4c..9898b7f79f 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1994,6 +1994,19 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size, case D3D10_SVT_TEXTURE2DMSARRAY: case D3D10_SVT_TEXTURE3D: case D3D10_SVT_TEXTURECUBE:
TRACE("SVT could not have elements.\n");
That trace doesn't seem to apply. I guess it's an accidental copypaste of the similar one below (not visible in the patch).
if (!v->type->element_count)
i = 1;
else
i = v->type->element_count;
if (!(v->u.resource.resource_view = heap_calloc(i, sizeof(ID3D10ShaderResourceView *))))
{
ERR("Failed to allocate shader resource view array memory.\n");
return E_OUTOFMEMORY;
}
break;
case D3D10_SVT_RENDERTARGETVIEW: case D3D10_SVT_DEPTHSTENCILVIEW: case D3D10_SVT_BUFFER:
@@ -2689,6 +2702,31 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v) ID3D10SamplerState_Release(v->u.state.object.sampler); break;
case D3D10_SVT_TEXTURE1D:
case D3D10_SVT_TEXTURE1DARRAY:
case D3D10_SVT_TEXTURE2D:
case D3D10_SVT_TEXTURE2DARRAY:
case D3D10_SVT_TEXTURE2DMS:
case D3D10_SVT_TEXTURE2DMSARRAY:
case D3D10_SVT_TEXTURE3D:
case D3D10_SVT_TEXTURECUBE:
if (!v->type->element_count)
{
if (*v->u.resource.resource_view)
ID3D10ShaderResourceView_Release(*v->u.resource.resource_view);
}
else
{
for (i = 0; i < v->type->element_count; i++)
{
if (v->u.resource.resource_view[i])
ID3D10ShaderResourceView_Release(v->u.resource.resource_view[i]);
}
}
I think it would be cleaner to use the for loop in the else branch for element_count == 0, fixing up the iteration count accordingly (like you do in parse_fx10_local_variable() above).
Get the resources that the shader will need to be bound for use by searching the effect framework buffers + local variables.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/d3d10_private.h | 12 ++++++ dlls/d3d10/effect.c | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index f3b4e65e1c..87e506d668 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -76,6 +76,15 @@ struct d3d10_effect_object } object; };
+struct d3d10_effect_shader_resource +{ + D3D10_SHADER_INPUT_TYPE in_type; + UINT bind_point; + UINT bind_count; + + struct d3d10_effect_variable *resource_variable; +}; + struct d3d10_effect_shader_signature { char *signature; @@ -94,6 +103,9 @@ struct d3d10_effect_shader_variable ID3D10PixelShader *ps; ID3D10GeometryShader *gs; } shader; + + UINT resources; + struct d3d10_effect_shader_resource *shader_resource; };
struct d3d10_effect_state_object_variable diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 9898b7f79f..df95724f95 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -657,6 +657,82 @@ static HRESULT shader_chunk_handler(const char *data, DWORD data_size, DWORD tag return S_OK; }
+static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const void *data, size_t data_size) +{ + struct d3d10_effect_variable *tmp; + struct d3d10_effect_shader_variable *shader_var = &v->u.shader; + ID3D10ShaderReflection *reflector; + D3D10_SHADER_DESC desc; + D3D10_SHADER_INPUT_BIND_DESC rsrc_desc; + unsigned int i, y; + HRESULT hr; + + hr = D3D10ReflectShader(data, data_size, &reflector); + if (FAILED(hr)) return hr; + + reflector->lpVtbl->GetDesc(reflector, &desc); + shader_var->resources = desc.BoundResources; + + if (!(shader_var->shader_resource = heap_calloc(shader_var->resources, sizeof(struct d3d10_effect_shader_resource)))) + { + ERR("Failed to allocate shader resource binding information memory.\n"); + hr = E_OUTOFMEMORY; + goto exit; + } + + for (i = 0; i < desc.BoundResources; i++) + { + reflector->lpVtbl->GetResourceBindingDesc(reflector, i, &rsrc_desc); + shader_var->shader_resource[i].in_type = rsrc_desc.Type; + shader_var->shader_resource[i].bind_point = rsrc_desc.BindPoint; + shader_var->shader_resource[i].bind_count = rsrc_desc.BindCount; + + switch (rsrc_desc.Type) + { + case D3D10_SIT_CBUFFER: + case D3D10_SIT_TBUFFER: + for (y = 0; y < v->effect->local_buffer_count; y++) + { + tmp = &v->effect->local_buffers[y]; + + if (tmp->name && !strcmp(rsrc_desc.Name, tmp->name)) + { + shader_var->shader_resource[i].resource_variable = tmp; + break; + } + } + break; + case D3D10_SIT_SAMPLER: + case D3D10_SIT_TEXTURE: + for (y = 0; y < v->effect->local_variable_count; y++) + { + tmp = &v->effect->local_variables[y]; + + if (tmp->name && !strcmp(rsrc_desc.Name, tmp->name)) + { + shader_var->shader_resource[i].resource_variable = tmp; + break; + } + } + break; + default: + break; + } + + if (!shader_var->shader_resource[i].resource_variable) + { + ERR("Failed to find shader resource.\n"); + hr = E_FAIL; + goto exit; + } + } + +exit: + reflector->lpVtbl->Release(reflector); + + return hr; +} + static HRESULT parse_fx10_shader(const char *data, size_t data_size, DWORD offset, struct d3d10_effect_variable *v) { ID3D10Device *device = v->effect->device; @@ -692,6 +768,9 @@ static HRESULT parse_fx10_shader(const char *data, size_t data_size, DWORD offse /* We got a shader VertexShader vs = NULL, so it is fine to skip this. */ if (!dxbc_size) return S_OK;
+ hr = get_fx10_shader_resources(v, (const void *)ptr, dxbc_size); + if (FAILED(hr)) return hr; + switch (v->type->basetype) { case D3D10_SVT_VERTEXSHADER: @@ -2635,6 +2714,9 @@ static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_vari FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type)); break; } + + if (s->resources) + heap_free(s->shader_resource); }
static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
On Sat, Dec 7, 2019 at 7:24 PM Connor McAdams conmanx360@gmail.com wrote:
Get the resources that the shader will need to be bound for use by searching the effect framework buffers + local variables.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/d3d10_private.h | 12 ++++++ dlls/d3d10/effect.c | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index f3b4e65e1c..87e506d668 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -76,6 +76,15 @@ struct d3d10_effect_object } object; };
+struct d3d10_effect_shader_resource +{
- D3D10_SHADER_INPUT_TYPE in_type;
- UINT bind_point;
- UINT bind_count;
- struct d3d10_effect_variable *resource_variable;
+};
struct d3d10_effect_shader_signature { char *signature; @@ -94,6 +103,9 @@ struct d3d10_effect_shader_variable ID3D10PixelShader *ps; ID3D10GeometryShader *gs; } shader;
- UINT resources;
We would usually call that "resource_count".
- struct d3d10_effect_shader_resource *shader_resource;
};
struct d3d10_effect_state_object_variable diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 9898b7f79f..df95724f95 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -657,6 +657,82 @@ static HRESULT shader_chunk_handler(const char *data, DWORD data_size, DWORD tag return S_OK; }
+static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const void *data, size_t data_size) +{
- struct d3d10_effect_variable *tmp;
You can probably just call it "var".
- struct d3d10_effect_shader_variable *shader_var = &v->u.shader;
- ID3D10ShaderReflection *reflector;
- D3D10_SHADER_DESC desc;
- D3D10_SHADER_INPUT_BIND_DESC rsrc_desc;
- unsigned int i, y;
- HRESULT hr;
- hr = D3D10ReflectShader(data, data_size, &reflector);
- if (FAILED(hr)) return hr;
- reflector->lpVtbl->GetDesc(reflector, &desc);
- shader_var->resources = desc.BoundResources;
- if (!(shader_var->shader_resource = heap_calloc(shader_var->resources, sizeof(struct d3d10_effect_shader_resource))))
sizeof(*shader_var->resources)
Apply resources that are used by the shaders within the effect pass.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- 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]);
On Sat, Dec 7, 2019 at 7:24 PM Connor McAdams conmanx360@gmail.com wrote:
Apply resources that are used by the shaders within the effect pass.
Signed-off-by: Connor McAdams conmanx360@gmail.com
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)
Maybe update_buffer()? I think it makes sense to move the changed check into the function too, but I don't feel strongly about it.
On Sat, Dec 7, 2019 at 7:23 PM Connor McAdams conmanx360@gmail.com wrote:
Patch series to implement the functions that are used by steam big picture mode. Submitting for feedback/ideas on how to improve/change things.
Connor McAdams (10): d3d10: Allocate buffers for effect interface local_buffers. d3d10: Implement scalar effect variable set methods. d3d10: Implement scalar effect variable get methods. d3d10: Implement vector effect variable set methods. d3d10: Implement vector effect variable get methods. d3d10: Implement matrix effect variable set methods. d3d10: Implement matrix effect variable get methods. d3d10: Implement ShaderResource effect variable set method. d3d10: Get resources used by effect shaders. d3d10: Apply shader resources for shaders used in pass.
dlls/d3d10/d3d10_private.h | 28 ++ dlls/d3d10/effect.c | 758 +++++++++++++++++++++++++++++++++---- 2 files changed, 718 insertions(+), 68 deletions(-)
First of all, sorry for replying so late, I kept deferring this review for various (none of them particularly good) reasons :/
I think this patch series looks pretty good. I'm okay with the general structure and I only have mostly minor comments (which I'm going to list by replying to the individual patches). I think you can update and resend now that Wine 5.0 is out. Probably better if in chunks of ~5 patches per day at most, as usual.