H. Verbeet : wined3d: Store multiple constant indices per list entry.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Feb 28 08:19:05 CST 2007
Module: wine
Branch: master
Commit: 19d223cadea1956eac0f0f8629c0ce1f7dc7a9b5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=19d223cadea1956eac0f0f8629c0ce1f7dc7a9b5
Author: H. Verbeet <hverbeet at gmail.com>
Date: Tue Feb 27 20:51:58 2007 +0100
wined3d: Store multiple constant indices per list entry.
---
dlls/wined3d/arb_program_shader.c | 29 ++++++++++++++++++---------
dlls/wined3d/device.c | 18 +++++++++++-----
dlls/wined3d/glsl_shader.c | 39 ++++++++++++++++++++++--------------
dlls/wined3d/stateblock.c | 6 ++--
dlls/wined3d/wined3d_private.h | 7 +++--
5 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 083c812..e483033 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -50,21 +50,30 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_constants);
*/
static void shader_arb_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL_Info *gl_info, GLuint target_type,
unsigned int max_constants, float* constants, struct list *constant_list) {
- constant_entry *constant;
+ constants_entry *constant;
local_constant* lconst;
- int i;
+ DWORD i, j;
+ DWORD *idx;
if (TRACE_ON(d3d_shader)) {
- LIST_FOR_EACH_ENTRY(constant, constant_list, constant_entry, entry) {
- i = constant->idx;
- TRACE_(d3d_constants)("Loading constants %i: %f, %f, %f, %f\n", i,
- constants[i * 4 + 0], constants[i * 4 + 1],
- constants[i * 4 + 2], constants[i * 4 + 3]);
+ LIST_FOR_EACH_ENTRY(constant, constant_list, constants_entry, entry) {
+ idx = constant->idx;
+ j = constant->count;
+ while (j--) {
+ i = *idx++;
+ TRACE_(d3d_constants)("Loading constants %i: %f, %f, %f, %f\n", i,
+ constants[i * 4 + 0], constants[i * 4 + 1],
+ constants[i * 4 + 2], constants[i * 4 + 3]);
+ }
}
}
- LIST_FOR_EACH_ENTRY(constant, constant_list, constant_entry, entry) {
- i = constant->idx;
- GL_EXTCALL(glProgramEnvParameter4fvARB(target_type, i, constants + (i * 4)));
+ LIST_FOR_EACH_ENTRY(constant, constant_list, constants_entry, entry) {
+ idx = constant->idx;
+ j = constant->count;
+ while (j--) {
+ i = *idx++;
+ GL_EXTCALL(glProgramEnvParameter4fvARB(target_type, i, constants + (i * 4)));
+ }
}
checkGLcall("glProgramEnvParameter4fvARB()");
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index f73ceb7..94c49fa 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2958,9 +2958,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(
for (i = start; i < count + start; ++i) {
if (!This->updateStateBlock->set.vertexShaderConstantsF[i]) {
- constant_entry *ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(constant_entry));
- ptr->idx = i;
- list_add_head(&This->updateStateBlock->set_vconstantsF, &ptr->entry);
+ constants_entry *ptr = LIST_ENTRY(list_head(&This->updateStateBlock->set_vconstantsF), constants_entry, entry);
+ if (!ptr || ptr->count >= sizeof(ptr->idx) / sizeof(*ptr->idx)) {
+ ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(constants_entry));
+ list_add_head(&This->updateStateBlock->set_vconstantsF, &ptr->entry);
+ }
+ ptr->idx[ptr->count++] = i;
This->updateStateBlock->set.vertexShaderConstantsF[i] = TRUE;
}
This->updateStateBlock->changed.vertexShaderConstantsF[i] = TRUE;
@@ -3238,9 +3241,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF(
for (i = start; i < count + start; ++i) {
if (!This->updateStateBlock->set.pixelShaderConstantsF[i]) {
- constant_entry *ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(constant_entry));
- ptr->idx = i;
- list_add_head(&This->updateStateBlock->set_pconstantsF, &ptr->entry);
+ constants_entry *ptr = LIST_ENTRY(list_head(&This->updateStateBlock->set_pconstantsF), constants_entry, entry);
+ if (!ptr || ptr->count >= sizeof(ptr->idx) / sizeof(*ptr->idx)) {
+ ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(constants_entry));
+ list_add_head(&This->updateStateBlock->set_pconstantsF, &ptr->entry);
+ }
+ ptr->idx[ptr->count++] = i;
This->updateStateBlock->set.pixelShaderConstantsF[i] = TRUE;
}
This->updateStateBlock->changed.pixelShaderConstantsF[i] = TRUE;
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index ae2bf08..64deb4d 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -105,28 +105,37 @@ void shader_glsl_load_psamplers(
static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL_Info *gl_info,
unsigned int max_constants, float* constants, GLhandleARB *constant_locations,
struct list *constant_list) {
- constant_entry *constant;
+ constants_entry *constant;
local_constant* lconst;
GLhandleARB tmp_loc;
- int i;
+ DWORD i, j;
+ DWORD *idx;
if (TRACE_ON(d3d_shader)) {
- LIST_FOR_EACH_ENTRY(constant, constant_list, constant_entry, entry) {
- i = constant->idx;
- tmp_loc = constant_locations[i];
- if (tmp_loc != -1) {
- TRACE_(d3d_constants)("Loading constants %i: %f, %f, %f, %f\n", i,
- constants[i * 4 + 0], constants[i * 4 + 1],
- constants[i * 4 + 2], constants[i * 4 + 3]);
+ LIST_FOR_EACH_ENTRY(constant, constant_list, constants_entry, entry) {
+ idx = constant->idx;
+ j = constant->count;
+ while (j--) {
+ i = *idx++;
+ tmp_loc = constant_locations[i];
+ if (tmp_loc != -1) {
+ TRACE_(d3d_constants)("Loading constants %i: %f, %f, %f, %f\n", i,
+ constants[i * 4 + 0], constants[i * 4 + 1],
+ constants[i * 4 + 2], constants[i * 4 + 3]);
+ }
}
}
}
- LIST_FOR_EACH_ENTRY(constant, constant_list, constant_entry, entry) {
- i = constant->idx;
- tmp_loc = constant_locations[i];
- if (tmp_loc != -1) {
- /* We found this uniform name in the program - go ahead and send the data */
- GL_EXTCALL(glUniform4fvARB(tmp_loc, 1, constants + (i * 4)));
+ LIST_FOR_EACH_ENTRY(constant, constant_list, constants_entry, entry) {
+ idx = constant->idx;
+ j = constant->count;
+ while (j--) {
+ i = *idx++;
+ tmp_loc = constant_locations[i];
+ if (tmp_loc != -1) {
+ /* We found this uniform name in the program - go ahead and send the data */
+ GL_EXTCALL(glUniform4fvARB(tmp_loc, 1, constants + (i * 4)));
+ }
}
}
checkGLcall("glUniform4fvARB()");
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 7622d8e..f9be5e9 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -249,7 +249,7 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
if (!refCount) {
- constant_entry *constant, *constant2;
+ constants_entry *constant, *constant2;
int counter;
/* type 0 represents the primary stateblock, so free all the resources */
@@ -284,11 +284,11 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
HeapFree(GetProcessHeap(), 0, This->set.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF);
- LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_vconstantsF, constant_entry, entry) {
+ LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_vconstantsF, constants_entry, entry) {
HeapFree(GetProcessHeap(), 0, constant);
}
- LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_pconstantsF, constant_entry, entry) {
+ LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_pconstantsF, constants_entry, entry) {
HeapFree(GetProcessHeap(), 0, constant);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index add82a8..dbb8364 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1194,9 +1194,10 @@ typedef struct SAVEDSTATES {
} SAVEDSTATES;
typedef struct {
- struct list entry;
- int idx;
-} constant_entry;
+ struct list entry;
+ DWORD count;
+ DWORD idx[13];
+} constants_entry;
struct IWineD3DStateBlockImpl
{
More information about the wine-cvs
mailing list