#include "main/glformats.h"
#include "util/bitscan.h"
#include "util/ralloc.h"
+#include "compiler/nir/nir.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
static struct blit_shader *
choose_blit_shader(GLenum target, struct blit_shader_table *table);
-static void cleanup_temp_texture(struct temp_texture *tex);
+static void cleanup_temp_texture(struct gl_context *ctx,
+ struct temp_texture *tex);
static void meta_glsl_clear_cleanup(struct gl_context *ctx,
struct clear_state *clear);
static void meta_decompress_cleanup(struct gl_context *ctx,
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face
: texObj->Target;
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, texTarget,
- level, layer, false, __func__);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, __func__);
+ assert(att);
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, texTarget,
+ level, layer, false);
}
static struct gl_shader *
sh = _mesa_new_shader(name, stage);
sh->Source = strdup(source);
- sh->CompileStatus = compile_failure;
+ sh->CompileStatus = COMPILE_FAILURE;
_mesa_compile_shader(ctx, sh);
if (!sh->CompileStatus) {
_mesa_meta_link_program_with_debug(ctx, sh_prog);
+ struct gl_program *fp =
+ sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+
+ /* texelFetch() can break GL_SKIP_DECODE_EXT, but many meta passes want
+ * to use both together; pretend that we're not using texelFetch to hack
+ * around this bad interaction. This is a bit fragile as it may break
+ * if you re-run the pass that gathers this info, but we probably won't...
+ */
+ fp->info.textures_used_by_txf = 0;
+ if (fp->nir)
+ fp->nir->info.textures_used_by_txf = 0;
+
_mesa_meta_use_program(ctx, sh_prog);
*out_sh_prog = sh_prog;
GL_DYNAMIC_DRAW, __func__);
/* setup vertex arrays */
+ FLUSH_VERTICES(ctx, 0);
if (use_generic_attributes) {
assert(color_size == 0);
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
GL_FALSE, GL_FALSE,
- offsetof(struct vertex, x), true);
+ offsetof(struct vertex, x));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
_mesa_enable_vertex_array_attrib(ctx, array_obj,
- VERT_ATTRIB_GENERIC(0));
+ VERT_ATTRIB_GENERIC(0), true);
if (texcoord_size > 0) {
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
texcoord_size, GL_FLOAT, GL_RGBA,
GL_FALSE, GL_FALSE, GL_FALSE,
- offsetof(struct vertex, tex), false);
+ offsetof(struct vertex, tex));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
_mesa_enable_vertex_array_attrib(ctx, array_obj,
- VERT_ATTRIB_GENERIC(1));
+ VERT_ATTRIB_GENERIC(1), true);
}
} else {
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
GL_FALSE, GL_FALSE,
- offsetof(struct vertex, x), true);
+ offsetof(struct vertex, x));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
- *buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
+ *buf_obj, 0, sizeof(struct vertex), true);
+ _mesa_enable_vertex_array_attrib(ctx, array_obj,
+ VERT_ATTRIB_POS, true);
if (texcoord_size > 0) {
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(0),
vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
GL_FALSE, GL_FALSE,
- offsetof(struct vertex, tex), false);
+ offsetof(struct vertex, tex));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
- *buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(0));
+ *buf_obj, 0, sizeof(struct vertex), true);
+ _mesa_enable_vertex_array_attrib(ctx, array_obj,
+ VERT_ATTRIB_TEX(0), true);
}
if (color_size > 0) {
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_COLOR0,
vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE,
GL_FALSE, GL_FALSE,
- offsetof(struct vertex, r), false);
+ offsetof(struct vertex, r));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
- *buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_COLOR0);
+ *buf_obj, 0, sizeof(struct vertex), true);
+ _mesa_enable_vertex_array_attrib(ctx, array_obj,
+ VERT_ATTRIB_COLOR0, true);
}
}
} else {
_mesa_meta_glsl_blit_cleanup(ctx, &ctx->Meta->Blit);
meta_glsl_clear_cleanup(ctx, &ctx->Meta->Clear);
_mesa_meta_glsl_generate_mipmap_cleanup(ctx, &ctx->Meta->Mipmap);
- cleanup_temp_texture(&ctx->Meta->TempTex);
+ cleanup_temp_texture(ctx, &ctx->Meta->TempTex);
meta_decompress_cleanup(ctx, &ctx->Meta->Decompress);
meta_drawpix_cleanup(ctx, &ctx->Meta->DrawPix);
if (old_context)
_mesa_set_enable(ctx, GL_DITHER, GL_TRUE);
}
- if (state & MESA_META_COLOR_MASK) {
- memcpy(save->ColorMask, ctx->Color.ColorMask,
- sizeof(ctx->Color.ColorMask));
- }
+ if (state & MESA_META_COLOR_MASK)
+ save->ColorMask = ctx->Color.ColorMask;
if (state & MESA_META_DEPTH_TEST) {
save->Depth = ctx->Depth; /* struct copy */
GLuint u, tgt;
save->ActiveUnit = ctx->Texture.CurrentUnit;
- save->EnvMode = ctx->Texture.Unit[0].EnvMode;
+ save->EnvMode = ctx->Texture.FixedFuncUnit[0].EnvMode;
/* Disable all texture units */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled;
- save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled;
- if (ctx->Texture.Unit[u].Enabled ||
- ctx->Texture.Unit[u].TexGenEnabled) {
+ save->TexEnabled[u] = ctx->Texture.FixedFuncUnit[u].Enabled;
+ save->TexGenEnabled[u] = ctx->Texture.FixedFuncUnit[u].TexGenEnabled;
+ if (ctx->Texture.FixedFuncUnit[u].Enabled ||
+ ctx->Texture.FixedFuncUnit[u].TexGenEnabled) {
_mesa_ActiveTexture(GL_TEXTURE0 + u);
_mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
if (ctx->Extensions.ARB_texture_cube_map)
if (state & MESA_META_COLOR_MASK) {
GLuint i;
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
- if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, i) !=
+ GET_COLORMASK(save->ColorMask, i)) {
if (i == 0) {
- _mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1],
- save->ColorMask[i][2], save->ColorMask[i][3]);
+ _mesa_ColorMask(GET_COLORMASK_BIT(save->ColorMask, i, 0),
+ GET_COLORMASK_BIT(save->ColorMask, i, 1),
+ GET_COLORMASK_BIT(save->ColorMask, i, 2),
+ GET_COLORMASK_BIT(save->ColorMask, i, 3));
}
else {
_mesa_ColorMaski(i,
- save->ColorMask[i][0],
- save->ColorMask[i][1],
- save->ColorMask[i][2],
- save->ColorMask[i][3]);
+ GET_COLORMASK_BIT(save->ColorMask, i, 0),
+ GET_COLORMASK_BIT(save->ColorMask, i, 1),
+ GET_COLORMASK_BIT(save->ColorMask, i, 2),
+ GET_COLORMASK_BIT(save->ColorMask, i, 3));
}
}
}
_mesa_reference_pipeline_object(ctx, &save->Pipeline, NULL);
}
+
+ _mesa_update_vertex_processing_mode(ctx);
}
if (state & MESA_META_STENCIL_TEST) {
/* Restore fixed function texture enables, texgen */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) {
+ if (ctx->Texture.FixedFuncUnit[u].Enabled != save->TexEnabled[u]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- ctx->Texture.Unit[u].Enabled = save->TexEnabled[u];
+ ctx->Texture.FixedFuncUnit[u].Enabled = save->TexEnabled[u];
}
- if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) {
+ if (ctx->Texture.FixedFuncUnit[u].TexGenEnabled != save->TexGenEnabled[u]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u];
+ ctx->Texture.FixedFuncUnit[u].TexGenEnabled = save->TexGenEnabled[u];
}
}
tex->MinSize = 16; /* 16 x 16 at least */
assert(tex->MaxSize > 0);
- _mesa_GenTextures(1, &tex->TexObj);
+ tex->tex_obj = ctx->Driver.NewTextureObject(ctx, 0xDEADBEEF, tex->Target);
}
static void
-cleanup_temp_texture(struct temp_texture *tex)
+cleanup_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
{
- if (!tex->TexObj)
- return;
- _mesa_DeleteTextures(1, &tex->TexObj);
- tex->TexObj = 0;
+ _mesa_delete_nameless_texture(ctx, tex->tex_obj);
+ tex->tex_obj = NULL;
}
{
struct temp_texture *tex = &ctx->Meta->TempTex;
- if (!tex->TexObj) {
+ if (tex->tex_obj == NULL) {
init_temp_texture(ctx, tex);
}
{
struct temp_texture *tex = &ctx->Meta->Bitmap.Tex;
- if (!tex->TexObj) {
+ if (tex->tex_obj == NULL) {
init_temp_texture(ctx, tex);
}
{
struct temp_texture *tex = &ctx->Meta->Blit.depthTex;
- if (!tex->TexObj) {
+ if (tex->tex_obj == NULL) {
init_temp_texture(ctx, tex);
}
{
bool newTex;
- _mesa_BindTexture(tex->Target, tex->TexObj);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter);
+ _mesa_bind_texture(ctx, tex->Target, tex->tex_obj);
+ _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MIN_FILTER,
+ (GLint *) &filter, false);
+ _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MAG_FILTER,
+ (GLint *) &filter, false);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
newTex = _mesa_meta_alloc_texture(tex, width, height, intFormat);
GLenum format, GLenum type,
const GLvoid *pixels)
{
- _mesa_BindTexture(tex->Target, tex->TexObj);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ /* GLint so the compiler won't complain about type signedness mismatch in
+ * the call to _mesa_texture_parameteriv below.
+ */
+ static const GLint filter = GL_NEAREST;
+
+ _mesa_bind_texture(ctx, tex->Target, tex->tex_obj);
+ _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MIN_FILTER, &filter,
+ false);
+ _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MAG_FILTER, &filter,
+ false);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
/* copy pixel data to texture */
_mesa_DrawBuffers(i, enums);
}
-/**
- * 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];
-}
-
/**
* Given a bitfield of BUFFER_BIT_x draw buffers, call glDrawBuffers to
* set GL to only draw to those buffers. Also, update color masks to
enums[0] = GL_NONE;
for (int i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- int b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+ gl_buffer_index b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
int colormask_idx = ctx->Extensions.EXT_draw_buffers2 ? i : 0;
- if (b < 0 || !(mask & (1 << b)) || is_color_disabled(ctx, colormask_idx))
+ if (b < 0 || !(mask & (1 << b)) ||
+ GET_COLORMASK(ctx->Color.ColorMask, colormask_idx) == 0)
continue;
switch (b) {
}
for (int k = 0; k < 4; k++)
- colormask[num_bufs][k] = ctx->Color.ColorMask[colormask_idx][k];
+ colormask[num_bufs][k] = GET_COLORMASK_BIT(ctx->Color.ColorMask,
+ colormask_idx, k);
num_bufs++;
}
verts[3].tex[1] = tex->Ttop;
/* upload new vertex data */
- _mesa_buffer_sub_data(ctx, copypix->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, copypix->buf_obj, 0, sizeof(verts), verts);
}
_mesa_set_enable(ctx, tex->Target, GL_TRUE);
* Check if swrast fallback is needed.
*/
if (ctx->_ImageTransferState ||
- ctx->FragmentProgram._Enabled ||
+ _mesa_arb_fragment_program_enabled(ctx) ||
ctx->Fog.Enabled ||
ctx->Texture._MaxEnabledTexImageUnit != -1 ||
width > tex->MaxSize ||
}
/* upload new vertex data */
- _mesa_buffer_sub_data(ctx, bitmap->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, bitmap->buf_obj, 0, sizeof(verts), verts);
}
/* choose different foreground/background alpha values */
* glBlitFramebuffer() to implement glCopyTexSubImage().
*/
static bool
-copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims,
+copytexsubimage_using_blit_framebuffer(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset,
GLint yoffset,
GLint bpp;
void *buf;
- if (copytexsubimage_using_blit_framebuffer(ctx, dims,
+ if (copytexsubimage_using_blit_framebuffer(ctx,
texImage,
xoffset, yoffset, zoffset,
rb,
return false;
}
- decompress_fbo->rb->RefCount = 1;
-
decompress_fbo->fb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
if (decompress_fbo->fb == NULL) {
_mesa_meta_end(ctx);
if (width > decompress_fbo->Width || height > decompress_fbo->Height) {
_mesa_renderbuffer_storage(ctx, decompress_fbo->rb, rbFormat,
width, height, 0);
+
+ /* Do the full completeness check to recompute
+ * ctx->DrawBuffer->Width/Height.
+ */
+ ctx->DrawBuffer->_Status = GL_FRAMEBUFFER_UNDEFINED;
status = _mesa_check_framebuffer_status(ctx, ctx->DrawBuffer);
if (status != GL_FRAMEBUFFER_COMPLETE) {
/* If the framebuffer isn't complete then we'll leave
_mesa_set_viewport(ctx, 0, 0, 0, width, height);
/* upload new vertex data */
- _mesa_buffer_sub_data(ctx, decompress->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, decompress->buf_obj, 0, sizeof(verts), verts);
/* setup texture state */
- _mesa_BindTexture(target, texObj->Name);
+ _mesa_bind_texture(ctx, target, texObj);
if (!use_glsl_version)
_mesa_set_enable(ctx, target, GL_TRUE);
GL_DYNAMIC_DRAW, __func__);
/* setup vertex arrays */
+ FLUSH_VERTICES(ctx, 0);
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
3, GL_FLOAT, GL_RGBA, GL_FALSE,
GL_FALSE, GL_FALSE,
- offsetof(struct vertex, x), true);
+ offsetof(struct vertex, x));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
- drawtex->buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
+ drawtex->buf_obj, 0,
+ sizeof(struct vertex), true);
+ _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS, true);
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ FLUSH_VERTICES(ctx, 0);
_mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(i),
2, GL_FLOAT, GL_RGBA, GL_FALSE,
GL_FALSE, GL_FALSE,
- offsetof(struct vertex, st[i]), true);
+ offsetof(struct vertex, st[i]));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i),
- drawtex->buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(i));
+ drawtex->buf_obj, 0,
+ sizeof(struct vertex), true);
+ _mesa_enable_vertex_array_attrib(ctx, array_obj,
+ VERT_ATTRIB_TEX(i), true);
}
}
else {
verts[3].st[i][1] = t1;
}
- _mesa_buffer_sub_data(ctx, drawtex->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, drawtex->buf_obj, 0, sizeof(verts), verts);
}
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
const GLvoid *clearValue,
GLint zoffset)
{
- GLint stencilValue;
- GLfloat depthValue;
+ GLint stencilValue = 0;
+ GLfloat depthValue = 0.0f;
GLenum status;
_mesa_meta_framebuffer_texture_image(ctx, ctx->DrawBuffer,
/* Convert the clearValue from whatever format it's in to a floating
* point value for the depth and an integer value for the stencil index
*/
- _mesa_unpack_float_32_uint_24_8_depth_stencil_row(texImage->TexFormat,
- 1, /* n */
- clearValue,
- depthStencilValue);
- /* We need a memcpy here instead of a cast because we need to
- * reinterpret the bytes as a float rather than converting it
- */
- memcpy(&depthValue, depthStencilValue, sizeof depthValue);
- stencilValue = depthStencilValue[1] & 0xff;
- } else {
- depthValue = 0.0f;
- stencilValue = 0;
+ if (texImage->_BaseFormat == GL_DEPTH_STENCIL) {
+ _mesa_unpack_float_32_uint_24_8_depth_stencil_row(texImage->TexFormat,
+ 1, /* n */
+ clearValue,
+ depthStencilValue);
+ /* We need a memcpy here instead of a cast because we need to
+ * reinterpret the bytes as a float rather than converting it
+ */
+ memcpy(&depthValue, depthStencilValue, sizeof depthValue);
+ stencilValue = depthStencilValue[1] & 0xff;
+ } else {
+ _mesa_unpack_float_z_row(texImage->TexFormat, 1 /* n */,
+ clearValue, &depthValue);
+ }
}
if (texImage->_BaseFormat == GL_DEPTH_STENCIL)