wined3d: Shaders will never have a NULL function.
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index 392c512..9cc0e2b 100644
--- a/dlls/wined3d/baseshader.c
+++ b/dlls/wined3d/baseshader.c
@@ -216,13 +216,6 @@
memset(reg_maps->bumpmat, 0, sizeof(reg_maps->bumpmat));
memset(reg_maps->luminanceparams, 0, sizeof(reg_maps->luminanceparams));
- if (!pToken)
- {
- WARN("Got a NULL pFunction, returning.\n");
- This->baseShader.functionLength = 0;
- return WINED3D_OK;
- }
-
/* get_registers_used is called on every compile on some 1.x shaders, which can result
* in stacking up a collection of local constants. Delete the old constants if existing
*/
@@ -844,8 +837,6 @@
hw_arg.reg_maps = reg_maps;
This->baseShader.parse_state.current_row = 0;
- if (!pToken) return;
-
while (WINED3DPS_END() != *pToken)
{
/* Skip version token */
@@ -970,12 +961,6 @@
TRACE("Parsing %p\n", pFunction);
- if (!pFunction)
- {
- WARN("Got a NULL pFunction, returning.\n");
- return;
- }
-
/* The version token is supposed to be the first token */
if (!shader_is_version_token(*pToken))
{
diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c
index 1b31c74..e761288 100644
--- a/dlls/wined3d/nvidia_texture_shader.c
+++ b/dlls/wined3d/nvidia_texture_shader.c
@@ -457,11 +457,8 @@
TRACE("Setting color op for stage %d\n", stage);
- if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE &&
- ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
- /* Using a pixel shader? Don't care for anything here, the shader applying does it */
- return;
- }
+ /* Using a pixel shader? Don't care for anything here, the shader applying does it */
+ if (use_ps(stateblock->wineD3DDevice)) return;
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c
index f3d4386..1dd3888 100644
--- a/dlls/wined3d/pixelshader.c
+++ b/dlls/wined3d/pixelshader.c
@@ -115,13 +115,10 @@
* return D3DERR_MOREDATA. That's not actually true. */
return WINED3DERR_INVALIDCALL;
}
- if (NULL == This->baseShader.function) { /* no function defined */
- TRACE("(%p) : GetFunction no User Function defined using NULL to %p\n", This, pData);
- (*(DWORD **) pData) = NULL;
- } else {
- TRACE("(%p) : GetFunction copying to %p\n", This, pData);
- memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
- }
+
+ TRACE("(%p) : GetFunction copying to %p\n", This, pData);
+ memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
+
return WINED3D_OK;
}
@@ -382,16 +379,10 @@
This->baseShader.shader_mode = deviceImpl->ps_selected_mode;
TRACE("(%p) : Copying the function\n", This);
- if (NULL != pFunction) {
- void *function;
- function = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->baseShader.functionLength);
- if (!function) return E_OUTOFMEMORY;
- memcpy(function, pFunction, This->baseShader.functionLength);
- This->baseShader.function = function;
- } else {
- This->baseShader.function = NULL;
- }
+ This->baseShader.function = HeapAlloc(GetProcessHeap(), 0, This->baseShader.functionLength);
+ if (!This->baseShader.function) return E_OUTOFMEMORY;
+ memcpy(This->baseShader.function, pFunction, This->baseShader.functionLength);
return WINED3D_OK;
}
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index ccaf6f5..085e3d4 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -2917,11 +2917,8 @@
TRACE("Setting color op for stage %d\n", stage);
- if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE &&
- ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
- /* Using a pixel shader? Don't care for anything here, the shader applying does it */
- return;
- }
+ /* Using a pixel shader? Don't care for anything here, the shader applying does it */
+ if (use_ps(stateblock->wineD3DDevice)) return;
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
@@ -4365,13 +4362,7 @@
BOOL load_numbered = FALSE;
BOOL load_named = FALSE;
- if (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
- ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) {
- useVertexShaderFunction = TRUE;
- } else {
- useVertexShaderFunction = FALSE;
- }
-
+ useVertexShaderFunction = (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader) ? TRUE : FALSE;
if(device->up_strided) {
/* Note: this is a ddraw fixed-function code path */
@@ -4459,8 +4450,7 @@
static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
BOOL useVertexShaderFunction = FALSE, updateFog = FALSE;
- BOOL usePixelShaderFunction = stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader
- && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
+ BOOL usePixelShaderFunction = use_ps(stateblock->wineD3DDevice);
BOOL transformed;
/* Some stuff is in the device until we have per context tracking */
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index ef55f67..063f576 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -412,13 +412,10 @@
* return D3DERR_MOREDATA. That's not actually true. */
return WINED3DERR_INVALIDCALL;
}
- if (NULL == This->baseShader.function) { /* no function defined */
- TRACE("(%p) : GetFunction no User Function defined using NULL to %p\n", This, pData);
- (*(DWORD **) pData) = NULL;
- } else {
- TRACE("(%p) : GetFunction copying to %p\n", This, pData);
- memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
- }
+
+ TRACE("(%p) : GetFunction copying to %p\n", This, pData);
+ memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
+
return WINED3D_OK;
}
@@ -474,16 +471,9 @@
This->baseShader.load_local_constsF = This->baseShader.reg_maps.usesrelconstF && !list_empty(&This->baseShader.constantsF);
/* copy the function ... because it will certainly be released by application */
- if (NULL != pFunction) {
- void *function;
-
- function = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->baseShader.functionLength);
- if (!function) return E_OUTOFMEMORY;
- memcpy(function, pFunction, This->baseShader.functionLength);
- This->baseShader.function = function;
- } else {
- This->baseShader.function = NULL;
- }
+ This->baseShader.function = HeapAlloc(GetProcessHeap(), 0, This->baseShader.functionLength);
+ if (!This->baseShader.function) return E_OUTOFMEMORY;
+ memcpy(This->baseShader.function, pFunction, This->baseShader.functionLength);
return WINED3D_OK;
}
@@ -611,12 +601,6 @@
deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface);
}
- /* We don't need to compile */
- if (!function) {
- This->baseShader.is_compiled = TRUE;
- return WINED3D_OK;
- }
-
/* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This);
IWineD3DVertexShaderImpl_GenerateShader(iface, &This->baseShader.reg_maps, function);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a660581..9500031 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2465,14 +2465,12 @@
static inline BOOL use_vs(IWineD3DDeviceImpl *device) {
return (device->vs_selected_mode != SHADER_NONE
&& device->stateBlock->vertexShader
- && ((IWineD3DVertexShaderImpl *)device->stateBlock->vertexShader)->baseShader.function
&& !device->strided_streams.u.s.position_transformed);
}
static inline BOOL use_ps(IWineD3DDeviceImpl *device) {
return (device->ps_selected_mode != SHADER_NONE
- && device->stateBlock->pixelShader
- && ((IWineD3DPixelShaderImpl *)device->stateBlock->pixelShader)->baseShader.function);
+ && device->stateBlock->pixelShader);
}
void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect,