Merge branch 'mesa_7_5_branch'

This commit is contained in:
Jakob Bornecrantz
2009-06-12 12:31:04 +01:00
7 changed files with 125 additions and 35 deletions

View File

@@ -43,19 +43,27 @@ except ImportError:
return struct.unpack(fmt, buf[offset:offset + size]) 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) data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
import Image import Image
outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
return outimage return outimage
def save_image(filename, surface): def save_image(filename, surface, x=None, y=None, w=None, h=None):
outimage = make_image(surface) outimage = make_image(surface, x, y, w, h)
outimage.save(filename, "PNG") outimage.save(filename, "PNG")
def show_image(surface, title): def show_image(surface, title, x=None, y=None, w=None, h=None):
outimage = make_image(surface) outimage = make_image(surface, x, y, w, h)
import Tkinter as tk import Tkinter as tk
from PIL import Image, ImageTk 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): def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
if texture is None: if texture is None:
return 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): def tex_transfer_destroy(self, transfer):
self.interpreter.unregister_object(transfer) self.interpreter.unregister_object(transfer)
@@ -314,6 +326,8 @@ class Screen(Object):
if transfer is None: if transfer is None:
return return
transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride) 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): def user_buffer_create(self, data, size):
# We don't really care to distinguish between user and regular buffers # We don't really care to distinguish between user and regular buffers
@@ -577,6 +591,14 @@ class Context(Object):
self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count) self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count)
self._set_dirty() 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): def _set_dirty(self):
if self.interpreter.options.step: if self.interpreter.options.step:
self._present() self._present()
@@ -602,6 +624,9 @@ class Context(Object):
if self.cbufs and self.cbufs[0]: if self.cbufs and self.cbufs[0]:
self.interpreter.present(self.cbufs[0], "cbuf") 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): class Interpreter(parser.TraceDumper):
@@ -671,16 +696,16 @@ class Interpreter(parser.TraceDumper):
def verbosity(self, level): def verbosity(self, level):
return self.options.verbosity >= 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: if self.call_no < self.options.start:
return return
if self.options.images: if self.options.images:
filename = '%s_%04u.png' % (description, self.call_no) filename = '%04u_%s.png' % (self.call_no, description)
save_image(filename, surface) save_image(filename, surface, x, y, w, h)
else: else:
title = '%u. %s' % (self.call_no, description) title = '%u. %s' % (self.call_no, description)
show_image(surface, title) show_image(surface, title, x, y, w, h)
class Main(parser.Main): class Main(parser.Main):
@@ -690,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("-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("-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("-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("-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("-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") optparser.add_option("-t", "--to", action="store", type="int", dest="stop", default=0, help="until call no")

View File

@@ -45,7 +45,7 @@
#include "stw_tls.h" #include "stw_tls.h"
struct stw_framebuffer * static INLINE struct stw_framebuffer *
stw_framebuffer_from_hwnd_locked( stw_framebuffer_from_hwnd_locked(
HWND hwnd ) HWND hwnd )
{ {

View File

@@ -231,6 +231,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->BeginQuery = _mesa_begin_query; driver->BeginQuery = _mesa_begin_query;
driver->EndQuery = _mesa_end_query; driver->EndQuery = _mesa_end_query;
driver->WaitQuery = _mesa_wait_query; driver->WaitQuery = _mesa_wait_query;
driver->CheckQuery = _mesa_check_query;
/* APPLE_vertex_array_object */ /* APPLE_vertex_array_object */
driver->NewArrayObject = _mesa_new_array_object; driver->NewArrayObject = _mesa_new_array_object;

View File

@@ -83,12 +83,26 @@ void
_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q)
{ {
/* For software drivers, _mesa_end_query() should have completed the query. /* 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); 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(). * Delete a query object. Called via ctx->Driver.DeleteQuery().
* Not removed from hash table here. * Not removed from hash table here.

View File

@@ -48,6 +48,9 @@ _mesa_end_query(GLcontext *ctx, struct gl_query_object *q);
extern void extern void
_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q); _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 extern void GLAPIENTRY
_mesa_GenQueriesARB(GLsizei n, GLuint *ids); _mesa_GenQueriesARB(GLsizei n, GLuint *ids);

View File

@@ -2689,12 +2689,45 @@ GLboolean
_mesa_texstore_z24_s8(TEXSTORE_PARAMS) _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
{ {
const GLfloat depthScale = (GLfloat) 0xffffff; 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(dstFormat == &_mesa_texformat_z24_s8);
ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT); ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT);
ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT); 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 && ctx->Pixel.DepthBias == 0.0f &&
!srcPacking->SwapBytes) { !srcPacking->SwapBytes) {
/* simple path */ /* simple path */

View File

@@ -175,11 +175,12 @@ find_translated_vp(struct st_context *st,
/* See if we need to translate vertex program to TGSI form */ /* See if we need to translate vertex program to TGSI form */
if (xvp->serialNo != stvp->serialNo) { if (xvp->serialNo != stvp->serialNo) {
GLuint outAttr, dummySlot; GLuint outAttr;
const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten; const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten;
GLuint numVpOuts = 0; GLuint numVpOuts = 0;
GLboolean emitPntSize = GL_FALSE, emitBFC0 = GL_FALSE, emitBFC1 = GL_FALSE; 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 /* Compute mapping of vertex program outputs to slots, which depends
* on the fragment program's input->slot mapping. * on the fragment program's input->slot mapping.
@@ -192,10 +193,12 @@ find_translated_vp(struct st_context *st,
if (outAttr == VERT_RESULT_HPOS) { if (outAttr == VERT_RESULT_HPOS) {
/* always put xformed position into slot zero */ /* 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_name[outAttr] = TGSI_SEMANTIC_POSITION;
xvp->output_to_semantic_index[outAttr] = 0; xvp->output_to_semantic_index[outAttr] = 0;
numVpOuts++; numVpOuts++;
usedOutputSlots |= (1 << slot);
} }
else if (outputsWritten & (1 << outAttr)) { else if (outputsWritten & (1 << outAttr)) {
/* see if the frag prog wants this vert output */ /* 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_name[outAttr] = stfp->input_semantic_name[fpInSlot];
xvp->output_to_semantic_index[outAttr] = stfp->input_semantic_index[fpInSlot]; xvp->output_to_semantic_index[outAttr] = stfp->input_semantic_index[fpInSlot];
numVpOuts++; 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) else if (outAttr == VERT_RESULT_PSIZ)
@@ -226,45 +235,49 @@ find_translated_vp(struct st_context *st,
/* must do these last */ /* must do these last */
if (emitPntSize) { 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_name[VERT_RESULT_PSIZ] = TGSI_SEMANTIC_PSIZE;
xvp->output_to_semantic_index[VERT_RESULT_PSIZ] = 0; xvp->output_to_semantic_index[VERT_RESULT_PSIZ] = 0;
usedOutputSlots |= (1 << slot);
} }
if (emitBFC0) { 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_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR;
xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 0; xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 0;
usedOutputSlots |= (1 << slot);
} }
if (emitBFC1) { 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_name[VERT_RESULT_BFC1] = TGSI_SEMANTIC_COLOR;
xvp->output_to_semantic_index[VERT_RESULT_BFC1] = 1; xvp->output_to_semantic_index[VERT_RESULT_BFC1] = 1;
usedOutputSlots |= (1 << slot);
} }
/* Unneeded vertex program outputs will go to this slot. /* build usedGenerics mask */
* We could use this info to do dead code elimination in the usedGenerics = 0x0;
* vertex program.
*/
dummySlot = numVpOuts;
/* find max GENERIC slot index */
maxGeneric = -1;
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) { for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
if (xvp->output_to_semantic_name[outAttr] == TGSI_SEMANTIC_GENERIC) { if (xvp->output_to_semantic_name[outAttr] == TGSI_SEMANTIC_GENERIC) {
maxGeneric = MAX2(maxGeneric, usedGenerics |= (1 << xvp->output_to_semantic_index[outAttr]);
xvp->output_to_semantic_index[outAttr]);
} }
} }
/* Map vert program outputs that aren't used to the dummy slot /* For each vertex program output that doesn't match up to a fragment
* (and an unused generic attribute slot). * program input, map the vertex program output to a free slot and
* free generic attribute.
*/ */
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) { for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
if (outputsWritten & (1 << outAttr)) { if (outputsWritten & (1 << outAttr)) {
if (xvp->output_to_slot[outAttr] == UNUSED) { 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_name[outAttr] = TGSI_SEMANTIC_GENERIC;
xvp->output_to_semantic_index[outAttr] = maxGeneric + 1; xvp->output_to_semantic_index[outAttr] = freeGeneric;
} }
} }