*/
+#include "main/context.h"
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/samplerobj.h"
else
return SWIZZLE_XYZW;
case GL_STENCIL_INDEX:
- return SWIZZLE_XYZW;
case GL_DEPTH_STENCIL:
- /* fall-through */
case GL_DEPTH_COMPONENT:
/* Now examine the depth mode */
switch (depthMode) {
static unsigned
-get_texture_format_swizzle(const struct st_texture_object *stObj,
+get_texture_format_swizzle(const struct st_context *st,
+ const struct st_texture_object *stObj,
unsigned glsl_version)
{
GLenum baseFormat = _mesa_texture_base_format(&stObj->base);
unsigned tex_swizzle;
if (baseFormat != GL_NONE) {
+ GLenum depth_mode = stObj->base.DepthMode;
+ /* In ES 3.0, DEPTH_TEXTURE_MODE is expected to be GL_RED for textures
+ * with depth component data specified with a sized internal format.
+ */
+ if (_mesa_is_gles3(st->ctx) &&
+ util_format_is_depth_or_stencil(stObj->pt->format)) {
+ const struct st_texture_image *firstImage =
+ st_texture_image_const(_mesa_base_tex_image(&stObj->base));
+ if (firstImage->base.InternalFormat != GL_DEPTH_COMPONENT &&
+ firstImage->base.InternalFormat != GL_DEPTH_STENCIL &&
+ firstImage->base.InternalFormat != GL_STENCIL_INDEX)
+ depth_mode = GL_RED;
+ }
tex_swizzle = compute_texture_format_swizzle(baseFormat,
- stObj->base.DepthMode,
+ depth_mode,
stObj->pt->format,
glsl_version);
}
* \param stObj the st texture object,
*/
static boolean
-check_sampler_swizzle(const struct st_texture_object *stObj,
+check_sampler_swizzle(const struct st_context *st,
+ const struct st_texture_object *stObj,
struct pipe_sampler_view *sv, unsigned glsl_version)
{
- unsigned swizzle = get_texture_format_swizzle(stObj, glsl_version);
+ unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
(sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
}
static struct pipe_sampler_view *
-st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
+st_create_texture_sampler_view_from_stobj(struct st_context *st,
struct st_texture_object *stObj,
enum pipe_format format,
unsigned glsl_version)
{
struct pipe_sampler_view templ;
- unsigned swizzle = get_texture_format_swizzle(stObj, glsl_version);
+ unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
u_sampler_view_default_template(&templ,
stObj->pt,
return NULL;
size = MIN2(stObj->pt->width0 - base, (unsigned)stObj->base.BufferSize);
- f = ((base * 8) / desc->block.bits) * desc->block.width;
- n = ((size * 8) / desc->block.bits) * desc->block.width;
+ f = (base / (desc->block.bits / 8)) * desc->block.width;
+ n = (size / (desc->block.bits / 8)) * desc->block.width;
if (!n)
return NULL;
templ.u.buf.first_element = f;
templ.swizzle_a = GET_SWZ(swizzle, 3);
}
- return pipe->create_sampler_view(pipe, stObj->pt, &templ);
+ return st->pipe->create_sampler_view(st->pipe, stObj->pt, &templ);
}
/* if sampler view has changed dereference it */
if (*sv) {
- if (check_sampler_swizzle(stObj, *sv, glsl_version) ||
+ if (check_sampler_swizzle(st, stObj, *sv, glsl_version) ||
(format != (*sv)->format) ||
gl_target_to_pipe(stObj->base.Target) != (*sv)->target ||
stObj->base.MinLevel + stObj->base.BaseLevel != (*sv)->u.tex.first_level ||
}
if (!*sv) {
- *sv = st_create_texture_sampler_view_from_stobj(st->pipe, stObj,
+ *sv = st_create_texture_sampler_view_from_stobj(st, stObj,
format, glsl_version);
} else if ((*sv)->context != st->pipe) {
}
+static void
+update_compute_textures(struct st_context *st)
+{
+ const struct gl_context *ctx = st->ctx;
+
+ if (ctx->ComputeProgram._Current) {
+ update_textures(st,
+ MESA_SHADER_COMPUTE,
+ &ctx->ComputeProgram._Current->Base,
+ ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
+ st->state.sampler_views[PIPE_SHADER_COMPUTE],
+ &st->state.num_sampler_views[PIPE_SHADER_COMPUTE]);
+ }
+}
+
+
const struct st_tracked_state st_update_fragment_texture = {
"st_update_texture", /* name */
{ /* dirty */
},
update_tesseval_textures /* update */
};
+
+
+const struct st_tracked_state st_update_compute_texture = {
+ "st_update_compute_texture", /* name */
+ { /* dirty */
+ _NEW_TEXTURE, /* mesa */
+ ST_NEW_COMPUTE_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
+ },
+ update_compute_textures /* update */
+};