Commit aa5ccba8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Only allow 256 vertex shader vec4's.

parent 5b8fdb97
...@@ -303,7 +303,8 @@ struct shader_arb_priv ...@@ -303,7 +303,8 @@ struct shader_arb_priv
DWORD ps_sig_number; DWORD ps_sig_number;
unsigned int highest_dirty_ps_const, highest_dirty_vs_const; unsigned int highest_dirty_ps_const, highest_dirty_vs_const;
char *vshader_const_dirty, *pshader_const_dirty; char vshader_const_dirty[WINED3D_MAX_VS_CONSTS_F];
char *pshader_const_dirty;
const struct wined3d_context *last_context; const struct wined3d_context *last_context;
const struct wined3d_vertex_pipe_ops *vertex_pipe; const struct wined3d_vertex_pipe_ops *vertex_pipe;
...@@ -4998,10 +4999,6 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine ...@@ -4998,10 +4999,6 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine
return E_FAIL; return E_FAIL;
} }
priv->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count);
if (!priv->vshader_const_dirty)
goto fail;
memset(priv->vshader_const_dirty, 1, memset(priv->vshader_const_dirty, 1,
sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count); sizeof(*priv->vshader_const_dirty) * d3d_info->limits.vs_uniform_count);
...@@ -5031,7 +5028,6 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine ...@@ -5031,7 +5028,6 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine
fail: fail:
HeapFree(GetProcessHeap(), 0, priv->pshader_const_dirty); HeapFree(GetProcessHeap(), 0, priv->pshader_const_dirty);
HeapFree(GetProcessHeap(), 0, priv->vshader_const_dirty);
fragment_pipe->free_private(device); fragment_pipe->free_private(device);
vertex_pipe->vp_free(device); vertex_pipe->vp_free(device);
HeapFree(GetProcessHeap(), 0, priv); HeapFree(GetProcessHeap(), 0, priv);
...@@ -5075,7 +5071,6 @@ static void shader_arb_free(struct wined3d_device *device) ...@@ -5075,7 +5071,6 @@ static void shader_arb_free(struct wined3d_device *device)
wine_rb_destroy(&priv->signature_tree, release_signature, NULL); wine_rb_destroy(&priv->signature_tree, release_signature, NULL);
HeapFree(GetProcessHeap(), 0, priv->pshader_const_dirty); HeapFree(GetProcessHeap(), 0, priv->pshader_const_dirty);
HeapFree(GetProcessHeap(), 0, priv->vshader_const_dirty);
priv->fragment_pipe->free_private(device); priv->fragment_pipe->free_private(device);
priv->vertex_pipe->vp_free(device); priv->vertex_pipe->vp_free(device);
HeapFree(GetProcessHeap(), 0, device->shader_priv); HeapFree(GetProcessHeap(), 0, device->shader_priv);
...@@ -5133,7 +5128,7 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh ...@@ -5133,7 +5128,7 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh
TRACE("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n"); TRACE("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
} }
caps->vs_version = min(wined3d_settings.max_sm_vs, vs_version); caps->vs_version = min(wined3d_settings.max_sm_vs, vs_version);
caps->vs_uniform_count = vs_consts; caps->vs_uniform_count = min(WINED3D_MAX_VS_CONSTS_F, vs_consts);
} }
else else
{ {
......
...@@ -2485,8 +2485,8 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device, ...@@ -2485,8 +2485,8 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
} }
if (device->recording) if (device->recording)
memset(&device->recording->changed.vertexShaderConstantsF[start_idx], 1, memset(&device->recording->changed.vs_consts_f[start_idx], 1,
count * sizeof(*device->recording->changed.vertexShaderConstantsF)); count * sizeof(*device->recording->changed.vs_consts_f));
else else
device->shader_backend->shader_update_float_vertex_constants(device, start_idx, count); device->shader_backend->shader_update_float_vertex_constants(device, start_idx, count);
......
...@@ -117,7 +117,7 @@ struct glsl_vs_program ...@@ -117,7 +117,7 @@ struct glsl_vs_program
struct list shader_entry; struct list shader_entry;
GLuint id; GLuint id;
GLenum vertex_color_clamp; GLenum vertex_color_clamp;
GLint *uniform_f_locations; GLint uniform_f_locations[WINED3D_MAX_VS_CONSTS_F];
GLint uniform_i_locations[MAX_CONST_I]; GLint uniform_i_locations[MAX_CONST_I];
GLint uniform_b_locations[MAX_CONST_B]; GLint uniform_b_locations[MAX_CONST_B];
GLint pos_fixup_location; GLint pos_fixup_location;
...@@ -5137,7 +5137,6 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const struc ...@@ -5137,7 +5137,6 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const struc
list_remove(&entry->gs.shader_entry); list_remove(&entry->gs.shader_entry);
if (entry->ps.id) if (entry->ps.id)
list_remove(&entry->ps.shader_entry); list_remove(&entry->ps.shader_entry);
HeapFree(GetProcessHeap(), 0, entry->vs.uniform_f_locations);
HeapFree(GetProcessHeap(), 0, entry->ps.uniform_f_locations); HeapFree(GetProcessHeap(), 0, entry->ps.uniform_f_locations);
HeapFree(GetProcessHeap(), 0, entry); HeapFree(GetProcessHeap(), 0, entry);
} }
...@@ -7015,15 +7014,12 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info * ...@@ -7015,15 +7014,12 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
unsigned int i; unsigned int i;
struct wined3d_string_buffer *name = string_buffer_get(&priv->string_buffers); struct wined3d_string_buffer *name = string_buffer_get(&priv->string_buffers);
vs->uniform_f_locations = HeapAlloc(GetProcessHeap(), 0,
sizeof(GLuint) * gl_info->limits.glsl_vs_float_constants);
for (i = 0; i < vs_c_count; ++i) for (i = 0; i < vs_c_count; ++i)
{ {
string_buffer_sprintf(name, "vs_c[%u]", i); string_buffer_sprintf(name, "vs_c[%u]", i);
vs->uniform_f_locations[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer)); vs->uniform_f_locations[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer));
} }
memset(&vs->uniform_f_locations[vs_c_count], 0xff, memset(&vs->uniform_f_locations[vs_c_count], 0xff, (WINED3D_MAX_VS_CONSTS_F - vs_c_count) * sizeof(GLuint));
(gl_info->limits.glsl_vs_float_constants - vs_c_count) * sizeof(GLuint));
for (i = 0; i < MAX_CONST_I; ++i) for (i = 0; i < MAX_CONST_I; ++i)
{ {
...@@ -7373,7 +7369,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const ...@@ -7373,7 +7369,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
shader_glsl_validate_link(gl_info, program_id); shader_glsl_validate_link(gl_info, program_id);
shader_glsl_init_vs_uniform_locations(gl_info, priv, program_id, &entry->vs, shader_glsl_init_vs_uniform_locations(gl_info, priv, program_id, &entry->vs,
vshader ? min(vshader->limits->constant_float, gl_info->limits.glsl_vs_float_constants) : 0); vshader ? vshader->limits->constant_float : 0);
shader_glsl_init_ps_uniform_locations(gl_info, priv, program_id, &entry->ps, shader_glsl_init_ps_uniform_locations(gl_info, priv, program_id, &entry->ps,
pshader ? min(pshader->limits->constant_float, gl_info->limits.glsl_ps_float_constants) : 0); pshader ? min(pshader->limits->constant_float, gl_info->limits.glsl_ps_float_constants) : 0);
checkGLcall("Find glsl program uniform locations"); checkGLcall("Find glsl program uniform locations");
...@@ -7934,8 +7930,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win ...@@ -7934,8 +7930,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
{ {
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct shader_glsl_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_glsl_priv)); struct shader_glsl_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_glsl_priv));
SIZE_T stack_size = wined3d_log2i(max(gl_info->limits.glsl_vs_float_constants, SIZE_T stack_size = wined3d_log2i(max(WINED3D_MAX_VS_CONSTS_F, gl_info->limits.glsl_ps_float_constants)) + 1;
gl_info->limits.glsl_ps_float_constants)) + 1;
struct fragment_caps fragment_caps; struct fragment_caps fragment_caps;
void *vertex_priv, *fragment_priv; void *vertex_priv, *fragment_priv;
...@@ -7969,7 +7964,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win ...@@ -7969,7 +7964,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
goto fail; goto fail;
} }
if (!constant_heap_init(&priv->vconst_heap, gl_info->limits.glsl_vs_float_constants)) if (!constant_heap_init(&priv->vconst_heap, WINED3D_MAX_VS_CONSTS_F))
{ {
ERR("Failed to initialize vertex shader constant heap\n"); ERR("Failed to initialize vertex shader constant heap\n");
goto fail; goto fail;
...@@ -8090,7 +8085,7 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s ...@@ -8090,7 +8085,7 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s
caps->gs_version = min(wined3d_settings.max_sm_gs, shader_model); caps->gs_version = min(wined3d_settings.max_sm_gs, shader_model);
caps->ps_version = min(wined3d_settings.max_sm_ps, shader_model); caps->ps_version = min(wined3d_settings.max_sm_ps, shader_model);
caps->vs_uniform_count = gl_info->limits.glsl_vs_float_constants; caps->vs_uniform_count = min(WINED3D_MAX_VS_CONSTS_F, gl_info->limits.glsl_vs_float_constants);
caps->ps_uniform_count = gl_info->limits.glsl_ps_float_constants; caps->ps_uniform_count = gl_info->limits.glsl_ps_float_constants;
caps->varying_count = gl_info->limits.glsl_varyings; caps->varying_count = gl_info->limits.glsl_varyings;
......
...@@ -200,14 +200,6 @@ static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *o ...@@ -200,14 +200,6 @@ static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *o
sizeof(BOOL) * d3d_info->limits.ps_uniform_count); sizeof(BOOL) * d3d_info->limits.ps_uniform_count);
if (!object->changed.pixelShaderConstantsF) goto fail; if (!object->changed.pixelShaderConstantsF) goto fail;
object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(BOOL) * d3d_info->limits.vs_uniform_count);
if (!object->changed.vertexShaderConstantsF) goto fail;
object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0,
sizeof(DWORD) * d3d_info->limits.vs_uniform_count);
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) * d3d_info->limits.ps_uniform_count); sizeof(DWORD) * d3d_info->limits.ps_uniform_count);
if (!object->contained_ps_consts_f) goto fail; if (!object->contained_ps_consts_f) goto fail;
...@@ -217,8 +209,6 @@ static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *o ...@@ -217,8 +209,6 @@ static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *o
fail: fail:
ERR("Failed to allocate memory\n"); ERR("Failed to allocate memory\n");
HeapFree(GetProcessHeap(), 0, object->changed.pixelShaderConstantsF); HeapFree(GetProcessHeap(), 0, object->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, object->changed.vertexShaderConstantsF);
HeapFree(GetProcessHeap(), 0, object->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, object->contained_ps_consts_f); HeapFree(GetProcessHeap(), 0, object->contained_ps_consts_f);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -261,7 +251,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, ...@@ -261,7 +251,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states,
/* Dynamically sized arrays */ /* Dynamically sized arrays */
memset(states->pixelShaderConstantsF, TRUE, sizeof(BOOL) * ps_consts); memset(states->pixelShaderConstantsF, TRUE, sizeof(BOOL) * ps_consts);
memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * vs_consts); memset(states->vs_consts_f, TRUE, sizeof(BOOL) * vs_consts);
} }
static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants) static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
...@@ -314,7 +304,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state ...@@ -314,7 +304,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
states->vertexShaderConstantsB = 0xffff; states->vertexShaderConstantsB = 0xffff;
states->vertexShaderConstantsI = 0xffff; states->vertexShaderConstantsI = 0xffff;
memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * num_constants); memset(states->vs_consts_f, TRUE, sizeof(BOOL) * num_constants);
} }
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
...@@ -348,7 +338,7 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) ...@@ -348,7 +338,7 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i) for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
{ {
if (stateblock->changed.vertexShaderConstantsF[i]) if (stateblock->changed.vs_consts_f[i])
{ {
stateblock->contained_vs_consts_f[stateblock->num_contained_vs_consts_f] = i; stateblock->contained_vs_consts_f[stateblock->num_contained_vs_consts_f] = i;
++stateblock->num_contained_vs_consts_f; ++stateblock->num_contained_vs_consts_f;
...@@ -565,7 +555,6 @@ void state_cleanup(struct wined3d_state *state) ...@@ -565,7 +555,6 @@ void state_cleanup(struct wined3d_state *state)
} }
} }
HeapFree(GetProcessHeap(), 0, state->vs_consts_f);
HeapFree(GetProcessHeap(), 0, state->ps_consts_f); HeapFree(GetProcessHeap(), 0, state->ps_consts_f);
} }
...@@ -579,9 +568,7 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock) ...@@ -579,9 +568,7 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
{ {
state_cleanup(&stateblock->state); state_cleanup(&stateblock->state);
HeapFree(GetProcessHeap(), 0, stateblock->changed.vertexShaderConstantsF);
HeapFree(GetProcessHeap(), 0, stateblock->changed.pixelShaderConstantsF); HeapFree(GetProcessHeap(), 0, stateblock->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, stateblock->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->contained_ps_consts_f); HeapFree(GetProcessHeap(), 0, stateblock->contained_ps_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock); HeapFree(GetProcessHeap(), 0, stateblock);
} }
...@@ -1310,16 +1297,9 @@ HRESULT state_init(struct wined3d_state *state, struct wined3d_fb_state *fb, ...@@ -1310,16 +1297,9 @@ HRESULT state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
list_init(&state->light_map[i]); list_init(&state->light_map[i]);
} }
if (!(state->vs_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*state->vs_consts_f) * d3d_info->limits.vs_uniform_count)))
return E_OUTOFMEMORY;
if (!(state->ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, if (!(state->ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*state->ps_consts_f) * d3d_info->limits.ps_uniform_count))) sizeof(*state->ps_consts_f) * d3d_info->limits.ps_uniform_count)))
{
HeapFree(GetProcessHeap(), 0, state->vs_consts_f);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
if (flags & WINED3D_STATE_INIT_DEFAULT) if (flags & WINED3D_STATE_INIT_DEFAULT)
state_init_default(state, gl_info); state_init_default(state, gl_info);
......
...@@ -513,6 +513,7 @@ enum wined3d_shader_rel_op ...@@ -513,6 +513,7 @@ enum wined3d_shader_rel_op
#define MAX_CONST_I 16 #define MAX_CONST_I 16
#define MAX_CONST_B 16 #define MAX_CONST_B 16
#define WINED3D_MAX_CBS 15 #define WINED3D_MAX_CBS 15
#define WINED3D_MAX_VS_CONSTS_F 256
/* FIXME: This needs to go up to 2048 for /* FIXME: This needs to go up to 2048 for
* Shader model 3 according to msdn (and for software shaders) */ * Shader model 3 according to msdn (and for software shaders) */
...@@ -2212,7 +2213,7 @@ struct wined3d_state ...@@ -2212,7 +2213,7 @@ struct wined3d_state
BOOL vs_consts_b[MAX_CONST_B]; BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4]; INT vs_consts_i[MAX_CONST_I * 4];
struct wined3d_vec4 *vs_consts_f; struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
BOOL ps_consts_b[MAX_CONST_B]; BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4]; INT ps_consts_i[MAX_CONST_I * 4];
...@@ -2779,7 +2780,7 @@ struct wined3d_saved_states ...@@ -2779,7 +2780,7 @@ struct wined3d_saved_states
BOOL *pixelShaderConstantsF; BOOL *pixelShaderConstantsF;
WORD vertexShaderConstantsB; /* MAX_CONST_B, 16 */ WORD vertexShaderConstantsB; /* MAX_CONST_B, 16 */
WORD vertexShaderConstantsI; /* MAX_CONST_I, 16 */ WORD vertexShaderConstantsI; /* MAX_CONST_I, 16 */
BOOL *vertexShaderConstantsF; BOOL vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
DWORD textures : 20; /* MAX_COMBINED_SAMPLERS, 20 */ DWORD textures : 20; /* MAX_COMBINED_SAMPLERS, 20 */
DWORD primitive_type : 1; DWORD primitive_type : 1;
DWORD indices : 1; DWORD indices : 1;
...@@ -2815,7 +2816,7 @@ struct wined3d_stateblock ...@@ -2815,7 +2816,7 @@ struct wined3d_stateblock
unsigned int num_contained_vs_consts_i; unsigned int num_contained_vs_consts_i;
DWORD contained_vs_consts_b[MAX_CONST_B]; DWORD contained_vs_consts_b[MAX_CONST_B];
unsigned int num_contained_vs_consts_b; unsigned int num_contained_vs_consts_b;
DWORD *contained_vs_consts_f; DWORD contained_vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
unsigned int num_contained_vs_consts_f; unsigned int num_contained_vs_consts_f;
DWORD contained_ps_consts_i[MAX_CONST_I]; DWORD contained_ps_consts_i[MAX_CONST_I];
unsigned int num_contained_ps_consts_i; unsigned int num_contained_ps_consts_i;
......
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