aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-12-22 12:51:45 +0100
committermarha <marha@users.sourceforge.net>2013-12-22 12:51:45 +0100
commitc81020559f329a516191927222b3698ba7370aca (patch)
tree6f004f5723ca41881b2ba703ed619a92faebfe16 /mesalib/src/mesa/state_tracker
parentc043f97a8572e1f509251288d8bcd70d0fb96770 (diff)
downloadvcxsrv-c81020559f329a516191927222b3698ba7370aca.tar.gz
vcxsrv-c81020559f329a516191927222b3698ba7370aca.tar.bz2
vcxsrv-c81020559f329a516191927222b3698ba7370aca.zip
libxtrans fontconfig glproto libX11 libxcb xcbproto mesa xserver pixman xkeyboard-config git update 22 Dec 2013
xserver commit a68df147421da21528b5be2d34678383922fa352 libxcb commit f653464554469b5767f1c99abced25a76bace047 libxcb/xcb-proto commit 4087fc682c5ceb849b74442e17a6b73176e5eecb xkeyboard-config commit a224a636139d22e1dc7ca7d23782cd656e87bcf5 libX11 commit 3d69b0a83e62f8f6fbdd952fc49cdbdf8825e1e6 libXdmcp commit 089081dca4ba3598c6f9bf401c029378943b5854 libXext commit bb24f2970f2e425f4df90c9b73d078ad15a73fbb libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a libXinerama commit edd95182b26eb5d576d4878c559e0f17dddaa909 libXau commit 304a11be4727c5a7feeb2501e8e001466f8ce84e xkbcomp commit e3e6e938535532bfad175c1635256ab7fb3ac943 pixman commit 945ab7a6f3eb6241f07e8f094dc0e647d1f10d9d xextproto commit 3f355f138d6df57e067458a20f47307883048adb randrproto commit e7526e6b5fe0966929cda10b2ded0258413744db glproto commit f84853d97d5749308992412a215fa518b6536eb3 mkfontscale commit 880a0c4733e62e54e6a0f1238c7430727d23657b xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 libXft commit 4acfdaf95adb0a05c2a25550bdde036c865902f4 libXmu commit 22d9c590901e121936f50dee97dc60c4f7defb63 libxtrans commit 2c0a7840a28ae696e80e73157856d7a049fdf6c7 fontconfig commit 5c725f2f5829238d16116f782d00d8bb0defaf08 mesa commit 2efe7927d38983029784825fc4897e9b77aa237e
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_framebuffer.c58
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c32
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c124
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c19
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c97
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.h10
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_readpixels.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c16
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp74
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.h6
16 files changed, 239 insertions, 232 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
index c752640f4..51f079cda 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -44,56 +44,6 @@
/**
- * When doing GL render to texture, we have to be sure that finalize_texture()
- * didn't yank out the pipe_resource that we earlier created a surface for.
- * Check for that here and create a new surface if needed.
- */
-static void
-update_renderbuffer_surface(struct st_context *st,
- struct st_renderbuffer *strb)
-{
- struct pipe_context *pipe = st->pipe;
- struct pipe_resource *resource = strb->rtt ? strb->rtt->pt : strb->texture;
- int rtt_width = strb->Base.Width;
- int rtt_height = strb->Base.Height;
- 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 ||
- strb->surface->height != rtt_height) {
- GLuint level;
- /* find matching mipmap level size */
- for (level = 0; level <= resource->last_level; level++) {
- if (u_minify(resource->width0, level) == rtt_width &&
- u_minify(resource->height0, level) == rtt_height) {
- struct pipe_surface surf_tmpl;
- memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = format;
- surf_tmpl.u.tex.level = level;
- surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice;
- surf_tmpl.u.tex.last_layer = strb->rtt_face + strb->rtt_slice;
-
- pipe_surface_reference(&strb->surface, NULL);
-
- strb->surface = pipe->create_surface(pipe,
- resource,
- &surf_tmpl);
-#if 0
- printf("-- alloc new surface %d x %d into tex %p\n",
- strb->surface->width, strb->surface->height,
- texture);
-#endif
- break;
- }
- }
- }
-}
-
-
-/**
* Update framebuffer state (color, depth, stencil, etc. buffers)
*/
static void
@@ -121,10 +71,10 @@ update_framebuffer_state( struct st_context *st )
if (strb) {
/*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
- if (strb->rtt ||
+ if (strb->is_rtt ||
(strb->texture && util_format_is_srgb(strb->texture->format))) {
/* rendering to a GL texture, may have to update surface */
- update_renderbuffer_surface(st, strb);
+ st_update_renderbuffer_surface(st, strb);
}
if (strb->surface) {
@@ -144,9 +94,9 @@ update_framebuffer_state( struct st_context *st )
*/
strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
if (strb) {
- if (strb->rtt) {
+ if (strb->is_rtt) {
/* rendering to a GL texture, may have to update surface */
- update_renderbuffer_surface(st, strb);
+ st_update_renderbuffer_surface(st, strb);
}
pipe_surface_reference(&framebuffer->zsbuf, strb->surface);
}
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index 302e12981..57670ce25 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -130,15 +130,20 @@ convert_sampler(struct st_context *st,
struct pipe_sampler_state *sampler,
GLuint texUnit)
{
- struct gl_texture_object *texobj;
+ const struct gl_texture_object *texobj;
struct gl_context *ctx = st->ctx;
struct gl_sampler_object *msamp;
+ const struct gl_texture_image *teximg;
+ GLenum texBaseFormat;
texobj = ctx->Texture.Unit[texUnit]._Current;
if (!texobj) {
texobj = _mesa_get_fallback_texture(ctx, TEXTURE_2D_INDEX);
}
+ teximg = texobj->Image[0][texobj->BaseLevel];
+ texBaseFormat = teximg ? teximg->_BaseFormat : GL_RGBA;
+
msamp = _mesa_get_samplerobj(ctx, texUnit);
memset(sampler, 0, sizeof(*sampler));
@@ -170,21 +175,15 @@ convert_sampler(struct st_context *st,
assert(sampler->min_lod <= sampler->max_lod);
}
+ /* For non-black borders... */
if (msamp->BorderColor.ui[0] ||
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;
+ const struct st_texture_object *stobj = st_texture_object_const(texobj);
+ const GLboolean is_integer = texobj->_IsIntegerFormat;
union pipe_color_union border_color;
- teximg = texobj->Image[0][texobj->BaseLevel];
-
- if (teximg) {
- is_integer = _mesa_is_enum_format_integer(teximg->InternalFormat);
- }
-
if (st->apply_texture_swizzle_to_border_color && stobj->sampler_view) {
const unsigned char swz[4] =
{
@@ -196,25 +195,26 @@ convert_sampler(struct st_context *st,
st_translate_color(&msamp->BorderColor,
&border_color,
- teximg ? teximg->_BaseFormat : GL_RGBA, is_integer);
+ texBaseFormat, 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);
+ texBaseFormat, is_integer);
}
}
sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?
0 : (GLuint) msamp->MaxAnisotropy);
- /* only care about ARB_shadow, not SGI shadow */
- if (msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
+ /* If sampling a depth texture and using shadow comparison */
+ if ((texBaseFormat == GL_DEPTH_COMPONENT ||
+ texBaseFormat == GL_DEPTH_STENCIL) &&
+ msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
- sampler->compare_func
- = st_compare_func_to_pipe(msamp->CompareFunc);
+ sampler->compare_func = st_compare_func_to_pipe(msamp->CompareFunc);
}
sampler->seamless_cube_map =
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 7fa4cbdc4..230ab5449 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -422,6 +422,9 @@ st_bufferobj_validate_usage(struct st_context *st,
void
st_init_bufferobject_functions(struct dd_function_table *functions)
{
+ /* plug in default driver fallbacks (such as for ClearBufferSubData) */
+ _mesa_init_buffer_object_functions(functions);
+
functions->NewBufferObject = st_bufferobj_alloc;
functions->DeleteBuffer = st_bufferobj_free;
functions->BufferData = st_bufferobj_data;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 8da664afb..887e58bd9 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -51,6 +51,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_format.h"
+#include "util/u_framebuffer.h"
#include "util/u_inlines.h"
#include "util/u_simple_shaders.h"
#include "util/u_draw_quad.h"
@@ -129,6 +130,26 @@ set_vertex_shader(struct st_context *st)
}
+static void
+set_vertex_shader_layered(struct st_context *st)
+{
+ struct pipe_context *pipe = st->pipe;
+
+ if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID) ||
+ !pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER)) {
+ assert(!"Got layered clear, but the VS layer output is unsupported");
+ set_vertex_shader(st);
+ return;
+ }
+
+ if (!st->clear.vs_layered) {
+ st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe);
+ }
+
+ cso_set_vertex_shader_handle(st->cso_context, st->clear.vs_layered);
+}
+
+
/**
* Draw a screen-aligned quadrilateral.
* Coords are clip coords with y=0=bottom.
@@ -136,15 +157,19 @@ set_vertex_shader(struct st_context *st)
static void
draw_quad(struct st_context *st,
float x0, float y0, float x1, float y1, GLfloat z,
+ unsigned num_instances,
const union pipe_color_union *color)
{
- struct pipe_context *pipe = st->pipe;
- struct pipe_resource *vbuf = NULL;
- GLuint i, offset;
+ struct cso_context *cso = st->cso_context;
+ struct pipe_vertex_buffer vb = {0};
+ GLuint i;
float (*vertices)[2][4]; /**< vertex pos + color */
+ vb.stride = 8 * sizeof(float);
+
if (u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
- &offset, &vbuf, (void **) &vertices) != PIPE_OK) {
+ &vb.buffer_offset, &vb.buffer,
+ (void **) &vertices) != PIPE_OK) {
return;
}
@@ -174,16 +199,10 @@ draw_quad(struct st_context *st,
u_upload_unmap(st->uploader);
/* draw */
- util_draw_vertex_buffer(pipe,
- st->cso_context,
- vbuf,
- cso_get_aux_vertex_buffer_slot(st->cso_context),
- offset,
- PIPE_PRIM_TRIANGLE_FAN,
- 4, /* verts */
- 2); /* attribs/vert */
-
- pipe_resource_reference(&vbuf, NULL);
+ cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso), 1, &vb);
+ cso_draw_arrays_instanced(cso, PIPE_PRIM_TRIANGLE_FAN, 0, 4,
+ 0, num_instances);
+ pipe_resource_reference(&vb.buffer, NULL);
}
@@ -194,8 +213,7 @@ draw_quad(struct st_context *st,
* ctx->DrawBuffer->_X/Ymin/max fields.
*/
static void
-clear_with_quad(struct gl_context *ctx,
- GLboolean color, GLboolean depth, GLboolean stencil)
+clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
{
struct st_context *st = st_context(ctx);
const struct gl_framebuffer *fb = ctx->DrawBuffer;
@@ -205,7 +223,8 @@ clear_with_quad(struct gl_context *ctx,
const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f;
- union pipe_color_union clearColor;
+ unsigned num_layers =
+ util_framebuffer_get_num_layers(&st->state.framebuffer);
/*
printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__,
@@ -233,7 +252,7 @@ clear_with_quad(struct gl_context *ctx,
{
struct pipe_blend_state blend;
memset(&blend, 0, sizeof(blend));
- if (color) {
+ if (clear_buffers & PIPE_CLEAR_COLOR) {
int num_buffers = ctx->Extensions.EXT_draw_buffers2 ?
ctx->DrawBuffer->_NumColorDrawBuffers : 1;
int i;
@@ -241,6 +260,9 @@ clear_with_quad(struct gl_context *ctx,
blend.independent_blend_enable = num_buffers > 1;
for (i = 0; i < num_buffers; i++) {
+ if (!(clear_buffers & (PIPE_CLEAR_COLOR0 << i)))
+ continue;
+
if (ctx->Color.ColorMask[i][0])
blend.rt[i].colormask |= PIPE_MASK_R;
if (ctx->Color.ColorMask[i][1])
@@ -261,13 +283,13 @@ clear_with_quad(struct gl_context *ctx,
{
struct pipe_depth_stencil_alpha_state depth_stencil;
memset(&depth_stencil, 0, sizeof(depth_stencil));
- if (depth) {
+ if (clear_buffers & PIPE_CLEAR_DEPTH) {
depth_stencil.depth.enabled = 1;
depth_stencil.depth.writemask = 1;
depth_stencil.depth.func = PIPE_FUNC_ALWAYS;
}
- if (stencil) {
+ if (clear_buffers & PIPE_CLEAR_STENCIL) {
struct pipe_stencil_ref stencil_ref;
memset(&stencil_ref, 0, sizeof(stencil_ref));
depth_stencil.stencil[0].enabled = 1;
@@ -305,21 +327,20 @@ clear_with_quad(struct gl_context *ctx,
}
set_fragment_shader(st);
- set_vertex_shader(st);
cso_set_geometry_shader_handle(st->cso_context, NULL);
- if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- GLboolean is_integer = _mesa_is_enum_format_integer(rb->InternalFormat);
+ if (num_layers > 1)
+ set_vertex_shader_layered(st);
+ else
+ set_vertex_shader(st);
- st_translate_color(&ctx->Color.ClearColor,
- &clearColor,
- ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- is_integer);
- }
+ /* We can't translate the clear color to the colorbuffer format,
+ * because different colorbuffers may have different formats.
+ */
/* draw quad matching scissor rect */
- draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, &clearColor);
+ draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, num_layers,
+ (union pipe_color_union*)&ctx->Color.ClearColor);
/* Restore pipe state */
cso_restore_blend(st->cso_context);
@@ -352,6 +373,19 @@ is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb)
/**
+ * Return if all of the color channels are masked.
+ */
+static INLINE GLboolean
+is_color_disabled(struct gl_context *ctx, int i)
+{
+ return !ctx->Color.ColorMask[i][0] &&
+ !ctx->Color.ColorMask[i][1] &&
+ !ctx->Color.ColorMask[i][2] &&
+ !ctx->Color.ColorMask[i][3];
+}
+
+
+/**
* Return if any of the color channels are masked.
*/
static INLINE GLboolean
@@ -408,11 +442,14 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
if (!strb || !strb->surface)
continue;
+ if (is_color_disabled(ctx, colormask_index))
+ continue;
+
if (is_scissor_enabled(ctx, rb) ||
is_color_masked(ctx, colormask_index))
- quad_buffers |= PIPE_CLEAR_COLOR;
+ quad_buffers |= PIPE_CLEAR_COLOR0 << i;
else
- clear_buffers |= PIPE_CLEAR_COLOR;
+ clear_buffers |= PIPE_CLEAR_COLOR0 << i;
}
}
}
@@ -445,24 +482,13 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
*/
if (quad_buffers) {
quad_buffers |= clear_buffers;
- clear_with_quad(ctx,
- quad_buffers & PIPE_CLEAR_COLOR,
- quad_buffers & PIPE_CLEAR_DEPTH,
- quad_buffers & PIPE_CLEAR_STENCIL);
+ clear_with_quad(ctx, quad_buffers);
} else if (clear_buffers) {
- union pipe_color_union clearColor;
-
- if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- GLboolean is_integer = _mesa_is_enum_format_integer(rb->InternalFormat);
-
- st_translate_color(&ctx->Color.ClearColor,
- &clearColor,
- ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- is_integer);
- }
-
- st->pipe->clear(st->pipe, clear_buffers, &clearColor,
+ /* We can't translate the clear color to the colorbuffer format,
+ * because different colorbuffers may have different formats.
+ */
+ st->pipe->clear(st->pipe, clear_buffers,
+ (union pipe_color_union*)&ctx->Color.ClearColor,
ctx->Depth.Clear, ctx->Stencil.Clear);
}
if (mask & BUFFER_BIT_ACCUM)
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 2ce4728ad..3058dfb5b 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -878,7 +878,8 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
}
stmap = pipe_transfer_map(pipe, strb->texture,
- strb->rtt_level, strb->rtt_face + strb->rtt_slice,
+ strb->surface->u.tex.level,
+ strb->surface->u.tex.first_layer,
usage, x, y,
width, height, &pt);
@@ -1263,8 +1264,8 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
/* map the stencil buffer */
drawMap = pipe_transfer_map(pipe,
rbDraw->texture,
- rbDraw->rtt_level,
- rbDraw->rtt_face + rbDraw->rtt_slice,
+ rbDraw->surface->u.tex.level,
+ rbDraw->surface->u.tex.first_layer,
usage, dstx, dsty,
width, height, &ptDraw);
@@ -1422,20 +1423,20 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
memset(&blit, 0, sizeof(blit));
blit.src.resource = rbRead->texture;
- blit.src.level = rbRead->rtt_level;
+ blit.src.level = rbRead->surface->u.tex.level;
blit.src.format = rbRead->texture->format;
blit.src.box.x = readX;
blit.src.box.y = readY;
- blit.src.box.z = rbRead->rtt_face + rbRead->rtt_slice;
+ blit.src.box.z = rbRead->surface->u.tex.first_layer;
blit.src.box.width = readW;
blit.src.box.height = readH;
blit.src.box.depth = 1;
blit.dst.resource = rbDraw->texture;
- blit.dst.level = rbDraw->rtt_level;
+ blit.dst.level = rbDraw->surface->u.tex.level;
blit.dst.format = rbDraw->texture->format;
blit.dst.box.x = drawX;
blit.dst.box.y = drawY;
- blit.dst.box.z = rbDraw->rtt_face + rbDraw->rtt_slice;
+ blit.dst.box.z = rbDraw->surface->u.tex.first_layer;
blit.dst.box.width = drawW;
blit.dst.box.height = drawH;
blit.dst.box.depth = 1;
@@ -1633,11 +1634,11 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
memset(&blit, 0, sizeof(blit));
blit.src.resource = rbRead->texture;
- blit.src.level = rbRead->rtt_level;
+ blit.src.level = rbRead->surface->u.tex.level;
blit.src.format = rbRead->texture->format;
blit.src.box.x = readX;
blit.src.box.y = readY;
- blit.src.box.z = rbRead->rtt_face + rbRead->rtt_slice;
+ blit.src.box.z = rbRead->surface->u.tex.first_layer;
blit.src.box.width = readW;
blit.src.box.height = readH;
blit.src.box.depth = 1;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 20894825f..70baa9965 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -389,6 +389,72 @@ st_bind_framebuffer(struct gl_context *ctx, GLenum target,
/**
+ * Create or update the pipe_surface of a FBO renderbuffer.
+ * This is usually called after st_finalize_texture.
+ */
+void
+st_update_renderbuffer_surface(struct st_context *st,
+ struct st_renderbuffer *strb)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_resource *resource = strb->texture;
+ int rtt_width = strb->Base.Width;
+ int rtt_height = strb->Base.Height;
+ int rtt_depth = strb->Base.Depth;
+ enum pipe_format format = st->ctx->Color.sRGBEnabled ? resource->format :
+ util_format_linear(resource->format);
+ unsigned first_layer, last_layer, level;
+
+ if (resource->target == PIPE_TEXTURE_1D_ARRAY) {
+ rtt_depth = rtt_height;
+ rtt_height = 1;
+ }
+
+ /* find matching mipmap level size */
+ for (level = 0; level <= resource->last_level; level++) {
+ if (u_minify(resource->width0, level) == rtt_width &&
+ u_minify(resource->height0, level) == rtt_height &&
+ (resource->target != PIPE_TEXTURE_3D ||
+ u_minify(resource->depth0, level) == rtt_depth)) {
+ break;
+ }
+ }
+ assert(level <= resource->last_level);
+
+ /* determine the layer bounds */
+ if (strb->rtt_layered) {
+ first_layer = 0;
+ last_layer = util_max_layer(strb->texture, level);
+ }
+ else {
+ first_layer =
+ last_layer = strb->rtt_face + strb->rtt_slice;
+ }
+
+ if (!strb->surface ||
+ strb->surface->texture->nr_samples != strb->Base.NumSamples ||
+ strb->surface->format != format ||
+ strb->surface->texture != resource ||
+ strb->surface->width != rtt_width ||
+ strb->surface->height != rtt_height ||
+ strb->surface->u.tex.level != level ||
+ strb->surface->u.tex.first_layer != first_layer ||
+ strb->surface->u.tex.last_layer != last_layer) {
+ /* create a new pipe_surface */
+ struct pipe_surface surf_tmpl;
+ memset(&surf_tmpl, 0, sizeof(surf_tmpl));
+ surf_tmpl.format = format;
+ surf_tmpl.u.tex.level = level;
+ surf_tmpl.u.tex.first_layer = first_layer;
+ surf_tmpl.u.tex.last_layer = last_layer;
+
+ pipe_surface_reference(&strb->surface, NULL);
+
+ strb->surface = pipe->create_surface(pipe, resource, &surf_tmpl);
+ }
+}
+
+/**
* Called by ctx->Driver.RenderTexture
*/
static void
@@ -401,8 +467,6 @@ st_render_texture(struct gl_context *ctx,
struct gl_renderbuffer *rb = att->Renderbuffer;
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_resource *pt;
- struct st_texture_object *stObj;
- struct pipe_surface surf_tmpl;
if (!st_finalize_texture(ctx, pipe, att->Texture))
return;
@@ -410,31 +474,16 @@ st_render_texture(struct gl_context *ctx,
pt = st_get_texobj_resource(att->Texture);
assert(pt);
- /* get the texture for the texture object */
- stObj = st_texture_object(att->Texture);
-
/* point renderbuffer at texobject */
- strb->rtt = stObj;
- strb->rtt_level = att->TextureLevel;
+ strb->is_rtt = TRUE;
strb->rtt_face = att->CubeMapFace;
strb->rtt_slice = att->Zoffset;
-
- pipe_resource_reference( &strb->texture, pt );
+ strb->rtt_layered = att->Layered;
+ pipe_resource_reference(&strb->texture, pt);
pipe_surface_release(pipe, &strb->surface);
- assert(strb->rtt_level <= strb->texture->last_level);
-
- /* new surface for rendering into the texture */
- memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = ctx->Color.sRGBEnabled
- ? strb->texture->format : util_format_linear(strb->texture->format);
- surf_tmpl.u.tex.level = strb->rtt_level;
- surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice;
- surf_tmpl.u.tex.last_layer = strb->rtt_face + strb->rtt_slice;
- strb->surface = pipe->create_surface(pipe,
- strb->texture,
- &surf_tmpl);
+ st_update_renderbuffer_surface(st, strb);
strb->Base.Format = st_pipe_format_to_mesa_format(pt->format);
@@ -464,7 +513,7 @@ st_finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer *rb)
if (!strb)
return;
- strb->rtt = NULL;
+ strb->is_rtt = FALSE;
/* restore previous framebuffer state */
st_invalidate_state(ctx, _NEW_BUFFERS);
@@ -706,8 +755,8 @@ st_MapRenderbuffer(struct gl_context *ctx,
map = pipe_transfer_map(pipe,
strb->texture,
- strb->rtt_level,
- strb->rtt_face + strb->rtt_slice,
+ strb->surface->u.tex.level,
+ strb->surface->u.tex.first_layer,
usage, x, y2, w, h, &strb->transfer);
if (map) {
if (invert) {
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.h b/mesalib/src/mesa/state_tracker/st_cb_fbo.h
index f335c371b..88fccc298 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.h
@@ -58,8 +58,10 @@ struct st_renderbuffer
boolean software;
void *data;
- struct st_texture_object *rtt; /**< GL render to texture's texture */
- unsigned rtt_level, rtt_face, rtt_slice;
+ /* Inputs from Driver.RenderTexture, don't use directly. */
+ boolean is_rtt; /**< whether Driver.RenderTexture was called */
+ unsigned rtt_face, rtt_slice;
+ boolean rtt_layered; /**< whether glFramebufferTexture was called */
};
@@ -74,6 +76,10 @@ extern struct gl_renderbuffer *
st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw);
extern void
+st_update_renderbuffer_surface(struct st_context *st,
+ struct st_renderbuffer *strb);
+
+extern void
st_init_fbo_functions(struct dd_function_table *functions);
#endif /* ST_CB_FBO_H */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
index b5df58c03..7547dfd8b 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
@@ -166,7 +166,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
}
blit.src.resource = src;
- blit.src.level = strb->rtt_level;
+ blit.src.level = strb->surface->u.tex.level;
blit.src.format = src_format;
blit.dst.resource = dst;
blit.dst.level = 0;
@@ -175,7 +175,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
blit.dst.box.x = 0;
blit.src.box.y = y;
blit.dst.box.y = 0;
- blit.src.box.z = strb->rtt_face + strb->rtt_slice;
+ blit.src.box.z = strb->surface->u.tex.first_layer;
blit.dst.box.z = 0;
blit.src.box.width = blit.dst.box.width = width;
blit.src.box.height = blit.dst.box.height = height;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index faa9ee3f6..c09f34e37 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -175,10 +175,8 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
pipe_resource_reference(&stImage->pt, NULL);
}
- if (stImage->TexData) {
- _mesa_align_free(stImage->TexData);
- stImage->TexData = NULL;
- }
+ _mesa_align_free(stImage->TexData);
+ stImage->TexData = NULL;
}
@@ -1156,8 +1154,8 @@ fallback_copy_texsubimage(struct gl_context *ctx,
map = pipe_transfer_map(pipe,
strb->texture,
- strb->rtt_level,
- strb->rtt_face + strb->rtt_slice,
+ strb->surface->u.tex.level,
+ strb->surface->u.tex.first_layer,
PIPE_TRANSFER_READ,
srcX, srcY,
width, height, &src_trans);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index ab89b4947..cd0a5ae98 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -178,6 +178,7 @@ struct st_context
struct pipe_viewport_state viewport;
void *vs;
void *fs;
+ void *vs_layered;
} clear;
/** used for anything using util_draw_vertex_buffer */
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index cd10a0c9d..5e4a3b398 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -406,7 +406,6 @@ void st_init_extensions(struct st_context *st)
{ o(NV_texture_barrier), PIPE_CAP_TEXTURE_BARRIER },
/* GL_NV_point_sprite is not supported by gallium because we don't
* support the GL_POINT_SPRITE_R_MODE_NV option. */
- { 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 },
@@ -444,11 +443,6 @@ void st_init_extensions(struct st_context *st)
{ { o(ARB_depth_buffer_float) },
{ PIPE_FORMAT_Z32_FLOAT,
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT } },
-
- { { o(EXT_packed_depth_stencil) },
- { PIPE_FORMAT_S8_UINT_Z24_UNORM,
- PIPE_FORMAT_Z24_UNORM_S8_UINT },
- GL_TRUE }, /* at least one format must be supported */
};
/* Required: sampler support */
@@ -605,6 +599,13 @@ void st_init_extensions(struct st_context *st)
ctx->Const.ForceGLSLVersion = st->options.force_glsl_version;
}
+ /* This extension needs full OpenGL 3.2, but we don't know if that's
+ * supported at this point. Only check the GLSL version. */
+ if (ctx->Const.GLSLVersion >= 150 &&
+ screen->get_param(screen, PIPE_CAP_TGSI_VS_LAYER)) {
+ ctx->Extensions.AMD_vertex_shader_layer = GL_TRUE;
+ }
+
if (ctx->Const.GLSLVersion >= 130) {
ctx->Const.NativeIntegers = GL_TRUE;
ctx->Const.MaxClipPlanes = 8;
@@ -758,8 +759,7 @@ void st_init_extensions(struct st_context *st)
PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW);
}
- if (screen->get_param(screen, PIPE_CAP_MIXED_FRAMEBUFFER_SIZES) &&
- ctx->Extensions.EXT_packed_depth_stencil) {
+ if (screen->get_param(screen, PIPE_CAP_MIXED_FRAMEBUFFER_SIZES)) {
ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index ec2552384..6acf98390 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -1854,12 +1854,12 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
* Similarly for texture border colors.
*/
void
-st_translate_color(union gl_color_union *colorIn,
+st_translate_color(const union gl_color_union *colorIn,
union pipe_color_union *colorOut,
GLenum baseFormat, GLboolean is_integer)
{
if (is_integer) {
- int *in = colorIn->i;
+ const int *in = colorIn->i;
int *out = colorOut->i;
switch (baseFormat) {
@@ -1901,7 +1901,7 @@ st_translate_color(union gl_color_union *colorIn,
}
}
else {
- float *in = colorIn->f;
+ const float *in = colorIn->f;
float *out = colorOut->f;
switch (baseFormat) {
diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h
index 6e97dcb96..3278748d0 100644
--- a/mesalib/src/mesa/state_tracker/st_format.h
+++ b/mesalib/src/mesa/state_tracker/st_format.h
@@ -73,7 +73,7 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
extern void
-st_translate_color(union gl_color_union *colorIn,
+st_translate_color(const union gl_color_union *colorIn,
union pipe_color_union *colorOut,
GLenum baseFormat, GLboolean is_integer);
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 ac95968d6..1331c73dc 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1056,11 +1056,11 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
if (strcmp(ir->name, "gl_FragCoord") == 0) {
struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
- fp->OriginUpperLeft = ir->origin_upper_left;
- fp->PixelCenterInteger = ir->pixel_center_integer;
+ fp->OriginUpperLeft = ir->data.origin_upper_left;
+ fp->PixelCenterInteger = ir->data.pixel_center_integer;
}
- if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
+ if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
unsigned int i;
const ir_state_slot *const slots = ir->state_slots;
assert(ir->state_slots != NULL);
@@ -1137,53 +1137,10 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
void
glsl_to_tgsi_visitor::visit(ir_loop *ir)
{
- ir_dereference_variable *counter = NULL;
-
- if (ir->counter != NULL)
- counter = new(ir) ir_dereference_variable(ir->counter);
-
- if (ir->from != NULL) {
- assert(ir->counter != NULL);
-
- ir_assignment *a = new(ir) ir_assignment(counter, ir->from, NULL);
-
- a->accept(this);
- delete a;
- }
-
emit(NULL, TGSI_OPCODE_BGNLOOP);
- if (ir->to) {
- ir_expression *e =
- new(ir) ir_expression(ir->cmp, glsl_type::bool_type,
- counter, ir->to);
- ir_if *if_stmt = new(ir) ir_if(e);
-
- ir_loop_jump *brk = new(ir) ir_loop_jump(ir_loop_jump::jump_break);
-
- if_stmt->then_instructions.push_tail(brk);
-
- if_stmt->accept(this);
-
- delete if_stmt;
- delete e;
- delete brk;
- }
-
visit_exec_list(&ir->body_instructions, this);
- if (ir->increment) {
- ir_expression *e =
- new(ir) ir_expression(ir_binop_add, counter->type,
- counter, ir->increment);
-
- ir_assignment *a = new(ir) ir_assignment(counter, e, NULL);
-
- a->accept(this);
- delete a;
- delete e;
- }
-
emit(NULL, TGSI_OPCODE_ENDLOOP);
}
@@ -2063,10 +2020,10 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
ir_variable *var = ir->var;
if (!entry) {
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
- var->location);
+ var->data.location);
this->variables.push_tail(entry);
break;
case ir_var_shader_in:
@@ -2075,21 +2032,22 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
* generic attributes (glBindVertexLocation), and
* user-defined varyings.
*/
- assert(var->location != -1);
+ assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
- var->location);
+ var->data.location);
break;
case ir_var_shader_out:
- assert(var->location != -1);
+ assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_OUTPUT,
- var->location + var->index);
+ var->data.location
+ + var->data.index);
break;
case ir_var_system_value:
entry = new(mem_ctx) variable_storage(var,
PROGRAM_SYSTEM_VALUE,
- var->location);
+ var->data.location);
break;
case ir_var_auto:
case ir_var_temporary:
@@ -2388,7 +2346,7 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
l.writemask = WRITEMASK_XYZW;
} else if (ir->lhs->type->is_scalar() &&
- ir->lhs->variable_referenced()->mode == ir_var_shader_out) {
+ ir->lhs->variable_referenced()->data.mode == ir_var_shader_out) {
/* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
* FINISHME: W component of fragment shader output zero, work correctly.
*/
@@ -2664,8 +2622,8 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_function_in ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_in ||
+ param->data.mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);
@@ -2700,8 +2658,8 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_function_out ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_out ||
+ param->data.mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index f010e1889..f72122b4f 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -258,6 +258,10 @@ st_prepare_vertex_program(struct gl_context *ctx,
stvp->output_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
stvp->output_semantic_index[slot] = 0;
break;
+ case VARYING_SLOT_LAYER:
+ stvp->output_semantic_name[slot] = TGSI_SEMANTIC_LAYER;
+ stvp->output_semantic_index[slot] = 0;
+ break;
case VARYING_SLOT_TEX0:
case VARYING_SLOT_TEX1:
@@ -563,6 +567,11 @@ st_translate_fragment_program(struct st_context *st,
input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
break;
+ case VARYING_SLOT_PRIMITIVE_ID:
+ input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
+ input_semantic_index[slot] = 0;
+ interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
+ break;
case VARYING_SLOT_CLIP_DIST0:
input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
input_semantic_index[slot] = 0;
diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h
index c15aeaea6..ac93d9655 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.h
+++ b/mesalib/src/mesa/state_tracker/st_texture.h
@@ -112,6 +112,12 @@ st_texture_object(struct gl_texture_object *obj)
return (struct st_texture_object *) obj;
}
+static INLINE const struct st_texture_object *
+st_texture_object_const(const struct gl_texture_object *obj)
+{
+ return (const struct st_texture_object *) obj;
+}
+
static INLINE struct pipe_resource *
st_get_texobj_resource(struct gl_texture_object *texObj)