wined3d: Add a separate function for pixel shader initialization.

This commit is contained in:
Henri Verbeet 2009-09-23 18:42:09 +02:00 committed by Alexandre Julliard
parent ca05ef5dd0
commit 8aea1b1302
3 changed files with 39 additions and 22 deletions

View File

@ -1795,37 +1795,28 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface
IWineD3DPixelShader **ppPixelShader, IUnknown *parent)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShaderImpl *object; /* NOTE: impl allowed, this is a create */
HRESULT hr = WINED3D_OK;
if (!pFunction) return WINED3DERR_INVALIDCALL;
IWineD3DPixelShaderImpl *object;
HRESULT hr;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Out of memory\n");
*ppPixelShader = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
ERR("Failed to allocate shader memory.\n");
return E_OUTOFMEMORY;
}
object->lpVtbl = &IWineD3DPixelShader_Vtbl;
object->parent = parent;
shader_init(&object->baseShader, iface);
list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
*ppPixelShader = (IWineD3DPixelShader *)object;
TRACE("(%p) : Created pixel shader %p\n", This, *ppPixelShader);
hr = IWineD3DPixelShader_SetFunction(*ppPixelShader, pFunction, output_signature);
hr = pixelshader_init(object, This, pFunction, output_signature, parent);
if (FAILED(hr))
{
WARN("(%p) : Failed to set function, returning %#x\n", iface, hr);
IWineD3DPixelShader_Release(*ppPixelShader);
*ppPixelShader = NULL;
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
return hr;
TRACE("Created pixel shader %p.\n", object);
*ppPixelShader = (IWineD3DPixelShader *)object;
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags,

View File

@ -343,7 +343,7 @@ void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseT
}
}
const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
static const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
{
/*** IUnknown methods ***/
IWineD3DPixelShaderImpl_QueryInterface,
@ -421,3 +421,27 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp
}
}
}
HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
IUnknown *parent)
{
HRESULT hr;
if (!byte_code) return WINED3DERR_INVALIDCALL;
shader->lpVtbl = &IWineD3DPixelShader_Vtbl;
shader->parent = parent;
shader_init(&shader->baseShader, (IWineD3DDevice *)device);
list_add_head(&device->shaders, &shader->baseShader.shader_list_entry);
hr = IWineD3DPixelShader_SetFunction((IWineD3DPixelShader *)shader, byte_code, output_signature);
if (FAILED(hr))
{
WARN("Failed to set function, hr %#x.\n", hr);
shader_cleanup((IWineD3DBaseShader *)shader);
return hr;
}
return WINED3D_OK;
}

View File

@ -2831,7 +2831,9 @@ typedef struct IWineD3DPixelShaderImpl {
} IWineD3DPixelShaderImpl;
extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl DECLSPEC_HIDDEN;
HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
IUnknown *parent) DECLSPEC_HIDDEN;
void pixelshader_update_samplers(struct shader_reg_maps *reg_maps,
IWineD3DBaseTexture * const *textures) DECLSPEC_HIDDEN;
void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,