summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/meta.c46
-rw-r--r--src/mesa/drivers/common/meta.h10
-rw-r--r--src/mesa/drivers/common/meta_blit.c53
-rw-r--r--src/mesa/drivers/common/meta_generate_mipmap.c53
-rw-r--r--src/mesa/drivers/dri/i965/brw_binding_tables.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_device_info.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c4
-rw-r--r--src/mesa/main/fbobject.c25
-rw-r--r--src/mesa/main/imports.h7
-rw-r--r--src/mesa/main/mtypes.h61
-rw-r--r--src/mesa/main/samplerobj.c65
-rw-r--r--src/mesa/main/samplerobj.h17
-rw-r--r--src/mesa/main/shader_query.cpp38
-rw-r--r--src/mesa/main/stencil.c18
-rw-r--r--src/mesa/main/uniform_query.cpp2
-rw-r--r--src/mesa/math/m_matrix.c2
16 files changed, 286 insertions, 127 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 36bed77..1ed0e4d 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2986,8 +2986,7 @@ meta_decompress_cleanup(struct gl_context *ctx,
_mesa_reference_buffer_object(ctx, &decompress->buf_obj, NULL);
}
- if (decompress->Sampler != 0)
- _mesa_DeleteSamplers(1, &decompress->Sampler);
+ _mesa_reference_sampler_object(ctx, &decompress->samp_obj, NULL);
memset(decompress, 0, sizeof(*decompress));
}
@@ -3017,7 +3016,7 @@ decompress_texture_image(struct gl_context *ctx,
GLenum rbFormat;
GLenum faceTarget;
struct vertex verts[4];
- GLuint samplerSave;
+ struct gl_sampler_object *samp_obj_save = NULL;
GLenum status;
const bool use_glsl_version = ctx->Extensions.ARB_vertex_shader &&
ctx->Extensions.ARB_fragment_shader;
@@ -3067,8 +3066,8 @@ decompress_texture_image(struct gl_context *ctx,
_mesa_meta_begin(ctx, MESA_META_ALL & ~(MESA_META_PIXEL_STORE |
MESA_META_DRAW_BUFFERS));
- samplerSave = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
- ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
+ _mesa_reference_sampler_object(ctx, &samp_obj_save,
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler);
/* Create/bind FBO/renderbuffer */
if (decompress_fbo->FBO == 0) {
@@ -3113,22 +3112,32 @@ decompress_texture_image(struct gl_context *ctx,
&decompress->buf_obj, 3);
}
- if (!decompress->Sampler) {
- _mesa_GenSamplers(1, &decompress->Sampler);
- _mesa_BindSampler(ctx->Texture.CurrentUnit, decompress->Sampler);
- /* nearest filtering */
- _mesa_SamplerParameteri(decompress->Sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- _mesa_SamplerParameteri(decompress->Sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- /* No sRGB decode or encode.*/
- if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_SamplerParameteri(decompress->Sampler, GL_TEXTURE_SRGB_DECODE_EXT,
- GL_SKIP_DECODE_EXT);
+ if (decompress->samp_obj == NULL) {
+ decompress->samp_obj = ctx->Driver.NewSamplerObject(ctx, 0xDEADBEEF);
+ if (decompress->samp_obj == NULL) {
+ _mesa_meta_end(ctx);
+
+ /* This is a bit lazy. Flag out of memory, and then don't bother to
+ * clean up. Once out of memory is flagged, the only realistic next
+ * move is to destroy the context. That will trigger all the right
+ * clean up.
+ *
+ * Returning true prevents other GetTexImage methods from attempting
+ * anything since they will likely fail too.
+ */
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ return true;
}
- } else {
- _mesa_BindSampler(ctx->Texture.CurrentUnit, decompress->Sampler);
+ /* nearest filtering */
+ _mesa_set_sampler_filters(ctx, decompress->samp_obj, GL_NEAREST, GL_NEAREST);
+
+ /* We don't want to encode or decode sRGB values; treat them as linear. */
+ _mesa_set_sampler_srgb_decode(ctx, decompress->samp_obj, GL_SKIP_DECODE_EXT);
}
+ _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, decompress->samp_obj);
+
/* Silence valgrind warnings about reading uninitialized stack. */
memset(verts, 0, sizeof(verts));
@@ -3218,7 +3227,8 @@ decompress_texture_image(struct gl_context *ctx,
if (!use_glsl_version)
_mesa_set_enable(ctx, target, GL_FALSE);
- _mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
+ _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, samp_obj_save);
+ _mesa_reference_sampler_object(ctx, &samp_obj_save, NULL);
_mesa_meta_end(ctx);
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 5b04755..d7d8fd3 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -309,7 +309,9 @@ struct blit_state
struct fb_tex_blit_state
{
GLint baseLevelSave, maxLevelSave;
- GLuint sampler, samplerSave, stencilSamplingSave;
+ struct gl_sampler_object *samp_obj;
+ struct gl_sampler_object *samp_obj_save;
+ GLuint stencilSamplingSave;
GLuint tempTex;
};
@@ -367,7 +369,7 @@ struct gen_mipmap_state
GLuint VAO;
struct gl_buffer_object *buf_obj;
GLuint FBO;
- GLuint Sampler;
+ struct gl_sampler_object *samp_obj;
struct blit_shader_table shaders;
};
@@ -390,7 +392,7 @@ struct decompress_state
GLuint VAO;
struct decompress_fbo_state byteFBO, floatFBO;
struct gl_buffer_object *buf_obj;
- GLuint Sampler;
+ struct gl_sampler_object *samp_obj;
struct blit_shader_table shaders;
};
@@ -465,7 +467,7 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
struct gl_texture_object **texObj,
GLenum *target);
-GLuint
+struct gl_sampler_object *
_mesa_meta_setup_sampler(struct gl_context *ctx,
const struct gl_texture_object *texObj,
GLenum target, GLenum filter, GLuint srcLevel);
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 4dbf0a7..78434cf 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -703,8 +703,8 @@ blitframebuffer_texture(struct gl_context *ctx,
printf(" srcTex %p dstText %p\n", texObj, drawAtt->Texture);
*/
- fb_tex_blit.sampler = _mesa_meta_setup_sampler(ctx, texObj, target, filter,
- srcLevel);
+ fb_tex_blit.samp_obj = _mesa_meta_setup_sampler(ctx, texObj, target, filter,
+ srcLevel);
/* Always do our blits with no net sRGB decode or encode.
*
@@ -725,13 +725,12 @@ blitframebuffer_texture(struct gl_context *ctx,
if (ctx->Extensions.EXT_texture_sRGB_decode) {
if (_mesa_get_format_color_encoding(rb->Format) == GL_SRGB &&
drawFb->Visual.sRGBCapable) {
- _mesa_SamplerParameteri(fb_tex_blit.sampler,
- GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT);
+ _mesa_set_sampler_srgb_decode(ctx, fb_tex_blit.samp_obj,
+ GL_DECODE_EXT);
_mesa_set_framebuffer_srgb(ctx, GL_TRUE);
} else {
- _mesa_SamplerParameteri(fb_tex_blit.sampler,
- GL_TEXTURE_SRGB_DECODE_EXT,
- GL_SKIP_DECODE_EXT);
+ _mesa_set_sampler_srgb_decode(ctx, fb_tex_blit.samp_obj,
+ GL_SKIP_DECODE_EXT);
/* set_framebuffer_srgb was set by _mesa_meta_begin(). */
}
}
@@ -811,9 +810,17 @@ void
_mesa_meta_fb_tex_blit_begin(const struct gl_context *ctx,
struct fb_tex_blit_state *blit)
{
- blit->samplerSave =
- ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
- ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
+ /* None of the existing callers preinitialize fb_tex_blit_state to zeros,
+ * and both use stack variables. If samp_obj_save is not NULL,
+ * _mesa_reference_sampler_object will try to dereference it. Leaving
+ * random garbage in samp_obj_save can only lead to crashes.
+ *
+ * Since the state isn't persistent across calls, we won't catch ref
+ * counting problems.
+ */
+ blit->samp_obj_save = NULL;
+ _mesa_reference_sampler_object(ctx, &blit->samp_obj_save,
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler);
blit->tempTex = 0;
}
@@ -839,8 +846,10 @@ _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
}
}
- _mesa_BindSampler(ctx->Texture.CurrentUnit, blit->samplerSave);
- _mesa_DeleteSamplers(1, &blit->sampler);
+ _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, blit->samp_obj_save);
+ _mesa_reference_sampler_object(ctx, &blit->samp_obj_save, NULL);
+ _mesa_reference_sampler_object(ctx, &blit->samp_obj, NULL);
+
if (blit->tempTex)
_mesa_DeleteTextures(1, &blit->tempTex);
}
@@ -884,31 +893,33 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
return true;
}
-GLuint
+struct gl_sampler_object *
_mesa_meta_setup_sampler(struct gl_context *ctx,
const struct gl_texture_object *texObj,
GLenum target, GLenum filter, GLuint srcLevel)
{
- GLuint sampler;
+ struct gl_sampler_object *samp_obj;
GLenum tex_filter = (filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
filter == GL_SCALED_RESOLVE_NICEST_EXT) ?
GL_NEAREST : filter;
- _mesa_GenSamplers(1, &sampler);
- _mesa_BindSampler(ctx->Texture.CurrentUnit, sampler);
+ samp_obj = ctx->Driver.NewSamplerObject(ctx, 0xDEADBEEF);
+ if (samp_obj == NULL)
+ return NULL;
+
+ _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, samp_obj);
+ _mesa_set_sampler_filters(ctx, samp_obj, tex_filter, tex_filter);
+ _mesa_set_sampler_wrap(ctx, samp_obj, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
+ samp_obj->WrapR);
/* Prepare src texture state */
_mesa_BindTexture(target, texObj->Name);
- _mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, tex_filter);
- _mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, tex_filter);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
}
- _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- return sampler;
+ return samp_obj;
}
/**
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index 2b942d6..f20fcac 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -137,8 +137,7 @@ _mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx,
_mesa_DeleteVertexArrays(1, &mipmap->VAO);
mipmap->VAO = 0;
_mesa_reference_buffer_object(ctx, &mipmap->buf_obj, NULL);
- _mesa_DeleteSamplers(1, &mipmap->Sampler);
- mipmap->Sampler = 0;
+ _mesa_reference_sampler_object(ctx, &mipmap->samp_obj, NULL);
if (mipmap->FBO != 0) {
_mesa_DeleteFramebuffers(1, &mipmap->FBO);
@@ -182,7 +181,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
ctx->Extensions.ARB_fragment_shader;
GLenum faceTarget;
GLuint dstLevel;
- GLuint samplerSave;
+ struct gl_sampler_object *samp_obj_save = NULL;
GLint swizzle[4];
GLboolean swizzleSaved = GL_FALSE;
@@ -213,8 +212,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
_mesa_set_enable(ctx, target, GL_TRUE);
}
- samplerSave = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
- ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
+ _mesa_reference_sampler_object(ctx, &samp_obj_save,
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler);
/* We may have been called from glGenerateTextureMipmap with CurrentUnit
* still set to 0, so we don't know when we can skip binding the texture.
@@ -223,30 +222,29 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
*/
_mesa_BindTexture(target, texObj->Name);
- if (!mipmap->Sampler) {
- _mesa_GenSamplers(1, &mipmap->Sampler);
- _mesa_BindSampler(ctx->Texture.CurrentUnit, mipmap->Sampler);
-
- _mesa_SamplerParameteri(mipmap->Sampler,
- GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_LINEAR);
- _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
-
- /* We don't want to encode or decode sRGB values; treat them as linear.
- * This is not technically correct for GLES3 but we don't get any API
- * error at the moment.
- */
- if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_SRGB_DECODE_EXT,
- GL_SKIP_DECODE_EXT);
+ if (mipmap->samp_obj == NULL) {
+ mipmap->samp_obj = ctx->Driver.NewSamplerObject(ctx, 0xDEADBEEF);
+ if (mipmap->samp_obj == NULL) {
+ /* This is a bit lazy. Flag out of memory, and then don't bother to
+ * clean up. Once out of memory is flagged, the only realistic next
+ * move is to destroy the context. That will trigger all the right
+ * clean up.
+ */
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenerateMipmap");
+ return;
}
- } else {
- _mesa_BindSampler(ctx->Texture.CurrentUnit, mipmap->Sampler);
+
+ _mesa_set_sampler_filters(ctx, mipmap->samp_obj, GL_LINEAR_MIPMAP_LINEAR,
+ GL_LINEAR);
+ _mesa_set_sampler_wrap(ctx, mipmap->samp_obj, GL_CLAMP_TO_EDGE,
+ GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
+
+ /* We don't want to encode or decode sRGB values; treat them as linear. */
+ _mesa_set_sampler_srgb_decode(ctx, mipmap->samp_obj, GL_SKIP_DECODE_EXT);
}
+ _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, mipmap->samp_obj);
+
assert(mipmap->FBO != 0);
_mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);
@@ -370,7 +368,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
_mesa_lock_texture(ctx, texObj); /* relock */
- _mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
+ _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, samp_obj_save);
+ _mesa_reference_sampler_object(ctx, &samp_obj_save, NULL);
_mesa_meta_end(ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_binding_tables.c b/src/mesa/drivers/dri/i965/brw_binding_tables.c
index 80935cf..7fa5d60 100644
--- a/src/mesa/drivers/dri/i965/brw_binding_tables.c
+++ b/src/mesa/drivers/dri/i965/brw_binding_tables.c
@@ -196,12 +196,12 @@ const struct brw_tracked_state brw_wm_binding_table = {
.emit = brw_upload_wm_binding_table,
};
-/** Upload the TCS binding table (if TCS is active). */
+/** Upload the TCS binding table (if tessellation stages are active). */
static void
brw_tcs_upload_binding_table(struct brw_context *brw)
{
- /* If there's no TCS, skip changing anything. */
- if (brw->tess_ctrl_program == NULL)
+ /* Skip if the tessellation stages are disabled. */
+ if (brw->tess_eval_program == NULL)
return;
/* BRW_NEW_TCS_PROG_DATA */
@@ -216,6 +216,7 @@ const struct brw_tracked_state brw_tcs_binding_table = {
.dirty = {
.mesa = 0,
.brw = BRW_NEW_BATCH |
+ BRW_NEW_DEFAULT_TESS_LEVELS |
BRW_NEW_SURFACES |
BRW_NEW_TCS_CONSTBUF |
BRW_NEW_TCS_PROG_DATA,
diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c b/src/mesa/drivers/dri/i965/brw_device_info.c
index 4eeca5c..e8af70c 100644
--- a/src/mesa/drivers/dri/i965/brw_device_info.c
+++ b/src/mesa/drivers/dri/i965/brw_device_info.c
@@ -420,6 +420,7 @@ static const struct brw_device_info brw_device_info_kbl_gt1 = {
.max_cs_threads = 7 * 6,
.max_wm_threads = KBL_MAX_THREADS_PER_PSD * 2,
.urb.size = 192,
+ .num_slices = 1,
};
static const struct brw_device_info brw_device_info_kbl_gt1_5 = {
@@ -428,6 +429,7 @@ static const struct brw_device_info brw_device_info_kbl_gt1_5 = {
.max_cs_threads = 7 * 6,
.max_wm_threads = KBL_MAX_THREADS_PER_PSD * 3,
+ .num_slices = 1,
};
static const struct brw_device_info brw_device_info_kbl_gt2 = {
@@ -435,6 +437,7 @@ static const struct brw_device_info brw_device_info_kbl_gt2 = {
.gt = 2,
.max_wm_threads = KBL_MAX_THREADS_PER_PSD * 3,
+ .num_slices = 1,
};
static const struct brw_device_info brw_device_info_kbl_gt3 = {
@@ -442,6 +445,7 @@ static const struct brw_device_info brw_device_info_kbl_gt3 = {
.gt = 3,
.max_wm_threads = KBL_MAX_THREADS_PER_PSD * 6,
+ .num_slices = 2,
};
static const struct brw_device_info brw_device_info_kbl_gt4 = {
@@ -460,6 +464,7 @@ static const struct brw_device_info brw_device_info_kbl_gt4 = {
* will be used."
*/
.urb.size = 1008 / 3,
+ .num_slices = 3,
};
const struct brw_device_info *
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index ed47172..c5f6c4f 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -409,8 +409,8 @@ set_read_rb_tex_image(struct gl_context *ctx, struct fb_tex_blit_state *blit,
blit->baseLevelSave = tex_obj->BaseLevel;
blit->maxLevelSave = tex_obj->MaxLevel;
blit->stencilSamplingSave = tex_obj->StencilSampling;
- blit->sampler = _mesa_meta_setup_sampler(ctx, tex_obj, *target,
- GL_NEAREST, level);
+ blit->samp_obj = _mesa_meta_setup_sampler(ctx, tex_obj, *target,
+ GL_NEAREST, level);
return true;
}
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index fe6bdc2..3be216d 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1253,23 +1253,22 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
ctx->Driver.ValidateFramebuffer(ctx, fb);
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
fbo_incomplete(ctx, "driver marked FBO as incomplete", -1);
+ return;
}
}
- if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) {
- /*
- * Note that if ARB_framebuffer_object is supported and the attached
- * renderbuffers/textures are different sizes, the framebuffer
- * width/height will be set to the smallest width/height.
- */
- if (numImages != 0) {
- fb->Width = minWidth;
- fb->Height = minHeight;
- }
-
- /* finally, update the visual info for the framebuffer */
- _mesa_update_framebuffer_visual(ctx, fb);
+ /*
+ * Note that if ARB_framebuffer_object is supported and the attached
+ * renderbuffers/textures are different sizes, the framebuffer
+ * width/height will be set to the smallest width/height.
+ */
+ if (numImages != 0) {
+ fb->Width = minWidth;
+ fb->Height = minHeight;
}
+
+ /* finally, update the visual info for the framebuffer */
+ _mesa_update_framebuffer_visual(ctx, fb);
}
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 042147f..ad7af5c 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -151,6 +151,13 @@ static inline int IROUND(float f)
return (int) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F));
}
+/**
+ * Convert double to int by rounding to nearest integer, away from zero.
+ */
+static inline int IROUNDD(double d)
+{
+ return (int) ((d >= 0.0) ? (d + 0.5) : (d - 0.5));
+}
/**
* Convert float to int64 by rounding to nearest integer.
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 39e3cfd..1c717fe 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2530,6 +2530,67 @@ struct gl_active_atomic_buffer
};
/**
+ * Data container for shader queries. This holds only the minimal
+ * amount of required information for resource queries to work.
+ */
+struct gl_shader_variable
+{
+ /**
+ * Declared type of the variable
+ */
+ const struct glsl_type *type;
+
+ /**
+ * Declared name of the variable
+ */
+ char *name;
+
+ /**
+ * Storage location of the base of this variable
+ *
+ * The precise meaning of this field depends on the nature of the variable.
+ *
+ * - Vertex shader input: one of the values from \c gl_vert_attrib.
+ * - Vertex shader output: one of the values from \c gl_varying_slot.
+ * - Geometry shader input: one of the values from \c gl_varying_slot.
+ * - Geometry shader output: one of the values from \c gl_varying_slot.
+ * - Fragment shader input: one of the values from \c gl_varying_slot.
+ * - Fragment shader output: one of the values from \c gl_frag_result.
+ * - Uniforms: Per-stage uniform slot number for default uniform block.
+ * - Uniforms: Index within the uniform block definition for UBO members.
+ * - Non-UBO Uniforms: explicit location until linking then reused to
+ * store uniform slot number.
+ * - Other: This field is not currently used.
+ *
+ * If the variable is a uniform, shader input, or shader output, and the
+ * slot has not been assigned, the value will be -1.
+ */
+ int location;
+
+ /**
+ * Output index for dual source blending.
+ *
+ * \note
+ * The GLSL spec only allows the values 0 or 1 for the index in \b dual
+ * source blending.
+ */
+ unsigned index:1;
+
+ /**
+ * Specifies whether a shader input/output is per-patch in tessellation
+ * shader stages.
+ */
+ unsigned patch:1;
+
+ /**
+ * Storage class of the variable.
+ *
+ * \sa (n)ir_variable_mode
+ */
+ unsigned mode:4;
+};
+
+/**
* Active resource in a gl_shader_program
*/
struct gl_program_resource
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 676dd36..fe15508 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -270,6 +270,17 @@ _mesa_IsSampler(GLuint sampler)
return sampObj != NULL;
}
+void
+_mesa_bind_sampler(struct gl_context *ctx, GLuint unit,
+ struct gl_sampler_object *sampObj)
+{
+ if (ctx->Texture.Unit[unit].Sampler != sampObj) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ }
+
+ _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler,
+ sampObj);
+}
void GLAPIENTRY
_mesa_BindSampler(GLuint unit, GLuint sampler)
@@ -297,13 +308,8 @@ _mesa_BindSampler(GLuint unit, GLuint sampler)
}
}
- if (ctx->Texture.Unit[unit].Sampler != sampObj) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- }
-
/* bind new sampler */
- _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler,
- sampObj);
+ _mesa_bind_sampler(ctx, unit, sampObj);
}
@@ -444,6 +450,22 @@ flush(struct gl_context *ctx)
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
}
+void
+_mesa_set_sampler_wrap(struct gl_context *ctx, struct gl_sampler_object *samp,
+ GLenum s, GLenum t, GLenum r)
+{
+ assert(validate_texture_wrap_mode(ctx, s));
+ assert(validate_texture_wrap_mode(ctx, t));
+ assert(validate_texture_wrap_mode(ctx, r));
+
+ if (samp->WrapS == s && samp->WrapT == t && samp->WrapR == r)
+ return;
+
+ flush(ctx);
+ samp->WrapS = s;
+ samp->WrapT = t;
+ samp->WrapR = r;
+}
#define INVALID_PARAM 0x100
#define INVALID_PNAME 0x101
@@ -493,6 +515,27 @@ set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp,
return INVALID_PARAM;
}
+void
+_mesa_set_sampler_filters(struct gl_context *ctx,
+ struct gl_sampler_object *samp,
+ GLenum min_filter, GLenum mag_filter)
+{
+ assert(min_filter == GL_NEAREST ||
+ min_filter == GL_LINEAR ||
+ min_filter == GL_NEAREST_MIPMAP_NEAREST ||
+ min_filter == GL_LINEAR_MIPMAP_NEAREST ||
+ min_filter == GL_NEAREST_MIPMAP_LINEAR ||
+ min_filter == GL_LINEAR_MIPMAP_LINEAR);
+ assert(mag_filter == GL_NEAREST ||
+ mag_filter == GL_LINEAR);
+
+ if (samp->MinFilter == min_filter && samp->MagFilter == mag_filter)
+ return;
+
+ flush(ctx);
+ samp->MinFilter = min_filter;
+ samp->MagFilter = mag_filter;
+}
static GLuint
set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
@@ -713,6 +756,16 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
return GL_TRUE;
}
+void
+_mesa_set_sampler_srgb_decode(struct gl_context *ctx,
+ struct gl_sampler_object *samp, GLenum param)
+{
+ assert(param == GL_DECODE_EXT || param == GL_SKIP_DECODE_EXT);
+
+ flush(ctx);
+ samp->sRGBDecode = param;
+}
+
static GLuint
set_sampler_srgb_decode(struct gl_context *ctx,
struct gl_sampler_object *samp, GLenum param)
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 7bea911..abc6e01 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -80,6 +80,23 @@ _mesa_new_sampler_object(struct gl_context *ctx, GLuint name);
extern void
_mesa_init_sampler_object_functions(struct dd_function_table *driver);
+extern void
+_mesa_set_sampler_wrap(struct gl_context *ctx, struct gl_sampler_object *samp,
+ GLenum s, GLenum t, GLenum r);
+
+extern void
+_mesa_set_sampler_filters(struct gl_context *ctx,
+ struct gl_sampler_object *samp,
+ GLenum min_filter, GLenum mag_filter);
+
+extern void
+_mesa_set_sampler_srgb_decode(struct gl_context *ctx,
+ struct gl_sampler_object *samp, GLenum param);
+
+extern void
+_mesa_bind_sampler(struct gl_context *ctx, GLuint unit,
+ struct gl_sampler_object *sampObj);
+
void GLAPIENTRY
_mesa_GenSamplers(GLsizei count, GLuint *samplers);
void GLAPIENTRY
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index b25732a..014977b 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -56,7 +56,7 @@ const type * RESOURCE_ ## name (gl_program_resource *res) { \
return (type *) res->Data; \
}
-DECL_RESOURCE_FUNC(VAR, ir_variable);
+DECL_RESOURCE_FUNC(VAR, gl_shader_variable);
DECL_RESOURCE_FUNC(UBO, gl_uniform_block);
DECL_RESOURCE_FUNC(UNI, gl_uniform_storage);
DECL_RESOURCE_FUNC(ATC, gl_active_atomic_buffer);
@@ -101,14 +101,14 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index,
}
static bool
-is_active_attrib(const ir_variable *var)
+is_active_attrib(const gl_shader_variable *var)
{
if (!var)
return false;
- switch (var->data.mode) {
+ switch (var->mode) {
case ir_var_shader_in:
- return var->data.location != -1;
+ return var->location != -1;
case ir_var_system_value:
/* From GL 4.3 core spec, section 11.1.1 (Vertex Attributes):
@@ -116,9 +116,9 @@ is_active_attrib(const ir_variable *var)
* are enumerated, including the special built-in inputs gl_VertexID
* and gl_InstanceID."
*/
- return var->data.location == SYSTEM_VALUE_VERTEX_ID ||
- var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE ||
- var->data.location == SYSTEM_VALUE_INSTANCE_ID;
+ return var->location == SYSTEM_VALUE_VERTEX_ID ||
+ var->location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE ||
+ var->location == SYSTEM_VALUE_INSTANCE_ID;
default:
return false;
@@ -163,7 +163,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
return;
}
- const ir_variable *const var = RESOURCE_VAR(res);
+ const gl_shader_variable *const var = RESOURCE_VAR(res);
if (!is_active_attrib(var))
return;
@@ -174,8 +174,8 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
* consider gl_VertexIDMESA as gl_VertexID for purposes of checking
* active attributes.
*/
- if (var->data.mode == ir_var_system_value &&
- var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
+ if (var->mode == ir_var_system_value &&
+ var->location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
var_name = "gl_VertexID";
}
@@ -427,7 +427,7 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
const char*
_mesa_program_resource_name(struct gl_program_resource *res)
{
- const ir_variable *var;
+ const gl_shader_variable *var;
switch (res->Type) {
case GL_UNIFORM_BLOCK:
case GL_SHADER_STORAGE_BLOCK:
@@ -437,8 +437,8 @@ _mesa_program_resource_name(struct gl_program_resource *res)
case GL_PROGRAM_INPUT:
var = RESOURCE_VAR(res);
/* Special case gl_VertexIDMESA -> gl_VertexID. */
- if (var->data.mode == ir_var_system_value &&
- var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
+ if (var->mode == ir_var_system_value &&
+ var->location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
return "gl_VertexID";
}
/* fallthrough */
@@ -857,14 +857,14 @@ program_resource_location(struct gl_shader_program *shProg,
*/
switch (res->Type) {
case GL_PROGRAM_INPUT: {
- const ir_variable *var = RESOURCE_VAR(res);
+ const gl_shader_variable *var = RESOURCE_VAR(res);
/* If the input is an array, fail if the index is out of bounds. */
if (array_index > 0
&& array_index >= var->type->length) {
return -1;
}
- return (var->data.location +
+ return (var->location +
(array_index * var->type->without_array()->matrix_columns) -
VERT_ATTRIB_GENERIC0);
}
@@ -874,7 +874,7 @@ program_resource_location(struct gl_shader_program *shProg,
&& array_index >= RESOURCE_VAR(res)->type->length) {
return -1;
}
- return RESOURCE_VAR(res)->data.location + array_index - FRAG_RESULT_DATA0;
+ return RESOURCE_VAR(res)->location + array_index - FRAG_RESULT_DATA0;
case GL_UNIFORM:
/* If the uniform is built-in, fail. */
if (RESOURCE_UNI(res)->builtin)
@@ -954,7 +954,7 @@ _mesa_program_resource_location_index(struct gl_shader_program *shProg,
if (!res || !(res->StageReferences & (1 << MESA_SHADER_FRAGMENT)))
return -1;
- return RESOURCE_VAR(res)->data.index;
+ return RESOURCE_VAR(res)->index;
}
static uint8_t
@@ -1252,7 +1252,7 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
case GL_LOCATION_INDEX:
if (res->Type != GL_PROGRAM_OUTPUT)
goto invalid_operation;
- *val = RESOURCE_VAR(res)->data.index;
+ *val = RESOURCE_VAR(res)->index;
return 1;
case GL_NUM_COMPATIBLE_SUBROUTINES:
@@ -1309,7 +1309,7 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
switch (res->Type) {
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
- *val = RESOURCE_VAR(res)->data.patch;
+ *val = RESOURCE_VAR(res)->patch;
return 1;
default:
goto invalid_operation;
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c
index 2a19a17..409b2f0 100644
--- a/src/mesa/main/stencil.c
+++ b/src/mesa/main/stencil.c
@@ -124,8 +124,8 @@ _mesa_ClearStencil( GLint s )
* \sa glStencilFunc().
*
* Verifies the parameters and updates the respective values in
- * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the
- * driver via the dd_function_table::StencilFunc callback.
+ * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
+ * the driver via the dd_function_table::StencilFunc callback.
*/
void GLAPIENTRY
_mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask )
@@ -178,8 +178,8 @@ _mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLui
* \sa glStencilFunc().
*
* Verifies the parameters and updates the respective values in
- * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the
- * driver via the dd_function_table::StencilFunc callback.
+ * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
+ * the driver via the dd_function_table::StencilFunc callback.
*/
void GLAPIENTRY
_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
@@ -298,8 +298,8 @@ _mesa_StencilMask( GLuint mask )
* \sa glStencilOp().
*
* Verifies the parameters and updates the respective fields in
- * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the
- * driver via the dd_function_table::StencilOp callback.
+ * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
+ * the driver via the dd_function_table::StencilOp callback.
*/
void GLAPIENTRY
_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
@@ -389,12 +389,6 @@ _mesa_ActiveStencilFaceEXT(GLenum face)
-/**
- * OpenGL 2.0 function.
- * \todo Make StencilOp() call this function. And eventually remove the
- * ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate
- * instead.
- */
void GLAPIENTRY
_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass)
{
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index b2ac65f..766a465 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -437,7 +437,7 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
dst[didx].i = src[sidx].i ? 1 : 0;
break;
case GLSL_TYPE_DOUBLE:
- dst[didx].i = *(double *)&src[sidx].f;
+ dst[didx].i = IROUNDD(*(double *)&src[sidx].f);
break;
default:
assert(!"Should not get here.");
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index b3cfcd2..493d0e5 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -131,7 +131,7 @@ static const char *types[] = {
/**
* Identity matrix.
*/
-static GLfloat Identity[16] = {
+static const GLfloat Identity[16] = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,