Commit 8e37fcd2 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Move applying shader constants to the state table.

parent f2dfbe76
......@@ -3328,6 +3328,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(
This->updateStateBlock->set.vertexShaderConstantsB[i] = TRUE;
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
return WINED3D_OK;
}
......@@ -3375,6 +3377,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(
This->updateStateBlock->set.vertexShaderConstantsI[i] = TRUE;
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
return WINED3D_OK;
}
......@@ -3427,6 +3431,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(
This->updateStateBlock->changed.vertexShaderConstantsF[i] = TRUE;
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
return WINED3D_OK;
}
......@@ -3606,6 +3612,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(
This->updateStateBlock->set.pixelShaderConstantsB[i] = TRUE;
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
return WINED3D_OK;
}
......@@ -3653,6 +3661,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(
This->updateStateBlock->set.pixelShaderConstantsI[i] = TRUE;
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
return WINED3D_OK;
}
......@@ -3705,6 +3715,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF(
This->updateStateBlock->changed.pixelShaderConstantsF[i] = TRUE;
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
return WINED3D_OK;
}
......
......@@ -1106,10 +1106,7 @@ inline static void drawPrimitiveDrawStrided(
int minIndex,
long StartIdx) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
/* Load any global constants/uniforms that may have been set by the application */
This->shader_backend->shader_load_constants(iface, usePixelShaderFunction, useVertexShaderFunction);
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
/* Draw vertex-by-vertex */
if (This->useDrawStridedSlow)
......@@ -1272,7 +1269,6 @@ void drawPrimitive(IWineD3DDevice *iface,
}
This->numDirtyEntries = 0; /* This makes the whole list clean */
if (TRACE_ON(d3d_draw) && wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
check_fbo_status(iface);
}
......
......@@ -1810,6 +1810,22 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock) {
}
}
static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock) {
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
/* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
* has an update pending
*/
if(isStateDirty(device, STATE_VDECL) ||
isStateDirty(device, STATE_PIXELSHADER)) {
return;
}
device->shader_backend->shader_load_constants((IWineD3DDevice *) device,
stateblock->pixelShader && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function,
stateblock->vertexShader && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function);
}
static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock) {
int i;
......@@ -1838,6 +1854,10 @@ static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock) {
(IWineD3DDevice *) stateblock->wineD3DDevice,
TRUE,
!stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
if(!isStateDirty(stateblock->wineD3DDevice, STATE_VERTEXSHADERCONSTANT)) {
shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock);
}
}
stateblock->wineD3DDevice->last_was_pshader = TRUE;
} else {
......@@ -1856,6 +1876,10 @@ static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock) {
(IWineD3DDevice *) stateblock->wineD3DDevice,
FALSE,
!stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
if(!isStateDirty(stateblock->wineD3DDevice, STATE_VERTEXSHADERCONSTANT)) {
shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock);
}
}
}
}
......@@ -2649,16 +2673,20 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
* in order to determine if we need to do any swizzling for D3DCOLOR
* registers. If the shader is already compiled this call will do nothing. */
IWineD3DVertexShader_CompileShader(stateblock->vertexShader);
}
/* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
* application
*/
if(!isStateDirty(device, STATE_PIXELSHADER)) {
BOOL usePixelShaderFunction = device->ps_selected_mode != SHADER_NONE &&
stateblock->pixelShader &&
((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
/* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
* application
*/
if(!isStateDirty(device, STATE_PIXELSHADER)) {
BOOL usePixelShaderFunction = device->ps_selected_mode != SHADER_NONE &&
stateblock->pixelShader &&
((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
device->shader_backend->shader_select((IWineD3DDevice *) device, usePixelShaderFunction, useVertexShaderFunction);
device->shader_backend->shader_select((IWineD3DDevice *) device, usePixelShaderFunction, useVertexShaderFunction);
if(!isStateDirty(stateblock->wineD3DDevice, STATE_VERTEXSHADERCONSTANT) && (useVertexShaderFunction || usePixelShaderFunction)) {
shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock);
}
}
......@@ -3704,5 +3732,6 @@ const struct StateEntry StateTable[] =
{ /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
{ /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
{ /* , STATE_VIEWPORT */ STATE_VIEWPORT, viewport },
{ /* , STATE_VERTEXSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT, shaderconstant },
{ /* , STATE_PIXELSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT, shaderconstant },
};
......@@ -436,7 +436,12 @@ typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock);
#define STATE_VIEWPORT (STATE_VSHADER + 1)
#define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
#define STATE_HIGHEST (STATE_VIEWPORT)
#define STATE_VERTEXSHADERCONSTANT (STATE_VIEWPORT + 1)
#define STATE_PIXELSHADERCONSTANT (STATE_VERTEXSHADERCONSTANT + 1)
#define STATE_IS_VERTEXSHADERCONSTANT(a) ((a) == STATE_VERTEXSHADERCONSTANT)
#define STATE_IS_PIXELSHADERCONSTANT(a) ((a) == STATE_PIXELSHADERCONSTANT)
#define STATE_HIGHEST (STATE_PIXELSHADERCONSTANT)
struct StateEntry
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment