diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-29 10:14:15 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-29 10:14:15 +0000 |
commit | 0b419bcbdb9b686807916d9f2ccb3e578f22496a (patch) | |
tree | 770bd11e6d4a88fdffede42da3ae5077997faf15 /lib/mesa | |
parent | b7ab2ee0fa1e6e04a545a9bd2088ac621c810081 (diff) |
Import Mesa 11.2.2
Diffstat (limited to 'lib/mesa')
-rw-r--r-- | lib/mesa/src/mesa/main/objectpurge.c | 20 | ||||
-rw-r--r-- | lib/mesa/src/mesa/state_tracker/st_cb_bitmap_shader.c | 67 | ||||
-rw-r--r-- | lib/mesa/src/mesa/state_tracker/st_cb_drawpixels_shader.c | 111 |
3 files changed, 135 insertions, 63 deletions
diff --git a/lib/mesa/src/mesa/main/objectpurge.c b/lib/mesa/src/mesa/main/objectpurge.c index de6f56c8e..d730f46b8 100644 --- a/lib/mesa/src/mesa/main/objectpurge.c +++ b/lib/mesa/src/mesa/main/objectpurge.c @@ -31,14 +31,14 @@ #include "glheader.h" #include "enums.h" #include "hash.h" - +#include "imports.h" #include "context.h" #include "bufferobj.h" #include "fbobject.h" #include "mtypes.h" +#include "objectpurge.h" #include "texobj.h" #include "teximage.h" -#include "api_exec_decl.h" static GLenum @@ -53,6 +53,10 @@ buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option) "glObjectPurgeable(name = 0x%x)", name); return 0; } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glObjectPurgeable(buffer 0)" ); + return 0; + } if (bufObj->Purgeable) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -63,6 +67,8 @@ buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option) bufObj->Purgeable = GL_TRUE; retval = GL_VOLATILE_APPLE; + if (ctx->Driver.BufferObjectPurgeable) + retval = ctx->Driver.BufferObjectPurgeable(ctx, bufObj, option); return retval; } @@ -90,6 +96,8 @@ renderbuffer_purgeable(struct gl_context *ctx, GLuint name, GLenum option) bufObj->Purgeable = GL_TRUE; retval = GL_VOLATILE_APPLE; + if (ctx->Driver.RenderObjectPurgeable) + retval = ctx->Driver.RenderObjectPurgeable(ctx, bufObj, option); return retval; } @@ -117,6 +125,8 @@ texture_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option) bufObj->Purgeable = GL_TRUE; retval = GL_VOLATILE_APPLE; + if (ctx->Driver.TextureObjectPurgeable) + retval = ctx->Driver.TextureObjectPurgeable(ctx, bufObj, option); return retval; } @@ -197,6 +207,8 @@ buffer_object_unpurgeable(struct gl_context *ctx, GLuint name, GLenum option) bufObj->Purgeable = GL_FALSE; retval = option; + if (ctx->Driver.BufferObjectUnpurgeable) + retval = ctx->Driver.BufferObjectUnpurgeable(ctx, bufObj, option); return retval; } @@ -225,6 +237,8 @@ renderbuffer_unpurgeable(struct gl_context *ctx, GLuint name, GLenum option) bufObj->Purgeable = GL_FALSE; retval = option; + if (ctx->Driver.RenderObjectUnpurgeable) + retval = ctx->Driver.RenderObjectUnpurgeable(ctx, bufObj, option); return retval; } @@ -253,6 +267,8 @@ texture_object_unpurgeable(struct gl_context *ctx, GLuint name, GLenum option) bufObj->Purgeable = GL_FALSE; retval = option; + if (ctx->Driver.TextureObjectUnpurgeable) + retval = ctx->Driver.TextureObjectUnpurgeable(ctx, bufObj, option); return retval; } diff --git a/lib/mesa/src/mesa/state_tracker/st_cb_bitmap_shader.c b/lib/mesa/src/mesa/state_tracker/st_cb_bitmap_shader.c index 4a051f35a..cddea36d4 100644 --- a/lib/mesa/src/mesa/state_tracker/st_cb_bitmap_shader.c +++ b/lib/mesa/src/mesa/state_tracker/st_cb_bitmap_shader.c @@ -26,17 +26,16 @@ * **************************************************************************/ -#include "main/macros.h" #include "st_cb_bitmap.h" #include "tgsi/tgsi_transform.h" #include "tgsi/tgsi_scan.h" +#include "tgsi/tgsi_dump.h" #include "util/u_debug.h" struct tgsi_bitmap_transform { struct tgsi_transform_context base; struct tgsi_shader_info info; unsigned sampler_index; - unsigned tex_target; bool use_texcoord; bool swizzle_xxxx; bool first_instruction_emitted; @@ -53,9 +52,8 @@ transform_instr(struct tgsi_transform_context *tctx, struct tgsi_full_instruction *current_inst) { struct tgsi_bitmap_transform *ctx = tgsi_bitmap_transform(tctx); + struct tgsi_full_declaration decl; struct tgsi_full_instruction inst; - unsigned tgsi_tex_target = ctx->tex_target == PIPE_TEXTURE_2D - ? TGSI_TEXTURE_2D : TGSI_TEXTURE_RECT; unsigned i, semantic; int texcoord_index = -1; @@ -68,7 +66,9 @@ transform_instr(struct tgsi_transform_context *tctx, /* Add TEMP[0] if it's missing. */ if (ctx->info.file_max[TGSI_FILE_TEMPORARY] == -1) { - tgsi_transform_temp_decl(tctx, 0); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_TEMPORARY; + tctx->emit_declaration(tctx, &decl); } /* Add TEXCOORD[0] if it's missing. */ @@ -83,23 +83,45 @@ transform_instr(struct tgsi_transform_context *tctx, } if (texcoord_index == -1) { + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_INPUT; + decl.Declaration.Semantic = 1; + decl.Semantic.Name = semantic; + decl.Declaration.Interpolate = 1; + decl.Interp.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE; + decl.Range.First = decl.Range.Last = ctx->info.num_inputs; texcoord_index = ctx->info.num_inputs; - tgsi_transform_input_decl(tctx, texcoord_index, - semantic, 0, TGSI_INTERPOLATE_PERSPECTIVE); + tctx->emit_declaration(tctx, &decl); } /* Declare the sampler. */ - tgsi_transform_sampler_decl(tctx, ctx->sampler_index); - - /* Declare the sampler view. */ - tgsi_transform_sampler_view_decl(tctx, ctx->sampler_index, - tgsi_tex_target, TGSI_RETURN_TYPE_FLOAT); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_SAMPLER; + decl.Range.First = decl.Range.Last = ctx->sampler_index; + tctx->emit_declaration(tctx, &decl); /* TEX tmp0, fragment.texcoord[0], texture[0], 2D; */ - tgsi_transform_tex_inst(tctx, - TGSI_FILE_TEMPORARY, 0, - TGSI_FILE_INPUT, texcoord_index, - tgsi_tex_target, ctx->sampler_index); + inst = tgsi_default_full_instruction(); + inst.Instruction.Opcode = TGSI_OPCODE_TEX; + inst.Instruction.Texture = 1; + inst.Texture.Texture = TGSI_TEXTURE_2D; + + inst.Instruction.NumDstRegs = 1; + inst.Dst[0].Register.File = TGSI_FILE_TEMPORARY; + inst.Dst[0].Register.Index = 0; + inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW; + + inst.Instruction.NumSrcRegs = 2; + inst.Src[0].Register.File = TGSI_FILE_INPUT; + inst.Src[0].Register.Index = texcoord_index; + inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X; + inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_Y; + inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_Z; + inst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_W; + inst.Src[1].Register.File = TGSI_FILE_SAMPLER; + inst.Src[1].Register.Index = ctx->sampler_index; + + tctx->emit_instruction(tctx, &inst); /* KIL if -tmp0 < 0 # texel=0 -> keep / texel=0 -> discard */ inst = tgsi_default_full_instruction(); @@ -128,24 +150,25 @@ transform_instr(struct tgsi_transform_context *tctx, const struct tgsi_token * st_get_bitmap_shader(const struct tgsi_token *tokens, - unsigned tex_target, unsigned sampler_index, + unsigned sampler_index, bool use_texcoord, bool swizzle_xxxx) { struct tgsi_bitmap_transform ctx; + struct tgsi_token *newtoks; int newlen; - assert(tex_target == PIPE_TEXTURE_2D || - tex_target == PIPE_TEXTURE_RECT); - memset(&ctx, 0, sizeof(ctx)); ctx.base.transform_instruction = transform_instr; - ctx.tex_target = tex_target; ctx.sampler_index = sampler_index; ctx.use_texcoord = use_texcoord; ctx.swizzle_xxxx = swizzle_xxxx; tgsi_scan_shader(tokens, &ctx.info); newlen = tgsi_num_tokens(tokens) + 20; + newtoks = tgsi_alloc_tokens(newlen); + if (!newtoks) + return NULL; - return tgsi_transform_shader(tokens, newlen, &ctx.base); + tgsi_transform_shader(tokens, newtoks, newlen, &ctx.base); + return newtoks; } diff --git a/lib/mesa/src/mesa/state_tracker/st_cb_drawpixels_shader.c b/lib/mesa/src/mesa/state_tracker/st_cb_drawpixels_shader.c index 534009957..749b46cfb 100644 --- a/lib/mesa/src/mesa/state_tracker/st_cb_drawpixels_shader.c +++ b/lib/mesa/src/mesa/state_tracker/st_cb_drawpixels_shader.c @@ -26,7 +26,6 @@ * **************************************************************************/ -#include "main/macros.h" #include "st_cb_drawpixels.h" #include "tgsi/tgsi_transform.h" #include "tgsi/tgsi_scan.h" @@ -44,7 +43,6 @@ struct tgsi_drawpix_transform { unsigned drawpix_sampler; unsigned pixelmap_sampler; unsigned texcoord_const; - unsigned tex_target; }; static inline struct tgsi_drawpix_transform * @@ -74,8 +72,8 @@ transform_instr(struct tgsi_transform_context *tctx, struct tgsi_full_instruction *current_inst) { struct tgsi_drawpix_transform *ctx = tgsi_drawpix_transform(tctx); - const unsigned tgsi_tex_target = ctx->tex_target == PIPE_TEXTURE_2D - ? TGSI_TEXTURE_2D : TGSI_TEXTURE_RECT; + struct tgsi_full_declaration decl; + struct tgsi_full_instruction inst; unsigned i, sem_texcoord = ctx->use_texcoord ? TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC; int texcoord_index = -1; @@ -88,21 +86,33 @@ transform_instr(struct tgsi_transform_context *tctx, /* Add scale and bias constants. */ if (ctx->scale_and_bias) { if (ctx->info.const_file_max[0] < (int)ctx->scale_const) { - tgsi_transform_const_decl(tctx, ctx->scale_const, ctx->scale_const); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_CONSTANT; + decl.Range.First = decl.Range.Last = ctx->scale_const; + tctx->emit_declaration(tctx, &decl); } if (ctx->info.const_file_max[0] < (int)ctx->bias_const) { - tgsi_transform_const_decl(tctx, ctx->bias_const, ctx->bias_const); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_CONSTANT; + decl.Range.First = decl.Range.Last = ctx->bias_const; + tctx->emit_declaration(tctx, &decl); } } if (ctx->info.const_file_max[0] < (int)ctx->texcoord_const) { - tgsi_transform_const_decl(tctx, ctx->texcoord_const, ctx->texcoord_const); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_CONSTANT; + decl.Range.First = decl.Range.Last = ctx->texcoord_const; + tctx->emit_declaration(tctx, &decl); } /* Add a new temp. */ ctx->color_temp = ctx->info.file_max[TGSI_FILE_TEMPORARY] + 1; - tgsi_transform_temp_decl(tctx, ctx->color_temp); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_TEMPORARY; + decl.Range.First = decl.Range.Last = ctx->color_temp; + tctx->emit_declaration(tctx, &decl); /* Add TEXCOORD[texcoord_slot] if it's missing. */ for (i = 0; i < ctx->info.num_inputs; i++) { @@ -114,51 +124,75 @@ transform_instr(struct tgsi_transform_context *tctx, } if (texcoord_index == -1) { + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_INPUT; + decl.Declaration.Semantic = 1; + decl.Semantic.Name = sem_texcoord; + decl.Declaration.Interpolate = 1; + decl.Interp.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE; + decl.Range.First = decl.Range.Last = ctx->info.num_inputs; texcoord_index = ctx->info.num_inputs; - tgsi_transform_input_decl(tctx, texcoord_index, sem_texcoord, 0, - TGSI_INTERPOLATE_PERSPECTIVE); + tctx->emit_declaration(tctx, &decl); } /* Declare the drawpix sampler if it's missing. */ if (!(ctx->info.samplers_declared & (1 << ctx->drawpix_sampler))) { - tgsi_transform_sampler_decl(tctx, ctx->drawpix_sampler); - - /* emit sampler view declaration */ - tgsi_transform_sampler_view_decl(tctx, ctx->drawpix_sampler, - tgsi_tex_target, TGSI_RETURN_TYPE_FLOAT); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_SAMPLER; + decl.Range.First = decl.Range.Last = ctx->drawpix_sampler; + tctx->emit_declaration(tctx, &decl); } /* Declare the pixel map sampler if it's missing. */ if (ctx->pixel_maps && !(ctx->info.samplers_declared & (1 << ctx->pixelmap_sampler))) { - tgsi_transform_sampler_decl(tctx, ctx->pixelmap_sampler); - - /* emit sampler view declaration */ - tgsi_transform_sampler_view_decl(tctx, ctx->pixelmap_sampler, - TGSI_TEXTURE_2D, TGSI_RETURN_TYPE_FLOAT); + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_SAMPLER; + decl.Range.First = decl.Range.Last = ctx->pixelmap_sampler; + tctx->emit_declaration(tctx, &decl); } /* Get initial pixel color from the texture. * TEX temp, fragment.texcoord[0], texture[0], 2D; */ - tgsi_transform_tex_inst(tctx, TGSI_FILE_TEMPORARY, ctx->color_temp, - TGSI_FILE_INPUT, texcoord_index, - tgsi_tex_target, ctx->drawpix_sampler); + inst = tgsi_default_full_instruction(); + inst.Instruction.Opcode = TGSI_OPCODE_TEX; + inst.Instruction.Texture = 1; + inst.Texture.Texture = TGSI_TEXTURE_2D; + + inst.Instruction.NumDstRegs = 1; + inst.Dst[0].Register.File = TGSI_FILE_TEMPORARY; + inst.Dst[0].Register.Index = ctx->color_temp; + inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW; + + inst.Instruction.NumSrcRegs = 2; + SET_SRC(&inst, 0, TGSI_FILE_INPUT, texcoord_index, X, Y, Z, W); + inst.Src[1].Register.File = TGSI_FILE_SAMPLER; + inst.Src[1].Register.Index = ctx->drawpix_sampler; + + tctx->emit_instruction(tctx, &inst); /* Apply the scale and bias. */ if (ctx->scale_and_bias) { /* MAD temp, temp, scale, bias; */ - tgsi_transform_op3_inst(tctx, TGSI_OPCODE_MAD, - TGSI_FILE_TEMPORARY, ctx->color_temp, - TGSI_WRITEMASK_XYZW, - TGSI_FILE_TEMPORARY, ctx->color_temp, - TGSI_FILE_CONSTANT, ctx->scale_const, - TGSI_FILE_CONSTANT, ctx->bias_const); + inst = tgsi_default_full_instruction(); + inst.Instruction.Opcode = TGSI_OPCODE_MAD; + + inst.Instruction.NumDstRegs = 1; + inst.Dst[0].Register.File = TGSI_FILE_TEMPORARY; + inst.Dst[0].Register.Index = ctx->color_temp; + inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW; + + inst.Instruction.NumSrcRegs = 3; + SET_SRC(&inst, 0, TGSI_FILE_TEMPORARY, ctx->color_temp, X, Y, Z, W); + SET_SRC(&inst, 1, TGSI_FILE_CONSTANT, ctx->scale_const, X, Y, Z, W); + SET_SRC(&inst, 2, TGSI_FILE_CONSTANT, ctx->bias_const, X, Y, Z, W); + + tctx->emit_instruction(tctx, &inst); } if (ctx->pixel_maps) { /* do four pixel map look-ups with two TEX instructions: */ - struct tgsi_full_instruction inst; /* TEX temp.xy, temp.xyyy, texture[1], 2D; */ inst = tgsi_default_full_instruction(); @@ -205,8 +239,6 @@ transform_inst: ctx->info.input_semantic_index[reg] == 0) { src->Register.File = TGSI_FILE_CONSTANT; src->Register.Index = ctx->texcoord_const; - src->Register.Dimension = 1; - src->Dimension.Index = 0; } } @@ -218,14 +250,12 @@ st_get_drawpix_shader(const struct tgsi_token *tokens, bool use_texcoord, bool scale_and_bias, unsigned scale_const, unsigned bias_const, bool pixel_maps, unsigned drawpix_sampler, unsigned pixelmap_sampler, - unsigned texcoord_const, unsigned tex_target) + unsigned texcoord_const) { struct tgsi_drawpix_transform ctx; + struct tgsi_token *newtoks; int newlen; - assert(tex_target == PIPE_TEXTURE_2D || - tex_target == PIPE_TEXTURE_RECT); - memset(&ctx, 0, sizeof(ctx)); ctx.base.transform_instruction = transform_instr; ctx.use_texcoord = use_texcoord; @@ -236,10 +266,13 @@ st_get_drawpix_shader(const struct tgsi_token *tokens, bool use_texcoord, ctx.drawpix_sampler = drawpix_sampler; ctx.pixelmap_sampler = pixelmap_sampler; ctx.texcoord_const = texcoord_const; - ctx.tex_target = tex_target; tgsi_scan_shader(tokens, &ctx.info); - newlen = tgsi_num_tokens(tokens) + 60; + newlen = tgsi_num_tokens(tokens) + 30; + newtoks = tgsi_alloc_tokens(newlen); + if (!newtoks) + return NULL; - return tgsi_transform_shader(tokens, newlen, &ctx.base); + tgsi_transform_shader(tokens, newtoks, newlen, &ctx.base); + return newtoks; } |