Create ID3D10Buffer interfaces for the constant buffers within the effect shader.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- v4: Add tests for Scalar/Vector array set/get offset arguments, instead of previously where it was just one of the two.
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 | 95 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index b62b7c0d3a..be5c28496e 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4212,8 +4212,54 @@ 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 offset, + 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; + } + + if (offset >= variable->type->element_count) + return; + + if (count > variable->type->element_count - offset) + count = variable->type->element_count - offset; + + element_size = variable->type->elementtype->size_packed; + if (offset) + buf += variable->type->stride * offset; + + 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 +4416,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 +4432,22 @@ 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. Testing has revealed that this is + * true for Scalar variables, but not for vectors. So, in the case of + * Scalar variables, just pass 0 as the offset argument of + * write_variable_array_to_buffer. + */ 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, 0, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface, @@ -4402,9 +4461,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 +4480,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, 0, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface, @@ -4434,9 +4499,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 +4518,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, 0, 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 | 79 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index be5c28496e..834d4346de 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4253,6 +4253,43 @@ 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 offset, + 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; + } + + if (offset >= variable->type->element_count) + return; + + if (count > variable->type->element_count - offset) + count = variable->type->element_count - offset; + + element_size = variable->type->elementtype->size_packed; + if (offset) + buf += variable->type->stride * offset; + + 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) @@ -4427,9 +4464,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; }
/* @@ -4453,9 +4493,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, 0, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface, @@ -4472,9 +4515,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, @@ -4491,9 +4537,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, 0, count); + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface, @@ -4510,9 +4559,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, @@ -4529,9 +4581,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, 0, 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 834d4346de..c488eb5ef1 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4634,6 +4634,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); @@ -4790,25 +4795,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, @@ -4838,25 +4852,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, offset, 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, offset, 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, offset, 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 c488eb5ef1..93be257b81 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -4828,25 +4828,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, @@ -4885,25 +4894,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, offset, 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, offset, 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, offset, count); + + return S_OK; }
static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
Add tests for the ID3D10EffectScalarVariable and ID3D10EffectVectorVariable set/get functions.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- v4: Add tests for Scalar/Vector array set/get offset arguments, instead of previously where it was just one of the two.
dlls/d3d10/tests/effect.c | 369 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 369 insertions(+)
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index e2b27cf0c8..0848f34045 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -4273,6 +4273,373 @@ static void test_effect_state_group_defaults(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+/* + * test_effect_scalar_variable + */ +#if 0 +cbuffer cb +{ + float f0, f_a[2]; + int i0, i_a[2]; + bool b0, b_a[2]; +}; +#endif +static DWORD fx_test_scalar_variable[] = +{ + 0x43425844, 0xe4da4aa6, 0x1380ddc5, 0x445edad5, + 0x08581666, 0x00000001, 0x0000020b, 0x00000001, + 0x00000024, 0x30315846, 0x000001df, 0xfeff1001, + 0x00000001, 0x00000006, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x000000d3, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x66006263, + 0x74616f6c, 0x00000700, 0x00000100, 0x00000000, + 0x00000400, 0x00001000, 0x00000400, 0x00090900, + 0x00306600, 0x00000007, 0x00000001, 0x00000002, + 0x00000014, 0x00000010, 0x00000008, 0x00000909, + 0x00615f66, 0x00746e69, 0x0000004c, 0x00000001, + 0x00000000, 0x00000004, 0x00000010, 0x00000004, + 0x00000911, 0x4c003069, 0x01000000, 0x02000000, + 0x14000000, 0x10000000, 0x08000000, 0x11000000, + 0x69000009, 0x6200615f, 0x006c6f6f, 0x0000008f, + 0x00000001, 0x00000000, 0x00000004, 0x00000010, + 0x00000004, 0x00000921, 0x8f003062, 0x01000000, + 0x02000000, 0x14000000, 0x10000000, 0x08000000, + 0x21000000, 0x62000009, 0x0400615f, 0x70000000, + 0x00000000, 0x06000000, 0xff000000, 0x00ffffff, + 0x29000000, 0x0d000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x48000000, + 0x2c000000, 0x00000000, 0x10000000, 0x00000000, + 0x00000000, 0x00000000, 0x6c000000, 0x50000000, + 0x00000000, 0x24000000, 0x00000000, 0x00000000, + 0x00000000, 0x8b000000, 0x6f000000, 0x00000000, + 0x30000000, 0x00000000, 0x00000000, 0x00000000, + 0xb0000000, 0x94000000, 0x00000000, 0x44000000, + 0x00000000, 0x00000000, 0x00000000, 0xcf000000, + 0xb3000000, 0x00000000, 0x50000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, +}; + +static void test_effect_scalar_variable(void) +{ + ID3D10Device *device; + ID3D10Effect *effect; + ID3D10EffectVariable *var; + ID3D10EffectType *type; + ID3D10EffectScalarVariable *f0, *f_a, *i0, *i_a, *b0, *b_a; + float f0_ret, f_a_ret[2], f_a_set[2]; + int i0_ret, i_a_ret[2], i_a_set[2]; + BOOL b0_ret, b_a_ret[2], b_a_set[2]; + D3D10_EFFECT_TYPE_DESC type_desc; + ULONG refcount; + HRESULT hr; + unsigned int i; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + hr = create_effect(fx_test_scalar_variable, 0, device, NULL, &effect); + ok(SUCCEEDED(hr), "D3D10CreateEffectFromMemory failed (%x)\n", hr); + + /* Check each different scalar type, make sure the variable returned is + * valid, set it to a value, and make sure what we get back is the same + * as what we set it to. */ + + /* Scalar floating point variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "f0"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_FLOAT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_FLOAT); + f0 = var->lpVtbl->AsScalar(var); + + f0->lpVtbl->SetFloat(f0, 5.0f); + f0->lpVtbl->GetFloat(f0, &f0_ret); + ok(f0_ret == 5.0f, "f0 is %f, expected %f.\n", f0_ret, 5.0f); + + /* Scalar floating point array variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "f_a"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_FLOAT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_FLOAT); + f_a = var->lpVtbl->AsScalar(var); + + f_a_set[0] = 10.0f; f_a_set[1] = 20.0f; + f_a->lpVtbl->SetFloatArray(f_a, f_a_set, 0, 2); + f_a->lpVtbl->GetFloatArray(f_a, f_a_ret, 0, 2); + for (i = 0; i < 2; i++) + ok(f_a_ret[i] == f_a_set[i], "f_a_ret[%d] is %f, expected %f.\n", i, f_a_ret[i], f_a_set[i]); + + /* Scalar int variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "i0"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_INT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_INT); + i0 = var->lpVtbl->AsScalar(var); + + i0->lpVtbl->SetInt(i0, 2); + i0->lpVtbl->GetInt(i0, &i0_ret); + ok(i0_ret == 2, "i0 is %d, expected %d.\n", i0_ret, 2); + + /* Scalar int array variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "i_a"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_INT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_INT); + i_a = var->lpVtbl->AsScalar(var); + + i_a_set[0] = 5; i_a_set[1] = 6; + i_a->lpVtbl->SetIntArray(i_a, i_a_set, 0, 2); + i_a->lpVtbl->GetIntArray(i_a, i_a_ret, 0, 2); + for (i = 0; i < 2; i++) + ok(i_a_ret[i] == i_a_set[i], "i_a_ret[%d] is %d, expected %d.\n", i, i_a_ret[i], i_a_set[i]); + + /* Scalar bool variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "b0"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_BOOL, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_BOOL); + b0 = var->lpVtbl->AsScalar(var); + + b0->lpVtbl->SetBool(b0, TRUE); + b0->lpVtbl->GetBool(b0, &b0_ret); + ok(b0_ret == TRUE, "b0 is %d, expected %d.\n", b0_ret, TRUE); + + /* Scalar bool array variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "b_a"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_BOOL, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_BOOL); + b_a = var->lpVtbl->AsScalar(var); + + b_a_set[0] = TRUE; b_a_set[1] = FALSE; + b_a->lpVtbl->SetBoolArray(b_a, b_a_set, 0, 2); + b_a->lpVtbl->GetBoolArray(b_a, b_a_ret, 0, 2); + for (i = 0; i < 2; i++) + ok(b_a_ret[i] == b_a_set[i], "b_a_ret[%d] is %d, expected %d.\n", i, b_a_ret[i], b_a_set[i]); + + /* According to MSDN, the offset argument goes unused. Test and make sure + * this is the case. */ + b_a->lpVtbl->SetBoolArray(b_a, b_a_set, 1, 1); + b_a->lpVtbl->GetBoolArray(b_a, b_a_ret, 0, 2); + /* If the offset argument actually worked, b_a_ret[1] should be set + * to TRUE instead of FALSE, having b_a's new values being { TRUE, TRUE }. */ + for (i = 0; i < 2; i++) + ok(b_a_ret[i] == b_a_set[i], "b_a_ret[%d] is %d, expected %d. Offset argument is being used in SetBoolArray.\n", i, b_a_ret[i], b_a_set[i]); + + /* In this case, if offset is used, b_a_ret[0] should be set to TRUE. */ + b_a_set[0] = FALSE; b_a_set[1] = TRUE; + b_a->lpVtbl->SetBoolArray(b_a, b_a_set, 0, 2); + b_a->lpVtbl->GetBoolArray(b_a, b_a_ret, 1, 1); + ok(!b_a_ret[0], "b_a_ret[0] is %d, expected 0. Offset argument is being used in GetBoolArray.\n", b_a_ret[0]); + + effect->lpVtbl->Release(effect); + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + +/* + * test_effect_vector_variable + */ +#if 0 +cbuffer cb +{ + float4 v_f0, v_f_a[2]; + int3 v_i0, v_i_a[3]; + bool2 v_b0, v_b_a[4]; +}; +#endif +static DWORD fx_test_vector_variable[] = +{ + 0x43425844, 0x581ae0ae, 0xa906b020, 0x26bba03e, + 0x5d7dfba2, 0x00000001, 0x0000021a, 0x00000001, + 0x00000024, 0x30315846, 0x000001ee, 0xfeff1001, + 0x00000001, 0x00000006, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x000000e2, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x66006263, + 0x74616f6c, 0x00070034, 0x00010000, 0x00000000, + 0x00100000, 0x00100000, 0x00100000, 0x210a0000, + 0x5f760000, 0x07003066, 0x01000000, 0x02000000, + 0x20000000, 0x10000000, 0x20000000, 0x0a000000, + 0x76000021, 0x615f665f, 0x746e6900, 0x00510033, + 0x00010000, 0x00000000, 0x000c0000, 0x00100000, + 0x000c0000, 0x19120000, 0x5f760000, 0x51003069, + 0x01000000, 0x03000000, 0x2c000000, 0x10000000, + 0x24000000, 0x12000000, 0x76000019, 0x615f695f, + 0x6f6f6200, 0x9900326c, 0x01000000, 0x00000000, + 0x08000000, 0x10000000, 0x08000000, 0x22000000, + 0x76000011, 0x0030625f, 0x00000099, 0x00000001, + 0x00000004, 0x00000038, 0x00000010, 0x00000020, + 0x00001122, 0x5f625f76, 0x00040061, 0x00c00000, + 0x00000000, 0x00060000, 0xffff0000, 0x0000ffff, + 0x002a0000, 0x000e0000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x004b0000, + 0x002f0000, 0x00000000, 0x00100000, 0x00000000, + 0x00000000, 0x00000000, 0x00720000, 0x00560000, + 0x00000000, 0x00300000, 0x00000000, 0x00000000, + 0x00000000, 0x00930000, 0x00770000, 0x00000000, + 0x00400000, 0x00000000, 0x00000000, 0x00000000, + 0x00bb0000, 0x009f0000, 0x00000000, 0x00700000, + 0x00000000, 0x00000000, 0x00000000, 0x00dc0000, + 0x00c00000, 0x00000000, 0x00800000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, +}; + +static void test_effect_vector_variable(void) +{ + ID3D10Device *device; + ID3D10Effect *effect; + ID3D10EffectVariable *var; + ID3D10EffectType *type; + ID3D10EffectVectorVariable *v_f0, *v_f_a, *v_i0, *v_i_a, *v_b0, *v_b_a; + float v_f0_ret[4], v_f_a_ret[8], v_f0_set[4], v_f_a_set[8]; + int v_i0_ret[3], v_i_a_ret[9], v_i0_set[3], v_i_a_set[9]; + BOOL v_b0_ret[2], v_b_a_ret[8], v_b0_set[2], v_b_a_set[8]; + D3D10_EFFECT_TYPE_DESC type_desc; + ULONG refcount; + HRESULT hr; + unsigned int i; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + hr = create_effect(fx_test_vector_variable, 0, device, NULL, &effect); + ok(SUCCEEDED(hr), "D3D10CreateEffectFromMemory failed (%x)\n", hr); + + /* Same as above test, except this time with vector variables. */ + + /* Vector floating point variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "v_f0"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_FLOAT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_FLOAT); + v_f0 = var->lpVtbl->AsVector(var); + + v_f0_set[0] = 1.0f; v_f0_set[1] = 3.0f; v_f0_set[2] = 5.0f; v_f0_set[3] = 7.0f; + v_f0->lpVtbl->SetFloatVector(v_f0, v_f0_set); + v_f0->lpVtbl->GetFloatVector(v_f0, v_f0_ret); + for (i = 0; i < 4; i++) + ok(v_f0_ret[i] == v_f0_set[i], "v_f0_ret[%d] is %f, expected %f.\n", i, v_f0_ret[i], v_f0_set[i]); + + /* Vector floating point array variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "v_f_a"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_FLOAT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_FLOAT); + v_f_a = var->lpVtbl->AsVector(var); + + v_f_a_set[0] = 5.0f; v_f_a_set[1] = 10.0f; v_f_a_set[2] = 15.0f; v_f_a_set[3] = 20.0f; + v_f_a_set[4] = 25.0f; v_f_a_set[5] = 30.0f; v_f_a_set[6] = 35.0f; v_f_a_set[7] = 40.0f; + v_f_a->lpVtbl->SetFloatVectorArray(v_f_a, v_f_a_set, 0, 2); + v_f_a->lpVtbl->GetFloatVectorArray(v_f_a, v_f_a_ret, 0, 2); + for (i = 0; i < 8; i++) + ok(v_f_a_ret[i] == v_f_a_set[i], "v_f_a_ret[%d] is %f, expected %f.\n", i, v_f_a_ret[i], v_f_a_set[i]); + + /* Vector int variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "v_i0"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_INT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_INT); + v_i0 = var->lpVtbl->AsVector(var); + + v_i0_set[0] = 1; v_i0_set[1] = 3; v_i0_set[2] = 5; + v_i0->lpVtbl->SetIntVector(v_i0, v_i0_set); + v_i0->lpVtbl->GetIntVector(v_i0, v_i0_ret); + for (i = 0; i < 3; i++) + ok(v_i0_ret[i] == v_i0_set[i], "v_i0_ret[%d] is %d, expected %d.\n", i, v_i0_ret[i], v_i0_set[i]); + + /* Vector int array variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "v_i_a"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_INT, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_INT); + v_i_a = var->lpVtbl->AsVector(var); + + v_i_a_set[0] = 1; v_i_a_set[1] = 3; v_i_a_set[2] = 5; + v_i_a_set[3] = 7; v_i_a_set[4] = 9; v_i_a_set[5] = 11; + v_i_a_set[6] = 13; v_i_a_set[7] = 15; v_i_a_set[8] = 17; + v_i_a->lpVtbl->SetIntVectorArray(v_i_a, v_i_a_set, 0, 3); + v_i_a->lpVtbl->GetIntVectorArray(v_i_a, v_i_a_ret, 0, 3); + for (i = 0; i < 9; i++) + ok(v_i_a_ret[i] == v_i_a_set[i], "v_i_a_ret[%d] is %d, expected %d.\n", i, v_i_a_ret[i], v_i_a_set[i]); + + /* Vector bool variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "v_b0"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_BOOL, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_BOOL); + v_b0 = var->lpVtbl->AsVector(var); + + v_b0_set[0] = TRUE; v_b0_set[1] = FALSE; + v_b0->lpVtbl->SetBoolVector(v_b0, v_b0_set); + v_b0->lpVtbl->GetBoolVector(v_b0, v_b0_ret); + for (i = 0; i < 2; i++) + ok(v_b0_ret[i] == v_b0_set[i], "v_b0_ret[%d] is %d, expected %d.\n", i, v_b0_ret[i], v_b0_set[i]); + + /* Vector bool array variable. */ + var = effect->lpVtbl->GetVariableByName(effect, "v_b_a"); + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + ok(type_desc.Type == D3D10_SVT_BOOL, "Type is %x, expected %x\n", type_desc.Type, D3D10_SVT_BOOL); + v_b_a = var->lpVtbl->AsVector(var); + + v_b_a_set[0] = TRUE; v_b_a_set[1] = FALSE; + v_b_a_set[2] = FALSE; v_b_a_set[3] = TRUE; + v_b_a_set[4] = TRUE; v_b_a_set[5] = FALSE; + v_b_a_set[6] = TRUE; v_b_a_set[7] = TRUE; + v_b_a->lpVtbl->SetBoolVectorArray(v_b_a, v_b_a_set, 0, 4); + v_b_a->lpVtbl->GetBoolVectorArray(v_b_a, v_b_a_ret, 0, 4); + for (i = 0; i < 8; i++) + ok(v_b_a_ret[i] == v_b_a_set[i], "v_b_a_ret[%d] is %d, expected %d.\n", i, v_b_a_ret[i], v_b_a_set[i]); + + /* According to MSDN, the offset argument goes unused for VectorArray + * methods, same as the ScalarArray methods. However, testing has shown + * this to not be the case. So, test for the correct behavior here. */ + v_b_a->lpVtbl->GetBoolVectorArray(v_b_a, v_b_a_ret, 2, 2); + + /* In this case, with the offset being two bool2 variables, v_b_a_ret[0] + * through v_b_a_ret[3] should be the same as v_b_a_set[4] through + * v_b_a_set[7]. */ + for (i = 0; i < 4; i++) + ok(v_b_a_ret[i] == v_b_a_set[i + 4], "v_b_a_ret[%d] is %d, expected %d.\n", i, v_b_a_ret[i], v_b_a_set[i + 4]); + + v_b_a_set[0] = FALSE; v_b_a_set[1] = FALSE; + v_b_a_set[2] = FALSE; v_b_a_set[3] = FALSE; + v_b_a->lpVtbl->SetBoolVectorArray(v_b_a, v_b_a_set, 2, 2); + v_b_a->lpVtbl->GetBoolVectorArray(v_b_a, v_b_a_ret, 0, 4); + + /* Similar to the GetBoolVectorArray test, v_b_a_ret[4] through + * v_b_a_ret[7] should be the same as v_b_a_set[0] through v_b_a_set[3]. */ + for (i = 0; i < 4; i++) + ok(v_b_a_ret[i + 4] == v_b_a_set[i], "v_b_a_ret[%d] is %d, expected %d.\n", i + 4, v_b_a_ret[i + 4], v_b_a_set[i]); + + effect->lpVtbl->Release(effect); + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + START_TEST(effect) { test_effect_constant_buffer_type(); @@ -4285,4 +4652,6 @@ START_TEST(effect) test_effect_get_variable_by(); test_effect_state_groups(); test_effect_state_group_defaults(); + test_effect_scalar_variable(); + test_effect_vector_variable(); }
On Mon, Feb 17, 2020 at 10:22 PM Connor McAdams conmanx360@gmail.com wrote:
- f0->lpVtbl->SetFloat(f0, 5.0f);
- f0->lpVtbl->GetFloat(f0, &f0_ret);
- ok(f0_ret == 5.0f, "f0 is %f, expected %f.\n", f0_ret, 5.0f);
What happens if you call e.g. SetInt() here? Patch 2/6 suggests that it would "reinterpret" the value as a float rather than convert it (which is what happens in d3dx9 for example). Some quick testing suggests that d3d10 keeps the d3dx9 behavior, so the implementation should be updated accordingly. For reference you can look up set_number() in d3dx9_private.h.
Additional nitpicks: those calls could use an ok() check for the return value; don't print the expected value when it's obvious from the code + failed test line (like in this case).
Didn't even think of that. You're correct, if you use SetInt, and then GetFloat, you'll get the integer value back as a float, and not interpreted as one.
d3dx9_private.h should be useful as a reference, thanks for that.
If I shouldn't print the expected value, should I still print the returned value?
I'll get started on a v5 series soon. Thanks for the review.
On Tue, Feb 25, 2020 at 12:42 PM Matteo Bruni matteo.mystral@gmail.com wrote:
On Mon, Feb 17, 2020 at 10:22 PM Connor McAdams conmanx360@gmail.com wrote:
- f0->lpVtbl->SetFloat(f0, 5.0f);
- f0->lpVtbl->GetFloat(f0, &f0_ret);
- ok(f0_ret == 5.0f, "f0 is %f, expected %f.\n", f0_ret, 5.0f);
What happens if you call e.g. SetInt() here? Patch 2/6 suggests that it would "reinterpret" the value as a float rather than convert it (which is what happens in d3dx9 for example). Some quick testing suggests that d3d10 keeps the d3dx9 behavior, so the implementation should be updated accordingly. For reference you can look up set_number() in d3dx9_private.h.
Additional nitpicks: those calls could use an ok() check for the return value; don't print the expected value when it's obvious from the code + failed test line (like in this case).
On Tue, Feb 25, 2020 at 10:05 PM Connor McAdams conmanx360@gmail.com wrote:
If I shouldn't print the expected value, should I still print the returned value?
Yes, the usual ok() message for this is "Got unexpected value %.8e.\n".