[PATCH 2/3] d3d10: Implement matrix effect variable get methods.
Connor McAdams
conmanx360 at gmail.com
Sun Feb 16 15:01:21 CST 2020
Implement GetMatrix/GetMatrixArray and
GetMatrixTranspose/GetMatrixTransposeArray methods for the matrix effect
variable interface.
Signed-off-by: Connor McAdams <conmanx360 at gmail.com>
---
dlls/d3d10/effect.c | 92 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 84 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c
index 1bc7968499..44f3bfa0ae 100644
--- a/dlls/d3d10/effect.c
+++ b/dlls/d3d10/effect.c
@@ -5041,6 +5041,70 @@ static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable *
variable->buffer->u.buffer.changed = 1;
}
+static void read_matrix_from_buffer(struct d3d10_effect_variable *variable, float *buf,
+ struct d3d10_effect_matrix *matrix, BOOL transpose)
+{
+ unsigned int 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++)
+ {
+ if (transpose)
+ matrix->m[col][row] = buf[(col * 4) + row];
+ else
+ matrix->m[row][col] = buf[(col * 4) + row];
+ }
+ }
+ }
+ else
+ {
+ for (col = 0; col < variable->type->column_count; col++)
+ {
+ for (row = 0; row < variable->type->row_count; row++)
+ {
+ if (transpose)
+ matrix->m[col][row] = buf[(row * 4) + col];
+ else
+ matrix->m[row][col] = buf[(row * 4) + col];
+ }
+ }
+ }
+}
+
+static void read_matrix_variable_from_buffer(struct d3d10_effect_variable *variable, void *data, BOOL transpose)
+{
+ char *buf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
+
+ read_matrix_from_buffer(variable, (float *)buf, data, transpose);
+}
+
+static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *data, UINT offset,
+ UINT count, BOOL transpose)
+{
+ char *buf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
+ struct d3d10_effect_matrix *input_data = data;
+ unsigned int i;
+
+ if (offset >= variable->type->element_count)
+ return;
+
+ if (count > variable->type->element_count - offset)
+ count = variable->type->element_count - offset;
+
+ if (offset)
+ buf += variable->type->stride * offset;
+
+ for (i = 0; i < count; i++)
+ {
+ read_matrix_from_buffer(variable, (float *)buf, &input_data[i], transpose);
+
+ buf += variable->type->stride;
+ }
+}
+
/* ID3D10EffectVariable methods */
static inline struct d3d10_effect_variable *impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable *iface)
@@ -5215,9 +5279,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_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p.\n", iface, data);
+ read_matrix_variable_from_buffer(effect_var, data, FALSE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface,
@@ -5234,9 +5301,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_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
+ read_matrix_variable_array_from_buffer(effect_var, data, offset, count, FALSE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
@@ -5253,9 +5323,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_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p.\n", iface, data);
+ read_matrix_variable_from_buffer(effect_var, data, TRUE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
@@ -5272,9 +5345,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_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
+ read_matrix_variable_array_from_buffer(effect_var, data, offset, count, TRUE);
+
+ return S_OK;
}
--
2.20.1
More information about the wine-devel
mailing list