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
const struct wined3d_stateblock *stateblock = device->stateBlock;
const struct wined3d_state *state = &stateblock->state;
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;
if (!from_shader_select)
......@@ -689,12 +690,12 @@ static void shader_arb_load_constants_internal(const struct wined3d_context *con
if (context != priv->last_context)
{
memset(priv->vshader_const_dirty, 1,
sizeof(*priv->vshader_const_dirty) * device->d3d_vshader_constantF);
priv->highest_dirty_vs_const = device->d3d_vshader_constantF;
sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count);
priv->highest_dirty_vs_const = d3d_info->limits.vs_uniform_count;
memset(priv->pshader_const_dirty, 1,
sizeof(*priv->pshader_const_dirty) * device->d3d_pshader_constantF);
priv->highest_dirty_ps_const = device->d3d_pshader_constantF;
sizeof(*priv->pshader_const_dirty) * d3d_info->limits.ps_uniform_count);
priv->highest_dirty_ps_const = d3d_info->limits.ps_uniform_count;
priv->last_context = context;
}
......@@ -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 fragment_caps fragment_caps;
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)))
{
......@@ -4867,18 +4869,18 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine
}
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)
goto fail;
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,
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)
goto fail;
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)
{
......
......@@ -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 i;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
device, start_register, constants, vector4f_count);
......@@ -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
* when adding start_register + vector4f_count. */
if (!constants
|| start_register + vector4f_count > device->d3d_vshader_constantF
|| start_register > device->d3d_vshader_constantF)
|| start_register + vector4f_count > d3d_info->limits.vs_uniform_count
|| start_register > d3d_info->limits.vs_uniform_count)
return WINED3DERR_INVALIDCALL;
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,
HRESULT CDECL wined3d_device_get_vs_consts_f(const struct wined3d_device *device,
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",
device, start_register, constants, vector4f_count);
......@@ -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 i;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
device, start_register, constants, vector4f_count);
......@@ -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
* when adding start_register + vector4f_count. */
if (!constants
|| start_register + vector4f_count > device->d3d_pshader_constantF
|| start_register > device->d3d_pshader_constantF)
|| start_register + vector4f_count > d3d_info->limits.ps_uniform_count
|| start_register > d3d_info->limits.ps_uniform_count)
return WINED3DERR_INVALIDCALL;
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,
HRESULT CDECL wined3d_device_get_ps_consts_f(const struct wined3d_device *device,
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",
device, start_register, constants, vector4f_count);
......@@ -5408,7 +5412,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct fragment_pipeline *fragment_pipeline;
const struct wined3d_vertex_pipe_ops *vertex_pipeline;
struct shader_caps shader_caps;
struct fragment_caps ffp_caps;
unsigned int i;
HRESULT hr;
......@@ -5429,12 +5432,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
device->create_parms.flags = flags;
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;
......
......@@ -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->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);
gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
......
......@@ -1625,6 +1625,7 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b
const struct wined3d_shader_frontend *fe;
HRESULT hr;
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",
shader, byte_code, output_signature, float_const_count);
......@@ -1672,13 +1673,13 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b
switch (type)
{
case WINED3D_SHADER_TYPE_VERTEX:
backend_version = shader->device->vs_version;
backend_version = d3d_info->limits.vs_version;
break;
case WINED3D_SHADER_TYPE_GEOMETRY:
backend_version = shader->device->gs_version;
backend_version = d3d_info->limits.gs_version;
break;
case WINED3D_SHADER_TYPE_PIXEL:
backend_version = shader->device->ps_version;
backend_version = d3d_info->limits.ps_version;
break;
default:
FIXME("No backend version-checking for this shader type\n");
......@@ -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,
shader->reg_maps.shader_version.minor);
struct wined3d_device *device = shader->device;
const DWORD vs_uniform_count = device->adapter->d3d_info.limits.vs_uniform_count;
shader->limits.packed_input = 0;
......@@ -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
* a vs_1_1 shader is used on a vs_3_0 capable card that has 256
* constants? */
shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
shader->limits.constant_float = min(256, vs_uniform_count);
break;
case WINED3D_SHADER_VERSION(2, 0):
......@@ -1866,7 +1868,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
shader->limits.constant_int = 16;
shader->limits.packed_output = 12;
shader->limits.sampler = 0;
shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
shader->limits.constant_float = min(256, vs_uniform_count);
break;
case WINED3D_SHADER_VERSION(3, 0):
......@@ -1879,7 +1881,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
* drivers advertise 1024). d3d9.dll and d3d8.dll clamp the
* wined3d-advertised maximum. Clamp the constant limit for <= 3.0
* shaders to 256. */
shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
shader->limits.constant_float = min(256, vs_uniform_count);
break;
case WINED3D_SHADER_VERSION(4, 0):
......@@ -1896,7 +1898,7 @@ static void vertexshader_set_limits(struct wined3d_shader *shader)
shader->limits.constant_int = 16;
shader->limits.packed_output = 12;
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",
shader->reg_maps.shader_version.major,
shader->reg_maps.shader_version.minor);
......@@ -1911,11 +1913,12 @@ static HRESULT vertexshader_init(struct wined3d_shader *shader, struct wined3d_d
unsigned int i;
HRESULT hr;
WORD map;
const DWORD vs_uniform_count = device->adapter->d3d_info.limits.vs_uniform_count;
if (!byte_code) return WINED3DERR_INVALIDCALL;
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);
if (FAILED(hr))
{
......@@ -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;
unsigned int i, highest_reg_used = 0, num_regs_used = 0;
HRESULT hr;
const DWORD ps_uniform_count = device->adapter->d3d_info.limits.ps_uniform_count;
if (!byte_code) return WINED3DERR_INVALIDCALL;
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);
if (FAILED(hr))
{
......
......@@ -194,31 +194,31 @@ static const DWORD vertex_states_sampler[] =
*/
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 */
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;
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;
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;
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;
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;
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;
return WINED3D_OK;
......@@ -330,7 +330,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
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;
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
......@@ -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])
{
......@@ -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])
{
......@@ -1148,6 +1148,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
{
struct wined3d_device *device = stateblock->device;
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;
union
{
......@@ -1171,8 +1172,8 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
TRACE("stateblock %p.\n", stateblock);
memset(stateblock->changed.pixelShaderConstantsF, 0, device->d3d_pshader_constantF * sizeof(BOOL));
memset(stateblock->changed.vertexShaderConstantsF, 0, device->d3d_vshader_constantF * sizeof(BOOL));
memset(stateblock->changed.pixelShaderConstantsF, 0, d3d_info->limits.ps_uniform_count * sizeof(BOOL));
memset(stateblock->changed.vertexShaderConstantsF, 0, d3d_info->limits.vs_uniform_count * sizeof(BOOL));
/* Set some of the defaults for lights, transforms etc */
state->transforms[WINED3D_TS_PROJECTION] = identity;
......@@ -1400,6 +1401,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
{
unsigned int i;
HRESULT hr;
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
stateblock->ref = 1;
stateblock->device = device;
......@@ -1423,17 +1425,19 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
{
case WINED3D_SBT_ALL:
stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_savedstates_set_all(&stateblock->changed, device->d3d_vshader_constantF,
device->d3d_pshader_constantF);
stateblock_savedstates_set_all(&stateblock->changed,
d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
break;
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;
case WINED3D_SBT_VERTEX_STATE:
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;
default:
......
......@@ -1587,8 +1587,16 @@ struct wined3d_driver_info
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_limits limits;
BOOL vs_clipping;
};
......@@ -1729,8 +1737,6 @@ struct wined3d_device
const struct blit_shader *blitter;
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;
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