wined3d: Move the pixel shader to wined3d_state.

This commit is contained in:
Henri Verbeet 2010-09-20 12:04:29 +02:00 committed by Alexandre Julliard
parent 8a148cc7c5
commit 33dfb9539c
6 changed files with 40 additions and 35 deletions

View File

@ -650,8 +650,9 @@ static void shader_arb_load_constants(const struct wined3d_context *context, cha
shader_arb_vs_local_constants(device);
}
if (usePixelShader) {
IWineD3DBaseShaderImpl* pshader = (IWineD3DBaseShaderImpl*) stateBlock->pixelShader;
if (usePixelShader)
{
IWineD3DBaseShaderImpl *pshader = (IWineD3DBaseShaderImpl *)stateBlock->state.pixel_shader;
/* Load DirectX 9 float constants for pixel shader */
device->highest_dirty_ps_const = shader_arb_load_constantsF(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB,
@ -3978,7 +3979,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
/* Instead of searching for the signature in the signature list, read the one from the current pixel shader.
* Its maybe not the shader where the signature came from, but it is the same signature and faster to find
*/
sig = ((IWineD3DPixelShaderImpl *)device->stateBlock->pixelShader)->baseShader.input_signature;
sig = device->stateBlock->state.pixel_shader->baseShader.input_signature;
TRACE("Pixel shader uses declared varyings\n");
/* Map builtin to declared. /dev/null the results by default to the TA temp reg */
@ -4453,7 +4454,7 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW
args->clip.boolclip_compare = 0;
if(use_ps(stateblock))
{
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) stateblock->pixelShader;
IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
struct arb_pshader_private *shader_priv = ps->baseShader.backend_data;
args->ps_signature = shader_priv->input_signature_idx;
@ -4528,9 +4529,9 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
if (usePS) {
struct arb_ps_compile_args compile_args;
struct arb_ps_compiled_shader *compiled;
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader;
IWineD3DPixelShaderImpl *ps = This->stateBlock->state.pixel_shader;
TRACE("Using pixel shader %p\n", This->stateBlock->pixelShader);
TRACE("Using pixel shader %p.\n", ps);
find_arb_ps_compile_args(ps, This->stateBlock, &compile_args);
compiled = find_arb_pshader(ps, &compile_args);
priv->current_fprogram_id = compiled->prgId;
@ -5587,7 +5588,7 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, s
if (use_ps(stateblock))
{
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
if (stage && (ps->baseShader.reg_maps.bumpmat & (1 << stage)))
{
/* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
@ -5624,7 +5625,7 @@ static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock
if (use_ps(stateblock))
{
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
if (stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
{
/* The pixel shader has to know the luminance offset. Do a constants update if it

View File

@ -481,7 +481,7 @@ void device_preload_textures(IWineD3DDeviceImpl *device)
{
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{
if (((IWineD3DBaseShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.sampler_type[i])
if (stateblock->state.pixel_shader->baseShader.reg_maps.sampler_type[i])
device_preload_texture(stateblock, i);
}
}
@ -3491,7 +3491,7 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const s
static void device_map_psamplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
{
const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type =
((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.sampler_type;
This->stateBlock->state.pixel_shader->baseShader.reg_maps.sampler_type;
unsigned int i;
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
@ -3539,8 +3539,9 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct
int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1;
int i;
if (ps) {
IWineD3DPixelShaderImpl *pshader = (IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader;
if (ps)
{
IWineD3DPixelShaderImpl *pshader = This->stateBlock->state.pixel_shader;
/* Note that we only care if a sampler is sampled or not, not the sampler's specific type.
* Otherwise we'd need to call shader_update_samplers() here for 1.x pixelshaders. */
@ -3591,10 +3592,11 @@ void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
if (vs) device_map_vsamplers(This, ps, gl_info);
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShader *oldShader = This->updateStateBlock->pixelShader;
This->updateStateBlock->pixelShader = pShader;
static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShader *oldShader = (IWineD3DPixelShader *)This->updateStateBlock->state.pixel_shader;
This->updateStateBlock->state.pixel_shader = (IWineD3DPixelShaderImpl *)pShader;
This->updateStateBlock->changed.pixelShader = TRUE;
/* Handle recording of state blocks */
@ -3630,7 +3632,7 @@ static IWineD3DPixelShader * WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDe
TRACE("iface %p.\n", iface);
shader = device->stateBlock->pixelShader;
shader = (IWineD3DPixelShader *)device->stateBlock->state.pixel_shader;
if (shader) IWineD3DPixelShader_AddRef(shader);
TRACE("Returning %p.\n", shader);

View File

@ -773,9 +773,9 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
checkGLcall("glUniform4fvARB");
}
if (usePixelShader) {
IWineD3DBaseShaderImpl* pshader = (IWineD3DBaseShaderImpl*) stateBlock->pixelShader;
if (usePixelShader)
{
IWineD3DBaseShaderImpl *pshader = (IWineD3DBaseShaderImpl *)stateBlock->state.pixel_shader;
/* Load DirectX 9 float constants/uniforms for pixel shader */
shader_glsl_load_constantsF(pshader, gl_info, stateBlock->pixelShaderConstantF,
@ -4279,7 +4279,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context,
IWineD3DDeviceImpl *device, BOOL use_ps, BOOL use_vs)
{
IWineD3DVertexShader *vshader = use_vs ? (IWineD3DVertexShader *)device->stateBlock->state.vertex_shader : NULL;
IWineD3DPixelShader *pshader = use_ps ? device->stateBlock->pixelShader : NULL;
IWineD3DPixelShader *pshader = use_ps ? (IWineD3DPixelShader *)device->stateBlock->state.pixel_shader : NULL;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct shader_glsl_priv *priv = device->shader_priv;
struct glsl_shader_prog_link *entry = NULL;

View File

@ -3562,9 +3562,9 @@ static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
if (stateblock->pixelShader && stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
if (ps && stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
{
/* The pixel shader has to know the luminance scale. Do a constants update if it
* isn't scheduled anyway
@ -3735,9 +3735,9 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
if (stateblock->pixelShader && stage && (ps->baseShader.reg_maps.bumpmat & (1 << stage)))
if (ps && stage && (ps->baseShader.reg_maps.bumpmat & (1 << stage)))
{
/* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
* anyway

View File

@ -514,7 +514,7 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
}
if(This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
if (This->state.vertex_shader) IWineD3DVertexShader_Release((IWineD3DVertexShader *)This->state.vertex_shader);
if(This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
if (This->state.pixel_shader) IWineD3DPixelShader_Release((IWineD3DPixelShader *)This->state.pixel_shader);
for(counter = 0; counter < LIGHTMAP_SIZE; counter++) {
struct list *e1, *e2;
@ -871,11 +871,13 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
This->state.sampler_states[stage][state] = targetStateBlock->state.sampler_states[stage][state];
}
if (This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader)
if (This->changed.pixelShader && This->state.pixel_shader != targetStateBlock->state.pixel_shader)
{
if (targetStateBlock->pixelShader) IWineD3DPixelShader_AddRef(targetStateBlock->pixelShader);
if (This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
This->pixelShader = targetStateBlock->pixelShader;
if (targetStateBlock->state.pixel_shader)
IWineD3DPixelShader_AddRef((IWineD3DPixelShader *)targetStateBlock->state.pixel_shader);
if (This->state.pixel_shader)
IWineD3DPixelShader_Release((IWineD3DPixelShader *)This->state.pixel_shader);
This->state.pixel_shader = targetStateBlock->state.pixel_shader;
}
record_lights(This, targetStateBlock);
@ -934,7 +936,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
apply_lights(device, This);
if (This->changed.pixelShader) IWineD3DDevice_SetPixelShader(device, This->pixelShader);
if (This->changed.pixelShader)
IWineD3DDevice_SetPixelShader(device, (IWineD3DPixelShader *)This->state.pixel_shader);
/* Pixel Shader Constants */
for (i = 0; i < This->num_contained_ps_consts_f; ++i)

View File

@ -2356,6 +2356,8 @@ struct wined3d_state
INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f;
struct IWineD3DPixelShaderImpl *pixel_shader;
IWineD3DBaseTextureImpl *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
@ -2406,9 +2408,6 @@ struct IWineD3DStateBlockImpl
double clipplane[MAX_CLIPPLANES][4];
WINED3DCLIPSTATUS clip_status;
/* Pixel Shader */
IWineD3DPixelShader *pixelShader;
/* Pixel Shader Constants */
BOOL pixelShaderConstantB[MAX_CONST_B];
INT pixelShaderConstantI[MAX_CONST_I * 4];
@ -3039,7 +3038,7 @@ static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
{
return (stateblock->pixelShader && stateblock->device->ps_selected_mode != SHADER_NONE);
return (stateblock->state.pixel_shader && stateblock->device->ps_selected_mode != SHADER_NONE);
}
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */