From 9d49fb4f29125ec4fe625323f2382bdfebd225e9 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sat, 28 Feb 2009 15:09:43 +0100 Subject: tgsi: More descriptive sanity diagnostic messages. --- src/gallium/auxiliary/tgsi/tgsi_sanity.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index bc7b941b78..d802b439fc 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -30,18 +30,19 @@ #include "tgsi_info.h" #include "tgsi_iterate.h" -#define MAX_REGISTERS 256 - typedef uint reg_flag; #define BITS_IN_REG_FLAG (sizeof( reg_flag ) * 8) +#define MAX_REGISTERS 256 +#define MAX_REG_FLAGS ((MAX_REGISTERS + BITS_IN_REG_FLAG - 1) / BITS_IN_REG_FLAG) + struct sanity_check_ctx { struct tgsi_iterate_context iter; - reg_flag regs_decl[TGSI_FILE_COUNT][MAX_REGISTERS / BITS_IN_REG_FLAG]; - reg_flag regs_used[TGSI_FILE_COUNT][MAX_REGISTERS / BITS_IN_REG_FLAG]; + reg_flag regs_decl[TGSI_FILE_COUNT][MAX_REG_FLAGS]; + reg_flag regs_used[TGSI_FILE_COUNT][MAX_REG_FLAGS]; boolean regs_ind_used[TGSI_FILE_COUNT]; uint num_imms; uint num_instructions; @@ -89,7 +90,7 @@ check_file_name( uint file ) { if (file <= TGSI_FILE_NULL || file >= TGSI_FILE_COUNT) { - report_error( ctx, "Invalid register file name" ); + report_error( ctx, "(%u): Invalid register file name", file ); return FALSE; } return TRUE; @@ -113,7 +114,7 @@ is_any_register_declared( { uint i; - for (i = 0; i < MAX_REGISTERS / BITS_IN_REG_FLAG; i++) + for (i = 0; i < MAX_REG_FLAGS; i++) if (ctx->regs_decl[file][i]) return TRUE; return FALSE; @@ -162,9 +163,8 @@ check_register_usage( ctx->regs_ind_used[file] = TRUE; } else { - if (index < 0 || index > MAX_REGISTERS) { - report_error( ctx, "%s[%i]: Invalid index %s", - file_names[file], index, name ); + if (index < 0 || index >= MAX_REGISTERS) { + report_error( ctx, "%s[%d]: Invalid %s index", file_names[file], index, name ); return FALSE; } @@ -193,15 +193,15 @@ iter_instruction( info = tgsi_get_opcode_info( inst->Instruction.Opcode ); if (info == NULL) { - report_error( ctx, "Invalid instruction opcode" ); + report_error( ctx, "(%u): Invalid instruction opcode", inst->Instruction.Opcode ); return TRUE; } if (info->num_dst != inst->Instruction.NumDstRegs) { - report_error( ctx, "Invalid number of destination operands" ); + report_error( ctx, "Invalid number of destination operands, should be %u", info->num_dst ); } if (info->num_src != inst->Instruction.NumSrcRegs) { - report_error( ctx, "Invalid number of source operands" ); + report_error( ctx, "Invalid number of source operands, should be %u", info->num_src ); } /* Check destination and source registers' validity. @@ -266,7 +266,7 @@ iter_declaration( return TRUE; for (i = decl->DeclarationRange.First; i <= decl->DeclarationRange.Last; i++) { if (is_register_declared( ctx, file, i )) - report_error( ctx, "The same register declared twice" ); + report_error( ctx, "%s[%u]: The same register declared more than once", file_names[file], i ); ctx->regs_decl[file][i / BITS_IN_REG_FLAG] |= (1 << (i % BITS_IN_REG_FLAG)); } @@ -295,7 +295,7 @@ iter_immediate( /* Check data type validity. */ if (imm->Immediate.DataType != TGSI_IMM_FLOAT32) { - report_error( ctx, "Invalid immediate data type" ); + report_error( ctx, "(%u): Invalid immediate data type", imm->Immediate.DataType ); return TRUE; } @@ -322,7 +322,7 @@ epilog( for (i = 0; i < MAX_REGISTERS; i++) { if (is_register_declared( ctx, file, i ) && !is_register_used( ctx, file, i ) && !ctx->regs_ind_used[file]) { - report_warning( ctx, "Register never used" ); + report_warning( ctx, "%s[%u]: Register never used", file_names[file], i ); } } } -- cgit v1.2.3 From 802a5ff507e44eafe86b687f603d496c3846fd50 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Feb 2009 11:22:24 +0000 Subject: pipebuffer: Remove unused var. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index c3d747898a..91b55c8238 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -476,7 +476,6 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) struct pipe_winsys *winsys = fenced_list->winsys; struct list_head *curr, *next; struct fenced_buffer *fenced_buf; - struct pipe_fence_handle *prev_fence = NULL; pipe_mutex_lock(fenced_list->mutex); -- cgit v1.2.3 From 2c1d40a051187242d7e55c7755e0433d4fb9c93a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 2 Mar 2009 17:32:37 +0000 Subject: pipebuffer: Wait for the GPU to finish reading too. No real change, as we're not tracking relocations read/write access yet. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 91b55c8238..ede2af4460 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -296,9 +296,10 @@ fenced_buffer_map(struct pb_buffer *buf, assert(!(flags & ~PIPE_BUFFER_USAGE_CPU_READ_WRITE)); flags &= PIPE_BUFFER_USAGE_CPU_READ_WRITE; - /* Check for GPU read/write access */ - if(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) { - /* Wait for the GPU to finish writing */ + /* Serialize writes */ + if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || + ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { + /* Wait for the GPU to finish */ _fenced_buffer_finish(fenced_buf); } -- cgit v1.2.3 From cfc3d5c219e3ae3190b7700472bdefec028a7a15 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 2 Mar 2009 17:18:21 +0000 Subject: gallium: New PIPE_BUFFER_USAGE_DONTBLOCK flag. To prevent blocking when mapping a buffer. --- src/gallium/include/pipe/p_defines.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index dc8a92dccb..284ebe084c 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -201,6 +201,8 @@ enum pipe_texture_target { #define PIPE_BUFFER_USAGE_VERTEX (1 << 5) #define PIPE_BUFFER_USAGE_INDEX (1 << 6) #define PIPE_BUFFER_USAGE_CONSTANT (1 << 7) +#define PIPE_BUFFER_USAGE_DISCARD (1 << 8) +#define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9) /** Pipe driver custom usage flags should be greater or equal to this value */ #define PIPE_BUFFER_USAGE_CUSTOM (1 << 16) -- cgit v1.2.3 From fe64aa0c8eb71e708a3530f8fec2c7df94d90e36 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 2 Mar 2009 17:35:28 +0000 Subject: pipebuffer: Handle PIPE_BUFFER_USAGE_DONTBLOCK flag. Conflicts: src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index ede2af4460..788bf9087f 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -291,16 +291,26 @@ fenced_buffer_map(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_buffer_list *fenced_list = fenced_buf->list; + struct pipe_winsys *winsys = fenced_list->winsys; void *map; - assert(!(flags & ~PIPE_BUFFER_USAGE_CPU_READ_WRITE)); - flags &= PIPE_BUFFER_USAGE_CPU_READ_WRITE; + assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE)); /* Serialize writes */ if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { - /* Wait for the GPU to finish */ - _fenced_buffer_finish(fenced_buf); + if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) { + /* Don't wait for the GPU to finish writing */ + if(winsys->fence_finish(winsys, fenced_buf->fence, 0) == 0) + _fenced_buffer_remove(fenced_list, fenced_buf); + else + return NULL; + } + else { + /* Wait for the GPU to finish writing */ + _fenced_buffer_finish(fenced_buf); + } } #if 0 @@ -314,7 +324,7 @@ fenced_buffer_map(struct pb_buffer *buf, map = pb_map(fenced_buf->buffer, flags); if(map) { ++fenced_buf->mapcount; - fenced_buf->flags |= flags; + fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE; } return map; -- cgit v1.2.3 From 050ce17799cbe652962f898942ae6551d31f21a2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 2 Mar 2009 17:45:35 +0000 Subject: pipebuffer: Cleanup code & comments. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 788bf9087f..9282bca2eb 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -419,16 +419,14 @@ buffer_fence(struct pb_buffer *buf, if(buf->vtbl != &fenced_buffer_vtbl) return; + if(!fence) + return; + fenced_buf = fenced_buffer(buf); fenced_list = fenced_buf->list; winsys = fenced_list->winsys; - if(!fence || fence == fenced_buf->fence) { - /* Handle the same fence case specially, not only because it is a fast - * path, but mostly to avoid serializing two writes with the same fence, - * as that would bring the hardware down to synchronous operation without - * any benefit. - */ + if(fence == fenced_buf->fence) { fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE; return; } @@ -436,11 +434,9 @@ buffer_fence(struct pb_buffer *buf, pipe_mutex_lock(fenced_list->mutex); if (fenced_buf->fence) _fenced_buffer_remove(fenced_list, fenced_buf); - if (fence) { - winsys->fence_reference(winsys, &fenced_buf->fence, fence); - fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE; - _fenced_buffer_add(fenced_buf); - } + winsys->fence_reference(winsys, &fenced_buf->fence, fence); + fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE; + _fenced_buffer_add(fenced_buf); pipe_mutex_unlock(fenced_list->mutex); } -- cgit v1.2.3