}
break;
default:
- _mesa_problem(ctx, "Unkown texture target %s\n",
+ _mesa_problem(ctx, "Unknown texture target %s\n",
_mesa_enum_to_string(target));
shader_index = BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE;
}
shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_COPY ||
shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY) {
char *sample_index;
+ const char *tex_coords = "texCoords";
if (dst_is_msaa) {
sample_index = "gl_SampleID";
name = "depth MSAA copy";
+
+ if (ctx->Extensions.ARB_gpu_shader5 && samples >= 16) {
+ /* See comment below for the color copy */
+ tex_coords = "interpolateAtOffset(texCoords, vec2(0.0))";
+ }
} else {
/* From the GL 4.3 spec:
*
"#version 130\n"
"#extension GL_ARB_texture_multisample : enable\n"
"#extension GL_ARB_sample_shading : enable\n"
+ "#extension GL_ARB_gpu_shader5 : enable\n"
"uniform sampler2DMS%s texSampler;\n"
"in %s texCoords;\n"
"out vec4 out_color;\n"
"\n"
"void main()\n"
"{\n"
- " gl_FragDepth = texelFetch(texSampler, i%s(texCoords), %s).r;\n"
+ " gl_FragDepth = texelFetch(texSampler, i%s(%s), %s).r;\n"
"}\n",
sampler_array_suffix,
texcoord_type,
texcoord_type,
+ tex_coords,
sample_index);
} else {
/* You can create 2D_MULTISAMPLE textures with 0 sample count (meaning 1
dst_is_msaa ? "copy" : "resolve");
if (dst_is_msaa) {
- sample_resolve = ralloc_asprintf(mem_ctx, " out_color = texelFetch(texSampler, i%s(texCoords), gl_SampleID);", texcoord_type);
+ const char *tex_coords;
+
+ if (ctx->Extensions.ARB_gpu_shader5 && samples >= 16) {
+ /* If interpolateAtOffset is available then it will be used to
+ * force the interpolation to the center. This is required at
+ * least on Intel hardware because it is possible to have a sample
+ * position on the 0 x or y axis which means it will lie exactly
+ * on the pixel boundary. If we let the hardware interpolate the
+ * coordinates at one of these positions then it is possible for
+ * it to jump to a neighboring texel when converting to ints due
+ * to rounding errors. This is only done for >= 16x MSAA because
+ * it probably has some overhead. It is more likely that some
+ * hardware will use one of these problematic positions at 16x
+ * MSAA because in that case in D3D they are defined to be at
+ * these positions.
+ */
+ tex_coords = "interpolateAtOffset(texCoords, vec2(0.0))";
+ } else {
+ tex_coords = "texCoords";
+ }
+
+ sample_resolve =
+ ralloc_asprintf(mem_ctx,
+ " out_color = texelFetch(texSampler, "
+ "i%s(%s), gl_SampleID);",
+ texcoord_type, tex_coords);
+
merge_function = "";
} else {
int i;
"#version 130\n"
"#extension GL_ARB_texture_multisample : enable\n"
"#extension GL_ARB_sample_shading : enable\n"
+ "#extension GL_ARB_gpu_shader5 : enable\n"
"#define gvec4 %svec4\n"
"uniform %ssampler2DMS%s texSampler;\n"
"in %s texCoords;\n"
texcoord_size = 2 + (src_rb->Depth > 1 ? 1 : 0);
- _mesa_meta_setup_vertex_objects(&blit->VAO, &blit->VBO, true,
+ _mesa_meta_setup_vertex_objects(ctx, &blit->VAO, &blit->buf_obj, true,
2, texcoord_size, 0);
if (is_target_multisample && is_filter_scaled_resolve && is_scaled_blit) {
do_depth);
}
else {
- _mesa_meta_setup_ff_tnl_for_blit(&ctx->Meta->Blit.VAO,
- &ctx->Meta->Blit.VBO,
+ _mesa_meta_setup_ff_tnl_for_blit(ctx,
+ &ctx->Meta->Blit.VAO,
+ &ctx->Meta->Blit.buf_obj,
2);
}
verts[3].tex[1] = t1;
verts[3].tex[2] = readAtt->Zoffset;
- _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
+ _mesa_buffer_sub_data(ctx, blit->buf_obj, 0, sizeof(verts), verts,
+ __func__);
}
/* setup viewport */
}
void
-_mesa_meta_glsl_blit_cleanup(struct blit_state *blit)
+_mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit)
{
if (blit->VAO) {
_mesa_DeleteVertexArrays(1, &blit->VAO);
blit->VAO = 0;
- _mesa_DeleteBuffers(1, &blit->VBO);
- blit->VBO = 0;
+ _mesa_reference_buffer_object(ctx, &blit->buf_obj, NULL);
}
_mesa_meta_blit_shader_table_cleanup(&blit->shaders_with_depth);