aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/drivers')
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c40
-rw-r--r--mesalib/src/mesa/drivers/common/meta.h40
-rw-r--r--mesalib/src/mesa/drivers/common/meta_blit.c37
-rw-r--r--mesalib/src/mesa/drivers/common/meta_copy_image.c2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/utils.c2
5 files changed, 62 insertions, 59 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 90befd42d..7a8e627ba 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -396,25 +396,6 @@ _mesa_meta_init(struct gl_context *ctx)
ctx->Meta = CALLOC_STRUCT(gl_meta_state);
}
-static GLenum
-gl_buffer_index_to_drawbuffers_enum(gl_buffer_index bufindex)
-{
- assert(bufindex < BUFFER_COUNT);
-
- if (bufindex >= BUFFER_COLOR0)
- return GL_COLOR_ATTACHMENT0 + bufindex - BUFFER_COLOR0;
- else if (bufindex == BUFFER_FRONT_LEFT)
- return GL_FRONT_LEFT;
- else if (bufindex == BUFFER_FRONT_RIGHT)
- return GL_FRONT_RIGHT;
- else if (bufindex == BUFFER_BACK_LEFT)
- return GL_BACK_LEFT;
- else if (bufindex == BUFFER_BACK_RIGHT)
- return GL_BACK_RIGHT;
-
- return GL_NONE;
-}
-
/**
* Free context meta-op state.
* To be called once during context destruction.
@@ -806,20 +787,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
}
if (state & MESA_META_DRAW_BUFFERS) {
- int buf, real_color_buffers = 0;
- memset(save->ColorDrawBuffers, 0, sizeof(save->ColorDrawBuffers));
-
- for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
- int buf_index = ctx->DrawBuffer->_ColorDrawBufferIndexes[buf];
- if (buf_index == -1)
- continue;
-
- save->ColorDrawBuffers[buf] =
- gl_buffer_index_to_drawbuffers_enum(buf_index);
-
- if (++real_color_buffers >= ctx->DrawBuffer->_NumColorDrawBuffers)
- break;
- }
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ memcpy(save->ColorDrawBuffers, fb->ColorDrawBuffer,
+ sizeof(save->ColorDrawBuffers));
}
/* misc */
@@ -1224,7 +1194,7 @@ _mesa_meta_end(struct gl_context *ctx)
_mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
if (state & MESA_META_DRAW_BUFFERS) {
- _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers, save->ColorDrawBuffers);
+ _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, save->ColorDrawBuffers, NULL);
}
ctx->Meta->SaveStackDepth--;
@@ -1250,7 +1220,7 @@ _mesa_meta_in_progress(struct gl_context *ctx)
* Used by the meta-Clear, Draw/CopyPixels and Bitmap functions where the Z
* value comes from the clear value or raster position.
*/
-static INLINE GLfloat
+static inline GLfloat
invert_z(GLfloat normZ)
{
GLfloat objZ = 1.0f - 2.0f * normZ;
diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h
index 56ba9bc65..edc3e8c20 100644
--- a/mesalib/src/mesa/drivers/common/meta.h
+++ b/mesalib/src/mesa/drivers/common/meta.h
@@ -235,21 +235,45 @@ struct blit_shader_table {
/**
* Indices in the blit_state->msaa_shaders[] array
*
- * Note that setup_glsl_msaa_blit_shader() assumes that the _INT enums are one
- * more than the non-_INT version and _UINT is one beyond that.
+ * Note that setup_glsl_msaa_blit_shader() assumes that the _INT enums are five
+ * more than the corresponding non-_INT versions and _UINT are five beyond that.
*/
enum blit_msaa_shader {
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
+ BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
+ BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
+ BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
+ BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
+ BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
+ BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
+ BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
+ BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
+ BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
+ BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
+ BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
+ BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY_INT,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY_UINT,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_RESOLVE,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY,
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
+ BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
+ BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
+ BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
+ BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
+ BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
+ BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
+ BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
+ BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
+ BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
+ BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
+ BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
+ BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY_INT,
BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY_UINT,
diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c
index 955e73f57..fc9848a7a 100644
--- a/mesalib/src/mesa/drivers/common/meta_blit.c
+++ b/mesalib/src/mesa/drivers/common/meta_blit.c
@@ -70,6 +70,16 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
const char *sampler_array_suffix = "";
char *name;
const char *texcoord_type = "vec2";
+ const int samples = MAX2(src_rb->NumSamples, 1);
+ int shader_offset = 0;
+
+ /* We expect only power of 2 samples in source multisample buffer. */
+ assert((samples & (samples - 1)) == 0);
+ while (samples >> (shader_offset + 1)) {
+ shader_offset++;
+ }
+ /* Update the assert if we plan to support more than 16X MSAA. */
+ assert(shader_offset >= 0 && shader_offset <= 4);
if (src_rb) {
src_datatype = _mesa_get_format_datatype(src_rb->Format);
@@ -107,13 +117,15 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
} else {
if (dst_is_msaa)
shader_index = BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY;
- else
- shader_index = BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE;
+ else {
+ shader_index = BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE +
+ shader_offset;
+ }
}
if (target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
- shader_index += (BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE -
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE);
+ shader_index += (BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE -
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE);
sampler_array_suffix = "Array";
texcoord_type = "vec3";
}
@@ -121,19 +133,19 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
default:
_mesa_problem(ctx, "Unkown texture target %s\n",
_mesa_lookup_enum_by_nr(target));
- shader_index = BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE;
+ shader_index = BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE;
}
/* We rely on the enum being sorted this way. */
- STATIC_ASSERT(BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT ==
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE + 1);
- STATIC_ASSERT(BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT ==
- BLIT_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE + 2);
+ STATIC_ASSERT(BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT ==
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE + 5);
+ STATIC_ASSERT(BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT ==
+ BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE + 10);
if (src_datatype == GL_INT) {
- shader_index++;
+ shader_index += 5;
vec4_prefix = "i";
} else if (src_datatype == GL_UNSIGNED_INT) {
- shader_index += 2;
+ shader_index += 10;
vec4_prefix = "u";
} else {
vec4_prefix = "";
@@ -209,7 +221,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
/* You can create 2D_MULTISAMPLE textures with 0 sample count (meaning 1
* sample). Yes, this is ridiculous.
*/
- int samples;
char *sample_resolve;
const char *arb_sample_shading_extension_string;
const char *merge_function;
@@ -217,8 +228,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
vec4_prefix,
dst_is_msaa ? "copy" : "resolve");
- samples = MAX2(src_rb->NumSamples, 1);
-
if (dst_is_msaa) {
arb_sample_shading_extension_string = "#extension GL_ARB_sample_shading : enable";
sample_resolve = ralloc_asprintf(mem_ctx, " out_color = texelFetch(texSampler, i%s(texCoords), gl_SampleID);", texcoord_type);
diff --git a/mesalib/src/mesa/drivers/common/meta_copy_image.c b/mesalib/src/mesa/drivers/common/meta_copy_image.c
index c40c2f011..0c204b87d 100644
--- a/mesalib/src/mesa/drivers/common/meta_copy_image.c
+++ b/mesalib/src/mesa/drivers/common/meta_copy_image.c
@@ -74,7 +74,7 @@ make_view(struct gl_context *ctx, struct gl_texture_image *tex_image,
tex_image->Depth,
0, internal_format, tex_format);
- view_tex_obj->MinLevel = 0;
+ view_tex_obj->MinLevel = tex_image->Level;
view_tex_obj->NumLevels = 1;
view_tex_obj->MinLayer = tex_obj->MinLayer;
view_tex_obj->NumLayers = tex_obj->NumLayers;
diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c
index e0b3db8cf..f2e63c0b9 100644
--- a/mesalib/src/mesa/drivers/dri/common/utils.c
+++ b/mesalib/src/mesa/drivers/dri/common/utils.c
@@ -238,7 +238,7 @@ driCreateConfigs(mesa_format format,
is_srgb = _mesa_get_format_color_encoding(format) == GL_SRGB;
num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * num_msaa_modes;
- configs = calloc(1, (num_modes + 1) * sizeof *configs);
+ configs = calloc(num_modes + 1, sizeof *configs);
if (configs == NULL)
return NULL;