[Mesa-dev] [PATCH 45/84] st/nine: Pass size of memory to nine_state

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:55:18 UTC 2016


From: Patrick Rudolph <siro at das-labor.org>

Required for CSMT.

Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
 src/gallium/state_trackers/nine/device9.c    | 20 ++++++++++++++------
 src/gallium/state_trackers/nine/nine_state.c | 18 ++++++++++++++----
 src/gallium/state_trackers/nine/nine_state.h |  6 ++++++
 3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index b959793..df96e88 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -3240,7 +3240,9 @@ NineDevice9_SetVertexShaderConstantF( struct NineDevice9 *This,
            pConstantData,
            Vector4fCount * 4 * sizeof(state->vs_const_f[0]));
 
-    nine_context_set_vertex_shader_constant_f(This, StartRegister, pConstantData, Vector4fCount);
+    nine_context_set_vertex_shader_constant_f(This, StartRegister, pConstantData,
+                                              Vector4fCount * 4 * sizeof(state->vs_const_f[0]),
+                                              Vector4fCount);
 
     return D3D_OK;
 }
@@ -3306,7 +3308,8 @@ NineDevice9_SetVertexShaderConstantI( struct NineDevice9 *This,
                            &This->range_pool);
         state->changed.group |= NINE_STATE_VS_CONST;
     } else
-        nine_context_set_vertex_shader_constant_i(This, StartRegister, pConstantData, Vector4iCount);
+        nine_context_set_vertex_shader_constant_i(This, StartRegister, pConstantData,
+                                                  Vector4iCount * sizeof(int[4]), Vector4iCount);
 
     return D3D_OK;
 }
@@ -3380,7 +3383,8 @@ NineDevice9_SetVertexShaderConstantB( struct NineDevice9 *This,
                            &This->range_pool);
         state->changed.group |= NINE_STATE_VS_CONST;
     } else
-        nine_context_set_vertex_shader_constant_b(This, StartRegister, pConstantData, BoolCount);
+        nine_context_set_vertex_shader_constant_b(This, StartRegister, pConstantData,
+                                                  sizeof(BOOL) * BoolCount, BoolCount);
 
     return D3D_OK;
 }
@@ -3644,7 +3648,9 @@ NineDevice9_SetPixelShaderConstantF( struct NineDevice9 *This,
            pConstantData,
            Vector4fCount * 4 * sizeof(state->ps_const_f[0]));
 
-    nine_context_set_pixel_shader_constant_f(This, StartRegister, pConstantData, Vector4fCount);
+    nine_context_set_pixel_shader_constant_f(This, StartRegister, pConstantData,
+                                             Vector4fCount * 4 * sizeof(state->ps_const_f[0]),
+                                             Vector4fCount);
 
     return D3D_OK;
 }
@@ -3706,7 +3712,8 @@ NineDevice9_SetPixelShaderConstantI( struct NineDevice9 *This,
         state->changed.ps_const_i |= ((1 << Vector4iCount) - 1) << StartRegister;
         state->changed.group |= NINE_STATE_PS_CONST;
     } else
-        nine_context_set_pixel_shader_constant_i(This, StartRegister, pConstantData, Vector4iCount);
+        nine_context_set_pixel_shader_constant_i(This, StartRegister, pConstantData,
+                                                 sizeof(state->ps_const_i[0]) * Vector4iCount, Vector4iCount);
 
     return D3D_OK;
 }
@@ -3774,7 +3781,8 @@ NineDevice9_SetPixelShaderConstantB( struct NineDevice9 *This,
         state->changed.ps_const_b |= ((1 << BoolCount) - 1) << StartRegister;
         state->changed.group |= NINE_STATE_PS_CONST;
     } else
-        nine_context_set_pixel_shader_constant_b(This, StartRegister, pConstantData, BoolCount);
+        nine_context_set_pixel_shader_constant_b(This, StartRegister, pConstantData,
+                                                 sizeof(BOOL) * BoolCount, BoolCount);
 
     return D3D_OK;
 }
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 9bc6f81..076a959 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1342,6 +1342,7 @@ void
 nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
                                           UINT StartRegister,
                                           const float *pConstantData,
