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_cb_drawpixels.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c187
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.h4
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp109
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.c3
10 files changed, 201 insertions, 121 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 26d1923b5..ba4f17a3d 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -492,7 +492,7 @@ make_texture(struct st_context *st,
/* Choose a pixel format for the temp texture which will hold the
* image to draw.
*/
- pipeFormat = st_choose_format(pipe->screen, intFormat, format, type,
+ pipeFormat = st_choose_format(st, intFormat, format, type,
PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
FALSE);
assert(pipeFormat != PIPE_FORMAT_NONE);
@@ -1499,7 +1499,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
else {
/* srcFormat can't be used as a texture format */
if (type == GL_DEPTH) {
- texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
+ texFormat = st_choose_format(st, GL_DEPTH_COMPONENT,
GL_NONE, GL_NONE, st->internal_target,
sample_count, PIPE_BIND_DEPTH_STENCIL,
FALSE);
@@ -1507,7 +1507,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
}
else {
/* default color format */
- texFormat = st_choose_format(screen, GL_RGBA,
+ texFormat = st_choose_format(st, GL_RGBA,
GL_NONE, GL_NONE, st->internal_target,
sample_count, PIPE_BIND_SAMPLER_VIEW,
FALSE);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index d042ebabf..72bc960b0 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -63,7 +63,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx,
GLenum internalFormat,
GLuint width, GLuint height)
{
- struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+ struct st_context *st = st_context(ctx);
struct st_renderbuffer *strb = st_renderbuffer(rb);
enum pipe_format format;
size_t size;
@@ -80,7 +80,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx,
format = PIPE_FORMAT_R16G16B16A16_SNORM;
}
else {
- format = st_choose_renderbuffer_format(screen, internalFormat, 0);
+ format = st_choose_renderbuffer_format(st, internalFormat, 0);
/* Not setting gl_renderbuffer::Format here will cause
* FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called.
@@ -153,7 +153,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
unsigned i;
for (i = rb->NumSamples; i <= ctx->Const.MaxSamples; i++) {
- format = st_choose_renderbuffer_format(screen, internalFormat, i);
+ format = st_choose_renderbuffer_format(st, internalFormat, i);
if (format != PIPE_FORMAT_NONE) {
rb->NumSamples = i;
@@ -161,7 +161,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
}
}
} else {
- format = st_choose_renderbuffer_format(screen, internalFormat, 0);
+ format = st_choose_renderbuffer_format(st, internalFormat, 0);
}
/* Not setting gl_renderbuffer::Format here will cause
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 80a440d18..ab5ff27b3 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -596,7 +596,7 @@ decompress_with_blit(struct gl_context * ctx,
pipe_target = gl_target_to_pipe(gl_target);
/* Find the best match for the format+type combo. */
- pipe_format = st_choose_format(pipe->screen, GL_RGBA8, format, type,
+ pipe_format = st_choose_format(st, GL_RGBA8, format, type,
pipe_target, 0, bind, FALSE);
if (pipe_format == PIPE_FORMAT_NONE) {
/* unable to get an rgba format!?! */
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index b416319e1..676fc069d 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -182,6 +182,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st->has_stencil_export =
screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT);
+ st->has_shader_model3 = screen->get_param(screen, PIPE_CAP_SM3);
/* GL limits and extensions */
st_init_limits(st);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 70ee671d0..726c64d04 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -84,6 +84,7 @@ struct st_context
GLboolean clamp_vert_color_in_shader;
boolean has_stencil_export; /**< can do shader stencil export? */
boolean has_time_elapsed;
+ boolean has_shader_model3;
/* 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_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 214588f1f..4d2d43d7e 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -597,6 +597,7 @@ void st_init_extensions(struct st_context *st)
/* Extensions that either depend on GLSL 1.30 or are a subset thereof. */
ctx->Extensions.ARB_conservative_depth = GL_TRUE;
ctx->Extensions.ARB_shader_bit_encoding = GL_TRUE;
+ ctx->Extensions.ARB_shading_language_packing = GL_TRUE;
ctx->Extensions.OES_depth_texture_cube_map = GL_TRUE;
} else {
/* Optional integer support for GLSL 1.2. */
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 2169bed89..5b6e74d50 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -184,7 +184,7 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_R16_UNORM;
case MESA_FORMAT_GR88:
return PIPE_FORMAT_R8G8_UNORM;
- case MESA_FORMAT_RG1616:
+ case MESA_FORMAT_GR1616:
return PIPE_FORMAT_R16G16_UNORM;
case MESA_FORMAT_RGBA_16:
return PIPE_FORMAT_R16G16B16A16_UNORM;
@@ -357,6 +357,38 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_R11G11B10_FLOAT;
case MESA_FORMAT_ARGB2101010_UINT:
return PIPE_FORMAT_B10G10R10A2_UINT;
+
+ case MESA_FORMAT_XRGB4444_UNORM:
+ return PIPE_FORMAT_B4G4R4X4_UNORM;
+ case MESA_FORMAT_XRGB1555_UNORM:
+ return PIPE_FORMAT_B5G5R5X1_UNORM;
+ case MESA_FORMAT_XBGR8888_SNORM:
+ return PIPE_FORMAT_R8G8B8X8_SNORM;
+ case MESA_FORMAT_XBGR8888_SRGB:
+ return PIPE_FORMAT_R8G8B8X8_SRGB;
+ case MESA_FORMAT_XBGR8888_UINT:
+ return PIPE_FORMAT_R8G8B8X8_UINT;
+ case MESA_FORMAT_XBGR8888_SINT:
+ return PIPE_FORMAT_R8G8B8X8_SINT;
+ case MESA_FORMAT_XRGB2101010_UNORM:
+ return PIPE_FORMAT_B10G10R10X2_UNORM;
+ case MESA_FORMAT_XBGR16161616_UNORM:
+ return PIPE_FORMAT_R16G16B16X16_UNORM;
+ case MESA_FORMAT_XBGR16161616_SNORM:
+ return PIPE_FORMAT_R16G16B16X16_SNORM;
+ case MESA_FORMAT_XBGR16161616_FLOAT:
+ return PIPE_FORMAT_R16G16B16X16_FLOAT;
+ case MESA_FORMAT_XBGR16161616_UINT:
+ return PIPE_FORMAT_R16G16B16X16_UINT;
+ case MESA_FORMAT_XBGR16161616_SINT:
+ return PIPE_FORMAT_R16G16B16X16_SINT;
+ case MESA_FORMAT_XBGR32323232_FLOAT:
+ return PIPE_FORMAT_R32G32B32X32_FLOAT;
+ case MESA_FORMAT_XBGR32323232_UINT:
+ return PIPE_FORMAT_R32G32B32X32_UINT;
+ case MESA_FORMAT_XBGR32323232_SINT:
+ return PIPE_FORMAT_R32G32B32X32_SINT;
+
default:
assert(0);
return PIPE_FORMAT_NONE;
@@ -509,7 +541,7 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
case PIPE_FORMAT_R8G8_UNORM:
return MESA_FORMAT_GR88;
case PIPE_FORMAT_R16G16_UNORM:
- return MESA_FORMAT_RG1616;
+ return MESA_FORMAT_GR1616;
case PIPE_FORMAT_A8_UINT:
return MESA_FORMAT_ALPHA_UINT8;
@@ -679,6 +711,38 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
case PIPE_FORMAT_B10G10R10A2_UINT:
return MESA_FORMAT_ARGB2101010_UINT;
+
+ case PIPE_FORMAT_B4G4R4X4_UNORM:
+ return MESA_FORMAT_XRGB4444_UNORM;
+ case PIPE_FORMAT_B5G5R5X1_UNORM:
+ return MESA_FORMAT_XRGB1555_UNORM;
+ case PIPE_FORMAT_R8G8B8X8_SNORM:
+ return MESA_FORMAT_XBGR8888_SNORM;
+ case PIPE_FORMAT_R8G8B8X8_SRGB:
+ return MESA_FORMAT_XBGR8888_SRGB;
+ case PIPE_FORMAT_R8G8B8X8_UINT:
+ return MESA_FORMAT_XBGR8888_UINT;
+ case PIPE_FORMAT_R8G8B8X8_SINT:
+ return MESA_FORMAT_XBGR8888_SINT;
+ case PIPE_FORMAT_B10G10R10X2_UNORM:
+ return MESA_FORMAT_XRGB2101010_UNORM;
+ case PIPE_FORMAT_R16G16B16X16_UNORM:
+ return MESA_FORMAT_XBGR16161616_UNORM;
+ case PIPE_FORMAT_R16G16B16X16_SNORM:
+ return MESA_FORMAT_XBGR16161616_SNORM;
+ case PIPE_FORMAT_R16G16B16X16_FLOAT:
+ return MESA_FORMAT_XBGR16161616_FLOAT;
+ case PIPE_FORMAT_R16G16B16X16_UINT:
+ return MESA_FORMAT_XBGR16161616_UINT;
+ case PIPE_FORMAT_R16G16B16X16_SINT:
+ return MESA_FORMAT_XBGR16161616_SINT;
+ case PIPE_FORMAT_R32G32B32X32_FLOAT:
+ return MESA_FORMAT_XBGR32323232_FLOAT;
+ case PIPE_FORMAT_R32G32B32X32_UINT:
+ return MESA_FORMAT_XBGR32323232_UINT;
+ case PIPE_FORMAT_R32G32B32X32_SINT:
+ return MESA_FORMAT_XBGR32323232_SINT;
+
default:
assert(0);
return MESA_FORMAT_NONE;
@@ -692,26 +756,24 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
struct format_mapping
{
GLenum glFormats[18]; /**< list of GLenum formats, 0-terminated */
- enum pipe_format pipeFormats[10]; /**< list of pipe formats, 0-terminated */
+ enum pipe_format pipeFormats[13]; /**< list of pipe formats, 0-terminated */
};
#define DEFAULT_RGBA_FORMATS \
PIPE_FORMAT_B8G8R8A8_UNORM, \
+ PIPE_FORMAT_R8G8B8A8_UNORM, \
PIPE_FORMAT_A8R8G8B8_UNORM, \
PIPE_FORMAT_A8B8G8R8_UNORM, \
- PIPE_FORMAT_B5G6R5_UNORM, \
0
#define DEFAULT_RGB_FORMATS \
PIPE_FORMAT_B8G8R8X8_UNORM, \
+ PIPE_FORMAT_R8G8B8X8_UNORM, \
PIPE_FORMAT_X8R8G8B8_UNORM, \
PIPE_FORMAT_X8B8G8R8_UNORM, \
- PIPE_FORMAT_B8G8R8A8_UNORM, \
- PIPE_FORMAT_A8R8G8B8_UNORM, \
- PIPE_FORMAT_A8B8G8R8_UNORM, \
PIPE_FORMAT_B5G6R5_UNORM, \
- 0
+ DEFAULT_RGBA_FORMATS
#define DEFAULT_SRGBA_FORMATS \
PIPE_FORMAT_B8G8R8A8_SRGB, \
@@ -744,7 +806,12 @@ struct format_mapping
static const struct format_mapping format_map[] = {
/* Basic RGB, RGBA formats */
{
- { GL_RGB10, GL_RGB10_A2, 0 },
+ { GL_RGB10, 0 },
+ { PIPE_FORMAT_B10G10R10X2_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM,
+ DEFAULT_RGB_FORMATS }
+ },
+ {
+ { GL_RGB10_A2, 0 },
{ PIPE_FORMAT_B10G10R10A2_UNORM, DEFAULT_RGBA_FORMATS }
},
{
@@ -760,7 +827,12 @@ static const struct format_mapping format_map[] = {
{ DEFAULT_RGB_FORMATS }
},
{
- { GL_RGB12, GL_RGB16, GL_RGBA12, GL_RGBA16, 0 },
+ { GL_RGB12, GL_RGB16, 0 },
+ { PIPE_FORMAT_R16G16B16X16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM,
+ DEFAULT_RGB_FORMATS }
+ },
+ {
+ { GL_RGBA12, GL_RGBA16, 0 },
{ PIPE_FORMAT_R16G16B16A16_UNORM, DEFAULT_RGBA_FORMATS }
},
{
@@ -774,16 +846,21 @@ static const struct format_mapping format_map[] = {
{
{ GL_R3_G3_B2, 0 },
{ PIPE_FORMAT_B2G3R3_UNORM, PIPE_FORMAT_B5G6R5_UNORM,
- PIPE_FORMAT_B5G5R5A1_UNORM, DEFAULT_RGBA_FORMATS }
+ PIPE_FORMAT_B5G5R5A1_UNORM, DEFAULT_RGB_FORMATS }
},
{
- { GL_RGB5, GL_RGB4 },
- { PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM,
- DEFAULT_RGBA_FORMATS }
+ { GL_RGB4 },
+ { PIPE_FORMAT_B4G4R4X4_UNORM, PIPE_FORMAT_B4G4R4A4_UNORM,
+ DEFAULT_RGB_FORMATS }
+ },
+ {
+ { GL_RGB5 },
+ { PIPE_FORMAT_B5G5R5X1_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM,
+ DEFAULT_RGB_FORMATS }
},
{
{ GL_RGB565 },
- { PIPE_FORMAT_B5G6R5_UNORM, DEFAULT_RGBA_FORMATS }
+ { PIPE_FORMAT_B5G6R5_UNORM, DEFAULT_RGB_FORMATS }
},
/* basic Alpha formats */
@@ -923,12 +1000,17 @@ static const struct format_mapping format_map[] = {
/* sRGB formats */
{
- { GL_SRGB_EXT, GL_SRGB8_EXT, GL_SRGB_ALPHA_EXT, GL_SRGB8_ALPHA8_EXT, 0 },
+ { GL_SRGB_EXT, GL_SRGB8_EXT, 0 },
+ { PIPE_FORMAT_R8G8B8X8_SRGB, DEFAULT_SRGBA_FORMATS }
+ },
+ {
+ { GL_SRGB_ALPHA_EXT, GL_SRGB8_ALPHA8_EXT, 0 },
{ DEFAULT_SRGBA_FORMATS }
},
{
{ GL_COMPRESSED_SRGB_EXT, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 0 },
- { PIPE_FORMAT_DXT1_SRGB, DEFAULT_SRGBA_FORMATS }
+ { PIPE_FORMAT_DXT1_SRGB, PIPE_FORMAT_R8G8B8X8_SRGB,
+ DEFAULT_SRGBA_FORMATS }
},
{
{ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0 },
@@ -945,11 +1027,12 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_SLUMINANCE_ALPHA_EXT, GL_SLUMINANCE8_ALPHA8_EXT,
- GL_COMPRESSED_SLUMINANCE_EXT, GL_COMPRESSED_SLUMINANCE_ALPHA_EXT, 0 },
+ GL_COMPRESSED_SLUMINANCE_ALPHA_EXT, 0 },
{ PIPE_FORMAT_L8A8_SRGB, DEFAULT_SRGBA_FORMATS }
},
{
- { GL_SLUMINANCE_EXT, GL_SLUMINANCE8_EXT, 0 },
+ { GL_SLUMINANCE_EXT, GL_SLUMINANCE8_EXT, GL_COMPRESSED_SLUMINANCE_EXT,
+ 0 },
{ PIPE_FORMAT_L8_SRGB, DEFAULT_SRGBA_FORMATS }
},
@@ -960,7 +1043,8 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_RGB16F_ARB, 0 },
- { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R16G16B16A16_FLOAT,
+ { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R16G16B16X16_FLOAT,
+ PIPE_FORMAT_R16G16B16A16_FLOAT,
PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, 0 }
},
{
@@ -1005,8 +1089,8 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_RGB32F_ARB, 0 },
- { PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT,
- PIPE_FORMAT_R16G16B16A16_FLOAT, 0 }
+ { PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32X32_FLOAT,
+ PIPE_FORMAT_R32G32B32A32_FLOAT, PIPE_FORMAT_R16G16B16A16_FLOAT, 0 }
},
{
{ GL_LUMINANCE_ALPHA32F_ARB, 0 },
@@ -1106,10 +1190,7 @@ static const struct format_mapping format_map[] = {
/* signed/unsigned integer formats.
*/
{
- { GL_RED_INTEGER_EXT,
- GL_GREEN_INTEGER_EXT,
- GL_BLUE_INTEGER_EXT,
- GL_RGBA_INTEGER_EXT,
+ { GL_RGBA_INTEGER_EXT,
GL_BGRA_INTEGER_EXT,
GL_RGBA8I_EXT, 0 },
{ PIPE_FORMAT_R8G8B8A8_SINT, 0 }
@@ -1117,8 +1198,9 @@ static const struct format_mapping format_map[] = {
{
{ GL_RGB_INTEGER_EXT,
GL_BGR_INTEGER_EXT,
- GL_RGB8I_EXT, 0 },
- { PIPE_FORMAT_R8G8B8_SINT,
+ GL_RGB8I_EXT,
+ GL_BLUE_INTEGER_EXT, 0 },
+ { PIPE_FORMAT_R8G8B8_SINT, PIPE_FORMAT_R8G8B8X8_SINT,
PIPE_FORMAT_R8G8B8A8_SINT, 0 }
},
{
@@ -1222,7 +1304,7 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_RGB16I_EXT, 0 },
- { PIPE_FORMAT_R16G16B16_SINT,
+ { PIPE_FORMAT_R16G16B16_SINT, PIPE_FORMAT_R16G16B16X16_SINT,
PIPE_FORMAT_R16G16B16A16_SINT, 0 },
},
{
@@ -1231,7 +1313,7 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_RGB32I_EXT, 0 },
- { PIPE_FORMAT_R32G32B32_SINT,
+ { PIPE_FORMAT_R32G32B32_SINT, PIPE_FORMAT_R32G32B32X32_SINT,
PIPE_FORMAT_R32G32B32A32_SINT, 0 },
},
{
@@ -1244,12 +1326,12 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_RGB8UI_EXT, 0 },
- { PIPE_FORMAT_R8G8B8_UINT,
+ { PIPE_FORMAT_R8G8B8_UINT, PIPE_FORMAT_R8G8B8X8_UINT,
PIPE_FORMAT_R8G8B8A8_UINT, 0 }
},
{
{ GL_RGB16UI_EXT, 0 },
- { PIPE_FORMAT_R16G16B16_UINT,
+ { PIPE_FORMAT_R16G16B16_UINT, PIPE_FORMAT_R16G16B16X16_UINT,
PIPE_FORMAT_R16G16B16A16_UINT, 0 }
},
{
@@ -1258,7 +1340,7 @@ static const struct format_mapping format_map[] = {
},
{
{ GL_RGB32UI_EXT, 0},
- { PIPE_FORMAT_R32G32B32_UINT,
+ { PIPE_FORMAT_R32G32B32_UINT, PIPE_FORMAT_R32G32B32X32_UINT,
PIPE_FORMAT_R32G32B32A32_UINT, 0 }
},
{
@@ -1266,7 +1348,7 @@ static const struct format_mapping format_map[] = {
{ PIPE_FORMAT_R32G32B32A32_UINT, 0 }
},
{
- { GL_R8I, 0},
+ { GL_R8I, GL_RED_INTEGER_EXT, 0},
{ PIPE_FORMAT_R8_SINT, 0},
},
{
@@ -1290,7 +1372,7 @@ static const struct format_mapping format_map[] = {
{ PIPE_FORMAT_R32_UINT, 0},
},
{
- { GL_RG8I, 0},
+ { GL_RG8I, GL_GREEN_INTEGER_EXT, 0},
{ PIPE_FORMAT_R8G8_SINT, 0},
},
{
@@ -1338,11 +1420,20 @@ static const struct format_mapping format_map[] = {
PIPE_FORMAT_R8G8_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
},
{
- { GL_RGB_SNORM, GL_RGB8_SNORM, GL_RGBA_SNORM, GL_RGBA8_SNORM, 0 },
+ { GL_RGB_SNORM, GL_RGB8_SNORM, 0 },
+ { PIPE_FORMAT_R8G8B8X8_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
+ },
+ {
+ { GL_RGBA_SNORM, GL_RGBA8_SNORM, 0 },
{ PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
},
{
- { GL_RGB16_SNORM, GL_RGBA16_SNORM, 0 },
+ { GL_RGB16_SNORM, 0 },
+ { PIPE_FORMAT_R16G16B16X16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM,
+ PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
+ },
+ {
+ { GL_RGBA16_SNORM, 0 },
{ PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
},
{
@@ -1449,14 +1540,12 @@ static const struct exact_format_mapping rgbx8888_tbl[] =
{ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8R8G8B8_UNORM },
{ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_B8G8R8X8_UNORM },
{ GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8X8_UNORM },
- /* No Mesa formats for these Gallium formats:
{ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8B8G8R8_UNORM },
{ GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_X8B8G8R8_UNORM },
{ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_R8G8B8X8_UNORM },
{ GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_R8G8B8X8_UNORM },
{ GL_RGBA, GL_UNSIGNED_BYTE, PIPE_FORMAT_R8G8B8X8_UNORM },
{ GL_ABGR_EXT, GL_UNSIGNED_BYTE, PIPE_FORMAT_X8B8G8R8_UNORM },
- */
{ 0, 0, 0 }
};
@@ -1527,17 +1616,17 @@ find_exact_format(GLint internalFormat, GLenum format, GLenum type)
* when we're getting called from gl[Copy]TexImage().
*/
enum pipe_format
-st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
+st_choose_format(struct st_context *st, GLenum internalFormat,
GLenum format, GLenum type,
enum pipe_texture_target target, unsigned sample_count,
unsigned bindings, boolean allow_dxt)
{
- GET_CURRENT_CONTEXT(ctx); /* XXX this should be a function parameter */
+ struct pipe_screen *screen = st->pipe->screen;
int i, j;
enum pipe_format pf;
/* can't render to compressed formats at this time */
- if (_mesa_is_compressed_format(ctx, internalFormat)
+ if (_mesa_is_compressed_format(st->ctx, internalFormat)
&& (bindings & ~PIPE_BIND_SAMPLER_VIEW)) {
return PIPE_FORMAT_NONE;
}
@@ -1573,7 +1662,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
* Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
*/
enum pipe_format
-st_choose_renderbuffer_format(struct pipe_screen *screen,
+st_choose_renderbuffer_format(struct st_context *st,
GLenum internalFormat, unsigned sample_count)
{
uint usage;
@@ -1581,7 +1670,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
usage = PIPE_BIND_DEPTH_STENCIL;
else
usage = PIPE_BIND_RENDER_TARGET;
- return st_choose_format(screen, internalFormat, GL_NONE, GL_NONE,
+ return st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
PIPE_TEXTURE_2D, sample_count, usage, FALSE);
}
@@ -1599,7 +1688,7 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
internalFormat == GL_RGB || internalFormat == GL_RGBA ||
internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
internalFormat == GL_BGRA;
- struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+ struct st_context *st = st_context(ctx);
enum pipe_format pFormat;
unsigned bindings;
@@ -1623,12 +1712,12 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
bindings |= PIPE_BIND_RENDER_TARGET;
}
- pFormat = st_choose_format(screen, internalFormat, format, type,
+ pFormat = st_choose_format(st, internalFormat, format, type,
PIPE_TEXTURE_2D, 0, bindings, ctx->Mesa_DXTn);
if (pFormat == PIPE_FORMAT_NONE) {
/* try choosing format again, this time without render target bindings */
- pFormat = st_choose_format(screen, internalFormat, format, type,
+ pFormat = st_choose_format(st, internalFormat, format, type,
PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
ctx->Mesa_DXTn);
}
@@ -1649,7 +1738,7 @@ size_t
st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
int samples[16])
{
- struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+ struct st_context *st = st_context(ctx);
enum pipe_format format;
unsigned i, bind, num_sample_counts = 0;
@@ -1660,7 +1749,7 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
/* Set sample counts in descending order. */
for (i = 16; i > 1; i--) {
- format = st_choose_format(screen, internalFormat, GL_NONE, GL_NONE,
+ format = st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
PIPE_TEXTURE_2D, i, bind, FALSE);
if (format != PIPE_FORMAT_NONE) {
diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h
index 50588d8d4..aee624d24 100644
--- a/mesalib/src/mesa/state_tracker/st_format.h
+++ b/mesalib/src/mesa/state_tracker/st_format.h
@@ -48,13 +48,13 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
extern enum pipe_format
-st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
+st_choose_format(struct st_context *st, GLenum internalFormat,
GLenum format, GLenum type,
enum pipe_texture_target target, unsigned sample_count,
unsigned bindings, boolean allow_dxt);
extern enum pipe_format
-st_choose_renderbuffer_format(struct pipe_screen *screen,
+st_choose_renderbuffer_format(struct st_context *st,
GLenum internalFormat, unsigned sample_count);
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 b3da2016d..63b74285a 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1287,11 +1287,12 @@ glsl_to_tgsi_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operan
bool
glsl_to_tgsi_visitor::try_emit_sat(ir_expression *ir)
{
- /* Saturates were only introduced to vertex programs in
- * NV_vertex_program3, so don't give them to drivers in the VP.
+ /* Emit saturates in the vertex shader only if SM 3.0 is supported.
*/
- if (this->prog->Target == GL_VERTEX_PROGRAM_ARB)
+ if (this->prog->Target == GL_VERTEX_PROGRAM_ARB &&
+ !st_context(this->ctx)->has_shader_model3) {
return false;
+ }
ir_rvalue *sat_src = ir->as_rvalue_to_saturate();
if (!sat_src)
@@ -2931,32 +2932,12 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)
void
glsl_to_tgsi_visitor::visit(ir_if *ir)
{
- glsl_to_tgsi_instruction *cond_inst, *if_inst;
- glsl_to_tgsi_instruction *prev_inst;
-
- prev_inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
+ glsl_to_tgsi_instruction *if_inst;
ir->condition->accept(this);
assert(this->result.file != PROGRAM_UNDEFINED);
- if (this->options->EmitCondCodes) {
- cond_inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
-
- /* See if we actually generated any instruction for generating
- * the condition. If not, then cook up a move to a temp so we
- * have something to set cond_update on.
- */
- if (cond_inst == prev_inst) {
- st_src_reg temp = get_temp(glsl_type::bool_type);
- cond_inst = emit(ir->condition, TGSI_OPCODE_MOV, st_dst_reg(temp), result);
- }
- cond_inst->cond_update = GL_TRUE;
-
- if_inst = emit(ir->condition, TGSI_OPCODE_IF);
- if_inst->dst.cond_mask = COND_NE;
- } else {
- if_inst = emit(ir->condition, TGSI_OPCODE_IF, undef_dst, this->result);
- }
+ if_inst = emit(ir->condition, TGSI_OPCODE_IF, undef_dst, this->result);
this->instructions.push_tail(if_inst);
@@ -5175,21 +5156,52 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)];
- do {
- unsigned what_to_lower = MOD_TO_FRACT | DIV_TO_MUL_RCP |
- EXP_TO_EXP2 | LOG_TO_LOG2;
- if (options->EmitNoPow)
- what_to_lower |= POW_TO_EXP2;
- if (!ctx->Const.NativeIntegers)
- what_to_lower |= INT_DIV_TO_MUL_RCP;
+ /* If there are forms of indirect addressing that the driver
+ * cannot handle, perform the lowering pass.
+ */
+ if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput ||
+ options->EmitNoIndirectTemp || options->EmitNoIndirectUniform) {
+ lower_variable_index_to_cond_assign(ir,
+ options->EmitNoIndirectInput,
+ options->EmitNoIndirectOutput,
+ options->EmitNoIndirectTemp,
+ options->EmitNoIndirectUniform);
+ }
- progress = false;
+ if (ctx->Extensions.ARB_shading_language_packing) {
+ unsigned lower_inst = LOWER_PACK_SNORM_2x16 |
+ LOWER_UNPACK_SNORM_2x16 |
+ LOWER_PACK_UNORM_2x16 |
+ LOWER_UNPACK_UNORM_2x16 |
+ LOWER_PACK_SNORM_4x8 |
+ LOWER_UNPACK_SNORM_4x8 |
+ LOWER_UNPACK_UNORM_4x8 |
+ LOWER_PACK_UNORM_4x8 |
+ LOWER_PACK_HALF_2x16 |
+ LOWER_UNPACK_HALF_2x16;
+
+ lower_packing_builtins(ir, lower_inst);
+ }
- /* Lowering */
- do_mat_op_to_vec(ir);
- lower_instructions(ir, what_to_lower);
+ do_mat_op_to_vec(ir);
+ lower_instructions(ir,
+ MOD_TO_FRACT |
+ DIV_TO_MUL_RCP |
+ EXP_TO_EXP2 |
+ LOG_TO_LOG2 |
+ (options->EmitNoPow ? POW_TO_EXP2 : 0) |
+ (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0));
+
+ lower_ubo_reference(prog->_LinkedShaders[i], ir);
+ do_vec_index_to_cond_assign(ir);
+ lower_quadop_vector(ir, false);
+ lower_noise(ir);
+ if (options->MaxIfDepth == 0) {
+ lower_discard(ir);
+ }
- lower_ubo_reference(prog->_LinkedShaders[i], ir);
+ do {
+ progress = false;
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
@@ -5197,31 +5209,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
options->MaxUnrollIterations)
|| progress;
- progress = lower_quadop_vector(ir, false) || progress;
-
- if (options->MaxIfDepth == 0)
- progress = lower_discard(ir) || progress;
-
progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
- if (options->EmitNoNoise)
- progress = lower_noise(ir) || progress;
-
- /* If there are forms of indirect addressing that the driver
- * cannot handle, perform the lowering pass.
- */
- if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput
- || options->EmitNoIndirectTemp || options->EmitNoIndirectUniform)
- progress =
- lower_variable_index_to_cond_assign(ir,
- options->EmitNoIndirectInput,
- options->EmitNoIndirectOutput,
- options->EmitNoIndirectTemp,
- options->EmitNoIndirectUniform)
- || progress;
-
- progress = do_vec_index_to_cond_assign(ir) || progress;
-
} while (progress);
validate_ir_tree(ir);
diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c
index 584eaa981..ed3709848 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_texture.c
@@ -391,13 +391,12 @@ struct pipe_resource *
st_create_color_map_texture(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
- struct pipe_context *pipe = st->pipe;
struct pipe_resource *pt;
enum pipe_format format;
const uint texSize = 256; /* simple, and usually perfect */
/* find an RGBA texture format */
- format = st_choose_format(pipe->screen, GL_RGBA, GL_NONE, GL_NONE,
+ format = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE,
PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
FALSE);