Commit f3743fb4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Shaders will never have a NULL function.

parent 46572f68
......@@ -216,13 +216,6 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
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 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
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 @@ void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table
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))
{
......
......@@ -457,11 +457,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
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);
......
......@@ -115,13 +115,10 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_GetFunction(IWineD3DPixelShader*
* 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 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
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;
}
......
......@@ -2917,11 +2917,8 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
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 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
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 streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
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;
......
......@@ -412,13 +412,10 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_GetFunction(IWineD3DVertexShader*
* 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 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
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 @@ HRESULT IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
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);
......
......@@ -2465,14 +2465,12 @@ const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
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,
......
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