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..b62b7c0d3a 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) + { + 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 */
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 b62b7c0d3a..bb6cfebea6 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4212,8 +4212,45 @@ static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_ d3d10_effect_constant_buffer_GetTextureBuffer, };
+static void write_variable_to_buffer(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_buffer(struct d3d10_effect_variable *variable, void *data, unsigned int count) +{ + char *buf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + char *cur_element = data; + unsigned int element_size, i; + + if (!variable->type->element_count) + { + write_variable_to_buffer(variable, data); + return; + } + + element_size = variable->type->elementtype->size_packed; + + for (i = 0; i < count; i++) + { + memcpy(buf, cur_element, element_size); + + cur_element += element_size; + buf += variable->type->stride; + } + + variable->buffer->u.buffer.changed = 1; +} + /* ID3D10EffectVariable methods */
+static inline struct d3d10_effect_variable *impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface); +} + static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface) { TRACE("iface %p\n", 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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %.8e.\n", iface, value); + write_variable_to_buffer(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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_buffer(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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %d.\n", iface, value); + write_variable_to_buffer(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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_buffer(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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %d.\n", iface, value); + write_variable_to_buffer(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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_buffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface,
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 | 70 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index bb6cfebea6..8b9aa23025 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4244,6 +4244,34 @@ static void write_variable_array_to_buffer(struct d3d10_effect_variable *variabl variable->buffer->u.buffer.changed = 1; }
+static void read_variable_from_buffer(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_buffer(struct d3d10_effect_variable *variable, void *data, unsigned int count) +{ + char *buf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset; + char *cur_element = data; + unsigned int element_size, i; + + if (!variable->type->element_count) + { + read_variable_from_buffer(variable, data); + return; + } + + element_size = variable->type->elementtype->size_packed; + + for (i = 0; i < count; i++) + { + memcpy(cur_element, buf, element_size); + + cur_element += element_size; + buf += variable->type->stride; + } +} + /* ID3D10EffectVariable methods */
static inline struct d3d10_effect_variable *impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable *iface) @@ -4418,9 +4446,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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_buffer(effect_var, value); + + return S_OK; }
/* @@ -4441,9 +4472,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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_buffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface, @@ -4460,9 +4494,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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_buffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface, @@ -4479,9 +4516,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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_buffer(effect_var, values, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface, @@ -4498,9 +4538,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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_buffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface, @@ -4517,9 +4560,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_ID3D10EffectScalarVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_buffer(effect_var, values, count); + + return S_OK; }
static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl =
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 | 47 +++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 8b9aa23025..53056dac93 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4613,6 +4613,11 @@ static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_
/* ID3D10EffectVariable methods */
+static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface); +} + static BOOL STDMETHODCALLTYPE d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable *iface) { TRACE("iface %p\n", iface); @@ -4769,25 +4774,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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + write_variable_to_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + write_variable_to_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + write_variable_to_buffer(effect_var, &value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface, @@ -4817,25 +4831,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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + write_variable_array_to_buffer(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 53056dac93..a73f95eab6 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4807,25 +4807,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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + read_variable_from_buffer(effect_var, value); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface, @@ -4864,25 +4873,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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_buffer(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_ID3D10EffectVectorVariable(iface);
- return E_NOTIMPL; + TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count); + read_variable_array_from_buffer(effect_var, values, count); + + return S_OK; }
static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
I probably should've included tests with this patch set. Originally I was going to test all of the new set functions along with Matrix in one test that also read back the constant buffer into a staging buffer, but I think a better idea is to have write/read tests for each variable type, then a test of reading back the constant buffer.
So I'll send these patches along with a test tomorrow.
On Thu, Feb 13, 2020 at 2:11 PM Connor McAdams conmanx360@gmail.com wrote:
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;
} u;struct d3d10_effect_buffer_variable buffer;
};
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 91e713bdf5..b62b7c0d3a 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)
- {
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 */
2.20.1