wined3d: Move vertex shader constants to wined3d_state.
This commit is contained in:
parent
dd4aea36c9
commit
8a148cc7c5
|
@ -616,9 +616,9 @@ static inline void shader_arb_vs_local_constants(IWineD3DDeviceImpl* deviceImpl)
|
|||
if(gl_shader->int_consts[i] != WINED3D_CONST_NUM_UNUSED)
|
||||
{
|
||||
float val[4];
|
||||
val[0] = (float) stateBlock->vertexShaderConstantI[4 * i];
|
||||
val[1] = (float) stateBlock->vertexShaderConstantI[4 * i + 1];
|
||||
val[2] = (float) stateBlock->vertexShaderConstantI[4 * i + 2];
|
||||
val[0] = (float)stateBlock->state.vs_consts_i[4 * i];
|
||||
val[1] = (float)stateBlock->state.vs_consts_i[4 * i + 1];
|
||||
val[2] = (float)stateBlock->state.vs_consts_i[4 * i + 2];
|
||||
val[3] = -1.0f;
|
||||
|
||||
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->int_consts[i], val));
|
||||
|
@ -646,7 +646,7 @@ static void shader_arb_load_constants(const struct wined3d_context *context, cha
|
|||
|
||||
/* Load DirectX 9 float constants for vertex shader */
|
||||
device->highest_dirty_vs_const = shader_arb_load_constantsF(vshader, gl_info, GL_VERTEX_PROGRAM_ARB,
|
||||
device->highest_dirty_vs_const, stateBlock->vertexShaderConstantF, context->vshader_const_dirty);
|
||||
device->highest_dirty_vs_const, stateBlock->state.vs_consts_f, context->vshader_const_dirty);
|
||||
shader_arb_vs_local_constants(device);
|
||||
}
|
||||
|
||||
|
@ -4481,7 +4481,8 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW
|
|||
/* TODO: Figure out if it would be better to store bool constants as bitmasks in the stateblock */
|
||||
for(i = 0; i < MAX_CONST_B; i++)
|
||||
{
|
||||
if(stateblock->vertexShaderConstantB[i]) args->clip.boolclip.bools |= ( 1 << i);
|
||||
if (stateblock->state.vs_consts_b[i])
|
||||
args->clip.boolclip.bools |= ( 1 << i);
|
||||
}
|
||||
|
||||
args->vertex.samplers[0] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 0];
|
||||
|
@ -4508,9 +4509,9 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW
|
|||
}
|
||||
else
|
||||
{
|
||||
args->loop_ctrl[i][0] = stateblock->vertexShaderConstantI[i * 4];
|
||||
args->loop_ctrl[i][1] = stateblock->vertexShaderConstantI[i * 4 + 1];
|
||||
args->loop_ctrl[i][2] = stateblock->vertexShaderConstantI[i * 4 + 2];
|
||||
args->loop_ctrl[i][0] = stateblock->state.vs_consts_i[i * 4];
|
||||
args->loop_ctrl[i][1] = stateblock->state.vs_consts_i[i * 4 + 1];
|
||||
args->loop_ctrl[i][2] = stateblock->state.vs_consts_i[i * 4 + 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3253,7 +3253,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(
|
|||
|
||||
if (!srcData || start >= MAX_CONST_B) return WINED3DERR_INVALIDCALL;
|
||||
|
||||
memcpy(&This->updateStateBlock->vertexShaderConstantB[start], srcData, cnt * sizeof(BOOL));
|
||||
memcpy(&This->updateStateBlock->state.vs_consts_b[start], srcData, cnt * sizeof(BOOL));
|
||||
for (i = 0; i < cnt; i++)
|
||||
TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
|
||||
|
||||
|
@ -3281,7 +3281,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB(
|
|||
if (!dstData || cnt < 0)
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
memcpy(dstData, &This->stateBlock->vertexShaderConstantB[start], cnt * sizeof(BOOL));
|
||||
memcpy(dstData, &This->stateBlock->state.vs_consts_b[start], cnt * sizeof(BOOL));
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
|
@ -3299,7 +3299,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(
|
|||
|
||||
if (!srcData || start >= MAX_CONST_I) return WINED3DERR_INVALIDCALL;
|
||||
|
||||
memcpy(&This->updateStateBlock->vertexShaderConstantI[start * 4], srcData, cnt * sizeof(int) * 4);
|
||||
memcpy(&This->updateStateBlock->state.vs_consts_i[start * 4], srcData, cnt * sizeof(int) * 4);
|
||||
for (i = 0; i < cnt; i++)
|
||||
TRACE("Set INT constant %u to { %d, %d, %d, %d }\n", start + i,
|
||||
srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
|
||||
|
@ -3328,7 +3328,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantI(
|
|||
if (!dstData || ((signed int)MAX_CONST_I - (signed int)start) <= 0)
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
memcpy(dstData, &This->stateBlock->vertexShaderConstantI[start * 4], cnt * sizeof(int) * 4);
|
||||
memcpy(dstData, &This->stateBlock->state.vs_consts_i[start * 4], cnt * sizeof(int) * 4);
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
|
@ -3348,7 +3348,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(
|
|||
if (!srcData || start + count > This->d3d_vshader_constantF || start > This->d3d_vshader_constantF)
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
memcpy(&This->updateStateBlock->vertexShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
|
||||
memcpy(&This->updateStateBlock->state.vs_consts_f[start * 4], srcData, count * sizeof(float) * 4);
|
||||
if(TRACE_ON(d3d)) {
|
||||
for (i = 0; i < count; i++)
|
||||
TRACE("Set FLOAT constant %u to { %f, %f, %f, %f }\n", start + i,
|
||||
|
@ -3382,7 +3382,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(
|
|||
if (!dstData || cnt < 0)
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
memcpy(dstData, &This->stateBlock->vertexShaderConstantF[start * 4], cnt * sizeof(float) * 4);
|
||||
memcpy(dstData, &This->stateBlock->state.vs_consts_f[start * 4], cnt * sizeof(float) * 4);
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -757,15 +757,15 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
|
|||
IWineD3DBaseShaderImpl *vshader = (IWineD3DBaseShaderImpl *)stateBlock->state.vertex_shader;
|
||||
|
||||
/* Load DirectX 9 float constants/uniforms for vertex shader */
|
||||
shader_glsl_load_constantsF(vshader, gl_info, stateBlock->vertexShaderConstantF,
|
||||
shader_glsl_load_constantsF(vshader, gl_info, stateBlock->state.vs_consts_f,
|
||||
prog->vuniformF_locations, &priv->vconst_heap, priv->stack, constant_version);
|
||||
|
||||
/* Load DirectX 9 integer constants/uniforms for vertex shader */
|
||||
shader_glsl_load_constantsI(vshader, gl_info, prog->vuniformI_locations, stateBlock->vertexShaderConstantI,
|
||||
shader_glsl_load_constantsI(vshader, gl_info, prog->vuniformI_locations, stateBlock->state.vs_consts_i,
|
||||
stateBlock->changed.vertexShaderConstantsI & vshader->baseShader.reg_maps.integer_constants);
|
||||
|
||||
/* Load DirectX 9 boolean constants/uniforms for vertex shader */
|
||||
shader_glsl_load_constantsB(vshader, gl_info, programId, stateBlock->vertexShaderConstantB,
|
||||
shader_glsl_load_constantsB(vshader, gl_info, programId, stateBlock->state.vs_consts_b,
|
||||
stateBlock->changed.vertexShaderConstantsB & vshader->baseShader.reg_maps.boolean_constants);
|
||||
|
||||
/* Upload the position fixup params */
|
||||
|
|
|
@ -204,9 +204,9 @@ static HRESULT stateblock_allocate_shader_constants(IWineD3DStateBlockImpl *obje
|
|||
sizeof(BOOL) * device->d3d_pshader_constantF);
|
||||
if (!object->changed.pixelShaderConstantsF) goto fail;
|
||||
|
||||
object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
object->state.vs_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
sizeof(float) * device->d3d_vshader_constantF * 4);
|
||||
if (!object->vertexShaderConstantF) goto fail;
|
||||
if (!object->state.vs_consts_f) goto fail;
|
||||
|
||||
object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
sizeof(BOOL) * device->d3d_vshader_constantF);
|
||||
|
@ -226,7 +226,7 @@ fail:
|
|||
ERR("Failed to allocate memory\n");
|
||||
HeapFree(GetProcessHeap(), 0, object->pixelShaderConstantF);
|
||||
HeapFree(GetProcessHeap(), 0, object->changed.pixelShaderConstantsF);
|
||||
HeapFree(GetProcessHeap(), 0, object->vertexShaderConstantF);
|
||||
HeapFree(GetProcessHeap(), 0, object->state.vs_consts_f);
|
||||
HeapFree(GetProcessHeap(), 0, object->changed.vertexShaderConstantsF);
|
||||
HeapFree(GetProcessHeap(), 0, object->contained_vs_consts_f);
|
||||
HeapFree(GetProcessHeap(), 0, object->contained_ps_consts_f);
|
||||
|
@ -526,7 +526,7 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
|
|||
}
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->vertexShaderConstantF);
|
||||
HeapFree(GetProcessHeap(), 0, This->state.vs_consts_f);
|
||||
HeapFree(GetProcessHeap(), 0, This->changed.vertexShaderConstantsF);
|
||||
HeapFree(GetProcessHeap(), 0, This->pixelShaderConstantF);
|
||||
HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF);
|
||||
|
@ -622,15 +622,15 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||
|
||||
TRACE("Setting %p from %p %u to {%.8e, %.8e, %.8e, %.8e}.\n",
|
||||
This, targetStateBlock, idx,
|
||||
targetStateBlock->vertexShaderConstantF[idx * 4 + 0],
|
||||
targetStateBlock->vertexShaderConstantF[idx * 4 + 1],
|
||||
targetStateBlock->vertexShaderConstantF[idx * 4 + 2],
|
||||
targetStateBlock->vertexShaderConstantF[idx * 4 + 3]);
|
||||
targetStateBlock->state.vs_consts_f[idx * 4 + 0],
|
||||
targetStateBlock->state.vs_consts_f[idx * 4 + 1],
|
||||
targetStateBlock->state.vs_consts_f[idx * 4 + 2],
|
||||
targetStateBlock->state.vs_consts_f[idx * 4 + 3]);
|
||||
|
||||
This->vertexShaderConstantF[idx * 4 + 0] = targetStateBlock->vertexShaderConstantF[idx * 4 + 0];
|
||||
This->vertexShaderConstantF[idx * 4 + 1] = targetStateBlock->vertexShaderConstantF[idx * 4 + 1];
|
||||
This->vertexShaderConstantF[idx * 4 + 2] = targetStateBlock->vertexShaderConstantF[idx * 4 + 2];
|
||||
This->vertexShaderConstantF[idx * 4 + 3] = targetStateBlock->vertexShaderConstantF[idx * 4 + 3];
|
||||
This->state.vs_consts_f[idx * 4 + 0] = targetStateBlock->state.vs_consts_f[idx * 4 + 0];
|
||||
This->state.vs_consts_f[idx * 4 + 1] = targetStateBlock->state.vs_consts_f[idx * 4 + 1];
|
||||
This->state.vs_consts_f[idx * 4 + 2] = targetStateBlock->state.vs_consts_f[idx * 4 + 2];
|
||||
This->state.vs_consts_f[idx * 4 + 3] = targetStateBlock->state.vs_consts_f[idx * 4 + 3];
|
||||
}
|
||||
|
||||
/* Vertex Shader Integer Constants */
|
||||
|
@ -640,15 +640,15 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||
|
||||
TRACE("Setting %p from %p %u to {%d, %d, %d, %d}.\n",
|
||||
This, targetStateBlock, idx,
|
||||
targetStateBlock->vertexShaderConstantI[idx * 4 + 0],
|
||||
targetStateBlock->vertexShaderConstantI[idx * 4 + 1],
|
||||
targetStateBlock->vertexShaderConstantI[idx * 4 + 2],
|
||||
targetStateBlock->vertexShaderConstantI[idx * 4 + 3]);
|
||||
targetStateBlock->state.vs_consts_i[idx * 4 + 0],
|
||||
targetStateBlock->state.vs_consts_i[idx * 4 + 1],
|
||||
targetStateBlock->state.vs_consts_i[idx * 4 + 2],
|
||||
targetStateBlock->state.vs_consts_i[idx * 4 + 3]);
|
||||
|
||||
This->vertexShaderConstantI[idx * 4 + 0] = targetStateBlock->vertexShaderConstantI[idx * 4 + 0];
|
||||
This->vertexShaderConstantI[idx * 4 + 1] = targetStateBlock->vertexShaderConstantI[idx * 4 + 1];
|
||||
This->vertexShaderConstantI[idx * 4 + 2] = targetStateBlock->vertexShaderConstantI[idx * 4 + 2];
|
||||
This->vertexShaderConstantI[idx * 4 + 3] = targetStateBlock->vertexShaderConstantI[idx * 4 + 3];
|
||||
This->state.vs_consts_i[idx * 4 + 0] = targetStateBlock->state.vs_consts_i[idx * 4 + 0];
|
||||
This->state.vs_consts_i[idx * 4 + 1] = targetStateBlock->state.vs_consts_i[idx * 4 + 1];
|
||||
This->state.vs_consts_i[idx * 4 + 2] = targetStateBlock->state.vs_consts_i[idx * 4 + 2];
|
||||
This->state.vs_consts_i[idx * 4 + 3] = targetStateBlock->state.vs_consts_i[idx * 4 + 3];
|
||||
}
|
||||
|
||||
/* Vertex Shader Boolean Constants */
|
||||
|
@ -658,9 +658,9 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||
|
||||
TRACE("Setting %p from %p %u to %s.\n",
|
||||
This, targetStateBlock, idx,
|
||||
targetStateBlock->vertexShaderConstantB[idx] ? "TRUE" : "FALSE");
|
||||
targetStateBlock->state.vs_consts_b[idx] ? "TRUE" : "FALSE");
|
||||
|
||||
This->vertexShaderConstantB[idx] = targetStateBlock->vertexShaderConstantB[idx];
|
||||
This->state.vs_consts_b[idx] = targetStateBlock->state.vs_consts_b[idx];
|
||||
}
|
||||
|
||||
/* Pixel Shader Float Constants */
|
||||
|
@ -919,17 +919,17 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
|
|||
for (i = 0; i < This->num_contained_vs_consts_f; ++i)
|
||||
{
|
||||
IWineD3DDevice_SetVertexShaderConstantF(device, This->contained_vs_consts_f[i],
|
||||
This->vertexShaderConstantF + This->contained_vs_consts_f[i] * 4, 1);
|
||||
This->state.vs_consts_f + This->contained_vs_consts_f[i] * 4, 1);
|
||||
}
|
||||
for (i = 0; i < This->num_contained_vs_consts_i; ++i)
|
||||
{
|
||||
IWineD3DDevice_SetVertexShaderConstantI(device, This->contained_vs_consts_i[i],
|
||||
This->vertexShaderConstantI + This->contained_vs_consts_i[i] * 4, 1);
|
||||
This->state.vs_consts_i + This->contained_vs_consts_i[i] * 4, 1);
|
||||
}
|
||||
for (i = 0; i < This->num_contained_vs_consts_b; ++i)
|
||||
{
|
||||
IWineD3DDevice_SetVertexShaderConstantB(device, This->contained_vs_consts_b[i],
|
||||
This->vertexShaderConstantB + This->contained_vs_consts_b[i], 1);
|
||||
This->state.vs_consts_b + This->contained_vs_consts_b[i], 1);
|
||||
}
|
||||
|
||||
apply_lights(device, This);
|
||||
|
|
|
@ -2352,6 +2352,9 @@ struct wined3d_state
|
|||
IWineD3DVertexDeclarationImpl *vertex_declaration;
|
||||
|
||||
struct IWineD3DVertexShaderImpl *vertex_shader;
|
||||
BOOL vs_consts_b[MAX_CONST_B];
|
||||
INT vs_consts_i[MAX_CONST_I * 4];
|
||||
float *vs_consts_f;
|
||||
|
||||
IWineD3DBaseTextureImpl *textures[MAX_COMBINED_SAMPLERS];
|
||||
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
|
||||
|
@ -2380,11 +2383,6 @@ struct IWineD3DStateBlockImpl
|
|||
SAVEDSTATES changed;
|
||||
struct wined3d_state state;
|
||||
|
||||
/* Vertex Shader Constants */
|
||||
BOOL vertexShaderConstantB[MAX_CONST_B];
|
||||
INT vertexShaderConstantI[MAX_CONST_I * 4];
|
||||
float *vertexShaderConstantF;
|
||||
|
||||
/* primitive type */
|
||||
GLenum gl_primitive_type;
|
||||
|
||||
|
|
Loading…
Reference in New Issue