[Mesa-dev] [PATCH V3 2/4] i965: Initialize the SampleMap{2, 4, 8}x variables
Anuj Phogat
anuj.phogat at gmail.com
Mon Sep 29 16:33:34 PDT 2014
with values specific to Intel hardware.
V2: Define and use gen6_get_sample_map() function to initialize
the variables.
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/drivers/dri/i965/brw_context.c | 8 ++++
src/mesa/drivers/dri/i965/brw_context.h | 2 +
src/mesa/drivers/dri/i965/gen6_multisample_state.c | 52 ++++++++++++++++++++++
3 files changed, 62 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 619f2d5..879e4bf 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -406,6 +406,14 @@ brw_initialize_context_constants(struct brw_context *brw)
ctx->Const.MaxDepthTextureSamples = max_samples;
ctx->Const.MaxIntegerSamples = max_samples;
+ /* SampleMap{2,4,8}x variables are used to map indices of rectangular grid
+ * to sample numbers within a pixel. For more details see the comment above
+ * gen6_get_sample_map() definition.
+ */
+ ctx->Const.SampleMap2x = (unsigned *) gen6_get_sample_map(2);
+ ctx->Const.SampleMap4x = (unsigned *) gen6_get_sample_map(4);
+ ctx->Const.SampleMap8x = (unsigned *) gen6_get_sample_map(8);
+
if (brw->gen >= 7)
ctx->Const.MaxProgramTextureGatherComponents = 4;
else if (brw->gen == 6)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 5830aa99..30313c8 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1660,6 +1660,8 @@ gen6_get_sample_position(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLuint index,
GLfloat *result);
+const unsigned *
+gen6_get_sample_map(unsigned samples);
/* gen8_multisample_state.c */
void gen8_emit_3dstate_multisample(struct brw_context *brw, unsigned num_samp);
diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
index 429a590..467f1af 100644
--- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
@@ -57,6 +57,58 @@ gen6_get_sample_position(struct gl_context *ctx,
}
/**
+ * Sample index layout shows the numbering of slots in a rectangular
+ * grid of samples with in a pixel. Sample number layout shows the
+ * rectangular grid of samples roughly corresponding to the real sample
+ * locations with in a pixel. Sample number layout matches the sample
+ * index layout in case of 2X and 4x MSAA, but they are different in
+ * case of 8X MSAA.
+ *
+ * 2X MSAA sample index / number layout
+ * ---------
+ * | 0 | 1 |
+ * ---------
+ *
+ * 4X MSAA sample index / number layout
+ * ---------
+ * | 0 | 1 |
+ * ---------
+ * | 2 | 3 |
+ * ---------
+ *
+ * 8X MSAA sample index layout 8x MSAA sample number layout
+ * --------- ---------
+ * | 0 | 1 | | 5 | 2 |
+ * --------- ---------
+ * | 2 | 3 | | 4 | 6 |
+ * --------- ---------
+ * | 4 | 5 | | 0 | 3 |
+ * --------- ---------
+ * | 6 | 7 | | 7 | 1 |
+ * --------- ---------
+ *
+ * A sample map is used to map sample indices to sample numbers.
+ */
+const unsigned *
+gen6_get_sample_map(unsigned samples)
+{
+ static const unsigned map_2x[2] = {0, 1};
+ static const unsigned map_4x[4] = {0, 1, 2, 3};
+ static const unsigned map_8x[8] = {5, 2, 4, 6, 0, 3, 7, 1};
+
+ switch (samples) {
+ case 2:
+ return map_2x;
+ case 4:
+ return map_4x;
+ case 8:
+ return map_8x;
+ default:
+ unreachable("Not implemented");
+ }
+}
+
+/**
* 3DSTATE_MULTISAMPLE
*/
void
--
1.9.3
More information about the mesa-dev
mailing list