[PATCH 7/9] wined3d: Implement dcl_thread_group instruction.
Józef Kucia
jkucia at codeweavers.com
Thu Feb 9 05:00:34 CST 2017
GLSL 1.30 is not enough for layout qualifiers.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 10 ++++++++--
dlls/wined3d/shader.c | 12 ++++++++++++
dlls/wined3d/wined3d_private.h | 6 ++++++
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 2778a9f..cac8749 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -353,7 +353,8 @@ static const char *shader_glsl_get_prefix(enum wined3d_shader_type type)
static unsigned int shader_glsl_get_version(const struct wined3d_gl_info *gl_info,
const struct wined3d_shader_version *version)
{
- if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
+ if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]
+ || (version && version->type == WINED3D_SHADER_TYPE_COMPUTE))
return 150;
else if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30) && version && version->major >= 4)
return 130;
@@ -6584,6 +6585,7 @@ static GLuint shader_glsl_generate_compute_shader(const struct wined3d_context *
struct wined3d_string_buffer *buffer, struct wined3d_string_buffer_list *string_buffers,
const struct wined3d_shader *shader)
{
+ const struct wined3d_shader_thread_group_size *thread_group_size = &shader->u.cs.thread_group_size;
const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
const struct wined3d_gl_info *gl_info = context->gl_info;
const DWORD *function = shader->function;
@@ -6601,6 +6603,10 @@ static GLuint shader_glsl_generate_compute_shader(const struct wined3d_context *
memset(&priv_ctx, 0, sizeof(priv_ctx));
priv_ctx.string_buffers = string_buffers;
shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx);
+
+ shader_addline(buffer, "layout(local_size_x = %u, local_size_y = %u, local_size_z = %u) in;\n",
+ thread_group_size->x, thread_group_size->y, thread_group_size->z);
+
shader_addline(buffer, "void main()\n{\n");
shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
shader_addline(buffer, "}\n");
@@ -9203,7 +9209,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_DCL_TESSELLATOR_PARTITIONING */ NULL,
/* WINED3DSIH_DCL_TGSM_RAW */ NULL,
/* WINED3DSIH_DCL_TGSM_STRUCTURED */ NULL,
- /* WINED3DSIH_DCL_THREAD_GROUP */ NULL,
+ /* WINED3DSIH_DCL_THREAD_GROUP */ shader_glsl_nop,
/* WINED3DSIH_DCL_UAV_RAW */ NULL,
/* WINED3DSIH_DCL_UAV_STRUCTURED */ NULL,
/* WINED3DSIH_DCL_UAV_TYPED */ shader_glsl_nop,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 490c985..814da17 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1033,6 +1033,18 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
{
reg_maps->temporary_count = ins.declaration.count;
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_THREAD_GROUP)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_COMPUTE)
+ {
+ shader->u.cs.thread_group_size = ins.declaration.thread_group_size;
+ }
+ else
+ {
+ FIXME("Invalid instruction %#x for shader type %#x.\n",
+ ins.handler_idx, shader_version.type);
+ }
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_VERTICES_OUT)
{
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index acd822e..81061cc 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3560,6 +3560,11 @@ struct wined3d_pixel_shader
DWORD color0_reg;
};
+struct wined3d_compute_shader
+{
+ struct wined3d_shader_thread_group_size thread_group_size;
+};
+
struct wined3d_shader
{
LONG ref;
@@ -3597,6 +3602,7 @@ struct wined3d_shader
struct wined3d_vertex_shader vs;
struct wined3d_geometry_shader gs;
struct wined3d_pixel_shader ps;
+ struct wined3d_compute_shader cs;
} u;
};
--
2.10.2
More information about the wine-patches
mailing list