=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Implement immediate constant buffer in GLSL backend.
Alexandre Julliard
julliard at winehq.org
Fri Jul 8 10:02:06 CDT 2016
Module: wine
Branch: master
Commit: 9fb41539ea6bd48bfb4d49cb584772b31c945f77
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9fb41539ea6bd48bfb4d49cb584772b31c945f77
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Fri Jul 8 12:12:32 2016 +0200
wined3d: Implement immediate constant buffer in GLSL backend.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/glsl_shader.c | 30 +++++++++++++++++++++++++++++-
dlls/wined3d/shader.c | 2 +-
dlls/wined3d/shader_sm4.c | 2 +-
dlls/wined3d/wined3d_private.h | 2 +-
4 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7ad5acd..2c04260 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -559,6 +559,26 @@ static void shader_glsl_load_samplers(const struct wined3d_gl_info *gl_info,
string_buffer_release(&priv->string_buffers, sampler_name);
}
+static void shader_glsl_load_icb(const struct wined3d_gl_info *gl_info, struct shader_glsl_priv *priv,
+ GLuint program_id, const struct wined3d_shader_reg_maps *reg_maps)
+{
+ const struct wined3d_shader_immediate_constant_buffer *icb = reg_maps->icb;
+
+ if (icb)
+ {
+ struct wined3d_string_buffer *icb_name = string_buffer_get(&priv->string_buffers);
+ const char *prefix = shader_glsl_get_prefix(reg_maps->shader_version.type);
+ GLint icb_location;
+
+ string_buffer_sprintf(icb_name, "%s_icb", prefix);
+ icb_location = GL_EXTCALL(glGetUniformLocation(program_id, icb_name->buffer));
+ GL_EXTCALL(glUniform4fv(icb_location, icb->vec4_count, (const GLfloat *)icb->data));
+ checkGLcall("Load immediate constant buffer");
+
+ string_buffer_release(&priv->string_buffers, icb_name);
+ }
+}
+
/* Context activation is done by the caller. */
static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, const struct wined3d_vec4 *constants,
const GLint *constant_locations, const struct constant_heap *heap, unsigned char *stack, DWORD version)
@@ -1892,6 +1912,11 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
if (shader->limits->constant_bool > 0 && reg_maps->boolean_constants)
shader_addline(buffer, "uniform bool %s_b[%u];\n", prefix, shader->limits->constant_bool);
+ /* Declare immediate constant buffer */
+ if (reg_maps->icb)
+ shader_addline(buffer, "uniform vec4 %s_icb[%u];\n", prefix, reg_maps->icb->vec4_count);
+
+ /* Declare constant buffers */
for (i = 0; i < WINED3D_MAX_CBS; ++i)
{
if (reg_maps->cb_sizes[i])
@@ -7863,6 +7888,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
entry->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP;
shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &vshader->reg_maps);
+ shader_glsl_load_icb(gl_info, priv, program_id, &vshader->reg_maps);
}
else
{
@@ -7903,6 +7929,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
{
entry->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP;
shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &gshader->reg_maps);
+ shader_glsl_load_icb(gl_info, priv, program_id, &gshader->reg_maps);
}
if (ps_id)
@@ -7918,6 +7945,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_Y_CORR;
shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &pshader->reg_maps);
+ shader_glsl_load_icb(gl_info, priv, program_id, &pshader->reg_maps);
}
else
{
@@ -8611,7 +8639,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_DCL_GLOBAL_FLAGS */ shader_glsl_nop,
/* WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT */ NULL,
/* WINED3DSIH_DCL_HS_MAX_TESSFACTOR */ NULL,
- /* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ NULL,
+ /* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ shader_glsl_nop,
/* WINED3DSIH_DCL_INDEXABLE_TEMP */ shader_glsl_nop,
/* WINED3DSIH_DCL_INPUT */ shader_glsl_nop,
/* WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT */ NULL,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 9a9eafb..08cee35 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2235,7 +2235,7 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
{
shader_addline(&buffer, "%s {\n", shader_opcode_names[ins.handler_idx]);
- for (i = 0; i < ins.declaration.icb->element_count / 4; ++i)
+ for (i = 0; i < ins.declaration.icb->vec4_count; ++i)
{
shader_addline(&buffer, " {0x%08x, 0x%08x, 0x%08x, 0x%08x},\n",
ins.declaration.icb->data[4 * i + 0],
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index 72cd5fc..c8fdb32 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -447,7 +447,7 @@ static void shader_sm4_read_shader_data(struct wined3d_shader_instruction *ins,
return;
}
- priv->icb.element_count = icb_size;
+ priv->icb.vec4_count = icb_size / 4;
memcpy(priv->icb.data, tokens, sizeof(*tokens) * icb_size);
ins->declaration.icb = &priv->icb;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3de14e8..41c127b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -790,7 +790,7 @@ struct wined3d_shader_sampler_map
struct wined3d_shader_immediate_constant_buffer
{
- UINT element_count;
+ unsigned int vec4_count;
DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
};
More information about the wine-cvs
mailing list