aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/glsl/ir_function.cpp33
-rw-r--r--mesalib/src/mesa/main/depthstencil.c3
-rw-r--r--mesalib/src/mesa/main/formats.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c115
4 files changed, 91 insertions, 64 deletions
diff --git a/mesalib/src/glsl/ir_function.cpp b/mesalib/src/glsl/ir_function.cpp
index 1255072a5..0f2f1a0ee 100644
--- a/mesalib/src/glsl/ir_function.cpp
+++ b/mesalib/src/glsl/ir_function.cpp
@@ -165,8 +165,18 @@ ir_function_signature *
ir_function::matching_signature(const exec_list *actual_parameters)
{
ir_function_signature *match = NULL;
- int matched_score = 0;
-
+ bool multiple_inexact_matches = false;
+
+ /* From page 42 (page 49 of the PDF) of the GLSL 1.20 spec:
+ *
+ * "If an exact match is found, the other signatures are ignored, and
+ * the exact match is used. Otherwise, if no exact match is found, then
+ * the implicit conversions in Section 4.1.10 "Implicit Conversions" will
+ * be applied to the calling arguments if this can make their types match
+ * a signature. In this case, it is a semantic error if there are
+ * multiple ways to apply these conversions to the actual arguments of a
+ * call such that the call can be made to match multiple signatures."
+ */
foreach_iter(exec_list_iterator, iter, signatures) {
ir_function_signature *const sig =
(ir_function_signature *) iter.get();
@@ -178,13 +188,24 @@ ir_function::matching_signature(const exec_list *actual_parameters)
if (score == 0)
return sig;
- /* If we found a match with fewer conversions, use that instead */
- if (score > 0 && (match == NULL || score < matched_score)) {
- match = sig;
- matched_score = score;
+ if (score > 0) {
+ if (match == NULL)
+ match = sig;
+ else
+ multiple_inexact_matches = true;
}
}
+ /* There is no exact match (we would have returned it by now). If there
+ * are multiple inexact matches, the call is ambiguous, which is an error.
+ *
+ * FINISHME: Report a decent error. Returning NULL will likely result in
+ * FINISHME: a "no matching signature" error; it should report that the
+ * FINISHME: call is ambiguous. But reporting errors from here is hard.
+ */
+ if (multiple_inexact_matches)
+ return NULL;
+
return match;
}
diff --git a/mesalib/src/mesa/main/depthstencil.c b/mesalib/src/mesa/main/depthstencil.c
index 4d0600050..40d6c9612 100644
--- a/mesalib/src/mesa/main/depthstencil.c
+++ b/mesalib/src/mesa/main/depthstencil.c
@@ -63,7 +63,8 @@ static void
delete_wrapper(struct gl_renderbuffer *rb)
{
ASSERT(rb->Format == MESA_FORMAT_S8 ||
- rb->Format == MESA_FORMAT_X8_Z24);
+ rb->Format == MESA_FORMAT_X8_Z24 ||
+ rb->Format == MESA_FORMAT_Z32_FLOAT);
_mesa_reference_renderbuffer(&rb->Wrapped, NULL);
free(rb);
}
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index f58b19756..f9298d2d1 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1485,7 +1485,9 @@ _mesa_test_formats(void)
info->DataType == GL_SIGNED_NORMALIZED ||
info->DataType == GL_UNSIGNED_INT ||
info->DataType == GL_INT ||
- info->DataType == GL_FLOAT);
+ info->DataType == GL_FLOAT ||
+ /* Z32_FLOAT_X24S8 has DataType of GL_NONE */
+ info->DataType == GL_NONE);
if (info->BaseFormat == GL_RGB) {
assert(info->RedBits > 0);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index dca332464..1d908c031 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -273,26 +273,6 @@ make_passthrough_vertex_shader(struct st_context *st,
/**
- * Return a texture base format for drawing/copying an image
- * of the given format.
- */
-static GLenum
-base_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH_COMPONENT:
- return GL_DEPTH_COMPONENT;
- case GL_DEPTH_STENCIL:
- return GL_DEPTH_STENCIL;
- case GL_STENCIL_INDEX:
- return GL_STENCIL_INDEX;
- default:
- return GL_RGBA;
- }
-}
-
-
-/**
* Return a texture internalFormat for drawing/copying an image
* of the given format and type.
*/
@@ -301,11 +281,36 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type)
{
switch (format) {
case GL_DEPTH_COMPONENT:
- return GL_DEPTH_COMPONENT;
+ switch (type) {
+ case GL_UNSIGNED_SHORT:
+ return GL_DEPTH_COMPONENT16;
+
+ case GL_UNSIGNED_INT:
+ return GL_DEPTH_COMPONENT32;
+
+ case GL_FLOAT:
+ if (ctx->Extensions.ARB_depth_buffer_float)
+ return GL_DEPTH_COMPONENT32F;
+ else
+ return GL_DEPTH_COMPONENT;
+
+ default:
+ return GL_DEPTH_COMPONENT;
+ }
+
case GL_DEPTH_STENCIL:
- return GL_DEPTH_STENCIL;
+ switch (type) {
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return GL_DEPTH32F_STENCIL8;
+
+ case GL_UNSIGNED_INT_24_8:
+ default:
+ return GL_DEPTH24_STENCIL8;
+ }
+
case GL_STENCIL_INDEX:
return GL_STENCIL_INDEX;
+
default:
if (_mesa_is_integer_format(format)) {
switch (type) {
@@ -999,7 +1004,6 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE;
struct pipe_sampler_view *sv[2];
int num_sampler_view = 1;
- enum pipe_format stencil_format = PIPE_FORMAT_NONE;
struct st_fp_variant *fpv;
if (format == GL_DEPTH_STENCIL)
@@ -1009,33 +1013,12 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
else if (format == GL_DEPTH_COMPONENT)
write_depth = GL_TRUE;
- if (write_stencil) {
- enum pipe_format tex_format;
- /* can we write to stencil if not fallback */
- if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT))
- goto stencil_fallback;
-
- tex_format = st_choose_format(st->pipe->screen, base_format(format),
- GL_NONE, GL_NONE,
- PIPE_TEXTURE_2D,
- 0, PIPE_BIND_SAMPLER_VIEW);
-
- switch (tex_format) {
- case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
- stencil_format = PIPE_FORMAT_X24S8_USCALED;
- break;
- case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- stencil_format = PIPE_FORMAT_S8X24_USCALED;
- break;
- case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
- stencil_format = PIPE_FORMAT_X32_S8X24_USCALED;
- break;
- case PIPE_FORMAT_S8_USCALED:
- stencil_format = PIPE_FORMAT_S8_USCALED;
- break;
- default:
- goto stencil_fallback;
- }
+ if (write_stencil &&
+ !pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
+ /* software fallback */
+ draw_stencil_pixels(ctx, x, y, width, height, format, type,
+ unpack, pixels);
+ return;
}
/* Mesa state should be up to date by now */
@@ -1080,7 +1063,32 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
sv[0] = st_create_texture_sampler_view(st->pipe, pt);
if (sv[0]) {
- if (write_stencil) {
+ /* Create a second sampler view to read stencil.
+ * The stencil is written using the shader stencil export
+ * functionality. */
+ if (write_stencil) {
+ enum pipe_format stencil_format = PIPE_FORMAT_NONE;
+
+ switch (pt->format) {
+ case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+ case PIPE_FORMAT_X24S8_USCALED:
+ stencil_format = PIPE_FORMAT_X24S8_USCALED;
+ break;
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ case PIPE_FORMAT_S8X24_USCALED:
+ stencil_format = PIPE_FORMAT_S8X24_USCALED;
+ break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ case PIPE_FORMAT_X32_S8X24_USCALED:
+ stencil_format = PIPE_FORMAT_X32_S8X24_USCALED;
+ break;
+ case PIPE_FORMAT_S8_USCALED:
+ stencil_format = PIPE_FORMAT_S8_USCALED;
+ break;
+ default:
+ assert(0);
+ }
+
sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
stencil_format);
num_sampler_view++;
@@ -1101,11 +1109,6 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
pipe_resource_reference(&pt, NULL);
}
}
- return;
-
-stencil_fallback:
- draw_stencil_pixels(ctx, x, y, width, height, format, type,
- unpack, pixels);
}