mesa: Pass number of samples as a program state variable
authorAnuj Phogat <anuj.phogat@gmail.com>
Thu, 3 Oct 2013 01:02:20 +0000 (18:02 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Fri, 1 Nov 2013 23:01:47 +0000 (16:01 -0700)
Number of samples will be required in fragment shader program by new
GLSL builtin uniform "gl_NumSamples".

V2: Use "state.numsamples" in place of "state.num.samples"
    Use _NEW_BUFFERS flag in place of _NEW_MULTISAMPLE

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ian Romanick <idr@freedesktop.org>
Reviewed-by: Ken Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/program/prog_statevars.c
src/mesa/program/prog_statevars.h

index 145c07c67673be0169b64ad33fb2e60ea2fbefb5..f6fd53576c1f609a034e01209947c52ab4ee8138 100644 (file)
@@ -349,6 +349,9 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
          }
       }
       return;
+   case STATE_NUM_SAMPLES:
+      ((int *)value)[0] = ctx->DrawBuffer->Visual.samples;
+      return;
    case STATE_DEPTH_RANGE:
       value[0] = ctx->Viewport.Near;                     /* near       */
       value[1] = ctx->Viewport.Far;                      /* far        */
@@ -665,6 +668,9 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
    case STATE_PROGRAM_MATRIX:
       return _NEW_TRACK_MATRIX;
 
+   case STATE_NUM_SAMPLES:
+      return _NEW_BUFFERS;
+
    case STATE_DEPTH_RANGE:
       return _NEW_VIEWPORT;
 
@@ -852,6 +858,9 @@ append_token(char *dst, gl_state_index k)
    case STATE_TEXENV_COLOR:
       append(dst, "texenv");
       break;
+   case STATE_NUM_SAMPLES:
+      append(dst, "numsamples");
+      break;
    case STATE_DEPTH_RANGE:
       append(dst, "depth.range");
       break;
@@ -1027,6 +1036,8 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
       break;
    case STATE_FOG_COLOR:
       break;
+   case STATE_NUM_SAMPLES:
+      break;
    case STATE_DEPTH_RANGE:
       break;
    case STATE_FRAGMENT_PROGRAM:
index ec22b7376dedcbe8711ba9c942ad9df7f9cfe708..23a9f48c32f5337cdc0e2a08a4c3d9a9a13e789e 100644 (file)
@@ -103,6 +103,8 @@ typedef enum gl_state_index_ {
 
    STATE_TEXENV_COLOR,
 
+   STATE_NUM_SAMPLES,    /* An integer, not a float like the other state vars */
+
    STATE_DEPTH_RANGE,
 
    STATE_VERTEX_PROGRAM,