Commit 8b8e081d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Keep track of contained indices in struct constant_heap itself.

parent 74faebd6
...@@ -84,6 +84,7 @@ struct constant_entry ...@@ -84,6 +84,7 @@ struct constant_entry
struct constant_heap struct constant_heap
{ {
struct constant_entry *entries; struct constant_entry *entries;
BOOL *contained;
unsigned int *positions; unsigned int *positions;
unsigned int size; unsigned int size;
}; };
...@@ -932,12 +933,21 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context ...@@ -932,12 +933,21 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
} }
} }
static void update_heap_entry(const struct constant_heap *heap, unsigned int idx, static void update_heap_entry(struct constant_heap *heap, unsigned int idx, DWORD new_version)
unsigned int heap_idx, DWORD new_version)
{ {
struct constant_entry *entries = heap->entries; struct constant_entry *entries = heap->entries;
unsigned int *positions = heap->positions; unsigned int *positions = heap->positions;
unsigned int parent_idx; unsigned int heap_idx, parent_idx;
if (!heap->contained[idx])
{
heap_idx = heap->size++;
heap->contained[idx] = TRUE;
}
else
{
heap_idx = positions[idx];
}
while (heap_idx > 1) while (heap_idx > 1)
{ {
...@@ -963,10 +973,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev ...@@ -963,10 +973,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
for (i = start; i < count + start; ++i) for (i = start; i < count + start; ++i)
{ {
if (!device->stateBlock->changed.vertexShaderConstantsF[i]) update_heap_entry(heap, i, priv->next_constant_version);
update_heap_entry(heap, i, heap->size++, priv->next_constant_version);
else
update_heap_entry(heap, i, heap->positions[i], priv->next_constant_version);
} }
for (i = 0; i < device->context_count; ++i) for (i = 0; i < device->context_count; ++i)
...@@ -983,10 +990,7 @@ static void shader_glsl_update_float_pixel_constants(struct wined3d_device *devi ...@@ -983,10 +990,7 @@ static void shader_glsl_update_float_pixel_constants(struct wined3d_device *devi
for (i = start; i < count + start; ++i) for (i = start; i < count + start; ++i)
{ {
if (!device->stateBlock->changed.pixelShaderConstantsF[i]) update_heap_entry(heap, i, priv->next_constant_version);
update_heap_entry(heap, i, heap->size++, priv->next_constant_version);
else
update_heap_entry(heap, i, heap->positions[i], priv->next_constant_version);
} }
for (i = 0; i < device->context_count; ++i) for (i = 0; i < device->context_count; ++i)
...@@ -6475,7 +6479,9 @@ static int glsl_program_key_compare(const void *key, const struct wine_rb_entry ...@@ -6475,7 +6479,9 @@ static int glsl_program_key_compare(const void *key, const struct wine_rb_entry
static BOOL constant_heap_init(struct constant_heap *heap, unsigned int constant_count) static BOOL constant_heap_init(struct constant_heap *heap, unsigned int constant_count)
{ {
SIZE_T size = (constant_count + 1) * sizeof(*heap->entries) + constant_count * sizeof(*heap->positions); SIZE_T size = (constant_count + 1) * sizeof(*heap->entries)
+ constant_count * sizeof(*heap->contained)
+ constant_count * sizeof(*heap->positions);
void *mem = HeapAlloc(GetProcessHeap(), 0, size); void *mem = HeapAlloc(GetProcessHeap(), 0, size);
if (!mem) if (!mem)
...@@ -6486,7 +6492,9 @@ static BOOL constant_heap_init(struct constant_heap *heap, unsigned int constant ...@@ -6486,7 +6492,9 @@ static BOOL constant_heap_init(struct constant_heap *heap, unsigned int constant
heap->entries = mem; heap->entries = mem;
heap->entries[1].version = 0; heap->entries[1].version = 0;
heap->positions = (unsigned int *)(heap->entries + constant_count + 1); heap->contained = (BOOL *)(heap->entries + constant_count + 1);
memset(heap->contained, 0, constant_count * sizeof(*heap->contained));
heap->positions = (unsigned int *)(heap->contained + constant_count);
heap->size = 1; heap->size = 1;
return TRUE; return TRUE;
......
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