Commit fb989f1d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Implement version checks for geometry shaders.

parent 62670c7b
...@@ -4978,28 +4978,30 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh ...@@ -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]) 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"); TRACE("Hardware vertex shader version 3.0 enabled (NV_VERTEX_PROGRAM3)\n");
} }
else if (vs_consts >= 256) else if (vs_consts >= 256)
{ {
/* Shader Model 2.0 requires at least 256 vertex shader constants */ /* 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"); TRACE("Hardware vertex shader version 2.0 enabled (ARB_PROGRAM)\n");
} }
else else
{ {
caps->VertexShaderVersion = 1; caps->vs_version = 1;
TRACE("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n"); TRACE("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
} }
caps->MaxVertexShaderConst = vs_consts; caps->vs_uniform_count = vs_consts;
} }
else else
{ {
caps->VertexShaderVersion = 0; caps->vs_version = 0;
caps->MaxVertexShaderConst = 0; caps->vs_uniform_count = 0;
} }
caps->gs_version = 0;
if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
{ {
DWORD ps_consts; DWORD ps_consts;
...@@ -5013,31 +5015,31 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh ...@@ -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]) 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"); TRACE("Hardware pixel shader version 3.0 enabled (NV_FRAGMENT_PROGRAM2)\n");
} }
else if (ps_consts >= 32) else if (ps_consts >= 32)
{ {
/* Shader Model 2.0 requires at least 32 pixel shader constants */ /* 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"); TRACE("Hardware pixel shader version 2.0 enabled (ARB_PROGRAM)\n");
} }
else else
{ {
caps->PixelShaderVersion = 1; caps->ps_version = 1;
TRACE("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n"); TRACE("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n");
} }
caps->PixelShader1xMaxValue = 8.0f; caps->ps_uniform_count = ps_consts;
caps->MaxPixelShaderConst = ps_consts; caps->ps_1x_max_value = 8.0f;
} }
else else
{ {
caps->PixelShaderVersion = 0; caps->ps_version = 0;
caps->PixelShader1xMaxValue = 0.0f; caps->ps_uniform_count = 0;
caps->MaxPixelShaderConst = 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) static BOOL shader_arb_color_fixup_supported(struct color_fixup_desc fixup)
......
...@@ -5547,11 +5547,12 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, ...@@ -5547,11 +5547,12 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
if (device->shader_backend) if (device->shader_backend)
{ {
device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
device->vshader_version = shader_caps.VertexShaderVersion; device->vs_version = shader_caps.vs_version;
device->pshader_version = shader_caps.PixelShaderVersion; device->gs_version = shader_caps.gs_version;
device->d3d_vshader_constantF = shader_caps.MaxVertexShaderConst; device->ps_version = shader_caps.ps_version;
device->d3d_pshader_constantF = shader_caps.MaxPixelShaderConst; device->d3d_vshader_constantF = shader_caps.vs_uniform_count;
device->vs_clipping = shader_caps.VSClipping; device->d3d_pshader_constantF = shader_caps.ps_uniform_count;
device->vs_clipping = shader_caps.vs_clipping;
} }
fragment_pipeline = adapter->fragment_pipe; fragment_pipeline = adapter->fragment_pipe;
device->frag_pipe = fragment_pipeline; device->frag_pipe = fragment_pipeline;
......
...@@ -4962,8 +4962,8 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte ...@@ -4962,8 +4962,8 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
} }
else else
{ {
caps->VertexShaderVersion = shader_caps.VertexShaderVersion; caps->VertexShaderVersion = shader_caps.vs_version;
caps->MaxVertexShaderConst = shader_caps.MaxVertexShaderConst; caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
} }
if (ps_selected_mode == SHADER_NONE) if (ps_selected_mode == SHADER_NONE)
...@@ -4972,8 +4972,8 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte ...@@ -4972,8 +4972,8 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
caps->PixelShaderVersion = 0; caps->PixelShaderVersion = 0;
caps->PixelShader1xMaxValue = 0.0f; caps->PixelShader1xMaxValue = 0.0f;
} else { } else {
caps->PixelShaderVersion = shader_caps.PixelShaderVersion; caps->PixelShaderVersion = shader_caps.ps_version;
caps->PixelShader1xMaxValue = shader_caps.PixelShader1xMaxValue; caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
} }
caps->TextureOpCaps = fragment_caps.TextureOpCaps; caps->TextureOpCaps = fragment_caps.TextureOpCaps;
......
...@@ -4964,27 +4964,25 @@ static void shader_glsl_context_destroyed(void *shader_priv, const struct wined3 ...@@ -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) 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] if (gl_info->supported[EXT_GPU_SHADER4] && gl_info->supported[ARB_GEOMETRY_SHADER4]
&& gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50)) && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50))
{ shader_model = 4;
caps->VertexShaderVersion = 4;
caps->PixelShaderVersion = 4;
}
/* ARB_shader_texture_lod or EXT_gpu_shader4 is required for the SM3 /* ARB_shader_texture_lod or EXT_gpu_shader4 is required for the SM3
* texldd and texldl instructions. */ * texldd and texldl instructions. */
else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD] || gl_info->supported[EXT_GPU_SHADER4]) else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD] || gl_info->supported[EXT_GPU_SHADER4])
{ shader_model = 3;
caps->VertexShaderVersion = 3;
caps->PixelShaderVersion = 3;
}
else else
{ shader_model = 2;
caps->VertexShaderVersion = 2; TRACE("Shader model %u.\n", shader_model);
caps->PixelShaderVersion = 2;
}
caps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants; caps->vs_version = shader_model;
caps->MaxPixelShaderConst = gl_info->limits.glsl_ps_float_constants; 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 /* FIXME: The following line is card dependent. -8.0 to 8.0 is the
* Direct3D minimum requirement. * Direct3D minimum requirement.
...@@ -4998,12 +4996,9 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s ...@@ -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 * the shader will generate incorrect results too. Unfortunately, GL deliberately doesn't
* offer a way to query this. * 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); caps->vs_clipping = TRUE;
TRACE("Hardware pixel shader version %u enabled (GLSL).\n", caps->PixelShaderVersion);
} }
static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup) static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup)
......
...@@ -1482,12 +1482,13 @@ static void shader_none_context_destroyed(void *shader_priv, const struct wined3 ...@@ -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) 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 */ /* Set the shader caps to 0 for the none shader backend */
caps->VertexShaderVersion = 0; caps->vs_version = 0;
caps->MaxVertexShaderConst = 0; caps->gs_version = 0;
caps->PixelShaderVersion = 0; caps->ps_version = 0;
caps->PixelShader1xMaxValue = 0.0f; caps->vs_uniform_count = 0;
caps->MaxPixelShaderConst = 0; caps->ps_uniform_count = 0;
caps->VSClipping = FALSE; caps->ps_1x_max_value = 0.0f;
caps->vs_clipping = FALSE;
} }
static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) 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 ...@@ -1581,10 +1582,13 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *b
switch (type) switch (type)
{ {
case WINED3D_SHADER_TYPE_VERTEX: 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; break;
case WINED3D_SHADER_TYPE_PIXEL: case WINED3D_SHADER_TYPE_PIXEL:
backend_version = shader->device->pshader_version; backend_version = shader->device->ps_version;
break; break;
default: default:
FIXME("No backend version-checking for this shader type\n"); FIXME("No backend version-checking for this shader type\n");
......
...@@ -702,15 +702,17 @@ extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN; ...@@ -702,15 +702,17 @@ extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *); typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
struct shader_caps { struct shader_caps
DWORD VertexShaderVersion; {
DWORD MaxVertexShaderConst; UINT vs_version;
UINT gs_version;
UINT ps_version;
DWORD PixelShaderVersion; DWORD vs_uniform_count;
float PixelShader1xMaxValue; DWORD ps_uniform_count;
DWORD MaxPixelShaderConst; float ps_1x_max_value;
BOOL VSClipping; BOOL vs_clipping;
}; };
enum tex_types enum tex_types
...@@ -1696,7 +1698,7 @@ struct wined3d_device ...@@ -1696,7 +1698,7 @@ struct wined3d_device
const struct blit_shader *blitter; const struct blit_shader *blitter;
unsigned int max_ffp_textures; 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 d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */
DWORD vs_clipping; DWORD vs_clipping;
......
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