From f6b76ba66d339e43b8f44256e0872e19d61b9946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 19 Oct 2009 17:46:13 +0200 Subject: [PATCH 04/18] WineD3D: Use the shader backend reported constant limit outside the shader backend --- dlls/wined3d/context.c | 16 ++++++++-------- dlls/wined3d/pixelshader.c | 2 +- dlls/wined3d/stateblock.c | 40 ++++++++++++++++++++-------------------- dlls/wined3d/vertexshader.c | 20 +++++++++++--------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index c6d6df8..90b3c87 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1255,13 +1255,13 @@ struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceI if(This->shader_backend->shader_dirtifyable_constants((IWineD3DDevice *) This)) { /* Create the dirty constants array and initialize them to dirty */ ret->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0, - sizeof(*ret->vshader_const_dirty) * GL_LIMITS(vshader_constantsF)); + sizeof(*ret->vshader_const_dirty) * This->d3d_vshader_constantF); ret->pshader_const_dirty = HeapAlloc(GetProcessHeap(), 0, - sizeof(*ret->pshader_const_dirty) * GL_LIMITS(pshader_constantsF)); + sizeof(*ret->pshader_const_dirty) * This->d3d_pshader_constantF); memset(ret->vshader_const_dirty, 1, - sizeof(*ret->vshader_const_dirty) * GL_LIMITS(vshader_constantsF)); + sizeof(*ret->vshader_const_dirty) * This->d3d_vshader_constantF); memset(ret->pshader_const_dirty, 1, - sizeof(*ret->pshader_const_dirty) * GL_LIMITS(pshader_constantsF)); + sizeof(*ret->pshader_const_dirty) * This->d3d_pshader_constantF); } ret->free_occlusion_query_size = 4; @@ -2020,14 +2020,14 @@ struct wined3d_context *ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurfac if (context->vshader_const_dirty) { memset(context->vshader_const_dirty, 1, - sizeof(*context->vshader_const_dirty) * GL_LIMITS(vshader_constantsF)); - This->highest_dirty_vs_const = GL_LIMITS(vshader_constantsF); + sizeof(*context->vshader_const_dirty) * This->d3d_vshader_constantF); + This->highest_dirty_vs_const = This->d3d_vshader_constantF; } if (context->pshader_const_dirty) { memset(context->pshader_const_dirty, 1, - sizeof(*context->pshader_const_dirty) * GL_LIMITS(pshader_constantsF)); - This->highest_dirty_ps_const = GL_LIMITS(pshader_constantsF); + sizeof(*context->pshader_const_dirty) * This->d3d_pshader_constantF); + This->highest_dirty_ps_const = This->d3d_pshader_constantF; } } diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index 00f04e9..c82faa5 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -247,7 +247,7 @@ static HRESULT pixelshader_set_function(IWineD3DPixelShaderImpl *shader, /* Second pass: figure out which registers are used, what the semantics are, etc.. */ hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe, reg_maps, NULL, shader->input_signature, NULL, - byte_code, gl_info->max_pshader_constantsF); + byte_code, device->d3d_pshader_constantF); if (FAILED(hr)) return hr; pshader_set_limits(shader); diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index f6ede2c..ba69fa5 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -195,24 +195,25 @@ static const DWORD vertex_states_sampler[] = static HRESULT stateblock_allocate_shader_constants(IWineD3DStateBlockImpl *object) { IWineD3DStateBlockImpl *This = object; + IWineD3DDeviceImpl *device = This->wineD3DDevice; /* Allocate space for floating point constants */ - object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4); + object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * device->d3d_pshader_constantF * 4); if (!object->pixelShaderConstantF) goto fail; - object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(pshader_constantsF)); + object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * device->d3d_pshader_constantF); if (!object->changed.pixelShaderConstantsF) goto fail; - object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4); + object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * device->d3d_vshader_constantF * 4); if (!object->vertexShaderConstantF) goto fail; - object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(vshader_constantsF)); + object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * device->d3d_vshader_constantF); if (!object->changed.vertexShaderConstantsF) goto fail; - object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(vshader_constantsF)); + object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * device->d3d_vshader_constantF); if (!object->contained_vs_consts_f) goto fail; - object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(pshader_constantsF)); + object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * device->d3d_pshader_constantF); if (!object->contained_ps_consts_f) goto fail; return WINED3D_OK; @@ -236,7 +237,7 @@ static inline void stateblock_set_bits(DWORD *map, UINT map_size) } /* Set all members of a stateblock savedstate to the given value */ -static void stateblock_savedstates_set_all(SAVEDSTATES *states, const struct wined3d_gl_info *gl_info) +static void stateblock_savedstates_set_all(SAVEDSTATES *states, const IWineD3DDeviceImpl *device) { unsigned int i; @@ -265,11 +266,11 @@ static void stateblock_savedstates_set_all(SAVEDSTATES *states, const struct win states->vertexShaderConstantsI = 0xffff; /* Dynamically sized arrays */ - memset(states->pixelShaderConstantsF, TRUE, sizeof(BOOL) * gl_info->max_pshader_constantsF); - memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * gl_info->max_vshader_constantsF); + memset(states->pixelShaderConstantsF, TRUE, sizeof(BOOL) * device->d3d_pshader_constantF); + memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * device->d3d_vshader_constantF); } -static void stateblock_savedstates_set_pixel(SAVEDSTATES *states, const struct wined3d_gl_info *gl_info) +static void stateblock_savedstates_set_pixel(SAVEDSTATES *states, const DWORD num_constants) { DWORD texture_mask = 0; WORD sampler_mask = 0; @@ -292,10 +293,10 @@ static void stateblock_savedstates_set_pixel(SAVEDSTATES *states, const struct w states->pixelShaderConstantsB = 0xffff; states->pixelShaderConstantsI = 0xffff; - memset(states->pixelShaderConstantsF, TRUE, sizeof(BOOL) * gl_info->max_pshader_constantsF); + memset(states->pixelShaderConstantsF, TRUE, sizeof(BOOL) * num_constants); } -static void stateblock_savedstates_set_vertex(SAVEDSTATES *states, const struct wined3d_gl_info *gl_info) +static void stateblock_savedstates_set_vertex(SAVEDSTATES *states, const DWORD num_constants) { DWORD texture_mask = 0; WORD sampler_mask = 0; @@ -319,12 +320,12 @@ static void stateblock_savedstates_set_vertex(SAVEDSTATES *states, const struct states->vertexShaderConstantsB = 0xffff; states->vertexShaderConstantsI = 0xffff; - memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * gl_info->max_vshader_constantsF); + memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * num_constants); } void stateblock_init_contained_states(IWineD3DStateBlockImpl *stateblock) { - const struct wined3d_gl_info *gl_info = &stateblock->wineD3DDevice->adapter->gl_info; + IWineD3DDeviceImpl *device = stateblock->wineD3DDevice; unsigned int i, j; for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i) @@ -351,7 +352,7 @@ void stateblock_init_contained_states(IWineD3DStateBlockImpl *stateblock) } } - for (i = 0; i < gl_info->max_vshader_constantsF; ++i) + for (i = 0; i < device->d3d_vshader_constantF; ++i) { if (stateblock->changed.vertexShaderConstantsF[i]) { @@ -378,7 +379,7 @@ void stateblock_init_contained_states(IWineD3DStateBlockImpl *stateblock) } } - for (i = 0; i < gl_info->max_pshader_constantsF; ++i) + for (i = 0; i < device->d3d_pshader_constantF; ++i) { if (stateblock->changed.pixelShaderConstantsF[i]) { @@ -1331,7 +1332,6 @@ static const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl = HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *device, WINED3DSTATEBLOCKTYPE type, IUnknown *parent) { - const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; unsigned int i; HRESULT hr; @@ -1360,16 +1360,16 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl * { case WINED3DSBT_ALL: stateblock_init_lights(stateblock, device->stateBlock->lightMap); - stateblock_savedstates_set_all(&stateblock->changed, gl_info); + stateblock_savedstates_set_all(&stateblock->changed, device); break; case WINED3DSBT_PIXELSTATE: - stateblock_savedstates_set_pixel(&stateblock->changed, gl_info); + stateblock_savedstates_set_pixel(&stateblock->changed, device->d3d_pshader_constantF); break; case WINED3DSBT_VERTEXSTATE: stateblock_init_lights(stateblock, device->stateBlock->lightMap); - stateblock_savedstates_set_vertex(&stateblock->changed, gl_info); + stateblock_savedstates_set_vertex(&stateblock->changed, device->d3d_vshader_constantF); break; default: diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c index f55f1fb..8774c1a 100644 --- a/dlls/wined3d/vertexshader.c +++ b/dlls/wined3d/vertexshader.c @@ -39,6 +39,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) { DWORD shader_version = WINED3D_SHADER_VERSION(This->baseShader.reg_maps.shader_version.major, This->baseShader.reg_maps.shader_version.minor); + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; This->baseShader.limits.texcoord = 0; This->baseShader.limits.attributes = 16; @@ -57,7 +58,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.label = 0; /* TODO: vs_1_1 has a minimum of 96 constants. What happens if a vs_1_1 shader is used * on a vs_3_0 capable card that has 256 constants? */ - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF); break; case WINED3D_SHADER_VERSION(2,0): @@ -69,7 +70,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.packed_output = 0; This->baseShader.limits.sampler = 0; This->baseShader.limits.label = 16; - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF); break; case WINED3D_SHADER_VERSION(4,0): @@ -88,7 +89,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) * of supporting much more(GL drivers advertise 1024). d3d9.dll and d3d8.dll clamp the * wined3d-advertised maximum. Clamp the constant limit for <= 3.0 shaders to 256.s * use constant buffers */ - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF); break; default: @@ -99,7 +100,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.packed_output = 0; This->baseShader.limits.sampler = 0; This->baseShader.limits.label = 16; - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF); FIXME("Unrecognized vertex shader version %u.%u\n", This->baseShader.reg_maps.shader_version.major, This->baseShader.reg_maps.shader_version.minor); @@ -259,11 +260,11 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader, list_init(&shader->baseShader.constantsI); /* Second pass: figure out registers used, semantics, etc.. */ - shader->min_rel_offset = gl_info->max_vshader_constantsF; + shader->min_rel_offset = device->d3d_vshader_constantF; shader->max_rel_offset = 0; hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe, reg_maps, shader->attributes, NULL, shader->output_signature, - byte_code, gl_info->max_vshader_constantsF); + byte_code, device->d3d_vshader_constantF); if (hr != WINED3D_OK) return hr; if (output_signature) @@ -316,14 +317,15 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader, static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertexShader *iface, UINT start_idx, const float *src_data, UINT count) { IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; UINT i, end_idx; TRACE("(%p) : start_idx %u, src_data %p, count %u\n", This, start_idx, src_data, count); end_idx = start_idx + count; - if (end_idx > GL_LIMITS(vshader_constantsF)) { - WARN("end_idx %u > float constants limit %u\n", end_idx, GL_LIMITS(vshader_constantsF)); - end_idx = GL_LIMITS(vshader_constantsF); + if (end_idx > device->d3d_vshader_constantF) { + WARN("end_idx %u > float constants limit %u\n", end_idx, device->d3d_vshader_constantF); + end_idx = device->d3d_vshader_constantF; } for (i = start_idx; i < end_idx; ++i) { -- 1.6.4.4