From fb989f1d1eb092f3273a206964f01376b93bc398 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 18 Sep 2012 22:13:59 +0200 Subject: [PATCH] wined3d: Implement version checks for geometry shaders. --- dlls/wined3d/arb_program_shader.c | 32 ++++++++++++++++-------------- dlls/wined3d/device.c | 11 ++++++----- dlls/wined3d/directx.c | 8 ++++---- dlls/wined3d/glsl_shader.c | 33 +++++++++++++------------------ dlls/wined3d/shader.c | 20 +++++++++++-------- dlls/wined3d/wined3d_private.h | 18 +++++++++-------- 6 files changed, 63 insertions(+), 59 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 1195563c494..a54a37f976b 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -4978,28 +4978,30 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh if (gl_info->supported[NV_VERTEX_PROGRAM3]) { - caps->VertexShaderVersion = 3; + caps->vs_version = 3; TRACE("Hardware vertex shader version 3.0 enabled (NV_VERTEX_PROGRAM3)\n"); } else if (vs_consts >= 256) { /* Shader Model 2.0 requires at least 256 vertex shader constants */ - caps->VertexShaderVersion = 2; + caps->vs_version = 2; TRACE("Hardware vertex shader version 2.0 enabled (ARB_PROGRAM)\n"); } else { - caps->VertexShaderVersion = 1; + caps->vs_version = 1; TRACE("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n"); } - caps->MaxVertexShaderConst = vs_consts; + caps->vs_uniform_count = vs_consts; } else { - caps->VertexShaderVersion = 0; - caps->MaxVertexShaderConst = 0; + caps->vs_version = 0; + caps->vs_uniform_count = 0; } + caps->gs_version = 0; + if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) { DWORD ps_consts; @@ -5013,31 +5015,31 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh if (gl_info->supported[NV_FRAGMENT_PROGRAM2]) { - caps->PixelShaderVersion = 3; + caps->ps_version = 3; TRACE("Hardware pixel shader version 3.0 enabled (NV_FRAGMENT_PROGRAM2)\n"); } else if (ps_consts >= 32) { /* Shader Model 2.0 requires at least 32 pixel shader constants */ - caps->PixelShaderVersion = 2; + caps->ps_version = 2; TRACE("Hardware pixel shader version 2.0 enabled (ARB_PROGRAM)\n"); } else { - caps->PixelShaderVersion = 1; + caps->ps_version = 1; TRACE("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n"); } - caps->PixelShader1xMaxValue = 8.0f; - caps->MaxPixelShaderConst = ps_consts; + caps->ps_uniform_count = ps_consts; + caps->ps_1x_max_value = 8.0f; } else { - caps->PixelShaderVersion = 0; - caps->PixelShader1xMaxValue = 0.0f; - caps->MaxPixelShaderConst = 0; + caps->ps_version = 0; + caps->ps_uniform_count = 0; + caps->ps_1x_max_value = 0.0f; } - caps->VSClipping = use_nv_clip(gl_info); + caps->vs_clipping = use_nv_clip(gl_info); } static BOOL shader_arb_color_fixup_supported(struct color_fixup_desc fixup) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 69518b49be8..8439c13e086 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5547,11 +5547,12 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, if (device->shader_backend) { device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); - device->vshader_version = shader_caps.VertexShaderVersion; - device->pshader_version = shader_caps.PixelShaderVersion; - device->d3d_vshader_constantF = shader_caps.MaxVertexShaderConst; - device->d3d_pshader_constantF = shader_caps.MaxPixelShaderConst; - device->vs_clipping = shader_caps.VSClipping; + device->vs_version = shader_caps.vs_version; + device->gs_version = shader_caps.gs_version; + device->ps_version = shader_caps.ps_version; + device->d3d_vshader_constantF = shader_caps.vs_uniform_count; + device->d3d_pshader_constantF = shader_caps.ps_uniform_count; + device->vs_clipping = shader_caps.vs_clipping; } fragment_pipeline = adapter->fragment_pipe; device->frag_pipe = fragment_pipeline; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 36aafeed532..0354b0a49a4 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4962,8 +4962,8 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte } else { - caps->VertexShaderVersion = shader_caps.VertexShaderVersion; - caps->MaxVertexShaderConst = shader_caps.MaxVertexShaderConst; + caps->VertexShaderVersion = shader_caps.vs_version; + caps->MaxVertexShaderConst = shader_caps.vs_uniform_count; } if (ps_selected_mode == SHADER_NONE) @@ -4972,8 +4972,8 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte caps->PixelShaderVersion = 0; caps->PixelShader1xMaxValue = 0.0f; } else { - caps->PixelShaderVersion = shader_caps.PixelShaderVersion; - caps->PixelShader1xMaxValue = shader_caps.PixelShader1xMaxValue; + caps->PixelShaderVersion = shader_caps.ps_version; + caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value; } caps->TextureOpCaps = fragment_caps.TextureOpCaps; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index afbdb22d76f..aece4d0ab97 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -4964,27 +4964,25 @@ static void shader_glsl_context_destroyed(void *shader_priv, const struct wined3 static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps) { + UINT shader_model; + if (gl_info->supported[EXT_GPU_SHADER4] && gl_info->supported[ARB_GEOMETRY_SHADER4] && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50)) - { - caps->VertexShaderVersion = 4; - caps->PixelShaderVersion = 4; - } + shader_model = 4; /* ARB_shader_texture_lod or EXT_gpu_shader4 is required for the SM3 * texldd and texldl instructions. */ else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD] || gl_info->supported[EXT_GPU_SHADER4]) - { - caps->VertexShaderVersion = 3; - caps->PixelShaderVersion = 3; - } + shader_model = 3; else - { - caps->VertexShaderVersion = 2; - caps->PixelShaderVersion = 2; - } + shader_model = 2; + TRACE("Shader model %u.\n", shader_model); - caps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants; - caps->MaxPixelShaderConst = gl_info->limits.glsl_ps_float_constants; + caps->vs_version = shader_model; + caps->gs_version = shader_model; + caps->ps_version = shader_model; + + caps->vs_uniform_count = gl_info->limits.glsl_vs_float_constants; + caps->ps_uniform_count = gl_info->limits.glsl_ps_float_constants; /* FIXME: The following line is card dependent. -8.0 to 8.0 is the * Direct3D minimum requirement. @@ -4998,12 +4996,9 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s * the shader will generate incorrect results too. Unfortunately, GL deliberately doesn't * offer a way to query this. */ - caps->PixelShader1xMaxValue = 8.0; + caps->ps_1x_max_value = 8.0; - caps->VSClipping = TRUE; - - TRACE("Hardware vertex shader version %u enabled (GLSL).\n", caps->VertexShaderVersion); - TRACE("Hardware pixel shader version %u enabled (GLSL).\n", caps->PixelShaderVersion); + caps->vs_clipping = TRUE; } static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup) diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index aaf34460149..3e309a637a8 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1482,12 +1482,13 @@ static void shader_none_context_destroyed(void *shader_priv, const struct wined3 static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps) { /* Set the shader caps to 0 for the none shader backend */ - caps->VertexShaderVersion = 0; - caps->MaxVertexShaderConst = 0; - caps->PixelShaderVersion = 0; - caps->PixelShader1xMaxValue = 0.0f; - caps->MaxPixelShaderConst = 0; - caps->VSClipping = FALSE; + caps->vs_version = 0; + caps->gs_version = 0; + caps->ps_version = 0; + caps->vs_uniform_count = 0; + caps->ps_uniform_count = 0; + caps->ps_1x_max_value = 0.0f; + caps->vs_clipping = FALSE; } static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) @@ -1581,10 +1582,13 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b switch (type) { case WINED3D_SHADER_TYPE_VERTEX: - backend_version = shader->device->vshader_version; + backend_version = shader->device->vs_version; + break; + case WINED3D_SHADER_TYPE_GEOMETRY: + backend_version = shader->device->gs_version; break; case WINED3D_SHADER_TYPE_PIXEL: - backend_version = shader->device->pshader_version; + backend_version = shader->device->ps_version; break; default: FIXME("No backend version-checking for this shader type\n"); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5ea23b453b0..258ac2d2238 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -702,15 +702,17 @@ extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN; typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *); -struct shader_caps { - DWORD VertexShaderVersion; - DWORD MaxVertexShaderConst; +struct shader_caps +{ + UINT vs_version; + UINT gs_version; + UINT ps_version; - DWORD PixelShaderVersion; - float PixelShader1xMaxValue; - DWORD MaxPixelShaderConst; + DWORD vs_uniform_count; + DWORD ps_uniform_count; + float ps_1x_max_value; - BOOL VSClipping; + BOOL vs_clipping; }; enum tex_types @@ -1696,7 +1698,7 @@ struct wined3d_device const struct blit_shader *blitter; unsigned int max_ffp_textures; - DWORD vshader_version, pshader_version; + UINT vs_version, gs_version, ps_version; DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */ DWORD vs_clipping;