Commit 768e8c09 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Move shader limits to wined3d_d3d_info.

parent f7580726
...@@ -657,6 +657,7 @@ static void shader_arb_load_constants_internal(const struct wined3d_context *con ...@@ -657,6 +657,7 @@ static void shader_arb_load_constants_internal(const struct wined3d_context *con
const struct wined3d_stateblock *stateblock = device->stateBlock; const struct wined3d_stateblock *stateblock = device->stateBlock;
const struct wined3d_state *state = &stateblock->state; const struct wined3d_state *state = &stateblock->state;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
struct shader_arb_priv *priv = device->shader_priv; struct shader_arb_priv *priv = device->shader_priv;
if (!from_shader_select) if (!from_shader_select)
...@@ -689,12 +690,12 @@ static void shader_arb_load_constants_internal(const struct wined3d_context *con ...@@ -689,12 +690,12 @@ static void shader_arb_load_constants_internal(const struct wined3d_context *con
if (context != priv->last_context) if (context != priv->last_context)
{ {
memset(priv->vshader_const_dirty, 1, memset(priv->vshader_const_dirty, 1,
sizeof(*priv->vshader_const_dirty) * device->d3d_vshader_constantF); sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count);
priv->highest_dirty_vs_const = device->d3d_vshader_constantF; priv->highest_dirty_vs_const = d3d_info->limits.vs_uniform_count;
memset(priv->pshader_const_dirty, 1, memset(priv->pshader_const_dirty, 1,
sizeof(*priv->pshader_const_dirty) * device->d3d_pshader_constantF); sizeof(*priv->pshader_const_dirty) * d3d_info->limits.ps_uniform_count);
priv->highest_dirty_ps_const = device->d3d_pshader_constantF; priv->highest_dirty_ps_const = d3d_info->limits.ps_uniform_count;
priv->last_context = context; priv->last_context = context;
} }
...@@ -4850,6 +4851,7 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine ...@@ -4850,6 +4851,7 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine
struct shader_arb_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*priv)); struct shader_arb_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*priv));
struct fragment_caps fragment_caps; struct fragment_caps fragment_caps;
void *vertex_priv, *fragment_priv; void *vertex_priv, *fragment_priv;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
if (!(vertex_priv = vertex_pipe->vp_alloc(&arb_program_shader_backend, priv))) if (!(vertex_priv = vertex_pipe->vp_alloc(&arb_program_shader_backend, priv)))
{ {
...@@ -4867,18 +4869,18 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine ...@@ -4867,18 +4869,18 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine
} }
priv->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0, priv->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
sizeof(*priv->vshader_const_dirty) * device->d3d_vshader_constantF); sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count);
if (!priv->vshader_const_dirty) if (!priv->vshader_const_dirty)
goto fail; goto fail;
memset(priv->vshader_const_dirty, 1, memset(priv->vshader_const_dirty, 1,
sizeof(*priv->vshader_const_dirty) * device->d3d_vshader_constantF); sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count);
priv->pshader_const_dirty = HeapAlloc(GetProcessHeap(), 0, priv->pshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
sizeof(*priv->pshader_const_dirty) * device->d3d_pshader_constantF); sizeof(*priv->pshader_const_dirty) * d3d_info->limits.ps_uniform_count);
if (!priv->pshader_const_dirty) if (!priv->pshader_const_dirty)
goto fail; goto fail;
memset(priv->pshader_const_dirty, 1, memset(priv->pshader_const_dirty, 1,
sizeof(*priv->pshader_const_dirty) * device->d3d_pshader_constantF); sizeof(*priv->pshader_const_dirty) * d3d_info->limits.ps_uniform_count);
if(wine_rb_init(&priv->signature_tree, &sig_tree_functions) == -1) if(wine_rb_init(&priv->signature_tree, &sig_tree_functions) == -1)
{ {
......
...@@ -2602,6 +2602,7 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device, ...@@ -2602,6 +2602,7 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
UINT start_register, const float *constants, UINT vector4f_count) UINT start_register, const float *constants, UINT vector4f_count)
{ {
UINT i; UINT i;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n", TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
device, start_register, constants, vector4f_count); device, start_register, constants, vector4f_count);
...@@ -2609,8 +2610,8 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device, ...@@ -2609,8 +2610,8 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
/* Specifically test start_register > limit to catch MAX_UINT overflows /* Specifically test start_register > limit to catch MAX_UINT overflows
* when adding start_register + vector4f_count. */ * when adding start_register + vector4f_count. */
if (!constants if (!constants
|| start_register + vector4f_count > device->d3d_vshader_constantF || start_register + vector4f_count > d3d_info->limits.vs_uniform_count
|| start_register > device->d3d_vshader_constantF) || start_register > d3d_info->limits.vs_uniform_count)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(&device->updateStateBlock->state.vs_consts_f[start_register * 4], memcpy(&device->updateStateBlock->state.vs_consts_f[start_register * 4],
...@@ -2638,7 +2639,8 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device, ...@@ -2638,7 +2639,8 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
HRESULT CDECL wined3d_device_get_vs_consts_f(const struct wined3d_device *device, HRESULT CDECL wined3d_device_get_vs_consts_f(const struct wined3d_device *device,
UINT start_register, float *constants, UINT vector4f_count) UINT start_register, float *constants, UINT vector4f_count)
{ {
int count = min(vector4f_count, device->d3d_vshader_constantF - start_register); const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
int count = min(vector4f_count, d3d_info->limits.vs_uniform_count - start_register);
TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n", TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
device, start_register, constants, vector4f_count); device, start_register, constants, vector4f_count);
...@@ -3071,6 +3073,7 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device, ...@@ -3071,6 +3073,7 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device,
UINT start_register, const float *constants, UINT vector4f_count) UINT start_register, const float *constants, UINT vector4f_count)
{ {
UINT i; UINT i;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n", TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
device, start_register, constants, vector4f_count); device, start_register, constants, vector4f_count);
...@@ -3078,8 +3081,8 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device, ...@@ -3078,8 +3081,8 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device,
/* Specifically test start_register > limit to catch MAX_UINT overflows /* Specifically test start_register > limit to catch MAX_UINT overflows
* when adding start_register + vector4f_count. */ * when adding start_register + vector4f_count. */
if (!constants if (!constants
|| start_register + vector4f_count > device->d3d_pshader_constantF || start_register + vector4f_count > d3d_info->limits.ps_uniform_count
|| start_register > device->d3d_pshader_constantF) || start_register > d3d_info->limits.ps_uniform_count)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(&device->updateStateBlock->state.ps_consts_f[start_register * 4], memcpy(&device->updateStateBlock->state.ps_consts_f[start_register * 4],
...@@ -3107,7 +3110,8 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device, ...@@ -3107,7 +3110,8 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device,
HRESULT CDECL wined3d_device_get_ps_consts_f(const struct wined3d_device *device, HRESULT CDECL wined3d_device_get_ps_consts_f(const struct wined3d_device *device,
UINT start_register, float *constants, UINT vector4f_count) UINT start_register, float *constants, UINT vector4f_count)
{ {
int count = min(vector4f_count, device->d3d_pshader_constantF - start_register); const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
int count = min(vector4f_count, d3d_info->limits.ps_uniform_count - start_register);
TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n", TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
device, start_register, constants, vector4f_count); device, start_register, constants, vector4f_count);
...@@ -5408,7 +5412,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, ...@@ -5408,7 +5412,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx]; struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct fragment_pipeline *fragment_pipeline; const struct fragment_pipeline *fragment_pipeline;
const struct wined3d_vertex_pipe_ops *vertex_pipeline; const struct wined3d_vertex_pipe_ops *vertex_pipeline;
struct shader_caps shader_caps;
struct fragment_caps ffp_caps; struct fragment_caps ffp_caps;
unsigned int i; unsigned int i;
HRESULT hr; HRESULT hr;
...@@ -5429,12 +5432,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, ...@@ -5429,12 +5432,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
device->create_parms.flags = flags; device->create_parms.flags = flags;
device->shader_backend = adapter->shader_backend; device->shader_backend = adapter->shader_backend;
device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
device->vs_version = shader_caps.vs_version;
device->gs_version = shader_caps.gs_version;
device->ps_version = shader_caps.ps_version;
device->d3d_vshader_constantF = shader_caps.vs_uniform_count;
device->d3d_pshader_constantF = shader_caps.ps_uniform_count;
vertex_pipeline = adapter->vertex_pipe; vertex_pipeline = adapter->vertex_pipe;
......
...@@ -2846,6 +2846,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter) ...@@ -2846,6 +2846,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING; adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
adapter->d3d_info.limits.vs_version = shader_caps.vs_version;
adapter->d3d_info.limits.gs_version = shader_caps.gs_version;
adapter->d3d_info.limits.ps_version = shader_caps.ps_version;
adapter->d3d_info.limits.vs_uniform_count = shader_caps.vs_uniform_count;
adapter->d3d_info.limits.ps_uniform_count = shader_caps.ps_uniform_count;
adapter->fragment_pipe->get_caps(gl_info, &fragment_caps); adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages; gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
......
...@@ -1625,6 +1625,7 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b ...@@ -1625,6 +1625,7 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b
const struct wined3d_shader_frontend *fe; const struct wined3d_shader_frontend *fe;
HRESULT hr; HRESULT hr;
unsigned int backend_version; unsigned int backend_version;
const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info;
TRACE("shader %p, byte_code %p, output_signature %p, float_const_count %u.\n", TRACE("shader %p, byte_code %p, output_signature %p, float_const_count %u.\n",
shader, byte_code, output_signature, float_const_count); shader, byte_code, output_signature, float_const_count);
...@@ -1672,13 +1673,13 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b ...@@ -1672,13 +1673,13 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b
switch (type) switch (type)
{ {
case WINED3D_SHADER_TYPE_VERTEX: case WINED3D_SHADER_TYPE_VERTEX:
backend_version = shader->device->vs_version; backend_version = d3d_info->limits.vs_version;
break; break;
case WINED3D_SHADER_TYPE_GEOMETRY: case WINED3D_SHADER_TYPE_GEOMETRY:
backend_version = shader->device->gs_version; backend_version = d3d_info->limits.gs_version;
break; break;
case WINED3D_SHADER_TYPE_PIXEL: case WINED3D_SHADER_TYPE_PIXEL:
backend_version = shader->device->ps_version; backend_version = d3d_info->limits.ps_version;
break; break;
default: default:
FIXME("No backend version-checking for this shader type\n"); FIXME("No backend version-checking for this shader type\n");
...@@ -1843,6 +1844,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader) ...@@ -1843,6 +1844,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major, DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major,
shader->reg_maps.shader_version.minor); shader->reg_maps.shader_version.minor);
struct wined3d_device *device = shader->device; struct wined3d_device *device = shader->device;
const DWORD vs_uniform_count = device->adapter->d3d_info.limits.vs_uniform_count;
shader->limits.packed_input = 0; shader->limits.packed_input = 0;
...@@ -1857,7 +1859,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader) ...@@ -1857,7 +1859,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
/* TODO: vs_1_1 has a minimum of 96 constants. What happens when /* TODO: vs_1_1 has a minimum of 96 constants. What happens when
* a vs_1_1 shader is used on a vs_3_0 capable card that has 256 * a vs_1_1 shader is used on a vs_3_0 capable card that has 256
* constants? */ * constants? */
shader->limits.constant_float = min(256, device->d3d_vshader_constantF); shader->limits.constant_float = min(256, vs_uniform_count);
break; break;
case WINED3D_SHADER_VERSION(2, 0): case WINED3D_SHADER_VERSION(2, 0):
...@@ -1866,7 +1868,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader) ...@@ -1866,7 +1868,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
shader->limits.constant_int = 16; shader->limits.constant_int = 16;
shader->limits.packed_output = 12; shader->limits.packed_output = 12;
shader->limits.sampler = 0; shader->limits.sampler = 0;
shader->limits.constant_float = min(256, device->d3d_vshader_constantF); shader->limits.constant_float = min(256, vs_uniform_count);
break; break;
case WINED3D_SHADER_VERSION(3, 0): case WINED3D_SHADER_VERSION(3, 0):
...@@ -1879,7 +1881,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader) ...@@ -1879,7 +1881,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
* drivers advertise 1024). d3d9.dll and d3d8.dll clamp the * drivers advertise 1024). d3d9.dll and d3d8.dll clamp the
* wined3d-advertised maximum. Clamp the constant limit for <= 3.0 * wined3d-advertised maximum. Clamp the constant limit for <= 3.0
* shaders to 256. */ * shaders to 256. */
shader->limits.constant_float = min(256, device->d3d_vshader_constantF); shader->limits.constant_float = min(256, vs_uniform_count);
break; break;
case WINED3D_SHADER_VERSION(4, 0): case WINED3D_SHADER_VERSION(4, 0):
...@@ -1896,7 +1898,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader) ...@@ -1896,7 +1898,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
shader->limits.constant_int = 16; shader->limits.constant_int = 16;
shader->limits.packed_output = 12; shader->limits.packed_output = 12;
shader->limits.sampler = 0; shader->limits.sampler = 0;
shader->limits.constant_float = min(256, device->d3d_vshader_constantF); shader->limits.constant_float = min(256, vs_uniform_count);
FIXME("Unrecognized vertex shader version \"%u.%u\".\n", FIXME("Unrecognized vertex shader version \"%u.%u\".\n",
shader->reg_maps.shader_version.major, shader->reg_maps.shader_version.major,
shader->reg_maps.shader_version.minor); shader->reg_maps.shader_version.minor);
...@@ -1911,11 +1913,12 @@ static HRESULT vertexshader_init(struct wined3d_shader *shader, struct wined3d_d ...@@ -1911,11 +1913,12 @@ static HRESULT vertexshader_init(struct wined3d_shader *shader, struct wined3d_d
unsigned int i; unsigned int i;
HRESULT hr; HRESULT hr;
WORD map; WORD map;
const DWORD vs_uniform_count = device->adapter->d3d_info.limits.vs_uniform_count;
if (!byte_code) return WINED3DERR_INVALIDCALL; if (!byte_code) return WINED3DERR_INVALIDCALL;
shader_init(shader, device, parent, parent_ops); shader_init(shader, device, parent, parent_ops);
hr = shader_set_function(shader, byte_code, output_signature, device->d3d_vshader_constantF, hr = shader_set_function(shader, byte_code, output_signature, vs_uniform_count,
WINED3D_SHADER_TYPE_VERTEX, max_version); WINED3D_SHADER_TYPE_VERTEX, max_version);
if (FAILED(hr)) if (FAILED(hr))
{ {
...@@ -2256,11 +2259,12 @@ static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_de ...@@ -2256,11 +2259,12 @@ static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_de
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
unsigned int i, highest_reg_used = 0, num_regs_used = 0; unsigned int i, highest_reg_used = 0, num_regs_used = 0;
HRESULT hr; HRESULT hr;
const DWORD ps_uniform_count = device->adapter->d3d_info.limits.ps_uniform_count;
if (!byte_code) return WINED3DERR_INVALIDCALL; if (!byte_code) return WINED3DERR_INVALIDCALL;
shader_init(shader, device, parent, parent_ops); shader_init(shader, device, parent, parent_ops);
hr = shader_set_function(shader, byte_code, output_signature, device->d3d_pshader_constantF, hr = shader_set_function(shader, byte_code, output_signature, ps_uniform_count,
WINED3D_SHADER_TYPE_PIXEL, max_version); WINED3D_SHADER_TYPE_PIXEL, max_version);
if (FAILED(hr)) if (FAILED(hr))
{ {
......
...@@ -194,31 +194,31 @@ static const DWORD vertex_states_sampler[] = ...@@ -194,31 +194,31 @@ static const DWORD vertex_states_sampler[] =
*/ */
static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *object) static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *object)
{ {
struct wined3d_device *device = object->device; const struct wined3d_d3d_info *d3d_info = &object->device->adapter->d3d_info;
/* Allocate space for floating point constants */ /* Allocate space for floating point constants */
object->state.ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->state.ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(float) * device->d3d_pshader_constantF * 4); sizeof(float) * d3d_info->limits.ps_uniform_count * 4);
if (!object->state.ps_consts_f) goto fail; if (!object->state.ps_consts_f) goto fail;
object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(BOOL) * device->d3d_pshader_constantF); sizeof(BOOL) * d3d_info->limits.ps_uniform_count);
if (!object->changed.pixelShaderConstantsF) goto fail; if (!object->changed.pixelShaderConstantsF) goto fail;
object->state.vs_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->state.vs_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(float) * device->d3d_vshader_constantF * 4); sizeof(float) * d3d_info->limits.vs_uniform_count * 4);
if (!object->state.vs_consts_f) goto fail; if (!object->state.vs_consts_f) goto fail;
object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(BOOL) * device->d3d_vshader_constantF); sizeof(BOOL) * d3d_info->limits.vs_uniform_count);
if (!object->changed.vertexShaderConstantsF) goto fail; if (!object->changed.vertexShaderConstantsF) goto fail;
object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0,
sizeof(DWORD) * device->d3d_vshader_constantF); sizeof(DWORD) * d3d_info->limits.vs_uniform_count);
if (!object->contained_vs_consts_f) goto fail; if (!object->contained_vs_consts_f) goto fail;
object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0,
sizeof(DWORD) * device->d3d_pshader_constantF); sizeof(DWORD) * d3d_info->limits.ps_uniform_count);
if (!object->contained_ps_consts_f) goto fail; if (!object->contained_ps_consts_f) goto fail;
return WINED3D_OK; return WINED3D_OK;
...@@ -330,7 +330,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state ...@@ -330,7 +330,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
{ {
struct wined3d_device *device = stateblock->device; const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
unsigned int i, j; unsigned int i, j;
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i) for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
...@@ -357,7 +357,7 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) ...@@ -357,7 +357,7 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
} }
} }
for (i = 0; i < device->d3d_vshader_constantF; ++i) for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
{ {
if (stateblock->changed.vertexShaderConstantsF[i]) if (stateblock->changed.vertexShaderConstantsF[i])
{ {
...@@ -384,7 +384,7 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) ...@@ -384,7 +384,7 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
} }
} }
for (i = 0; i < device->d3d_pshader_constantF; ++i) for (i = 0; i < d3d_info->limits.ps_uniform_count; ++i)
{ {
if (stateblock->changed.pixelShaderConstantsF[i]) if (stateblock->changed.pixelShaderConstantsF[i])
{ {
...@@ -1148,6 +1148,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock) ...@@ -1148,6 +1148,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
{ {
struct wined3d_device *device = stateblock->device; struct wined3d_device *device = stateblock->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
struct wined3d_state *state = &stateblock->state; struct wined3d_state *state = &stateblock->state;
union union
{ {
...@@ -1171,8 +1172,8 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock) ...@@ -1171,8 +1172,8 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
TRACE("stateblock %p.\n", stateblock); TRACE("stateblock %p.\n", stateblock);
memset(stateblock->changed.pixelShaderConstantsF, 0, device->d3d_pshader_constantF * sizeof(BOOL)); memset(stateblock->changed.pixelShaderConstantsF, 0, d3d_info->limits.ps_uniform_count * sizeof(BOOL));
memset(stateblock->changed.vertexShaderConstantsF, 0, device->d3d_vshader_constantF * sizeof(BOOL)); memset(stateblock->changed.vertexShaderConstantsF, 0, d3d_info->limits.vs_uniform_count * sizeof(BOOL));
/* Set some of the defaults for lights, transforms etc */ /* Set some of the defaults for lights, transforms etc */
state->transforms[WINED3D_TS_PROJECTION] = identity; state->transforms[WINED3D_TS_PROJECTION] = identity;
...@@ -1400,6 +1401,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, ...@@ -1400,6 +1401,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
{ {
unsigned int i; unsigned int i;
HRESULT hr; HRESULT hr;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
stateblock->ref = 1; stateblock->ref = 1;
stateblock->device = device; stateblock->device = device;
...@@ -1423,17 +1425,19 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, ...@@ -1423,17 +1425,19 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
{ {
case WINED3D_SBT_ALL: case WINED3D_SBT_ALL:
stateblock_init_lights(stateblock, device->stateBlock->state.light_map); stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_savedstates_set_all(&stateblock->changed, device->d3d_vshader_constantF, stateblock_savedstates_set_all(&stateblock->changed,
device->d3d_pshader_constantF); d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
break; break;
case WINED3D_SBT_PIXEL_STATE: case WINED3D_SBT_PIXEL_STATE:
stateblock_savedstates_set_pixel(&stateblock->changed, device->d3d_pshader_constantF); stateblock_savedstates_set_pixel(&stateblock->changed,
d3d_info->limits.ps_uniform_count);
break; break;
case WINED3D_SBT_VERTEX_STATE: case WINED3D_SBT_VERTEX_STATE:
stateblock_init_lights(stateblock, device->stateBlock->state.light_map); stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_savedstates_set_vertex(&stateblock->changed, device->d3d_vshader_constantF); stateblock_savedstates_set_vertex(&stateblock->changed,
d3d_info->limits.vs_uniform_count);
break; break;
default: default:
......
...@@ -1587,8 +1587,16 @@ struct wined3d_driver_info ...@@ -1587,8 +1587,16 @@ struct wined3d_driver_info
DWORD version_low; DWORD version_low;
}; };
struct wined3d_d3d_limits
{
UINT vs_version, gs_version, ps_version;
DWORD vs_uniform_count;
DWORD ps_uniform_count;
};
struct wined3d_d3d_info struct wined3d_d3d_info
{ {
struct wined3d_d3d_limits limits;
BOOL vs_clipping; BOOL vs_clipping;
}; };
...@@ -1729,8 +1737,6 @@ struct wined3d_device ...@@ -1729,8 +1737,6 @@ struct wined3d_device
const struct blit_shader *blitter; const struct blit_shader *blitter;
unsigned int max_ffp_textures; unsigned int max_ffp_textures;
UINT vs_version, gs_version, ps_version;
DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */
UINT instance_count; UINT instance_count;
WORD vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */ WORD vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */
......
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