Commit 4a19d893 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Only apply shader constants that changed.

This improves performance a bit for applications that use a lot of shaders with a lot of constants.
parent 684017c0
...@@ -57,9 +57,6 @@ HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) { ...@@ -57,9 +57,6 @@ HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(pshader_constantsF)); object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(pshader_constantsF));
if (!object->contained_ps_consts_f) goto fail; if (!object->contained_ps_consts_f) goto fail;
list_init(&object->set_vconstantsF);
list_init(&object->set_pconstantsF);
return WINED3D_OK; return WINED3D_OK;
fail: fail:
...@@ -252,7 +249,6 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) { ...@@ -252,7 +249,6 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
TRACE("(%p) : Releasing from %d\n", This, refCount + 1); TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
if (!refCount) { if (!refCount) {
constants_entry *constant, *constant2;
int counter; int counter;
/* type 0 represents the primary stateblock, so free all the resources */ /* type 0 represents the primary stateblock, so free all the resources */
...@@ -294,15 +290,6 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) { ...@@ -294,15 +290,6 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF); HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, This->contained_vs_consts_f); HeapFree(GetProcessHeap(), 0, This->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, This->contained_ps_consts_f); HeapFree(GetProcessHeap(), 0, This->contained_ps_consts_f);
LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_vconstantsF, constants_entry, entry) {
HeapFree(GetProcessHeap(), 0, constant);
}
LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_pconstantsF, constants_entry, entry) {
HeapFree(GetProcessHeap(), 0, constant);
}
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return refCount; return refCount;
......
...@@ -1723,6 +1723,16 @@ void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *val ...@@ -1723,6 +1723,16 @@ void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *val
HeapFree(GetProcessHeap(), 0, table); HeapFree(GetProcessHeap(), 0, table);
} }
void hash_table_for_each_entry(struct hash_table_t *table, void (*callback)(void *value, void *context), void *context)
{
unsigned int i = 0;
for (i = 0; i < table->entry_count; ++i)
{
callback(table->entries[i].value, context);
}
}
static inline struct hash_table_entry_t *hash_table_get_by_idx(const struct hash_table_t *table, const void *key, static inline struct hash_table_entry_t *hash_table_get_by_idx(const struct hash_table_t *table, const void *key,
unsigned int idx) unsigned int idx)
{ {
......
...@@ -153,6 +153,7 @@ struct hash_table_t { ...@@ -153,6 +153,7 @@ struct hash_table_t {
struct hash_table_t *hash_table_create(hash_function_t *hash_function, compare_function_t *compare_function); struct hash_table_t *hash_table_create(hash_function_t *hash_function, compare_function_t *compare_function);
void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *value, void *cb), void *cb); void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *value, void *cb), void *cb);
void hash_table_for_each_entry(struct hash_table_t *table, void (*callback)(void *value, void *context), void *context);
void *hash_table_get(const struct hash_table_t *table, const void *key); void *hash_table_get(const struct hash_table_t *table, const void *key);
void hash_table_put(struct hash_table_t *table, void *key, void *value); void hash_table_put(struct hash_table_t *table, void *key, void *value);
void hash_table_remove(struct hash_table_t *table, void *key); void hash_table_remove(struct hash_table_t *table, void *key);
...@@ -1784,12 +1785,6 @@ typedef struct SAVEDSTATES { ...@@ -1784,12 +1785,6 @@ typedef struct SAVEDSTATES {
BOOL scissorRect; BOOL scissorRect;
} SAVEDSTATES; } SAVEDSTATES;
typedef struct {
struct list entry;
DWORD count;
DWORD idx[13];
} constants_entry;
struct StageState { struct StageState {
DWORD stage; DWORD stage;
DWORD state; DWORD state;
...@@ -1808,8 +1803,6 @@ struct IWineD3DStateBlockImpl ...@@ -1808,8 +1803,6 @@ struct IWineD3DStateBlockImpl
/* Array indicating whether things have been set or changed */ /* Array indicating whether things have been set or changed */
SAVEDSTATES changed; SAVEDSTATES changed;
struct list set_vconstantsF;
struct list set_pconstantsF;
/* Vertex Shader Declaration */ /* Vertex Shader Declaration */
IWineD3DVertexDeclaration *vertexDecl; IWineD3DVertexDeclaration *vertexDecl;
......
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