wined3d: Store multiple constant indices per list entry.
This commit is contained in:
parent
2c85e5e8a3
commit
19d223cade
|
@ -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()");
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue