From b30f59c56725441f23e8a13083b38d37a73d3c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 21 Jun 2016 13:09:56 +0200 Subject: [PATCH] wined3d: Add compute shader type. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/arb_program_shader.c | 4 +++- dlls/wined3d/context.c | 3 ++- dlls/wined3d/directx.c | 1 + dlls/wined3d/glsl_shader.c | 8 +++++++- dlls/wined3d/shader.c | 21 +++++++++++++++++++-- dlls/wined3d/utils.c | 1 + dlls/wined3d/wined3d_main.c | 3 +++ dlls/wined3d/wined3d_private.h | 5 ++++- 8 files changed, 40 insertions(+), 6 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 6810b21fb06..62102b2965a 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -4842,7 +4842,8 @@ static void shader_arb_disable(void *shader_priv, struct wined3d_context *contex | (1u << WINED3D_SHADER_TYPE_VERTEX) | (1u << WINED3D_SHADER_TYPE_GEOMETRY) | (1u << WINED3D_SHADER_TYPE_HULL) - | (1u << WINED3D_SHADER_TYPE_DOMAIN); + | (1u << WINED3D_SHADER_TYPE_DOMAIN) + | (1u << WINED3D_SHADER_TYPE_COMPUTE); } /* Context activation is done by the caller. */ @@ -5117,6 +5118,7 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh caps->hs_version = 0; caps->ds_version = 0; caps->gs_version = 0; + caps->cs_version = 0; if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) { diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index ae82a820d03..085ed03b729 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1987,7 +1987,8 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, | (1u << WINED3D_SHADER_TYPE_VERTEX) | (1u << WINED3D_SHADER_TYPE_GEOMETRY) | (1u << WINED3D_SHADER_TYPE_HULL) - | (1u << WINED3D_SHADER_TYPE_DOMAIN); + | (1u << WINED3D_SHADER_TYPE_DOMAIN) + | (1u << WINED3D_SHADER_TYPE_COMPUTE); /* If this happens to be the first context for the device, dummy textures * are not created yet. In that case, they will be created (and bound) by diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index cac89585271..03008cc49b0 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3839,6 +3839,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, DWORD adapter->d3d_info.limits.ds_version = shader_caps.ds_version; adapter->d3d_info.limits.gs_version = shader_caps.gs_version; adapter->d3d_info.limits.ps_version = shader_caps.ps_version; + adapter->d3d_info.limits.cs_version = shader_caps.cs_version; adapter->d3d_info.limits.vs_uniform_count = shader_caps.vs_uniform_count; adapter->d3d_info.limits.ps_uniform_count = shader_caps.ps_uniform_count; adapter->d3d_info.limits.varying_count = shader_caps.varying_count; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index cf4f72c2351..9223bf013bc 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -279,6 +279,7 @@ static const char *debug_gl_shader_type(GLenum type) WINED3D_TO_STR(GL_TESS_EVALUATION_SHADER); WINED3D_TO_STR(GL_GEOMETRY_SHADER); WINED3D_TO_STR(GL_FRAGMENT_SHADER); + WINED3D_TO_STR(GL_COMPUTE_SHADER); #undef WINED3D_TO_STR default: return wine_dbg_sprintf("UNKNOWN(%#x)", type); @@ -304,6 +305,9 @@ static const char *shader_glsl_get_prefix(enum wined3d_shader_type type) case WINED3D_SHADER_TYPE_PIXEL: return "ps"; + case WINED3D_SHADER_TYPE_COMPUTE: + return "cs"; + default: FIXME("Unhandled shader type %#x.\n", type); return "unknown"; @@ -8092,7 +8096,8 @@ static void shader_glsl_invalidate_current_program(struct wined3d_context *conte | (1u << WINED3D_SHADER_TYPE_VERTEX) | (1u << WINED3D_SHADER_TYPE_GEOMETRY) | (1u << WINED3D_SHADER_TYPE_HULL) - | (1u << WINED3D_SHADER_TYPE_DOMAIN); + | (1u << WINED3D_SHADER_TYPE_DOMAIN) + | (1u << WINED3D_SHADER_TYPE_COMPUTE); } /* Context activation is done by the caller. */ @@ -8492,6 +8497,7 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s caps->ds_version = min(wined3d_settings.max_sm_ds, shader_model); caps->gs_version = min(wined3d_settings.max_sm_gs, shader_model); caps->ps_version = min(wined3d_settings.max_sm_ps, shader_model); + caps->cs_version = min(wined3d_settings.max_sm_cs, shader_model); caps->vs_uniform_count = min(WINED3D_MAX_VS_CONSTS_F, gl_info->limits.glsl_vs_float_constants); caps->ps_uniform_count = min(WINED3D_MAX_PS_CONSTS_F, gl_info->limits.glsl_ps_float_constants); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 33c6280b996..d0f6eebd5e0 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -582,6 +582,11 @@ static void shader_set_limits(struct wined3d_shader *shader) {WINED3D_SHADER_VERSION(3, 0), WINED3D_SHADER_VERSION(3, 0), {16, 16, 224, 16, 0, 12}}, {WINED3D_SHADER_VERSION(4, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 0, 32}}, {0} + }, + cs_limits[] = + { + /* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packed_input */ + {WINED3D_SHADER_VERSION(5, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 0, 0}}, }; const struct limits_entry *limits_array; DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major, @@ -608,6 +613,9 @@ static void shader_set_limits(struct wined3d_shader *shader) case WINED3D_SHADER_TYPE_PIXEL: limits_array = ps_limits; break; + case WINED3D_SHADER_TYPE_COMPUTE: + limits_array = cs_limits; + break; } while (limits_array[i].min_version && limits_array[i].min_version <= shader_version) @@ -2111,6 +2119,10 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe type_prefix = "ps"; break; + case WINED3D_SHADER_TYPE_COMPUTE: + type_prefix = "cs"; + break; + default: FIXME("Unhandled shader type %#x.\n", shader_version.type); type_prefix = "unknown"; @@ -2413,7 +2425,8 @@ static void shader_none_disable(void *shader_priv, struct wined3d_context *conte | (1u << WINED3D_SHADER_TYPE_VERTEX) | (1u << WINED3D_SHADER_TYPE_GEOMETRY) | (1u << WINED3D_SHADER_TYPE_HULL) - | (1u << WINED3D_SHADER_TYPE_DOMAIN); + | (1u << WINED3D_SHADER_TYPE_DOMAIN) + | (1u << WINED3D_SHADER_TYPE_COMPUTE); } static HRESULT shader_none_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, @@ -2475,6 +2488,7 @@ static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct s caps->ds_version = 0; caps->gs_version = 0; caps->ps_version = 0; + caps->cs_version = 0; caps->vs_uniform_count = 0; caps->ps_uniform_count = 0; caps->ps_1x_max_value = 0.0f; @@ -2584,8 +2598,11 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b case WINED3D_SHADER_TYPE_PIXEL: backend_version = d3d_info->limits.ps_version; break; + case WINED3D_SHADER_TYPE_COMPUTE: + backend_version = d3d_info->limits.cs_version; + break; default: - FIXME("No backend version-checking for this shader type\n"); + FIXME("No backend version-checking for this shader type.\n"); backend_version = 0; } if (reg_maps->shader_version.major > backend_version) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 878de10ad22..9575b3955cd 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4186,6 +4186,7 @@ const char *debug_shader_type(enum wined3d_shader_type type) WINED3D_TO_STR(WINED3D_SHADER_TYPE_GEOMETRY); WINED3D_TO_STR(WINED3D_SHADER_TYPE_HULL); WINED3D_TO_STR(WINED3D_SHADER_TYPE_DOMAIN); + WINED3D_TO_STR(WINED3D_SHADER_TYPE_COMPUTE); #undef WINED3D_TO_STR default: FIXME("Unrecognized shader type %#x.\n", type); diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 0a525288398..3e6bb7a010b 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -89,6 +89,7 @@ struct wined3d_settings wined3d_settings = ~0U, /* No DS shader model limit by default. */ ~0U, /* No GS shader model limit by default. */ ~0U, /* No PS shader model limit by default. */ + ~0u, /* No CS shader model limit by default. */ FALSE, /* 3D support enabled by default. */ }; @@ -325,6 +326,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) TRACE("Limiting GS shader model to %u.\n", wined3d_settings.max_sm_gs); if (!get_config_key_dword(hkey, appkey, "MaxShaderModelPS", &wined3d_settings.max_sm_ps)) TRACE("Limiting PS shader model to %u.\n", wined3d_settings.max_sm_ps); + if (!get_config_key_dword(hkey, appkey, "MaxShaderModelCS", &wined3d_settings.max_sm_cs)) + TRACE("Limiting CS shader model to %u.\n", wined3d_settings.max_sm_cs); if (!get_config_key(hkey, appkey, "DirectDrawRenderer", buffer, size) && !strcmp(buffer, "gdi")) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 43714a8a442..3b1d911d4db 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -308,6 +308,7 @@ struct wined3d_settings unsigned int max_sm_ds; unsigned int max_sm_gs; unsigned int max_sm_ps; + unsigned int max_sm_cs; BOOL no_3d; }; @@ -738,6 +739,7 @@ enum wined3d_shader_type WINED3D_SHADER_TYPE_GEOMETRY, WINED3D_SHADER_TYPE_HULL, WINED3D_SHADER_TYPE_DOMAIN, + WINED3D_SHADER_TYPE_COMPUTE, WINED3D_SHADER_TYPE_COUNT, }; @@ -981,6 +983,7 @@ struct shader_caps unsigned int ds_version; unsigned int gs_version; unsigned int ps_version; + unsigned int cs_version; DWORD vs_uniform_count; DWORD ps_uniform_count; @@ -2004,7 +2007,7 @@ struct wined3d_driver_info struct wined3d_d3d_limits { - unsigned int vs_version, hs_version, ds_version, gs_version, ps_version; + unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version; DWORD vs_uniform_count; DWORD ps_uniform_count; UINT varying_count;