From d5ba39ad08f098f377fd258edb904aa7d64ab434 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 11 Jun 2009 19:05:46 +0100 Subject: wgl: Fix prototype. --- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index a601fc5646..58f1830319 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -45,7 +45,7 @@ #include "stw_tls.h" -struct stw_framebuffer * +static INLINE struct stw_framebuffer * stw_framebuffer_from_hwnd_locked( HWND hwnd ) { -- cgit v1.2.3 From e1700009b7cfc5f9a136649d7fd6e0f13ae4e7ad Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 11 Jun 2009 19:24:48 +0100 Subject: python/retrace: Interpret is_texture_referenced/is_buffer_referenced. --- src/gallium/state_trackers/python/retrace/interpreter.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 5d4d04498b..7374904554 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -577,6 +577,14 @@ class Context(Object): self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count) self._set_dirty() + def is_texture_referenced(self, texture, face, level): + #return self.real.is_texture_referenced(format, texture, face, level) + pass + + def is_buffer_referenced(self, buf): + #return self.real.is_buffer_referenced(format, buf) + pass + def _set_dirty(self): if self.interpreter.options.step: self._present() -- cgit v1.2.3 From 0ddc38309a4ecbe7db4a9e6055d7855d00e6ab7b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 11 Jun 2009 20:46:07 +0100 Subject: python/retrace: Show the contents of the depth/stencil and surfaces before/after transfers. --- .../state_trackers/python/retrace/interpreter.py | 38 ++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 7374904554..5885e162c2 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -43,19 +43,27 @@ except ImportError: return struct.unpack(fmt, buf[offset:offset + size]) -def make_image(surface): +def make_image(surface, x=None, y=None, w=None, h=None): + if x is None: + x = 0 + if y is None: + y = 0 + if w is None: + w = surface.width - x + if h is None: + h = surface.height - y data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) import Image outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) return outimage -def save_image(filename, surface): - outimage = make_image(surface) +def save_image(filename, surface, x=None, y=None, w=None, h=None): + outimage = make_image(surface, x, y, w, h) outimage.save(filename, "PNG") -def show_image(surface, title): - outimage = make_image(surface) +def show_image(surface, title, x=None, y=None, w=None, h=None): + outimage = make_image(surface, x, y, w, h) import Tkinter as tk from PIL import Image, ImageTk @@ -305,7 +313,11 @@ class Screen(Object): def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h): if texture is None: return None - return Transfer(texture.get_surface(face, level, zslice), x, y, w, h) + transfer = Transfer(texture.get_surface(face, level, zslice), x, y, w, h) + if transfer and usage != gallium.PIPE_TRANSFER_WRITE: + if self.interpreter.options.all: + self.interpreter.present(transfer.surface, 'transf_read', x, y, w, h) + return transfer def tex_transfer_destroy(self, transfer): self.interpreter.unregister_object(transfer) @@ -314,6 +326,8 @@ class Screen(Object): if transfer is None: return transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride) + if self.interpreter.options.all: + self.interpreter.present(transfer.surface, 'transf_write', transfer.x, transfer.y, transfer.w, transfer.h) def user_buffer_create(self, data, size): # We don't really care to distinguish between user and regular buffers @@ -610,6 +624,9 @@ class Context(Object): if self.cbufs and self.cbufs[0]: self.interpreter.present(self.cbufs[0], "cbuf") + if self.zsbuf: + if self.interpreter.options.all: + self.interpreter.present(self.zsbuf, "zsbuf") class Interpreter(parser.TraceDumper): @@ -679,16 +696,16 @@ class Interpreter(parser.TraceDumper): def verbosity(self, level): return self.options.verbosity >= level - def present(self, surface, description): + def present(self, surface, description, x=None, y=None, w=None, h=None): if self.call_no < self.options.start: return if self.options.images: - filename = '%s_%04u.png' % (description, self.call_no) - save_image(filename, surface) + filename = '%04u_%s.png' % (self.call_no, description) + save_image(filename, surface, x, y, w, h) else: title = '%u. %s' % (self.call_no, description) - show_image(surface, title) + show_image(surface, title, x, y, w, h) class Main(parser.Main): @@ -698,6 +715,7 @@ class Main(parser.Main): optparser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbosity", help="no messages") optparser.add_option("-v", "--verbose", action="count", dest="verbosity", default=1, help="increase verbosity level") optparser.add_option("-i", "--images", action="store_true", dest="images", default=False, help="save images instead of showing them") + optparser.add_option("-a", "--all", action="store_true", dest="all", default=False, help="show depth, stencil, and transfers") optparser.add_option("-s", "--step", action="store_true", dest="step", default=False, help="step trhough every draw") optparser.add_option("-f", "--from", action="store", type="int", dest="start", default=0, help="from call no") optparser.add_option("-t", "--to", action="store", type="int", dest="stop", default=0, help="until call no") -- cgit v1.2.3 From 322e8556b91ceb80d4a53129cbb5db99087085f1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Jun 2009 14:55:14 -0600 Subject: mesa: add default function for ctx->Driver.CheckQuery() hook --- src/mesa/drivers/common/driverfuncs.c | 1 + src/mesa/main/queryobj.c | 16 +++++++++++++++- src/mesa/main/queryobj.h | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 276da41f4e..6a98c29a3d 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -231,6 +231,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->BeginQuery = _mesa_begin_query; driver->EndQuery = _mesa_end_query; driver->WaitQuery = _mesa_wait_query; + driver->CheckQuery = _mesa_check_query; /* APPLE_vertex_array_object */ driver->NewArrayObject = _mesa_new_array_object; diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 554e0b0d18..c25b31af02 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -83,12 +83,26 @@ void _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) { /* For software drivers, _mesa_end_query() should have completed the query. - * For real hardware, implement a proper WaitQuery() driver function. + * For real hardware, implement a proper WaitQuery() driver function, + * which may require issuing a flush. */ assert(q->Ready); } +/** + * Check if a query results are ready. Software driver fallback. + * Called via ctx->Driver.CheckQuery(). + */ +void +_mesa_check_query(GLcontext *ctx, struct gl_query_object *q) +{ + /* No-op for sw rendering. + * HW drivers may need to flush at this time. + */ +} + + /** * Delete a query object. Called via ctx->Driver.DeleteQuery(). * Not removed from hash table here. diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index 9a9774641b..bc02b65b54 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -48,6 +48,9 @@ _mesa_end_query(GLcontext *ctx, struct gl_query_object *q); extern void _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q); +extern void +_mesa_check_query(GLcontext *ctx, struct gl_query_object *q); + extern void GLAPIENTRY _mesa_GenQueriesARB(GLsizei n, GLuint *ids); -- cgit v1.2.3 From 3754c4135cb29e23bd81d573af458742e9a624b2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Jun 2009 14:55:25 -0600 Subject: mesa: rework vertex shader output / fragment shader input attribute matching Before, if a vertex shader's outputs didn't exactly match a fragment shader's inputs we could wind up with invalid TGSI shader declarations. For example: Before patch: DCL OUT[0], POSITION DCL OUT[1], COLOR[1] DCL OUT[2], GENERIC[0] DCL OUT[3], GENERIC[0] <- note duplicate [0] DCL OUT[4], GENERIC[2] After patch: DCL OUT[0], POSITION DCL OUT[1], COLOR[1] DCL OUT[2], GENERIC[0] DCL OUT[3], GENERIC[1] DCL OUT[4], GENERIC[2] --- src/mesa/state_tracker/st_atom_shader.c | 53 ++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index cb869c98a3..ee649be885 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -175,11 +175,12 @@ find_translated_vp(struct st_context *st, /* See if we need to translate vertex program to TGSI form */ if (xvp->serialNo != stvp->serialNo) { - GLuint outAttr, dummySlot; + GLuint outAttr; const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten; GLuint numVpOuts = 0; GLboolean emitPntSize = GL_FALSE, emitBFC0 = GL_FALSE, emitBFC1 = GL_FALSE; - GLint maxGeneric; + GLbitfield usedGenerics = 0x0; + GLbitfield usedOutputSlots = 0x0; /* Compute mapping of vertex program outputs to slots, which depends * on the fragment program's input->slot mapping. @@ -192,10 +193,12 @@ find_translated_vp(struct st_context *st, if (outAttr == VERT_RESULT_HPOS) { /* always put xformed position into slot zero */ - xvp->output_to_slot[VERT_RESULT_HPOS] = 0; + GLuint slot = 0; + xvp->output_to_slot[VERT_RESULT_HPOS] = slot; xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_POSITION; xvp->output_to_semantic_index[outAttr] = 0; numVpOuts++; + usedOutputSlots |= (1 << slot); } else if (outputsWritten & (1 << outAttr)) { /* see if the frag prog wants this vert output */ @@ -209,6 +212,12 @@ find_translated_vp(struct st_context *st, xvp->output_to_semantic_name[outAttr] = stfp->input_semantic_name[fpInSlot]; xvp->output_to_semantic_index[outAttr] = stfp->input_semantic_index[fpInSlot]; numVpOuts++; + usedOutputSlots |= (1 << vpOutSlot); + } + else { +#if 0 /*debug*/ + printf("VP output %d not used by FP\n", outAttr); +#endif } } else if (outAttr == VERT_RESULT_PSIZ) @@ -226,45 +235,49 @@ find_translated_vp(struct st_context *st, /* must do these last */ if (emitPntSize) { - xvp->output_to_slot[VERT_RESULT_PSIZ] = numVpOuts++; + GLuint slot = numVpOuts++; + xvp->output_to_slot[VERT_RESULT_PSIZ] = slot; xvp->output_to_semantic_name[VERT_RESULT_PSIZ] = TGSI_SEMANTIC_PSIZE; xvp->output_to_semantic_index[VERT_RESULT_PSIZ] = 0; + usedOutputSlots |= (1 << slot); } if (emitBFC0) { - xvp->output_to_slot[VERT_RESULT_BFC0] = numVpOuts++; + GLuint slot = numVpOuts++; + xvp->output_to_slot[VERT_RESULT_BFC0] = slot; xvp->output_to_semantic_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR; xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 0; + usedOutputSlots |= (1 << slot); } if (emitBFC1) { - xvp->output_to_slot[VERT_RESULT_BFC1] = numVpOuts++; + GLuint slot = numVpOuts++; + xvp->output_to_slot[VERT_RESULT_BFC1] = slot; xvp->output_to_semantic_name[VERT_RESULT_BFC1] = TGSI_SEMANTIC_COLOR; xvp->output_to_semantic_index[VERT_RESULT_BFC1] = 1; + usedOutputSlots |= (1 << slot); } - /* Unneeded vertex program outputs will go to this slot. - * We could use this info to do dead code elimination in the - * vertex program. - */ - dummySlot = numVpOuts; - - /* find max GENERIC slot index */ - maxGeneric = -1; + /* build usedGenerics mask */ + usedGenerics = 0x0; for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) { if (xvp->output_to_semantic_name[outAttr] == TGSI_SEMANTIC_GENERIC) { - maxGeneric = MAX2(maxGeneric, - xvp->output_to_semantic_index[outAttr]); + usedGenerics |= (1 << xvp->output_to_semantic_index[outAttr]); } } - /* Map vert program outputs that aren't used to the dummy slot - * (and an unused generic attribute slot). + /* For each vertex program output that doesn't match up to a fragment + * program input, map the vertex program output to a free slot and + * free generic attribute. */ for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) { if (outputsWritten & (1 << outAttr)) { if (xvp->output_to_slot[outAttr] == UNUSED) { - xvp->output_to_slot[outAttr] = dummySlot; + GLint freeGeneric = _mesa_ffs(~usedGenerics) - 1; + GLint freeSlot = _mesa_ffs(~usedOutputSlots) - 1; + usedGenerics |= (1 << freeGeneric); + usedOutputSlots |= (1 << freeSlot); + xvp->output_to_slot[outAttr] = freeSlot; xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_GENERIC; - xvp->output_to_semantic_index[outAttr] = maxGeneric + 1; + xvp->output_to_semantic_index[outAttr] = freeGeneric; } } -- cgit v1.2.3 From c6de08fff483911953692693c501bc200c235dce Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 11 Jun 2009 19:26:55 +0100 Subject: mesa: Enable uploads of only depth to z24s8 textures --- src/mesa/main/texstore.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index f3739f950b..bfced1b3f4 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2689,12 +2689,45 @@ GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS) { const GLfloat depthScale = (GLfloat) 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; ASSERT(dstFormat == &_mesa_texformat_z24_s8); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT); - ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); - if (ctx->Pixel.DepthScale == 1.0f && + /* In case we only upload depth we need to preserve the stencil */ + if (srcFormat == GL_DEPTH_COMPONENT) { + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLint i; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + depth, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + for (i = 0; i < srcWidth; i++) + dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } + else if (ctx->Pixel.DepthScale == 1.0f && ctx->Pixel.DepthBias == 0.0f && !srcPacking->SwapBytes) { /* simple path */ -- cgit v1.2.3