aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_array.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_constbuf.c28
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_depth.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_framebuffer.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_msaa.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_rasterizer.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c33
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_scissor.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_blit.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_blit.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c19
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawtex.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawtex.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_eglimage.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_eglimage.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c39
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_feedback.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_feedback.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_msaa.c59
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_msaa.h39
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_queryobj.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_queryobj.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_rasterpos.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_rasterpos.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c51
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_xformfb.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_xformfb.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h3
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw_feedback.c15
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c148
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c36
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.h4
-rw-r--r--mesalib/src/mesa/state_tracker/st_gen_mipmap.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp48
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c34
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c22
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.h11
50 files changed, 441 insertions, 258 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom.c b/mesalib/src/mesa/state_tracker/st_atom.c
index 32bcc266a..1abaf8f3e 100644
--- a/mesalib/src/mesa/state_tracker/st_atom.c
+++ b/mesalib/src/mesa/state_tracker/st_atom.c
@@ -55,10 +55,10 @@ static const struct st_tracked_state *atoms[] =
&st_update_viewport,
&st_update_scissor,
&st_update_blend,
- &st_update_sampler,
&st_update_vertex_texture,
&st_update_fragment_texture,
&st_update_geometry_texture,
+ &st_update_sampler, /* depends on update_*_texture for swizzle */
&st_update_framebuffer,
&st_update_msaa,
&st_update_vs_constants,
@@ -160,11 +160,7 @@ void st_validate_state( struct st_context *st )
check_attrib_edgeflag(st);
- /* The bitmap cache is immune to pixel unpack changes.
- * Note that GLUT makes several calls to glPixelStore for each
- * bitmap char it draws so this is an important check.
- */
- if (state->mesa & ~_NEW_PACKUNPACK)
+ if (state->mesa)
st_flush_bitmap_cache(st);
check_program_state( st );
diff --git a/mesalib/src/mesa/state_tracker/st_atom_array.c b/mesalib/src/mesa/state_tracker/st_atom_array.c
index 2437245bd..87a0a17f1 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_array.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_array.c
@@ -589,7 +589,7 @@ static void update_array(struct st_context *st)
const struct st_tracked_state st_update_array = {
"st_update_array", /* name */
{ /* dirty */
- _NEW_BUFFER_OBJECT, /* mesa */
+ 0, /* mesa */
ST_NEW_VERTEX_ARRAYS | ST_NEW_VERTEX_PROGRAM, /* st */
},
update_array /* update */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
index 56ba96fe3..27a910b5f 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
@@ -194,12 +194,25 @@ static void st_bind_ubos(struct st_context *st,
binding = &st->ctx->UniformBufferBindings[shader->UniformBlocks[i].Binding];
st_obj = st_buffer_object(binding->BufferObject);
- pipe_resource_reference(&cb.buffer, st_obj->buffer);
- cb.buffer_size = st_obj->buffer->width0 - binding->Offset;
+ cb.buffer = st_obj->buffer;
+
+ if (cb.buffer) {
+ cb.buffer_offset = binding->Offset;
+ cb.buffer_size = cb.buffer->width0 - binding->Offset;
+
+ /* AutomaticSize is FALSE if the buffer was set with BindBufferRange.
+ * Take the minimum just to be sure.
+ */
+ if (!binding->AutomaticSize)
+ cb.buffer_size = MIN2(cb.buffer_size, binding->Size);
+ }
+ else {
+ cb.buffer_offset = 0;
+ cb.buffer_size = 0;
+ }
cso_set_constant_buffer(st->cso_context, shader_type, 1 + i, &cb);
- pipe_resource_reference(&cb.buffer, NULL);
}
}
@@ -216,8 +229,8 @@ static void bind_vs_ubos(struct st_context *st)
const struct st_tracked_state st_bind_vs_ubos = {
"st_bind_vs_ubos",
{
- (_NEW_PROGRAM | _NEW_BUFFER_OBJECT),
- ST_NEW_VERTEX_PROGRAM,
+ 0,
+ ST_NEW_VERTEX_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_vs_ubos
};
@@ -230,14 +243,13 @@ static void bind_fs_ubos(struct st_context *st)
return;
st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT], PIPE_SHADER_FRAGMENT);
-
}
const struct st_tracked_state st_bind_fs_ubos = {
"st_bind_fs_ubos",
{
- (_NEW_PROGRAM | _NEW_BUFFER_OBJECT),
- ST_NEW_FRAGMENT_PROGRAM,
+ 0,
+ ST_NEW_FRAGMENT_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_fs_ubos
};
diff --git a/mesalib/src/mesa/state_tracker/st_atom_depth.c b/mesalib/src/mesa/state_tracker/st_atom_depth.c
index c76a6d8c6..18a56a2e4 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_depth.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_depth.c
@@ -41,6 +41,9 @@
#include "pipe/p_defines.h"
#include "cso_cache/cso_context.h"
+#include "main/core.h"
+#include "main/stencil.h"
+
/**
* Convert an OpenGL compare mode to a pipe tokens.
@@ -116,7 +119,7 @@ update_depth_stencil_alpha(struct st_context *st)
dsa->stencil[0].zpass_op = gl_stencil_op_to_pipe(ctx->Stencil.ZPassFunc[0]);
dsa->stencil[0].valuemask = ctx->Stencil.ValueMask[0] & 0xff;
dsa->stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff;
- sr.ref_value[0] = ctx->Stencil.Ref[0] & 0xff;
+ sr.ref_value[0] = _mesa_get_stencil_ref(ctx, 0);
if (ctx->Stencil._TestTwoSide) {
const GLuint back = ctx->Stencil._BackFace;
@@ -127,7 +130,7 @@ update_depth_stencil_alpha(struct st_context *st)
dsa->stencil[1].zpass_op = gl_stencil_op_to_pipe(ctx->Stencil.ZPassFunc[back]);
dsa->stencil[1].valuemask = ctx->Stencil.ValueMask[back] & 0xff;
dsa->stencil[1].writemask = ctx->Stencil.WriteMask[back] & 0xff;
- sr.ref_value[1] = ctx->Stencil.Ref[back] & 0xff;
+ sr.ref_value[1] = _mesa_get_stencil_ref(ctx, back);
}
else {
/* This should be unnecessary. Drivers must not expect this to
@@ -153,7 +156,7 @@ update_depth_stencil_alpha(struct st_context *st)
const struct st_tracked_state st_update_depth_stencil_alpha = {
"st_update_depth_stencil", /* name */
{ /* dirty */
- (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR), /* mesa */
+ (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR|_NEW_BUFFERS),/* mesa */
0, /* st */
},
update_depth_stencil_alpha /* update */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
index 3df8691f4..c752640f4 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -59,6 +59,7 @@ update_renderbuffer_surface(struct st_context *st,
enum pipe_format format = st->ctx->Color.sRGBEnabled ? resource->format : util_format_linear(resource->format);
if (!strb->surface ||
+ strb->surface->texture->nr_samples != strb->Base.NumSamples ||
strb->surface->format != format ||
strb->surface->texture != resource ||
strb->surface->width != rtt_width ||
diff --git a/mesalib/src/mesa/state_tracker/st_atom_msaa.c b/mesalib/src/mesa/state_tracker/st_atom_msaa.c
index 9baa4fcf2..fb760460c 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_msaa.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_msaa.c
@@ -62,7 +62,8 @@ static void update_sample_mask( struct st_context *st )
if (st->ctx->Multisample.SampleCoverageInvert)
sample_mask = ~sample_mask;
}
- /* TODO merge with app-supplied sample mask */
+ if (st->ctx->Multisample.SampleMask)
+ sample_mask &= st->ctx->Multisample.SampleMaskValue;
}
/* mask off unused bits or don't care? */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
index 62464b475..f4d0cab42 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -228,9 +228,12 @@ static void update_raster_state( struct st_context *st )
/* _NEW_FRAG_CLAMP */
raster->clamp_fragment_color = !st->clamp_frag_color_in_shader &&
ctx->Color._ClampFragmentColor;
- raster->gl_rasterization_rules = 1;
- /* _NEW_RASTERIZER_DISCARD */
+ raster->half_pixel_center = 1;
+ if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
+ raster->bottom_edge_rule = 1;
+
+ /* ST_NEW_RASTERIZER */
raster->rasterizer_discard = ctx->RasterDiscard;
/* _NEW_TRANSFORM */
@@ -252,9 +255,9 @@ const struct st_tracked_state st_update_rasterizer = {
_NEW_PROGRAM |
_NEW_SCISSOR |
_NEW_FRAG_CLAMP |
- _NEW_RASTERIZER_DISCARD |
_NEW_TRANSFORM), /* mesa state dependencies*/
- ST_NEW_VERTEX_PROGRAM, /* state tracker dependencies */
+ (ST_NEW_VERTEX_PROGRAM |
+ ST_NEW_RASTERIZER), /* state tracker dependencies */
},
update_raster_state /* update function */
};
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index 3eba5b13c..302e12981 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -48,6 +48,8 @@
#include "cso_cache/cso_context.h"
+#include "util/u_format.h"
+
/**
* Convert GLenum texcoord wrap tokens to pipe tokens.
@@ -172,8 +174,10 @@ convert_sampler(struct st_context *st,
msamp->BorderColor.ui[1] ||
msamp->BorderColor.ui[2] ||
msamp->BorderColor.ui[3]) {
+ struct st_texture_object *stobj = st_texture_object(texobj);
struct gl_texture_image *teximg;
GLboolean is_integer = GL_FALSE;
+ union pipe_color_union border_color;
teximg = texobj->Image[0][texobj->BaseLevel];
@@ -181,9 +185,26 @@ convert_sampler(struct st_context *st,
is_integer = _mesa_is_enum_format_integer(teximg->InternalFormat);
}
- st_translate_color(&msamp->BorderColor,
- &sampler->border_color,
- teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+ if (st->apply_texture_swizzle_to_border_color && stobj->sampler_view) {
+ const unsigned char swz[4] =
+ {
+ stobj->sampler_view->swizzle_r,
+ stobj->sampler_view->swizzle_g,
+ stobj->sampler_view->swizzle_b,
+ stobj->sampler_view->swizzle_a,
+ };
+
+ st_translate_color(&msamp->BorderColor,
+ &border_color,
+ teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+
+ util_format_apply_color_swizzle(&sampler->border_color,
+ &border_color, swz, is_integer);
+ } else {
+ st_translate_color(&msamp->BorderColor,
+ &sampler->border_color,
+ teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+ }
}
sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?
@@ -258,14 +279,14 @@ update_samplers(struct st_context *st)
update_shader_samplers(st,
PIPE_SHADER_FRAGMENT,
&ctx->FragmentProgram._Current->Base,
- ctx->Const.MaxTextureImageUnits,
+ ctx->Const.FragmentProgram.MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_FRAGMENT],
&st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
update_shader_samplers(st,
PIPE_SHADER_VERTEX,
&ctx->VertexProgram._Current->Base,
- ctx->Const.MaxVertexTextureImageUnits,
+ ctx->Const.VertexProgram.MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_VERTEX],
&st->state.num_samplers[PIPE_SHADER_VERTEX]);
@@ -273,7 +294,7 @@ update_samplers(struct st_context *st)
update_shader_samplers(st,
PIPE_SHADER_GEOMETRY,
&ctx->GeometryProgram._Current->Base,
- ctx->Const.MaxGeometryTextureImageUnits,
+ ctx->Const.GeometryProgram.MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_GEOMETRY],
&st->state.num_samplers[PIPE_SHADER_GEOMETRY]);
}
diff --git a/mesalib/src/mesa/state_tracker/st_atom_scissor.c b/mesalib/src/mesa/state_tracker/st_atom_scissor.c
index eb1387778..19c2cd2fb 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_scissor.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_scissor.c
@@ -86,7 +86,7 @@ update_scissor( struct st_context *st )
if (memcmp(&scissor, &st->state.scissor, sizeof(scissor)) != 0) {
/* state has changed */
st->state.scissor = scissor; /* struct copy */
- st->pipe->set_scissor_state(st->pipe, &scissor); /* activate */
+ st->pipe->set_scissor_states(st->pipe, 0, 1, &scissor); /* activate */
}
}
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index fc2d69013..d79e04cf4 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -239,7 +239,8 @@ update_single_texture(struct st_context *st,
st_mesa_format_to_pipe_format(stObj->base._BufferObjectFormat);
}
else {
- view_format = stObj->pt->format;
+ view_format =
+ stObj->surface_based ? stObj->surface_format : stObj->pt->format;
/* If sRGB decoding is off, use the linear format */
if (samp->sRGBDecode == GL_SKIP_DECODE_EXT) {
@@ -325,11 +326,11 @@ update_vertex_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
- if (ctx->Const.MaxVertexTextureImageUnits > 0) {
+ if (ctx->Const.VertexProgram.MaxTextureImageUnits > 0) {
update_textures(st,
PIPE_SHADER_VERTEX,
&ctx->VertexProgram._Current->Base,
- ctx->Const.MaxVertexTextureImageUnits,
+ ctx->Const.VertexProgram.MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_VERTEX],
&st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
}
@@ -344,7 +345,7 @@ update_fragment_textures(struct st_context *st)
update_textures(st,
PIPE_SHADER_FRAGMENT,
&ctx->FragmentProgram._Current->Base,
- ctx->Const.MaxTextureImageUnits,
+ ctx->Const.FragmentProgram.MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_FRAGMENT],
&st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
}
@@ -359,7 +360,7 @@ update_geometry_textures(struct st_context *st)
update_textures(st,
PIPE_SHADER_GEOMETRY,
&ctx->GeometryProgram._Current->Base,
- ctx->Const.MaxTextureImageUnits,
+ ctx->Const.FragmentProgram.MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_GEOMETRY],
&st->state.num_sampler_views[PIPE_SHADER_GEOMETRY]);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index b3ca40501..e96f4b36e 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -34,7 +34,6 @@
#include "main/image.h"
#include "main/bufferobj.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "main/pbo.h"
#include "program/program.h"
#include "program/prog_print.h"
@@ -299,7 +298,7 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
* Create texture to hold bitmap pattern.
*/
pt = st_texture_create(st, st->internal_target, st->bitmap.tex_format,
- 0, width, height, 1, 1,
+ 0, width, height, 1, 1, 0,
PIPE_BIND_SAMPLER_VIEW);
if (!pt) {
_mesa_unmap_pbo_source(ctx, unpack);
@@ -567,7 +566,7 @@ reset_cache(struct st_context *st)
cache->texture = st_texture_create(st, PIPE_TEXTURE_2D,
st->bitmap.tex_format, 0,
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
- 1, 1,
+ 1, 1, 0,
PIPE_BIND_SAMPLER_VIEW);
}
@@ -826,7 +825,8 @@ st_init_bitmap(struct st_context *st)
/* init baseline rasterizer state once */
memset(&st->bitmap.rasterizer, 0, sizeof(st->bitmap.rasterizer));
- st->bitmap.rasterizer.gl_rasterization_rules = 1;
+ st->bitmap.rasterizer.half_pixel_center = 1;
+ st->bitmap.rasterizer.bottom_edge_rule = 1;
st->bitmap.rasterizer.depth_clip = 1;
/* find a usable texture format */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.h b/mesalib/src/mesa/state_tracker/st_cb_bitmap.h
index d1c18058b..cc9f5f574 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.h
@@ -31,7 +31,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
struct st_context;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_blit.c b/mesalib/src/mesa/state_tracker/st_cb_blit.c
index 50cab4294..a236a08e9 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_blit.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_blit.c
@@ -33,7 +33,6 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "st_context.h"
#include "st_texture.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_blit.h b/mesalib/src/mesa/state_tracker/st_cb_blit.h
index 159c6ca8d..9e94e4439 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_blit.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_blit.h
@@ -30,7 +30,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
struct st_context;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 8ff32c842..2e5e253a4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -182,6 +182,21 @@ st_bufferobj_data(struct gl_context *ctx,
struct st_buffer_object *st_obj = st_buffer_object(obj);
unsigned bind, pipe_usage;
+ if (size && data && st_obj->buffer &&
+ st_obj->Base.Size == size && st_obj->Base.Usage == usage) {
+ /* Just discard the old contents and write new data.
+ * This should be the same as creating a new buffer, but we avoid
+ * a lot of validation in Mesa.
+ */
+ struct pipe_box box;
+
+ u_box_1d(0, size, &box);
+ pipe->transfer_inline_write(pipe, st_obj->buffer, 0,
+ PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
+ &box, data, 0, 0);
+ return GL_TRUE;
+ }
+
st_obj->Base.Size = size;
st_obj->Base.Usage = usage;
@@ -247,9 +262,11 @@ st_bufferobj_data(struct gl_context *ctx,
if (data)
pipe_buffer_write(pipe, st_obj->buffer, 0, size, data);
- return GL_TRUE;
}
+ /* BufferData may change an array or uniform buffer, need to update it */
+ st->dirty.st |= ST_NEW_VERTEX_ARRAYS | ST_NEW_UNIFORM_BUFFER;
+
return GL_TRUE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index a5aa8f496..566f4a76e 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -67,7 +67,8 @@ st_init_clear(struct st_context *st)
{
memset(&st->clear, 0, sizeof(st->clear));
- st->clear.raster.gl_rasterization_rules = 1;
+ st->clear.raster.half_pixel_center = 1;
+ st->clear.raster.bottom_edge_rule = 1;
st->clear.raster.depth_clip = 1;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index f5a1e27f7..68359e803 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -35,7 +35,6 @@
#include "main/bufferobj.h"
#include "main/format_pack.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "main/pack.h"
#include "main/pbo.h"
@@ -466,7 +465,7 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height,
struct pipe_resource *pt;
pt = st_texture_create(st, st->internal_target, texFormat, 0,
- width, height, 1, 1, PIPE_BIND_SAMPLER_VIEW);
+ width, height, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW);
return pt;
}
@@ -711,7 +710,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
memset(&rasterizer, 0, sizeof(rasterizer));
rasterizer.clamp_fragment_color = !st->clamp_frag_color_in_shader &&
ctx->Color._ClampFragmentColor;
- rasterizer.gl_rasterization_rules = 1;
+ rasterizer.half_pixel_center = 1;
+ rasterizer.bottom_edge_rule = 1;
rasterizer.depth_clip = !ctx->Transform.DepthClamp;
rasterizer.scissor = ctx->Scissor.Enabled;
cso_set_rasterizer(cso, &rasterizer);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.h b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.h
index 6209dcade..6cd6a4ed6 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.h
@@ -31,7 +31,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
struct st_context;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
index c4efce02f..2cc200e0c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
@@ -15,7 +15,6 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "program/program.h"
#include "program/prog_print.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.h b/mesalib/src/mesa/state_tracker/st_cb_drawtex.h
index ccb615e98..9794ccc15 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.h
@@ -11,7 +11,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
struct st_context;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
index 8c78e5ef4..a396b9e97 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
@@ -26,7 +26,6 @@
* Chia-I Wu <olv@lunarg.com>
*/
-#include "main/mfeatures.h"
#include "main/texobj.h"
#include "main/teximage.h"
#include "util/u_inlines.h"
@@ -132,6 +131,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target,
stObj->width0 = ps->width;
stObj->height0 = ps->height;
stObj->depth0 = 1;
+ stObj->surface_format = ps->format;
_mesa_dirty_texobj(ctx, texObj, GL_TRUE);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.h b/mesalib/src/mesa/state_tracker/st_cb_eglimage.h
index 1750b9147..c6ddec6ae 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.h
@@ -30,7 +30,6 @@
#define ST_CB_EGLIMAGE_H
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 4452e523b..826722be8 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -38,7 +38,6 @@
#include "main/fbobject.h"
#include "main/framebuffer.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "main/renderbuffer.h"
#include "pipe/p_context.h"
@@ -391,11 +390,10 @@ st_render_texture(struct gl_context *ctx,
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
- struct st_renderbuffer *strb;
- struct gl_renderbuffer *rb;
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_resource *pt;
struct st_texture_object *stObj;
- const struct gl_texture_image *texImage;
struct pipe_surface surf_tmpl;
if (!st_finalize_texture(ctx, pipe, att->Texture))
@@ -404,27 +402,6 @@ st_render_texture(struct gl_context *ctx,
pt = st_get_texobj_resource(att->Texture);
assert(pt);
- /* get pointer to texture image we're rendeing to */
- texImage = _mesa_get_attachment_teximage(att);
-
- /* create new renderbuffer which wraps the texture image.
- * Use the texture's name as the renderbuffer's name so that we have
- * something that's non-zero (to determine vertical orientation) and
- * possibly helpful for debugging.
- */
- rb = st_new_renderbuffer(ctx, att->Texture->Name);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture()");
- return;
- }
-
- _mesa_reference_renderbuffer(&att->Renderbuffer, rb);
- assert(rb->RefCount == 1);
- rb->AllocStorage = NULL; /* should not get called */
- strb = st_renderbuffer(rb);
-
- assert(strb->Base.RefCount > 0);
-
/* get the texture for the texture object */
stObj = st_texture_object(att->Texture);
@@ -434,11 +411,6 @@ st_render_texture(struct gl_context *ctx,
strb->rtt_face = att->CubeMapFace;
strb->rtt_slice = att->Zoffset;
- rb->Width = texImage->Width2;
- rb->Height = texImage->Height2;
- rb->_BaseFormat = texImage->_BaseFormat;
- rb->InternalFormat = texImage->InternalFormat;
-
pipe_resource_reference( &strb->texture, pt );
pipe_surface_release(pipe, &strb->surface);
@@ -477,10 +449,9 @@ st_render_texture(struct gl_context *ctx,
* Called via ctx->Driver.FinishRenderTexture.
*/
static void
-st_finish_render_texture(struct gl_context *ctx,
- struct gl_renderbuffer_attachment *att)
+st_finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
- struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer);
+ struct st_renderbuffer *strb = st_renderbuffer(rb);
if (!strb)
return;
@@ -527,7 +498,7 @@ st_validate_attachment(struct gl_context *ctx,
return GL_FALSE;
format = stObj->pt->format;
- texFormat = _mesa_get_attachment_teximage_const(att)->TexFormat;
+ texFormat = att->Renderbuffer->TexImage->TexFormat;
/* If the encoding is sRGB and sRGB rendering cannot be enabled,
* check for linear format support instead.
diff --git a/mesalib/src/mesa/state_tracker/st_cb_feedback.c b/mesalib/src/mesa/state_tracker/st_cb_feedback.c
index 7a8fde465..d2e4346b7 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_feedback.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_feedback.c
@@ -40,7 +40,6 @@
#include "main/imports.h"
#include "main/context.h"
#include "main/feedback.h"
-#include "main/mfeatures.h"
#include "vbo/vbo.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_feedback.h b/mesalib/src/mesa/state_tracker/st_cb_feedback.h
index 0163631e3..6350da4e4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_feedback.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_feedback.h
@@ -31,7 +31,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c
index b11004718..f428e0af9 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c
@@ -77,7 +77,7 @@ display_front_buffer(struct st_context *st)
void st_flush(struct st_context *st,
struct pipe_fence_handle **fence,
- enum pipe_flush_flags flags)
+ unsigned flags)
{
FLUSH_VERTICES(st->ctx, 0);
FLUSH_CURRENT(st->ctx, 0);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.h b/mesalib/src/mesa/state_tracker/st_cb_flush.h
index 003e2a2a9..cb5c62e87 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.h
@@ -42,7 +42,7 @@ st_init_flush_functions(struct dd_function_table *functions);
extern void
st_flush(struct st_context *st,
struct pipe_fence_handle **fence,
- enum pipe_flush_flags flags);
+ unsigned flags);
extern void
st_finish(struct st_context *st);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_msaa.c b/mesalib/src/mesa/state_tracker/st_cb_msaa.c
new file mode 100644
index 000000000..bbf2b2c5c
--- /dev/null
+++ b/mesalib/src/mesa/state_tracker/st_cb_msaa.c
@@ -0,0 +1,59 @@
+/**************************************************************************
+ *
+ * Copyright 2013 Red Hat
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/bufferobj.h"
+#include "main/imports.h"
+
+#include "state_tracker/st_cb_msaa.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_atom.h"
+#include "state_tracker/st_cb_fbo.h"
+
+#include "pipe/p_context.h"
+
+
+static void
+st_GetSamplePosition(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLuint index,
+ GLfloat *outValue)
+{
+ struct st_context *st = st_context(ctx);
+
+ st_validate_state(st);
+
+ if (st->pipe->get_sample_position)
+ st->pipe->get_sample_position(st->pipe, (unsigned) fb->Visual.samples,
+ index, outValue);
+}
+
+
+void
+st_init_msaa_functions(struct dd_function_table *functions)
+{
+ functions->GetSamplePosition = st_GetSamplePosition;
+}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_msaa.h b/mesalib/src/mesa/state_tracker/st_cb_msaa.h
new file mode 100644
index 000000000..ba4c06f6b
--- /dev/null
+++ b/mesalib/src/mesa/state_tracker/st_cb_msaa.h
@@ -0,0 +1,39 @@
+/**************************************************************************
+ *
+ * Copyright 2013 Red Hat
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef ST_CB_MSAA_H
+#define ST_CB_MSAA_H
+
+#include "main/glheader.h"
+
+struct dd_function_table;
+
+extern void
+st_init_msaa_functions(struct dd_function_table *functions);
+
+#endif
diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
index 6a35c1b69..24ce6351d 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
@@ -35,7 +35,6 @@
#include "main/imports.h"
#include "main/context.h"
-#include "main/mfeatures.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h
index d5b107532..e069b095c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h
@@ -29,7 +29,6 @@
#define ST_CB_QUERYOBJ_H
-#include "main/mfeatures.h"
#include "main/mtypes.h"
/**
diff --git a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c
index 4731f2648..26a55909d 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -38,7 +38,6 @@
#include "main/imports.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "main/feedback.h"
#include "st_context.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.h b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.h
index bfd3e4138..99796f610 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.h
@@ -30,7 +30,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 0cd0d77af..56dbe85c0 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -25,7 +25,6 @@
*
**************************************************************************/
-#include "main/mfeatures.h"
#include "main/bufferobj.h"
#include "main/enums.h"
#include "main/fbobject.h"
@@ -78,6 +77,8 @@ gl_target_to_pipe(GLenum target)
case GL_TEXTURE_2D:
case GL_PROXY_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
return PIPE_TEXTURE_2D;
case GL_TEXTURE_RECTANGLE_NV:
case GL_PROXY_TEXTURE_RECTANGLE_NV:
@@ -99,6 +100,8 @@ gl_target_to_pipe(GLenum target)
return PIPE_TEXTURE_1D_ARRAY;
case GL_TEXTURE_2D_ARRAY_EXT:
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
return PIPE_TEXTURE_2D_ARRAY;
case GL_TEXTURE_BUFFER:
return PIPE_BUFFER;
@@ -408,7 +411,7 @@ guess_and_alloc_texture(struct st_context *st,
ptWidth,
ptHeight,
ptDepth,
- ptLayers,
+ ptLayers, 0,
bindings);
stObj->lastLevel = lastLevel;
@@ -496,7 +499,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
ptWidth,
ptHeight,
ptDepth,
- ptLayers,
+ ptLayers, 0,
bindings);
return stImage->pt != NULL;
}
@@ -1492,7 +1495,7 @@ st_finalize_texture(struct gl_context *ctx,
GLuint face;
struct st_texture_image *firstImage;
enum pipe_format firstImageFormat;
- GLuint ptWidth, ptHeight, ptDepth, ptLayers;
+ GLuint ptWidth, ptHeight, ptDepth, ptLayers, ptNumSamples;
if (_mesa_is_texture_complete(tObj, &tObj->Sampler)) {
/* The texture is complete and we know exactly how many mipmap levels
@@ -1537,6 +1540,11 @@ st_finalize_texture(struct gl_context *ctx,
pipe_sampler_view_release(st->pipe, &stObj->sampler_view);
}
+ /* If this texture comes from a window system, there is nothing else to do. */
+ if (stObj->surface_based) {
+ return GL_TRUE;
+ }
+
/* Find gallium format for the Mesa texture */
firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
@@ -1556,6 +1564,7 @@ st_finalize_texture(struct gl_context *ctx,
/* convert GL dims to Gallium dims */
st_gl_texture_dims_to_pipe_dims(stObj->base.Target, width, height, depth,
&ptWidth, &ptHeight, &ptDepth, &ptLayers);
+ ptNumSamples = firstImage->base.NumSamples;
}
/* If we already have a gallium texture, check that it matches the texture
@@ -1563,11 +1572,12 @@ st_finalize_texture(struct gl_context *ctx,
*/
if (stObj->pt) {
if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
- !st_sampler_compat_formats(stObj->pt->format, firstImageFormat) ||
+ stObj->pt->format != firstImageFormat ||
stObj->pt->last_level < stObj->lastLevel ||
stObj->pt->width0 != ptWidth ||
stObj->pt->height0 != ptHeight ||
stObj->pt->depth0 != ptDepth ||
+ stObj->pt->nr_samples != ptNumSamples ||
stObj->pt->array_size != ptLayers)
{
/* The gallium texture does not match the Mesa texture so delete the
@@ -1591,7 +1601,7 @@ st_finalize_texture(struct gl_context *ctx,
ptWidth,
ptHeight,
ptDepth,
- ptLayers,
+ ptLayers, ptNumSamples,
bindings);
if (!stObj->pt) {
@@ -1637,11 +1647,14 @@ st_AllocTextureStorage(struct gl_context *ctx,
GLsizei height, GLsizei depth)
{
const GLuint numFaces = _mesa_num_tex_faces(texObj->Target);
+ struct gl_texture_image *texImage = texObj->Image[0][0];
struct st_context *st = st_context(ctx);
struct st_texture_object *stObj = st_texture_object(texObj);
+ struct pipe_screen *screen = st->pipe->screen;
GLuint ptWidth, ptHeight, ptDepth, ptLayers, bindings;
enum pipe_format fmt;
GLint level;
+ int num_samples = texImage->NumSamples;
assert(levels > 0);
@@ -1651,10 +1664,30 @@ st_AllocTextureStorage(struct gl_context *ctx,
stObj->depth0 = depth;
stObj->lastLevel = levels - 1;
- fmt = st_mesa_format_to_pipe_format(texObj->Image[0][0]->TexFormat);
+ fmt = st_mesa_format_to_pipe_format(texImage->TexFormat);
bindings = default_bindings(st, fmt);
+ /* Raise the sample count if the requested one is unsupported. */
+ if (num_samples > 1) {
+ boolean found = FALSE;
+
+ for (; num_samples <= ctx->Const.MaxSamples; num_samples++) {
+ if (screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D,
+ num_samples,
+ PIPE_BIND_SAMPLER_VIEW)) {
+ /* Update the sample count in gl_texture_image as well. */
+ texImage->NumSamples = num_samples;
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ return GL_FALSE;
+ }
+ }
+
st_gl_texture_dims_to_pipe_dims(texObj->Target,
width, height, depth,
&ptWidth, &ptHeight, &ptDepth, &ptLayers);
@@ -1662,11 +1695,11 @@ st_AllocTextureStorage(struct gl_context *ctx,
stObj->pt = st_texture_create(st,
gl_target_to_pipe(texObj->Target),
fmt,
- levels,
+ levels - 1,
ptWidth,
ptHeight,
ptDepth,
- ptLayers,
+ ptLayers, num_samples,
bindings);
if (!stObj->pt)
return GL_FALSE;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_xformfb.c b/mesalib/src/mesa/state_tracker/st_cb_xformfb.c
index 3e52c9988..e1a7a88a1 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_xformfb.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_xformfb.c
@@ -36,7 +36,6 @@
#include "main/bufferobj.h"
#include "main/context.h"
-#include "main/mfeatures.h"
#include "main/transformfeedback.h"
#include "st_cb_bufferobjects.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_xformfb.h b/mesalib/src/mesa/state_tracker/st_cb_xformfb.h
index 5c82fed18..998c41825 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_xformfb.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_xformfb.h
@@ -30,7 +30,6 @@
#include "main/compiler.h"
-#include "main/mfeatures.h"
struct dd_function_table;
struct gl_transform_feedback_object;
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index cc87f2bb3..7d18c2521 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -49,6 +49,7 @@
#include "st_cb_eglimage.h"
#include "st_cb_fbo.h"
#include "st_cb_feedback.h"
+#include "st_cb_msaa.h"
#include "st_cb_program.h"
#include "st_cb_queryobj.h"
#include "st_cb_readpixels.h"
@@ -187,6 +188,10 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st->needs_texcoord_semantic =
screen->get_param(screen, PIPE_CAP_TGSI_TEXCOORD);
+ st->apply_texture_swizzle_to_border_color =
+ !!(screen->get_param(screen, PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK) &
+ (PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 |
+ PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600));
/* GL limits and extensions */
st_init_limits(st);
@@ -203,6 +208,8 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
static void st_init_driver_flags(struct gl_driver_flags *f)
{
f->NewArray = ST_NEW_VERTEX_ARRAYS;
+ f->NewRasterizerDiscard = ST_NEW_RASTERIZER;
+ f->NewUniformBuffer = ST_NEW_UNIFORM_BUFFER;
}
struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
@@ -233,7 +240,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
* driver prefers DP4 or MUL/MAD for vertex transformation.
*/
if (debug_get_option_mesa_mvp_dp4())
- _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+ ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = GL_TRUE;
return st_create_context_priv(ctx, pipe, options);
}
@@ -340,6 +347,7 @@ void st_init_driver_functions(struct dd_function_table *functions)
st_init_fbo_functions(functions);
st_init_feedback_functions(functions);
+ st_init_msaa_functions(functions);
st_init_program_functions(functions);
st_init_query_functions(functions);
st_init_cond_render_functions(functions);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 8786a036f..ab89b4947 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -50,6 +50,8 @@ struct u_upload_mgr;
#define ST_NEW_EDGEFLAGS_DATA (1 << 4)
#define ST_NEW_GEOMETRY_PROGRAM (1 << 5)
#define ST_NEW_VERTEX_ARRAYS (1 << 6)
+#define ST_NEW_RASTERIZER (1 << 7)
+#define ST_NEW_UNIFORM_BUFFER (1 << 8)
struct st_state_flags {
@@ -87,6 +89,7 @@ struct st_context
boolean prefer_blit_based_texture_transfer;
boolean needs_texcoord_semantic;
+ boolean apply_texture_swizzle_to_border_color;
/* On old libGL's for linux we need to invalidate the drawables
* on glViewpport calls, this is set via a option.
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index bff8d9b31..a440ae2a8 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -40,7 +40,6 @@
#include "main/image.h"
#include "main/bufferobj.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "vbo/vbo.h"
@@ -231,7 +230,7 @@ st_draw_vbo(struct gl_context *ctx,
nr_prims);
if (!setup_index_buffer(st, ib, &ibuffer)) {
- /* out of memory */
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBegin/DrawElements/DrawArray");
return;
}
@@ -245,7 +244,7 @@ st_draw_vbo(struct gl_context *ctx,
* so we only set these fields for indexed drawing:
*/
info.primitive_restart = ctx->Array._PrimitiveRestart;
- info.restart_index = ctx->Array._RestartIndex;
+ info.restart_index = ctx->Array.RestartIndex;
}
else {
/* Transform feedback drawing is always non-indexed. */
diff --git a/mesalib/src/mesa/state_tracker/st_draw_feedback.c b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
index ae87fb28d..b19d913e5 100644
--- a/mesalib/src/mesa/state_tracker/st_draw_feedback.c
+++ b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
@@ -28,7 +28,6 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "vbo/vbo.h"
@@ -134,7 +133,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
* code sends state updates to the pipe, not to our private draw module.
*/
assert(draw);
- draw_set_viewport_state(draw, &st->state.viewport);
+ draw_set_viewport_states(draw, 0, 1, &st->state.viewport);
draw_set_clip_state(draw, &st->state.clip);
draw_set_rasterizer_state(draw, &st->state.rasterizer, NULL);
draw_bind_vertex_shader(draw, st->vp_variant->draw_shader);
@@ -176,7 +175,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
map = pipe_buffer_map(pipe, vbuffers[attr].buffer,
PIPE_TRANSFER_READ,
&vb_transfer[attr]);
- draw_set_mapped_vertex_buffer(draw, attr, map);
+ draw_set_mapped_vertex_buffer(draw, attr, map,
+ vbuffers[attr].buffer->width0);
}
else {
vbuffers[attr].buffer = NULL;
@@ -184,7 +184,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
vbuffers[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
- draw_set_mapped_vertex_buffer(draw, attr, vbuffers[attr].user_buffer);
+ draw_set_mapped_vertex_buffer(draw, attr, vbuffers[attr].user_buffer,
+ ~0);
}
/* common-case setup */
@@ -232,7 +233,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
draw_set_indexes(draw,
(ubyte *) mapped_indices + ibuffer.offset,
- ibuffer.index_size);
+ ibuffer.index_size, ~0);
}
/* set the constant buffer */
@@ -251,7 +252,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
* unmap vertex/index buffers
*/
if (ib) {
- draw_set_indexes(draw, NULL, 0);
+ draw_set_indexes(draw, NULL, 0, 0);
if (ib_transfer)
pipe_buffer_unmap(pipe, ib_transfer);
pipe_resource_reference(&ibuffer.buffer, NULL);
@@ -261,7 +262,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
for (attr = 0; attr < vp->num_inputs; attr++) {
if (vb_transfer[attr])
pipe_buffer_unmap(pipe, vb_transfer[attr]);
- draw_set_mapped_vertex_buffer(draw, attr, NULL);
+ draw_set_mapped_vertex_buffer(draw, attr, NULL, 0);
pipe_resource_reference(&vbuffers[attr].buffer, NULL);
}
draw_set_vertex_buffers(draw, 0, vp->num_inputs, NULL);
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 2d8b9efec..46acc8763 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -29,7 +29,6 @@
#include "main/imports.h"
#include "main/context.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "main/version.h"
#include "pipe/p_context.h"
@@ -38,9 +37,9 @@
#include "st_context.h"
#include "st_extensions.h"
+#include "st_format.h"
-
-static int _min(int a, int b)
+static unsigned _min(unsigned a, unsigned b)
{
return (a < b) ? a : b;
}
@@ -71,7 +70,6 @@ void st_init_limits(struct st_context *st)
struct gl_constants *c = &st->ctx->Const;
gl_shader_type sh;
boolean can_ubo = TRUE;
- int max_const_buffers;
c->MaxTextureLevels
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
@@ -91,25 +89,10 @@ void st_init_limits(struct st_context *st)
c->MaxArrayTextureLayers
= screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS);
- c->MaxTextureImageUnits
- = _min(screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
- PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS),
- MAX_TEXTURE_IMAGE_UNITS);
-
- c->MaxVertexTextureImageUnits
- = _min(screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
- PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS),
- MAX_VERTEX_TEXTURE_IMAGE_UNITS);
-
c->MaxCombinedTextureImageUnits
= _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS),
MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- c->MaxTextureCoordUnits
- = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);
-
- c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits);
-
/* Define max viewport size and max renderbuffer size in terms of
* max texture size (note: max tex RECT size = max tex 2D size).
* If this isn't true for some hardware we'll need new PIPE_CAP_ queries.
@@ -118,9 +101,9 @@ void st_init_limits(struct st_context *st)
c->MaxViewportHeight =
c->MaxRenderbufferSize = c->MaxTextureRectSize;
- c->MaxDrawBuffers
- = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
- 1, MAX_DRAW_BUFFERS);
+ c->MaxDrawBuffers = c->MaxColorAttachments =
+ _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
+ 1, MAX_DRAW_BUFFERS);
c->MaxDualSourceDrawBuffers
= _clamp(screen->get_param(screen, PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS),
@@ -156,13 +139,16 @@ void st_init_limits(struct st_context *st)
c->MaxTextureLodBias
= screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_LOD_BIAS);
- c->MaxDrawBuffers
- = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
- 1, MAX_DRAW_BUFFERS);
-
c->QuadsFollowProvokingVertexConvention = screen->get_param(
screen, PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
+ c->MaxUniformBlockSize =
+ screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_MAX_CONSTS) * 16;
+ if (c->MaxUniformBlockSize < 16384) {
+ can_ubo = FALSE;
+ }
+
for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) {
struct gl_shader_compiler_options *options =
&st->ctx->ShaderCompilerOptions[sh];
@@ -183,17 +169,39 @@ void st_init_limits(struct st_context *st)
continue;
}
- pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS);
- pc->MaxNativeAluInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS);
- pc->MaxNativeTexInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS);
- pc->MaxNativeTexIndirections = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS);
- pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS);
- pc->MaxNativeTemps = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS);
- pc->MaxNativeAddressRegs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS);
- pc->MaxNativeParameters = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS);
- pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
- /* raise MaxParameters if native support is higher */
- pc->MaxParameters = MAX2(pc->MaxParameters, pc->MaxNativeParameters);
+ pc->MaxTextureImageUnits =
+ _min(screen->get_shader_param(screen, sh,
+ PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS),
+ MAX_TEXTURE_IMAGE_UNITS);
+
+ pc->MaxInstructions = pc->MaxNativeInstructions =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS);
+ pc->MaxAluInstructions = pc->MaxNativeAluInstructions =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS);
+ pc->MaxTexInstructions = pc->MaxNativeTexInstructions =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS);
+ pc->MaxTexIndirections = pc->MaxNativeTexIndirections =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS);
+ pc->MaxAttribs = pc->MaxNativeAttribs =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS);
+ pc->MaxTemps = pc->MaxNativeTemps =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS);
+ pc->MaxAddressRegs = pc->MaxNativeAddressRegs =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS);
+ pc->MaxParameters = pc->MaxNativeParameters =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS);
+
+ pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
+
+ pc->MaxUniformBlocks =
+ screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
+ if (pc->MaxUniformBlocks)
+ pc->MaxUniformBlocks -= 1; /* The first one is for ordinary uniforms. */
+ pc->MaxUniformBlocks = _min(pc->MaxUniformBlocks, MAX_UNIFORM_BUFFERS);
+
+ pc->MaxCombinedUniformComponents = (pc->MaxUniformComponents +
+ c->MaxUniformBlockSize / 4 *
+ pc->MaxUniformBlocks);
/* Gallium doesn't really care about local vs. env parameters so use the
* same limits.
@@ -220,15 +228,9 @@ void st_init_limits(struct st_context *st)
options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh,
PIPE_SHADER_CAP_INDIRECT_CONST_ADDR);
- if (pc->MaxNativeInstructions) {
- if (options->EmitNoIndirectUniform)
+ if (pc->MaxNativeInstructions &&
+ (options->EmitNoIndirectUniform || pc->MaxUniformBlocks < 12)) {
can_ubo = FALSE;
-
- max_const_buffers = screen->get_shader_param(screen, sh,
- PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
- /* we need 13 buffers - 1 constant, 12 UBO */
- if (max_const_buffers < 13)
- can_ubo = FALSE;
}
if (options->EmitNoLoops)
@@ -238,11 +240,20 @@ void st_init_limits(struct st_context *st)
options->LowerClipDistance = true;
}
+ /* This depends on program constants. */
+ c->MaxTextureCoordUnits
+ = _min(c->FragmentProgram.MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);
+
+ c->MaxTextureUnits = _min(c->FragmentProgram.MaxTextureImageUnits, c->MaxTextureCoordUnits);
+
+ c->VertexProgram.MaxAttribs = MIN2(c->VertexProgram.MaxAttribs, 16);
+
/* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
* of inputs. It's always 2 colors + N generic inputs. */
c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
PIPE_SHADER_CAP_MAX_INPUTS);
c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
+ c->MaxVaryingComponents = c->MaxVarying * 4;
c->MinProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET);
c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET);
@@ -267,8 +278,13 @@ void st_init_limits(struct st_context *st)
if (can_ubo) {
st->ctx->Extensions.ARB_uniform_buffer_object = GL_TRUE;
- st->ctx->Const.UniformBufferOffsetAlignment =
+ c->UniformBufferOffsetAlignment =
screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT);
+ c->MaxCombinedUniformBlocks = c->MaxUniformBufferBindings =
+ c->VertexProgram.MaxUniformBlocks +
+ c->GeometryProgram.MaxUniformBlocks +
+ c->FragmentProgram.MaxUniformBlocks;
+ assert(c->MaxCombinedUniformBlocks <= MAX_COMBINED_UNIFORM_BUFFERS);
}
}
@@ -398,7 +414,8 @@ void st_init_extensions(struct st_context *st)
{ o(MESA_texture_array), PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS },
{ o(OES_standard_derivatives), PIPE_CAP_SM3 },
- { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY }
+ { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY },
+ { o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE }
};
/* Required: render target and sampler support */
@@ -658,10 +675,33 @@ void st_init_extensions(struct st_context *st)
/* Maximum sample count. */
for (i = 16; i > 0; --i) {
- if (screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_UNORM,
- PIPE_TEXTURE_2D, i,
- PIPE_BIND_RENDER_TARGET)) {
+ enum pipe_format pformat = st_choose_format(st, GL_RGBA,
+ GL_NONE, GL_NONE,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET, FALSE);
+ if (pformat != PIPE_FORMAT_NONE) {
ctx->Const.MaxSamples = i;
+ ctx->Const.MaxColorTextureSamples = i;
+ break;
+ }
+ }
+ for (i = ctx->Const.MaxSamples; i > 0; --i) {
+ enum pipe_format pformat = st_choose_format(st, GL_DEPTH_STENCIL,
+ GL_NONE, GL_NONE,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_DEPTH_STENCIL, FALSE);
+ if (pformat != PIPE_FORMAT_NONE) {
+ ctx->Const.MaxDepthTextureSamples = i;
+ break;
+ }
+ }
+ for (i = ctx->Const.MaxSamples; i > 0; --i) {
+ enum pipe_format pformat = st_choose_format(st, GL_RGBA_INTEGER,
+ GL_NONE, GL_NONE,
+ PIPE_TEXTURE_2D, i,
+ PIPE_BIND_RENDER_TARGET, FALSE);
+ if (pformat != PIPE_FORMAT_NONE) {
+ ctx->Const.MaxIntegerSamples = i;
break;
}
}
@@ -689,7 +729,10 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_transform_feedback_instanced = GL_TRUE;
}
if (st->options.force_glsl_extensions_warn)
- ctx->Const.ForceGLSLExtensionsWarn = 1;
+ ctx->Const.ForceGLSLExtensionsWarn = 1;
+
+ if (st->options.disable_glsl_line_continuations)
+ ctx->Const.DisableGLSLLineContinuations = 1;
ctx->Const.MinMapBufferAlignment =
screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
@@ -699,6 +742,9 @@ void st_init_extensions(struct st_context *st)
if (screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) {
ctx->Extensions.ARB_texture_buffer_object = GL_TRUE;
+ ctx->Const.MaxTextureBufferSize =
+ _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE),
+ (1u << 31) - 1);
ctx->Const.TextureBufferOffsetAlignment =
screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT);
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index a15706a03..56f3a4a48 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -38,7 +38,6 @@
#include "main/texstore.h"
#include "main/image.h"
#include "main/macros.h"
-#include "main/mfeatures.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -1801,41 +1800,6 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
}
-GLboolean
-st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2)
-{
- if (format1 == format2)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_B8G8R8A8_UNORM &&
- format2 == PIPE_FORMAT_B8G8R8X8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_B8G8R8X8_UNORM &&
- format2 == PIPE_FORMAT_B8G8R8A8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_A8B8G8R8_UNORM &&
- format2 == PIPE_FORMAT_X8B8G8R8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_X8B8G8R8_UNORM &&
- format2 == PIPE_FORMAT_A8B8G8R8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_A8R8G8B8_UNORM &&
- format2 == PIPE_FORMAT_X8R8G8B8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_X8R8G8B8_UNORM &&
- format2 == PIPE_FORMAT_A8R8G8B8_UNORM)
- return GL_TRUE;
-
- return GL_FALSE;
-}
-
-
-
/**
* This is used for translating texture border color and the clear
* color. For example, the clear color is interpreted according to
diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h
index 0a1c18d92..6e97dcb96 100644
--- a/mesalib/src/mesa/state_tracker/st_format.h
+++ b/mesalib/src/mesa/state_tracker/st_format.h
@@ -70,10 +70,6 @@ size_t
st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
GLenum internalFormat, int samples[16]);
-/* can we use a sampler view to translate these formats
- only used to make TFP so far */
-extern GLboolean
-st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2);
extern void
diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
index 8ce2e06a2..e5512af2a 100644
--- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
@@ -172,6 +172,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
oldTex->height0,
oldTex->depth0,
oldTex->array_size,
+ 0,
oldTex->bind);
/* This will copy the old texture's base image into the new texture
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 338c652cb..f8176eb77 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1945,8 +1945,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
if (ir->type->base_type == GLSL_TYPE_BOOL) {
emit(ir, TGSI_OPCODE_USNE, result_dst, cbuf, st_src_reg_for_int(0));
- result_src.negate = 1;
- emit(ir, TGSI_OPCODE_UCMP, result_dst, result_src, st_src_reg_for_int(~0), st_src_reg_for_int(0));
} else {
emit(ir, TGSI_OPCODE_MOV, result_dst, cbuf);
}
@@ -1969,7 +1967,17 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_unop_unpack_snorm_4x8:
case ir_unop_unpack_unorm_4x8:
case ir_binop_pack_half_2x16_split:
+ case ir_unop_bitfield_reverse:
+ case ir_unop_bit_count:
+ case ir_unop_find_msb:
+ case ir_unop_find_lsb:
+ case ir_binop_bfm:
+ case ir_triop_bfi:
+ case ir_triop_bitfield_extract:
+ case ir_quadop_bitfield_insert:
case ir_quadop_vector:
+ case ir_binop_vector_extract:
+ case ir_triop_vector_insert:
/* This operation is not supported, or should have already been handled.
*/
assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()");
@@ -2388,8 +2396,8 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
if (native_integers) {
/* This is necessary because TGSI's CMP instruction expects the
* condition to be a float, and we store booleans as integers.
- * If TGSI had a UCMP instruction or similar, this extra
- * instruction would not be necessary.
+ * TODO: really want to avoid i2f path and use UCMP. Requires
+ * changes to process_move_condition though too.
*/
condition_temp = get_temp(glsl_type::vec4_type);
condition.negate = 0;
@@ -2683,7 +2691,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
void
glsl_to_tgsi_visitor::visit(ir_texture *ir)
{
- st_src_reg result_src, coord, cube_sc, lod_info, projector, dx, dy, offset;
+ st_src_reg result_src, coord, cube_sc, lod_info, projector, dx, dy, offset, sample_index;
st_dst_reg result_dst, coord_dst, cube_sc_dst;
glsl_to_tgsi_instruction *inst = NULL;
unsigned opcode = TGSI_OPCODE_NOP;
@@ -2706,6 +2714,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
*/
coord = get_temp(glsl_type::vec4_type);
coord_dst = st_dst_reg(coord);
+ coord_dst.writemask = (1 << ir->coordinate->type->vector_elements) - 1;
emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
}
@@ -2772,7 +2781,9 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
}
break;
case ir_txf_ms:
- assert(!"Unexpected ir_txf_ms opcode");
+ opcode = TGSI_OPCODE_TXF;
+ ir->lod_info.sample_index->accept(this);
+ sample_index = this->result;
break;
case ir_lod:
assert(!"Unexpected ir_lod opcode");
@@ -2859,7 +2870,11 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
}
}
- if (opcode == TGSI_OPCODE_TXL || opcode == TGSI_OPCODE_TXB ||
+ if (ir->op == ir_txf_ms) {
+ coord_dst.writemask = WRITEMASK_W;
+ emit(ir, TGSI_OPCODE_MOV, coord_dst, sample_index);
+ coord_dst.writemask = WRITEMASK_XYZW;
+ } else if (opcode == TGSI_OPCODE_TXL || opcode == TGSI_OPCODE_TXB ||
opcode == TGSI_OPCODE_TXF) {
/* TGSI stores LOD or LOD bias in the last channel of the coords. */
coord_dst.writemask = WRITEMASK_W;
@@ -2921,6 +2936,10 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
case GLSL_SAMPLER_DIM_EXTERNAL:
inst->tex_target = TEXTURE_EXTERNAL_INDEX;
break;
+ case GLSL_SAMPLER_DIM_MS:
+ inst->tex_target = (sampler_type->sampler_array)
+ ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : TEXTURE_2D_MULTISAMPLE_INDEX;
+ break;
default:
assert(!"Should not get here.");
}
@@ -2967,12 +2986,15 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)
void
glsl_to_tgsi_visitor::visit(ir_if *ir)
{
+ unsigned if_opcode;
glsl_to_tgsi_instruction *if_inst;
ir->condition->accept(this);
assert(this->result.file != PROGRAM_UNDEFINED);
- if_inst = emit(ir->condition, TGSI_OPCODE_IF, undef_dst, this->result);
+ if_opcode = native_integers ? TGSI_OPCODE_UIF : TGSI_OPCODE_IF;
+
+ if_inst = emit(ir->condition, if_opcode, undef_dst, this->result);
this->instructions.push_tail(if_inst);
@@ -3451,6 +3473,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
break;
case TGSI_OPCODE_IF:
+ case TGSI_OPCODE_UIF:
++level;
break;
@@ -3529,6 +3552,8 @@ glsl_to_tgsi_visitor::copy_propagate(void)
/* If this is a copy, add it to the ACP. */
if (inst->op == TGSI_OPCODE_MOV &&
inst->dst.file == PROGRAM_TEMPORARY &&
+ !(inst->dst.file == inst->src[0].file &&
+ inst->dst.index == inst->src[0].index) &&
!inst->dst.reladdr &&
!inst->saturate &&
!inst->src[0].reladdr &&
@@ -3653,6 +3678,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
break;
case TGSI_OPCODE_IF:
+ case TGSI_OPCODE_UIF:
++level;
/* fallthrough to default case to mark the condition as read */
@@ -4378,6 +4404,7 @@ compile_tgsi_instruction(struct st_translate *t,
case TGSI_OPCODE_ELSE:
case TGSI_OPCODE_ENDLOOP:
case TGSI_OPCODE_IF:
+ case TGSI_OPCODE_UIF:
assert(num_dst == 0);
ureg_label_insn(ureg,
inst->op,
@@ -4903,7 +4930,7 @@ st_translate_program(
assert(i == program->num_immediates);
/* texture samplers */
- for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
if (program->samplers_used & (1 << i)) {
t->samplers[i] = ureg_DECL_sampler(ureg, i);
}
@@ -5216,6 +5243,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
lower_ubo_reference(prog->_LinkedShaders[i], ir);
do_vec_index_to_cond_assign(ir);
+ lower_vector_insert(ir, true);
lower_quadop_vector(ir, false);
lower_noise(ir);
if (options->MaxIfDepth == 0) {
@@ -5228,7 +5256,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
progress = do_common_optimization(ir, true, true,
- options->MaxUnrollIterations)
+ options->MaxUnrollIterations, options)
|| progress;
progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 03e086a72..9e537f3c4 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -28,7 +28,6 @@
#include "main/mtypes.h"
#include "main/context.h"
-#include "main/mfeatures.h"
#include "main/texobj.h"
#include "main/teximage.h"
#include "main/texstate.h"
@@ -454,7 +453,7 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags,
struct pipe_fence_handle **fence)
{
struct st_context *st = (struct st_context *) stctxi;
- enum pipe_flush_flags pipe_flags = 0;
+ unsigned pipe_flags = 0;
if (flags & ST_FLUSH_END_OF_FRAME) {
pipe_flags |= PIPE_FLUSH_END_OF_FRAME;
@@ -468,7 +467,7 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags,
static boolean
st_context_teximage(struct st_context_iface *stctxi,
enum st_texture_type tex_type,
- int level, enum pipe_format internal_format,
+ int level, enum pipe_format pipe_format,
struct pipe_resource *tex, boolean mipmap)
{
struct st_context *st = (struct st_context *) stctxi;
@@ -512,29 +511,13 @@ st_context_teximage(struct st_context_iface *stctxi,
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
stImage = st_texture_image(texImage);
if (tex) {
- gl_format texFormat;
-
- /*
- * XXX When internal_format and tex->format differ, st_finalize_texture
- * needs to allocate a new texture with internal_format and copy the
- * texture here into the new one. It will result in surface_copy being
- * called on surfaces whose formats differ.
- *
- * To avoid that, internal_format is (wrongly) ignored here. A sane fix
- * is to use a sampler view.
- */
- if (!st_sampler_compat_formats(tex->format, internal_format))
- internal_format = tex->format;
-
- if (util_format_get_component_bits(internal_format,
- UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
+ gl_format texFormat = st_pipe_format_to_mesa_format(pipe_format);
+
+ if (util_format_has_alpha(tex->format))
internalFormat = GL_RGBA;
else
internalFormat = GL_RGB;
- texFormat = st_ChooseTextureFormat(ctx, target, internalFormat,
- GL_BGRA, GL_UNSIGNED_BYTE);
-
_mesa_init_teximage_fields(ctx, texImage,
tex->width0, tex->height0, 1, 0,
internalFormat, texFormat);
@@ -563,6 +546,7 @@ st_context_teximage(struct st_context_iface *stctxi,
stObj->width0 = width;
stObj->height0 = height;
stObj->depth0 = depth;
+ stObj->surface_format = pipe_format;
_mesa_dirty_texobj(ctx, texObj, GL_TRUE);
_mesa_unlock_texture(ctx, texObj);
@@ -884,16 +868,10 @@ st_manager_add_color_renderbuffer(struct st_context *st,
static const struct st_api st_gl_api = {
"Mesa " PACKAGE_VERSION,
ST_API_OPENGL,
-#if FEATURE_GL
ST_PROFILE_DEFAULT_MASK |
ST_PROFILE_OPENGL_CORE_MASK |
-#endif
-#if FEATURE_ES1
ST_PROFILE_OPENGL_ES1_MASK |
-#endif
-#if FEATURE_ES2
ST_PROFILE_OPENGL_ES2_MASK |
-#endif
0,
ST_API_FEATURE_MS_VISUALS_MASK,
st_api_destroy,
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 3831a0a79..dd9f4fc53 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -269,6 +269,8 @@ st_translate_texture_target( GLuint textarget,
}
switch( textarget ) {
+ case TEXTURE_2D_MULTISAMPLE_INDEX: return TGSI_TEXTURE_2D_MSAA;
+ case TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX: return TGSI_TEXTURE_2D_ARRAY_MSAA;
case TEXTURE_BUFFER_INDEX: return TGSI_TEXTURE_BUFFER;
case TEXTURE_1D_INDEX: return TGSI_TEXTURE_1D;
case TEXTURE_2D_INDEX: return TGSI_TEXTURE_2D;
@@ -554,8 +556,6 @@ translate_opcode( unsigned op )
return TGSI_OPCODE_DDY;
case OPCODE_DP2:
return TGSI_OPCODE_DP2;
- case OPCODE_DP2A:
- return TGSI_OPCODE_DP2A;
case OPCODE_DP3:
return TGSI_OPCODE_DP3;
case OPCODE_DP4:
@@ -608,10 +608,6 @@ translate_opcode( unsigned op )
return TGSI_OPCODE_MUL;
case OPCODE_NOP:
return TGSI_OPCODE_NOP;
- case OPCODE_NRM3:
- return TGSI_OPCODE_NRM;
- case OPCODE_NRM4:
- return TGSI_OPCODE_NRM4;
case OPCODE_POW:
return TGSI_OPCODE_POW;
case OPCODE_RCP:
@@ -663,6 +659,7 @@ translate_opcode( unsigned op )
static void
compile_instruction(
+ struct gl_context *ctx,
struct st_translate *t,
const struct prog_instruction *inst,
boolean clamp_dst_color_output)
@@ -695,7 +692,6 @@ compile_instruction(
case OPCODE_CAL:
case OPCODE_ELSE:
case OPCODE_ENDLOOP:
- case OPCODE_IF:
debug_assert(num_dst == 0);
ureg_label_insn( ureg,
translate_opcode( inst->Opcode ),
@@ -703,6 +699,14 @@ compile_instruction(
get_label( t, inst->BranchTarget ));
return;
+ case OPCODE_IF:
+ debug_assert(num_dst == 0);
+ ureg_label_insn( ureg,
+ ctx->Const.NativeIntegers ? TGSI_OPCODE_UIF : TGSI_OPCODE_IF,
+ src, num_src,
+ get_label( t, inst->BranchTarget ));
+ return;
+
case OPCODE_TEX:
case OPCODE_TXB:
case OPCODE_TXD:
@@ -1217,7 +1221,7 @@ st_translate_mesa_program(
}
/* texture samplers */
- for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
if (program->SamplersUsed & (1 << i)) {
t->samplers[i] = ureg_DECL_sampler( ureg, i );
}
@@ -1227,7 +1231,7 @@ st_translate_mesa_program(
*/
for (i = 0; i < program->NumInstructions; i++) {
set_insn_start( t, ureg_get_instruction_number( ureg ));
- compile_instruction( t, &program->Instructions[i], clamp_color );
+ compile_instruction( ctx, t, &program->Instructions[i], clamp_color );
}
/* Fix up all emitted labels:
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 7a38da84f..60cc37cf8 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -33,7 +33,6 @@
#include "main/imports.h"
#include "main/hash.h"
-#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "program/prog_parameter.h"
#include "program/prog_print.h"
diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c
index ed3709848..9a271826e 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_texture.c
@@ -60,6 +60,7 @@ st_texture_create(struct st_context *st,
GLuint height0,
GLuint depth0,
GLuint layers,
+ GLuint nr_samples,
GLuint bind )
{
struct pipe_resource pt, *newtex;
@@ -90,6 +91,7 @@ st_texture_create(struct st_context *st,
pt.usage = PIPE_USAGE_DEFAULT;
pt.bind = bind;
pt.flags = 0;
+ pt.nr_samples = nr_samples;
newtex = screen->resource_create(screen, &pt);
@@ -138,6 +140,8 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture,
case GL_TEXTURE_RECTANGLE:
case GL_PROXY_TEXTURE_RECTANGLE:
case GL_TEXTURE_EXTERNAL_OES:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
assert(depthIn == 1);
*widthOut = widthIn;
*heightOut = heightIn;
@@ -159,7 +163,9 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture,
*layersOut = 6;
break;
case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
case GL_PROXY_TEXTURE_2D_ARRAY:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
*widthOut = widthIn;
*heightOut = heightIn;
*depthOut = 1;
@@ -402,7 +408,7 @@ st_create_color_map_texture(struct gl_context *ctx)
/* create texture for color map/table */
pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
- texSize, texSize, 1, 1, PIPE_BIND_SAMPLER_VIEW);
+ texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW);
return pt;
}
diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h
index 8a701009a..c15aeaea6 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.h
+++ b/mesalib/src/mesa/state_tracker/st_texture.h
@@ -87,10 +87,16 @@ struct st_texture_object
*/
struct pipe_sampler_view *sampler_view;
- /* True if there is/was a surface bound to this texture object. It helps
- * track whether the texture object is surface based or not.
+ /* True if this texture comes from the window system. Such a texture
+ * cannot be reallocated and the format can only be changed with a sampler
+ * view or a surface.
*/
GLboolean surface_based;
+
+ /* If surface_based is true, this format should be used for all sampler
+ * views and surfaces instead of pt->format.
+ */
+ enum pipe_format surface_format;
};
@@ -153,6 +159,7 @@ st_texture_create(struct st_context *st,
GLuint height0,
GLuint depth0,
GLuint layers,
+ GLuint nr_samples,
GLuint tex_usage );