summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2012-01-24 22:23:01 +0100
committerMarek Olšák <maraeo@gmail.com>2012-01-29 02:16:00 +0100
commit171be755223d99f8cc5cc1bdaf8bd7b4caa04b4f (patch)
tree4fa7b708b29027241eda8262dfa0c0e50fc8b2b4
parent1d01429c6a1ae679d0cc0cb61db1948fca5ced4c (diff)
st/mesa: add PIPE_CAP_GLSL_FEATURE_LEVEL, cleanup st_extensions.c
v2: handle the cap in r300 and r600 as well Additional info for r600g: The env var R600_GLSL130=1 enables GLSL 1.3. Along with R600_STREAMOUT=1, it enables full GL 3.
-rw-r--r--src/gallium/docs/source/screen.rst3
-rw-r--r--src/gallium/drivers/r300/r300_screen.c3
-rw-r--r--src/gallium/drivers/r600/r600_pipe.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/include/pipe/p_defines.h3
-rw-r--r--src/mesa/state_tracker/st_extensions.c49
6 files changed, 41 insertions, 22 deletions
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index 8161c64253d..2af9f74e902 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -91,12 +91,15 @@ The integer capabilities:
the vertex colors are always clamped. This is the default for DX9 hardware.
* ``PIPE_CAP_VERTEX_COLOR_CLAMPED``: Whether the driver is capable of
clamping vertex colors when they come out of a vertex shader. If unsupported,
the vertex colors are never clamped. This is the default for DX10 hardware.
If both clamped and unclamped CAPs are supported, the clamping can be
controlled through pipe_rasterizer_state.
+* ``PIPE_CAP_GLSL_FEATURE_LEVEL``: Whether the driver supports features
+ equivalent to a specific GLSL version. E.g. for GLSL 1.3, report 130.
+
.. _pipe_capf:
PIPE_CAPF_*
^^^^^^^^^^^^^^^^
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 48a65696359..9a9418bc927 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -102,12 +102,15 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TEXTURE_BARRIER:
case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
case PIPE_CAP_VERTEX_COLOR_CLAMPED:
return 1;
+ case PIPE_CAP_GLSL_FEATURE_LEVEL:
+ return 120;
+
/* r300 cannot do swizzling of compressed textures. Supported otherwise. */
case PIPE_CAP_TEXTURE_SWIZZLE:
return util_format_s3tc_enabled ? r300screen->caps.dxtc_swizzle : 1;
/* Supported on r500 only. */
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index c38fbc59c5a..1123557a5ec 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -364,12 +364,15 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_PRIMITIVE_RESTART:
case PIPE_CAP_CONDITIONAL_RENDER:
case PIPE_CAP_TEXTURE_BARRIER:
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
return 1;
+ case PIPE_CAP_GLSL_FEATURE_LEVEL:
+ return debug_get_bool_option("R600_GLSL130", FALSE) ? 130 : 120;
+
/* Supported except the original R600. */
case PIPE_CAP_INDEP_BLEND_ENABLE:
case PIPE_CAP_INDEP_BLEND_FUNC:
/* R600 doesn't support per-MRT blends */
return family == CHIP_R600 ? 0 : 1;
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 37bbc43f325..6cafeafbe19 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -129,12 +129,14 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_CONDITIONAL_RENDER:
return 1;
case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: /* draw module */
case PIPE_CAP_VERTEX_COLOR_CLAMPED: /* draw module */
return 1;
+ case PIPE_CAP_GLSL_FEATURE_LEVEL:
+ return 130;
default:
return 0;
}
}
static int
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 2cd11f988ab..000be3d86cf 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -484,13 +484,14 @@ enum pipe_cap {
PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS = 55,
PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS = 56,
PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME = 57,
PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS = 58, /* temporary */
PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS = 59, /* temporary */
PIPE_CAP_VERTEX_COLOR_UNCLAMPED = 60,
- PIPE_CAP_VERTEX_COLOR_CLAMPED = 61
+ PIPE_CAP_VERTEX_COLOR_CLAMPED = 61,
+ PIPE_CAP_GLSL_FEATURE_LEVEL = 62,
};
/**
* Implementation limits which are queried through
* pipe_screen::get_paramf()
*/
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 49709d34260..f8b9ff879eb 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -255,16 +255,13 @@ static GLboolean st_get_s3tc_override(void)
* Some fine tuning may still be needed.
*/
void st_init_extensions(struct st_context *st)
{
struct pipe_screen *screen = st->pipe->screen;
struct gl_context *ctx = st->ctx;
- int i;
-
- ctx->Const.GLSLVersion = 120;
- _mesa_override_glsl_version(st->ctx);
+ int i, glsl_feature_level;
/*
* Extensions that are supported by all Gallium drivers:
*/
ctx->Extensions.ARB_copy_buffer = GL_TRUE;
ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
@@ -327,12 +324,39 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.OES_EGL_image_external = GL_TRUE;
#endif
#if FEATURE_OES_draw_texture
ctx->Extensions.OES_draw_texture = GL_TRUE;
#endif
+ /* Figure out GLSL support. */
+ glsl_feature_level = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL);
+
+ if (glsl_feature_level >= 130) {
+ ctx->Const.GLSLVersion = 130;
+ } else {
+ ctx->Const.GLSLVersion = 120;
+ }
+
+ _mesa_override_glsl_version(st->ctx);
+
+ if (ctx->Const.GLSLVersion >= 130) {
+ ctx->Const.NativeIntegers = GL_TRUE;
+ ctx->Const.MaxClipPlanes = 8;
+
+ /* Extensions that only depend on GLSL 1.3. */
+ ctx->Extensions.ARB_conservative_depth = GL_TRUE;
+ } else {
+ /* Optional integer support for GLSL 1.2. */
+ if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
+ PIPE_SHADER_CAP_INTEGERS) &&
+ screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_INTEGERS)) {
+ ctx->Const.NativeIntegers = GL_TRUE;
+ }
+ }
+
/*
* Extensions that depend on the driver/hardware:
*/
if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) {
ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
}
@@ -575,29 +599,12 @@ void st_init_extensions(struct st_context *st)
PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
#if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
#endif
}
- if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
- PIPE_SHADER_CAP_INTEGERS) &&
- screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
- PIPE_SHADER_CAP_INTEGERS)) {
- ctx->Const.NativeIntegers = GL_TRUE;
- }
-
- if (ctx->Const.NativeIntegers)
- ctx->Const.GLSLVersion = 130;
-
- /* Extensions that only depend on the GLSL version:
- */
- if (ctx->Const.GLSLVersion >= 130) {
- ctx->Extensions.ARB_conservative_depth = GL_TRUE;
- ctx->Const.MaxClipPlanes = 8;
- }
-
ctx->Extensions.NV_primitive_restart = GL_TRUE;
if (!screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) {
st->sw_primitive_restart = GL_TRUE;
}
if (screen->get_param(screen, PIPE_CAP_DEPTH_CLIP_DISABLE)) {