Commit a85a5ffb authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Store the glsl program lookup table in the backend's private data.

parent 4904c807
...@@ -173,8 +173,6 @@ static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) { ...@@ -173,8 +173,6 @@ static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
GL_EXTCALL(glDeleteFramebuffersEXT(1, &This->dst_fbo)); GL_EXTCALL(glDeleteFramebuffersEXT(1, &This->dst_fbo));
} }
if (This->glsl_program_lookup) hash_table_destroy(This->glsl_program_lookup);
/* TODO: Clean up all the surfaces and textures! */ /* TODO: Clean up all the surfaces and textures! */
/* NOTE: You must release the parent if the object was created via a callback /* NOTE: You must release the parent if the object was created via a callback
** ***************************/ ** ***************************/
......
...@@ -2782,35 +2782,33 @@ void pshader_glsl_input_pack( ...@@ -2782,35 +2782,33 @@ void pshader_glsl_input_pack(
* Vertex Shader Specific Code begins here * Vertex Shader Specific Code begins here
********************************************/ ********************************************/
static void add_glsl_program_entry(IWineD3DDeviceImpl *device, struct glsl_shader_prog_link *entry) { static void add_glsl_program_entry(struct shader_glsl_priv *priv, struct glsl_shader_prog_link *entry) {
glsl_program_key_t *key; glsl_program_key_t *key;
key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t)); key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t));
key->vshader = entry->vshader; key->vshader = entry->vshader;
key->pshader = entry->pshader; key->pshader = entry->pshader;
hash_table_put(device->glsl_program_lookup, key, entry); hash_table_put(priv->glsl_program_lookup, key, entry);
} }
static struct glsl_shader_prog_link *get_glsl_program_entry(IWineD3DDeviceImpl *device, static struct glsl_shader_prog_link *get_glsl_program_entry(struct shader_glsl_priv *priv,
GLhandleARB vshader, GLhandleARB pshader) { GLhandleARB vshader, GLhandleARB pshader) {
glsl_program_key_t key; glsl_program_key_t key;
key.vshader = vshader; key.vshader = vshader;
key.pshader = pshader; key.pshader = pshader;
return (struct glsl_shader_prog_link *)hash_table_get(device->glsl_program_lookup, &key); return (struct glsl_shader_prog_link *)hash_table_get(priv->glsl_program_lookup, &key);
} }
void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_link *entry) { void delete_glsl_program_entry(struct shader_glsl_priv *priv, WineD3D_GL_Info *gl_info, struct glsl_shader_prog_link *entry) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
glsl_program_key_t *key; glsl_program_key_t *key;
key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t)); key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t));
key->vshader = entry->vshader; key->vshader = entry->vshader;
key->pshader = entry->pshader; key->pshader = entry->pshader;
hash_table_remove(This->glsl_program_lookup, key); hash_table_remove(priv->glsl_program_lookup, key);
GL_EXTCALL(glDeleteObjectARB(entry->programId)); GL_EXTCALL(glDeleteObjectARB(entry->programId));
if (entry->vshader) list_remove(&entry->vshader_entry); if (entry->vshader) list_remove(&entry->vshader_entry);
...@@ -3158,7 +3156,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use ...@@ -3158,7 +3156,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
GLhandleARB vshader_id = use_vs ? ((IWineD3DBaseShaderImpl*)vshader)->baseShader.prgId : 0; GLhandleARB vshader_id = use_vs ? ((IWineD3DBaseShaderImpl*)vshader)->baseShader.prgId : 0;
GLhandleARB pshader_id = use_ps ? ((IWineD3DBaseShaderImpl*)pshader)->baseShader.prgId : 0; GLhandleARB pshader_id = use_ps ? ((IWineD3DBaseShaderImpl*)pshader)->baseShader.prgId : 0;
entry = get_glsl_program_entry(This, vshader_id, pshader_id); entry = get_glsl_program_entry(priv, vshader_id, pshader_id);
if (entry) { if (entry) {
priv->glsl_program = entry; priv->glsl_program = entry;
return; return;
...@@ -3174,7 +3172,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use ...@@ -3174,7 +3172,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
entry->vshader = vshader_id; entry->vshader = vshader_id;
entry->pshader = pshader_id; entry->pshader = pshader_id;
/* Add the hash table entry */ /* Add the hash table entry */
add_glsl_program_entry(This, entry); add_glsl_program_entry(priv, entry);
/* Set the current program */ /* Set the current program */
priv->glsl_program = entry; priv->glsl_program = entry;
...@@ -3420,7 +3418,9 @@ static void shader_glsl_cleanup(IWineD3DDevice *iface) { ...@@ -3420,7 +3418,9 @@ static void shader_glsl_cleanup(IWineD3DDevice *iface) {
static void shader_glsl_destroy(IWineD3DBaseShader *iface) { static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
struct list *linked_programs; struct list *linked_programs;
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface; IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface;
WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *) This->baseShader.device)->adapter->gl_info; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
struct shader_glsl_priv *priv = (struct shader_glsl_priv *)device->shader_priv;
WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
/* Note: Do not use QueryInterface here to find out which shader type this is because this code /* Note: Do not use QueryInterface here to find out which shader type this is because this code
* can be called from IWineD3DBaseShader::Release * can be called from IWineD3DBaseShader::Release
...@@ -3436,11 +3436,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { ...@@ -3436,11 +3436,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
if(pshader) { if(pshader) {
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, pshader_entry) { LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, pshader_entry) {
delete_glsl_program_entry(This->baseShader.device, entry); delete_glsl_program_entry(priv, gl_info, entry);
} }
} else { } else {
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, vshader_entry) { LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, vshader_entry) {
delete_glsl_program_entry(This->baseShader.device, entry); delete_glsl_program_entry(priv, gl_info, entry);
} }
} }
} }
...@@ -3475,8 +3475,9 @@ static BOOL glsl_program_key_compare(void *keya, void *keyb) { ...@@ -3475,8 +3475,9 @@ static BOOL glsl_program_key_compare(void *keya, void *keyb) {
static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) { static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
This->shader_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));
This->glsl_program_lookup = hash_table_create(glsl_program_key_hash, glsl_program_key_compare); priv->glsl_program_lookup = hash_table_create(glsl_program_key_hash, glsl_program_key_compare);
This->shader_priv = priv;
return WINED3D_OK; return WINED3D_OK;
} }
......
...@@ -310,6 +310,7 @@ extern const shader_backend_t none_shader_backend; ...@@ -310,6 +310,7 @@ extern const shader_backend_t none_shader_backend;
/* GLSL shader private data */ /* GLSL shader private data */
struct shader_glsl_priv { struct shader_glsl_priv {
hash_table_t *glsl_program_lookup;
struct glsl_shader_prog_link *glsl_program; struct glsl_shader_prog_link *glsl_program;
GLhandleARB depth_blt_glsl_program_id; GLhandleARB depth_blt_glsl_program_id;
}; };
...@@ -824,7 +825,6 @@ struct IWineD3DDeviceImpl ...@@ -824,7 +825,6 @@ struct IWineD3DDeviceImpl
int vs_selected_mode; int vs_selected_mode;
int ps_selected_mode; int ps_selected_mode;
const shader_backend_t *shader_backend; const shader_backend_t *shader_backend;
hash_table_t *glsl_program_lookup;
void *shader_priv; void *shader_priv;
struct StateEntry StateTable[STATE_HIGHEST + 1]; struct StateEntry StateTable[STATE_HIGHEST + 1];
/* Array of functions for states which are handled by more than one pipeline part */ /* Array of functions for states which are handled by more than one pipeline part */
...@@ -1991,8 +1991,6 @@ extern const SHADER_OPCODE* shader_get_opcode( ...@@ -1991,8 +1991,6 @@ extern const SHADER_OPCODE* shader_get_opcode(
IWineD3DBaseShader *iface, IWineD3DBaseShader *iface,
const DWORD code); const DWORD code);
void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_link *entry);
/* Vertex shader utility functions */ /* Vertex shader utility functions */
extern BOOL vshader_get_input( extern BOOL vshader_get_input(
IWineD3DVertexShader* iface, IWineD3DVertexShader* iface,
......
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