wined3d: Use the shader backend reported constant limit outside the shader backend.

This commit is contained in:
Stefan Dösinger 2009-10-24 16:23:34 -07:00 committed by Alexandre Julliard
parent 3259c81e10
commit 70d6304a21
4 changed files with 41 additions and 41 deletions

View File

@ -1286,13 +1286,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_info->max_vshader_constantsF);
sizeof(*ret->vshader_const_dirty) * This->d3d_vshader_constantF);
ret->pshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
sizeof(*ret->pshader_const_dirty) * gl_info->max_pshader_constantsF);
sizeof(*ret->pshader_const_dirty) * This->d3d_pshader_constantF);
memset(ret->vshader_const_dirty, 1,
sizeof(*ret->vshader_const_dirty) * gl_info->max_vshader_constantsF);
sizeof(*ret->vshader_const_dirty) * This->d3d_vshader_constantF);
memset(ret->pshader_const_dirty, 1,
sizeof(*ret->pshader_const_dirty) * gl_info->max_pshader_constantsF);
sizeof(*ret->pshader_const_dirty) * This->d3d_pshader_constantF);
}
ret->free_occlusion_query_size = 4;
@ -2059,14 +2059,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_info->max_vshader_constantsF);
This->highest_dirty_vs_const = gl_info->max_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_info->max_pshader_constantsF);
This->highest_dirty_ps_const = gl_info->max_pshader_constantsF;
sizeof(*context->pshader_const_dirty) * This->d3d_pshader_constantF);
This->highest_dirty_ps_const = This->d3d_pshader_constantF;
}
}

View File

@ -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);

View File

@ -194,31 +194,31 @@ static const DWORD vertex_states_sampler[] =
*/
static HRESULT stateblock_allocate_shader_constants(IWineD3DStateBlockImpl *object)
{
const struct wined3d_gl_info *gl_info = &object->wineD3DDevice->adapter->gl_info;
IWineD3DDeviceImpl *device = object->wineD3DDevice;
/* Allocate space for floating point constants */
object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(float) * gl_info->max_pshader_constantsF * 4);
sizeof(float) * device->d3d_pshader_constantF * 4);
if (!object->pixelShaderConstantF) goto fail;
object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(BOOL) * gl_info->max_pshader_constantsF);
sizeof(BOOL) * device->d3d_pshader_constantF);
if (!object->changed.pixelShaderConstantsF) goto fail;
object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(float) * gl_info->max_vshader_constantsF * 4);
sizeof(float) * device->d3d_vshader_constantF * 4);
if (!object->vertexShaderConstantF) goto fail;
object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(BOOL) * gl_info->max_vshader_constantsF);
sizeof(BOOL) * device->d3d_vshader_constantF);
if (!object->changed.vertexShaderConstantsF) goto fail;
object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0,
sizeof(DWORD) * gl_info->max_vshader_constantsF);
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_info->max_pshader_constantsF);
sizeof(DWORD) * device->d3d_pshader_constantF);
if (!object->contained_ps_consts_f) goto fail;
return WINED3D_OK;
@ -242,7 +242,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, DWORD vs_consts, DWORD ps_consts)
{
unsigned int i;
@ -271,11 +271,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) * ps_consts);
memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * vs_consts);
}
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;
@ -298,10 +298,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;
@ -325,12 +325,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)
@ -357,7 +357,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])
{
@ -384,7 +384,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])
{
@ -1339,7 +1339,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;
@ -1368,16 +1367,17 @@ 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->d3d_vshader_constantF,
device->d3d_pshader_constantF);
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:

View File

@ -37,9 +37,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
{
const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
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;
@ -58,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_info->max_vshader_constantsF);
This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
break;
case WINED3D_SHADER_VERSION(2,0):
@ -70,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_info->max_vshader_constantsF);
This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
break;
case WINED3D_SHADER_VERSION(4,0):
@ -89,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_info->max_vshader_constantsF);
This->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
break;
default:
@ -100,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_info->max_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);
@ -260,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)
@ -317,16 +317,16 @@ 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;
const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
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_info->max_vshader_constantsF)
if (end_idx > device->d3d_vshader_constantF)
{
WARN("end_idx %u > float constants limit %u\n", end_idx, gl_info->max_vshader_constantsF);
end_idx = gl_info->max_vshader_constantsF;
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) {