+                                          const unsigned pConstantData_size,
                                           UINT Vector4fCount)
 {
     struct nine_context *context = &device->context;
@@ -1349,7 +1350,7 @@ nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
 
     memcpy(&vs_const_f[StartRegister * 4],
            pConstantData,
-           Vector4fCount * 4 * sizeof(context->vs_const_f[0]));
+           pConstantData_size);
 
     if (device->may_swvp) {
         Vector4fCount = MIN2(StartRegister + Vector4fCount, NINE_MAX_CONST_F) - StartRegister;
@@ -1368,6 +1369,7 @@ void
 nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
                                           UINT StartRegister,
                                           const int *pConstantData,
+                                          const unsigned pConstantData_size,
                                           UINT Vector4iCount)
 {
     struct nine_context *context = &device->context;
@@ -1376,7 +1378,7 @@ nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
     if (device->driver_caps.vs_integer) {
         memcpy(&context->vs_const_i[4 * StartRegister],
                pConstantData,
-               Vector4iCount * sizeof(int[4]));
+               pConstantData_size);
     } else {
         for (i = 0; i < Vector4iCount; i++) {
             context->vs_const_i[4 * (StartRegister + i)] = fui((float)(pConstantData[4 * i]));
@@ -1394,12 +1396,15 @@ void
 nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device,
                                           UINT StartRegister,
                                           const BOOL *pConstantData,
+                                          const unsigned pConstantData_size,
                                           UINT BoolCount)
 {
     struct nine_context *context = &device->context;
     int i;
     uint32_t bool_true = device->driver_caps.vs_integer ? 0xFFFFFFFF : fui(1.0f);
 
+    (void) pConstantData_size;
+
     for (i = 0; i < BoolCount; i++)
         context->vs_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
 
@@ -1434,13 +1439,14 @@ void
 nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device,
                                         UINT StartRegister,
                                         const float *pConstantData,
+                                        const unsigned pConstantData_size,
                                         UINT Vector4fCount)
 {
     struct nine_context *context = &device->context;
 
     memcpy(&context->ps_const_f[StartRegister * 4],
            pConstantData,
-           Vector4fCount * 4 * sizeof(context->ps_const_f[0]));
+           pConstantData_size);
 
     context->changed.ps_const_f = TRUE;
     context->changed.group |= NINE_STATE_PS_CONST;
@@ -1467,6 +1473,7 @@ void
 nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
                                          UINT StartRegister,
                                          const int *pConstantData,
+                                         const unsigned pConstantData_size,
                                          UINT Vector4iCount)
 {
     struct nine_context *context = &device->context;
@@ -1475,7 +1482,7 @@ nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
     if (device->driver_caps.ps_integer) {
         memcpy(&context->ps_const_i[StartRegister][0],
                pConstantData,
-               Vector4iCount * sizeof(context->ps_const_i[0]));
+               pConstantData_size);
     } else {
         for (i = 0; i < Vector4iCount; i++) {
             context->ps_const_i[StartRegister+i][0] = fui((float)(pConstantData[4*i]));
@@ -1492,12 +1499,15 @@ void
 nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
                                          UINT StartRegister,
                                          const BOOL *pConstantData,
+                                         const unsigned pConstantData_size,
                                          UINT BoolCount)
 {
     struct nine_context *context = &device->context;
     int i;
     uint32_t bool_true = device->driver_caps.ps_integer ? 0xFFFFFFFF : fui(1.0f);
 
+    (void) pConstantData_size;
+
     for (i = 0; i < BoolCount; i++)
         context->ps_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
 
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 9e863bc..cd3afed 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -381,18 +381,21 @@ void
 nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
                                           UINT StartRegister,
                                           const float *pConstantData,
+                                          const unsigned pConstantData_size,
                                           UINT Vector4fCount);
 
 void
 nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
                                           UINT StartRegister,
                                           const int *pConstantData,
+                                          const unsigned pConstantData_size,
                                           UINT Vector4iCount);
 
 void
 nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device,
                                           UINT StartRegister,
                                           const BOOL *pConstantData,
+                                          const unsigned pConstantData_size,
                                           UINT BoolCount);
 
 void
@@ -403,18 +406,21 @@ void
 nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device,
                                         UINT StartRegister,
                                         const float *pConstantData,
+                                        const unsigned pConstantData_size,
                                         UINT Vector4fCount);
 
 void
 nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
                                          UINT StartRegister,
                                          const int *pConstantData,
+                                         const unsigned pConstantData_size,
                                          UINT Vector4iCount);
 
 void
 nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
                                          UINT StartRegister,
                                          const BOOL *pConstantData,
+                                         const unsigned pConstantData_size,
                                          UINT BoolCount);
 
 void
-- 
2.10.2



More information about the mesa-dev mailing list