summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c4
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c8
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c2
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c30
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c6
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c6
-rw-r--r--src/mesa/state_tracker/st_cb_drawtex.c4
-rw-r--r--src/mesa/state_tracker/st_cb_program.c12
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c4
-rw-r--r--src/mesa/state_tracker/st_context.c4
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_debug.c2
-rw-r--r--src/mesa/state_tracker/st_draw.c2
-rw-r--r--src/mesa/state_tracker/st_format.c33
-rw-r--r--src/mesa/state_tracker/st_format.h4
-rw-r--r--src/mesa/state_tracker/st_manager.c6
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c4
-rw-r--r--src/mesa/state_tracker/st_program.c4
-rw-r--r--src/mesa/state_tracker/st_program.h2
20 files changed, 94 insertions, 47 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 28439103b2..38fadb2016 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -32,8 +32,8 @@
*/
#include "main/imports.h"
-#include "shader/prog_parameter.h"
-#include "shader/prog_print.h"
+#include "program/prog_parameter.h"
+#include "program/prog_print.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index b8644faaf8..b88c74fa03 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -36,10 +36,10 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
-#include "shader/program.h"
-#include "shader/prog_instruction.h"
-#include "shader/prog_parameter.h"
-#include "shader/prog_print.h"
+#include "program/program.h"
+#include "program/prog_instruction.h"
+#include "program/prog_parameter.h"
+#include "program/prog_print.h"
#include "st_context.h"
#include "st_format.h"
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index ad151edf3b..dcaad83a3c 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -37,7 +37,7 @@
#include "main/imports.h"
#include "main/mtypes.h"
-#include "shader/program.h"
+#include "program/program.h"
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 65b57f1591..5a650b305d 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -33,11 +33,12 @@
#include "main/macros.h"
-#include "shader/prog_instruction.h"
+#include "program/prog_instruction.h"
#include "st_context.h"
#include "st_atom.h"
#include "st_texture.h"
+#include "st_format.h"
#include "st_cb_texture.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
@@ -56,14 +57,15 @@ static boolean check_sampler_swizzle(struct pipe_sampler_view *sv,
static INLINE struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
- struct st_texture_object *stObj)
+ struct st_texture_object *stObj,
+ enum pipe_format format)
{
struct pipe_sampler_view templ;
u_sampler_view_default_template(&templ,
stObj->pt,
- stObj->pt->format);
+ format);
if (stObj->base._Swizzle != SWIZZLE_NOOP) {
templ.swizzle_r = GET_SWZ(stObj->base._Swizzle, 0);
@@ -78,7 +80,8 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
static INLINE struct pipe_sampler_view *
st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
- struct pipe_context *pipe)
+ struct pipe_context *pipe,
+ enum pipe_format format)
{
if (!stObj || !stObj->pt) {
@@ -86,7 +89,7 @@ st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
}
if (!stObj->sampler_view) {
- stObj->sampler_view = st_create_texture_sampler_view_from_stobj(pipe, stObj);
+ stObj->sampler_view = st_create_texture_sampler_view_from_stobj(pipe, stObj, format);
}
return stObj->sampler_view;
@@ -107,7 +110,7 @@ update_textures(struct st_context *st)
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_view *sampler_view = NULL;
-
+ enum pipe_format st_view_format;
if (samplersUsed & (1 << su)) {
struct gl_texture_object *texObj;
struct st_texture_object *stObj;
@@ -132,14 +135,25 @@ update_textures(struct st_context *st)
continue;
}
+ st_view_format = stObj->pt->format;
+ {
+ struct st_texture_image *firstImage;
+ enum pipe_format firstImageFormat;
+ firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
+
+ firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
+ if (firstImageFormat != stObj->pt->format)
+ st_view_format = firstImageFormat;
+
+ }
st->state.num_textures = su + 1;
/* if sampler view has changed dereference it */
if (stObj->sampler_view)
- if (check_sampler_swizzle(stObj->sampler_view, stObj->base._Swizzle))
+ if (check_sampler_swizzle(stObj->sampler_view, stObj->base._Swizzle) || (st_view_format != stObj->sampler_view->format))
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
- sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe);
+ sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe, st_view_format);
}
pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 5aca1105ee..ba600ccef6 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -34,8 +34,8 @@
#include "main/image.h"
#include "main/bufferobj.h"
#include "main/macros.h"
-#include "shader/program.h"
-#include "shader/prog_print.h"
+#include "program/program.h"
+#include "program/prog_print.h"
#include "st_context.h"
#include "st_atom.h"
@@ -49,7 +49,7 @@
#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
-#include "shader/prog_instruction.h"
+#include "program/prog_instruction.h"
#include "cso_cache/cso_context.h"
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index b15792504a..ea2414c4a0 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -36,7 +36,7 @@
#include "main/glheader.h"
#include "main/formats.h"
#include "main/macros.h"
-#include "shader/prog_instruction.h"
+#include "program/prog_instruction.h"
#include "st_context.h"
#include "st_atom.h"
#include "st_cb_accum.h"
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index f74d8cd42d..69a3dd45e8 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -36,8 +36,8 @@
#include "main/macros.h"
#include "main/texformat.h"
#include "main/texstore.h"
-#include "shader/program.h"
-#include "shader/prog_print.h"
+#include "program/program.h"
+#include "program/prog_print.h"
#include "st_debug.h"
#include "st_context.h"
@@ -58,7 +58,7 @@
#include "util/u_draw_quad.h"
#include "util/u_format.h"
#include "util/u_math.h"
-#include "shader/prog_instruction.h"
+#include "program/prog_instruction.h"
#include "cso_cache/cso_context.h"
diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c
index 3d99d6c8a1..b191a7f890 100644
--- a/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/state_tracker/st_cb_drawtex.c
@@ -16,8 +16,8 @@
#include "main/image.h"
#include "main/bufferobj.h"
#include "main/macros.h"
-#include "shader/program.h"
-#include "shader/prog_print.h"
+#include "program/program.h"
+#include "program/prog_print.h"
#include "st_context.h"
#include "st_atom.h"
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 2361b2eddf..c8e4b9d56d 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -33,10 +33,9 @@
#include "main/glheader.h"
#include "main/macros.h"
#include "main/enums.h"
-#include "shader/prog_instruction.h"
-#include "shader/prog_parameter.h"
-#include "shader/program.h"
-#include "shader/shader_api.h"
+#include "main/shaderapi.h"
+#include "program/prog_instruction.h"
+#include "program/program.h"
#include "cso_cache/cso_context.h"
#include "draw/draw_context.h"
@@ -75,15 +74,12 @@ static void st_bind_program( GLcontext *ctx,
* Called via ctx->Driver.UseProgram() to bind a linked GLSL program
* (vertex shader + fragment shader).
*/
-static void st_use_program( GLcontext *ctx,
- GLuint program )
+static void st_use_program( GLcontext *ctx, struct gl_shader_program *shProg)
{
struct st_context *st = st_context(ctx);
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
-
- _mesa_use_program(ctx, program);
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 647898ef7c..8f7ebeed97 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1242,8 +1242,6 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
assert(xoffset % util_format_get_blockwidth(pformat) == 0);
assert(yoffset % util_format_get_blockheight(pformat) == 0);
- assert(width % util_format_get_blockwidth(pformat) == 0);
- assert(height % util_format_get_blockheight(pformat) == 0);
for (y = 0; y < height; y += util_format_get_blockheight(pformat)) {
/* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */
@@ -1850,7 +1848,7 @@ st_finalize_texture(GLcontext *ctx,
*/
if (stObj->pt) {
if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
- stObj->pt->format != firstImageFormat ||
+ !st_sampler_compat_formats(stObj->pt->format, firstImageFormat) ||
stObj->pt->last_level < stObj->lastLevel ||
stObj->pt->width0 != stObj->width0 ||
stObj->pt->height0 != stObj->height0 ||
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 0bf030e987..4b809b6114 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -27,8 +27,8 @@
#include "main/imports.h"
#include "main/context.h"
+#include "main/shaderobj.h"
#include "vbo/vbo.h"
-#include "shader/shader_api.h"
#include "glapi/glapi.h"
#include "st_context.h"
#include "st_debug.h"
@@ -254,7 +254,7 @@ void st_destroy_context( struct st_context *st )
void st_init_driver_functions(struct dd_function_table *functions)
{
- _mesa_init_glsl_driver_functions(functions);
+ _mesa_init_shader_object_functions(functions);
st_init_accum_functions(functions);
st_init_blit_functions(functions);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index efff55a905..4edfb2ae85 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -29,7 +29,7 @@
#define ST_CONTEXT_H
#include "main/mtypes.h"
-#include "shader/prog_cache.h"
+#include "program/prog_cache.h"
#include "pipe/p_state.h"
#include "state_tracker/st_api.h"
diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c
index 0b3768341e..ebf6ec6e7e 100644
--- a/src/mesa/state_tracker/st_debug.c
+++ b/src/mesa/state_tracker/st_debug.c
@@ -27,7 +27,7 @@
#include "main/context.h"
-#include "shader/prog_print.h"
+#include "program/prog_print.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index eb2e5b2bbf..eed8e2aa5d 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -43,7 +43,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
-#include "shader/prog_uniform.h"
+#include "program/prog_uniform.h"
#include "vbo/vbo.h"
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index f7b10ea243..c9fa7a62e1 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -767,3 +767,36 @@ st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type)
return GL_FALSE;
}
}
+
+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;
+}
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 3288225d5d..29768f296d 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -62,5 +62,9 @@ st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
extern GLboolean
st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type);
+/* 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);
#endif /* ST_FORMAT_H */
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 8c3dfb3f71..ccfb1f4a52 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -550,12 +550,14 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
* To avoid that, internal_format is (wrongly) ignored here. A sane fix
* is to use a sampler view.
*/
- if (util_format_get_component_bits(tex->format,
+ 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)
internalFormat = GL_RGBA;
else
internalFormat = GL_RGB;
-
_mesa_init_teximage_fields(ctx, target, texImage,
tex->width0, tex->height0, 1, 0, internalFormat);
texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 35016d80e6..49b7b5d1c1 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -38,8 +38,8 @@
#include "tgsi/tgsi_ureg.h"
#include "st_mesa_to_tgsi.h"
#include "st_context.h"
-#include "shader/prog_instruction.h"
-#include "shader/prog_parameter.h"
+#include "program/prog_instruction.h"
+#include "program/prog_parameter.h"
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 3c865028a7..3ea325bb42 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -33,8 +33,8 @@
#include "main/imports.h"
#include "main/mtypes.h"
-#include "shader/prog_print.h"
-#include "shader/programopt.h"
+#include "program/prog_print.h"
+#include "program/programopt.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 1b3f75ca27..d4b7151e92 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -35,7 +35,7 @@
#define ST_PROGRAM_H
#include "main/mtypes.h"
-#include "shader/program.h"
+#include "program/program.h"
#include "pipe/p_shader_tokens.h"