[PATCH 03/10] d3d10: Implement scalar effect variable get methods.
Connor McAdams
conmanx360 at gmail.com
Sat Dec 7 12:22:53 CST 2019
Implement GetFloat/GetFloatArray, GetInt/GetIntArray, and
GetBool/GetBoolArray methods for the scalar effect variable interface.
Signed-off-by: Connor McAdams <conmanx360 at 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 =
--
2.20.1
More information about the wine-devel
mailing list