From 0f82aa5f15479aea692613fb56643bf3b769cf37 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 22 Mar 2009 18:10:10 -0600 Subject: tgsi: minor comments --- src/gallium/auxiliary/tgsi/tgsi_exec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 4ffd4efbffa..0b4b2a6fb6e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -205,8 +205,8 @@ struct tgsi_exec_machine const float (*Consts)[4]; struct tgsi_exec_vector *Inputs; struct tgsi_exec_vector *Outputs; - const struct tgsi_token *Tokens; - unsigned Processor; + const struct tgsi_token *Tokens; /**< Declarations, instructions */ + unsigned Processor; /**< TGSI_PROCESSOR_x */ /* GEOMETRY processor only. */ unsigned *Primitives; -- cgit v1.2.3 From bab6d6bfe928687717a5e5f274110fe1838f99ba Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 22 Mar 2009 18:11:12 -0600 Subject: softpipe: reformatting, comments, minor clean-ups --- src/gallium/drivers/softpipe/sp_fs_exec.c | 17 ++++++++--------- src/gallium/drivers/softpipe/sp_fs_llvm.c | 14 ++++++++++---- src/gallium/drivers/softpipe/sp_fs_sse.c | 25 +++++++++++++++++++------ src/gallium/drivers/softpipe/sp_quad_fs.c | 21 ++++++++++----------- 4 files changed, 47 insertions(+), 30 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c index 0c14d92864f..9ee86fe7878 100644 --- a/src/gallium/drivers/softpipe/sp_fs_exec.c +++ b/src/gallium/drivers/softpipe/sp_fs_exec.c @@ -25,22 +25,29 @@ * **************************************************************************/ +/** + * Execute fragment shader using the TGSI interpreter. + */ #include "sp_context.h" #include "sp_state.h" #include "sp_fs.h" #include "sp_quad.h" - #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_memory.h" #include "tgsi/tgsi_exec.h" #include "tgsi/tgsi_parse.h" + +/** + * Subclass of sp_fragment_shader + */ struct sp_exec_fragment_shader { struct sp_fragment_shader base; + /* No other members for now */ }; @@ -106,8 +113,6 @@ exec_prepare( const struct sp_fragment_shader *base, } - - /* TODO: hide the machine struct in here somewhere, remove from this * interface: */ @@ -116,7 +121,6 @@ exec_run( const struct sp_fragment_shader *base, struct tgsi_exec_machine *machine, struct quad_header *quad ) { - /* Compute X, Y, Z, W vals for this quad */ sp_setup_pos_vector(quad->posCoef, (float)quad->input.x0, (float)quad->input.y0, @@ -126,7 +130,6 @@ exec_run( const struct sp_fragment_shader *base, } - static void exec_delete( struct sp_fragment_shader *base ) { @@ -135,9 +138,6 @@ exec_delete( struct sp_fragment_shader *base ) } - - - struct sp_fragment_shader * softpipe_create_fs_exec(struct softpipe_context *softpipe, const struct pipe_shader_state *templ) @@ -160,4 +160,3 @@ softpipe_create_fs_exec(struct softpipe_context *softpipe, return &shader->base; } - diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c index f33b3e32854..95c0d982d12 100644 --- a/src/gallium/drivers/softpipe/sp_fs_llvm.c +++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c @@ -25,7 +25,9 @@ * **************************************************************************/ -/* Authors: +/** + * Execute fragment shader using LLVM code generation. + * Authors: * Zack Rusin */ @@ -33,7 +35,6 @@ #include "sp_state.h" #include "sp_fs.h" - #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -41,11 +42,16 @@ #if 0 -struct sp_llvm_fragment_shader { +/** + * Subclass of sp_fragment_shader + */ +struct sp_llvm_fragment_shader +{ struct sp_fragment_shader base; struct gallivm_prog *llvm_prog; }; + static void shade_quad_llvm(struct quad_stage *qs, struct quad_header *quad) @@ -160,7 +166,7 @@ delete_llvm_fs( struct sp_fragment_shader *base ) struct sp_fragment_shader * softpipe_create_fs_llvm(struct softpipe_context *softpipe, - const struct pipe_shader_state *templ) + const struct pipe_shader_state *templ) { struct sp_llvm_fragment_shader *shader = NULL; diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c index 366abe2ed49..31c3ca21c51 100644 --- a/src/gallium/drivers/softpipe/sp_fs_sse.c +++ b/src/gallium/drivers/softpipe/sp_fs_sse.c @@ -25,13 +25,15 @@ * **************************************************************************/ +/** + * Execute fragment shader using runtime SSE code generation. + */ #include "sp_context.h" #include "sp_state.h" #include "sp_fs.h" #include "sp_quad.h" - #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -56,14 +58,25 @@ typedef void (PIPE_CDECL *codegen_function)( ); -struct sp_sse_fragment_shader { +/** + * Subclass of sp_fragment_shader + */ +struct sp_sse_fragment_shader +{ struct sp_fragment_shader base; - struct x86_function sse2_program; + struct x86_function sse2_program; codegen_function func; float immediates[TGSI_EXEC_NUM_IMMEDIATES][4]; }; +/** cast wrapper */ +static INLINE struct sp_sse_fragment_shader * +sp_sse_fragment_shader(const struct sp_fragment_shader *base) +{ + return (struct sp_sse_fragment_shader *) base; +} + static void fs_sse_prepare( const struct sp_fragment_shader *base, @@ -83,7 +96,7 @@ fs_sse_run( const struct sp_fragment_shader *base, struct tgsi_exec_machine *machine, struct quad_header *quad ) { - struct sp_sse_fragment_shader *shader = (struct sp_sse_fragment_shader *) base; + struct sp_sse_fragment_shader *shader = sp_sse_fragment_shader(base); /* Compute X, Y, Z, W vals for this quad -- place in temp[0] for now */ sp_setup_pos_vector(quad->posCoef, @@ -110,7 +123,7 @@ fs_sse_run( const struct sp_fragment_shader *base, static void fs_sse_delete( struct sp_fragment_shader *base ) { - struct sp_sse_fragment_shader *shader = (struct sp_sse_fragment_shader *) base; + struct sp_sse_fragment_shader *shader = sp_sse_fragment_shader(base); x86_release_func( &shader->sse2_program ); FREE(shader); @@ -156,7 +169,7 @@ softpipe_create_fs_sse(struct softpipe_context *softpipe, #else -/* Maybe put this varient in the header file. +/* Maybe put this variant in the header file. */ struct sp_fragment_shader * softpipe_create_fs_sse(struct softpipe_context *softpipe, diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index adca5df73d8..ca637a1d6a4 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -65,14 +65,11 @@ quad_shade_stage(struct quad_stage *qs) } - /** * Execute fragment shader for the four fragments in the quad. */ static void -shade_quad( - struct quad_stage *qs, - struct quad_header *quad ) +shade_quad(struct quad_stage *qs, struct quad_header *quad) { struct quad_shade_stage *qss = quad_shade_stage( qs ); struct softpipe_context *softpipe = qs->softpipe; @@ -85,9 +82,7 @@ shade_quad( machine->InterpCoefs = quad->coef; /* run shader */ - quad->inout.mask &= softpipe->fs->run( softpipe->fs, - &qss->machine, - quad ); + quad->inout.mask &= softpipe->fs->run( softpipe->fs, machine, quad ); /* store outputs */ z_written = FALSE; @@ -135,15 +130,17 @@ shade_quad( } /* shader may cull fragments */ - if( quad->inout.mask ) { + if (quad->inout.mask) { qs->next->run( qs->next, quad ); } } + /** * Per-primitive (or per-begin?) setup */ -static void shade_begin(struct quad_stage *qs) +static void +shade_begin(struct quad_stage *qs) { struct quad_shade_stage *qss = quad_shade_stage(qs); struct softpipe_context *softpipe = qs->softpipe; @@ -157,7 +154,8 @@ static void shade_begin(struct quad_stage *qs) } -static void shade_destroy(struct quad_stage *qs) +static void +shade_destroy(struct quad_stage *qs) { struct quad_shade_stage *qss = (struct quad_shade_stage *) qs; @@ -168,7 +166,8 @@ static void shade_destroy(struct quad_stage *qs) } -struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe ) +struct quad_stage * +sp_quad_shade_stage( struct softpipe_context *softpipe ) { struct quad_shade_stage *qss = CALLOC_STRUCT(quad_shade_stage); -- cgit v1.2.3 From 3708aaeaff5041040783bd252768fadf2b794ec2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 23 Mar 2009 12:05:07 +0000 Subject: util: Add a new macro for testing empty lists. --- src/gallium/auxiliary/util/u_double_list.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_double_list.h b/src/gallium/auxiliary/util/u_double_list.h index d108d92e52b..53bb1342ddc 100644 --- a/src/gallium/auxiliary/util/u_double_list.h +++ b/src/gallium/auxiliary/util/u_double_list.h @@ -95,5 +95,8 @@ struct list_head #define LIST_ENTRY(__type, __item, __field) \ ((__type *)(((char *)(__item)) - offsetof(__type, __field))) +#define LIST_IS_EMPTY(__list) \ + ((__list)->next == (__list)) + #endif /*_U_DOUBLE_LIST_H_*/ -- cgit v1.2.3 From 1196885293f19003472276a6446a1904e9c69112 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 20 Mar 2009 23:06:05 +0100 Subject: trace: Fix args to buffer write --- src/gallium/drivers/trace/tr_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 954576d7217..c83ec4e30e6 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -706,7 +706,7 @@ trace_screen_buffer_unmap(struct pipe_screen *_screen, struct pipe_buffer *buffer = tr_buf->buffer; if (tr_buf->map && !tr_buf->range_flushed) - buffer_write(screen, buffer, tr_buf->map, 0, buffer->size); + buffer_write(screen, buffer, 0, tr_buf->map, buffer->size); tr_buf->map = NULL; tr_buf->range_flushed = FALSE; screen->buffer_unmap(screen, buffer); -- cgit v1.2.3 From da96767c8971e792285e3190c708438d65802379 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 21 Mar 2009 14:23:04 +0100 Subject: debug: Add function for writing transfers to files --- src/gallium/auxiliary/util/u_debug.c | 71 ++++++++++++++++++++---------------- src/gallium/auxiliary/util/u_debug.h | 3 ++ 2 files changed, 42 insertions(+), 32 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index f96e27e09fd..0af69d8c8f0 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -715,78 +715,85 @@ struct bmp_rgb_quad { uint8_t rgbAlpha; }; -void +void debug_dump_surface_bmp(const char *filename, struct pipe_surface *surface) { -#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT + struct pipe_transfer *transfer; struct pipe_texture *texture; struct pipe_screen *screen; + + transfer = screen->get_tex_transfer(screen, texture, surface->face, + surface->level, surface->zslice, + PIPE_TRANSFER_READ, 0, 0, surface->width, + surface->height); + + debug_dump_transfer_bmp(filename, transfer); + + screen->tex_transfer_destroy(transfer); +} + +void +debug_dump_transfer_bmp(const char *filename, + struct pipe_transfer *transfer) +{ +#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT struct util_stream *stream; - struct pipe_transfer *transfer; struct bmp_file_header bmfh; struct bmp_info_header bmih; float *rgba; unsigned x, y; - if (!surface) + if (!transfer) goto error1; - rgba = MALLOC(surface->width*4*sizeof(float)); + rgba = MALLOC(transfer->width*transfer->height*4*sizeof(float)); if(!rgba) goto error1; - + bmfh.bfType = 0x4d42; - bmfh.bfSize = 14 + 40 + surface->height*surface->width*4; + bmfh.bfSize = 14 + 40 + transfer->height*transfer->width*4; bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; bmfh.bfOffBits = 14 + 40; - + bmih.biSize = 40; - bmih.biWidth = surface->width; - bmih.biHeight = surface->height; + bmih.biWidth = transfer->width; + bmih.biHeight = transfer->height; bmih.biPlanes = 1; bmih.biBitCount = 32; bmih.biCompression = 0; - bmih.biSizeImage = surface->height*surface->width*4; + bmih.biSizeImage = transfer->height*transfer->width*4; bmih.biXPelsPerMeter = 0; bmih.biYPelsPerMeter = 0; bmih.biClrUsed = 0; bmih.biClrImportant = 0; - + stream = util_stream_create(filename, bmfh.bfSize); if(!stream) goto error2; - + util_stream_write(stream, &bmfh, 14); util_stream_write(stream, &bmih, 40); - texture = surface->texture; - screen = texture->screen; - - transfer = screen->get_tex_transfer(screen, texture, surface->face, - surface->level, surface->zslice, - PIPE_TRANSFER_READ, 0, 0, surface->width, - surface->height); + pipe_get_tile_rgba(transfer, 0, 0, + transfer->width, transfer->height, + rgba); - y = surface->height; + y = transfer->height; while(y--) { - pipe_get_tile_rgba(transfer, - 0, y, surface->width, 1, - rgba); - for(x = 0; x < surface->width; ++x) + float *ptr = rgba + (transfer->width * y * 4); + for(x = 0; x < transfer->width; ++x) { struct bmp_rgb_quad pixel; - pixel.rgbRed = float_to_ubyte(rgba[x*4 + 0]); - pixel.rgbGreen = float_to_ubyte(rgba[x*4 + 1]); - pixel.rgbBlue = float_to_ubyte(rgba[x*4 + 2]); - pixel.rgbAlpha = float_to_ubyte(rgba[x*4 + 3]); + pixel.rgbRed = float_to_ubyte(ptr[x*4 + 0]); + pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]); + pixel.rgbBlue = float_to_ubyte(ptr[x*4 + 2]); + pixel.rgbAlpha = 255; util_stream_write(stream, &pixel, 4); - } + } } - screen->tex_transfer_destroy(transfer); - util_stream_close(stream); error2: FREE(rgba); diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 7c829707b20..33e7cb3419e 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -338,6 +338,7 @@ debug_profile_stop(void); #ifdef DEBUG struct pipe_surface; +struct pipe_transfer; void debug_dump_image(const char *prefix, unsigned format, unsigned cpp, unsigned width, unsigned height, @@ -347,6 +348,8 @@ void debug_dump_surface(const char *prefix, struct pipe_surface *surface); void debug_dump_surface_bmp(const char *filename, struct pipe_surface *surface); +void debug_dump_transfer_bmp(const char *filename, + struct pipe_transfer *transfer); #else #define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0) #define debug_dump_surface(prefix, surface) ((void)0) -- cgit v1.2.3 From e9d156e9e4f92ae1ce70bd563c251b34d238c4bc Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Mon, 23 Mar 2009 18:03:13 +0100 Subject: gallium: Remove remnants of reference counting internals outside of p_refcnt.h. --- src/gallium/auxiliary/pipebuffer/pb_buffer.h | 8 ++++---- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 8 ++++---- src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c | 6 +++--- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 4 ++-- src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 2 +- src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | 4 ++-- src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 2 +- src/gallium/drivers/softpipe/sp_texture.c | 1 - src/gallium/include/pipe/p_refcnt.h | 12 ++++++++++-- src/mesa/state_tracker/st_texture.c | 2 +- 10 files changed, 28 insertions(+), 21 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index 2a1315922a8..92b6fd00564 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h @@ -158,7 +158,7 @@ pb_map(struct pb_buffer *buf, assert(buf); if(!buf) return NULL; - assert(p_atomic_read(&buf->base.reference.count) > 0); + assert(pipe_is_referenced(&buf->base.reference)); return buf->vtbl->map(buf, flags); } @@ -169,7 +169,7 @@ pb_unmap(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(p_atomic_read(&buf->base.reference.count) > 0); + assert(pipe_is_referenced(&buf->base.reference)); buf->vtbl->unmap(buf); } @@ -185,7 +185,7 @@ pb_get_base_buffer( struct pb_buffer *buf, offset = 0; return; } - assert(p_atomic_read(&buf->base.reference.count) > 0); + assert(pipe_is_referenced(&buf->base.reference)); assert(buf->vtbl->get_base_buffer); buf->vtbl->get_base_buffer(buf, base_buf, offset); assert(*base_buf); @@ -221,7 +221,7 @@ pb_destroy(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(p_atomic_read(&buf->base.reference.count) == 0); + assert(!pipe_is_referenced(&buf->base.reference)); buf->vtbl->destroy(buf); } diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 1bdf7a0b2da..48d76a7af79 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -115,7 +115,7 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf) { struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(p_atomic_read(&fenced_buf->base.base.reference.count)); + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(fenced_buf->fence); @@ -137,7 +137,7 @@ _fenced_buffer_destroy(struct fenced_buffer *fenced_buf) { struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); assert(!fenced_buf->fence); #ifdef DEBUG assert(fenced_buf->head.prev); @@ -181,7 +181,7 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list, * FIXME!!! */ - if(!p_atomic_read(&fenced_buf->base.base.reference.count)) + if(!pipe_is_referenced(&fenced_buf->base.base.reference)) _fenced_buffer_destroy(fenced_buf); } @@ -257,7 +257,7 @@ fenced_buffer_destroy(struct pb_buffer *buf) struct fenced_buffer_list *fenced_list = fenced_buf->list; pipe_mutex_lock(fenced_list->mutex); - assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); if (fenced_buf->fence) { struct pb_fence_ops *ops = fenced_list->ops; if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 010a2ecc1fa..35358430b43 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -112,7 +112,7 @@ _pb_cache_buffer_destroy(struct pb_cache_buffer *buf) LIST_DEL(&buf->head); assert(mgr->numDelayed); --mgr->numDelayed; - assert(p_atomic_read(&buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&buf->base.base.reference)); pb_reference(&buf->buffer, NULL); FREE(buf); } @@ -153,7 +153,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf) struct pb_cache_manager *mgr = buf->mgr; pipe_mutex_lock(mgr->mutex); - assert(p_atomic_read(&buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&buf->base.base.reference)); _pb_cache_buffer_list_check_free(mgr); @@ -310,7 +310,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, return NULL; } - assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1); + assert(pipe_is_referenced(&buf->buffer->base.reference)); assert(pb_check_alignment(desc->alignment, buf->buffer->base.alignment)); assert(pb_check_usage(desc->usage, buf->buffer->base.usage)); assert(buf->buffer->base.size >= size); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index 478682dbee9..f1a05be46e4 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -208,7 +208,7 @@ pb_debug_buffer_destroy(struct pb_buffer *_buf) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); - assert(p_atomic_read(&buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&buf->base.base.reference)); pb_debug_buffer_check(buf); @@ -315,7 +315,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, return NULL; } - assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1); + assert(pipe_is_referenced(&buf->buffer->base.reference)); assert(pb_check_alignment(real_desc.alignment, buf->buffer->base.alignment)); assert(pb_check_usage(real_desc.usage, buf->buffer->base.usage)); assert(buf->buffer->base.size >= real_size); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index fb18dcc5dca..5a342fbf3b1 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -97,7 +97,7 @@ mm_buffer_destroy(struct pb_buffer *buf) struct mm_buffer *mm_buf = mm_buffer(buf); struct mm_pb_manager *mm = mm_buf->mgr; - assert(p_atomic_read(&mm_buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&mm_buf->base.base.reference)); pipe_mutex_lock(mm->mutex); u_mmFreeMem(mm_buf->block); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index 75b95e132e8..07fd1a22d93 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -108,7 +108,7 @@ pool_buffer_destroy(struct pb_buffer *buf) struct pool_buffer *pool_buf = pool_buffer(buf); struct pool_pb_manager *pool = pool_buf->mgr; - assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&pool_buf->base.base.reference)); pipe_mutex_lock(pool->mutex); LIST_ADD(&pool_buf->head, &pool->free); @@ -216,7 +216,7 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr, pipe_mutex_unlock(pool->mutex); pool_buf = LIST_ENTRY(struct pool_buffer, item, head); - assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&pool_buf->base.base.reference)); pipe_reference_init(&pool_buf->base.base.reference, 1); pool_buf->base.base.alignment = desc->alignment; pool_buf->base.base.usage = desc->usage; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index a431fd5211e..724aaadb436 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -202,7 +202,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf) pipe_mutex_lock(mgr->mutex); - assert(p_atomic_read(&buf->base.base.reference.count) == 0); + assert(!pipe_is_referenced(&buf->base.base.reference)); buf->mapCount = 0; diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 48b2c22af45..e3c577c2494 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -138,7 +138,6 @@ softpipe_texture_create(struct pipe_screen *screen, goto fail; } - assert(p_atomic_read(&spt->base.reference.count) == 1); return &spt->base; fail: diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h index 60844e40a57..1f89453e09a 100644 --- a/src/gallium/include/pipe/p_refcnt.h +++ b/src/gallium/include/pipe/p_refcnt.h @@ -51,6 +51,13 @@ pipe_reference_init(struct pipe_reference *reference, unsigned count) } +static INLINE bool +pipe_is_referenced(struct pipe_reference *reference) +{ + return p_atomic_read(&reference->count) != 0; +} + + /** * Set 'ptr' to point to 'reference' and update reference counting. * The old thing pointed to, if any, will be unreferenced first. @@ -65,12 +72,12 @@ pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference) /* bump the reference.count first */ if (reference) { - assert(p_atomic_read(&reference->count) != 0); + assert(pipe_is_referenced(reference)); p_atomic_inc(&reference->count); } if (*ptr) { - assert(p_atomic_read(&(*ptr)->count) != 0); + assert(pipe_is_referenced(*ptr)); if (p_atomic_dec_zero(&(*ptr)->count)) { destroy = TRUE; } @@ -81,6 +88,7 @@ pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference) return destroy; } + #ifdef __cplusplus } #endif diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 6f274d6d69b..3f90ad502c2 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -107,7 +107,7 @@ st_texture_create(struct st_context *st, newtex = screen->texture_create(screen, &pt); - assert(!newtex || p_atomic_read(&newtex->reference.count) == 1); + assert(!newtex || pipe_is_referenced(&newtex->reference)); return newtex; } -- cgit v1.2.3 From d0d5e6a22cca4aae487be6828d1dd87621929a7d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 23 Mar 2009 18:38:11 +0000 Subject: draw: update aa points shader comment --- src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 5008086cf26..3133abe5dc7 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -286,7 +286,7 @@ aa_transform_inst(struct tgsi_transform_context *ctx, ctx->emit_instruction(ctx, &newInst); #endif - /* SGT t0.y, t0.xxxx, t0.wwww; # bool b = d > 1 (NOTE t0.w == 1) */ + /* SGT t0.y, t0.xxxx, tex.wwww; # bool b = d > 1 (NOTE tex.w == 1) */ newInst = tgsi_default_full_instruction(); newInst.Instruction.Opcode = TGSI_OPCODE_SGT; newInst.Instruction.NumDstRegs = 1; -- cgit v1.2.3 From cc8afbd3862fedfe42e51c3774960d1c7078ec53 Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Tue, 24 Mar 2009 09:53:22 -0600 Subject: i965: fix point rasterization when rendering to FBO The FBO pixel coordinate system, with (0,0) as the upper-left pixel, is inverted in Y compared to the normal OpenGL pixel coordinate system, which has (0,0) as its lower-left pixel. Viewport and polygon stipple are sensitive to this inversion; so is point rasterization. The basic fix is simple: when rendering to an FBO, instead of the normal RASTRULE_UPPER_RIGHT that's appropriate for OpenGL windows, use the Y inversion RASTRULE_LOWER_RIGHT. Unfortunately, current Intel documentation has this value listed as "Reserved, but not seen as useful". It does work on at least some i965-class devices, though; and the worst that could happen if an older device didn't support it would be incorrect point rasterization to FBOs, which is what happens already, so this fix is at least no worse than what happens presently, and is better for some (and possibly all) i965-class devices. --- src/gallium/drivers/i965simple/brw_defines.h | 18 ++++++++++++++++++ src/mesa/drivers/dri/i965/brw_defines.h | 18 ++++++++++++++++++ src/mesa/drivers/dri/i965/brw_sf_state.c | 28 +++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965simple/brw_defines.h b/src/gallium/drivers/i965simple/brw_defines.h index 9379a397f63..715d2d2d011 100644 --- a/src/gallium/drivers/i965simple/brw_defines.h +++ b/src/gallium/drivers/i965simple/brw_defines.h @@ -289,6 +289,24 @@ #define BRW_RASTRULE_UPPER_LEFT 0 #define BRW_RASTRULE_UPPER_RIGHT 1 +/* These are listed as "Reserved, but not seen as useful" + * in Intel documentation (page 212, "Point Rasterization Rule", + * section 7.4 "SF Pipeline State Summary", of document + * "Intel® 965 Express Chipset Family and Intel® G35 Express + * Chipset Graphics Controller Programmer's Reference Manual, + * Volume 2: 3D/Media", Revision 1.0b as of January 2008, + * available at + * http://intellinuxgraphics.org/documentation.html + * at the time of this writing). + * + * These appear to be supported on at least some + * i965-family devices, and the BRW_RASTRULE_LOWER_RIGHT + * is useful when using OpenGL to render to a FBO + * (which has the pixel coordinate Y orientation inverted + * with respect to the normal OpenGL pixel coordinate system). + */ +#define BRW_RASTRULE_LOWER_LEFT 2 +#define BRW_RASTRULE_LOWER_RIGHT 3 #define BRW_RENDERTARGET_CLAMPRANGE_UNORM 0 #define BRW_RENDERTARGET_CLAMPRANGE_SNORM 1 diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 590b064c7ef..74dbba4fdd1 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -225,6 +225,24 @@ #define BRW_RASTRULE_UPPER_LEFT 0 #define BRW_RASTRULE_UPPER_RIGHT 1 +/* These are listed as "Reserved, but not seen as useful" + * in Intel documentation (page 212, "Point Rasterization Rule", + * section 7.4 "SF Pipeline State Summary", of document + * "Intel® 965 Express Chipset Family and Intel® G35 Express + * Chipset Graphics Controller Programmer's Reference Manual, + * Volume 2: 3D/Media", Revision 1.0b as of January 2008, + * available at + * http://intellinuxgraphics.org/documentation.html + * at the time of this writing). + * + * These appear to be supported on at least some + * i965-family devices, and the BRW_RASTRULE_LOWER_RIGHT + * is useful when using OpenGL to render to a FBO + * (which has the pixel coordinate Y orientation inverted + * with respect to the normal OpenGL pixel coordinate system). + */ +#define BRW_RASTRULE_LOWER_LEFT 2 +#define BRW_RASTRULE_LOWER_RIGHT 3 #define BRW_RENDERTARGET_CLAMPRANGE_UNORM 0 #define BRW_RENDERTARGET_CLAMPRANGE_SNORM 1 diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 93a9686f718..fc4eddda0a5 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -231,7 +231,33 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key, sf.sf6.line_width = 0; /* _NEW_POINT */ - sf.sf6.point_rast_rule = BRW_RASTRULE_UPPER_RIGHT; /* opengl conventions */ + key->render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0; + if (!key->render_to_fbo) { + /* Rendering to an OpenGL window */ + sf.sf6.point_rast_rule = BRW_RASTRULE_UPPER_RIGHT; + } + else { + /* If rendering to an FBO, the pixel coordinate system is + * inverted with respect to the normal OpenGL coordinate + * system, so BRW_RASTRULE_LOWER_RIGHT is correct. + * But this value is listed as "Reserved, but not seen as useful" + * in Intel documentation (page 212, "Point Rasterization Rule", + * section 7.4 "SF Pipeline State Summary", of document + * "Intel® 965 Express Chipset Family and Intel® G35 Express + * Chipset Graphics Controller Programmer's Reference Manual, + * Volume 2: 3D/Media", Revision 1.0b as of January 2008, + * available at + * http://intellinuxgraphics.org/documentation.html + * at the time of this writing). + * + * It does work on at least some devices, if not all; + * if devices that don't support it can be identified, + * the likely failure case is that points are rasterized + * incorrectly, which is no worse than occurs without + * the value, so we're using it here. + */ + sf.sf6.point_rast_rule = BRW_RASTRULE_LOWER_RIGHT; + } /* XXX clamp max depends on AA vs. non-AA */ sf.sf7.sprite_point = key->point_sprite; -- cgit v1.2.3 From 578af516104bf0078cf93b1b9dd783e19e113177 Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Tue, 24 Mar 2009 18:55:37 -0400 Subject: nouveau: Frontbuffer needs to be marked as linear. --- src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c index c4cbbc21248..0b45b1ff1f6 100644 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c +++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c @@ -199,7 +199,8 @@ dri_surface_from_handle(struct pipe_screen *screen, return NULL; memset(&templat, 0, sizeof(templat)); - templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; + templat.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY | + NOUVEAU_TEXTURE_USAGE_LINEAR; templat.target = PIPE_TEXTURE_2D; templat.last_level = 0; templat.depth[0] = 1; -- cgit v1.2.3 From 88b19bbe651e4362d0bc96eb6ec10218c2ef6cf2 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 25 Mar 2009 12:09:58 +1000 Subject: nouveau: fix some pipe_buffer reference counting issues --- src/gallium/drivers/nouveau/nouveau_stateobj.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h index 97859110b5f..a54820e8512 100644 --- a/src/gallium/drivers/nouveau/nouveau_stateobj.h +++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h @@ -46,9 +46,12 @@ static INLINE void so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) { struct nouveau_stateobj *so = *pso; + int i; if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) { free(so->push); + for (i = 0; i < so->cur_reloc; i++) + pipe_buffer_reference(&so->reloc[i].bo, NULL); free(so->reloc); free(so); } @@ -83,7 +86,8 @@ so_reloc(struct nouveau_stateobj *so, struct pipe_buffer *bo, { struct nouveau_stateobj_reloc *r = &so->reloc[so->cur_reloc++]; - r->bo = bo; + r->bo = NULL; + pipe_buffer_reference(&r->bo, bo); r->offset = so->cur - so->push; r->packet = so->cur_packet; r->data = data; -- cgit v1.2.3 From c306bf94d6ae20ce75965b1ae13213e24c976ed7 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 25 Mar 2009 12:16:25 +1000 Subject: nv50: fix typo in nv50_query.c --- src/gallium/drivers/nv50/nv50_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index a2c56f99a89..35cebdbdc32 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -41,7 +41,7 @@ nv50_query(struct pipe_query *pipe) static struct pipe_query * nv50_query_create(struct pipe_context *pipe, unsigned type) { - struct pipe_screen *screen = pipe->winsys; + struct pipe_screen *screen = pipe->screen; struct nv50_query *q = CALLOC_STRUCT(nv50_query); assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER); -- cgit v1.2.3 From e36f01a7a195a747c7d40bc0bab0bfbd00f0a5a7 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 25 Mar 2009 05:48:07 -0700 Subject: r300-gallium: r500-fs: Remove unused variable. --- src/gallium/drivers/r300/r300_state_shader.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index 20b83bd15b1..b5dc1a61b0e 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -371,7 +371,6 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs, struct r300_fs_asm* assembler, struct tgsi_full_instruction* inst) { - int i; /* Switch between opcodes. When possible, prefer using the official * AMD/ATI names for opcodes, please, as it facilitates using the * documentation. */ -- cgit v1.2.3 From 1db736f74a911f74228d6843f4d981eeafb8669d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 25 Mar 2009 06:24:39 -0700 Subject: r300-gallium: Unify shader interfaces, enable r300 shader, start unbreaking. progs/trivial/clear no longer is horrifically wrong, just kind of wrong. --- src/gallium/drivers/r300/r300_emit.c | 2 +- src/gallium/drivers/r300/r300_state.c | 6 +- src/gallium/drivers/r300/r300_state_shader.c | 102 +++++++++++++++++++++------ src/gallium/drivers/r300/r300_state_shader.h | 5 +- 4 files changed, 84 insertions(+), 31 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 9bfb89626cd..bf190a7dcdc 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -87,7 +87,7 @@ void r300_emit_fragment_shader(struct r300_context* r300, BEGIN_CS(22); - OUT_CS_REG(R300_US_CONFIG, MAX2(fs->indirections - 1, 0)); + OUT_CS_REG(R300_US_CONFIG, fs->indirections); OUT_CS_REG(R300_US_PIXSIZE, fs->shader.stack_size); /* XXX figure out exactly how big the sizes are on this reg */ OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 2a026e7fcac..8c38f7c706e 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -293,11 +293,7 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) r300->fs = NULL; return; } else if (!fs->translated) { - if (r300_screen(r300->context.screen)->caps->is_r500) { - r500_translate_fragment_shader(r300, (struct r500_fragment_shader*)fs); - } else { - r300_translate_fragment_shader(r300, (struct r300_fragment_shader*)fs); - } + r300_translate_fragment_shader(r300, fs); } fs->translated = TRUE; diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index b5dc1a61b0e..7d81cb87a24 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -171,6 +171,26 @@ static INLINE uint32_t r500_alpha_swiz(struct tgsi_full_src_register* reg) (reg->SrcRegisterExtMod.Absolute ? (1 << 10) : 0); } +static INLINE uint32_t r300_rgb_op(unsigned op) +{ + switch (op) { + case TGSI_OPCODE_MOV: + return R300_ALU_OUTC_CMP; + default: + return 0; + } +} + +static INLINE uint32_t r300_alpha_op(unsigned op) +{ + switch (op) { + case TGSI_OPCODE_MOV: + return R300_ALU_OUTA_CMP; + default: + return 0; + } +} + static INLINE uint32_t r500_rgba_op(unsigned op) { switch (op) { @@ -249,6 +269,33 @@ static INLINE uint32_t r500_tex_op(unsigned op) } } +static INLINE void r300_emit_maths(struct r300_fragment_shader* fs, + struct r300_fs_asm* assembler, + struct tgsi_full_src_register* src, + struct tgsi_full_dst_register* dst, + unsigned op, + unsigned count) +{ + int i = fs->alu_instruction_count; + + fs->instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | + R300_RGB_SWIZB(R300_ALU_ARGC_ONE) | + R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) | + R300_ALU_OUTC_MAD; + fs->instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | + R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ; + fs->instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | + R300_ALPHA_SWIZB(R300_ALU_ARGA_ONE) | + R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) | + R300_ALU_OUTA_MAD; + fs->instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) | + R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT; + + fs->alu_instruction_count++; + fs->indirections = 0; + fs->shader.stack_size = 2; +} + /* Setup an ALU operation. */ static INLINE void r500_emit_alu(struct r500_fragment_shader* fs, struct r300_fs_asm* assembler, @@ -367,6 +414,27 @@ static INLINE void r500_emit_tex(struct r500_fragment_shader* fs, } } +static void r300_fs_instruction(struct r300_fragment_shader* fs, + struct r300_fs_asm* assembler, + struct tgsi_full_instruction* inst) +{ + switch (inst->Instruction.Opcode) { + case TGSI_OPCODE_MOV: + /* src0 -> src1 and src2 forced to zero */ + inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0]; + inst->FullSrcRegisters[2] = r500_constant_zero; + r300_emit_maths(fs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3); + break; + case TGSI_OPCODE_END: + break; + default: + debug_printf("r300: fs: Bad opcode %d\n", + inst->Instruction.Opcode); + break; + } +} + static void r500_fs_instruction(struct r500_fragment_shader* fs, struct r300_fs_asm* assembler, struct tgsi_full_instruction* inst) @@ -497,24 +565,11 @@ static void r500_fs_finalize(struct r500_fragment_shader* fs, } void r300_translate_fragment_shader(struct r300_context* r300, - struct r300_fragment_shader* fs) -{ - struct tgsi_parse_context parser; - - tgsi_parse_init(&parser, fs->shader.state.tokens); - - while (!tgsi_parse_end_of_tokens(&parser)) { - tgsi_parse_token(&parser); - } - - r300_copy_passthrough_shader(fs); -} - -void r500_translate_fragment_shader(struct r300_context* r300, - struct r500_fragment_shader* fs) + struct r3xx_fragment_shader* fs) { struct tgsi_parse_context parser; int i; + boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; struct r300_constant_buffer* consts = &r300->shader_constants[PIPE_SHADER_FRAGMENT]; @@ -525,7 +580,7 @@ void r500_translate_fragment_shader(struct r300_context* r300, /* Setup starting offset for immediates. */ assembler->imm_offset = consts->user_count; - tgsi_parse_init(&parser, fs->shader.state.tokens); + tgsi_parse_init(&parser, fs->state.tokens); while (!tgsi_parse_end_of_tokens(&parser)) { tgsi_parse_token(&parser); @@ -552,8 +607,13 @@ void r500_translate_fragment_shader(struct r300_context* r300, assembler->imm_count++; break; case TGSI_TOKEN_TYPE_INSTRUCTION: - r500_fs_instruction(fs, assembler, - &parser.FullToken.FullInstruction); + if (is_r500) { + r500_fs_instruction((struct r500_fragment_shader*)fs, + assembler, &parser.FullToken.FullInstruction); + } else { + r300_fs_instruction((struct r300_fragment_shader*)fs, + assembler, &parser.FullToken.FullInstruction); + } break; } @@ -567,10 +627,10 @@ void r500_translate_fragment_shader(struct r300_context* r300, debug_printf("r300: %d total constants, " "%d from user and %d from immediates\n", consts->count, consts->user_count, assembler->imm_count); - r500_fs_finalize(fs, assembler); + //r500_fs_finalize(fs, assembler); - tgsi_dump(fs->shader.state.tokens); - r500_fs_dump(fs); + tgsi_dump(fs->state.tokens); + //r500_fs_dump(fs); tgsi_parse_free(&parser); FREE(assembler); diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 06c0bb73789..fdba207e183 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -102,10 +102,7 @@ struct r300_fs_asm { }; void r300_translate_fragment_shader(struct r300_context* r300, - struct r300_fragment_shader* fs); - -void r500_translate_fragment_shader(struct r300_context* r300, - struct r500_fragment_shader* fs); + struct r3xx_fragment_shader* fs); static const struct r300_fragment_shader r300_passthrough_fragment_shader = { /* XXX This is the emission code. TODO: decode -- cgit v1.2.3 From def5660c9eed84f92838f9f7679deef94ab27c58 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 25 Mar 2009 07:15:07 -0700 Subject: r300-gallium: r300-fs: Moar. --- src/gallium/drivers/r300/r300_context.h | 5 +--- src/gallium/drivers/r300/r300_debug.c | 8 +++++++ src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/drivers/r300/r300_state_shader.c | 36 +++++++++++++++++----------- src/gallium/drivers/r300/r300_state_shader.h | 4 ++-- 5 files changed, 35 insertions(+), 22 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 0e5e471d116..ed6480bea79 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -169,10 +169,7 @@ struct r300_fragment_shader { int indirections; /* Indirection node offsets */ - int offset0; - int offset1; - int offset2; - int offset3; + int alu_offset[4]; /* Machine instructions */ struct { diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index f657588c720..8d44756c332 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -22,6 +22,14 @@ #include "r300_debug.h" +static void r300_dump_fs(struct r300_fragment_shader* fs) +{ + int i; + + for (i = 0; i < fs->alu_instruction_count; i++) { + } +} + static char* r500_fs_swiz[] = { " R", " G", diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index bf190a7dcdc..16455e48ce8 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -90,12 +90,12 @@ void r300_emit_fragment_shader(struct r300_context* r300, OUT_CS_REG(R300_US_CONFIG, fs->indirections); OUT_CS_REG(R300_US_PIXSIZE, fs->shader.stack_size); /* XXX figure out exactly how big the sizes are on this reg */ - OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); + OUT_CS_REG(R300_US_CODE_OFFSET, 0x40); /* XXX figure these ones out a bit better kthnx */ OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0); OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0); OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0); - OUT_CS_REG(R300_US_CODE_ADDR_3, R300_RGBA_OUT); + OUT_CS_REG(R300_US_CODE_ADDR_3, 0x40 | R300_RGBA_OUT); for (i = 0; i < fs->alu_instruction_count; i++) { OUT_CS_REG(R300_US_ALU_RGB_INST_0 + (4 * i), diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index 7d81cb87a24..ed9d26f0b9b 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -278,22 +278,20 @@ static INLINE void r300_emit_maths(struct r300_fragment_shader* fs, { int i = fs->alu_instruction_count; - fs->instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | - R300_RGB_SWIZB(R300_ALU_ARGC_ONE) | + fs->instructions[i].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | + R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) | R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) | - R300_ALU_OUTC_MAD; - fs->instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | + r300_rgb_op(op); + fs->instructions[i].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ; - fs->instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | - R300_ALPHA_SWIZB(R300_ALU_ARGA_ONE) | + fs->instructions[i].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | + R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) | R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) | - R300_ALU_OUTA_MAD; - fs->instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) | + r300_alpha_op(op); + fs->instructions[i].alu_alpha_addr = R300_ALPHA_ADDR0(0) | R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT; fs->alu_instruction_count++; - fs->indirections = 0; - fs->shader.stack_size = 2; } /* Setup an ALU operation. */ @@ -554,11 +552,15 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs, } } -static void r500_fs_finalize(struct r500_fragment_shader* fs, +static void r300_fs_finalize(struct r3xx_fragment_shader* fs, struct r300_fs_asm* assembler) { - fs->shader.stack_size = assembler->temp_count + assembler->temp_offset; + fs->stack_size = assembler->temp_count + assembler->temp_offset; +} +static void r500_fs_finalize(struct r500_fragment_shader* fs, + struct r300_fs_asm* assembler) +{ /* XXX should this just go with OPCODE_END? */ fs->instructions[fs->instruction_count - 1].inst0 |= R500_INST_LAST; @@ -627,10 +629,16 @@ void r300_translate_fragment_shader(struct r300_context* r300, debug_printf("r300: %d total constants, " "%d from user and %d from immediates\n", consts->count, consts->user_count, assembler->imm_count); - //r500_fs_finalize(fs, assembler); + r300_fs_finalize(fs, assembler); + if (is_r500) { + r500_fs_finalize((struct r500_fragment_shader*)fs, assembler); + } tgsi_dump(fs->state.tokens); - //r500_fs_dump(fs); + /* XXX finish r300 dumper too */ + if (is_r500) { + r500_fs_dump((struct r500_fragment_shader*)fs); + } tgsi_parse_free(&parser); FREE(assembler); diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index fdba207e183..e83d007ba20 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -115,8 +115,8 @@ static const struct r300_fragment_shader r300_passthrough_fragment_shader = { */ .alu_instruction_count = 1, .tex_instruction_count = 0, - .indirections = 1, - .shader.stack_size = 2, + .indirections = 0, + .shader.stack_size = 1, .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | R300_RGB_SWIZB(R300_ALU_ARGC_ONE) | -- cgit v1.2.3 From ad11107206ff4954366d77f334431b637ee256fa Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 23 Mar 2009 20:17:57 -0700 Subject: Add #ifdefs needed to compile Gallium on Solaris with gcc or Sun cc Signed-off-by: Alan Coopersmith --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 4 ++-- src/gallium/auxiliary/rtasm/rtasm_execmem.c | 6 +++--- src/gallium/auxiliary/util/u_stream_stdc.c | 2 +- src/gallium/auxiliary/util/u_time.c | 12 ++++++------ src/gallium/auxiliary/util/u_time.h | 6 +++--- src/gallium/drivers/trace/tr_dump.c | 4 ++-- src/gallium/include/pipe/p_compiler.h | 19 +++++++++++++++++++ src/gallium/include/pipe/p_config.h | 12 ++++++++---- src/gallium/include/pipe/p_thread.h | 10 +++++----- 9 files changed, 49 insertions(+), 26 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 48d76a7af79..2cd0b8a8cdf 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -36,7 +36,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #include #include #endif @@ -573,7 +573,7 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list) /* Wait on outstanding fences */ while (fenced_list->numDelayed) { pipe_mutex_unlock(fenced_list->mutex); -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) sched_yield(); #endif _fenced_buffer_list_check_free(fenced_list, 1); diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c index 1f0923b6831..01811d50114 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c +++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c @@ -42,7 +42,7 @@ #endif -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) /* @@ -118,7 +118,7 @@ rtasm_exec_free(void *addr) } -#else /* PIPE_OS_LINUX || PIPE_OS_BSD */ +#else /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */ /* * Just use regular memory. @@ -138,4 +138,4 @@ rtasm_exec_free(void *addr) } -#endif /* PIPE_OS_LINUX || PIPE_OS_BSD */ +#endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */ diff --git a/src/gallium/auxiliary/util/u_stream_stdc.c b/src/gallium/auxiliary/util/u_stream_stdc.c index 0ead45a7491..d8f648e5dd1 100644 --- a/src/gallium/auxiliary/util/u_stream_stdc.c +++ b/src/gallium/auxiliary/util/u_stream_stdc.c @@ -32,7 +32,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_OS_SOLARIS) #include diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c index 357d9360c90..8afe4fccf7b 100644 --- a/src/gallium/auxiliary/util/u_time.c +++ b/src/gallium/auxiliary/util/u_time.c @@ -35,7 +35,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #include #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) #include @@ -77,7 +77,7 @@ util_time_get_frequency(void) void util_time_get(struct util_time *t) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) gettimeofday(&t->tv, NULL); #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) LONGLONG temp; @@ -102,7 +102,7 @@ util_time_add(const struct util_time *t1, int64_t usecs, struct util_time *t2) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) t2->tv.tv_sec = t1->tv.tv_sec + usecs / 1000000; t2->tv.tv_usec = t1->tv.tv_usec + usecs % 1000000; #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) @@ -124,7 +124,7 @@ int64_t util_time_diff(const struct util_time *t1, const struct util_time *t2) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) return (t2->tv.tv_usec - t1->tv.tv_usec) + (t2->tv.tv_sec - t1->tv.tv_sec)*1000000; #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) @@ -144,7 +144,7 @@ util_time_micros( void ) util_time_get(&t1); -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) return t1.tv.tv_usec + t1.tv.tv_sec*1000000LL; #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) util_time_get_frequency(); @@ -166,7 +166,7 @@ static INLINE int util_time_compare(const struct util_time *t1, const struct util_time *t2) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) if (t1->tv.tv_sec < t2->tv.tv_sec) return -1; else if(t1->tv.tv_sec > t2->tv.tv_sec) diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h index 4346ce1fa45..6bca6077a2a 100644 --- a/src/gallium/auxiliary/util/u_time.h +++ b/src/gallium/auxiliary/util/u_time.h @@ -38,7 +38,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #include /* timeval */ #include /* usleep */ #endif @@ -58,7 +58,7 @@ extern "C" { */ struct util_time { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) struct timeval tv; #else int64_t counter; @@ -89,7 +89,7 @@ util_time_timeout(const struct util_time *start, const struct util_time *end, const struct util_time *curr); -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #define util_time_sleep usleep #else void diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index 6837c94542d..5fb020538ee 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -40,7 +40,7 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #include #endif @@ -239,7 +239,7 @@ boolean trace_dump_trace_begin() trace_dump_writes("\n"); trace_dump_writes("\n"); -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) /* Linux applications rarely cleanup GL / Gallium resources so catch * application exit here */ atexit(trace_dump_trace_close); diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index bc2a0a7ef3a..e6a67f8c2fd 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -124,11 +124,30 @@ typedef unsigned char boolean; # define INLINE inline # elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) # define INLINE __inline +# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +# define INLINE inline +# elif (__STDC_VERSION__ >= 199901L) /* C99 */ +# define INLINE inline # else # define INLINE # endif #endif +/* The __FUNCTION__ gcc variable is generally only used for debugging. + * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. + */ +#ifndef __FUNCTION__ +# if (!defined(__GNUC__) || (__GNUC__ < 2)) +# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +# define __FUNCTION__ __func__ +# else +# define __FUNCTION__ "" +# endif +# endif +#endif + + /* This should match linux gcc cdecl semantics everywhere, so that we * just codegen one calling convention on all platforms. diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h index 7f7657031d8..63238ea46e9 100644 --- a/src/gallium/include/pipe/p_config.h +++ b/src/gallium/include/pipe/p_config.h @@ -77,11 +77,11 @@ * Processor architecture */ -#if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) +#if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) || defined(__i386) /* Sun cc */ #define PIPE_ARCH_X86 #endif -#if defined(__x86_64__) /* gcc */ || defined(_M_X64) /* msvc */ || defined(_M_AMD64) /* msvc */ +#if defined(__x86_64__) /* gcc */ || defined(_M_X64) /* msvc */ || defined(_M_AMD64) /* msvc */ || defined(__x86_64) /* Sun cc */ #define PIPE_ARCH_X86_64 #endif @@ -115,6 +115,10 @@ #define PIPE_OS_BSD #endif +#if defined(__sun) +#define PIPE_OS_SOLARIS +#endif + #if defined(_WIN32) || defined(WIN32) #define PIPE_OS_WINDOWS #endif @@ -126,9 +130,9 @@ * NOTE: There is no way to auto-detect most of these. */ -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #define PIPE_SUBSYSTEM_DRI -#endif /* PIPE_OS_LINUX || PIPE_OS_BSD */ +#endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */ #if defined(PIPE_OS_WINDOWS) #if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h index a9cd77541d4..de55e99ed49 100644 --- a/src/gallium/include/pipe/p_thread.h +++ b/src/gallium/include/pipe/p_thread.h @@ -38,7 +38,7 @@ #include "pipe/p_compiler.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) #include /* POSIX threads headers */ #include /* for perror() */ @@ -210,7 +210,7 @@ typedef unsigned pipe_condvar; */ typedef struct { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) pthread_key_t key; #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) DWORD key; @@ -225,7 +225,7 @@ typedef struct { static INLINE void pipe_tsd_init(pipe_tsd *tsd) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { perror("pthread_key_create(): failed to allocate key for thread specific data"); exit(-1); @@ -242,7 +242,7 @@ pipe_tsd_get(pipe_tsd *tsd) if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) { pipe_tsd_init(tsd); } -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) return pthread_getspecific(tsd->key); #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) assert(0); @@ -259,7 +259,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value) if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) { pipe_tsd_init(tsd); } -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) if (pthread_setspecific(tsd->key, value) != 0) { perror("pthread_set_specific() failed"); exit(-1); -- cgit v1.2.3 From 26e27ba30884be927cf1bc21d39f32d6096a6678 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 19:24:16 +0000 Subject: scons: Support building with the Windows SDK. x86_64 is also supported. --- common.py | 2 +- scons/gallium.py | 7 +- scons/generic.py | 7 +- scons/winsdk.py | 139 ++++++++++++++++++++++++++++++++++++++ src/gallium/winsys/gdi/SConscript | 2 +- 5 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 scons/winsdk.py (limited to 'src/gallium') diff --git a/common.py b/common.py index 1a99df41c01..f1c6372abde 100644 --- a/common.py +++ b/common.py @@ -61,7 +61,7 @@ def AddOptions(opts): opts.Add(EnumOption('platform', 'target platform', default_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince'))) opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default', - allowed_values=('default', 'crossmingw', 'winddk'))) + allowed_values=('default', 'crossmingw', 'winsdk', 'winddk'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) diff --git a/scons/gallium.py b/scons/gallium.py index ecdeef06fdf..ed4f49c1d89 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -198,14 +198,17 @@ def generate(env): env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) + env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') + env['msvc'] = env['CC'] == 'cl' + # shortcuts debug = env['debug'] machine = env['machine'] platform = env['platform'] x86 = env['machine'] == 'x86' ppc = env['machine'] == 'ppc' - gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw' - msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw' + gcc = env['gcc'] + msvc = env['msvc'] # Put build output in a separate dir, which depends on the current # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample diff --git a/scons/generic.py b/scons/generic.py index 01a374e3633..764b626e588 100644 --- a/scons/generic.py +++ b/scons/generic.py @@ -303,14 +303,17 @@ def generate(env): # Load tool chain env.Tool(env['toolchain']) + env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') + env['msvc'] = env['CC'] == 'cl' + # shortcuts debug = env['debug'] machine = env['machine'] platform = env['platform'] x86 = env['machine'] == 'x86' ppc = env['machine'] == 'ppc' - gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw' - msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw' + gcc = env['gcc'] + msvc = env['msvc'] # C preprocessor options cppdefines = [] diff --git a/scons/winsdk.py b/scons/winsdk.py new file mode 100644 index 00000000000..255f9c5a654 --- /dev/null +++ b/scons/winsdk.py @@ -0,0 +1,139 @@ +"""winsdk + +Tool-specific initialization for Microsoft Windows SDK. + +""" + +# +# Copyright (c) 2001-2007 The SCons Foundation +# Copyright (c) 2008 Tungsten Graphics, Inc. +# Copyright (c) 2009 VMware, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +import os.path +import platform + +import SCons.Errors +import SCons.Util + +import msvc_sa +import mslib_sa +import mslink_sa + + +def get_vs_root(env): + # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7 + path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0') + return path + +def get_vs_paths(env): + vs_root = get_vs_root(env) + if vs_root is None: + raise SCons.Errors.InternalError, "WINSDK compiler not found" + + tool_path = os.path.join(vs_root, 'Common7', 'IDE') + + env.PrependENVPath('PATH', tool_path) + +def get_vc_root(env): + # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VC7 + path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0', 'VC') + return path + +def get_vc_paths(env): + vc_root = get_vc_root(env) + if vc_root is None: + raise SCons.Errors.InternalError, "WINSDK compiler not found" + + target_cpu = env['machine'] + + if target_cpu in ('generic', 'x86'): + bin_dir = 'bin' + lib_dir = 'lib' + elif target_cpu == 'x86_64': + # TODO: take in consideration the host cpu + bin_dir = r'bin\x86_amd64' + lib_dir = r'lib\amd64' + else: + raise SCons.Errors.InternalError, "Unsupported target machine" + include_dir = 'include' + + exe_path = os.path.join(vc_root, bin_dir) + include_path = os.path.join(vc_root, include_dir) + lib_path = os.path.join(vc_root, lib_dir) + + env.PrependENVPath('INCLUDE', include_path) + env.PrependENVPath('LIB', lib_path) + env.PrependENVPath('PATH', exe_path) + +def get_sdk_root(env): + if SCons.Util.can_read_reg: + key = r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder' + try: + path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key) + except SCons.Util.RegError: + pass + else: + return path + + return None + +def get_sdk_paths(env): + sdk_root = get_sdk_root(env) + if sdk_root is None: + raise SCons.Errors.InternalError, "WINSDK not found" + + target_cpu = env['machine'] + + bin_dir = 'Bin' + if target_cpu in ('generic', 'x86'): + lib_dir = 'Lib' + elif target_cpu == 'x86_64': + lib_dir = 'Lib/x64' + else: + raise SCons.Errors.InternalError, "Unsupported target machine" + include_dir = 'Include' + + exe_path = os.path.join(sdk_root, bin_dir) + include_path = os.path.join(sdk_root, include_dir) + lib_path = os.path.join(sdk_root, lib_dir) + + env.PrependENVPath('INCLUDE', include_path) + env.PrependENVPath('LIB', lib_path) + env.PrependENVPath('PATH', exe_path) + +def generate(env): + if not env.has_key('ENV'): + env['ENV'] = {} + + get_vs_paths(env) + get_vc_paths(env) + get_sdk_paths(env) + + msvc_sa.generate(env) + mslib_sa.generate(env) + mslink_sa.generate(env) + +def exists(env): + return get_vc_root(env) is not None and get_sdk_root(env) is not None + +# vim:set ts=4 sw=4 et: diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 72b5df8ca24..42290d7603e 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -21,7 +21,7 @@ if env['platform'] == 'windows': 'gdi_softpipe_winsys.c', ] - if env['toolchain'] == 'crossmingw': + if env['gcc']: sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def'] else: sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] -- cgit v1.2.3 From 079be0fd3f1d0f52f26a95756809ac4a2325ccb1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 20:56:34 +0000 Subject: draw: Use size_t (for x86_64). --- src/gallium/auxiliary/draw/draw_vertex.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h index c143cf23723..554f4ac3c18 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.h +++ b/src/gallium/auxiliary/draw/draw_vertex.h @@ -87,18 +87,17 @@ struct vertex_info } attrib[PIPE_MAX_SHADER_INPUTS]; }; -static INLINE int +static INLINE size_t draw_vinfo_size( const struct vertex_info *a ) { - return ((const char *)&a->attrib[a->num_attribs] - - (const char *)a); + return offsetof(const struct vertex_info, attrib[a->num_attribs]); } static INLINE int draw_vinfo_compare( const struct vertex_info *a, const struct vertex_info *b ) { - unsigned sizea = draw_vinfo_size( a ); + size_t sizea = draw_vinfo_size( a ); return memcmp( a, b, sizea ); } @@ -106,7 +105,7 @@ static INLINE void draw_vinfo_copy( struct vertex_info *dst, const struct vertex_info *src ) { - unsigned size = draw_vinfo_size( src ); + size_t size = draw_vinfo_size( src ); memcpy( dst, src, size ); } -- cgit v1.2.3 From 8c4bd92b68cf79ff94dc431f78a970bbab7e0d00 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 20:58:38 +0000 Subject: util: Don't use x86 asm on x86_64. --- src/gallium/auxiliary/util/u_debug.c | 10 +++++----- src/gallium/auxiliary/util/u_debug.h | 9 +++------ src/gallium/auxiliary/util/u_debug_stack.c | 2 +- src/gallium/auxiliary/util/u_math.h | 16 ++++++++++++---- 4 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 0af69d8c8f0..1b984425b59 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -169,18 +169,18 @@ void debug_print_blob( const char *name, #endif -void _debug_break(void) +#ifndef debug_break +void debug_break(void) { -#if defined(PIPE_ARCH_X86) && defined(PIPE_CC_GCC) - __asm("int3"); -#elif defined(PIPE_ARCH_X86) && defined(PIPE_CC_MSVC) - _asm {int 3}; +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) + DebugBreak(); #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) EngDebugBreak(); #else abort(); #endif } +#endif #ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 33e7cb3419e..5e88f3ebb1a 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -125,19 +125,16 @@ void debug_print_format(const char *msg, unsigned fmt ); #endif -void _debug_break(void); - - /** * Hard-coded breakpoint. */ #ifdef DEBUG #if defined(PIPE_ARCH_X86) && defined(PIPE_CC_GCC) #define debug_break() __asm("int3") -#elif defined(PIPE_ARCH_X86) && defined(PIPE_CC_MSVC) -#define debug_break() do { _asm {int 3} } while(0) +#elif defined(PIPE_CC_MSVC) +#define debug_break() __debugbreak() #else -#define debug_break() _debug_break() +void debug_break(void); #endif #else /* !DEBUG */ #define debug_break() ((void)0) diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c index 76068a65091..e5d61907c0e 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++ b/src/gallium/auxiliary/util/u_debug_stack.c @@ -49,7 +49,7 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace, #if defined(PIPE_CC_GCC) frame_pointer = ((const void **)__builtin_frame_address(1)); -#elif defined(PIPE_CC_MSVC) +#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86) __asm { mov frame_pointer, ebp } diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 1ecde7a9125..9268a9bb7ee 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -319,11 +319,21 @@ util_iround(float f) -#if defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86) /** * Find first bit set in word. Least significant bit is 1. * Return 0 if no bits set. */ +#if defined(_MSC_VER) && _MSC_VER >= 1300 +static INLINE +unsigned long ffs( unsigned long u ) +{ + unsigned long i; + if(_BitScanForward(&i, u)) + return i + 1; + else + return 0; +} +#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86) static INLINE unsigned ffs( unsigned u ) { @@ -339,9 +349,7 @@ unsigned ffs( unsigned u ) return i; } -#endif - -#ifdef __MINGW32__ +#elif defined(__MINGW32__) #define ffs __builtin_ffs #endif -- cgit v1.2.3 From 9fb46fb4c30fe01c9cb485f909aca502691aaa3b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 20:58:53 +0000 Subject: util: Use size_t (for x86_64). --- src/gallium/auxiliary/util/u_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_string.h b/src/gallium/auxiliary/util/u_string.h index 08c89bbf770..cc7992d7391 100644 --- a/src/gallium/auxiliary/util/u_string.h +++ b/src/gallium/auxiliary/util/u_string.h @@ -130,7 +130,7 @@ static INLINE char * util_strstr(const char *haystack, const char *needle) { const char *p = haystack; - int len = strlen(needle); + size_t len = strlen(needle); for (; (p = util_strchr(p, *needle)) != 0; p++) { if (util_strncmp(p, needle, len) == 0) { -- cgit v1.2.3 From 601a6a5839220605e353ea8cb82759b39542f9e5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:00:59 +0000 Subject: wgl: Use SetWindowLongPtr. --- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 17c96c411f7..024c9ad36af 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -167,10 +167,10 @@ framebuffer_create( */ fb->hWnd = WindowFromDC( hdc ); if (fb->hWnd != NULL) { - fb->WndProc = (WNDPROC) SetWindowLong( + fb->WndProc = (WNDPROC) SetWindowLongPtr( fb->hWnd, - GWL_WNDPROC, - (LONG) window_proc ); + GWLP_WNDPROC, + (LONG_PTR) window_proc ); } fb->next = fb_head; @@ -188,10 +188,10 @@ framebuffer_destroy( while (pfb != NULL) { if (pfb == fb) { if (fb->hWnd != NULL) { - SetWindowLong( + SetWindowLongPtr( fb->hWnd, - GWL_WNDPROC, - (LONG) fb->WndProc ); + GWLP_WNDPROC, + (LONG_PTR) fb->WndProc ); } *link = fb->next; -- cgit v1.2.3 From ce518f4b0f361189957f20ce642afe919da680ba Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:01:23 +0000 Subject: wgl: Use right integer type. --- src/gallium/state_trackers/wgl/shared/stw_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index 3c1eb1ad393..c5501727d4e 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -130,7 +130,7 @@ st_cleanup_thread(void) void st_cleanup(void) { - UINT_PTR i; + unsigned i; debug_printf("%s\n", __FUNCTION__); -- cgit v1.2.3 From 5381331f97e55db12cce30859a0156c69894f1d2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Mar 2009 21:18:54 +0000 Subject: python: s/num_cbufs/nr_cbufs/ --- src/gallium/state_trackers/python/retrace/interpreter.py | 2 +- src/gallium/state_trackers/python/samples/tri.py | 2 +- src/gallium/state_trackers/python/tests/texture.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index e6999a2211e..3050904ece3 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -396,7 +396,7 @@ class Context(Object): _state = gallium.Framebuffer() _state.width = state.width _state.height = state.height - _state.num_cbufs = state.num_cbufs + _state.nr_cbufs = state.nr_cbufs for i in range(len(state.cbufs)): _state.set_cbuf(i, state.cbufs[i]) _state.set_zsbuf(state.zsbuf) diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index d3ccb6c2f46..ae065c5b9ae 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -139,7 +139,7 @@ def test(dev): fb = Framebuffer() fb.width = width fb.height = height - fb.num_cbufs = 1 + fb.nr_cbufs = 1 fb.set_cbuf(0, _cbuf) ctx.set_framebuffer(fb) _cbuf.clear_value = 0x00000000 diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py index 880a61306c9..8cec57e2a60 100644 --- a/src/gallium/state_trackers/python/tests/texture.py +++ b/src/gallium/state_trackers/python/tests/texture.py @@ -234,7 +234,7 @@ class TextureTest(TestCase): fb = Framebuffer() fb.width = width fb.height = height - fb.num_cbufs = 1 + fb.nr_cbufs = 1 fb.set_cbuf(0, cbuf) ctx.set_framebuffer(fb) ctx.surface_clear(cbuf, 0x00000000) -- cgit v1.2.3 From ad5f9752ce7dc7b588a98e0c1ac820a3f918b4d5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Mar 2009 21:21:37 +0000 Subject: python: s/pitch/stride/ --- src/gallium/state_trackers/python/p_context.i | 4 ++-- src/gallium/state_trackers/python/retrace/interpreter.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 1fdbdf98b26..178ab0e24ef 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -151,7 +151,7 @@ struct st_context { } void set_vertex_buffer(unsigned index, - unsigned pitch, + unsigned stride, unsigned max_index, unsigned buffer_offset, struct st_buffer *buffer) @@ -160,7 +160,7 @@ struct st_context { struct pipe_vertex_buffer state; memset(&state, 0, sizeof(state)); - state.stride = pitch; + state.stride = stride; state.max_index = max_index; state.buffer_offset = buffer_offset; state.buffer = buffer ? buffer->buffer : NULL; diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 3050904ece3..6b9587bf2bf 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -424,7 +424,7 @@ class Context(Object): vbuf = vbufs[i] self.real.set_vertex_buffer( i, - pitch = vbuf.pitch, + stride = vbuf.stride, max_index = vbuf.max_index, buffer_offset = vbuf.buffer_offset, buffer = vbuf.buffer, @@ -452,7 +452,7 @@ class Context(Object): for velem in self.velems: vbuf = self.vbufs[velem.vertex_buffer_index] - offset = vbuf.buffer_offset + velem.src_offset + vbuf.pitch*index + offset = vbuf.buffer_offset + velem.src_offset + vbuf.stride*index format = { gallium.PIPE_FORMAT_R32_FLOAT: 'f', gallium.PIPE_FORMAT_R32G32_FLOAT: '2f', -- cgit v1.2.3 From 8ca95d812148209f78c1e2501c3183623dcae0b2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Mar 2009 21:24:31 +0000 Subject: python: Tweak instructions. --- src/gallium/state_trackers/python/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/README b/src/gallium/state_trackers/python/README index 8f45fb6d1b7..942f3c06c49 100644 --- a/src/gallium/state_trackers/python/README +++ b/src/gallium/state_trackers/python/README @@ -11,11 +11,11 @@ To build you'll need: Invoke scons on the top dir as - scons statetrackers=python + scons debug=yes statetrackers=python driver=softpipe,trace To use do - export PYTHONPATH=build/XXXX-XXXX-XXXX/gallium/state_trackers/python + export PYTHONPATH=$PWD/build/XXXX-XXXX-XXXX/gallium/state_trackers/python and then try running -- cgit v1.2.3 From a6ad0c86cab0f3044781ece33d3ac0388e238a36 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Mar 2009 21:35:10 +0000 Subject: python: Allow to dump all images to disk. --- src/gallium/state_trackers/python/retrace/interpreter.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 6b9587bf2bf..66d73ed903f 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -75,7 +75,13 @@ def show_image(surface): root.mainloop() +# Verbosity level: 0, 1, 2 verbose = 1 +# Dump images to disk instead of showing: True, False +images = False + + +image_no = 0 class Struct: @@ -538,7 +544,13 @@ class Context(Object): self.real.flush() if self.cbufs and self.cbufs[0]: - show_image(self.cbufs[0]) + if images: + global image_no + image_no += 1 + filename = 'cbuf_%04u.png' % image_no + save_image(filename, self.cbufs[0]) + else: + show_image(self.cbufs[0]) class Interpreter(parser.TraceDumper): -- cgit v1.2.3 From b52b78a2269e6f773fc02c9740e7f2e18cdf1699 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Mar 2009 21:39:16 +0000 Subject: python: List packages needed on debian systems. --- src/gallium/state_trackers/python/README | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/README b/src/gallium/state_trackers/python/README index 942f3c06c49..4281d9bdb0d 100644 --- a/src/gallium/state_trackers/python/README +++ b/src/gallium/state_trackers/python/README @@ -9,6 +9,10 @@ To build you'll need: * SWIG * Python Imaging Library with TK support (for the samples) +On a debian-based distro you can simply do: + + aptitude install python-dev scons swig python-imaging python-imaging-tk + Invoke scons on the top dir as scons debug=yes statetrackers=python driver=softpipe,trace -- cgit v1.2.3 From 5743483778ffe5b389d10b1651ae1e8951b397ee Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 10:22:05 +0000 Subject: python: Use Ansi escape codes regardless of output is a tty or not. --- src/gallium/state_trackers/python/retrace/format.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/format.py b/src/gallium/state_trackers/python/retrace/format.py index 0bf6baf0b94..d56d72f606f 100755 --- a/src/gallium/state_trackers/python/retrace/format.py +++ b/src/gallium/state_trackers/python/retrace/format.py @@ -27,6 +27,9 @@ ########################################################################## +import sys + + class Formatter: '''Plain formatter''' @@ -93,7 +96,7 @@ class AnsiFormatter(Formatter): def DefaultFormatter(stream): - if stream.isatty(): + if sys.platform in ('linux2', 'cygwin'): return AnsiFormatter(stream) else: return Formatter(stream) -- cgit v1.2.3 From 9d97c3d0be9e57226b6a438a90b71f36e0c99269 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 13:31:27 +0000 Subject: python/trace: Control the interpreter from command line options. --- .../state_trackers/python/retrace/interpreter.py | 80 +++++++++++++--------- .../state_trackers/python/retrace/parser.py | 40 ++++++++--- 2 files changed, 80 insertions(+), 40 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 66d73ed903f..23038c5c1c0 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -75,15 +75,6 @@ def show_image(surface): root.mainloop() -# Verbosity level: 0, 1, 2 -verbose = 1 -# Dump images to disk instead of showing: True, False -images = False - - -image_no = 0 - - class Struct: """C-like struct""" @@ -381,7 +372,7 @@ class Context(Object): self.real.set_clip(_state) def dump_constant_buffer(self, buffer): - if verbose < 2: + if not self.interpreter.verbosity(2): return data = buffer.read() @@ -447,7 +438,7 @@ class Context(Object): pass def dump_vertices(self, start, count): - if verbose < 2: + if not self.interpreter.verbosity(2): return for index in range(start, start + count): @@ -474,7 +465,7 @@ class Context(Object): sys.stdout.write('\t},\n') def dump_indices(self, ibuf, isize, start, count): - if verbose < 2: + if not self.interpreter.verbosity(2): return format = { @@ -506,51 +497,48 @@ class Context(Object): self.dump_vertices(start, count) self.real.draw_arrays(mode, start, count) - - self.dirty = True + self._set_dirty() def draw_elements(self, indexBuffer, indexSize, mode, start, count): - if verbose >= 2: + if self.interpreter.verbosity(2): minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) self.dump_vertices(minindex, maxindex - minindex) self.real.draw_elements(indexBuffer, indexSize, mode, start, count) - - self.dirty = True + self._set_dirty() def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count): - if verbose >= 2: + if self.interpreter.verbosity(2): minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) minindex = min(minindex, minIndex) maxindex = min(maxindex, maxIndex) self.dump_vertices(minindex, maxindex - minindex) self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count) - - self.dirty = True + self._set_dirty() + def _set_dirty(self): + if self.interpreter.options.step: + self._present() + else: + self.dirty = True + def flush(self, flags): self.real.flush(flags) if self.dirty: if flags & gallium.PIPE_FLUSH_FRAME: - self._update() + self._present() self.dirty = False return None def clear(self, surface, value): self.real.surface_clear(surface, value) - def _update(self): + def _present(self): self.real.flush() if self.cbufs and self.cbufs[0]: - if images: - global image_no - image_no += 1 - filename = 'cbuf_%04u.png' % image_no - save_image(filename, self.cbufs[0]) - else: - show_image(self.cbufs[0]) + self.interpreter.present(self.cbufs[0], "cbuf") class Interpreter(parser.TraceDumper): @@ -561,11 +549,13 @@ class Interpreter(parser.TraceDumper): ('pipe_screen', 'get_paramf'), )) - def __init__(self, stream): + def __init__(self, stream, options): parser.TraceDumper.__init__(self, stream) + self.options = options self.objects = {} self.result = None self.globl = Global(self, None) + self.image_no = 0 def register_object(self, address, object): self.objects[address] = object @@ -586,7 +576,7 @@ class Interpreter(parser.TraceDumper): if (call.klass, call.method) in self.ignore_calls: return - if verbose >= 1: + if self.verbosity(1): parser.TraceDumper.handle_call(self, call) args = [self.interpret_arg(arg) for name, arg in call.args] @@ -606,7 +596,33 @@ class Interpreter(parser.TraceDumper): def interpret_arg(self, node): translator = Translator(self) return translator.visit(node) + + def verbosity(self, level): + return self.options.verbosity >= level + + def present(self, surface, description): + if self.options.images: + self.image_no += 1 + filename = '%s_%04u.png' % (description, self.image_no) + save_image(filename, surface) + else: + show_image(surface) +class Main(parser.Main): + + def get_optparser(self): + optparser = parser.Main.get_optparser(self) + 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("-s", "--step", action="store_true", dest="step", default=False, help="step trhough every draw") + return optparser + + def process_arg(self, stream, options): + parser = Interpreter(stream, options) + parser.parse() + + if __name__ == '__main__': - parser.main(Interpreter) + Main().main() diff --git a/src/gallium/state_trackers/python/retrace/parser.py b/src/gallium/state_trackers/python/retrace/parser.py index 5205f2d8dd5..db9bcc8226c 100755 --- a/src/gallium/state_trackers/python/retrace/parser.py +++ b/src/gallium/state_trackers/python/retrace/parser.py @@ -30,6 +30,7 @@ import sys import xml.parsers.expat import binascii +import optparse from model import * @@ -342,16 +343,39 @@ class TraceDumper(TraceParser): self.formatter.newline() -def main(ParserFactory): - for arg in sys.argv[1:]: - if arg.endswith('.gz'): - import gzip - stream = gzip.GzipFile(arg, 'rt') +class Main: + '''Common main class for all retrace command line utilities.''' + + def __init__(self): + pass + + def main(self): + optparser = self.get_optparser() + (options, args) = optparser.parse_args(sys.argv[1:]) + + if args: + for arg in args: + if arg.endswith('.gz'): + from gzip import GzipFile + stream = GzipFile(arg, 'rt') + elif arg.endswith('.bz2'): + from bz2 import BZ2File + stream = BZ2File(arg, 'rt') + else: + stream = open(arg, 'rt') + self.process_arg(stream, options) else: - stream = open(arg, 'rt') - parser = ParserFactory(stream) + self.process_arg(stream, options) + + def get_optparser(self): + optparser = optparse.OptionParser( + usage="\n\t%prog [options] [traces] ...") + return optparser + + def process_arg(self, stream, options): + parser = TraceDumper(stream) parser.parse() if __name__ == '__main__': - main(TraceDumper) + Main().main() -- cgit v1.2.3 From ecfa99ece1743769bbdb4371cf57229481993e91 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 13:44:32 +0000 Subject: python: Use a sequential number to identify each call. TODO: Modify the trace driver to generate these on the XML file itself. --- src/gallium/state_trackers/python/retrace/model.py | 4 +++- src/gallium/state_trackers/python/retrace/parser.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/model.py b/src/gallium/state_trackers/python/retrace/model.py index ae0f4327d76..d4a079fb1e5 100755 --- a/src/gallium/state_trackers/python/retrace/model.py +++ b/src/gallium/state_trackers/python/retrace/model.py @@ -101,7 +101,8 @@ class Pointer(Node): class Call: - def __init__(self, klass, method, args, ret): + def __init__(self, no, klass, method, args, ret): + self.no = no self.klass = klass self.method = method self.args = args @@ -187,6 +188,7 @@ class PrettyPrinter: self.formatter.address(node.address) def visit_call(self, node): + self.formatter.text('%s ' % node.no) if node.klass is not None: self.formatter.function(node.klass + '::' + node.method) else: diff --git a/src/gallium/state_trackers/python/retrace/parser.py b/src/gallium/state_trackers/python/retrace/parser.py index db9bcc8226c..b0f3e8a432f 100755 --- a/src/gallium/state_trackers/python/retrace/parser.py +++ b/src/gallium/state_trackers/python/retrace/parser.py @@ -190,6 +190,10 @@ class XmlParser: class TraceParser(XmlParser): + def __init__(self, fp): + XmlParser.__init__(self, fp) + self.last_call_no = 0 + def parse(self): self.element_start('trace') while self.token.type not in (ELEMENT_END, EOF): @@ -200,6 +204,13 @@ class TraceParser(XmlParser): def parse_call(self): attrs = self.element_start('call') + try: + no = int(attrs['no']) + except KeyError: + self.last_call_no += 1 + no = self.last_call_no + else: + self.last_call_no = no klass = attrs['class'] method = attrs['method'] args = [] @@ -217,7 +228,7 @@ class TraceParser(XmlParser): raise TokenMismatch(" or ", self.token) self.element_end('call') - return Call(klass, method, args, ret) + return Call(no, klass, method, args, ret) def parse_arg(self): attrs = self.element_start('arg') -- cgit v1.2.3 From 710bcc8050848766a85420d0425e51008943fc78 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 14:02:49 +0000 Subject: python/retrace: Use the call no when dumping images. To make it easy associate images with the calls. --- src/gallium/state_trackers/python/retrace/interpreter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 23038c5c1c0..6aaea2d65da 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -555,7 +555,7 @@ class Interpreter(parser.TraceDumper): self.objects = {} self.result = None self.globl = Global(self, None) - self.image_no = 0 + self.call_no = None def register_object(self, address, object): self.objects[address] = object @@ -576,6 +576,8 @@ class Interpreter(parser.TraceDumper): if (call.klass, call.method) in self.ignore_calls: return + self.call_no = call.no + if self.verbosity(1): parser.TraceDumper.handle_call(self, call) @@ -593,6 +595,8 @@ class Interpreter(parser.TraceDumper): if call.ret and isinstance(call.ret, model.Pointer): self.register_object(call.ret.address, ret) + self.call_no = None + def interpret_arg(self, node): translator = Translator(self) return translator.visit(node) @@ -602,8 +606,7 @@ class Interpreter(parser.TraceDumper): def present(self, surface, description): if self.options.images: - self.image_no += 1 - filename = '%s_%04u.png' % (description, self.image_no) + filename = '%s_%04u.png' % (description, self.call_no) save_image(filename, surface) else: show_image(surface) -- cgit v1.2.3 From 58351b5023c2d87c22e21a27fd238212040dab8b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 15:11:30 +0000 Subject: trace: Number calls. --- src/gallium/drivers/trace/tr_dump.c | 10 +++++++++- src/gallium/drivers/trace/trace.xsl | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index 5fb020538ee..97872be784d 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -265,8 +265,16 @@ void trace_dump_trace_end(void) void trace_dump_call_begin(const char *klass, const char *method) { + static long unsigned no = 0; + ++no; trace_dump_indent(1); - trace_dump_tag_begin2("call", "class", klass, "method", method); + trace_dump_writes(""); trace_dump_newline(); } diff --git a/src/gallium/drivers/trace/trace.xsl b/src/gallium/drivers/trace/trace.xsl index 9cd621e7ab9..7be95e0e753 100644 --- a/src/gallium/drivers/trace/trace.xsl +++ b/src/gallium/drivers/trace/trace.xsl @@ -68,6 +68,9 @@ along with this program. If not, see .
  • + + + :: -- cgit v1.2.3 From c847b4515314e11bee6463da908c665424cafa30 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 15:13:06 +0000 Subject: trace: Update readme. Actually, the trace driver with the xlib statetracker is still causing assertion failures here.. --- src/gallium/drivers/trace/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index f0e1cd596d3..73dce20372e 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -10,15 +10,14 @@ This directory contains a Gallium3D pipe driver which traces all incoming calls. To build, invoke scons on the top dir as - scons statetrackers=mesa drivers=softpipe,i965simple,trace winsys=xlib + scons dri=no statetrackers=mesa drivers=softpipe,i965simple,trace winsys=xlib = Usage = To use do - ln -s libGL.so build/linux-x86-debug/gallium/winsys/xlib/libGL.so.1 - export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/gallium/winsys/xlib + export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib ensure the right libGL.so is being picked by doing @@ -26,6 +25,7 @@ ensure the right libGL.so is being picked by doing and then try running + export XMESA_TRACE=y GALLIUM_TRACE=tri.trace progs/trivial/tri which should create a tri.trace file, which is an XML file. You can view copying -- cgit v1.2.3 From de89c022d5a2e63b52a9ae27ec70b9f5e203d3ed Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 15:36:51 +0000 Subject: python: Show call no in image window. --- src/gallium/state_trackers/python/retrace/interpreter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 6aaea2d65da..a22314d2000 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -54,14 +54,14 @@ def save_image(filename, surface): outimage = make_image(surface) outimage.save(filename, "PNG") -def show_image(surface): +def show_image(surface, title): outimage = make_image(surface) import Tkinter as tk from PIL import Image, ImageTk root = tk.Tk() - root.title('background image') + root.title(title) image1 = ImageTk.PhotoImage(outimage) w = image1.width() @@ -609,7 +609,8 @@ class Interpreter(parser.TraceDumper): filename = '%s_%04u.png' % (description, self.call_no) save_image(filename, surface) else: - show_image(surface) + title = '%u. %s' % (self.call_no, description) + show_image(surface, title) class Main(parser.Main): -- cgit v1.2.3 From 78abcb88fedd7177a5da93a987793d3a86a0ec57 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 25 Mar 2009 20:51:33 +0000 Subject: st/egl: Fix warning --- src/gallium/state_trackers/egl/egl_tracker.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index a22ef381b96..9667c7ee3d4 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -66,10 +66,13 @@ drm_get_device_id(struct drm_device *device) { char path[512]; FILE *file; + char *ret; /* TODO get the real minor */ int minor = 0; + device->deviceID = 0; + snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", minor); file = fopen(path, "r"); if (!file) { @@ -77,7 +80,10 @@ drm_get_device_id(struct drm_device *device) return; } - fgets(path, sizeof( path ), file); + ret = fgets(path, sizeof( path ), file); + if (!ret) + return; + sscanf(path, "%x", &device->deviceID); fclose(file); } -- cgit v1.2.3 From e21d31e8ab047966a3d6c6ee489e5cfe93819781 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 25 Mar 2009 20:51:47 +0000 Subject: st/egl: Set dpms to on when showing screens There is a wonderful bug in 2.6.29 that causes a hard lock on my computer when this code is active for lvds that are turned off. --- src/gallium/state_trackers/egl/egl_surface.c | 7 +++++++ src/gallium/state_trackers/egl/egl_tracker.c | 21 +++++++++++++++++++++ src/gallium/state_trackers/egl/egl_tracker.h | 3 +++ 3 files changed, 31 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index e6e80b985aa..ca545b12e68 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -330,6 +330,13 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, if (ret) goto err_crtc; + + if (scrn->dpms) + drmModeConnectorSetProperty(dev->drmFD, + scrn->connectorID, + scrn->dpms->prop_id, + DRM_MODE_DPMS_ON); + surf->screen = scrn; scrn->surf = surf; diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index 9667c7ee3d4..abdf84544f3 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -107,6 +107,25 @@ drm_add_modes_from_connector(_EGLScreen *screen, drmModeConnectorPtr connector) } } +static void +drm_find_dpms(struct drm_device *dev, struct drm_screen *screen) +{ + drmModeConnectorPtr c = screen->connector; + drmModePropertyPtr p; + int i; + + for (i = 0; i < c->count_props; i++) { + p = drmModeGetProperty(dev->drmFD, c->props[i]); + if (!strcmp(p->name, "DPMS")) + break; + + drmModeFreeProperty(p); + p = NULL; + } + + screen->dpms = p; +} + EGLBoolean drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) { @@ -160,6 +179,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) _eglInitScreen(&screen->base); _eglAddScreen(disp, &screen->base); drm_add_modes_from_connector(&screen->base, connector); + drm_find_dpms(dev, screen); dev->screens[num_screens++] = screen; } dev->count_screens = num_screens; @@ -206,6 +226,7 @@ drm_terminate(_EGLDriver *drv, EGLDisplay dpy) if (screen->shown) drm_takedown_shown_screen(drv, screen); + drmModeFreeProperty(screen->dpms); drmModeFreeConnector(screen->connector); _eglDestroyScreen(&screen->base); dev->screens[i] = NULL; diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h index 908bab5f9bf..ce2717de639 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.h +++ b/src/gallium/state_trackers/egl/egl_tracker.h @@ -114,6 +114,9 @@ struct drm_screen drmModeConnectorPtr connector; uint32_t connectorID; + /* dpms property */ + drmModePropertyPtr dpms; + /* Has this screen been shown */ int shown; -- cgit v1.2.3 From 573346da2a1de9a32b2673a5d4634aa6338da374 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:44:54 +0000 Subject: translate: Avoid unused variable warning. --- src/gallium/auxiliary/translate/translate.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/translate/translate.c b/src/gallium/auxiliary/translate/translate.c index 7678903f75c..a9b7253bf44 100644 --- a/src/gallium/auxiliary/translate/translate.c +++ b/src/gallium/auxiliary/translate/translate.c @@ -42,6 +42,8 @@ struct translate *translate_create( const struct translate_key *key ) translate = translate_sse2_create( key ); if (translate) return translate; +#else + (void)translate; #endif return translate_generic_create( key ); -- cgit v1.2.3 From e866cd7401e70f1e6494c8adf3983e916c7fa9cf Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:45:10 +0000 Subject: softpipe: Include declarations. --- src/gallium/drivers/softpipe/sp_surface.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c index ef04843f172..b04c2a63ad6 100644 --- a/src/gallium/drivers/softpipe/sp_surface.c +++ b/src/gallium/drivers/softpipe/sp_surface.c @@ -27,6 +27,7 @@ #include "util/u_rect.h" #include "sp_context.h" +#include "sp_surface.h" static void -- cgit v1.2.3 From 57ea34214c114539a92eafafebf7e7fcfa9fc286 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:45:57 +0000 Subject: trace: Defer the cast to after the check for enabled trace. Prevents segfault when trace is disabled. --- src/gallium/drivers/trace/tr_context.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index c8949729047..b69ed2cb526 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1037,9 +1037,9 @@ struct pipe_context * trace_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) { - struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_screen *tr_scr; struct trace_context *tr_ctx; - struct pipe_screen *screen = tr_scr->screen; + struct pipe_screen *screen; if(!pipe) goto error1; @@ -1047,6 +1047,9 @@ trace_context_create(struct pipe_screen *_screen, if(!trace_dump_enabled()) goto error1; + tr_scr = trace_screen(_screen); + screen = tr_scr->screen; + tr_ctx = CALLOC_STRUCT(trace_context); if(!tr_ctx) goto error1; -- cgit v1.2.3 From 8866ff4cacea1005cc137d4fa88386824316a336 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:46:26 +0000 Subject: python: Catchup buffer_destroy interface change. --- src/gallium/state_trackers/python/st_softpipe_winsys.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index 426f347d189..41cdeaa6fdc 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -84,8 +84,7 @@ st_softpipe_buffer_unmap(struct pipe_winsys *winsys, static void -st_softpipe_buffer_destroy(struct pipe_winsys *winsys, - struct pipe_buffer *buf) +st_softpipe_buffer_destroy(struct pipe_buffer *buf) { struct st_softpipe_buffer *oldBuf = st_softpipe_buffer(buf); -- cgit v1.2.3 From 6ce06f3fbcc04b6cde52d625368266b1e69e061e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 25 Mar 2009 21:47:04 +0000 Subject: python: Pass transfers to the tile functions. --- src/gallium/state_trackers/python/p_texture.i | 172 +++++++++++++++++++++----- 1 file changed, 140 insertions(+), 32 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 1e64fc8e41f..e53369cc56c 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -95,37 +95,92 @@ pipe_surface_reference(&ptr, NULL); } - // gets mapped to pipe_surface_map automatically - void * map( unsigned flags ); - - // gets mapped to pipe_surface_unmap automatically - void unmap( void ); - void - get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char *raw, unsigned stride) { - pipe_get_tile_raw($self, x, y, w, h, raw, stride); + get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char *raw, unsigned stride) + { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_READ, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_get_tile_raw(transfer, x, y, w, h, raw, stride); + screen->tex_transfer_destroy(transfer); + } } void - put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *raw, unsigned stride) { - pipe_put_tile_raw($self, x, y, w, h, raw, stride); + put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *raw, unsigned stride) + { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_WRITE, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_put_tile_raw(transfer, x, y, w, h, raw, stride); + screen->tex_transfer_destroy(transfer); + } } void - get_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) { - pipe_get_tile_rgba($self, x, y, w, h, rgba); + get_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) + { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_READ, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_get_tile_rgba(transfer, x, y, w, h, rgba); + screen->tex_transfer_destroy(transfer); + } } void - put_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba) { - pipe_put_tile_rgba($self, x, y, w, h, rgba); + put_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba) + { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_WRITE, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_put_tile_rgba(transfer, x, y, w, h, rgba); + screen->tex_transfer_destroy(transfer); + } } %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); void get_tile_rgba8(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) { - unsigned surface_usage; + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; float *rgba; unsigned char *rgba8; unsigned i, j, k; @@ -147,32 +202,68 @@ rgba8 = (unsigned char *) *STRING; - /* XXX: force mappable surface */ - surface_usage = $self->usage; - $self->usage |= PIPE_BUFFER_USAGE_CPU_READ; - for(j = 0; j < h; ++j) { - pipe_get_tile_rgba($self, - x, y + j, w, 1, - rgba); - for(i = 0; i < w; ++i) - for(k = 0; k <4; ++k) - rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[i*4 + k]); + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_READ, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_get_tile_rgba(transfer, + x, y + j, w, 1, + rgba); + for(i = 0; i < w; ++i) + for(k = 0; k <4; ++k) + rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[i*4 + k]); + screen->tex_transfer_destroy(transfer); + } } - $self->usage = surface_usage; - free(rgba); } void - get_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) { - pipe_get_tile_z($self, x, y, w, h, z); + get_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) + { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_READ, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_get_tile_z(transfer, x, y, w, h, z); + screen->tex_transfer_destroy(transfer); + } } void - put_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned *z) { - pipe_put_tile_z($self, x, y, w, h, z); + put_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned *z) + { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_WRITE, + 0, 0, + $self->width, + $self->height); + if(transfer) { + pipe_put_tile_z(transfer, x, y, w, h, z); + screen->tex_transfer_destroy(transfer); + } } void @@ -183,6 +274,8 @@ unsigned compare_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba, float tol = 0.0) { + struct pipe_screen *screen = $self->texture->screen; + struct pipe_transfer *transfer; float *rgba2; const float *p1; const float *p2; @@ -192,7 +285,22 @@ if(!rgba2) return ~0; - pipe_get_tile_rgba($self, x, y, w, h, rgba2); + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_WRITE, + 0, 0, + $self->width, + $self->height); + if(!transfer) { + FREE(rgba2); + return ~0; + } + + pipe_get_tile_rgba(transfer, x, y, w, h, rgba2); + screen->tex_transfer_destroy(transfer); p1 = rgba; p2 = rgba2; -- cgit v1.2.3 From d332f8b4efae39f09454593374ff939a08af7619 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 26 Mar 2009 10:53:47 +0100 Subject: gallium: Remove some little-used fields from struct pipe_surface. --- src/gallium/drivers/cell/ppu/cell_clear.c | 13 ------------- src/gallium/drivers/i915simple/i915_clear.c | 1 - src/gallium/drivers/i915simple/i915_texture.c | 9 --------- src/gallium/drivers/i965simple/brw_tex_layout.c | 1 - src/gallium/drivers/nv04/nv04_miptree.c | 1 - src/gallium/drivers/nv10/nv10_miptree.c | 1 - src/gallium/drivers/nv20/nv20_clear.c | 1 - src/gallium/drivers/nv20/nv20_miptree.c | 1 - src/gallium/drivers/nv30/nv30_clear.c | 1 - src/gallium/drivers/nv30/nv30_miptree.c | 1 - src/gallium/drivers/nv30/nv30_state_emit.c | 8 -------- src/gallium/drivers/nv40/nv40_clear.c | 1 - src/gallium/drivers/nv40/nv40_miptree.c | 1 - src/gallium/drivers/nv40/nv40_state_emit.c | 8 -------- src/gallium/drivers/nv50/nv50_clear.c | 2 -- src/gallium/drivers/nv50/nv50_miptree.c | 1 - src/gallium/drivers/nv50/nv50_state_validate.c | 7 ------- src/gallium/drivers/r300/r300_clear.c | 3 +-- src/gallium/drivers/r300/r300_texture.c | 1 - src/gallium/drivers/softpipe/sp_clear.c | 2 -- src/gallium/drivers/softpipe/sp_setup.c | 10 ---------- src/gallium/drivers/trace/tr_state.c | 2 -- src/gallium/include/pipe/p_defines.h | 8 -------- src/gallium/include/pipe/p_state.h | 2 -- src/gallium/state_trackers/egl/egl_surface.c | 2 -- src/mesa/state_tracker/st_cb_clear.c | 17 ---------------- src/mesa/state_tracker/st_framebuffer.c | 26 ------------------------- src/mesa/state_tracker/st_public.h | 1 - 28 files changed, 1 insertion(+), 131 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c index edc06747ac1..34be5f3dc7d 100644 --- a/src/gallium/drivers/cell/ppu/cell_clear.c +++ b/src/gallium/drivers/cell/ppu/cell_clear.c @@ -101,17 +101,4 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, clr->surface = surfIndex; clr->value = clearValue; } - - /* Technically, the surface's contents are now known and cleared, - * so we could set the status to PIPE_SURFACE_STATUS_CLEAR. But - * it turns out it's quite painful to recognize when any particular - * surface goes from PIPE_SURFACE_STATUS_CLEAR to - * PIPE_SURFACE_STATUS_DEFINED (i.e. with known contents), because - * the drawing commands could be operating on numerous draw buffers, - * which we'd have to iterate through to set all their stati... - * For now, we cheat a bit and set the surface's status to DEFINED - * right here. Later we should revisit this and set the status to - * CLEAR here, and find a better place to set the status to DEFINED. - */ - ps->status = PIPE_SURFACE_STATUS_DEFINED; } diff --git a/src/gallium/drivers/i915simple/i915_clear.c b/src/gallium/drivers/i915simple/i915_clear.c index 8a2d3ca43f1..cde69daacc0 100644 --- a/src/gallium/drivers/i915simple/i915_clear.c +++ b/src/gallium/drivers/i915simple/i915_clear.c @@ -44,5 +44,4 @@ i915_clear(struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue) { pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); - ps->status = PIPE_SURFACE_STATUS_DEFINED; } diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index 39aca9f8173..ca8e87af8d1 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -677,7 +677,6 @@ i915_get_tex_surface(struct pipe_screen *screen, ps->height = pt->height[level]; ps->offset = offset; ps->usage = flags; - ps->status = PIPE_SURFACE_STATUS_DEFINED; } return ps; } @@ -725,14 +724,6 @@ i915_init_texture_functions(struct i915_context *i915) static void i915_tex_surface_destroy(struct pipe_surface *surf) { - /* This really should not be possible, but it's actually - * happening quite a bit... Will fix. - */ - if (surf->status == PIPE_SURFACE_STATUS_CLEAR) { - debug_printf("XXX destroying a surface with pending clears...\n"); - assert(0); - } - pipe_texture_reference(&surf->texture, NULL); FREE(surf); } diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c index c921c0d38be..f44bd17451b 100644 --- a/src/gallium/drivers/i965simple/brw_tex_layout.c +++ b/src/gallium/drivers/i965simple/brw_tex_layout.c @@ -363,7 +363,6 @@ brw_get_tex_surface_screen(struct pipe_screen *screen, ps->nblocksy = pt->nblocksy[level]; ps->stride = tex->stride; ps->offset = offset; - ps->status = PIPE_SURFACE_STATUS_DEFINED; } return ps; } diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c index 85dc017fbc4..4da833c25e8 100644 --- a/src/gallium/drivers/nv04/nv04_miptree.c +++ b/src/gallium/drivers/nv04/nv04_miptree.c @@ -122,7 +122,6 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt, ns->base.width = pt->width[level]; ns->base.height = pt->height[level]; ns->base.usage = flags; - ns->base.status = PIPE_SURFACE_STATUS_DEFINED; pipe_reference_init(&ns->base.reference, 1); ns->base.face = face; ns->base.level = level; diff --git a/src/gallium/drivers/nv10/nv10_miptree.c b/src/gallium/drivers/nv10/nv10_miptree.c index bb3a1c0f19e..34e3c2ebd77 100644 --- a/src/gallium/drivers/nv10/nv10_miptree.c +++ b/src/gallium/drivers/nv10/nv10_miptree.c @@ -136,7 +136,6 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt, ns->base.width = pt->width[level]; ns->base.height = pt->height[level]; ns->base.usage = flags; - ns->base.status = PIPE_SURFACE_STATUS_DEFINED; pipe_reference_init(&ns->base.reference, 1); ns->base.face = face; ns->base.level = level; diff --git a/src/gallium/drivers/nv20/nv20_clear.c b/src/gallium/drivers/nv20/nv20_clear.c index 29f4afd87c9..81b6f3e78ac 100644 --- a/src/gallium/drivers/nv20/nv20_clear.c +++ b/src/gallium/drivers/nv20/nv20_clear.c @@ -9,5 +9,4 @@ nv20_clear(struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue) { pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); - ps->status = PIPE_SURFACE_STATUS_CLEAR; } diff --git a/src/gallium/drivers/nv20/nv20_miptree.c b/src/gallium/drivers/nv20/nv20_miptree.c index b2f29aff8d2..185fbf53e0f 100644 --- a/src/gallium/drivers/nv20/nv20_miptree.c +++ b/src/gallium/drivers/nv20/nv20_miptree.c @@ -170,7 +170,6 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt, ns->base.width = pt->width[level]; ns->base.height = pt->height[level]; ns->base.usage = flags; - ns->base.status = PIPE_SURFACE_STATUS_DEFINED; pipe_reference_init(&ns->base.reference, 1); ns->base.face = face; ns->base.level = level; diff --git a/src/gallium/drivers/nv30/nv30_clear.c b/src/gallium/drivers/nv30/nv30_clear.c index 8c3ca204d58..71f413588ee 100644 --- a/src/gallium/drivers/nv30/nv30_clear.c +++ b/src/gallium/drivers/nv30/nv30_clear.c @@ -9,5 +9,4 @@ nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue) { pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); - ps->status = PIPE_SURFACE_STATUS_CLEAR; } diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index d6dc621c9ee..7f8054de733 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -177,7 +177,6 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt, ns->base.width = pt->width[level]; ns->base.height = pt->height[level]; ns->base.usage = flags; - ns->base.status = PIPE_SURFACE_STATUS_DEFINED; pipe_reference_init(&ns->base.reference, 1); ns->base.face = face; ns->base.level = level; diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c index f77b08ff695..c18be20a327 100644 --- a/src/gallium/drivers/nv30/nv30_state_emit.c +++ b/src/gallium/drivers/nv30/nv30_state_emit.c @@ -21,14 +21,6 @@ static void nv30_state_do_validate(struct nv30_context *nv30, struct nv30_state_entry **states) { - const struct pipe_framebuffer_state *fb = &nv30->framebuffer; - unsigned i; - - for (i = 0; i < fb->nr_cbufs; i++) - fb->cbufs[i]->status = PIPE_SURFACE_STATUS_DEFINED; - if (fb->zsbuf) - fb->zsbuf->status = PIPE_SURFACE_STATUS_DEFINED; - while (*states) { struct nv30_state_entry *e = *states; diff --git a/src/gallium/drivers/nv40/nv40_clear.c b/src/gallium/drivers/nv40/nv40_clear.c index 59efd620e32..2c4e8f01fda 100644 --- a/src/gallium/drivers/nv40/nv40_clear.c +++ b/src/gallium/drivers/nv40/nv40_clear.c @@ -9,5 +9,4 @@ nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue) { pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); - ps->status = PIPE_SURFACE_STATUS_CLEAR; } diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c index abadca8c933..5a201ccf458 100644 --- a/src/gallium/drivers/nv40/nv40_miptree.c +++ b/src/gallium/drivers/nv40/nv40_miptree.c @@ -176,7 +176,6 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt, ns->base.width = pt->width[level]; ns->base.height = pt->height[level]; ns->base.usage = flags; - ns->base.status = PIPE_SURFACE_STATUS_DEFINED; pipe_reference_init(&ns->base.reference, 1); ns->base.face = face; ns->base.level = level; diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c index ce859def108..10aae298328 100644 --- a/src/gallium/drivers/nv40/nv40_state_emit.c +++ b/src/gallium/drivers/nv40/nv40_state_emit.c @@ -38,14 +38,6 @@ static void nv40_state_do_validate(struct nv40_context *nv40, struct nv40_state_entry **states) { - const struct pipe_framebuffer_state *fb = &nv40->framebuffer; - unsigned i; - - for (i = 0; i < fb->nr_cbufs; i++) - fb->cbufs[i]->status = PIPE_SURFACE_STATUS_DEFINED; - if (fb->zsbuf) - fb->zsbuf->status = PIPE_SURFACE_STATUS_DEFINED; - while (*states) { struct nv40_state_entry *e = *states; diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index f9bc3b53caa..db44a9da0e3 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -86,7 +86,5 @@ nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps, pipe->set_framebuffer_state(pipe, &s_fb); pipe->set_scissor_state(pipe, &s_sc); nv50->dirty |= dirty; - - ps->status = PIPE_SURFACE_STATUS_CLEAR; } diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index dc4688ccdc4..f79a7ca86c9 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -163,7 +163,6 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt, ps->width = pt->width[level]; ps->height = pt->height[level]; ps->usage = flags; - ps->status = PIPE_SURFACE_STATUS_DEFINED; pipe_reference_init(&ps->reference, 1); ps->face = face; ps->level = level; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 85098a78a25..fc6157dbd09 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -178,17 +178,10 @@ nv50_state_emit(struct nv50_context *nv50) boolean nv50_state_validate(struct nv50_context *nv50) { - const struct pipe_framebuffer_state *fb = &nv50->framebuffer; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_stateobj *so; unsigned i; - for (i = 0; i < fb->nr_cbufs; i++) - fb->cbufs[i]->status = PIPE_SURFACE_STATUS_DEFINED; - - if (fb->zsbuf) - fb->zsbuf->status = PIPE_SURFACE_STATUS_DEFINED; - if (nv50->dirty & NV50_NEW_FRAMEBUFFER) nv50_state_validate_fb(nv50); diff --git a/src/gallium/drivers/r300/r300_clear.c b/src/gallium/drivers/r300/r300_clear.c index fd28437aaa4..8506ed29424 100644 --- a/src/gallium/drivers/r300/r300_clear.c +++ b/src/gallium/drivers/r300/r300_clear.c @@ -29,5 +29,4 @@ void r300_clear(struct pipe_context* pipe, unsigned color) { pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color); - ps->status = PIPE_SURFACE_STATUS_DEFINED; -} \ No newline at end of file +} diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 6cdea3d2854..fe91f4e1844 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -147,7 +147,6 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen, surface->height = texture->height[level]; surface->offset = offset; surface->usage = flags; - surface->status = PIPE_SURFACE_STATUS_DEFINED; } return surface; diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index ad108ec446d..a60c6c4c16f 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -79,7 +79,6 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) { sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue); - softpipe->framebuffer.zsbuf->status = PIPE_SURFACE_STATUS_CLEAR; #if TILE_CLEAR_OPTIMIZATION return; #endif @@ -96,7 +95,6 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, cv = clearValue; } sp_tile_cache_clear(softpipe->cbuf_cache[i], cv); - softpipe->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_CLEAR; } } diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 96cb09b9051..711343abe67 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -1489,16 +1489,6 @@ void setup_prepare( struct setup_context *setup ) softpipe_update_derived(sp); } - /* Mark surfaces as defined now */ - for (i = 0; i < sp->framebuffer.nr_cbufs; i++){ - if (sp->framebuffer.cbufs[i]) { - sp->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_DEFINED; - } - } - if (sp->framebuffer.zsbuf) { - sp->framebuffer.zsbuf->status = PIPE_SURFACE_STATUS_DEFINED; - } - /* Note: nr_attrs is only used for debugging (vertex printing) */ setup->quad.nr_attrs = draw_num_vs_outputs(sp->draw); diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c index f9fbe9aee79..a9570c1aebd 100644 --- a/src/gallium/drivers/trace/tr_state.c +++ b/src/gallium/drivers/trace/tr_state.c @@ -406,8 +406,6 @@ void trace_dump_surface(const struct pipe_surface *state) trace_dump_reference(&state->reference); trace_dump_member(format, state, format); - trace_dump_member(uint, state, status); - trace_dump_member(uint, state, clear_value); trace_dump_member(uint, state, width); trace_dump_member(uint, state, height); diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 52d443970b0..8e4f253359a 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -185,14 +185,6 @@ enum pipe_texture_target { #define PIPE_SURFACE_LAYOUT_LINEAR 0 -/** - * Surface status - */ -#define PIPE_SURFACE_STATUS_UNDEFINED 0 -#define PIPE_SURFACE_STATUS_DEFINED 1 -#define PIPE_SURFACE_STATUS_CLEAR 2 - - /** * Transfer object usage flags */ diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 9c7baa3d92e..705ae68ec65 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -281,8 +281,6 @@ struct pipe_surface { struct pipe_reference reference; enum pipe_format format; /**< PIPE_FORMAT_x */ - unsigned status; /**< PIPE_SURFACE_STATUS_x */ - unsigned clear_value; /**< XXX may be temporary */ unsigned width; /**< logical width in pixels */ unsigned height; /**< logical height in pixels */ unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */ diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index ca545b12e68..489aa8d9af5 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -406,8 +406,6 @@ drm_swap_buffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) surf->user->pipe->flush(surf->user->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL); /* TODO stuff here */ } - - st_notify_swapbuffers_complete(surf->stfb); } return EGL_TRUE; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index dd9ba2881f9..020684b4e14 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -291,11 +291,6 @@ clear_with_quad(GLcontext *ctx, static INLINE GLboolean check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) { - const struct st_renderbuffer *strb = st_renderbuffer(rb); - - if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED) - return FALSE; - if (ctx->Scissor.Enabled) return TRUE; @@ -312,14 +307,10 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) static INLINE GLboolean check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) { - const struct st_renderbuffer *strb = st_renderbuffer(rb); const GLuint stencilMax = (1 << rb->StencilBits) - 1; GLboolean maskStencil = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax; - if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED) - return FALSE; - if (ctx->Scissor.Enabled) return TRUE; @@ -339,14 +330,10 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) const struct st_renderbuffer *strb = st_renderbuffer(rb); const GLboolean isDS = is_depth_stencil_format(strb->surface->format); - if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED) - return FALSE; - if (ctx->Scissor.Enabled) return TRUE; if (isDS && - strb->surface->status == PIPE_SURFACE_STATUS_DEFINED && ctx->DrawBuffer->Visual.stencilBits > 0) return TRUE; @@ -366,9 +353,6 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) const GLboolean maskStencil = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax; - if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED) - return FALSE; - if (maskStencil) return TRUE; @@ -381,7 +365,6 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) * current state. */ if (isDS && - strb->surface->status == PIPE_SURFACE_STATUS_DEFINED && ctx->DrawBuffer->Visual.depthBits > 0) return TRUE; diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 06fec20eeec..daaad65ccaf 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -293,32 +293,6 @@ st_notify_swapbuffers(struct st_framebuffer *stfb) } -/** - * Quick hack - allows the winsys to inform the driver that surface - * states are now undefined after a glXSwapBuffers or similar. - */ -void -st_notify_swapbuffers_complete(struct st_framebuffer *stfb) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx && ctx->DrawBuffer == &stfb->Base) { - struct st_renderbuffer *strb; - - /* Mark back color buffers as undefined */ - strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_BACK_LEFT]. - Renderbuffer); - if (strb && strb->surface) - strb->surface->status = PIPE_SURFACE_STATUS_UNDEFINED; - - strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_BACK_RIGHT]. - Renderbuffer); - if (strb && strb->surface) - strb->surface->status = PIPE_SURFACE_STATUS_UNDEFINED; - } -} - - void *st_framebuffer_private( struct st_framebuffer *stfb ) { return stfb->Private; diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 414218bb589..030314372f9 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -100,7 +100,6 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, void st_finish( struct st_context *st ); void st_notify_swapbuffers(struct st_framebuffer *stfb); -void st_notify_swapbuffers_complete(struct st_framebuffer *stfb); int st_set_teximage(struct pipe_texture *pt, int target); -- cgit v1.2.3 From 6af3be43091eff32793bb722cd483fe3ca435954 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 26 Mar 2009 12:07:06 +0100 Subject: python: Fix tri sample. --- src/gallium/state_trackers/python/samples/tri.py | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index ae065c5b9ae..9581b307bf5 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -67,6 +67,8 @@ def test(dev): width = 255 height = 255 + minz = 0.0 + maxz = 0.0 # disabled blending/masking blend = Blend() @@ -85,23 +87,21 @@ def test(dev): rasterizer = Rasterizer() rasterizer.front_winding = PIPE_WINDING_CW rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.bypass_clipping = 1 rasterizer.scissor = 1 - #rasterizer.bypass_vs = 1 ctx.set_rasterizer(rasterizer) - # viewport (identity, we setup vertices in wincoords) + # viewport viewport = Viewport() scale = FloatArray(4) - scale[0] = 1.0 - scale[1] = 1.0 - scale[2] = 1.0 + scale[0] = width / 2.0 + scale[1] = -height / 2.0 + scale[2] = (maxz - minz) / 2.0 scale[3] = 1.0 viewport.scale = scale translate = FloatArray(4) - translate[0] = 0.0 - translate[1] = 0.0 - translate[2] = 0.0 + translate[0] = width / 2.0 + translate[1] = height / 2.0 + translate[2] = (maxz - minz) / 2.0 translate[3] = 0.0 viewport.translate = translate ctx.set_viewport(viewport) @@ -173,24 +173,24 @@ def test(dev): nattrs = 2 verts = FloatArray(nverts * nattrs * 4) - verts[ 0] = 128.0 # x1 - verts[ 1] = 32.0 # y1 + verts[ 0] = 0.0 # x1 + verts[ 1] = 0.8 # y1 verts[ 2] = 0.0 # z1 verts[ 3] = 1.0 # w1 verts[ 4] = 1.0 # r1 verts[ 5] = 0.0 # g1 verts[ 6] = 0.0 # b1 verts[ 7] = 1.0 # a1 - verts[ 8] = 32.0 # x2 - verts[ 9] = 224.0 # y2 + verts[ 8] = -0.8 # x2 + verts[ 9] = -0.8 # y2 verts[10] = 0.0 # z2 verts[11] = 1.0 # w2 verts[12] = 0.0 # r2 verts[13] = 1.0 # g2 verts[14] = 0.0 # b2 verts[15] = 1.0 # a2 - verts[16] = 224.0 # x3 - verts[17] = 224.0 # y3 + verts[16] = 0.8 # x3 + verts[17] = -0.8 # y3 verts[18] = 0.0 # z3 verts[19] = 1.0 # w3 verts[20] = 0.0 # r3 -- cgit v1.2.3 From f4520277e1a5113146fb99e831d515ba7f74c1f8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 26 Mar 2009 10:47:25 +0000 Subject: python: Transfer only the requested tile. --- src/gallium/state_trackers/python/p_texture.i | 50 ++++++++++----------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index e53369cc56c..de03f8f446c 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -106,11 +106,9 @@ $self->level, $self->zslice, PIPE_TRANSFER_READ, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(transfer) { - pipe_get_tile_raw(transfer, x, y, w, h, raw, stride); + pipe_get_tile_raw(transfer, 0, 0, w, h, raw, stride); screen->tex_transfer_destroy(transfer); } } @@ -126,11 +124,9 @@ $self->level, $self->zslice, PIPE_TRANSFER_WRITE, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(transfer) { - pipe_put_tile_raw(transfer, x, y, w, h, raw, stride); + pipe_put_tile_raw(transfer, 0, 0, w, h, raw, stride); screen->tex_transfer_destroy(transfer); } } @@ -146,11 +142,9 @@ $self->level, $self->zslice, PIPE_TRANSFER_READ, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(transfer) { - pipe_get_tile_rgba(transfer, x, y, w, h, rgba); + pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba); screen->tex_transfer_destroy(transfer); } } @@ -166,11 +160,9 @@ $self->level, $self->zslice, PIPE_TRANSFER_WRITE, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(transfer) { - pipe_put_tile_rgba(transfer, x, y, w, h, rgba); + pipe_put_tile_rgba(transfer, 0, 0, w, h, rgba); screen->tex_transfer_destroy(transfer); } } @@ -209,12 +201,12 @@ $self->level, $self->zslice, PIPE_TRANSFER_READ, - 0, 0, - $self->width, - $self->height); + x, y + j, + w, + 1); if(transfer) { pipe_get_tile_rgba(transfer, - x, y + j, w, 1, + 0, 0, w, 1, rgba); for(i = 0; i < w; ++i) for(k = 0; k <4; ++k) @@ -237,11 +229,9 @@ $self->level, $self->zslice, PIPE_TRANSFER_READ, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(transfer) { - pipe_get_tile_z(transfer, x, y, w, h, z); + pipe_get_tile_z(transfer, 0, 0, w, h, z); screen->tex_transfer_destroy(transfer); } } @@ -257,11 +247,9 @@ $self->level, $self->zslice, PIPE_TRANSFER_WRITE, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(transfer) { - pipe_put_tile_z(transfer, x, y, w, h, z); + pipe_put_tile_z(transfer, 0, 0, w, h, z); screen->tex_transfer_destroy(transfer); } } @@ -291,15 +279,13 @@ $self->level, $self->zslice, PIPE_TRANSFER_WRITE, - 0, 0, - $self->width, - $self->height); + x, y, w, h); if(!transfer) { FREE(rgba2); return ~0; } - pipe_get_tile_rgba(transfer, x, y, w, h, rgba2); + pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba2); screen->tex_transfer_destroy(transfer); p1 = rgba; -- cgit v1.2.3 From ca9d2044a2390267477f1e7118b16f21f2557dd3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 26 Mar 2009 10:54:48 +0000 Subject: python: Use pipe_buffer_read/write. --- src/gallium/state_trackers/python/p_texture.i | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index de03f8f446c..4648af691d1 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -327,7 +327,6 @@ struct st_buffer { void read(char **STRING, int *LENGTH) { struct pipe_screen *screen = $self->st_dev->screen; - const char *map; assert(p_atomic_read(&$self->buffer->reference.count) > 0); @@ -336,18 +335,13 @@ struct st_buffer { if(!*STRING) return; - map = pipe_buffer_map(screen, $self->buffer, PIPE_BUFFER_USAGE_CPU_READ); - if(map) { - memcpy(*STRING, map, $self->buffer->size); - pipe_buffer_unmap(screen, $self->buffer); - } + pipe_buffer_read(screen, $self->buffer, 0, $self->buffer->size, STRING); } %cstring_input_binary(const char *STRING, unsigned LENGTH); void write(const char *STRING, unsigned LENGTH, unsigned offset = 0) { struct pipe_screen *screen = $self->st_dev->screen; - char *map; assert(p_atomic_read(&$self->buffer->reference.count) > 0); @@ -361,10 +355,6 @@ struct st_buffer { return; } - map = pipe_buffer_map(screen, $self->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); - if(map) { - memcpy(map + offset, STRING, LENGTH); - pipe_buffer_unmap(screen, $self->buffer); - } + pipe_buffer_write(screen, $self->buffer, offset, LENGTH, STRING); } }; -- cgit v1.2.3 From d18c2ee3d5a1d0352a6f8d48aa067e8983dd5878 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 26 Mar 2009 11:19:15 +0000 Subject: python: Drop st_buffer. It adds nothing, now that pipe_buffer has a pointer to the screen. --- src/gallium/state_trackers/python/gallium.i | 2 +- src/gallium/state_trackers/python/p_context.i | 16 +++++----- src/gallium/state_trackers/python/p_device.i | 4 +-- src/gallium/state_trackers/python/p_texture.i | 44 ++++++++++++++------------- src/gallium/state_trackers/python/st_device.c | 34 --------------------- src/gallium/state_trackers/python/st_device.h | 14 --------- 6 files changed, 34 insertions(+), 80 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i index 79e68de1df8..8b43c1721ef 100644 --- a/src/gallium/state_trackers/python/gallium.i +++ b/src/gallium/state_trackers/python/gallium.i @@ -72,7 +72,7 @@ %rename(Context) st_context; %rename(Texture) pipe_texture; %rename(Surface) pipe_surface; -%rename(Buffer) st_buffer; +%rename(Buffer) pipe_buffer; %rename(BlendColor) pipe_blend_color; %rename(Blend) pipe_blend_state; diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 178ab0e24ef..05f3f222035 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -116,11 +116,11 @@ struct st_context { } void set_constant_buffer(unsigned shader, unsigned index, - struct st_buffer *buffer ) + struct pipe_buffer *buffer ) { struct pipe_constant_buffer state; memset(&state, 0, sizeof(state)); - state.buffer = buffer ? buffer->buffer : NULL; + state.buffer = buffer; $self->pipe->set_constant_buffer($self->pipe, shader, index, &state); } @@ -154,7 +154,7 @@ struct st_context { unsigned stride, unsigned max_index, unsigned buffer_offset, - struct st_buffer *buffer) + struct pipe_buffer *buffer) { unsigned i; struct pipe_vertex_buffer state; @@ -163,7 +163,7 @@ struct st_context { state.stride = stride; state.max_index = max_index; state.buffer_offset = buffer_offset; - state.buffer = buffer ? buffer->buffer : NULL; + state.buffer = buffer; memcpy(&$self->vertex_buffers[index], &state, sizeof(state)); @@ -198,22 +198,22 @@ struct st_context { $self->pipe->draw_arrays($self->pipe, mode, start, count); } - void draw_elements( struct st_buffer *indexBuffer, + void draw_elements( struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { $self->pipe->draw_elements($self->pipe, - indexBuffer->buffer, + indexBuffer, indexSize, mode, start, count); } - void draw_range_elements( struct st_buffer *indexBuffer, + void draw_range_elements( struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned minIndex, unsigned maxIndex, unsigned mode, unsigned start, unsigned count) { $self->pipe->draw_range_elements($self->pipe, - indexBuffer->buffer, + indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); } diff --git a/src/gallium/state_trackers/python/p_device.i b/src/gallium/state_trackers/python/p_device.i index 84fd2e4349b..f16fe5b0ff7 100644 --- a/src/gallium/state_trackers/python/p_device.i +++ b/src/gallium/state_trackers/python/p_device.i @@ -122,9 +122,9 @@ struct st_device { return $self->screen->texture_create($self->screen, &templat); } - struct st_buffer * + struct pipe_buffer * buffer_create(unsigned size, unsigned alignment = 0, unsigned usage = 0) { - return st_buffer_create($self, alignment, usage, size); + return pipe_buffer_create($self->screen, alignment, usage, size); } }; diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 4648af691d1..63c63db9ebe 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -35,11 +35,11 @@ %nodefaultctor pipe_texture; %nodefaultctor pipe_surface; -%nodefaultctor st_buffer; +%nodefaultctor pipe_buffer; %nodefaultdtor pipe_texture; %nodefaultdtor pipe_surface; -%nodefaultdtor st_buffer; +%nodefaultdtor pipe_buffer; %ignore pipe_texture::screen; @@ -308,53 +308,55 @@ }; -struct st_buffer { -}; +/* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */ +%rename(read) pipe_buffer_read_; +%rename(write) pipe_buffer_write_; -%extend st_buffer { +%extend pipe_buffer { - ~st_buffer() { - st_buffer_destroy($self); + ~pipe_buffer() { + struct pipe_buffer *ptr = $self; + pipe_buffer_reference(&ptr, NULL); } unsigned __len__(void) { - assert(p_atomic_read(&$self->buffer->reference.count) > 0); - return $self->buffer->size; + assert(p_atomic_read(&$self->reference.count) > 0); + return $self->size; } %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); - void read(char **STRING, int *LENGTH) + void read_(char **STRING, int *LENGTH) { - struct pipe_screen *screen = $self->st_dev->screen; + struct pipe_screen *screen = $self->screen; - assert(p_atomic_read(&$self->buffer->reference.count) > 0); + assert(p_atomic_read(&$self->reference.count) > 0); - *LENGTH = $self->buffer->size; - *STRING = (char *) malloc($self->buffer->size); + *LENGTH = $self->size; + *STRING = (char *) malloc($self->size); if(!*STRING) return; - pipe_buffer_read(screen, $self->buffer, 0, $self->buffer->size, STRING); + pipe_buffer_read(screen, $self, 0, $self->size, STRING); } %cstring_input_binary(const char *STRING, unsigned LENGTH); - void write(const char *STRING, unsigned LENGTH, unsigned offset = 0) + void write_(const char *STRING, unsigned LENGTH, unsigned offset = 0) { - struct pipe_screen *screen = $self->st_dev->screen; + struct pipe_screen *screen = $self->screen; - assert(p_atomic_read(&$self->buffer->reference.count) > 0); + assert(p_atomic_read(&$self->reference.count) > 0); - if(offset > $self->buffer->size) { + if(offset > $self->size) { PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size"); return; } - if(offset + LENGTH > $self->buffer->size) { + if(offset + LENGTH > $self->size) { PyErr_SetString(PyExc_ValueError, "data length must fit inside the buffer"); return; } - pipe_buffer_write(screen, $self->buffer, offset, LENGTH, STRING); + pipe_buffer_write(screen, $self, offset, LENGTH, STRING); } }; diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 366d4eb19af..b4f8649d3bc 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -291,37 +291,3 @@ st_context_create(struct st_device *st_dev) return st_ctx; } - - -void -st_buffer_destroy(struct st_buffer *st_buf) -{ - if(st_buf) { - pipe_buffer_reference(&st_buf->buffer, NULL); - FREE(st_buf); - } -} - - -struct st_buffer * -st_buffer_create(struct st_device *st_dev, - unsigned alignment, unsigned usage, unsigned size) -{ - struct pipe_screen *screen = st_dev->screen; - struct st_buffer *st_buf; - - st_buf = CALLOC_STRUCT(st_buffer); - if(!st_buf) - return NULL; - - st_buf->st_dev = st_dev; - - st_buf->buffer = pipe_buffer_create(screen, alignment, usage, size); - if(!st_buf->buffer) { - st_buffer_destroy(st_buf); - return NULL; - } - - return st_buf; -} - diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h index 0641aff149f..d1bd8c31f4f 100644 --- a/src/gallium/state_trackers/python/st_device.h +++ b/src/gallium/state_trackers/python/st_device.h @@ -38,13 +38,6 @@ struct pipe_context; struct st_winsys; -struct st_buffer { - struct st_device *st_dev; - - struct pipe_buffer *buffer; -}; - - struct st_context { struct st_device *st_dev; @@ -78,13 +71,6 @@ struct st_device { }; -struct st_buffer * -st_buffer_create(struct st_device *st_dev, - unsigned alignment, unsigned usage, unsigned size); - -void -st_buffer_destroy(struct st_buffer *st_buf); - struct st_context * st_context_create(struct st_device *st_dev); -- cgit v1.2.3 From bb84ce71593d79bae9e8a5a8bdd4b2bd6aba2c87 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 26 Mar 2009 11:29:59 +0000 Subject: python: Make swig bindings python independent. --- src/gallium/state_trackers/python/gallium.i | 3 +-- src/gallium/state_trackers/python/p_texture.i | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i index 8b43c1721ef..4970819190e 100644 --- a/src/gallium/state_trackers/python/gallium.i +++ b/src/gallium/state_trackers/python/gallium.i @@ -37,7 +37,6 @@ %{ #include -#include #include "pipe/p_screen.h" #include "pipe/p_context.h" @@ -58,7 +57,7 @@ %} %include "typemaps.i" - +%include "exception.i" %include "cstring.i" %include "carrays.i" diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 63c63db9ebe..b03054adcce 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -347,16 +347,15 @@ assert(p_atomic_read(&$self->reference.count) > 0); - if(offset > $self->size) { - PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size"); - return; - } + if(offset > $self->size) + SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size"); - if(offset + LENGTH > $self->size) { - PyErr_SetString(PyExc_ValueError, "data length must fit inside the buffer"); - return; - } + if(offset + LENGTH > $self->size) + SWIG_exception(SWIG_ValueError, "data length must fit inside the buffer"); pipe_buffer_write(screen, $self, offset, LENGTH, STRING); + +fail: + return; } }; -- cgit v1.2.3 From 7138cd700997a353bfa127495b3f11adeab68940 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 26 Mar 2009 12:04:15 +0000 Subject: python: Fix the texture test. --- src/gallium/state_trackers/python/tests/texture.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py index 8cec57e2a60..ce1c66720b4 100644 --- a/src/gallium/state_trackers/python/tests/texture.py +++ b/src/gallium/state_trackers/python/tests/texture.py @@ -168,26 +168,9 @@ class TextureTest(TestCase): rasterizer = Rasterizer() rasterizer.front_winding = PIPE_WINDING_CW rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.bypass_clipping = 1 - #rasterizer.bypass_vs = 1 + rasterizer.bypass_vs_clip_and_viewport = 1 ctx.set_rasterizer(rasterizer) - # viewport (identity, we setup vertices in wincoords) - viewport = Viewport() - scale = FloatArray(4) - scale[0] = 1.0 - scale[1] = 1.0 - scale[2] = 1.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = 0.0 - translate[1] = 0.0 - translate[2] = 0.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - # samplers sampler = Sampler() sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE -- cgit v1.2.3 From a2f52f500cdff2ffd5aec039cafaaa3bc2273595 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 26 Mar 2009 12:11:27 +0000 Subject: python: Don't bypass vs/clip/viewport by default. --- src/gallium/state_trackers/python/st_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index b4f8649d3bc..8246b378ce0 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -192,10 +192,16 @@ st_context_create(struct st_device *st_dev) memset(&rasterizer, 0, sizeof(rasterizer)); rasterizer.front_winding = PIPE_WINDING_CW; rasterizer.cull_mode = PIPE_WINDING_NONE; - rasterizer.bypass_vs_clip_and_viewport = 1; cso_set_rasterizer(st_ctx->cso, &rasterizer); } + /* clip */ + { + struct pipe_clip_state clip; + memset(&clip, 0, sizeof(clip)); + st_ctx->pipe->set_clip_state(st_ctx->pipe, &clip); + } + /* identity viewport */ { struct pipe_viewport_state viewport; -- cgit v1.2.3 From 3673189326e348eb91e354017703fdfd9d6d8184 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 26 Mar 2009 08:40:07 -0600 Subject: tgsi: pass zero vector to texture sampler for 1D case instead of NULL Fixes segfault when sampling 1D textures. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index ba807e498f1..259877b500d 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -123,6 +123,10 @@ #define UPDATE_EXEC_MASK(MACH) \ MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->FuncMask + +static const union tgsi_exec_channel ZeroVec = + { { 0.0, 0.0, 0.0, 0.0 } }; + /** * Initialize machine state by expanding tokens to full instructions, * allocating temporary storage, setting up constants, etc. @@ -1643,7 +1647,7 @@ exec_tex(struct tgsi_exec_machine *mach, lodBias = 0.0; fetch_texel(mach->Samplers[unit], - &r[0], NULL, NULL, lodBias, /* S, T, P, BIAS */ + &r[0], &ZeroVec, &ZeroVec, lodBias, /* S, T, P, BIAS */ &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */ break; -- cgit v1.2.3 From ec30d1b2e5738264ca2ab2ce23d9fce2b9c7a2ce Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 27 Mar 2009 19:13:21 +0000 Subject: mesa: Use the python executable from sys.executable. From Ramesh Dharan --- src/gallium/auxiliary/indices/SConscript | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/indices/SConscript b/src/gallium/auxiliary/indices/SConscript index e5f7ee94845..712e215534f 100644 --- a/src/gallium/auxiliary/indices/SConscript +++ b/src/gallium/auxiliary/indices/SConscript @@ -1,17 +1,19 @@ Import('*') +from sys import executable as python_cmd + env.CodeGenerate( target = 'u_indices_gen.c', script = 'u_indices_gen.py', source = [], - command = 'python $SCRIPT > $TARGET' + command = python_cmd + ' $SCRIPT > $TARGET' ) env.CodeGenerate( target = 'u_unfilled_gen.c', script = 'u_unfilled_gen.py', source = [], - command = 'python $SCRIPT > $TARGET' + command = python_cmd + ' $SCRIPT > $TARGET' ) indices = env.ConvenienceLibrary( -- cgit v1.2.3 From aa91f05f9de28511f352ac1d0ce754c19539e38f Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 25 Mar 2009 07:25:06 -0700 Subject: r300-gallium: Use CMP for MOV on r300. Doesn't quite fix problems, though. :c --- src/gallium/drivers/r300/r300_state_shader.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index e83d007ba20..7cbb41ffdb9 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -119,15 +119,15 @@ static const struct r300_fragment_shader r300_passthrough_fragment_shader = { .shader.stack_size = 1, .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | - R300_RGB_SWIZB(R300_ALU_ARGC_ONE) | + R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) | R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) | - R300_ALU_OUTC_MAD, + R300_ALU_OUTC_CMP, .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ, .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | - R300_ALPHA_SWIZB(R300_ALU_ARGA_ONE) | + R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) | R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) | - R300_ALU_OUTA_MAD, + R300_ALU_OUTA_CMP, .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) | R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT, }; -- cgit v1.2.3 From 2431a027c197c7172d6769eb616d4301cc6a0bca Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 25 Mar 2009 21:26:02 -0700 Subject: r300-gallium: Add some surface_copy. --- src/gallium/drivers/r300/r300_emit.c | 2 +- src/gallium/drivers/r300/r300_emit.h | 2 + src/gallium/drivers/r300/r300_reg.h | 3 + src/gallium/drivers/r300/r300_state_invariant.c | 17 ---- src/gallium/drivers/r300/r300_state_shader.h | 54 +++++++++++++ src/gallium/drivers/r300/r300_surface.c | 101 ++++++++++++++++++++++-- src/gallium/drivers/r300/r300_surface.h | 29 +++++++ 7 files changed, 184 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 16455e48ce8..a2e9cca39ba 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -343,7 +343,7 @@ void r300_emit_viewport_state(struct r300_context* r300, END_CS; } -static void r300_flush_textures(struct r300_context* r300) +void r300_flush_textures(struct r300_context* r300) { CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 0bc1f90e6ab..9d92b090ace 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -67,6 +67,8 @@ void r300_emit_vertex_format_state(struct r300_context* r300); void r300_emit_viewport_state(struct r300_context* r300, struct r300_viewport_state* viewport); +void r300_flush_textures(struct r300_context* r300); + /* Emit all dirty state. */ void r300_emit_dirty_state(struct r300_context* r300); diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 3fe45e13932..c9a195a6ce4 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -1191,6 +1191,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_RS_INST_COUNT_MASK 0x0000000f # define R300_RS_TX_OFFSET_SHIFT 5 # define R300_RS_TX_OFFSET_MASK 0x000000e0 +# define R300_RS_TX_OFFSET(x) ((x) << 5) /* gap */ @@ -1434,6 +1435,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_TX_MAX_ANISO_8_TO_1 (3 << 21) # define R300_TX_MAX_ANISO_16_TO_1 (4 << 21) # define R300_TX_MAX_ANISO_MASK (7 << 21) +# define R300_TX_WRAP_S(x) ((x) << 0) +# define R300_TX_WRAP_T(x) ((x) << 3) #define R300_TX_FILTER1_0 0x4440 # define R300_CHROMA_KEY_MODE_DISABLE 0 diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index e1837b63801..3705ff98db5 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -141,28 +141,11 @@ void r300_emit_invariant_state(struct r300_context* r300) OUT_CS_REG(R300_ZB_DEPTHCLEARVALUE, 0x00000000); OUT_CS_REG(R300_ZB_HIZ_OFFSET, 0x00000000); OUT_CS_REG(R300_ZB_HIZ_PITCH, 0x00000000); - if (caps->has_tcl) { - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, - (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) | - ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) | - R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)); - } else { - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, - (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) | - ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) | - R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)); - } - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, - (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) | - (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT)); OUT_CS_REG(R300_VAP_VTX_STATE_CNTL, 0x1); OUT_CS_REG(R300_VAP_VSM_VTX_ASSM, 0x405); OUT_CS_REG(R300_SE_VTE_CNTL, 0x0000043F); /* Vertex size. */ OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8); - OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, 0x00000003); - OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x00000000); - OUT_CS_REG(R300_TX_ENABLE, 0x0); /* XXX */ OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa); diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 7cbb41ffdb9..3c5f036d2ae 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -158,4 +158,58 @@ static const struct r500_fragment_shader r500_passthrough_fragment_shader = { R500_ALU_RGBA_A_SWIZ_0, }; +static const struct r300_fragment_shader r300_texture_fragment_shader = { + /* XXX This is the emission code. TODO: decode + OUT_CS_REG(R300_US_CONFIG, 0); + OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); + OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0); + OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0); + OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0); + OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000); +*/ + .alu_instruction_count = 1, + .tex_instruction_count = 0, + .indirections = 0, + .shader.stack_size = 1, + + .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | + R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) | + R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) | + R300_ALU_OUTC_CMP, + .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | + R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ, + .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | + R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) | + R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) | + R300_ALU_OUTA_CMP, + .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) | + R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT, +}; + +static const struct r500_fragment_shader r500_texture_fragment_shader = { + .shader.stack_size = 0, + .instruction_count = 1, + .instructions[0].inst0 = R500_INST_TYPE_OUT | + R500_INST_TEX_SEM_WAIT | R500_INST_LAST | + R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK | + R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, + .instructions[0].inst1 = + R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST | + R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST, + .instructions[0].inst2 = + R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST | + R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST, + .instructions[0].inst3 = + R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R | + R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B | + R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R | + R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B, + .instructions[0].inst4 = + R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A, + .instructions[0].inst5 = + R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 | + R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 | + R500_ALU_RGBA_A_SWIZ_0, +}; + #endif /* R300_STATE_SHADER_H */ diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index db18975a10f..96b63986ea7 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -113,7 +113,32 @@ static void r300_surface_fill(struct pipe_context* pipe, r300_emit_rs_block_state(r300, &r300_rs_block_clear_state); } - BEGIN_CS(21); + BEGIN_CS(31); + + /* VAP stream control, mapping from input memory to PVS/RS memory */ + if (caps->has_tcl) { + OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, + (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) | + ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) | + R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)); + } else { + OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, + (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) | + ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) | + R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)); + } + OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, + (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) | + (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT)); + + /* VAP format controls */ + OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, + R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT | + R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT); + OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x0); + + /* Disable textures */ + OUT_CS_REG(R300_TX_ENABLE, 0x0); /* Viewport setup */ OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); @@ -132,7 +157,7 @@ static void r300_surface_fill(struct pipe_context* pipe, /* Packet3 with our point vertex */ OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8); OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING | - (1 << R300_PRIM_NUM_VERTICES_SHIFT)); + (1 << R300_PRIM_NUM_VERTICES_SHIFT)); OUT_CS_32F(w / 2.0); OUT_CS_32F(h / 2.0); /* XXX this should be the depth value to clear to */ @@ -163,6 +188,7 @@ static void r300_surface_copy(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); CS_LOCALS(r300); + struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* srctex = (struct r300_texture*)src->texture; struct r300_texture* desttex = (struct r300_texture*)dest->texture; @@ -171,14 +197,77 @@ static void r300_surface_copy(struct pipe_context* pipe, " dimensions %dx%d (pixel pitch %d)\n", src, srcx, srcy, dest, destx, desty, w, h, pixpitch); - /* if ((srctex == desttex) && + if ((srctex == desttex) && ((destx < srcx + w) || (srcx < destx + w)) && - ((desty < srcy + h) || (srcy < destx + h))) { */ - if (TRUE) { + ((desty < srcy + h) || (srcy < desty + h))) { debug_printf("r300: Falling back on surface_copy\n"); - return util_surface_copy(pipe, FALSE, dest, destx, desty, src, + util_surface_copy(pipe, FALSE, dest, destx, desty, src, srcx, srcy, w, h); } + + r300_emit_sampler(r300, &r300_sampler_copy_state, 0); + r300_emit_texture(r300, srctex, 0); + r300_flush_textures(r300); + + /* Fragment shader setup */ + if (caps->is_r500) { + r500_emit_fragment_shader(r300, &r500_texture_fragment_shader); + r300_emit_rs_block_state(r300, &r500_rs_block_copy_state); + } else { + r300_emit_fragment_shader(r300, &r300_texture_fragment_shader); + r300_emit_rs_block_state(r300, &r300_rs_block_copy_state); + } + + /* VAP stream control, mapping from input memory to PVS/RS memory */ + if (caps->has_tcl) { + OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, + (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) | + ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) | + R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT)); + } else { + OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, + (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) | + ((R300_LAST_VEC | (6 << R300_DST_VEC_LOC_SHIFT) | + R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT)); + } + OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, + (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) | + (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT)); + + /* VAP format controls */ + OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, + R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT); + /* Two components of texture 0 */ + OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2); + + /* Packet3 with our texcoords */ + OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8); + OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING | + (4 << R300_PRIM_NUM_VERTICES_SHIFT)); + /* (x , y ) */ + OUT_CS_32F((float)destx); + OUT_CS_32F((float)desty); + OUT_CS_32F((float)srcx); + OUT_CS_32F((float)srcy); + /* (x , y + h) */ + OUT_CS_32F((float)destx); + OUT_CS_32F((float)(desty + h)); + OUT_CS_32F((float)srcx); + OUT_CS_32F((float)(srcy + h)); + /* (x + w, y + h) */ + OUT_CS_32F((float)(destx + w)); + OUT_CS_32F((float)(desty + h)); + OUT_CS_32F((float)(srcx + w)); + OUT_CS_32F((float)(srcy + h)); + /* (x + w, y ) */ + OUT_CS_32F((float)(destx + w)); + OUT_CS_32F((float)desty); + OUT_CS_32F((float)(srcx + w)); + OUT_CS_32F((float)srcy); + + OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); + + r300->dirty_hw++; } void r300_init_surface_functions(struct r300_context* r300) diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h index b75b3ab84cf..465b8476edf 100644 --- a/src/gallium/drivers/r300/r300_surface.h +++ b/src/gallium/drivers/r300/r300_surface.h @@ -91,4 +91,33 @@ const struct r300_rs_block r500_rs_block_clear_state = { .inst_count = 0, }; +/* The following state is used for surface_copy only. */ + +const struct r300_rs_block r300_rs_block_copy_state = { + .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) | + R500_RS_SEL_T(R300_RS_SEL_K0) | + R500_RS_SEL_R(R300_RS_SEL_K0) | + R500_RS_SEL_Q(R300_RS_SEL_K1), + .inst[0] = R300_RS_INST_COL_CN_WRITE, + .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN, + .inst_count = R300_RS_TX_OFFSET(6), +}; + +const struct r300_rs_block r500_rs_block_copy_state = { + .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) | + R500_RS_SEL_T(R500_RS_IP_PTR_K0) | + R500_RS_SEL_R(R500_RS_IP_PTR_K0) | + R500_RS_SEL_Q(R500_RS_IP_PTR_K1), + .inst[0] = R500_RS_INST_COL_CN_WRITE, + .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN, + .inst_count = R300_RS_TX_OFFSET(6), +}; + +const struct r300_sampler_state r300_sampler_copy_state = { + .filter0 = R300_TX_WRAP_S(R300_TX_CLAMP) | + R300_TX_WRAP_T(R300_TX_CLAMP) | + R300_TX_MAG_FILTER_NEAREST | + R300_TX_MIN_FILTER_NEAREST, +}; + #endif /* R300_SURFACE_H */ -- cgit v1.2.3 From a7900748106a9ad339a4552ca944f2fa30486cfc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 27 Mar 2009 20:23:16 +0000 Subject: util: Support Z24S8/Z24X8. --- src/gallium/auxiliary/util/u_tile.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index d31ca9c029e..f0a5a339eb3 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -957,6 +957,7 @@ pipe_tile_raw_to_rgba(enum pipe_format format, s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: z24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_Z32_FLOAT: @@ -1069,6 +1070,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; default: @@ -1198,6 +1200,20 @@ pipe_put_tile_z(struct pipe_transfer *pt, } } break; + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + { + uint *pDest = (uint *) (map + y * pt->stride + x*4); + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { + /* convert 32-bit Z to 24-bit Z (0 stencil) */ + pDest[j] = ptrc[j] << 8; + } + pDest += pt->stride/4; + ptrc += srcStride; + } + } + break; case PIPE_FORMAT_Z16_UNORM: { ushort *pDest = (ushort *) (map + y * pt->stride + x*2); -- cgit v1.2.3 From c03000b73e49b858d6bf256114d28c8e9d7a2802 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 27 Mar 2009 21:38:54 +0000 Subject: wgl: Remove unused cruft. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 4 ---- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 10 ---------- src/gallium/state_trackers/wgl/shared/stw_framebuffer.h | 5 ----- 3 files changed, 19 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 89df8b0a2a0..82aabe0a7ee 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -317,10 +317,6 @@ stw_make_current( fb = framebuffer_create( hdc, visual, width, height ); if (fb == NULL) return FALSE; - - fb->dib_hDC = CreateCompatibleDC( hdc ); - fb->hbmDIB = NULL; - fb->pbPixels = NULL; } if (ctx && fb) { diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 024c9ad36af..2f0d8cbc318 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -44,16 +44,6 @@ framebuffer_resize( GLuint width, GLuint height ) { - if (fb->hbmDIB == NULL || fb->stfb->Base.Width != width || fb->stfb->Base.Height != height) { - if (fb->hbmDIB) - DeleteObject( fb->hbmDIB ); - - fb->hbmDIB = CreateCompatibleBitmap( - fb->hDC, - width, - height ); - } - st_resize_framebuffer( fb->stfb, width, height ); } diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h index 2e16e421f2c..5abdf189970 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h @@ -36,12 +36,7 @@ struct stw_framebuffer { struct st_framebuffer *stfb; HDC hDC; - int pixelformat; BYTE cColorBits; - HDC dib_hDC; - HBITMAP hbmDIB; - HBITMAP hOldBitmap; - PBYTE pbPixels; HWND hWnd; WNDPROC WndProc; struct stw_framebuffer *next; -- cgit v1.2.3 From aa011836c2778d242c75547c3f64435a055a86ff Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 27 Mar 2009 21:43:24 +0000 Subject: wgl: Don't flush surface if it is NULL. Just a quick fix to prevent segfaults with glean. --- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 2f0d8cbc318..4641884f950 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -225,11 +225,14 @@ stw_swap_buffers( */ st_notify_swapbuffers( fb->stfb ); - st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf ); - - stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen, - surf, - hdc ); + if(st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf )) { + stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen, + surf, + hdc ); + } + else { + /* FIXME: this shouldn't happen, but does on glean */ + } return TRUE; } -- cgit v1.2.3 From 29933fc6fec88e0c20e6ba4feebce10934eb48a3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 12:12:37 +0100 Subject: python: Update instructions for windows. --- src/gallium/state_trackers/python/README | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/README b/src/gallium/state_trackers/python/README index 4281d9bdb0d..e03d5468304 100644 --- a/src/gallium/state_trackers/python/README +++ b/src/gallium/state_trackers/python/README @@ -6,20 +6,27 @@ the python script perspective. To build you'll need: * Python (with development packages) * SCons -* SWIG -* Python Imaging Library with TK support (for the samples) +* SWIG, http://www.swig.org/download.html +* Python Imaging Library with TK support, http://www.pythonware.com/products/pil/, + for the samples On a debian-based distro you can simply do: aptitude install python-dev scons swig python-imaging python-imaging-tk +On a Windows machine ensure the swig command is in your PATH. + Invoke scons on the top dir as - scons debug=yes statetrackers=python driver=softpipe,trace + scons debug=yes statetrackers=python drivers=softpipe,trace winsys=none + +To use it set PYTHONPATH appropriately, e.g, in Linux do: + + export PYTHONPATH=$PWD/build/linux-x86-debug/gallium/state_trackers/python -To use do +or (in Windows) - export PYTHONPATH=$PWD/build/XXXX-XXXX-XXXX/gallium/state_trackers/python + set PYTHONPATH=%CD%\build\windows-x86-debug\gallium\state_trackers\python and then try running @@ -31,7 +38,6 @@ which should show a triangle. This is still work in progress: - errors are not handled properly and almost always result in crash - state atoms with array members are awkward to set -- there no efficient way to view images -- -Jose Fonseca +Jose Fonseca -- cgit v1.2.3 From 1c989c24aea5a4cc8807cbc46e68e62f4d28f018 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 14:24:20 +0100 Subject: python: Dont touch old pipe_winsys. --- src/gallium/state_trackers/python/gallium.i | 1 - src/gallium/state_trackers/python/p_context.i | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i index 4970819190e..38f8245adf5 100644 --- a/src/gallium/state_trackers/python/gallium.i +++ b/src/gallium/state_trackers/python/gallium.i @@ -42,7 +42,6 @@ #include "pipe/p_context.h" #include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" -#include "pipe/internal/p_winsys_screen.h" #include "cso_cache/cso_context.h" #include "util/u_draw_quad.h" #include "util/u_tile.h" diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 05f3f222035..6dcd38e7d14 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -257,8 +257,8 @@ error1: struct pipe_fence_handle *fence = NULL; $self->pipe->flush($self->pipe, flags | PIPE_FLUSH_RENDER_CACHE, &fence); /* TODO: allow asynchronous operation */ - $self->pipe->winsys->fence_finish( $self->pipe->winsys, fence, 0 ); - $self->pipe->winsys->fence_reference( $self->pipe->winsys, &fence, NULL ); + $self->pipe->screen->fence_finish( $self->pipe->screen, fence, 0 ); + $self->pipe->screen->fence_reference( $self->pipe->screen, &fence, NULL ); } /* -- cgit v1.2.3 From 25e491e68c4c191a7f76b24520e5812356fe5a85 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 30 Mar 2009 15:39:29 +0200 Subject: tgsi: Document BRA opcode. --- src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt index 5b21a2be0bd..d3b66728e6d 100644 --- a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt +++ b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt @@ -548,7 +548,7 @@ TGSI Instruction Specification 1.6.3 BRA - Branch - TBD + pc = target 1.6.4 CAL - Subroutine Call -- cgit v1.2.3 From bd4c1c133b19e87d372c4f1c4e1cb7cae178d381 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 30 Mar 2009 17:12:58 +0200 Subject: tgsi: Explain symbols used in instruction set documentation. --- .../auxiliary/tgsi/tgsi-instruction-set.txt | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt index d3b66728e6d..d6b8fef83c1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt +++ b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt @@ -1038,3 +1038,74 @@ TGSI Instruction Specification Alias for ARR. + +2 Explanation of symbols used +============================== + + +2.1 Functions +-------------- + + + abs(x) Absolute value of x. + |x| + (x < 0.0) ? -x : x + + ceil(x) Ceiling of x. + + clamp(x,y,z) Clamp x between y and z. + (x < y) ? y : (x > z) ? z : x + + cos(x) Cosine of x. + + floor(x) Floor of x. + + lg2(x) Logarithm base 2 of x. + + max(x,y) Maximum of x and y. + (x > y) ? x : y + + min(x,y) Minimum of x and y. + (x < y) ? x : y + + partialx(x) Derivative of x relative to fragment's X. + + partialy(x) Derivative of x relative to fragment's Y. + + pop() Pop from stack. + + pow(x,y) Raise x to power of y. + + push(x) Push x on stack. + + round(x) Round x. + + sin(x) Sine of x. + + sqrt(x) Square root of x. + + trunc(x) Truncate x. + + +2.2 Keywords +------------- + + + discard Discard fragment. + + dst First destination register. + + dst0 First destination register. + + pc Program counter. + + src First source register. + + src0 First source register. + + src1 Second source register. + + src2 Third source register. + + target Label of target instruction. + -- cgit v1.2.3 From e08a0f479055be08a08594d723aa8837778c79f8 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 30 Mar 2009 17:13:52 +0200 Subject: tgsi: Condition codes are implied in KILP. --- src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt index d6b8fef83c1..a20ad689c08 100644 --- a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt +++ b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt @@ -382,9 +382,7 @@ TGSI Instruction Specification 1.5.7 KILP - Predicated Discard - if (cc.x || cc.y || cc.z || cc.w) - discard - endif + discard 1.5.8 LG2 - Logarithm Base 2 -- cgit v1.2.3 From 68342f9036d3c94ee50c4cbe5c7b36439eeb6825 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 15:09:18 +0100 Subject: python: Hide away the surface usage flags. Surfaces are now by definition GPU views. So CPU access flags don't make any sense when creating a surface. For now we are forcing surfaces to be GPU read/write, but that will go away soon. --- src/gallium/state_trackers/python/p_texture.i | 3 ++- src/gallium/state_trackers/python/retrace/interpreter.py | 2 +- src/gallium/state_trackers/python/samples/tri.py | 6 +++--- src/gallium/state_trackers/python/tests/texture.py | 5 ++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index b03054adcce..fee9fb0bf84 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -79,8 +79,9 @@ /** Get a surface which is a "view" into a texture */ struct pipe_surface * - get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0, unsigned usage=0 ) + get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0 ) { + const usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE; struct pipe_screen *screen = $self->screen; return screen->get_tex_surface(screen, $self, face, level, zslice, usage); } diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index a22314d2000..510adcc2425 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -272,7 +272,7 @@ class Screen(Object): pass def get_tex_surface(self, texture, face, level, zslice, usage): - return texture.get_surface(face, level, zslice, usage) + return texture.get_surface(face, level, zslice) def tex_surface_destroy(self, surface): self.interpreter.unregister_object(surface) diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index 9581b307bf5..72e94560af4 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -135,7 +135,7 @@ def test(dev): width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ) - _cbuf = cbuf.get_surface(usage = PIPE_BUFFER_USAGE_GPU_READ|PIPE_BUFFER_USAGE_GPU_WRITE) + _cbuf = cbuf.get_surface() fb = Framebuffer() fb.width = width fb.height = height @@ -205,8 +205,8 @@ def test(dev): ctx.flush() - show_image(cbuf.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ|PIPE_BUFFER_USAGE_CPU_WRITE)) - #save_image('tri.png', cbuf.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ|PIPE_BUFFER_USAGE_CPU_WRITE)) + show_image(cbuf.get_surface()) + #save_image('tri.png', cbuf.get_surface()) diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py index ce1c66720b4..bd95f734fe7 100644 --- a/src/gallium/state_trackers/python/tests/texture.py +++ b/src/gallium/state_trackers/python/tests/texture.py @@ -197,7 +197,6 @@ class TextureTest(TestCase): expected_rgba = FloatArray(height*width*4) texture.get_surface( - usage = PIPE_BUFFER_USAGE_CPU_READ|PIPE_BUFFER_USAGE_CPU_WRITE, face = face, level = level, zslice = zslice, @@ -213,7 +212,7 @@ class TextureTest(TestCase): tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, ) - cbuf = cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_GPU_WRITE|PIPE_BUFFER_USAGE_GPU_READ) + cbuf = cbuf_tex.get_surface() fb = Framebuffer() fb.width = width fb.height = height @@ -290,7 +289,7 @@ class TextureTest(TestCase): ctx.flush() - cbuf = cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ) + cbuf = cbuf_tex.get_surface() total = h*w different = cbuf.compare_tile_rgba(x, y, w, h, expected_rgba, tol=4.0/256) -- cgit v1.2.3 From 28de69d6819eab289a400482d15797b662e4d633 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 16:02:21 +0100 Subject: python: Set the surface GPU access flags. Make python surface just a dumb (texture, face, level, zslice) tuple. --- src/gallium/state_trackers/python/gallium.i | 2 +- src/gallium/state_trackers/python/p_context.i | 85 +++++++++++++++++++++++---- src/gallium/state_trackers/python/p_state.i | 31 ++++++++-- src/gallium/state_trackers/python/p_texture.i | 84 +++++++++++++++++++++----- src/gallium/state_trackers/python/st_device.h | 19 ++++++ src/gallium/state_trackers/python/st_sample.c | 22 ++++--- src/gallium/state_trackers/python/st_sample.h | 2 +- 7 files changed, 206 insertions(+), 39 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i index 38f8245adf5..3f79cc1a3d7 100644 --- a/src/gallium/state_trackers/python/gallium.i +++ b/src/gallium/state_trackers/python/gallium.i @@ -69,7 +69,7 @@ %rename(Device) st_device; %rename(Context) st_context; %rename(Texture) pipe_texture; -%rename(Surface) pipe_surface; +%rename(Surface) st_surface; %rename(Buffer) pipe_buffer; %rename(BlendColor) pipe_blend_color; diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 6dcd38e7d14..a0bf063d814 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -124,7 +124,9 @@ struct st_context { $self->pipe->set_constant_buffer($self->pipe, shader, index, &state); } - void set_framebuffer(const struct pipe_framebuffer_state *state ) { + void set_framebuffer(const struct pipe_framebuffer_state *state ) + { + memcpy(&$self->framebuffer, state, sizeof *state); cso_set_framebuffer($self->cso, state); } @@ -265,23 +267,86 @@ error1: * Surface functions */ - void surface_copy(struct pipe_surface *dest, + void surface_copy(struct st_surface *dst, unsigned destx, unsigned desty, - struct pipe_surface *src, + struct st_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) { - $self->pipe->surface_copy($self->pipe, dest, destx, desty, src, srcx, srcy, width, height); + unsigned width, unsigned height) + { + struct pipe_surface *_dst = NULL; + struct pipe_surface *_src = NULL; + + _dst = st_pipe_surface(dst, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_dst) + SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing"); + + _src = st_pipe_surface(src, PIPE_BUFFER_USAGE_GPU_READ); + if(!_src) + SWIG_exception(SWIG_ValueError, "couldn't acquire source surface for reading"); + + $self->pipe->surface_copy($self->pipe, _dst, destx, desty, _src, srcx, srcy, width, height); + + fail: + pipe_surface_reference(&_src, NULL); + pipe_surface_reference(&_dst, NULL); } - void surface_fill(struct pipe_surface *dst, + void surface_fill(struct st_surface *dst, unsigned x, unsigned y, unsigned width, unsigned height, - unsigned value) { - $self->pipe->surface_fill($self->pipe, dst, x, y, width, height, value); + unsigned value) + { + struct pipe_surface *_dst = NULL; + + _dst = st_pipe_surface(dst, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_dst) + SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing"); + + $self->pipe->surface_fill($self->pipe, _dst, x, y, width, height, value); + + fail: + pipe_surface_reference(&_dst, NULL); } - void surface_clear(struct pipe_surface *surface, unsigned value = 0) { - $self->pipe->clear($self->pipe, surface, value); + void surface_clear(struct st_surface *surface, unsigned value = 0) + { + unsigned i; + struct pipe_surface *_surface = NULL; + + if(!surface) + SWIG_exception(SWIG_TypeError, "surface must not be null"); + + for(i = 0; i < $self->framebuffer.nr_cbufs; ++i) { + struct pipe_surface *cbuf = $self->framebuffer.cbufs[i]; + if(cbuf) { + if(cbuf->texture == surface->texture && + cbuf->face == surface->face && + cbuf->level == surface->level && + cbuf->zslice == surface->zslice) { + _surface = cbuf; + break; + } + } + } + + if(!_surface) { + struct pipe_surface *zsbuf = $self->framebuffer.zsbuf; + if(zsbuf) { + if(zsbuf->texture == surface->texture && + zsbuf->face == surface->face && + zsbuf->level == surface->level && + zsbuf->zslice == surface->zslice) { + _surface = zsbuf; + } + } + } + + if(!_surface) + SWIG_exception(SWIG_ValueError, "surface not bound"); + + $self->pipe->clear($self->pipe, _surface, value); + fail: + return; } }; diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i index 110b3d5da43..fc8607ba72f 100644 --- a/src/gallium/state_trackers/python/p_state.i +++ b/src/gallium/state_trackers/python/p_state.i @@ -59,13 +59,36 @@ } void - set_cbuf(unsigned index, struct pipe_surface *surface) { - pipe_surface_reference(&$self->cbufs[index], surface); + set_cbuf(unsigned index, struct st_surface *surface) + { + struct pipe_surface *_surface = NULL; + + if(index >= PIPE_MAX_COLOR_BUFS) + SWIG_exception(SWIG_ValueError, "index out of bounds"); + + _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_surface) + SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing"); + + pipe_surface_reference(&$self->cbufs[index], _surface); + + fail: + return; } void - set_zsbuf(struct pipe_surface *surface) { - pipe_surface_reference(&$self->zsbuf, surface); + set_zsbuf(struct st_surface *surface) + { + struct pipe_surface *_surface = NULL; + + _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_surface) + SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing"); + + pipe_surface_reference(&$self->zsbuf, _surface); + + fail: + return; } }; diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index fee9fb0bf84..543a0cf33f8 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -34,18 +34,19 @@ %nodefaultctor pipe_texture; -%nodefaultctor pipe_surface; +%nodefaultctor st_surface; %nodefaultctor pipe_buffer; %nodefaultdtor pipe_texture; -%nodefaultdtor pipe_surface; +%nodefaultdtor st_surface; %nodefaultdtor pipe_buffer; %ignore pipe_texture::screen; -%ignore pipe_surface::winsys; -%immutable pipe_surface::texture; -%immutable pipe_surface::buffer; +%immutable st_surface::texture; +%immutable st_surface::face; +%immutable st_surface::level; +%immutable st_surface::zslice; %newobject pipe_texture::get_surface; @@ -78,22 +79,57 @@ } /** Get a surface which is a "view" into a texture */ - struct pipe_surface * - get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0 ) + struct st_surface * + get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0) { - const usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE; - struct pipe_screen *screen = $self->screen; - return screen->get_tex_surface(screen, $self, face, level, zslice, usage); + struct st_surface *surface; + + if(face >= ($self->target == PIPE_TEXTURE_CUBE ? 6 : 1)) + SWIG_exception(SWIG_ValueError, "face out of bounds"); + if(level > $self->last_level) + SWIG_exception(SWIG_ValueError, "level out of bounds"); + if(zslice >= $self->depth[level]) + SWIG_exception(SWIG_ValueError, "zslice out of bounds"); + + surface = CALLOC_STRUCT(st_surface); + if(!surface) + return NULL; + + pipe_texture_reference(&surface->texture, $self); + surface->face = face; + surface->level = level; + surface->zslice = zslice; + + return surface; + + fail: + return NULL; } }; +struct st_surface +{ + %immutable; + + struct pipe_texture *texture; + unsigned face; + unsigned level; + unsigned zslice; + +}; -%extend pipe_surface { +%extend st_surface { + + %immutable; - ~pipe_surface() { - struct pipe_surface *ptr = $self; - pipe_surface_reference(&ptr, NULL); + unsigned format; + unsigned width; + unsigned height; + + ~st_surface() { + pipe_texture_reference(&$self->texture, NULL); + FREE($self); } void @@ -309,6 +345,26 @@ }; +%{ + static enum pipe_format + st_surface_format_get(struct st_surface *surface) + { + return surface->texture->format; + } + + static unsigned + st_surface_width_get(struct st_surface *surface) + { + return surface->texture->width[surface->level]; + } + + static unsigned + st_surface_height_get(struct st_surface *surface) + { + return surface->texture->height[surface->level]; + } +%} + /* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */ %rename(read) pipe_buffer_read_; %rename(write) pipe_buffer_write_; diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h index d1bd8c31f4f..a246b6a1f25 100644 --- a/src/gallium/state_trackers/python/st_device.h +++ b/src/gallium/state_trackers/python/st_device.h @@ -38,6 +38,15 @@ struct pipe_context; struct st_winsys; +struct st_surface +{ + struct pipe_texture *texture; + unsigned face; + unsigned level; + unsigned zslice; +}; + + struct st_context { struct st_device *st_dev; @@ -57,6 +66,8 @@ struct st_context { unsigned num_vertex_elements; struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS]; + + struct pipe_framebuffer_state framebuffer; }; @@ -71,6 +82,14 @@ struct st_device { }; +static INLINE struct pipe_surface * +st_pipe_surface(struct st_surface *surface, unsigned usage) +{ + struct pipe_texture *texture = surface->texture; + struct pipe_screen *screen = texture->screen; + return screen->get_tex_surface(screen, texture, surface->face, surface->level, surface->zslice, usage); +} + struct st_context * st_context_create(struct st_device *st_dev); diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index c2ffe9fce1d..70ca16c23dd 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -34,6 +34,7 @@ #include "util/u_math.h" #include "util/u_memory.h" +#include "st_device.h" #include "st_sample.h" @@ -523,10 +524,13 @@ st_sample_pixel_block(enum pipe_format format, void -st_sample_surface(struct pipe_surface *surface, float *rgba) +st_sample_surface(struct st_surface *surface, float *rgba) { - struct pipe_screen *screen = surface->texture->screen; - uint rgba_stride = surface->width * 4; + struct pipe_texture *texture = surface->texture; + struct pipe_screen *screen = texture->screen; + unsigned width = texture->width[surface->level]; + unsigned height = texture->height[surface->level]; + uint rgba_stride = width * 4; struct pipe_transfer *transfer; void *raw; @@ -537,25 +541,25 @@ st_sample_surface(struct pipe_surface *surface, float *rgba) surface->zslice, PIPE_TRANSFER_READ, 0, 0, - surface->width, - surface->height); + width, + height); if (!transfer) return; raw = screen->transfer_map(screen, transfer); if (raw) { - const struct pipe_format_block *block = &transfer->block; + const struct pipe_format_block *block = &texture->block; uint x, y; for (y = 0; y < transfer->nblocksy; ++y) { for (x = 0; x < transfer->nblocksx; ++x) { - st_sample_pixel_block(surface->format, + st_sample_pixel_block(texture->format, block, (uint8_t *) raw + y * transfer->stride + x * block->size, rgba + y * block->height * rgba_stride + x * block->width * 4, rgba_stride, - MIN2(block->width, surface->width - x*block->width), - MIN2(block->height, surface->height - y*block->height)); + MIN2(block->width, width - x*block->width), + MIN2(block->height, height - y*block->height)); } } diff --git a/src/gallium/state_trackers/python/st_sample.h b/src/gallium/state_trackers/python/st_sample.h index ff04a12613f..0a27083549f 100644 --- a/src/gallium/state_trackers/python/st_sample.h +++ b/src/gallium/state_trackers/python/st_sample.h @@ -41,7 +41,7 @@ st_sample_pixel_block(enum pipe_format format, unsigned w, unsigned h); void -st_sample_surface(struct pipe_surface *surface, float *rgba); +st_sample_surface(struct st_surface *surface, float *rgba); #endif /* ST_SAMPLE_H_ */ -- cgit v1.2.3 From 844868048f404ab941cc2e75358b77463ee67482 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 17:08:23 +0100 Subject: python: Set correct transfer mode. --- src/gallium/state_trackers/python/p_texture.i | 2 +- src/gallium/state_trackers/python/st_sample.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 543a0cf33f8..b97d1889737 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -315,7 +315,7 @@ struct st_surface $self->face, $self->level, $self->zslice, - PIPE_TRANSFER_WRITE, + PIPE_TRANSFER_READ, x, y, w, h); if(!transfer) { FREE(rgba2); diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index 70ca16c23dd..53a01891e12 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -539,7 +539,7 @@ st_sample_surface(struct st_surface *surface, float *rgba) surface->face, surface->level, surface->zslice, - PIPE_TRANSFER_READ, + PIPE_TRANSFER_WRITE, 0, 0, width, height); -- cgit v1.2.3 From af25470a5430c68e157489ff095baa5d548d8783 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 17:09:03 +0100 Subject: python: Force unsigned comparison. --- src/gallium/state_trackers/python/p_texture.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index b97d1889737..47bcd4ba3c6 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -84,7 +84,7 @@ { struct st_surface *surface; - if(face >= ($self->target == PIPE_TEXTURE_CUBE ? 6 : 1)) + if(face >= ($self->target == PIPE_TEXTURE_CUBE ? 6U : 1U)) SWIG_exception(SWIG_ValueError, "face out of bounds"); if(level > $self->last_level) SWIG_exception(SWIG_ValueError, "level out of bounds"); -- cgit v1.2.3 From a8251d041ac323712a00d5fed3e51fa5ad7bc987 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 17:51:55 +0100 Subject: python/test: Move the image comparison logic to the base test class. --- src/gallium/state_trackers/python/tests/base.py | 21 ++++++++++++++++++++- src/gallium/state_trackers/python/tests/texture.py | 18 +----------------- 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 8477aa5fc9b..2df2af0cdf2 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -33,6 +33,8 @@ Loosely inspired on Python's unittest module. """ +import sys + from gallium import * @@ -115,6 +117,23 @@ class Test: self._run(result) result.summary() + def assert_rgba(self, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85): + total = h*w + different = surface.compare_tile_rgba(x, y, w, h, expected_rgba, tol=pixel_tol) + if different: + sys.stderr.write("%u out of %u pixels differ\n" % (different, total)) + + if float(total - different)/float(total) < surface_tol: + if 0: + rgba = FloatArray(h*w*4) + surface.get_tile_rgba(x, y, w, h, rgba) + show_image(w, h, Result=rgba, Expected=expected_rgba) + save_image(w, h, rgba, "result.png") + save_image(w, h, expected_rgba, "expected.png") + #sys.exit(0) + + raise TestFailure + class TestCase(Test): @@ -190,4 +209,4 @@ class TestResult: print "%u tests, %u passed, %u skipped, %u failed" % (self.tests, self.passed, self.skipped, self.failed) for description in self.failed_descriptions: print " %s" % description - \ No newline at end of file + diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py index bd95f734fe7..58b7e1c1246 100644 --- a/src/gallium/state_trackers/python/tests/texture.py +++ b/src/gallium/state_trackers/python/tests/texture.py @@ -27,7 +27,6 @@ ########################################################################## -import sys from gallium import * from base import * @@ -291,22 +290,7 @@ class TextureTest(TestCase): cbuf = cbuf_tex.get_surface() - total = h*w - different = cbuf.compare_tile_rgba(x, y, w, h, expected_rgba, tol=4.0/256) - if different: - sys.stderr.write("%u out of %u pixels differ\n" % (different, total)) - - if float(total - different)/float(total) < 0.85: - - if 0: - rgba = FloatArray(h*w*4) - cbuf.get_tile_rgba(x, y, w, h, rgba) - show_image(w, h, Result=rgba, Expected=expected_rgba) - save_image(w, h, rgba, "result.png") - save_image(w, h, expected_rgba, "expected.png") - #sys.exit(0) - - raise TestFailure + self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85) del ctx -- cgit v1.2.3 From 5e815cf26fe4789d92c0fa018e6a20c463e20d32 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 18:18:15 +0100 Subject: python/test: Move the test description logic to the base class. --- src/gallium/state_trackers/python/tests/base.py | 44 +++++++++++++++++++++- src/gallium/state_trackers/python/tests/texture.py | 37 ++++++------------ 2 files changed, 54 insertions(+), 27 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 2df2af0cdf2..10964d99568 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -137,14 +137,54 @@ class Test: class TestCase(Test): + tags = () + def __init__(self, dev, **kargs): Test.__init__(self) self.dev = dev self.__dict__.update(kargs) def description(self): - raise NotImplementedError - + descriptions = [] + for tag in self.tags: + try: + method = getattr(self, '_describe_' + tag) + except AttributeError: + description = str(getattr(self, tag, None)) + else: + description = method() + if description is not None: + descriptions.append(tag + '=' + description) + return ' '.join(descriptions) + + def _describe_target(self): + return { + PIPE_TEXTURE_1D: "1d", + PIPE_TEXTURE_2D: "2d", + PIPE_TEXTURE_3D: "3d", + PIPE_TEXTURE_CUBE: "cube", + }[self.target] + + def _describe_format(self): + name = formats[self.format] + if name.startswith('PIPE_FORMAT_'): + name = name[12:] + name = name.lower() + return name + + def _describe_face(self): + if self.target == PIPE_TEXTURE_CUBE: + return { + PIPE_TEX_FACE_POS_X: "+x", + PIPE_TEX_FACE_NEG_X: "-x", + PIPE_TEX_FACE_POS_Y: "+y", + PIPE_TEX_FACE_NEG_Y: "-y", + PIPE_TEX_FACE_POS_Z: "+z", + PIPE_TEX_FACE_NEG_Z: "-z", + }[self.face] + else: + return None + def test(self): raise NotImplementedError diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py index 58b7e1c1246..fcb347f9a17 100644 --- a/src/gallium/state_trackers/python/tests/texture.py +++ b/src/gallium/state_trackers/python/tests/texture.py @@ -100,31 +100,18 @@ def is_pot(n): class TextureTest(TestCase): - def description(self): - target = { - PIPE_TEXTURE_1D: "1d", - PIPE_TEXTURE_2D: "2d", - PIPE_TEXTURE_3D: "3d", - PIPE_TEXTURE_CUBE: "cube", - }[self.target] - format = formats[self.format] - if self.target == PIPE_TEXTURE_CUBE: - face = { - PIPE_TEX_FACE_POS_X: "+x", - PIPE_TEX_FACE_NEG_X: "-x", - PIPE_TEX_FACE_POS_Y: "+y", - PIPE_TEX_FACE_NEG_Y: "-y", - PIPE_TEX_FACE_POS_Z: "+z", - PIPE_TEX_FACE_NEG_Z: "-z", - }[self.face] - else: - face = "" - return "%s %s %ux%ux%u last_level=%u face=%s level=%u zslice=%u" % ( - target, format, - self.width, self.height, self.depth, self.last_level, - face, self.level, self.zslice, - ) - + tags = ( + 'target', + 'format', + 'width', + 'height', + 'depth', + 'last_level', + 'face', + 'level', + 'zslice', + ) + def test(self): dev = self.dev -- cgit v1.2.3 From 76d43ed4c98c4e5ad23dd342ecf3ed83b35fdcd7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 18:26:40 +0100 Subject: python: Don't use deprecated clear_value field. --- src/gallium/state_trackers/python/samples/tri.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index 72e94560af4..ed72e4383bb 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -142,8 +142,7 @@ def test(dev): fb.nr_cbufs = 1 fb.set_cbuf(0, _cbuf) ctx.set_framebuffer(fb) - _cbuf.clear_value = 0x00000000 - ctx.surface_clear(_cbuf, _cbuf.clear_value) + ctx.surface_clear(_cbuf, 0x00000000) del _cbuf # vertex shader -- cgit v1.2.3 From ffaff2736f703523a603f758254b682e6e698ae5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 18:29:35 +0100 Subject: python: Cleanup. --- src/gallium/state_trackers/python/samples/tri.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index ed72e4383bb..d5e9dcd951a 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -134,16 +134,15 @@ def test(dev): PIPE_FORMAT_X8R8G8B8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, - ) - _cbuf = cbuf.get_surface() + ).get_surface() + fb = Framebuffer() fb.width = width fb.height = height fb.nr_cbufs = 1 - fb.set_cbuf(0, _cbuf) + fb.set_cbuf(0, cbuf) ctx.set_framebuffer(fb) - ctx.surface_clear(_cbuf, 0x00000000) - del _cbuf + ctx.surface_clear(cbuf, 0x00000000) # vertex shader vs = Shader(''' @@ -204,8 +203,8 @@ def test(dev): ctx.flush() - show_image(cbuf.get_surface()) - #save_image('tri.png', cbuf.get_surface()) + show_image(cbuf) + #save_image('tri.png', cbuf) -- cgit v1.2.3 From b4de7c4c5fc1a6b103fea1139c7a01f0d6a401ad Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 19:48:30 +0100 Subject: python: Read rgba8 with a single transfer. --- src/gallium/state_trackers/python/p_texture.i | 31 ++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 47bcd4ba3c6..db7a1358e14 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -225,31 +225,28 @@ struct st_surface if(!*STRING) return; - rgba = malloc(w*4*sizeof(float)); + rgba = malloc(h*w*4*sizeof(float)); if(!rgba) return; rgba8 = (unsigned char *) *STRING; - for(j = 0; j < h; ++j) { - transfer = screen->get_tex_transfer(screen, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_READ, - x, y + j, - w, - 1); - if(transfer) { - pipe_get_tile_rgba(transfer, - 0, 0, w, 1, - rgba); + transfer = screen->get_tex_transfer(screen, + $self->texture, + $self->face, + $self->level, + $self->zslice, + PIPE_TRANSFER_READ, + x, y, + w, h); + if(transfer) { + pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba); + for(j = 0; j < h; ++j) { for(i = 0; i < w; ++i) for(k = 0; k <4; ++k) - rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[i*4 + k]); - screen->tex_transfer_destroy(transfer); + rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]); } + screen->tex_transfer_destroy(transfer); } free(rgba); -- cgit v1.2.3 From f24ce499691a342b680e6c3d7aa257480e5d69d9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Mar 2009 19:49:11 +0100 Subject: python: Use depth buffer in the triangle example. --- src/gallium/state_trackers/python/samples/tri.py | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index d5e9dcd951a..4c84d121c49 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -68,7 +68,7 @@ def test(dev): width = 255 height = 255 minz = 0.0 - maxz = 0.0 + maxz = 1.0 # disabled blending/masking blend = Blend() @@ -79,8 +79,11 @@ def test(dev): blend.colormask = PIPE_MASK_RGBA ctx.set_blend(blend) - # no-op depth/stencil/alpha + # depth/stencil/alpha depth_stencil_alpha = DepthStencilAlpha() + depth_stencil_alpha.depth.enabled = 1 + depth_stencil_alpha.depth.writemask = 1 + depth_stencil_alpha.depth.func = PIPE_FUNC_LESS ctx.set_depth_stencil_alpha(depth_stencil_alpha) # rasterizer @@ -135,14 +138,20 @@ def test(dev): width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() - + zbuf = dev.texture_create( + PIPE_FORMAT_Z32_UNORM, + width, height, + tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL, + ).get_surface() fb = Framebuffer() fb.width = width fb.height = height fb.nr_cbufs = 1 fb.set_cbuf(0, cbuf) + fb.set_zsbuf(zbuf) ctx.set_framebuffer(fb) ctx.surface_clear(cbuf, 0x00000000) + ctx.surface_clear(zbuf, 0xffffffff) # vertex shader vs = Shader(''' @@ -173,7 +182,7 @@ def test(dev): verts[ 0] = 0.0 # x1 verts[ 1] = 0.8 # y1 - verts[ 2] = 0.0 # z1 + verts[ 2] = 0.2 # z1 verts[ 3] = 1.0 # w1 verts[ 4] = 1.0 # r1 verts[ 5] = 0.0 # g1 @@ -181,7 +190,7 @@ def test(dev): verts[ 7] = 1.0 # a1 verts[ 8] = -0.8 # x2 verts[ 9] = -0.8 # y2 - verts[10] = 0.0 # z2 + verts[10] = 0.5 # z2 verts[11] = 1.0 # w2 verts[12] = 0.0 # r2 verts[13] = 1.0 # g2 @@ -189,7 +198,7 @@ def test(dev): verts[15] = 1.0 # a2 verts[16] = 0.8 # x3 verts[17] = -0.8 # y3 - verts[18] = 0.0 # z3 + verts[18] = 0.8 # z3 verts[19] = 1.0 # w3 verts[20] = 0.0 # r3 verts[21] = 0.0 # g3 @@ -204,7 +213,9 @@ def test(dev): ctx.flush() show_image(cbuf) - #save_image('tri.png', cbuf) + #show_image(zbuf) + #save_image('cbuf.png', cbuf) + #save_image('zbuf.png', zbuf) -- cgit v1.2.3 From 458bfe7e8dd429b9dcb980013ac7979689db1367 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 13:55:00 -0700 Subject: r300-gallium: Handful of small leftovers. --- src/gallium/drivers/r300/r300_state_invariant.c | 2 +- src/gallium/drivers/r300/r300_surface.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 3705ff98db5..421f01e62ec 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -86,7 +86,7 @@ void r300_emit_invariant_state(struct r300_context* r300) END_CS; /* XXX unsorted stuff from surface_fill */ - BEGIN_CS(91 + (caps->has_tcl ? 26 : 0)); + BEGIN_CS(81 + (caps->has_tcl ? 26 : 0)); /* Flush PVS. */ OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 96b63986ea7..b2e0cef0b94 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -88,6 +88,7 @@ static void r300_surface_fill(struct pipe_context* pipe, float r, g, b, a, depth; unsigned pixpitch = tex->stride / tex->tex.block.size; + a = (float)((color >> 24) & 0xff) / 255.0f; r = (float)((color >> 16) & 0xff) / 255.0f; g = (float)((color >> 8) & 0xff) / 255.0f; b = (float)((color >> 0) & 0xff) / 255.0f; @@ -158,11 +159,12 @@ static void r300_surface_fill(struct pipe_context* pipe, OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8); OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING | (1 << R300_PRIM_NUM_VERTICES_SHIFT)); + /* Position */ OUT_CS_32F(w / 2.0); OUT_CS_32F(h / 2.0); - /* XXX this should be the depth value to clear to */ OUT_CS_32F(1.0); OUT_CS_32F(1.0); + /* Color */ OUT_CS_32F(r); OUT_CS_32F(g); OUT_CS_32F(b); -- cgit v1.2.3 From 7620b3943b5f9d6ab7156e245aade3bf2a5358a2 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 15:47:00 -0700 Subject: r300-gallium: Fix strange build error. Why didn't this come up before? --- src/gallium/drivers/r300/r300_state_invariant.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h index 8204bf9588b..5bea6779fe5 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.h +++ b/src/gallium/drivers/r300/r300_state_invariant.h @@ -23,6 +23,7 @@ #ifndef R300_STATE_INVARIANT_H #define R300_STATE_INVARIANT_H +#include "r300_chipset.h" #include "r300_context.h" #include "r300_cs.h" #include "r300_reg.h" -- cgit v1.2.3 From a56020fe17b3d26ea0ea933dd4e8286e5029996f Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 15:50:09 -0700 Subject: r300-gallium: Fix hardlock when no colors or textures are present. --- src/gallium/drivers/r300/r300_state_derived.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index d761a0302f0..0e7a2b6726f 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -211,7 +211,6 @@ static void r300_update_rs_block(struct r300_context* r300) rs->ip[0] |= R500_RS_COL_FMT(R300_RS_COL_FMT_0001); } - /* Set up at least one texture pointer or RS will not be happy. */ if (tex_count == 0) { rs->ip[0] |= R500_RS_SEL_S(R500_RS_IP_PTR_K0) | @@ -220,15 +219,20 @@ static void r300_update_rs_block(struct r300_context* r300) R500_RS_SEL_Q(R500_RS_IP_PTR_K1); } + /* Rasterize at least one color, or bad things happen. */ + if ((col_count == 0) && (tex_count == 0)) { + col_count++; + } + for (i = 0; i < tex_count; i++) { - rs->inst[i] |= R500_RS_INST_TEX_ID(i) | R500_RS_INST_TEX_CN_WRITE | - R500_RS_INST_TEX_ADDR(fp_offset); + rs->inst[i] |= R500_RS_INST_TEX_ID(i) | + R500_RS_INST_TEX_CN_WRITE | R500_RS_INST_TEX_ADDR(fp_offset); fp_offset++; } for (i = 0; i < col_count; i++) { - rs->inst[i] |= R500_RS_INST_COL_ID(i) | R500_RS_INST_COL_CN_WRITE | - R500_RS_INST_COL_ADDR(fp_offset); + rs->inst[i] |= R500_RS_INST_COL_ID(i) | + R500_RS_INST_COL_CN_WRITE | R500_RS_INST_COL_ADDR(fp_offset); fp_offset++; } } else { @@ -268,15 +272,20 @@ static void r300_update_rs_block(struct r300_context* r300) R300_RS_SEL_Q(R300_RS_SEL_K1); } + /* Rasterize at least one color, or bad things happen. */ + if ((col_count == 0) && (tex_count == 0)) { + col_count++; + } + for (i = 0; i < tex_count; i++) { - rs->inst[i] |= R300_RS_INST_TEX_ID(i) | R300_RS_INST_TEX_CN_WRITE | - R300_RS_INST_TEX_ADDR(fp_offset); + rs->inst[i] |= R300_RS_INST_TEX_ID(i) | + R300_RS_INST_TEX_CN_WRITE | R300_RS_INST_TEX_ADDR(fp_offset); fp_offset++; } for (i = 0; i < col_count; i++) { - rs->inst[i] |= R300_RS_INST_COL_ID(i) | R300_RS_INST_COL_CN_WRITE | - R300_RS_INST_COL_ADDR(fp_offset); + rs->inst[i] |= R300_RS_INST_COL_ID(i) | + R300_RS_INST_COL_CN_WRITE | R300_RS_INST_COL_ADDR(fp_offset); fp_offset++; } } -- cgit v1.2.3 From 4bfe784dcadf5bcb65dbd8b9c3d4db757d1824b8 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 16:15:04 -0700 Subject: r300-gallium: Emit the "right" sequence of colors. ARGB, not RGBA. --- src/gallium/drivers/r300/r300_surface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index b2e0cef0b94..6ecc708e000 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -165,10 +165,10 @@ static void r300_surface_fill(struct pipe_context* pipe, OUT_CS_32F(1.0); OUT_CS_32F(1.0); /* Color */ + OUT_CS_32F(a); OUT_CS_32F(r); OUT_CS_32F(g); OUT_CS_32F(b); - OUT_CS_32F(1.0); /* XXX figure out why this is 0xA and not 0x2 */ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); -- cgit v1.2.3 From 70d39c70536079eb51298086c559e4b40e6ffc03 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 16:51:01 -0700 Subject: r300-gallium: Allow surface_fill to clear depth/stencil buffers too. --- src/gallium/drivers/r300/r300_state_inlines.h | 2 ++ src/gallium/drivers/r300/r300_surface.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index b80ff1c1aba..91b93fc367e 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -292,6 +292,7 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format) return R300_COLOR_FORMAT_ARGB4444; /* 32-bit buffers */ case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return R300_COLOR_FORMAT_ARGB8888; /* XXX Not in pipe_format case PIPE_FORMAT_A32R32G32B32: @@ -337,6 +338,7 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format) { switch (format) { case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return R300_US_OUT_FMT_C4_8 | R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A; diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 6ecc708e000..7e6036868a9 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -97,7 +97,7 @@ static void r300_surface_fill(struct pipe_context* pipe, dest, x, y, w, h, pixpitch, color); /* Fallback? */ - if (tex->tex.format != PIPE_FORMAT_A8R8G8B8_UNORM) { + if (FALSE) { debug_printf("r300: Falling back on surface clear..."); util_surface_fill(pipe, dest, x, y, w, h, color); return; -- cgit v1.2.3 From 70de577b14e9b0efab7a749203d50dc19540472d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 16:58:20 -0700 Subject: r300-gallium: Properly redo shaders when constant buffer changes size. --- src/gallium/drivers/r300/r300_state.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 8c38f7c706e..c9a20c9e8ac 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -132,6 +132,7 @@ static void const struct pipe_constant_buffer* buffer) { struct r300_context* r300 = r300_context(pipe); + int i = r300->shader_constants[shader].user_count; /* This entire chunk of code seems ever-so-slightly baked. * It's as if I've got pipe_buffer* matryoshkas... */ @@ -149,6 +150,12 @@ static void } r300->dirty_state |= R300_NEW_CONSTANTS; + + /* If the number of constants have changed, invalidate the shader. */ + if (r300->shader_constants[shader].user_count != i) { + r300->fs->translated = FALSE; + r300_translate_fragment_shader(r300, r300->fs); + } } /* Create a new depth, stencil, and alpha state based on the CSO dsa state. -- cgit v1.2.3 From aafbbf77441dedf6015a4ab61cc7a82ef592415f Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 17:20:12 -0700 Subject: r300-gallium: r500-fs: If recompiling a shader, overwrite old insts. --- src/gallium/drivers/r300/r300_state_shader.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index ed9d26f0b9b..5dc7266f9b1 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -582,6 +582,11 @@ void r300_translate_fragment_shader(struct r300_context* r300, /* Setup starting offset for immediates. */ assembler->imm_offset = consts->user_count; + /* Make sure we start at the beginning of the shader. */ + if (is_r500) { + ((struct r500_fragment_shader*)fs)->instruction_count = 0; + } + tgsi_parse_init(&parser, fs->state.tokens); while (!tgsi_parse_end_of_tokens(&parser)) { -- cgit v1.2.3 From 3eeeaf04e31b8aed831f29d8a192f3f9a0a8ef03 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 17:31:58 -0700 Subject: r300-gallium: RGBA, not ARGB, after all. Clearly, something else is wrong. --- src/gallium/drivers/r300/r300_surface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 7e6036868a9..9c4f3065a7f 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -165,10 +165,10 @@ static void r300_surface_fill(struct pipe_context* pipe, OUT_CS_32F(1.0); OUT_CS_32F(1.0); /* Color */ - OUT_CS_32F(a); OUT_CS_32F(r); OUT_CS_32F(g); OUT_CS_32F(b); + OUT_CS_32F(a); /* XXX figure out why this is 0xA and not 0x2 */ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); -- cgit v1.2.3 From 382306c5732dd04f514bb1d8f2b050bd6d58a893 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 09:46:55 +0100 Subject: gallium: Move pf_is_depth_stencil to p_format.h. --- src/gallium/include/pipe/p_format.h | 7 +++++++ src/mesa/state_tracker/st_texture.h | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 3f65a604364..a279eefef9e 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -536,6 +536,13 @@ pf_get_nblocks(const struct pipe_format_block *block, unsigned width, unsigned h return pf_get_nblocksx(block, width)*pf_get_nblocksy(block, height); } +static INLINE boolean +pf_is_depth_stencil( enum pipe_format format ) +{ + return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) + + pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0; +} + static INLINE boolean pf_is_compressed( enum pipe_format format ) { diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 840b7e27cc0..28c2f580f68 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -99,12 +99,6 @@ st_get_stobj_texture(struct st_texture_object *stObj) return stObj ? stObj->pt : NULL; } -static INLINE GLboolean pf_is_depth_stencil( enum pipe_format format ) -{ - return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) + - pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0; -} - extern struct pipe_texture * st_texture_create(struct st_context *st, -- cgit v1.2.3 From e848a86dbacbec0bed16fac29264c77f4c2eeb0c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 10:57:44 +0100 Subject: python: Add nblocksx/y members to surfaces. --- src/gallium/state_trackers/python/p_texture.i | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index db7a1358e14..7c1f1c361a4 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -126,6 +126,8 @@ struct st_surface unsigned format; unsigned width; unsigned height; + unsigned nblocksx; + unsigned nblocksy; ~st_surface() { pipe_texture_reference(&$self->texture, NULL); @@ -360,6 +362,18 @@ struct st_surface { return surface->texture->height[surface->level]; } + + static unsigned + st_surface_nblocksx_get(struct st_surface *surface) + { + return surface->texture->nblocksx[surface->level]; + } + + static unsigned + st_surface_nblocksy_get(struct st_surface *surface) + { + return surface->texture->nblocksy[surface->level]; + } %} /* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */ -- cgit v1.2.3 From b4b4986f1f0be2f5d0f70fcca25f29c5637e4d92 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 10:58:18 +0100 Subject: python: Make get/put_tile_raw more user friendlier. --- src/gallium/state_trackers/python/p_texture.i | 43 ++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 7c1f1c361a4..276fa795cce 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -134,11 +134,20 @@ struct st_surface FREE($self); } - void - get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char *raw, unsigned stride) + %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); + void get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_texture *texture = $self->texture; + struct pipe_screen *screen = texture->screen; struct pipe_transfer *transfer; + unsigned stride; + + stride = pf_get_nblocksx(&texture->block, w) * texture->block.size; + *LENGTH = pf_get_nblocksy(&texture->block, h) * stride; + *STRING = (char *) malloc(*LENGTH); + if(!*STRING) + return; + transfer = screen->get_tex_transfer(screen, $self->texture, $self->face, @@ -147,16 +156,24 @@ struct st_surface PIPE_TRANSFER_READ, x, y, w, h); if(transfer) { - pipe_get_tile_raw(transfer, 0, 0, w, h, raw, stride); + pipe_get_tile_raw(transfer, 0, 0, w, h, *STRING, stride); screen->tex_transfer_destroy(transfer); } } - void - put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *raw, unsigned stride) + %cstring_input_binary(const char *STRING, unsigned LENGTH); + void put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *STRING, unsigned LENGTH, unsigned stride = 0) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_texture *texture = $self->texture; + struct pipe_screen *screen = texture->screen; struct pipe_transfer *transfer; + + if(stride == 0) + stride = pf_get_nblocksx(&texture->block, w) * texture->block.size; + + if(LENGTH < pf_get_nblocksy(&texture->block, h) * stride) + SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size"); + transfer = screen->get_tex_transfer(screen, $self->texture, $self->face, @@ -164,10 +181,14 @@ struct st_surface $self->zslice, PIPE_TRANSFER_WRITE, x, y, w, h); - if(transfer) { - pipe_put_tile_raw(transfer, 0, 0, w, h, raw, stride); - screen->tex_transfer_destroy(transfer); - } + if(!transfer) + SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer"); + + pipe_put_tile_raw(transfer, 0, 0, w, h, STRING, stride); + screen->tex_transfer_destroy(transfer); + + fail: + return; } void -- cgit v1.2.3 From 7d5d5a6cb7021b580cbdfd1e4b5f215fa13aa8c5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 11:00:18 +0100 Subject: python/test: More descriptive test name. --- src/gallium/state_trackers/python/tests/texture.py | 350 --------------------- .../state_trackers/python/tests/texture_sample.py | 350 +++++++++++++++++++++ 2 files changed, 350 insertions(+), 350 deletions(-) delete mode 100644 src/gallium/state_trackers/python/tests/texture.py create mode 100644 src/gallium/state_trackers/python/tests/texture_sample.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py deleted file mode 100644 index fcb347f9a17..00000000000 --- a/src/gallium/state_trackers/python/tests/texture.py +++ /dev/null @@ -1,350 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -########################################################################## - - -from gallium import * -from base import * - - -def lods(*dims): - size = max(dims) - lods = 0 - while size: - lods += 1 - size >>= 1 - return lods - - -def minify(dims, level = 1): - return [max(dim>>level, 1) for dim in dims] - - -def tex_coords(texture, face, level, zslice): - st = [ - [0.0, 0.0], - [1.0, 0.0], - [1.0, 1.0], - [0.0, 1.0], - ] - - if texture.target == PIPE_TEXTURE_2D: - return [[s, t, 0.0] for s, t in st] - elif texture.target == PIPE_TEXTURE_3D: - depth = texture.get_depth(level) - if depth > 1: - r = float(zslice)/float(depth - 1) - else: - r = 0.0 - return [[s, t, r] for s, t in st] - elif texture.target == PIPE_TEXTURE_CUBE: - result = [] - for s, t in st: - # See http://developer.nvidia.com/object/cube_map_ogl_tutorial.html - sc = 2.0*s - 1.0 - tc = 2.0*t - 1.0 - if face == PIPE_TEX_FACE_POS_X: - rx = 1.0 - ry = -tc - rz = -sc - if face == PIPE_TEX_FACE_NEG_X: - rx = -1.0 - ry = -tc - rz = sc - if face == PIPE_TEX_FACE_POS_Y: - rx = sc - ry = 1.0 - rz = tc - if face == PIPE_TEX_FACE_NEG_Y: - rx = sc - ry = -1.0 - rz = -tc - if face == PIPE_TEX_FACE_POS_Z: - rx = sc - ry = -tc - rz = 1.0 - if face == PIPE_TEX_FACE_NEG_Z: - rx = -sc - ry = -tc - rz = -1.0 - result.append([rx, ry, rz]) - return result - -def is_pot(n): - return n & (n - 1) == 0 - - -class TextureTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - - tex_usage = PIPE_TEXTURE_USAGE_SAMPLER - geom_flags = 0 - if width != height: - geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE - if not is_pot(width) or not is_pot(height) or not is_pot(depth): - geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO - - if not dev.is_format_supported(format, target, tex_usage, geom_flags): - raise TestSkip - - ctx = self.dev.context_create() - - # disabled blending/masking - blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # no-op depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.bypass_vs_clip_and_viewport = 1 - ctx.set_rasterizer(rasterizer) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - sampler.min_lod = 0 - sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 - ctx.set_sampler(0, sampler) - - # texture - texture = dev.texture_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - tex_usage = tex_usage, - ) - - expected_rgba = FloatArray(height*width*4) - texture.get_surface( - face = face, - level = level, - zslice = zslice, - ).sample_rgba(expected_rgba) - - ctx.set_sampler_texture(0, texture) - - # framebuffer - cbuf_tex = dev.texture_create( - PIPE_FORMAT_A8R8G8B8_UNORM, - width, - height, - tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, - ) - - cbuf = cbuf_tex.get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - ctx.set_framebuffer(fb) - ctx.surface_clear(cbuf, 0x00000000) - del fb - - # vertex shader - vs = Shader(''' - VERT1.1 - DCL IN[0], POSITION, CONSTANT - DCL IN[1], GENERIC, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], GENERIC, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - #vs.dump() - ctx.set_vertex_shader(vs) - - # fragment shader - op = { - PIPE_TEXTURE_1D: "1D", - PIPE_TEXTURE_2D: "2D", - PIPE_TEXTURE_3D: "3D", - PIPE_TEXTURE_CUBE: "CUBE", - }[target] - fs = Shader(''' - FRAG1.1 - DCL IN[0], GENERIC[0], LINEAR - DCL OUT[0], COLOR, CONSTANT - DCL SAMP[0], CONSTANT - 0:TEX OUT[0], IN[0], SAMP[0], %s - 1:END - ''' % op) - #fs.dump() - ctx.set_fragment_shader(fs) - - nverts = 4 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - x = 0 - y = 0 - w, h = minify((width, height), level) - - pos = [ - [x, y], - [x+w, y], - [x+w, y+h], - [x, y+h], - ] - - tex = tex_coords(texture, face, level, zslice) - - for i in range(0, 4): - j = 8*i - verts[j + 0] = pos[i][0] # x - verts[j + 1] = pos[i][1] # y - verts[j + 2] = 0.0 # z - verts[j + 3] = 1.0 # w - verts[j + 4] = tex[i][0] # s - verts[j + 5] = tex[i][1] # r - verts[j + 6] = tex[i][2] # q - verts[j + 7] = 1.0 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, - nverts, - nattrs, - verts) - - ctx.flush() - - cbuf = cbuf_tex.get_surface() - - self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85) - - del ctx - - - -def main(): - dev = Device() - suite = TestSuite() - - targets = [] - targets += [PIPE_TEXTURE_2D] - targets += [PIPE_TEXTURE_CUBE] - targets += [PIPE_TEXTURE_3D] - - formats = [] - formats += [PIPE_FORMAT_A8R8G8B8_UNORM] - formats += [PIPE_FORMAT_R5G6B5_UNORM] - formats += [PIPE_FORMAT_L8_UNORM] - formats += [PIPE_FORMAT_YCBCR] - formats += [PIPE_FORMAT_DXT1_RGB] - - sizes = [64, 32, 16, 8, 4, 2, 1] - #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] - #sizes = [64] - #sizes = [63] - - for target in targets: - for format in formats: - for size in sizes: - if target == PIPE_TEXTURE_CUBE: - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - #faces = [PIPE_TEX_FACE_NEG_X] - else: - faces = [0] - if target == PIPE_TEXTURE_3D: - depth = size - else: - depth = 1 - for face in faces: - levels = lods(size) - for last_level in range(levels): - for level in range(0, last_level + 1): - zslice = 0 - while zslice < depth >> level: - test = TextureTest( - dev = dev, - target = target, - format = format, - width = size, - height = size, - depth = depth, - last_level = last_level, - face = face, - level = level, - zslice = zslice, - ) - suite.add_test(test) - zslice = (zslice + 1)*2 - 1 - suite.run() - - -if __name__ == '__main__': - main() diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py new file mode 100644 index 00000000000..fcb347f9a17 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/texture_sample.py @@ -0,0 +1,350 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################## + + +from gallium import * +from base import * + + +def lods(*dims): + size = max(dims) + lods = 0 + while size: + lods += 1 + size >>= 1 + return lods + + +def minify(dims, level = 1): + return [max(dim>>level, 1) for dim in dims] + + +def tex_coords(texture, face, level, zslice): + st = [ + [0.0, 0.0], + [1.0, 0.0], + [1.0, 1.0], + [0.0, 1.0], + ] + + if texture.target == PIPE_TEXTURE_2D: + return [[s, t, 0.0] for s, t in st] + elif texture.target == PIPE_TEXTURE_3D: + depth = texture.get_depth(level) + if depth > 1: + r = float(zslice)/float(depth - 1) + else: + r = 0.0 + return [[s, t, r] for s, t in st] + elif texture.target == PIPE_TEXTURE_CUBE: + result = [] + for s, t in st: + # See http://developer.nvidia.com/object/cube_map_ogl_tutorial.html + sc = 2.0*s - 1.0 + tc = 2.0*t - 1.0 + if face == PIPE_TEX_FACE_POS_X: + rx = 1.0 + ry = -tc + rz = -sc + if face == PIPE_TEX_FACE_NEG_X: + rx = -1.0 + ry = -tc + rz = sc + if face == PIPE_TEX_FACE_POS_Y: + rx = sc + ry = 1.0 + rz = tc + if face == PIPE_TEX_FACE_NEG_Y: + rx = sc + ry = -1.0 + rz = -tc + if face == PIPE_TEX_FACE_POS_Z: + rx = sc + ry = -tc + rz = 1.0 + if face == PIPE_TEX_FACE_NEG_Z: + rx = -sc + ry = -tc + rz = -1.0 + result.append([rx, ry, rz]) + return result + +def is_pot(n): + return n & (n - 1) == 0 + + +class TextureTest(TestCase): + + tags = ( + 'target', + 'format', + 'width', + 'height', + 'depth', + 'last_level', + 'face', + 'level', + 'zslice', + ) + + def test(self): + dev = self.dev + + target = self.target + format = self.format + width = self.width + height = self.height + depth = self.depth + last_level = self.last_level + face = self.face + level = self.level + zslice = self.zslice + + tex_usage = PIPE_TEXTURE_USAGE_SAMPLER + geom_flags = 0 + if width != height: + geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE + if not is_pot(width) or not is_pot(height) or not is_pot(depth): + geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO + + if not dev.is_format_supported(format, target, tex_usage, geom_flags): + raise TestSkip + + ctx = self.dev.context_create() + + # disabled blending/masking + blend = Blend() + blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.colormask = PIPE_MASK_RGBA + ctx.set_blend(blend) + + # no-op depth/stencil/alpha + depth_stencil_alpha = DepthStencilAlpha() + ctx.set_depth_stencil_alpha(depth_stencil_alpha) + + # rasterizer + rasterizer = Rasterizer() + rasterizer.front_winding = PIPE_WINDING_CW + rasterizer.cull_mode = PIPE_WINDING_NONE + rasterizer.bypass_vs_clip_and_viewport = 1 + ctx.set_rasterizer(rasterizer) + + # samplers + sampler = Sampler() + sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.normalized_coords = 1 + sampler.min_lod = 0 + sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 + ctx.set_sampler(0, sampler) + + # texture + texture = dev.texture_create( + target = target, + format = format, + width = width, + height = height, + depth = depth, + last_level = last_level, + tex_usage = tex_usage, + ) + + expected_rgba = FloatArray(height*width*4) + texture.get_surface( + face = face, + level = level, + zslice = zslice, + ).sample_rgba(expected_rgba) + + ctx.set_sampler_texture(0, texture) + + # framebuffer + cbuf_tex = dev.texture_create( + PIPE_FORMAT_A8R8G8B8_UNORM, + width, + height, + tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, + ) + + cbuf = cbuf_tex.get_surface() + fb = Framebuffer() + fb.width = width + fb.height = height + fb.nr_cbufs = 1 + fb.set_cbuf(0, cbuf) + ctx.set_framebuffer(fb) + ctx.surface_clear(cbuf, 0x00000000) + del fb + + # vertex shader + vs = Shader(''' + VERT1.1 + DCL IN[0], POSITION, CONSTANT + DCL IN[1], GENERIC, CONSTANT + DCL OUT[0], POSITION, CONSTANT + DCL OUT[1], GENERIC, CONSTANT + 0:MOV OUT[0], IN[0] + 1:MOV OUT[1], IN[1] + 2:END + ''') + #vs.dump() + ctx.set_vertex_shader(vs) + + # fragment shader + op = { + PIPE_TEXTURE_1D: "1D", + PIPE_TEXTURE_2D: "2D", + PIPE_TEXTURE_3D: "3D", + PIPE_TEXTURE_CUBE: "CUBE", + }[target] + fs = Shader(''' + FRAG1.1 + DCL IN[0], GENERIC[0], LINEAR + DCL OUT[0], COLOR, CONSTANT + DCL SAMP[0], CONSTANT + 0:TEX OUT[0], IN[0], SAMP[0], %s + 1:END + ''' % op) + #fs.dump() + ctx.set_fragment_shader(fs) + + nverts = 4 + nattrs = 2 + verts = FloatArray(nverts * nattrs * 4) + + x = 0 + y = 0 + w, h = minify((width, height), level) + + pos = [ + [x, y], + [x+w, y], + [x+w, y+h], + [x, y+h], + ] + + tex = tex_coords(texture, face, level, zslice) + + for i in range(0, 4): + j = 8*i + verts[j + 0] = pos[i][0] # x + verts[j + 1] = pos[i][1] # y + verts[j + 2] = 0.0 # z + verts[j + 3] = 1.0 # w + verts[j + 4] = tex[i][0] # s + verts[j + 5] = tex[i][1] # r + verts[j + 6] = tex[i][2] # q + verts[j + 7] = 1.0 + + ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, + nverts, + nattrs, + verts) + + ctx.flush() + + cbuf = cbuf_tex.get_surface() + + self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85) + + del ctx + + + +def main(): + dev = Device() + suite = TestSuite() + + targets = [] + targets += [PIPE_TEXTURE_2D] + targets += [PIPE_TEXTURE_CUBE] + targets += [PIPE_TEXTURE_3D] + + formats = [] + formats += [PIPE_FORMAT_A8R8G8B8_UNORM] + formats += [PIPE_FORMAT_R5G6B5_UNORM] + formats += [PIPE_FORMAT_L8_UNORM] + formats += [PIPE_FORMAT_YCBCR] + formats += [PIPE_FORMAT_DXT1_RGB] + + sizes = [64, 32, 16, 8, 4, 2, 1] + #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] + #sizes = [64] + #sizes = [63] + + for target in targets: + for format in formats: + for size in sizes: + if target == PIPE_TEXTURE_CUBE: + faces = [ + PIPE_TEX_FACE_POS_X, + PIPE_TEX_FACE_NEG_X, + PIPE_TEX_FACE_POS_Y, + PIPE_TEX_FACE_NEG_Y, + PIPE_TEX_FACE_POS_Z, + PIPE_TEX_FACE_NEG_Z, + ] + #faces = [PIPE_TEX_FACE_NEG_X] + else: + faces = [0] + if target == PIPE_TEXTURE_3D: + depth = size + else: + depth = 1 + for face in faces: + levels = lods(size) + for last_level in range(levels): + for level in range(0, last_level + 1): + zslice = 0 + while zslice < depth >> level: + test = TextureTest( + dev = dev, + target = target, + format = format, + width = size, + height = size, + depth = depth, + last_level = last_level, + face = face, + level = level, + zslice = zslice, + ) + suite.add_test(test) + zslice = (zslice + 1)*2 - 1 + suite.run() + + +if __name__ == '__main__': + main() -- cgit v1.2.3 From 6dd0a5f3d69bc84d4a57123dc890365f59b4a3aa Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 11:02:15 +0100 Subject: python/test: New test for texture transfers. --- .../python/tests/texture_transfer.py | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/texture_transfer.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/texture_transfer.py b/src/gallium/state_trackers/python/tests/texture_transfer.py new file mode 100644 index 00000000000..e65b425adf4 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/texture_transfer.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2009 VMware, Inc. +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################## + + +import os + +from gallium import * +from base import * + + +def lods(*dims): + size = max(dims) + lods = 0 + while size: + lods += 1 + size >>= 1 + return lods + + +class TextureTest(TestCase): + + tags = ( + 'target', + 'format', + 'width', + 'height', + 'depth', + 'last_level', + 'face', + 'level', + 'zslice', + ) + + def test(self): + dev = self.dev + + target = self.target + format = self.format + width = self.width + height = self.height + depth = self.depth + last_level = self.last_level + face = self.face + level = self.level + zslice = self.zslice + + tex_usage = 0 + + texture = dev.texture_create( + target = target, + format = format, + width = width, + height = height, + depth = depth, + last_level = last_level, + tex_usage = tex_usage, + ) + if texture is None: + raise TestSkip + + surface = texture.get_surface(face, level, zslice) + + stride = surface.nblocksx * texture.block.size + size = surface.nblocksy * stride + + in_raw = os.urandom(size) + + surface.put_tile_raw(0, 0, surface.width, surface.height, in_raw, stride) + + out_raw = surface.get_tile_raw(0, 0, surface.width, surface.height) + + if in_raw != out_raw: + raise TestFailure + + +def main(): + dev = Device() + suite = TestSuite() + + targets = [ + PIPE_TEXTURE_2D, + PIPE_TEXTURE_CUBE, + PIPE_TEXTURE_3D, + ] + + formats = [ + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_R5G6B5_UNORM, + PIPE_FORMAT_A1R5G5B5_UNORM, + PIPE_FORMAT_A4R4G4B4_UNORM, + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_S8_UNORM, + PIPE_FORMAT_A8_UNORM, + PIPE_FORMAT_L8_UNORM, + PIPE_FORMAT_DXT1_RGB, + PIPE_FORMAT_DXT1_RGBA, + PIPE_FORMAT_DXT3_RGBA, + PIPE_FORMAT_DXT5_RGBA, + ] + + sizes = [64, 32, 16, 8, 4, 2, 1] + #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] + #sizes = [64] + #sizes = [63] + + faces = [ + PIPE_TEX_FACE_POS_X, + PIPE_TEX_FACE_NEG_X, + PIPE_TEX_FACE_POS_Y, + PIPE_TEX_FACE_NEG_Y, + PIPE_TEX_FACE_POS_Z, + PIPE_TEX_FACE_NEG_Z, + ] + + for target in targets: + for format in formats: + for size in sizes: + if target == PIPE_TEXTURE_3D: + depth = size + else: + depth = 1 + for face in faces: + if target != PIPE_TEXTURE_CUBE and face: + continue + levels = lods(size) + for last_level in range(levels): + for level in range(0, last_level + 1): + zslice = 0 + while zslice < depth >> level: + test = TextureTest( + dev = dev, + target = target, + format = format, + width = size, + height = size, + depth = depth, + last_level = last_level, + face = face, + level = level, + zslice = zslice, + ) + suite.add_test(test) + zslice = (zslice + 1)*2 - 1 + suite.run() + + +if __name__ == '__main__': + main() -- cgit v1.2.3 From 10b808156bff157d401b5b999a215d16715a1018 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 16:38:03 +0100 Subject: python/test: Dump a classification tree of the results when finished testing. --- src/gallium/state_trackers/python/tests/base.py | 97 +++++++++++++++++++++---- src/gallium/state_trackers/python/tests/tree.py | 21 ++++++ 2 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 src/gallium/state_trackers/python/tests/tree.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 10964d99568..b338f44a252 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -1,6 +1,7 @@ #!/usr/bin/env python ########################################################################## # +# Copyright 2009 VMware, Inc. # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. # All Rights Reserved. # @@ -19,7 +20,7 @@ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,6 +34,7 @@ Loosely inspired on Python's unittest module. """ +import os.path import sys from gallium import * @@ -147,16 +149,19 @@ class TestCase(Test): def description(self): descriptions = [] for tag in self.tags: - try: - method = getattr(self, '_describe_' + tag) - except AttributeError: - description = str(getattr(self, tag, None)) - else: - description = method() + description = self.describe(tag) if description is not None: descriptions.append(tag + '=' + description) return ' '.join(descriptions) + def describe(self, tag): + try: + method = getattr(self, '_describe_' + tag) + except AttributeError: + return str(getattr(self, tag, None)) + else: + return method() + def _describe_target(self): return { PIPE_TEXTURE_1D: "1d", @@ -226,27 +231,87 @@ class TestResult: self.passed = 0 self.skipped = 0 self.failed = 0 - self.failed_descriptions = [] + + self.names = ['result'] + self.types = ['pass skip fail'] + self.rows = [] def test_start(self, test): - self.tests += 1 print "Running %s..." % test.description() + self.tests += 1 def test_passed(self, test): - self.passed += 1 print "PASS" + self.passed += 1 + self.log_result(test, 'pass') def test_skipped(self, test): - self.skipped += 1 print "SKIP" + self.skipped += 1 + #self.log_result(test, 'skip') def test_failed(self, test): - self.failed += 1 - self.failed_descriptions.append(test.description()) print "FAIL" + self.failed += 1 + self.log_result(test, 'fail') + + def log_result(self, test, result): + row = [None]*len(self.names) + + # add result + assert self.names[0] == 'result' + assert result in ('pass', 'skip', 'fail') + row[0] = result + + # add tags + for tag in test.tags: + value = test.describe(tag) + if value is None: + value = '' + else: + value = str(value) + try: + col = self.names.index(tag, 1) + except ValueError: + self.names.append(tag) + self.types.append('d') + row.append(value) + else: + row[col] = value + + self.rows.append(row) def summary(self): print "%u tests, %u passed, %u skipped, %u failed" % (self.tests, self.passed, self.skipped, self.failed) - for description in self.failed_descriptions: - print " %s" % description - + + name, ext = os.path.splitext(os.path.basename(sys.argv[0])) + filename = name + '.tsv' + stream = file(filename, 'wt') + + # header + stream.write('\t'.join(self.names) + '\n') + stream.write('\t'.join(self.types) + '\n') + stream.write('class\n') + + # rows + for row in self.rows: + row += [None]*(len(self.names) - len(row)) + stream.write('\t'.join(row) + '\n') + + stream.close() + + # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm + try: + import orange + import orngTree + except ImportError: + sys.stderr.write('Install Orange from http://www.ailab.si/orange/ for a classification tree.\n') + return + + data = orange.ExampleTable(filename) + + tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) + + orngTree.printTxt(tree) + + orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') diff --git a/src/gallium/state_trackers/python/tests/tree.py b/src/gallium/state_trackers/python/tests/tree.py new file mode 100644 index 00000000000..14b3599c6d7 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/tree.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# +# See also: +# http://www.ailab.si/orange/doc/ofb/c_otherclass.htm + +import os.path +import sys + +import orange +import orngTree + +for arg in sys.argv[1:]: + name, ext = os.path.splitext(arg) + + data = orange.ExampleTable(arg) + + tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) + + orngTree.printTxt(tree) + + orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') -- cgit v1.2.3 From bdfc411b449b3eafec8fb803fba42fce58a49c32 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 16:39:11 +0100 Subject: python/test: Flush stdout to keep in sync with debug info on stderr. --- src/gallium/state_trackers/python/tests/base.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index b338f44a252..401095fa908 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -237,21 +237,25 @@ class TestResult: self.rows = [] def test_start(self, test): - print "Running %s..." % test.description() + sys.stdout.write("Running %s...\n" % test.description()) + sys.stdout.flush() self.tests += 1 def test_passed(self, test): - print "PASS" + sys.stdout.write("PASS\n") + sys.stdout.flush() self.passed += 1 self.log_result(test, 'pass') def test_skipped(self, test): - print "SKIP" + sys.stdout.write("SKIP\n") + sys.stdout.flush() self.skipped += 1 #self.log_result(test, 'skip') def test_failed(self, test): - print "FAIL" + sys.stdout.write("FAIL\n") + sys.stdout.flush() self.failed += 1 self.log_result(test, 'fail') @@ -282,7 +286,8 @@ class TestResult: self.rows.append(row) def summary(self): - print "%u tests, %u passed, %u skipped, %u failed" % (self.tests, self.passed, self.skipped, self.failed) + sys.stdout.write("%u tests, %u passed, %u skipped, %u failed\n\n" % (self.tests, self.passed, self.skipped, self.failed)) + sys.stdout.flush() name, ext = os.path.splitext(os.path.basename(sys.argv[0])) filename = name + '.tsv' -- cgit v1.2.3 From 65554af5c3ea172891428382c13dc2318bf4b60d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 17:21:52 +0100 Subject: python/test: Infer type (continuous/discrete) from object type. --- src/gallium/state_trackers/python/tests/base.py | 42 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 401095fa908..585fbba1272 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -149,20 +149,20 @@ class TestCase(Test): def description(self): descriptions = [] for tag in self.tags: - description = self.describe(tag) - if description is not None: - descriptions.append(tag + '=' + description) + value = self.get(tag) + if value is not None and value != '': + descriptions.append(tag + '=' + str(value)) return ' '.join(descriptions) - def describe(self, tag): + def get(self, tag): try: - method = getattr(self, '_describe_' + tag) + method = getattr(self, '_get_' + tag) except AttributeError: - return str(getattr(self, tag, None)) + return getattr(self, tag, None) else: return method() - def _describe_target(self): + def _get_target(self): return { PIPE_TEXTURE_1D: "1d", PIPE_TEXTURE_2D: "2d", @@ -170,14 +170,14 @@ class TestCase(Test): PIPE_TEXTURE_CUBE: "cube", }[self.target] - def _describe_format(self): + def _get_format(self): name = formats[self.format] if name.startswith('PIPE_FORMAT_'): name = name[12:] name = name.lower() return name - def _describe_face(self): + def _get_face(self): if self.target == PIPE_TEXTURE_CUBE: return { PIPE_TEX_FACE_POS_X: "+x", @@ -188,7 +188,7 @@ class TestCase(Test): PIPE_TEX_FACE_NEG_Z: "-z", }[self.face] else: - return None + return '' def test(self): raise NotImplementedError @@ -260,7 +260,7 @@ class TestResult: self.log_result(test, 'fail') def log_result(self, test, result): - row = [None]*len(self.names) + row = ['']*len(self.names) # add result assert self.names[0] == 'result' @@ -269,19 +269,31 @@ class TestResult: # add tags for tag in test.tags: - value = test.describe(tag) + value = test.get(tag) + + # infer type if value is None: - value = '' + continue + elif isinstance(value, (int, float)): + value = str(value) + type = 'c' # continous + elif isinstance(value, basestring): + type = 'd' # discrete else: + assert False value = str(value) + type = 'd' # discrete + + # insert value try: col = self.names.index(tag, 1) except ValueError: self.names.append(tag) - self.types.append('d') + self.types.append(type) row.append(value) else: row[col] = value + assert self.types[col] == type self.rows.append(row) @@ -300,7 +312,7 @@ class TestResult: # rows for row in self.rows: - row += [None]*(len(self.names) - len(row)) + row += ['']*(len(self.names) - len(row)) stream.write('\t'.join(row) + '\n') stream.close() -- cgit v1.2.3 From 71384f29f12ab599b4430802ec8e21056a4dd60f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 17:23:48 +0100 Subject: python/test: Limit tree depth. --- src/gallium/state_trackers/python/tests/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 585fbba1272..6b2e702955f 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -329,6 +329,6 @@ class TestResult: tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) - orngTree.printTxt(tree) + orngTree.printTxt(tree, maxDepth=4) orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') -- cgit v1.2.3 From fcc2598fffe0f0e0412d2a30777f1b4a4ed22249 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 18:00:46 +0100 Subject: util: Enable assembly breakpointt on x86_64. A breakpoint is much nicer than abort when gdb is attached. --- src/gallium/auxiliary/util/u_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 5e88f3ebb1a..8d703e47fce 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -129,7 +129,7 @@ void debug_print_format(const char *msg, unsigned fmt ); * Hard-coded breakpoint. */ #ifdef DEBUG -#if defined(PIPE_ARCH_X86) && defined(PIPE_CC_GCC) +#if (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)) && defined(PIPE_CC_GCC) #define debug_break() __asm("int3") #elif defined(PIPE_CC_MSVC) #define debug_break() __debugbreak() -- cgit v1.2.3 From 4d9dd3ecef1501de31c82e8a08ce1df894b6c548 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 18:01:32 +0100 Subject: python/test: New test for rendering into textures. --- .../state_trackers/python/tests/texture_render.py | 315 +++++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100755 src/gallium/state_trackers/python/tests/texture_render.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/texture_render.py b/src/gallium/state_trackers/python/tests/texture_render.py new file mode 100755 index 00000000000..580bf65c13b --- /dev/null +++ b/src/gallium/state_trackers/python/tests/texture_render.py @@ -0,0 +1,315 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2009 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################## + + +from gallium import * +from base import * + + +def lods(*dims): + size = max(dims) + lods = 0 + while size: + lods += 1 + size >>= 1 + return lods + + +class TextureTest(TestCase): + + tags = ( + 'target', + 'format', + 'width', + 'height', + 'depth', + 'last_level', + 'face', + 'level', + 'zslice', + ) + + def test(self): + dev = self.dev + + target = self.target + format = self.format + width = self.width + height = self.height + depth = self.depth + last_level = self.last_level + face = self.face + level = self.level + zslice = self.zslice + + # textures + dst_texture = dev.texture_create( + target = target, + format = format, + width = width, + height = height, + depth = depth, + last_level = last_level, + tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, + ) + if dst_texture is None: + raise TestSkip + + dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice) + + ref_texture = dev.texture_create( + target = target, + format = format, + width = dst_surface.width, + height = dst_surface.height, + depth = 1, + last_level = 0, + tex_usage = PIPE_TEXTURE_USAGE_SAMPLER, + ) + + ref_surface = ref_texture.get_surface() + + src_texture = dev.texture_create( + target = target, + format = PIPE_FORMAT_A8R8G8B8_UNORM, + width = dst_surface.width, + height = dst_surface.height, + depth = 1, + last_level = 0, + tex_usage = PIPE_TEXTURE_USAGE_SAMPLER, + ) + + src_surface = src_texture.get_surface() + + expected_rgba = FloatArray(height*width*4) + ref_surface.sample_rgba(expected_rgba) + + src_surface.put_tile_rgba(0, 0, src_surface.width, src_surface.height, expected_rgba) + + ctx = self.dev.context_create() + + # disabled blending/masking + blend = Blend() + blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.colormask = PIPE_MASK_RGBA + ctx.set_blend(blend) + + # no-op depth/stencil/alpha + depth_stencil_alpha = DepthStencilAlpha() + ctx.set_depth_stencil_alpha(depth_stencil_alpha) + + # rasterizer + rasterizer = Rasterizer() + rasterizer.front_winding = PIPE_WINDING_CW + rasterizer.cull_mode = PIPE_WINDING_NONE + rasterizer.bypass_vs_clip_and_viewport = 1 + ctx.set_rasterizer(rasterizer) + + # samplers + sampler = Sampler() + sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.normalized_coords = 1 + sampler.min_lod = 0 + sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 + ctx.set_sampler(0, sampler) + ctx.set_sampler_texture(0, src_texture) + + # framebuffer + cbuf_tex = dev.texture_create( + PIPE_FORMAT_A8R8G8B8_UNORM, + width, + height, + tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, + ) + + fb = Framebuffer() + fb.width = dst_surface.width + fb.height = dst_surface.height + fb.nr_cbufs = 1 + fb.set_cbuf(0, dst_surface) + ctx.set_framebuffer(fb) + ctx.surface_clear(dst_surface, 0x00000000) + del fb + + # vertex shader + vs = Shader(''' + VERT1.1 + DCL IN[0], POSITION, CONSTANT + DCL IN[1], GENERIC, CONSTANT + DCL OUT[0], POSITION, CONSTANT + DCL OUT[1], GENERIC, CONSTANT + 0:MOV OUT[0], IN[0] + 1:MOV OUT[1], IN[1] + 2:END + ''') + #vs.dump() + ctx.set_vertex_shader(vs) + + # fragment shader + fs = Shader(''' + FRAG1.1 + DCL IN[0], GENERIC[0], LINEAR + DCL OUT[0], COLOR, CONSTANT + DCL SAMP[0], CONSTANT + 0:TEX OUT[0], IN[0], SAMP[0], 2D + 1:END + ''') + #fs.dump() + ctx.set_fragment_shader(fs) + + nverts = 4 + nattrs = 2 + verts = FloatArray(nverts * nattrs * 4) + + x = 0 + y = 0 + w = dst_surface.width + h = dst_surface.height + + pos = [ + [x, y], + [x+w, y], + [x+w, y+h], + [x, y+h], + ] + + tex = [ + [0.0, 0.0], + [1.0, 0.0], + [1.0, 1.0], + [0.0, 1.0], + ] + + for i in range(0, 4): + j = 8*i + verts[j + 0] = pos[i][0] # x + verts[j + 1] = pos[i][1] # y + verts[j + 2] = 0.0 # z + verts[j + 3] = 1.0 # w + verts[j + 4] = tex[i][0] # s + verts[j + 5] = tex[i][1] # r + verts[j + 6] = 0.0 + verts[j + 7] = 1.0 + + ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, + nverts, + nattrs, + verts) + + ctx.flush() + + self.assert_rgba(dst_surface, x, y, w, h, expected_rgba, 4.0/256, 0.85) + + + +def main(): + dev = Device() + suite = TestSuite() + + targets = [ + PIPE_TEXTURE_2D, + PIPE_TEXTURE_CUBE, + #PIPE_TEXTURE_3D, + ] + + formats = [ + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + #PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_R5G6B5_UNORM, + PIPE_FORMAT_A1R5G5B5_UNORM, + PIPE_FORMAT_A4R4G4B4_UNORM, + #PIPE_FORMAT_Z32_UNORM, + #PIPE_FORMAT_Z24S8_UNORM, + #PIPE_FORMAT_Z24X8_UNORM, + #PIPE_FORMAT_Z16_UNORM, + #PIPE_FORMAT_S8_UNORM, + PIPE_FORMAT_A8_UNORM, + PIPE_FORMAT_L8_UNORM, + #PIPE_FORMAT_DXT1_RGB, + #PIPE_FORMAT_DXT1_RGBA, + #PIPE_FORMAT_DXT3_RGBA, + #PIPE_FORMAT_DXT5_RGBA, + ] + + sizes = [64, 32, 16, 8, 4, 2, 1] + #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] + #sizes = [64] + #sizes = [63] + + faces = [ + PIPE_TEX_FACE_POS_X, + PIPE_TEX_FACE_NEG_X, + PIPE_TEX_FACE_POS_Y, + PIPE_TEX_FACE_NEG_Y, + PIPE_TEX_FACE_POS_Z, + PIPE_TEX_FACE_NEG_Z, + ] + + for target in targets: + for format in formats: + for size in sizes: + if target == PIPE_TEXTURE_3D: + depth = size + else: + depth = 1 + for face in faces: + if target != PIPE_TEXTURE_CUBE and face: + continue + levels = lods(size) + for last_level in range(levels): + for level in range(0, last_level + 1): + zslice = 0 + while zslice < depth >> level: + test = TextureTest( + dev = dev, + target = target, + format = format, + width = size, + height = size, + depth = depth, + last_level = last_level, + face = face, + level = level, + zslice = zslice, + ) + suite.add_test(test) + zslice = (zslice + 1)*2 - 1 + suite.run() + + +if __name__ == '__main__': + main() -- cgit v1.2.3 From fee78c0c1fcfc308c84ab8da1efcc98ed8afc889 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 18:02:27 +0100 Subject: python/test: Set executable permission bit. --- src/gallium/state_trackers/python/tests/base.py | 0 src/gallium/state_trackers/python/tests/texture_sample.py | 0 src/gallium/state_trackers/python/tests/texture_transfer.py | 0 src/gallium/state_trackers/python/tests/tree.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/gallium/state_trackers/python/tests/base.py mode change 100644 => 100755 src/gallium/state_trackers/python/tests/texture_sample.py mode change 100644 => 100755 src/gallium/state_trackers/python/tests/texture_transfer.py mode change 100644 => 100755 src/gallium/state_trackers/python/tests/tree.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py old mode 100644 new mode 100755 diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py old mode 100644 new mode 100755 diff --git a/src/gallium/state_trackers/python/tests/texture_transfer.py b/src/gallium/state_trackers/python/tests/texture_transfer.py old mode 100644 new mode 100755 diff --git a/src/gallium/state_trackers/python/tests/tree.py b/src/gallium/state_trackers/python/tests/tree.py old mode 100644 new mode 100755 -- cgit v1.2.3 From f784906eb96ccda2062b53867a5d4bc52653396d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 18:38:48 +0100 Subject: python/test: Dump classification tree to text file too. --- src/gallium/state_trackers/python/tests/base.py | 2 ++ src/gallium/state_trackers/python/tests/tree.py | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 6b2e702955f..1fa7fe6f3b3 100755 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -331,4 +331,6 @@ class TestResult: orngTree.printTxt(tree, maxDepth=4) + file(name+'.txt', 'wt').write(orngTree.dumpTree(tree)) + orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') diff --git a/src/gallium/state_trackers/python/tests/tree.py b/src/gallium/state_trackers/python/tests/tree.py index 14b3599c6d7..0c1bcda4cf2 100755 --- a/src/gallium/state_trackers/python/tests/tree.py +++ b/src/gallium/state_trackers/python/tests/tree.py @@ -18,4 +18,6 @@ for arg in sys.argv[1:]: orngTree.printTxt(tree) + file(name+'.txt', 'wt').write(orngTree.dumpTree(tree) + '\n') + orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') -- cgit v1.2.3 From e2cdc997881bff382eada8c798560c8264219b0b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 18:39:06 +0100 Subject: python/test: Cleanup. --- .../state_trackers/python/tests/texture_sample.py | 63 +++++++++++++--------- 1 file changed, 38 insertions(+), 25 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py index fcb347f9a17..f5f49f6e515 100755 --- a/src/gallium/state_trackers/python/tests/texture_sample.py +++ b/src/gallium/state_trackers/python/tests/texture_sample.py @@ -1,6 +1,7 @@ #!/usr/bin/env python ########################################################################## # +# Copyright 2009 VMware, Inc. # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. # All Rights Reserved. # @@ -19,7 +20,7 @@ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -278,8 +279,6 @@ class TextureTest(TestCase): cbuf = cbuf_tex.get_surface() self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85) - - del ctx @@ -287,43 +286,57 @@ def main(): dev = Device() suite = TestSuite() - targets = [] - targets += [PIPE_TEXTURE_2D] - targets += [PIPE_TEXTURE_CUBE] - targets += [PIPE_TEXTURE_3D] + targets = [ + PIPE_TEXTURE_2D, + PIPE_TEXTURE_CUBE, + PIPE_TEXTURE_3D, + ] - formats = [] - formats += [PIPE_FORMAT_A8R8G8B8_UNORM] - formats += [PIPE_FORMAT_R5G6B5_UNORM] - formats += [PIPE_FORMAT_L8_UNORM] - formats += [PIPE_FORMAT_YCBCR] - formats += [PIPE_FORMAT_DXT1_RGB] + formats = [ + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + #PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_R5G6B5_UNORM, + PIPE_FORMAT_A1R5G5B5_UNORM, + PIPE_FORMAT_A4R4G4B4_UNORM, + #PIPE_FORMAT_Z32_UNORM, + #PIPE_FORMAT_Z24S8_UNORM, + #PIPE_FORMAT_Z24X8_UNORM, + #PIPE_FORMAT_Z16_UNORM, + #PIPE_FORMAT_S8_UNORM, + PIPE_FORMAT_A8_UNORM, + PIPE_FORMAT_L8_UNORM, + PIPE_FORMAT_YCBCR, + PIPE_FORMAT_DXT1_RGB, + #PIPE_FORMAT_DXT1_RGBA, + #PIPE_FORMAT_DXT3_RGBA, + #PIPE_FORMAT_DXT5_RGBA, + ] sizes = [64, 32, 16, 8, 4, 2, 1] #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] #sizes = [64] #sizes = [63] + faces = [ + PIPE_TEX_FACE_POS_X, + PIPE_TEX_FACE_NEG_X, + PIPE_TEX_FACE_POS_Y, + PIPE_TEX_FACE_NEG_Y, + PIPE_TEX_FACE_POS_Z, + PIPE_TEX_FACE_NEG_Z, + ] + for target in targets: for format in formats: for size in sizes: - if target == PIPE_TEXTURE_CUBE: - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - #faces = [PIPE_TEX_FACE_NEG_X] - else: - faces = [0] if target == PIPE_TEXTURE_3D: depth = size else: depth = 1 for face in faces: + if target != PIPE_TEXTURE_CUBE and face: + continue levels = lods(size) for last_level in range(levels): for level in range(0, last_level + 1): -- cgit v1.2.3 From 89ecefb887a9e2fd49489904663873e416ec4a83 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 18:39:18 +0100 Subject: python/test: Ignore test output files. --- src/gallium/state_trackers/python/tests/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/.gitignore (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/.gitignore b/src/gallium/state_trackers/python/tests/.gitignore new file mode 100644 index 00000000000..0dbbaeea16b --- /dev/null +++ b/src/gallium/state_trackers/python/tests/.gitignore @@ -0,0 +1,3 @@ +*.txt +*.tsv +*.dot -- cgit v1.2.3 From 10b987ae7f5e145bdea4cf726a1e728254ed32ad Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 31 Mar 2009 19:16:17 +0100 Subject: python/test: New test for surface copies. --- .../state_trackers/python/tests/surface_copy.py | 199 +++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100755 src/gallium/state_trackers/python/tests/surface_copy.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/surface_copy.py b/src/gallium/state_trackers/python/tests/surface_copy.py new file mode 100755 index 00000000000..3ceecbbd3aa --- /dev/null +++ b/src/gallium/state_trackers/python/tests/surface_copy.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2009 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################## + + +from gallium import * +from base import * + + +def lods(*dims): + size = max(dims) + lods = 0 + while size: + lods += 1 + size >>= 1 + return lods + + +class TextureTest(TestCase): + + tags = ( + 'target', + 'format', + 'width', + 'height', + 'depth', + 'last_level', + 'face', + 'level', + 'zslice', + ) + + def test(self): + dev = self.dev + + target = self.target + format = self.format + width = self.width + height = self.height + depth = self.depth + last_level = self.last_level + face = self.face + level = self.level + zslice = self.zslice + + # textures + dst_texture = dev.texture_create( + target = target, + format = format, + width = width, + height = height, + depth = depth, + last_level = last_level, + tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, + ) + if dst_texture is None: + raise TestSkip + + dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice) + + src_texture = dev.texture_create( + target = target, + format = format, + width = dst_surface.width, + height = dst_surface.height, + depth = 1, + last_level = 0, + tex_usage = PIPE_TEXTURE_USAGE_SAMPLER, + ) + + src_surface = src_texture.get_surface() + + x = 0 + y = 0 + w = dst_surface.width + h = dst_surface.height + + stride = dst_surface.nblocksx * dst_texture.block.size + size = dst_surface.nblocksy * stride + src_raw = os.urandom(size) + + src_surface.put_tile_raw(0, 0, w, h, src_raw, stride) + + ctx = self.dev.context_create() + + ctx.surface_copy(dst_surface, 0, 0, + src_surface, 0, 0, w, h) + + ctx.flush() + + dst_raw = dst_surface.get_tile_raw(0, 0, w, h) + + if dst_raw != src_raw: + raise TestFailure + + + +def main(): + dev = Device() + suite = TestSuite() + + targets = [ + PIPE_TEXTURE_2D, + PIPE_TEXTURE_CUBE, + #PIPE_TEXTURE_3D, + ] + + formats = [ + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_R5G6B5_UNORM, + PIPE_FORMAT_A1R5G5B5_UNORM, + PIPE_FORMAT_A4R4G4B4_UNORM, + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_S8_UNORM, + PIPE_FORMAT_A8_UNORM, + PIPE_FORMAT_L8_UNORM, + PIPE_FORMAT_DXT1_RGB, + PIPE_FORMAT_DXT1_RGBA, + PIPE_FORMAT_DXT3_RGBA, + PIPE_FORMAT_DXT5_RGBA, + ] + + sizes = [64, 32, 16, 8, 4, 2, 1] + #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] + #sizes = [64] + #sizes = [63] + + faces = [ + PIPE_TEX_FACE_POS_X, + PIPE_TEX_FACE_NEG_X, + PIPE_TEX_FACE_POS_Y, + PIPE_TEX_FACE_NEG_Y, + PIPE_TEX_FACE_POS_Z, + PIPE_TEX_FACE_NEG_Z, + ] + + for target in targets: + for format in formats: + for size in sizes: + if target == PIPE_TEXTURE_3D: + depth = size + else: + depth = 1 + for face in faces: + if target != PIPE_TEXTURE_CUBE and face: + continue + levels = lods(size) + for last_level in range(levels): + for level in range(0, last_level + 1): + zslice = 0 + while zslice < depth >> level: + test = TextureTest( + dev = dev, + target = target, + format = format, + width = size, + height = size, + depth = depth, + last_level = last_level, + face = face, + level = level, + zslice = zslice, + ) + suite.add_test(test) + zslice = (zslice + 1)*2 - 1 + suite.run() + + +if __name__ == '__main__': + main() -- cgit v1.2.3 From 3f3db46911d11189a2487db288420f4a6a3d0069 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 00:19:46 +0200 Subject: python/regress: Initial commit for vertex shader regression tests. --- .../tests/regress/vertex-shader/vert-abs.txt | 11 + .../tests/regress/vertex-shader/vert-add.txt | 9 + .../tests/regress/vertex-shader/vert-dp3.txt | 12 ++ .../tests/regress/vertex-shader/vert-mov.txt | 8 + .../tests/regress/vertex-shader/vertex-shader.py | 240 +++++++++++++++++++++ 5 files changed, 280 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt new file mode 100644 index 00000000000..66c1986cef7 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt @@ -0,0 +1,11 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] +IMM FLT32 { 0.2, 0.2, 0.0, 0.0 } +ADD TEMP[0], IN[0], IMM[0] +ABS OUT[0], TEMP[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt new file mode 100644 index 00000000000..78753b76d8a --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt @@ -0,0 +1,9 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +IMM FLT32 { 0.2, -0.1, 0.0, 0.0 } +ADD OUT[0], IN[0], IMM[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt new file mode 100644 index 00000000000..e4c1c4a9b33 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt @@ -0,0 +1,12 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +DP3 TEMP[0].xy, IN[0], IN[0] +MOV TEMP[0].zw, IMM[0] +MUL OUT[0], IN[0], TEMP[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt new file mode 100644 index 00000000000..12712ff8590 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt @@ -0,0 +1,8 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +MOV OUT[0], IN[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py new file mode 100644 index 00000000000..92ff2053093 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -0,0 +1,240 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2009 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################## + + +from gallium import * + +def make_image(surface): + 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) + outimage.save(filename, "PNG") + +def test(dev, name): + ctx = dev.context_create() + + width = 320 + height = 320 + minz = 0.0 + maxz = 1.0 + + # disabled blending/masking + blend = Blend() + blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.colormask = PIPE_MASK_RGBA + ctx.set_blend(blend) + + # depth/stencil/alpha + depth_stencil_alpha = DepthStencilAlpha() + depth_stencil_alpha.depth.enabled = 1 + depth_stencil_alpha.depth.writemask = 1 + depth_stencil_alpha.depth.func = PIPE_FUNC_LESS + ctx.set_depth_stencil_alpha(depth_stencil_alpha) + + # rasterizer + rasterizer = Rasterizer() + rasterizer.front_winding = PIPE_WINDING_CW + rasterizer.cull_mode = PIPE_WINDING_NONE + rasterizer.scissor = 1 + ctx.set_rasterizer(rasterizer) + + # viewport + viewport = Viewport() + scale = FloatArray(4) + scale[0] = width / 2.0 + scale[1] = -height / 2.0 + scale[2] = (maxz - minz) / 2.0 + scale[3] = 1.0 + viewport.scale = scale + translate = FloatArray(4) + translate[0] = width / 2.0 + translate[1] = height / 2.0 + translate[2] = (maxz - minz) / 2.0 + translate[3] = 0.0 + viewport.translate = translate + ctx.set_viewport(viewport) + + # samplers + sampler = Sampler() + sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE + sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.normalized_coords = 1 + ctx.set_sampler(0, sampler) + + # scissor + scissor = Scissor() + scissor.minx = 0 + scissor.miny = 0 + scissor.maxx = width + scissor.maxy = height + ctx.set_scissor(scissor) + + clip = Clip() + clip.nr = 0 + ctx.set_clip(clip) + + # framebuffer + cbuf = dev.texture_create( + PIPE_FORMAT_X8R8G8B8_UNORM, + width, height, + tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, + ).get_surface() + zbuf = dev.texture_create( + PIPE_FORMAT_Z32_UNORM, + width, height, + tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL, + ).get_surface() + fb = Framebuffer() + fb.width = width + fb.height = height + fb.nr_cbufs = 1 + fb.set_cbuf(0, cbuf) + fb.set_zsbuf(zbuf) + ctx.set_framebuffer(fb) + ctx.surface_clear(cbuf, 0x80808080) + ctx.surface_clear(zbuf, 0xffffffff) + + # vertex shader + vs = Shader(file('vert-' + name + '.txt', 'rt').read()) + ctx.set_vertex_shader(vs) + + # fragment shader + fs = Shader(''' + FRAG1.1 + DCL IN[0], COLOR, LINEAR + DCL OUT[0], COLOR, CONSTANT + 0:MOV OUT[0], IN[0] + 1:END + ''') + ctx.set_fragment_shader(fs) + + xy = [ + 0.0, 0.8, + -0.2, 0.4, + 0.2, 0.4, + -0.4, 0.0, + 0.0, 0.0, + 0.4, 0.0, + -0.6, -0.4, + -0.2, -0.4, + 0.2, -0.4, + 0.6, -0.4, + -0.8, -0.8, + -0.4, -0.8, + 0.0, -0.8, + 0.4, -0.8, + 0.8, -0.8, + ] + color = [ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + ] + tri = [ + 1, 2, 0, + 3, 4, 1, + 4, 2, 1, + 4, 5, 2, + 6, 7, 3, + 7, 4, 3, + 7, 8, 4, + 8, 5, 4, + 8, 9, 5, + 10, 11, 6, + 11, 7, 6, + 11, 12, 7, + 12, 8, 7, + 12, 13, 8, + 13, 9, 8, + 13, 14, 9, + ] + + nverts = 16 * 3 + nattrs = 2 + verts = FloatArray(nverts * nattrs * 4) + + for i in range(0, nverts): + verts[i * nattrs * 4 + 0] = xy[tri[i] * 2 + 0] # x + verts[i * nattrs * 4 + 1] = xy[tri[i] * 2 + 1] # y + verts[i * nattrs * 4 + 2] = 0.5 # z + verts[i * nattrs * 4 + 3] = 1.0 # w + verts[i * nattrs * 4 + 4] = color[(i % 3) * 3 + 0] # r + verts[i * nattrs * 4 + 5] = color[(i % 3) * 3 + 1] # g + verts[i * nattrs * 4 + 6] = color[(i % 3) * 3 + 2] # b + verts[i * nattrs * 4 + 7] = 1.0 # a + + ctx.draw_vertices(PIPE_PRIM_TRIANGLES, + nverts, + nattrs, + verts) + + ctx.flush() + + save_image('vert-' + name + '.png', cbuf) + +def main(): + tests = [ + 'abs', + 'add', + 'dp3', + 'mov', + ] + + html = ''' + + + + +
    +

    regression tests for vertex shader

    + +''' + + dev = Device() + for t in tests: + test(dev, t) + html += '' + html += '\n' + + html += '
    ' + t + '
    \n\n\n' + file('vertex-shader.htm', 'wt').write(html) + +if __name__ == '__main__': + main() -- cgit v1.2.3 From 3705d03b0fbe349dee0221d982965a0590bc7cb0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 31 Mar 2009 16:06:19 -0600 Subject: gallium: added util_is_inf_or_nan() function to u_math.h --- src/gallium/auxiliary/util/u_math.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 9268a9bb7ee..e5003af01d8 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -319,6 +319,18 @@ util_iround(float f) +/** + * Test if x is NaN or +/- infinity. + */ +static INLINE boolean +util_is_inf_or_nan(float x) +{ + union fi tmp; + tmp.f = x; + return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); +} + + /** * Find first bit set in word. Least significant bit is 1. * Return 0 if no bits set. -- cgit v1.2.3 From d0f28b6dd967cd74bafb37e1e203b5934981bed0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 31 Mar 2009 16:07:38 -0600 Subject: softpipe: use util_is_inf_or_nan() And print/warn NaN/Inf in print_vertex(). --- src/gallium/drivers/softpipe/sp_setup.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 711343abe67..accc692b66f 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -252,16 +252,6 @@ static PIPE_THREAD_ROUTINE( quad_thread, param ) #endif -/** - * Test if x is NaN or +/- infinity. - */ -static INLINE boolean -is_inf_or_nan(float x) -{ - union fi tmp; - tmp.f = x; - return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); -} /** @@ -506,6 +496,9 @@ static void print_vertex(const struct setup_context *setup, for (i = 0; i < setup->quad.nr_attrs; i++) { debug_printf(" %d: %f %f %f %f\n", i, v[i][0], v[i][1], v[i][2], v[i][3]); + if (util_is_inf_or_nan(v[i][0])) { + debug_printf(" NaN!\n"); + } } } #endif @@ -595,7 +588,7 @@ static boolean setup_sort_vertices( struct setup_context *setup, debug_printf("%s one-over-area %f area %f det %f\n", __FUNCTION__, setup->oneoverarea, area, det ); */ - if (is_inf_or_nan(setup->oneoverarea)) + if (util_is_inf_or_nan(setup->oneoverarea)) return FALSE; } @@ -1065,7 +1058,7 @@ setup_line_coefficients(struct setup_context *setup, /* NOTE: this is not really area but something proportional to it */ area = setup->emaj.dx * setup->emaj.dx + setup->emaj.dy * setup->emaj.dy; - if (area == 0.0f || is_inf_or_nan(area)) + if (area == 0.0f || util_is_inf_or_nan(area)) return FALSE; setup->oneoverarea = 1.0f / area; -- cgit v1.2.3 From ef6f1027ff0b6027976a7467b8461ffdd53ce2a8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 31 Mar 2009 16:12:17 -0600 Subject: draw: added Nan/Inf assertion in debug code --- src/gallium/auxiliary/draw/draw_vs_exec.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index b3200df8112..dbbc33fffa7 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -151,6 +151,7 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, output[slot][1], output[slot][2], output[slot][3]); + assert(!util_is_inf_or_nan(output[slot][0])); } #endif -- cgit v1.2.3 From a44f54912e4bc0f6be0b7303f8b7a1b934c5819a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 31 Mar 2009 16:17:23 -0600 Subject: tgsi: added some helpful debug functions in the tgsi interpreter Check for NaN/Inf, print exec vectors, print temp registers. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 259877b500d..80b8c92445a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -127,6 +127,49 @@ static const union tgsi_exec_channel ZeroVec = { { 0.0, 0.0, 0.0, 0.0 } }; + +#ifdef DEBUG +static void +check_inf_or_nan(const union tgsi_exec_channel *chan) +{ + assert(!util_is_inf_or_nan(chan->f[0])); + assert(!util_is_inf_or_nan(chan->f[1])); + assert(!util_is_inf_or_nan(chan->f[2])); + assert(!util_is_inf_or_nan(chan->f[3])); +} +#endif + + +#ifdef DEBUG +static void +print_chan(const char *msg, const union tgsi_exec_channel *chan) +{ + debug_printf("%s = {%f, %f, %f, %f}\n", + msg, chan->f[0], chan->f[1], chan->f[2], chan->f[3]); +} +#endif + + +#ifdef DEBUG +static void +print_temp(const struct tgsi_exec_machine *mach, uint index) +{ + const struct tgsi_exec_vector *tmp = &mach->Temps[index]; + int i; + debug_printf("Temp[%u] =\n", index); + for (i = 0; i < 4; i++) { + debug_printf(" %c: { %f, %f, %f, %f }\n", + "XYZW"[i], + tmp->xyzw[i].f[0], + tmp->xyzw[i].f[1], + tmp->xyzw[i].f[2], + tmp->xyzw[i].f[3]); + } +} +#endif + + + /** * Initialize machine state by expanding tokens to full instructions, * allocating temporary storage, setting up constants, etc. @@ -282,6 +325,12 @@ tgsi_exec_machine_init( mach->Temps[TEMP_3_I].xyzw[TEMP_3_C].f[i] = 3.0f; mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C].f[i] = 0.5f; } + +#ifdef DEBUG + /* silence warnings */ + (void) print_chan; + (void) print_temp; +#endif } @@ -1285,6 +1334,10 @@ store_dest( union tgsi_exec_channel *dst; uint execmask = mach->ExecMask; +#ifdef DEBUG + check_inf_or_nan(chan); +#endif + switch (reg->DstRegister.File) { case TGSI_FILE_NULL: dst = &null; -- cgit v1.2.3 From 63529c731a090c5e41c1224ca79b544243a1e570 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 30 Mar 2009 23:54:53 -0700 Subject: r300-gallium: Stubs for vertex shaders. --- src/gallium/drivers/r300/Makefile | 1 + src/gallium/drivers/r300/r300_context.h | 22 +++ src/gallium/drivers/r300/r300_state_shader.c | 5 +- src/gallium/drivers/r300/r300_state_tcl.c | 196 +++++++++++++++++++++++++++ src/gallium/drivers/r300/r300_state_tcl.h | 72 ++++++++++ 5 files changed, 293 insertions(+), 3 deletions(-) create mode 100644 src/gallium/drivers/r300/r300_state_tcl.c create mode 100644 src/gallium/drivers/r300/r300_state_tcl.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 0e4e1155325..9330c286d2b 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -16,6 +16,7 @@ C_SOURCES = \ r300_state_derived.c \ r300_state_invariant.c \ r300_state_shader.c \ + r300_state_tcl.c \ r300_surface.c \ r300_swtcl_emit.c \ r300_texture.c diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index ed6480bea79..0ca445c0918 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -231,6 +231,26 @@ struct r300_vertex_format { int tab[16]; }; +struct r300_vertex_shader { + /* Parent class */ + struct pipe_shader_state state; + struct tgsi_shader_info info; + + /* Has this shader been translated yet? */ + boolean translated; + + /* Number of used instructions */ + int instruction_count; + + /* Machine instructions */ + struct { + uint32_t inst0; + uint32_t inst1; + uint32_t inst2; + uint32_t inst3; + } instructions[128]; /*< XXX magic number */ +}; + struct r300_context { /* Parent class */ struct pipe_context context; @@ -270,6 +290,8 @@ struct r300_context { int vertex_buffer_count; /* Vertex information. */ struct r300_vertex_format vertex_info; + /* Vertex shader. */ + struct r300_vertex_shader* vs; /* Viewport state. */ struct r300_viewport_state* viewport_state; /* Bitmask of dirty state objects. */ diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index 5dc7266f9b1..1b02239ee76 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -623,15 +623,14 @@ void r300_translate_fragment_shader(struct r300_context* r300, } break; } - } - debug_printf("r300: %d texs and %d colors, first free reg is %d\n", + debug_printf("r300: fs: %d texs and %d colors, first free reg is %d\n", assembler->tex_count, assembler->color_count, assembler->tex_count + assembler->color_count); consts->count = consts->user_count + assembler->imm_count; - debug_printf("r300: %d total constants, " + debug_printf("r300: fs: %d total constants, " "%d from user and %d from immediates\n", consts->count, consts->user_count, assembler->imm_count); r300_fs_finalize(fs, assembler); diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c new file mode 100644 index 00000000000..ddf43604b9a --- /dev/null +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -0,0 +1,196 @@ +/* + * Copyright 2009 Corbin Simpson + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include "r300_state_tcl.h" + +static void r300_vs_declare(struct r300_vs_asm* assembler, + struct tgsi_full_declaration* decl) +{ + switch (decl->Declaration.File) { + case TGSI_FILE_INPUT: + switch (decl->Semantic.SemanticName) { + case TGSI_SEMANTIC_COLOR: + assembler->color_count++; + break; + case TGSI_SEMANTIC_GENERIC: + assembler->tex_count++; + break; + default: + debug_printf("r300: vs: Bad semantic declaration %d\n", + decl->Semantic.SemanticName); + break; + } + break; + case TGSI_FILE_OUTPUT: + case TGSI_FILE_CONSTANT: + break; + case TGSI_FILE_TEMPORARY: + assembler->temp_count++; + break; + default: + debug_printf("r300: vs: Bad file %d\n", decl->Declaration.File); + break; + } + + assembler->temp_offset = assembler->color_count + assembler->tex_count; +} + +static INLINE unsigned r300_vs_src(struct r300_vs_asm* assembler, + struct tgsi_src_register* src) +{ + switch (src->File) { + case TGSI_FILE_NULL: + return 0; + case TGSI_FILE_INPUT: + /* XXX may be wrong */ + return src->Index; + break; + case TGSI_FILE_TEMPORARY: + return src->Index + assembler->temp_offset; + break; + case TGSI_FILE_IMMEDIATE: + return (src->Index + assembler->imm_offset) | (1 << 8); + break; + case TGSI_FILE_CONSTANT: + /* XXX magic */ + return src->Index | (1 << 8); + break; + default: + debug_printf("r300: vs: Unimplemented src %d\n", src->File); + break; + } + return 0; +} + +static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, + struct tgsi_dst_register* dst) +{ + switch (dst->File) { + case TGSI_FILE_NULL: + /* This happens during KIL instructions. */ + return 0; + break; + case TGSI_FILE_OUTPUT: + return 0; + break; + case TGSI_FILE_TEMPORARY: + return dst->Index + assembler->temp_offset; + break; + default: + debug_printf("r300: vs: Unimplemented dst %d\n", dst->File); + break; + } + return 0; +} + +static void r300_vs_emit_inst(struct r300_vertex_shader* vs, + struct r300_vs_asm* assembler, + struct tgsi_full_src_register* src, + struct tgsi_full_dst_register* dst) +{ + int i = vs->instruction_count; + vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | + R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | + R300_PVS_DST_OFFSET(dst->DstRegister.Index); +} + +static void r300_vs_instruction(struct r300_vertex_shader* vs, + struct r300_vs_asm* assembler, + struct tgsi_full_instruction* inst) +{ + switch (inst->Instruction.Opcode) { + case TGSI_OPCODE_MOV: + r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0]); + break; + case TGSI_OPCODE_END: + break; + default: + debug_printf("r300: vs: Bad opcode %d\n", + inst->Instruction.Opcode); + break; + } +} + +void r300_translate_vertex_shader(struct r300_context* r300, + struct r300_vertex_shader* vs) +{ + struct tgsi_parse_context parser; + int i; + struct r300_constant_buffer* consts = + &r300->shader_constants[PIPE_SHADER_VERTEX]; + + struct r300_vs_asm* assembler = CALLOC_STRUCT(r300_vs_asm); + if (assembler == NULL) { + return; + } + /* Setup starting offset for immediates. */ + assembler->imm_offset = consts->user_count; + + tgsi_parse_init(&parser, vs->state.tokens); + + while (!tgsi_parse_end_of_tokens(&parser)) { + tgsi_parse_token(&parser); + + /* This is seriously the lamest way to create fragment programs ever. + * I blame TGSI. */ + switch (parser.FullToken.Token.Type) { + case TGSI_TOKEN_TYPE_DECLARATION: + /* Allocated registers sitting at the beginning + * of the program. */ + r300_vs_declare(assembler, &parser.FullToken.FullDeclaration); + break; + case TGSI_TOKEN_TYPE_IMMEDIATE: + debug_printf("r300: Emitting immediate to constant buffer, " + "position %d\n", + assembler->imm_offset + assembler->imm_count); + /* I am not amused by the length of these. */ + for (i = 0; i < 4; i++) { + consts->constants[assembler->imm_offset + + assembler->imm_count][i] = + parser.FullToken.FullImmediate.u.ImmediateFloat32[i] + .Float; + } + assembler->imm_count++; + break; + case TGSI_TOKEN_TYPE_INSTRUCTION: + r300_vs_instruction(vs, assembler, + &parser.FullToken.FullInstruction); + break; + } + } + + debug_printf("r300: vs: %d texs and %d colors, first free reg is %d\n", + assembler->tex_count, assembler->color_count, + assembler->tex_count + assembler->color_count); + + consts->count = consts->user_count + assembler->imm_count; + debug_printf("r300: vs: %d total constants, " + "%d from user and %d from immediates\n", consts->count, + consts->user_count, assembler->imm_count); + + tgsi_dump(vs->state.tokens); + /* XXX finish r300 vertex shader dumper */ + + tgsi_parse_free(&parser); + FREE(assembler); +} diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h new file mode 100644 index 00000000000..54900cc191a --- /dev/null +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -0,0 +1,72 @@ +/* + * Copyright 2009 Corbin Simpson + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#ifndef R300_STATE_TCL_H +#define R300_STATE_TCL_H + +#include "tgsi/tgsi_parse.h" + +#include "r300_context.h" +#include "r300_debug.h" +#include "r300_reg.h" +#include "r300_screen.h" + +/* XXX get these to r300_reg */ +#define R300_PVS_DST_OPCODE(x) ((x) << 0) +# define R300_VE_ADD 3 +#define R300_PVS_DST_REG_TYPE(x) ((x) << 8) +# define R300_PVS_DST_REG_TEMPORARY 0 +# define R300_PVS_DST_REG_A0 1 +# define R300_PVS_DST_REG_OUT 2 +# define R300_PVS_DST_REG_OUT_REPL_X 3 +# define R300_PVS_DST_REG_ALT_TEMPORARY 4 +# define R300_PVS_DST_REG_INPUT 5 +#define R300_PVS_DST_OFFSET(x) ((x) << 13) +#define R300_PVS_DST_WE_SHIFT 20 + +/* Temporary struct used to hold assembly state while putting together + * fragment programs. */ +struct r300_vs_asm { + /* Pipe context. */ + struct r300_context* r300; + /* Number of colors. */ + unsigned color_count; + /* Number of texcoords. */ + unsigned tex_count; + /* Offset for temporary registers. Inputs and temporaries have no + * distinguishing markings, so inputs start at 0 and the first usable + * temporary register is after all inputs. */ + unsigned temp_offset; + /* Number of requested temporary registers. */ + unsigned temp_count; + /* Offset for immediate constants. Neither R300 nor R500 can do four + * inline constants per source, so instead we copy immediates into the + * constant buffer. */ + unsigned imm_offset; + /* Number of immediate constants. */ + unsigned imm_count; +}; + +void r300_translate_vertex_shader(struct r300_context* r300, + struct r300_vertex_shader* vs); + +#endif /* R300_STATE_TCL_H */ -- cgit v1.2.3 From ddd0c94f0440cebc5e63afc1ae0300e0f51bc0a3 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 31 Mar 2009 18:58:03 -0700 Subject: r300-gallium: Add vertex shader emit. --- src/gallium/drivers/r300/r300_emit.c | 20 ++++++++++++++++++ src/gallium/drivers/r300/r300_emit.h | 3 +++ src/gallium/drivers/r300/r300_state_invariant.c | 28 ------------------------- src/gallium/drivers/r300/r300_state_tcl.h | 12 +++++++++++ src/gallium/drivers/r300/r300_surface.c | 21 +++++++++++++++++++ src/gallium/drivers/r300/r300_surface.h | 1 + 6 files changed, 57 insertions(+), 28 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a2e9cca39ba..4032eac1337 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -325,9 +325,29 @@ void r300_emit_vertex_format_state(struct r300_context* r300) END_CS; } +void r300_emit_vertex_shader(struct r300_context* r300, + struct r300_vertex_shader* vs) +{ + CS_LOCALS(r300); + int i; + + BEGIN_CS(1 + (vs->instruction_count * 4)); + + OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, vs->instruction_count * 4); + for (i = 0; i < vs->instruction_count; i++) { + OUT_CS(vs->instructions[i].inst0); + OUT_CS(vs->instructions[i].inst1); + OUT_CS(vs->instructions[i].inst2); + OUT_CS(vs->instructions[i].inst3); + } + END_CS; + +} + void r300_emit_viewport_state(struct r300_context* r300, struct r300_viewport_state* viewport) { + /* XXX has_tcl */ return; CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 9d92b090ace..31dbc7ab853 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -64,6 +64,9 @@ void r300_emit_texture(struct r300_context* r300, void r300_emit_vertex_format_state(struct r300_context* r300); +void r300_emit_vertex_shader(struct r300_context* r300, + struct r300_vertex_shader* vs); + void r300_emit_viewport_state(struct r300_context* r300, struct r300_viewport_state* viewport); diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 421f01e62ec..f4bd5b6c4b5 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -156,33 +156,5 @@ void r300_emit_invariant_state(struct r300_context* r300) OUT_CS(R300_US_OUT_FMT_UNUSED); OUT_CS(R300_US_OUT_FMT_UNUSED); OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0); - /* XXX these magic numbers should be explained when - * this becomes a cached state object */ - if (caps->has_tcl) { - OUT_CS_REG(R300_VAP_CNTL, 0xA | - (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) | - (0xB << R300_VF_MAX_VTX_NUM_SHIFT) | - (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT)); - OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000); - OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000); - OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001); - /* XXX translate these back into normal instructions */ - OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1); - OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0); - OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 8); - OUT_CS(0x00F00203); - OUT_CS(0x00D10001); - OUT_CS(0x01248001); - OUT_CS(0x00000000); - OUT_CS(0x00F02203); - OUT_CS(0x00D10021); - OUT_CS(0x01248021); - OUT_CS(0x00000000); - } else { - OUT_CS_REG(R300_VAP_CNTL, 0xA | - (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) | - (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) | - (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT)); - } END_CS; } diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index 54900cc191a..1b44b9bb04e 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -66,6 +66,18 @@ struct r300_vs_asm { unsigned imm_count; }; +static struct r300_vertex_shader r300_passthrough_vertex_shader = { + .instruction_count = 2, + .instructions[0].inst0 = 0xF00203, + .instructions[0].inst1 = 0xD10001, + .instructions[0].inst2 = 0x1248001, + .instructions[0].inst3 = 0x0, + .instructions[1].inst0 = 0xF00203, + .instructions[1].inst1 = 0xD10021, + .instructions[1].inst2 = 0x1248021, + .instructions[1].inst3 = 0x0, +}; + void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs); diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 9c4f3065a7f..e524b5bf3ef 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -39,6 +39,27 @@ static void r300_surface_setup(struct pipe_context* pipe, r300_emit_dsa_state(r300, &dsa_clear_state); r300_emit_rs_state(r300, &rs_clear_state); + /* XXX these magic numbers should be explained when + * this becomes a cached state object */ + if (caps->has_tcl) { + OUT_CS_REG(R300_VAP_CNTL, 0xA | + (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) | + (0xB << R300_VF_MAX_VTX_NUM_SHIFT) | + (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT)); + OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000); + OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000); + OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001); + /* XXX translate these back into normal instructions */ + OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1); + OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0); + r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader); + } else { + OUT_CS_REG(R300_VAP_CNTL, 0xA | + (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) | + (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) | + (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT)); + } + BEGIN_CS(15); /* Pixel scissors. */ diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h index 465b8476edf..aa34054326c 100644 --- a/src/gallium/drivers/r300/r300_surface.h +++ b/src/gallium/drivers/r300/r300_surface.h @@ -32,6 +32,7 @@ #include "r300_cs.h" #include "r300_emit.h" #include "r300_state_shader.h" +#include "r300_state_tcl.h" #include "r300_state_inlines.h" const struct r300_blend_state blend_clear_state = { -- cgit v1.2.3 From 7540c847f1f046967d31445d5c936bcfdc7ed863 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 31 Mar 2009 20:04:56 -0700 Subject: r300-gallium: Moar vert shader emit. --- src/gallium/drivers/r300/r300_emit.c | 23 ++++++++++++++++++++++- src/gallium/drivers/r300/r300_reg.h | 6 ++++++ src/gallium/drivers/r300/r300_state_invariant.c | 2 +- src/gallium/drivers/r300/r300_state_tcl.h | 1 + src/gallium/drivers/r300/r300_surface.c | 18 ++++-------------- 5 files changed, 34 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 4032eac1337..989fba74df0 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -329,10 +329,26 @@ void r300_emit_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs) { CS_LOCALS(r300); + struct r300_screen* r300screen = r300_screen(r300->context.screen); int i; - BEGIN_CS(1 + (vs->instruction_count * 4)); + if (!r300screen->caps->has_tcl) { + debug_printf("r300: Implementation error: emit_vertex_shader called," + " but has_tcl is FALSE!\n"); + return; + } + + BEGIN_CS(13 + (vs->instruction_count * 4)); + OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); + OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) | + R300_PVS_LAST_INST(vs->instruction_count - 1)); + OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, vs->instruction_count - 1); + + /* XXX */ + OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x0); + + OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, vs->instruction_count * 4); for (i = 0; i < vs->instruction_count; i++) { OUT_CS(vs->instructions[i].inst0); @@ -340,6 +356,11 @@ void r300_emit_vertex_shader(struct r300_context* r300, OUT_CS(vs->instructions[i].inst2); OUT_CS(vs->instructions[i].inst3); } + + OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(10) | + R300_PVS_NUM_CNTLRS(5) | + R300_PVS_NUM_FPUS(r300screen->caps->num_vert_fpus) | + R300_PVS_VF_MAX_VTX_NUM(12)); END_CS; } diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index c9a195a6ce4..660816e1da1 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -73,6 +73,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_PVS_NUM_CNTLRS_SHIFT 4 # define R300_PVS_NUM_FPUS_SHIFT 8 # define R300_VF_MAX_VTX_NUM_SHIFT 18 +# define R300_PVS_NUM_SLOTS(x) ((x) << 0) +# define R300_PVS_NUM_CNTLRS(x) ((x) << 4) +# define R300_PVS_NUM_FPUS(x) ((x) << 8) +# define R300_PVS_VF_MAX_VTX_NUM(x) ((x) << 18) # define R300_GL_CLIP_SPACE_DEF (0 << 22) # define R300_DX_CLIP_SPACE_DEF (1 << 22) # define R500_TCL_STATE_OPTIMIZATION (1 << 23) @@ -506,6 +510,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_PVS_FIRST_INST_SHIFT 0 # define R300_PVS_XYZW_VALID_INST_SHIFT 10 # define R300_PVS_LAST_INST_SHIFT 20 +# define R300_PVS_FIRST_INST(x) ((x) << 0) +# define R300_PVS_LAST_INST(x) ((x) << 20) /* Addresses are relative the the vertex program parameters area. */ #define R300_VAP_PVS_CONST_CNTL 0x22D4 # define R300_PVS_CONST_BASE_OFFSET_SHIFT 0 diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index f4bd5b6c4b5..8bd9b41bd74 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -86,7 +86,7 @@ void r300_emit_invariant_state(struct r300_context* r300) END_CS; /* XXX unsorted stuff from surface_fill */ - BEGIN_CS(81 + (caps->has_tcl ? 26 : 0)); + BEGIN_CS(79 + (caps->has_tcl ? 7 : 0)); /* Flush PVS. */ OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index 1b44b9bb04e..bc22cd984dd 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -67,6 +67,7 @@ struct r300_vs_asm { }; static struct r300_vertex_shader r300_passthrough_vertex_shader = { + /* XXX translate these back into normal instructions */ .instruction_count = 2, .instructions[0].inst0 = 0xF00203, .instructions[0].inst1 = 0xD10001, diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index e524b5bf3ef..8cafe7d1045 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -42,22 +42,12 @@ static void r300_surface_setup(struct pipe_context* pipe, /* XXX these magic numbers should be explained when * this becomes a cached state object */ if (caps->has_tcl) { - OUT_CS_REG(R300_VAP_CNTL, 0xA | - (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) | - (0xB << R300_VF_MAX_VTX_NUM_SHIFT) | - (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT)); - OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000); - OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000); - OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001); - /* XXX translate these back into normal instructions */ - OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1); - OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0); r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader); } else { - OUT_CS_REG(R300_VAP_CNTL, 0xA | - (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) | - (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) | - (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT)); + OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | + R300_PVS_NUM_CNTLRS(5) | + R300_PVS_NUM_FPUS(caps->num_vert_fpus) | + R300_PVS_VF_MAX_VTX_NUM(12)); } BEGIN_CS(15); -- cgit v1.2.3 From 27d886ae33d287d91c92cc353f7b98f916b4d080 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 31 Mar 2009 20:24:50 -0700 Subject: r300-gallium: Backwards test. Wow, how long's that been there? Embarrassing. --- src/gallium/drivers/r300/r300_chipset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index e01a0546b22..9d95ad918c2 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -30,7 +30,7 @@ void r300_parse_chipset(struct r300_capabilities* caps) { /* Reasonable defaults */ - caps->has_tcl = getenv("RADEON_NO_TCL") ? TRUE : FALSE; + caps->has_tcl = getenv("RADEON_NO_TCL") ? FALSE : TRUE; caps->is_r500 = FALSE; caps->num_vert_fpus = 4; -- cgit v1.2.3 From e8b5d170abdab9d3d750081e0371db5c3ce51c56 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 10:18:50 +0200 Subject: python/regress: Add more vertex shader tests. --- .../python/tests/regress/vertex-shader/vert-dp4.txt | 12 ++++++++++++ .../python/tests/regress/vertex-shader/vert-mul.txt | 9 +++++++++ .../python/tests/regress/vertex-shader/vert-sub.txt | 9 +++++++++ .../python/tests/regress/vertex-shader/vertex-shader.py | 3 +++ 4 files changed, 33 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt new file mode 100644 index 00000000000..3e5f248bebc --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt @@ -0,0 +1,12 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +DP4 TEMP[0].xy, IN[0], IN[0] +MOV TEMP[0].zw, IMM[0] +MUL OUT[0], IN[0], TEMP[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt new file mode 100644 index 00000000000..1289fcd2e2b --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt @@ -0,0 +1,9 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +IMM FLT32 { 0.6, 0.6, 1.0, 1.0 } +MUL OUT[0], IN[0], IMM[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt new file mode 100644 index 00000000000..9190086a22e --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt @@ -0,0 +1,9 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } +SUB OUT[0], IN[0], IMM[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 92ff2053093..b393500742c 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -214,7 +214,10 @@ def main(): 'abs', 'add', 'dp3', + 'dp4', 'mov', + 'mul', + 'sub', ] html = ''' -- cgit v1.2.3 From 541d74423abf04c6cdcf545f853980b959a70ec8 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 10:23:09 +0200 Subject: python/regress: Rename test files from *.txt to *.sh -- won't be .gitignored. --- .../python/tests/regress/vertex-shader/vert-abs.sh | 11 +++++++++++ .../python/tests/regress/vertex-shader/vert-abs.txt | 11 ----------- .../python/tests/regress/vertex-shader/vert-add.sh | 9 +++++++++ .../python/tests/regress/vertex-shader/vert-add.txt | 9 --------- .../python/tests/regress/vertex-shader/vert-dp3.sh | 12 ++++++++++++ .../python/tests/regress/vertex-shader/vert-dp3.txt | 12 ------------ .../python/tests/regress/vertex-shader/vert-dp4.sh | 12 ++++++++++++ .../python/tests/regress/vertex-shader/vert-dp4.txt | 12 ------------ .../python/tests/regress/vertex-shader/vert-mov.sh | 8 ++++++++ .../python/tests/regress/vertex-shader/vert-mov.txt | 8 -------- .../python/tests/regress/vertex-shader/vert-mul.sh | 9 +++++++++ .../python/tests/regress/vertex-shader/vert-mul.txt | 9 --------- .../python/tests/regress/vertex-shader/vert-sub.sh | 9 +++++++++ .../python/tests/regress/vertex-shader/vert-sub.txt | 9 --------- .../python/tests/regress/vertex-shader/vertex-shader.py | 2 +- 15 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh delete mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh new file mode 100644 index 00000000000..66c1986cef7 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh @@ -0,0 +1,11 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] +IMM FLT32 { 0.2, 0.2, 0.0, 0.0 } +ADD TEMP[0], IN[0], IMM[0] +ABS OUT[0], TEMP[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt deleted file mode 100644 index 66c1986cef7..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.txt +++ /dev/null @@ -1,11 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] -IMM FLT32 { 0.2, 0.2, 0.0, 0.0 } -ADD TEMP[0], IN[0], IMM[0] -ABS OUT[0], TEMP[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh new file mode 100644 index 00000000000..78753b76d8a --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh @@ -0,0 +1,9 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +IMM FLT32 { 0.2, -0.1, 0.0, 0.0 } +ADD OUT[0], IN[0], IMM[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt deleted file mode 100644 index 78753b76d8a..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.txt +++ /dev/null @@ -1,9 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -IMM FLT32 { 0.2, -0.1, 0.0, 0.0 } -ADD OUT[0], IN[0], IMM[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh new file mode 100644 index 00000000000..e4c1c4a9b33 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh @@ -0,0 +1,12 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +DP3 TEMP[0].xy, IN[0], IN[0] +MOV TEMP[0].zw, IMM[0] +MUL OUT[0], IN[0], TEMP[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt deleted file mode 100644 index e4c1c4a9b33..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.txt +++ /dev/null @@ -1,12 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } -DP3 TEMP[0].xy, IN[0], IN[0] -MOV TEMP[0].zw, IMM[0] -MUL OUT[0], IN[0], TEMP[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh new file mode 100644 index 00000000000..3e5f248bebc --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh @@ -0,0 +1,12 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +DP4 TEMP[0].xy, IN[0], IN[0] +MOV TEMP[0].zw, IMM[0] +MUL OUT[0], IN[0], TEMP[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt deleted file mode 100644 index 3e5f248bebc..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.txt +++ /dev/null @@ -1,12 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } -DP4 TEMP[0].xy, IN[0], IN[0] -MOV TEMP[0].zw, IMM[0] -MUL OUT[0], IN[0], TEMP[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh new file mode 100644 index 00000000000..12712ff8590 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh @@ -0,0 +1,8 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +MOV OUT[0], IN[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt deleted file mode 100644 index 12712ff8590..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.txt +++ /dev/null @@ -1,8 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -MOV OUT[0], IN[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh new file mode 100644 index 00000000000..1289fcd2e2b --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh @@ -0,0 +1,9 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +IMM FLT32 { 0.6, 0.6, 1.0, 1.0 } +MUL OUT[0], IN[0], IMM[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt deleted file mode 100644 index 1289fcd2e2b..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.txt +++ /dev/null @@ -1,9 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -IMM FLT32 { 0.6, 0.6, 1.0, 1.0 } -MUL OUT[0], IN[0], IMM[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh new file mode 100644 index 00000000000..9190086a22e --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh @@ -0,0 +1,9 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } +SUB OUT[0], IN[0], IMM[0] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt deleted file mode 100644 index 9190086a22e..00000000000 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.txt +++ /dev/null @@ -1,9 +0,0 @@ -VERT1.1 -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } -SUB OUT[0], IN[0], IMM[0] -MOV OUT[1], IN[1] -END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index b393500742c..7e0b561d79a 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -132,7 +132,7 @@ def test(dev, name): ctx.surface_clear(zbuf, 0xffffffff) # vertex shader - vs = Shader(file('vert-' + name + '.txt', 'rt').read()) + vs = Shader(file('vert-' + name + '.sh', 'rt').read()) ctx.set_vertex_shader(vs) # fragment shader -- cgit v1.2.3 From 5d8677469b369d2b6a89519be7e379abdf4015d3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 10:56:53 +0200 Subject: python/regress: Add vertex shader test for XPD. --- .../state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh | 8 ++++++++ .../python/tests/regress/vertex-shader/vertex-shader.py | 1 + 2 files changed, 9 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh new file mode 100644 index 00000000000..6c767cc017f --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh @@ -0,0 +1,8 @@ +VERT1.1 +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +XPD OUT[0], IN[0], IN[1] +MOV OUT[1], IN[1] +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 7e0b561d79a..c207a46ec35 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -218,6 +218,7 @@ def main(): 'mov', 'mul', 'sub', + 'xpd', ] html = ''' -- cgit v1.2.3 From dd6f1771c9e52f1c6126aa223555e363e522c088 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 10:58:46 +0200 Subject: python/regress: Indent. --- .../state_trackers/python/tests/regress/vertex-shader/vert-abs.sh | 4 ++++ .../state_trackers/python/tests/regress/vertex-shader/vert-add.sh | 4 ++++ .../state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh | 4 ++++ .../state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh | 4 ++++ .../state_trackers/python/tests/regress/vertex-shader/vert-mov.sh | 3 +++ .../state_trackers/python/tests/regress/vertex-shader/vert-mul.sh | 4 ++++ .../state_trackers/python/tests/regress/vertex-shader/vert-sub.sh | 4 ++++ .../state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh | 3 +++ 8 files changed, 30 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh index 66c1986cef7..f0d0d5de171 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-abs.sh @@ -1,11 +1,15 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR DCL TEMP[0] + IMM FLT32 { 0.2, 0.2, 0.0, 0.0 } + ADD TEMP[0], IN[0], IMM[0] ABS OUT[0], TEMP[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh index 78753b76d8a..936c851c9dc 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-add.sh @@ -1,9 +1,13 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR + IMM FLT32 { 0.2, -0.1, 0.0, 0.0 } + ADD OUT[0], IN[0], IMM[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh index e4c1c4a9b33..b57d68520fc 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp3.sh @@ -1,12 +1,16 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR DCL TEMP[0] + IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } + DP3 TEMP[0].xy, IN[0], IN[0] MOV TEMP[0].zw, IMM[0] MUL OUT[0], IN[0], TEMP[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh index 3e5f248bebc..0eb31719c58 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dp4.sh @@ -1,12 +1,16 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR DCL TEMP[0] + IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } + DP4 TEMP[0].xy, IN[0], IN[0] MOV TEMP[0].zw, IMM[0] MUL OUT[0], IN[0], TEMP[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh index 12712ff8590..bcdec07c204 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mov.sh @@ -1,8 +1,11 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR + MOV OUT[0], IN[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh index 1289fcd2e2b..f3b57c30382 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mul.sh @@ -1,9 +1,13 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR + IMM FLT32 { 0.6, 0.6, 1.0, 1.0 } + MUL OUT[0], IN[0], IMM[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh index 9190086a22e..a583b958284 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sub.sh @@ -1,9 +1,13 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR + IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } + SUB OUT[0], IN[0], IMM[0] MOV OUT[1], IN[1] + END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh index 6c767cc017f..10e421684b5 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh @@ -1,8 +1,11 @@ VERT1.1 + DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR + XPD OUT[0], IN[0], IN[1] MOV OUT[1], IN[1] + END -- cgit v1.2.3 From 65cbe7e69c30a4ac91cfbc27a964a19b59d3cedd Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 11:08:41 +0200 Subject: python/regress: Fix vertex shader XPD test. --- .../state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh index 10e421684b5..8def8943b03 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-xpd.sh @@ -5,7 +5,7 @@ DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR -XPD OUT[0], IN[0], IN[1] -MOV OUT[1], IN[1] +MOV OUT[0], IN[0] +XPD OUT[1], IN[0], IN[1] END -- cgit v1.2.3 From 449bab61b3209d15d71ba7d5cc266f76ee16df2b Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 11:09:37 +0200 Subject: python/regress: Add vertex shader DST test. --- .../python/tests/regress/vertex-shader/vert-dst.sh | 11 +++++++++++ .../python/tests/regress/vertex-shader/vertex-shader.py | 1 + 2 files changed, 12 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dst.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dst.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dst.sh new file mode 100644 index 00000000000..dc5e0eb92e5 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-dst.sh @@ -0,0 +1,11 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +MOV OUT[0], IN[0] +DST OUT[1], IN[1], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index c207a46ec35..7b658165a7f 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -215,6 +215,7 @@ def main(): 'add', 'dp3', 'dp4', + 'dst', 'mov', 'mul', 'sub', -- cgit v1.2.3 From 998234ced24e2a4b73b91fbbe25b00d29c6ccc66 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 11:25:02 +0200 Subject: python/regress: Add vertex shader EX2 test. --- .../python/tests/regress/vertex-shader/vert-ex2.sh | 18 ++++++++++++++++++ .../tests/regress/vertex-shader/vertex-shader.py | 1 + 2 files changed, 19 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-ex2.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-ex2.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-ex2.sh new file mode 100644 index 00000000000..34057af4e66 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-ex2.sh @@ -0,0 +1,18 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0..1] + +IMM FLT32 { 0.3, 0.3, 0.3, 1.0 } + +EX2 TEMP[0], IN[0] +EX2 TEMP[1], IN[1].yyyy +MUL TEMP[0], TEMP[0], IMM[0] +MOV OUT[0], IN[0] +MUL OUT[1], TEMP[0], TEMP[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 7b658165a7f..72ea88b1860 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -216,6 +216,7 @@ def main(): 'dp3', 'dp4', 'dst', + 'ex2', 'mov', 'mul', 'sub', -- cgit v1.2.3 From 9d77663abb6ebb5eae66fac18088079e76f508d3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 11:25:58 +0200 Subject: tgsi/doc: Fix typo. --- src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt index a20ad689c08..a3f4947c734 100644 --- a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt +++ b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt @@ -262,7 +262,7 @@ TGSI Instruction Specification dst.w = round(src.w) -1.3.10 EXPBASE2 - Exponent Base 2 +1.3.10 EXPBASE2 - Exponential Base 2 dst.x = pow(2.0, src.x) dst.y = pow(2.0, src.x) -- cgit v1.2.3 From 1aa4b79dc772825cabfcc97de90b7247cc4b10a0 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 11:45:25 +0200 Subject: tgsi: Provide alternate instruction mnemonics in tgsi info. --- src/gallium/auxiliary/tgsi/tgsi_info.c | 58 +++++++++++++++++----------------- src/gallium/auxiliary/tgsi/tgsi_info.h | 2 ++ 2 files changed, 31 insertions(+), 29 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 2b8a6f0fb19..22034c7a0ba 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -33,42 +33,42 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 1, 0, 0, "ARL" }, { 1, 1, 0, 0, "MOV" }, { 1, 1, 0, 0, "LIT" }, - { 1, 1, 0, 0, "RCP" }, - { 1, 1, 0, 0, "RSQ" }, - { 1, 1, 0, 0, "EXP" }, + { 1, 1, 0, 0, "RCP", "RECIP" }, + { 1, 1, 0, 0, "RSQ", "RECIPSQRT" }, + { 1, 1, 0, 0, "EXP", "EXPP" }, { 1, 1, 0, 0, "LOG" }, { 1, 2, 0, 0, "MUL" }, { 1, 2, 0, 0, "ADD" }, - { 1, 2, 0, 0, "DP3" }, - { 1, 2, 0, 0, "DP4" }, + { 1, 2, 0, 0, "DP3", "DOT3" }, + { 1, 2, 0, 0, "DP4", "DOT4" }, { 1, 2, 0, 0, "DST" }, { 1, 2, 0, 0, "MIN" }, { 1, 2, 0, 0, "MAX" }, - { 1, 2, 0, 0, "SLT" }, - { 1, 2, 0, 0, "SGE" }, - { 1, 3, 0, 0, "MAD" }, + { 1, 2, 0, 0, "SLT", "SETLT" }, + { 1, 2, 0, 0, "SGE", "SETGE" }, + { 1, 3, 0, 0, "MAD", "MADD" }, { 1, 2, 0, 0, "SUB" }, - { 1, 3, 0, 0, "LERP" }, + { 1, 3, 0, 0, "LRP", "LERP" }, { 1, 3, 0, 0, "CND" }, { 1, 3, 0, 0, "CND0" }, - { 1, 3, 0, 0, "DOT2ADD" }, + { 1, 3, 0, 0, "DP2A", "DP2ADD", "DOT2ADD" }, { 1, 2, 0, 0, "INDEX" }, { 1, 1, 0, 0, "NEGATE" }, - { 1, 1, 0, 0, "FRAC" }, + { 1, 1, 0, 0, "FRC", "FRAC" }, { 1, 3, 0, 0, "CLAMP" }, - { 1, 1, 0, 0, "FLOOR" }, + { 1, 1, 0, 0, "FLR", "FLOOR" }, { 1, 1, 0, 0, "ROUND" }, - { 1, 1, 0, 0, "EXPBASE2" }, - { 1, 1, 0, 0, "LOGBASE2" }, - { 1, 2, 0, 0, "POWER" }, - { 1, 2, 0, 0, "CROSSPRODUCT" }, - { 1, 2, 0, 0, "MULTIPLYMATRIX" }, + { 1, 1, 0, 0, "EX2", "EXPBASE2" }, + { 1, 1, 0, 0, "LG2", "LOGBASE2", "LOGP" }, + { 1, 2, 0, 0, "POW", "POWER" }, + { 1, 2, 0, 0, "XPD", "CRS", "CROSSPRODUCT" }, + { 1, 2, 0, 0, "M4X4", "MULTIPLYMATRIX" }, { 1, 1, 0, 0, "ABS" }, { 1, 1, 0, 0, "RCC" }, { 1, 2, 0, 0, "DPH" }, { 1, 1, 0, 0, "COS" }, - { 1, 1, 0, 0, "DDX" }, - { 1, 1, 0, 0, "DDY" }, + { 1, 1, 0, 0, "DDX", "DSX" }, + { 1, 1, 0, 0, "DDY", "DSY" }, { 0, 0, 0, 0, "KILP" }, { 1, 1, 0, 0, "PK2H" }, { 1, 1, 0, 0, "PK2US" }, @@ -82,8 +82,8 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 2, 0, 0, "SLE" }, { 1, 2, 0, 0, "SNE" }, { 1, 2, 0, 0, "STR" }, - { 1, 2, 1, 0, "TEX" }, - { 1, 4, 1, 0, "TXD" }, + { 1, 2, 1, 0, "TEX", "TEXLD" }, + { 1, 4, 1, 0, "TXD", "TEXLDD" }, { 1, 2, 1, 0, "TXP" }, { 1, 1, 0, 0, "UP2H" }, { 1, 1, 0, 0, "UP2US" }, @@ -91,19 +91,19 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 1, 0, 0, "UP4UB" }, { 1, 3, 0, 0, "X2D" }, { 1, 1, 0, 0, "ARA" }, - { 1, 1, 0, 0, "ARR" }, + { 1, 1, 0, 0, "ARR", "MOVA" }, { 0, 1, 0, 0, "BRA" }, - { 0, 0, 0, 1, "CAL" }, + { 0, 0, 0, 1, "CAL", "CALL" }, { 0, 0, 0, 0, "RET" }, - { 1, 1, 0, 0, "SSG" }, + { 1, 1, 0, 0, "SGN", "SSG" }, { 1, 3, 0, 0, "CMP" }, - { 1, 1, 0, 0, "SCS" }, - { 1, 2, 1, 0, "TXB" }, + { 1, 1, 0, 0, "SCS", "SINCOS" }, + { 1, 2, 1, 0, "TXB", "TEXLDB" }, { 1, 1, 0, 0, "NRM" }, { 1, 2, 0, 0, "DIV" }, { 1, 2, 0, 0, "DP2" }, { 1, 2, 1, 0, "TXL" }, - { 0, 0, 0, 0, "BRK" }, + { 0, 0, 0, 0, "BRK", "BREAK" }, { 0, 1, 0, 1, "IF" }, { 0, 0, 0, 0, "LOOP" }, { 0, 1, 0, 0, "REP" }, @@ -116,7 +116,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 1, 0, 0, "CEIL" }, { 1, 1, 0, 0, "I2F" }, { 1, 1, 0, 0, "NOT" }, - { 1, 1, 0, 0, "TRUNC" }, + { 1, 1, 0, 0, "INT", "TRUNC" }, { 1, 2, 0, 0, "SHL" }, { 1, 2, 0, 0, "SHR" }, { 1, 2, 0, 0, "AND" }, @@ -146,7 +146,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 0, 1, 0, 0, "CALLNZ" }, { 0, 1, 0, 0, "IFC" }, { 0, 1, 0, 0, "BREAKC" }, - { 0, 1, 0, 0, "KIL" }, + { 0, 1, 0, 0, "KIL", "TEXKILL" }, { 0, 0, 0, 0, "END" }, { 1, 1, 0, 0, "SWZ" } }; diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h index 7230bdaae33..077e25acd7f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.h +++ b/src/gallium/auxiliary/tgsi/tgsi_info.h @@ -41,6 +41,8 @@ struct tgsi_opcode_info boolean is_tex; boolean is_branch; const char *mnemonic; + const char *alt_mnemonic1; + const char *alt_mnemonic2; }; const struct tgsi_opcode_info * -- cgit v1.2.3 From daec1035a2d23ee4d3122f10fd6e676216527d53 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 11:49:55 +0200 Subject: tgsi: Lookup alternate instruction mnemonics when parsing tgsi text. --- src/gallium/auxiliary/tgsi/tgsi_text.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 58fe07c11d1..fdaee9b060b 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -740,6 +740,26 @@ static const char *texture_names[TGSI_TEXTURE_COUNT] = "SHADOWRECT" }; +static boolean +match_inst_mnemonic(const char **pcur, + const struct tgsi_opcode_info *info) +{ + if (str_match_no_case(pcur, info->mnemonic)) { + return TRUE; + } + if (info->alt_mnemonic1) { + if (str_match_no_case(pcur, info->alt_mnemonic1)) { + return TRUE; + } + if (info->alt_mnemonic2) { + if (str_match_no_case(pcur, info->alt_mnemonic2)) { + return TRUE; + } + } + } + return FALSE; +} + static boolean parse_instruction( struct translate_ctx *ctx, @@ -758,7 +778,7 @@ parse_instruction( const char *cur = ctx->cur; info = tgsi_get_opcode_info( i ); - if (str_match_no_case( &cur, info->mnemonic )) { + if (match_inst_mnemonic(&cur, info)) { if (str_match_no_case( &cur, "_SATNV" )) saturate = TGSI_SAT_MINUS_PLUS_ONE; else if (str_match_no_case( &cur, "_SAT" )) -- cgit v1.2.3 From 16c281dfb537ccad02ab205298e94353c5bb1a2a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 15:41:36 +0200 Subject: python/regress: Add vertex shader FRC test. --- .../python/tests/regress/vertex-shader/vert-frc.sh | 16 ++++++++++++++++ .../python/tests/regress/vertex-shader/vertex-shader.py | 1 + 2 files changed, 17 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh new file mode 100644 index 00000000000..91c0f9c70dd --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh @@ -0,0 +1,16 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +IMM FLT32 { 2.7, 3.1, 4.5, 1.0 } + +MUL TEMP[0], IN[0].xyxw, IMM[0] +MOV OUT[0], IN[0] +FRC OUT[1], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 72ea88b1860..4f7878ee8dc 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -217,6 +217,7 @@ def main(): 'dp4', 'dst', 'ex2', + 'frc', 'mov', 'mul', 'sub', -- cgit v1.2.3 From 4900545bbaff238c75130cf14dd399505a1cde71 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 16:05:29 +0200 Subject: python/regress: Add vertex shader LRP test. --- .../python/tests/regress/vertex-shader/vert-lrp.sh | 14 ++++++++++++++ .../python/tests/regress/vertex-shader/vertex-shader.py | 1 + 2 files changed, 15 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lrp.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lrp.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lrp.sh new file mode 100644 index 00000000000..8c262580e23 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lrp.sh @@ -0,0 +1,14 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +ABS TEMP[0], IN[0] +MOV OUT[0], IN[0] +LRP OUT[1], TEMP[0], IN[1].xxxx, IN[1].yyyy + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 4f7878ee8dc..97f6240dec5 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -218,6 +218,7 @@ def main(): 'dst', 'ex2', 'frc', + 'lrp', 'mov', 'mul', 'sub', -- cgit v1.2.3 From d11a476ead3e617e45b091f73bd1f67042643a0f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Apr 2009 22:06:53 +0200 Subject: tgsi: Fix structure members initialisation. --- src/gallium/auxiliary/tgsi/tgsi_info.c | 232 ++++++++++++++++----------------- 1 file changed, 116 insertions(+), 116 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 22034c7a0ba..37f2b66d1f6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -30,125 +30,125 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { - { 1, 1, 0, 0, "ARL" }, - { 1, 1, 0, 0, "MOV" }, - { 1, 1, 0, 0, "LIT" }, - { 1, 1, 0, 0, "RCP", "RECIP" }, - { 1, 1, 0, 0, "RSQ", "RECIPSQRT" }, - { 1, 1, 0, 0, "EXP", "EXPP" }, - { 1, 1, 0, 0, "LOG" }, - { 1, 2, 0, 0, "MUL" }, - { 1, 2, 0, 0, "ADD" }, - { 1, 2, 0, 0, "DP3", "DOT3" }, - { 1, 2, 0, 0, "DP4", "DOT4" }, - { 1, 2, 0, 0, "DST" }, - { 1, 2, 0, 0, "MIN" }, - { 1, 2, 0, 0, "MAX" }, - { 1, 2, 0, 0, "SLT", "SETLT" }, - { 1, 2, 0, 0, "SGE", "SETGE" }, - { 1, 3, 0, 0, "MAD", "MADD" }, - { 1, 2, 0, 0, "SUB" }, - { 1, 3, 0, 0, "LRP", "LERP" }, - { 1, 3, 0, 0, "CND" }, - { 1, 3, 0, 0, "CND0" }, + { 1, 1, 0, 0, "ARL", NULL, NULL }, + { 1, 1, 0, 0, "MOV", NULL, NULL }, + { 1, 1, 0, 0, "LIT", NULL, NULL }, + { 1, 1, 0, 0, "RCP", "RECIP", NULL }, + { 1, 1, 0, 0, "RSQ", "RECIPSQRT", NULL }, + { 1, 1, 0, 0, "EXP", "EXPP", NULL }, + { 1, 1, 0, 0, "LOG", NULL, NULL }, + { 1, 2, 0, 0, "MUL", NULL, NULL }, + { 1, 2, 0, 0, "ADD", NULL, NULL }, + { 1, 2, 0, 0, "DP3", "DOT3", NULL }, + { 1, 2, 0, 0, "DP4", "DOT4", NULL }, + { 1, 2, 0, 0, "DST", NULL, NULL }, + { 1, 2, 0, 0, "MIN", NULL, NULL }, + { 1, 2, 0, 0, "MAX", NULL, NULL }, + { 1, 2, 0, 0, "SLT", "SETLT", NULL }, + { 1, 2, 0, 0, "SGE", "SETGE", NULL }, + { 1, 3, 0, 0, "MAD", "MADD", NULL }, + { 1, 2, 0, 0, "SUB", NULL, NULL }, + { 1, 3, 0, 0, "LRP", "LERP", NULL }, + { 1, 3, 0, 0, "CND", NULL, NULL }, + { 1, 3, 0, 0, "CND0", NULL, NULL }, { 1, 3, 0, 0, "DP2A", "DP2ADD", "DOT2ADD" }, - { 1, 2, 0, 0, "INDEX" }, - { 1, 1, 0, 0, "NEGATE" }, - { 1, 1, 0, 0, "FRC", "FRAC" }, - { 1, 3, 0, 0, "CLAMP" }, - { 1, 1, 0, 0, "FLR", "FLOOR" }, - { 1, 1, 0, 0, "ROUND" }, - { 1, 1, 0, 0, "EX2", "EXPBASE2" }, + { 1, 2, 0, 0, "INDEX", NULL, NULL }, + { 1, 1, 0, 0, "NEGATE", NULL, NULL }, + { 1, 1, 0, 0, "FRC", "FRAC", NULL }, + { 1, 3, 0, 0, "CLAMP", NULL, NULL }, + { 1, 1, 0, 0, "FLR", "FLOOR", NULL }, + { 1, 1, 0, 0, "ROUND", NULL, NULL }, + { 1, 1, 0, 0, "EX2", "EXPBASE2", NULL }, { 1, 1, 0, 0, "LG2", "LOGBASE2", "LOGP" }, - { 1, 2, 0, 0, "POW", "POWER" }, + { 1, 2, 0, 0, "POW", "POWER", NULL }, { 1, 2, 0, 0, "XPD", "CRS", "CROSSPRODUCT" }, - { 1, 2, 0, 0, "M4X4", "MULTIPLYMATRIX" }, - { 1, 1, 0, 0, "ABS" }, - { 1, 1, 0, 0, "RCC" }, - { 1, 2, 0, 0, "DPH" }, - { 1, 1, 0, 0, "COS" }, - { 1, 1, 0, 0, "DDX", "DSX" }, - { 1, 1, 0, 0, "DDY", "DSY" }, - { 0, 0, 0, 0, "KILP" }, - { 1, 1, 0, 0, "PK2H" }, - { 1, 1, 0, 0, "PK2US" }, - { 1, 1, 0, 0, "PK4B" }, - { 1, 1, 0, 0, "PK4UB" }, - { 1, 2, 0, 0, "RFL" }, - { 1, 2, 0, 0, "SEQ" }, - { 1, 2, 0, 0, "SFL" }, - { 1, 2, 0, 0, "SGT" }, - { 1, 1, 0, 0, "SIN" }, - { 1, 2, 0, 0, "SLE" }, - { 1, 2, 0, 0, "SNE" }, - { 1, 2, 0, 0, "STR" }, - { 1, 2, 1, 0, "TEX", "TEXLD" }, - { 1, 4, 1, 0, "TXD", "TEXLDD" }, - { 1, 2, 1, 0, "TXP" }, - { 1, 1, 0, 0, "UP2H" }, - { 1, 1, 0, 0, "UP2US" }, - { 1, 1, 0, 0, "UP4B" }, - { 1, 1, 0, 0, "UP4UB" }, - { 1, 3, 0, 0, "X2D" }, - { 1, 1, 0, 0, "ARA" }, - { 1, 1, 0, 0, "ARR", "MOVA" }, - { 0, 1, 0, 0, "BRA" }, - { 0, 0, 0, 1, "CAL", "CALL" }, - { 0, 0, 0, 0, "RET" }, - { 1, 1, 0, 0, "SGN", "SSG" }, - { 1, 3, 0, 0, "CMP" }, - { 1, 1, 0, 0, "SCS", "SINCOS" }, - { 1, 2, 1, 0, "TXB", "TEXLDB" }, - { 1, 1, 0, 0, "NRM" }, - { 1, 2, 0, 0, "DIV" }, - { 1, 2, 0, 0, "DP2" }, - { 1, 2, 1, 0, "TXL" }, - { 0, 0, 0, 0, "BRK", "BREAK" }, - { 0, 1, 0, 1, "IF" }, - { 0, 0, 0, 0, "LOOP" }, - { 0, 1, 0, 0, "REP" }, - { 0, 0, 0, 1, "ELSE" }, - { 0, 0, 0, 0, "ENDIF" }, - { 0, 0, 0, 0, "ENDLOOP" }, - { 0, 0, 0, 0, "ENDREP" }, - { 0, 1, 0, 0, "PUSHA" }, - { 1, 0, 0, 0, "POPA" }, - { 1, 1, 0, 0, "CEIL" }, - { 1, 1, 0, 0, "I2F" }, - { 1, 1, 0, 0, "NOT" }, - { 1, 1, 0, 0, "INT", "TRUNC" }, - { 1, 2, 0, 0, "SHL" }, - { 1, 2, 0, 0, "SHR" }, - { 1, 2, 0, 0, "AND" }, - { 1, 2, 0, 0, "OR" }, - { 1, 2, 0, 0, "MOD" }, - { 1, 2, 0, 0, "XOR" }, - { 1, 3, 0, 0, "SAD" }, - { 1, 2, 1, 0, "TXF" }, - { 1, 2, 1, 0, "TXQ" }, - { 0, 0, 0, 0, "CONT" }, - { 0, 0, 0, 0, "EMIT" }, - { 0, 0, 0, 0, "ENDPRIM" }, - { 0, 0, 0, 1, "BGNLOOP2" }, - { 0, 0, 0, 0, "BGNSUB" }, - { 0, 0, 0, 1, "ENDLOOP2" }, - { 0, 0, 0, 0, "ENDSUB" }, - { 1, 1, 0, 0, "NOISE1" }, - { 1, 1, 0, 0, "NOISE2" }, - { 1, 1, 0, 0, "NOISE3" }, - { 1, 1, 0, 0, "NOISE4" }, - { 0, 0, 0, 0, "NOP" }, - { 1, 2, 0, 0, "M4X3" }, - { 1, 2, 0, 0, "M3X4" }, - { 1, 2, 0, 0, "M3X3" }, - { 1, 2, 0, 0, "M3X2" }, - { 1, 1, 0, 0, "NRM4" }, - { 0, 1, 0, 0, "CALLNZ" }, - { 0, 1, 0, 0, "IFC" }, - { 0, 1, 0, 0, "BREAKC" }, - { 0, 1, 0, 0, "KIL", "TEXKILL" }, - { 0, 0, 0, 0, "END" }, - { 1, 1, 0, 0, "SWZ" } + { 1, 2, 0, 0, "M4X4", "MULTIPLYMATRIX", NULL }, + { 1, 1, 0, 0, "ABS", NULL, NULL }, + { 1, 1, 0, 0, "RCC", NULL, NULL }, + { 1, 2, 0, 0, "DPH", NULL, NULL }, + { 1, 1, 0, 0, "COS", NULL, NULL }, + { 1, 1, 0, 0, "DDX", "DSX", NULL }, + { 1, 1, 0, 0, "DDY", "DSY", NULL }, + { 0, 0, 0, 0, "KILP", NULL, NULL }, + { 1, 1, 0, 0, "PK2H", NULL, NULL }, + { 1, 1, 0, 0, "PK2US", NULL, NULL }, + { 1, 1, 0, 0, "PK4B", NULL, NULL }, + { 1, 1, 0, 0, "PK4UB", NULL, NULL }, + { 1, 2, 0, 0, "RFL", NULL, NULL }, + { 1, 2, 0, 0, "SEQ", NULL, NULL }, + { 1, 2, 0, 0, "SFL", NULL, NULL }, + { 1, 2, 0, 0, "SGT", NULL, NULL }, + { 1, 1, 0, 0, "SIN", NULL, NULL }, + { 1, 2, 0, 0, "SLE", NULL, NULL }, + { 1, 2, 0, 0, "SNE", NULL, NULL }, + { 1, 2, 0, 0, "STR", NULL, NULL }, + { 1, 2, 1, 0, "TEX", "TEXLD", NULL }, + { 1, 4, 1, 0, "TXD", "TEXLDD", NULL }, + { 1, 2, 1, 0, "TXP", NULL, NULL }, + { 1, 1, 0, 0, "UP2H", NULL, NULL }, + { 1, 1, 0, 0, "UP2US", NULL, NULL }, + { 1, 1, 0, 0, "UP4B", NULL, NULL }, + { 1, 1, 0, 0, "UP4UB", NULL, NULL }, + { 1, 3, 0, 0, "X2D", NULL, NULL }, + { 1, 1, 0, 0, "ARA", NULL, NULL }, + { 1, 1, 0, 0, "ARR", "MOVA", NULL }, + { 0, 1, 0, 0, "BRA", NULL, NULL }, + { 0, 0, 0, 1, "CAL", "CALL", NULL }, + { 0, 0, 0, 0, "RET", NULL, NULL }, + { 1, 1, 0, 0, "SGN", "SSG", NULL }, + { 1, 3, 0, 0, "CMP", NULL, NULL }, + { 1, 1, 0, 0, "SCS", "SINCOS", NULL }, + { 1, 2, 1, 0, "TXB", "TEXLDB", NULL }, + { 1, 1, 0, 0, "NRM", NULL, NULL }, + { 1, 2, 0, 0, "DIV", NULL, NULL }, + { 1, 2, 0, 0, "DP2", NULL, NULL }, + { 1, 2, 1, 0, "TXL", NULL, NULL }, + { 0, 0, 0, 0, "BRK", "BREAK", NULL }, + { 0, 1, 0, 1, "IF", NULL, NULL }, + { 0, 0, 0, 0, "LOOP", NULL, NULL }, + { 0, 1, 0, 0, "REP", NULL, NULL }, + { 0, 0, 0, 1, "ELSE", NULL, NULL }, + { 0, 0, 0, 0, "ENDIF", NULL, NULL }, + { 0, 0, 0, 0, "ENDLOOP", NULL, NULL }, + { 0, 0, 0, 0, "ENDREP", NULL, NULL }, + { 0, 1, 0, 0, "PUSHA", NULL, NULL }, + { 1, 0, 0, 0, "POPA", NULL, NULL }, + { 1, 1, 0, 0, "CEIL", NULL, NULL }, + { 1, 1, 0, 0, "I2F", NULL, NULL }, + { 1, 1, 0, 0, "NOT", NULL, NULL }, + { 1, 1, 0, 0, "INT", "TRUNC", NULL }, + { 1, 2, 0, 0, "SHL", NULL, NULL }, + { 1, 2, 0, 0, "SHR", NULL, NULL }, + { 1, 2, 0, 0, "AND", NULL, NULL }, + { 1, 2, 0, 0, "OR", NULL, NULL }, + { 1, 2, 0, 0, "MOD", NULL, NULL }, + { 1, 2, 0, 0, "XOR", NULL, NULL }, + { 1, 3, 0, 0, "SAD", NULL, NULL }, + { 1, 2, 1, 0, "TXF", NULL, NULL }, + { 1, 2, 1, 0, "TXQ", NULL, NULL }, + { 0, 0, 0, 0, "CONT", NULL, NULL }, + { 0, 0, 0, 0, "EMIT", NULL, NULL }, + { 0, 0, 0, 0, "ENDPRIM", NULL, NULL }, + { 0, 0, 0, 1, "BGNLOOP2", NULL, NULL }, + { 0, 0, 0, 0, "BGNSUB", NULL, NULL }, + { 0, 0, 0, 1, "ENDLOOP2", NULL, NULL }, + { 0, 0, 0, 0, "ENDSUB", NULL, NULL }, + { 1, 1, 0, 0, "NOISE1", NULL, NULL }, + { 1, 1, 0, 0, "NOISE2", NULL, NULL }, + { 1, 1, 0, 0, "NOISE3", NULL, NULL }, + { 1, 1, 0, 0, "NOISE4", NULL, NULL }, + { 0, 0, 0, 0, "NOP", NULL, NULL }, + { 1, 2, 0, 0, "M4X3", NULL, NULL }, + { 1, 2, 0, 0, "M3X4", NULL, NULL }, + { 1, 2, 0, 0, "M3X3", NULL, NULL }, + { 1, 2, 0, 0, "M3X2", NULL, NULL }, + { 1, 1, 0, 0, "NRM4", NULL, NULL }, + { 0, 1, 0, 0, "CALLNZ", NULL, NULL }, + { 0, 1, 0, 0, "IFC", NULL, NULL }, + { 0, 1, 0, 0, "BREAKC", NULL, NULL }, + { 0, 1, 0, 0, "KIL", "TEXKILL", NULL }, + { 0, 0, 0, 0, "END", NULL, NULL }, + { 1, 1, 0, 0, "SWZ", NULL, NULL } }; const struct tgsi_opcode_info * -- cgit v1.2.3 From 346e12773219b8a514b6cab7a670777c0fb554b6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 1 Apr 2009 21:00:59 +0100 Subject: util: Lookup symbol names from addresses. Nice for stack backtraces. Windows-only for now. --- src/gallium/auxiliary/util/Makefile | 2 + src/gallium/auxiliary/util/SConscript | 1 + src/gallium/auxiliary/util/u_debug_stack.c | 3 +- src/gallium/auxiliary/util/u_debug_symbol.c | 250 ++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_debug_symbol.h | 53 ++++++ 5 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 src/gallium/auxiliary/util/u_debug_symbol.c create mode 100644 src/gallium/auxiliary/util/u_debug_symbol.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile index d68bdeadcc8..5035e9cc133 100644 --- a/src/gallium/auxiliary/util/Makefile +++ b/src/gallium/auxiliary/util/Makefile @@ -5,6 +5,8 @@ LIBNAME = util C_SOURCES = \ u_debug.c \ + u_debug_symbol.c \ + u_debug_stack.c \ u_blit.c \ u_cache.c \ u_draw_quad.c \ diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript index 0f15c632c3f..8317263bb8b 100644 --- a/src/gallium/auxiliary/util/SConscript +++ b/src/gallium/auxiliary/util/SConscript @@ -10,6 +10,7 @@ util = env.ConvenienceLibrary( 'u_debug_memory.c', 'u_debug_profile.c', 'u_debug_stack.c', + 'u_debug_symbol.c', 'u_draw_quad.c', 'u_gen_mipmap.c', 'u_handle_table.c', diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c index e5d61907c0e..e9891fde8a3 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++ b/src/gallium/auxiliary/util/u_debug_stack.c @@ -33,6 +33,7 @@ */ #include "u_debug.h" +#include "u_debug_symbol.h" #include "u_debug_stack.h" @@ -91,7 +92,7 @@ debug_backtrace_dump(const struct debug_stack_frame *backtrace, for(i = 0; i < nr_frames; ++i) { if(!backtrace[i].function) break; - debug_printf("\t%p\n", backtrace[i].function); + debug_symbol_print(backtrace[i].function); } } diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c new file mode 100644 index 00000000000..7036f6bf968 --- /dev/null +++ b/src/gallium/auxiliary/util/u_debug_symbol.c @@ -0,0 +1,250 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * @file + * Symbol lookup. + * + * @author Jose Fonseca + */ + +#include "pipe/p_compiler.h" + +#include "u_debug.h" +#include "u_debug_symbol.h" + +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) && defined(PIPE_ARCH_X86) + +#include +#include +#include + +/* + * TODO: Cleanup code. + * TODO: Support x86_64 + */ + +static BOOL bSymInitialized = FALSE; + +static HMODULE hModule_Imagehlp = NULL; + +typedef BOOL (WINAPI *PFNSYMINITIALIZE)(HANDLE, LPSTR, BOOL); +static PFNSYMINITIALIZE pfnSymInitialize = NULL; + +static +BOOL WINAPI j_SymInitialize(HANDLE hProcess, PSTR UserSearchPath, BOOL fInvadeProcess) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymInitialize || (pfnSymInitialize = (PFNSYMINITIALIZE) GetProcAddress(hModule_Imagehlp, "SymInitialize"))) + ) + return pfnSymInitialize(hProcess, UserSearchPath, fInvadeProcess); + else + return FALSE; +} + +typedef BOOL (WINAPI *PFNSYMCLEANUP)(HANDLE); +static PFNSYMCLEANUP pfnSymCleanup = NULL; + +static +BOOL WINAPI j_SymCleanup(HANDLE hProcess) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymCleanup || (pfnSymCleanup = (PFNSYMCLEANUP) GetProcAddress(hModule_Imagehlp, "SymCleanup"))) + ) + return pfnSymCleanup(hProcess); + else + return FALSE; +} + +typedef DWORD (WINAPI *PFNSYMSETOPTIONS)(DWORD); +static PFNSYMSETOPTIONS pfnSymSetOptions = NULL; + +static +DWORD WINAPI j_SymSetOptions(DWORD SymOptions) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymSetOptions || (pfnSymSetOptions = (PFNSYMSETOPTIONS) GetProcAddress(hModule_Imagehlp, "SymSetOptions"))) + ) + return pfnSymSetOptions(SymOptions); + else + return FALSE; +} + +typedef BOOL (WINAPI *PFNSYMUNDNAME)(PIMAGEHLP_SYMBOL, PSTR, DWORD); +static PFNSYMUNDNAME pfnSymUnDName = NULL; + +static +BOOL WINAPI j_SymUnDName(PIMAGEHLP_SYMBOL Symbol, PSTR UnDecName, DWORD UnDecNameLength) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymUnDName || (pfnSymUnDName = (PFNSYMUNDNAME) GetProcAddress(hModule_Imagehlp, "SymUnDName"))) + ) + return pfnSymUnDName(Symbol, UnDecName, UnDecNameLength); + else + return FALSE; +} + +typedef PFUNCTION_TABLE_ACCESS_ROUTINE PFNSYMFUNCTIONTABLEACCESS; +static PFNSYMFUNCTIONTABLEACCESS pfnSymFunctionTableAccess = NULL; + +static +PVOID WINAPI j_SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymFunctionTableAccess || (pfnSymFunctionTableAccess = (PFNSYMFUNCTIONTABLEACCESS) GetProcAddress(hModule_Imagehlp, "SymFunctionTableAccess"))) + ) + return pfnSymFunctionTableAccess(hProcess, AddrBase); + else + return NULL; +} + +typedef PGET_MODULE_BASE_ROUTINE PFNSYMGETMODULEBASE; +static PFNSYMGETMODULEBASE pfnSymGetModuleBase = NULL; + +static +DWORD WINAPI j_SymGetModuleBase(HANDLE hProcess, DWORD dwAddr) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymGetModuleBase || (pfnSymGetModuleBase = (PFNSYMGETMODULEBASE) GetProcAddress(hModule_Imagehlp, "SymGetModuleBase"))) + ) + return pfnSymGetModuleBase(hProcess, dwAddr); + else + return 0; +} + +typedef BOOL (WINAPI *PFNSTACKWALK)(DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID, PREAD_PROCESS_MEMORY_ROUTINE, PFUNCTION_TABLE_ACCESS_ROUTINE, PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE); +static PFNSTACKWALK pfnStackWalk = NULL; + +static +BOOL WINAPI j_StackWalk( + DWORD MachineType, + HANDLE hProcess, + HANDLE hThread, + LPSTACKFRAME StackFrame, + PVOID ContextRecord, + PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, + PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, + PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, + PTRANSLATE_ADDRESS_ROUTINE TranslateAddress +) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnStackWalk || (pfnStackWalk = (PFNSTACKWALK) GetProcAddress(hModule_Imagehlp, "StackWalk"))) + ) + return pfnStackWalk( + MachineType, + hProcess, + hThread, + StackFrame, + ContextRecord, + ReadMemoryRoutine, + FunctionTableAccessRoutine, + GetModuleBaseRoutine, + TranslateAddress + ); + else + return FALSE; +} + +typedef BOOL (WINAPI *PFNSYMGETSYMFROMADDR)(HANDLE, DWORD, LPDWORD, PIMAGEHLP_SYMBOL); +static PFNSYMGETSYMFROMADDR pfnSymGetSymFromAddr = NULL; + +static +BOOL WINAPI j_SymGetSymFromAddr(HANDLE hProcess, DWORD Address, PDWORD Displacement, PIMAGEHLP_SYMBOL Symbol) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymGetSymFromAddr || (pfnSymGetSymFromAddr = (PFNSYMGETSYMFROMADDR) GetProcAddress(hModule_Imagehlp, "SymGetSymFromAddr"))) + ) + return pfnSymGetSymFromAddr(hProcess, Address, Displacement, Symbol); + else + return FALSE; +} + +typedef BOOL (WINAPI *PFNSYMGETLINEFROMADDR)(HANDLE, DWORD, LPDWORD, PIMAGEHLP_LINE); +static PFNSYMGETLINEFROMADDR pfnSymGetLineFromAddr = NULL; + +static +BOOL WINAPI j_SymGetLineFromAddr(HANDLE hProcess, DWORD dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE Line) +{ + if( + (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && + (pfnSymGetLineFromAddr || (pfnSymGetLineFromAddr = (PFNSYMGETLINEFROMADDR) GetProcAddress(hModule_Imagehlp, "SymGetLineFromAddr"))) + ) + return pfnSymGetLineFromAddr(hProcess, dwAddr, pdwDisplacement, Line); + else + return FALSE; +} + + +static INLINE boolean +debug_symbol_print_imagehlp(const void *addr) +{ + HANDLE hProcess; + BYTE symbolBuffer[1024]; + PIMAGEHLP_SYMBOL pSymbol = (PIMAGEHLP_SYMBOL) symbolBuffer; + DWORD dwDisplacement = 0; // Displacement of the input address, relative to the start of the symbol + + hProcess = GetCurrentProcess(); + + pSymbol->SizeOfStruct = sizeof(symbolBuffer); + pSymbol->MaxNameLength = sizeof(symbolBuffer) - offsetof(IMAGEHLP_SYMBOL, Name); + + if(!bSymInitialized) { + j_SymSetOptions(/* SYMOPT_UNDNAME | */ SYMOPT_LOAD_LINES); + if(j_SymInitialize(hProcess, NULL, TRUE)) + bSymInitialized = TRUE; + } + + if(!j_SymGetSymFromAddr(hProcess, (DWORD)addr, &dwDisplacement, pSymbol)) + return FALSE; + + debug_printf("\t%s\n", pSymbol->Name); + + return TRUE; + +} +#endif + + +void +debug_symbol_print(const void *addr) +{ +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) + if(debug_symbol_print_imagehlp(addr)) + return; +#endif + + debug_printf("\t%p\n", addr); +} diff --git a/src/gallium/auxiliary/util/u_debug_symbol.h b/src/gallium/auxiliary/util/u_debug_symbol.h new file mode 100644 index 00000000000..021586987b6 --- /dev/null +++ b/src/gallium/auxiliary/util/u_debug_symbol.h @@ -0,0 +1,53 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef U_DEBUG_SYMBOL_H_ +#define U_DEBUG_SYMBOL_H_ + + +/** + * @file + * Symbol lookup. + * + * @author Jose Fonseca + */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +void +debug_symbol_print(const void *addr); + + +#ifdef __cplusplus +} +#endif + +#endif /* U_DEBUG_SYMBOL_H_ */ -- cgit v1.2.3 From 8d72caea3f10a26e4b11a522f4f973ce61f95127 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 1 Apr 2009 22:05:07 +0100 Subject: util: Fix x86_64 build. --- src/gallium/auxiliary/util/u_debug_symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c index 7036f6bf968..811931f81b0 100644 --- a/src/gallium/auxiliary/util/u_debug_symbol.c +++ b/src/gallium/auxiliary/util/u_debug_symbol.c @@ -241,7 +241,7 @@ debug_symbol_print_imagehlp(const void *addr) void debug_symbol_print(const void *addr) { -#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) && defined(PIPE_ARCH_X86) if(debug_symbol_print_imagehlp(addr)) return; #endif -- cgit v1.2.3 From c4fb791909e687d5af5b95d88ebd6332c82c3095 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 1 Apr 2009 15:14:19 -0700 Subject: r300-gallium: Add vertex shader for surface_copy. --- src/gallium/drivers/r300/r300_state_tcl.h | 13 ++++++++++++ src/gallium/drivers/r300/r300_surface.c | 35 +++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index bc22cd984dd..06767c9b02f 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -79,6 +79,19 @@ static struct r300_vertex_shader r300_passthrough_vertex_shader = { .instructions[1].inst3 = 0x0, }; +static struct r300_vertex_shader r300_texture_vertex_shader = { + /* XXX translate these back into normal instructions */ + .instruction_count = 2, + .instructions[0].inst0 = 0xF00203, + .instructions[0].inst1 = 0xD10001, + .instructions[0].inst2 = 0x1248001, + .instructions[0].inst3 = 0x0, + .instructions[1].inst0 = 0xF00203, + .instructions[1].inst1 = 0xD10061, + .instructions[1].inst2 = 0x1248061, + .instructions[1].inst3 = 0x0, +}; + void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs); diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 8cafe7d1045..ab0ecac35a4 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -39,17 +39,6 @@ static void r300_surface_setup(struct pipe_context* pipe, r300_emit_dsa_state(r300, &dsa_clear_state); r300_emit_rs_state(r300, &rs_clear_state); - /* XXX these magic numbers should be explained when - * this becomes a cached state object */ - if (caps->has_tcl) { - r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader); - } else { - OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | - R300_PVS_NUM_CNTLRS(5) | - R300_PVS_NUM_FPUS(caps->num_vert_fpus) | - R300_PVS_VF_MAX_VTX_NUM(12)); - } - BEGIN_CS(15); /* Pixel scissors. */ @@ -116,6 +105,18 @@ static void r300_surface_fill(struct pipe_context* pipe, r300_surface_setup(r300, dest, x, y, w, h); + /* Vertex shader setup */ + if (caps->has_tcl) { + r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader); + } else { + BEGIN_CS(2); + OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | + R300_PVS_NUM_CNTLRS(5) | + R300_PVS_NUM_FPUS(caps->num_vert_fpus) | + R300_PVS_VF_MAX_VTX_NUM(12)); + END_CS; + } + /* Fragment shader setup */ if (caps->is_r500) { r500_emit_fragment_shader(r300, &r500_passthrough_fragment_shader); @@ -222,6 +223,18 @@ static void r300_surface_copy(struct pipe_context* pipe, r300_emit_texture(r300, srctex, 0); r300_flush_textures(r300); + /* Vertex shader setup */ + if (caps->has_tcl) { + r300_emit_vertex_shader(r300, &r300_texture_vertex_shader); + } else { + BEGIN_CS(2); + OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | + R300_PVS_NUM_CNTLRS(5) | + R300_PVS_NUM_FPUS(caps->num_vert_fpus) | + R300_PVS_VF_MAX_VTX_NUM(12)); + END_CS; + } + /* Fragment shader setup */ if (caps->is_r500) { r500_emit_fragment_shader(r300, &r500_texture_fragment_shader); -- cgit v1.2.3 From 28fa809c9eb9168ab6b80fd66c7cf6ce2b9ccf98 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 1 Apr 2009 15:24:28 -0700 Subject: r300-gallium: Fix compiler warnings. "const" is the right keyword, but I can't do that without adding a bunch of really annoying and ugly const casts everywhere, and frankly, that's really stupid, so instead, just don't make them const. --- src/gallium/drivers/r300/r300_state_shader.h | 8 ++++---- src/gallium/drivers/r300/r300_surface.h | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 3c5f036d2ae..76f2989fd13 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -104,7 +104,7 @@ struct r300_fs_asm { void r300_translate_fragment_shader(struct r300_context* r300, struct r3xx_fragment_shader* fs); -static const struct r300_fragment_shader r300_passthrough_fragment_shader = { +static struct r300_fragment_shader r300_passthrough_fragment_shader = { /* XXX This is the emission code. TODO: decode OUT_CS_REG(R300_US_CONFIG, 0); OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); @@ -132,7 +132,7 @@ static const struct r300_fragment_shader r300_passthrough_fragment_shader = { R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT, }; -static const struct r500_fragment_shader r500_passthrough_fragment_shader = { +static struct r500_fragment_shader r500_passthrough_fragment_shader = { .shader.stack_size = 0, .instruction_count = 1, .instructions[0].inst0 = R500_INST_TYPE_OUT | @@ -158,7 +158,7 @@ static const struct r500_fragment_shader r500_passthrough_fragment_shader = { R500_ALU_RGBA_A_SWIZ_0, }; -static const struct r300_fragment_shader r300_texture_fragment_shader = { +static struct r300_fragment_shader r300_texture_fragment_shader = { /* XXX This is the emission code. TODO: decode OUT_CS_REG(R300_US_CONFIG, 0); OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); @@ -186,7 +186,7 @@ static const struct r300_fragment_shader r300_texture_fragment_shader = { R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT, }; -static const struct r500_fragment_shader r500_texture_fragment_shader = { +static struct r500_fragment_shader r500_texture_fragment_shader = { .shader.stack_size = 0, .instruction_count = 1, .instructions[0].inst0 = R500_INST_TYPE_OUT | diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h index aa34054326c..36090882f13 100644 --- a/src/gallium/drivers/r300/r300_surface.h +++ b/src/gallium/drivers/r300/r300_surface.h @@ -35,20 +35,20 @@ #include "r300_state_tcl.h" #include "r300_state_inlines.h" -const struct r300_blend_state blend_clear_state = { +static struct r300_blend_state blend_clear_state = { .blend_control = 0x0, .alpha_blend_control = 0x0, .rop = 0x0, .dither = 0x0, }; -const struct r300_blend_color_state blend_color_clear_state = { +static struct r300_blend_color_state blend_color_clear_state = { .blend_color = 0x0, .blend_color_red_alpha = 0x0, .blend_color_green_blue = 0x0, }; -const struct r300_dsa_state dsa_clear_state = { +static struct r300_dsa_state dsa_clear_state = { .alpha_function = 0x0, .alpha_reference = 0x0, .z_buffer_control = 0x0, @@ -58,7 +58,7 @@ const struct r300_dsa_state dsa_clear_state = { .stencil_ref_bf = 0x0, }; -const struct r300_rs_state rs_clear_state = { +static struct r300_rs_state rs_clear_state = { .point_minmax = 0x36000006, .line_control = 0x00030006, .depth_scale_front = 0x0, @@ -72,7 +72,7 @@ const struct r300_rs_state rs_clear_state = { .color_control = R300_SHADE_MODEL_FLAT, }; -const struct r300_rs_block r300_rs_block_clear_state = { +static struct r300_rs_block r300_rs_block_clear_state = { .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) | R500_RS_SEL_T(R300_RS_SEL_K0) | R500_RS_SEL_R(R300_RS_SEL_K0) | @@ -82,7 +82,7 @@ const struct r300_rs_block r300_rs_block_clear_state = { .inst_count = 0, }; -const struct r300_rs_block r500_rs_block_clear_state = { +static struct r300_rs_block r500_rs_block_clear_state = { .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) | R500_RS_SEL_T(R500_RS_IP_PTR_K0) | R500_RS_SEL_R(R500_RS_IP_PTR_K0) | @@ -94,7 +94,7 @@ const struct r300_rs_block r500_rs_block_clear_state = { /* The following state is used for surface_copy only. */ -const struct r300_rs_block r300_rs_block_copy_state = { +static struct r300_rs_block r300_rs_block_copy_state = { .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) | R500_RS_SEL_T(R300_RS_SEL_K0) | R500_RS_SEL_R(R300_RS_SEL_K0) | @@ -104,7 +104,7 @@ const struct r300_rs_block r300_rs_block_copy_state = { .inst_count = R300_RS_TX_OFFSET(6), }; -const struct r300_rs_block r500_rs_block_copy_state = { +static struct r300_rs_block r500_rs_block_copy_state = { .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) | R500_RS_SEL_T(R500_RS_IP_PTR_K0) | R500_RS_SEL_R(R500_RS_IP_PTR_K0) | @@ -114,7 +114,7 @@ const struct r300_rs_block r500_rs_block_copy_state = { .inst_count = R300_RS_TX_OFFSET(6), }; -const struct r300_sampler_state r300_sampler_copy_state = { +static struct r300_sampler_state r300_sampler_copy_state = { .filter0 = R300_TX_WRAP_S(R300_TX_CLAMP) | R300_TX_WRAP_T(R300_TX_CLAMP) | R300_TX_MAG_FILTER_NEAREST | -- cgit v1.2.3 From 935e6b19245542d177ab26ced416dd665a79048d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 1 Apr 2009 15:52:32 -0700 Subject: r300-gallium: Translate vertex shader magic numbers. --- src/gallium/drivers/r300/r300_state_tcl.h | 64 ++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index 06767c9b02f..b947f0d1cf6 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -41,7 +41,33 @@ # define R300_PVS_DST_REG_ALT_TEMPORARY 4 # define R300_PVS_DST_REG_INPUT 5 #define R300_PVS_DST_OFFSET(x) ((x) << 13) -#define R300_PVS_DST_WE_SHIFT 20 +#define R300_PVS_DST_WE(x) ((x) << 20) +#define R300_PVS_DST_WE_XYZW (0xf << 20) + +#define R300_PVS_SRC_REG_TYPE(x) ((x) << 0) +# define R300_PVS_SRC_REG_TEMPORARY 0 +# define R300_PVS_SRC_REG_INPUT 1 +# define R300_PVS_SRC_REG_CONSTANT 2 +# define R300_PVS_SRC_REG_ALT_TEMPORARY 3 +#define R300_PVS_SRC_OFFSET(x) ((x) << 5) +#define R300_PVS_SRC_SWIZZLE(x) ((x) << 13) +# define R300_PVS_SRC_SELECT_X 0 +# define R300_PVS_SRC_SELECT_Y 1 +# define R300_PVS_SRC_SELECT_Z 2 +# define R300_PVS_SRC_SELECT_W 3 +# define R300_PVS_SRC_SELECT_FORCE_0 4 +# define R300_PVS_SRC_SELECT_FORCE_1 5 +# define R300_PVS_SRC_SWIZZLE_XYZW \ + ((R300_PVS_SRC_SELECT_X | (R300_PVS_SRC_SELECT_Y << 3) | \ + (R300_PVS_SRC_SELECT_Z << 6) | (R300_PVS_SRC_SELECT_W << 9)) << 13) +# define R300_PVS_SRC_SWIZZLE_ZERO \ + ((R300_PVS_SRC_SELECT_FORCE_0 | (R300_PVS_SRC_SELECT_FORCE_0 << 3) | \ + (R300_PVS_SRC_SELECT_FORCE_0 << 6) | \ + (R300_PVS_SRC_SELECT_FORCE_0 << 9)) << 13) +# define R300_PVS_SRC_SWIZZLE_ONE \ + ((R300_PVS_SRC_SELECT_FORCE_1 | (R300_PVS_SRC_SELECT_FORCE_1 << 3) | \ + (R300_PVS_SRC_SELECT_FORCE_1 << 6) | \ + (R300_PVS_SRC_SELECT_FORCE_1 << 9)) << 13) /* Temporary struct used to hold assembly state while putting together * fragment programs. */ @@ -69,26 +95,38 @@ struct r300_vs_asm { static struct r300_vertex_shader r300_passthrough_vertex_shader = { /* XXX translate these back into normal instructions */ .instruction_count = 2, - .instructions[0].inst0 = 0xF00203, - .instructions[0].inst1 = 0xD10001, - .instructions[0].inst2 = 0x1248001, + .instructions[0].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | + R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | + R300_PVS_DST_OFFSET(0) | R300_PVS_DST_WE_XYZW, + .instructions[0].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | + R300_PVS_SRC_OFFSET(0) | R300_PVS_SRC_SWIZZLE_XYZW, + .instructions[0].inst2 = R300_PVS_SRC_SWIZZLE_ZERO, .instructions[0].inst3 = 0x0, - .instructions[1].inst0 = 0xF00203, - .instructions[1].inst1 = 0xD10021, - .instructions[1].inst2 = 0x1248021, + .instructions[1].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | + R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | + R300_PVS_DST_OFFSET(2) | R300_PVS_DST_WE_XYZW, + .instructions[1].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | + R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW, + .instructions[1].inst2 = R300_PVS_SRC_SWIZZLE_ZERO, .instructions[1].inst3 = 0x0, }; static struct r300_vertex_shader r300_texture_vertex_shader = { /* XXX translate these back into normal instructions */ .instruction_count = 2, - .instructions[0].inst0 = 0xF00203, - .instructions[0].inst1 = 0xD10001, - .instructions[0].inst2 = 0x1248001, + .instructions[0].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | + R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | + R300_PVS_DST_OFFSET(0) | R300_PVS_DST_WE_XYZW, + .instructions[0].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | + R300_PVS_SRC_OFFSET(0) | R300_PVS_SRC_SWIZZLE_XYZW, + .instructions[0].inst2 = R300_PVS_SRC_SWIZZLE_ZERO, .instructions[0].inst3 = 0x0, - .instructions[1].inst0 = 0xF00203, - .instructions[1].inst1 = 0xD10061, - .instructions[1].inst2 = 0x1248061, + .instructions[1].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | + R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | + R300_PVS_DST_OFFSET(6) | R300_PVS_DST_WE_XYZW, + .instructions[1].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | + R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW, + .instructions[1].inst2 = R300_PVS_SRC_SWIZZLE_ZERO, .instructions[1].inst3 = 0x0, }; -- cgit v1.2.3 From 336a4f84e87908692a8c9424f6f5d27dca30ea95 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 2 Apr 2009 09:39:40 +0200 Subject: python/regress: Add more vertex shader test cases. --- .../python/tests/regress/vertex-shader/vert-lg2.sh | 18 ++++++++++++++++++ .../python/tests/regress/vertex-shader/vert-lit.sh | 11 +++++++++++ .../python/tests/regress/vertex-shader/vert-mad.sh | 14 ++++++++++++++ .../python/tests/regress/vertex-shader/vert-max.sh | 13 +++++++++++++ .../python/tests/regress/vertex-shader/vert-min.sh | 13 +++++++++++++ .../python/tests/regress/vertex-shader/vert-rcp.sh | 18 ++++++++++++++++++ .../python/tests/regress/vertex-shader/vert-rsq.sh | 18 ++++++++++++++++++ .../python/tests/regress/vertex-shader/vert-sge.sh | 16 ++++++++++++++++ .../python/tests/regress/vertex-shader/vert-slt.sh | 16 ++++++++++++++++ .../tests/regress/vertex-shader/vertex-shader.py | 9 +++++++++ 10 files changed, 146 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lg2.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lit.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mad.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-max.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-min.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rcp.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rsq.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sge.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-slt.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lg2.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lg2.sh new file mode 100644 index 00000000000..f6e08d087c1 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lg2.sh @@ -0,0 +1,18 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } +IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +LG2 TEMP[0].x, TEMP[0].xxxx +ADD OUT[0], TEMP[0], IMM[1] +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lit.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lit.sh new file mode 100644 index 00000000000..da98f30928e --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-lit.sh @@ -0,0 +1,11 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +MOV OUT[0], IN[0] +LIT OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mad.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mad.sh new file mode 100644 index 00000000000..eb07a3bd565 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-mad.sh @@ -0,0 +1,14 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +IMM FLT32 { 0.5, 1.0, 1.0, 1.0 } +IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } + +MAD OUT[0], IN[0], IMM[0], IMM[1] +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-max.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-max.sh new file mode 100644 index 00000000000..2d8b1fe3bfb --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-max.sh @@ -0,0 +1,13 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +IMM FLT32 { 0.5, 0.5, 0.5, 0.0 } + +MOV OUT[0], IN[0] +MAX OUT[1], IN[1], IMM[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-min.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-min.sh new file mode 100644 index 00000000000..84af0e29051 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-min.sh @@ -0,0 +1,13 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +IMM FLT32 { 0.5, 0.5, 0.5, 0.0 } + +MOV OUT[0], IN[0] +MIN OUT[1], IN[1], IMM[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rcp.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rcp.sh new file mode 100644 index 00000000000..78af589b5c0 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rcp.sh @@ -0,0 +1,18 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } +IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +RCP TEMP[0].x, TEMP[0].xxxx +SUB OUT[0], TEMP[0], IMM[1] +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rsq.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rsq.sh new file mode 100644 index 00000000000..1675c7d5ff1 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-rsq.sh @@ -0,0 +1,18 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } +IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +RSQ TEMP[0].x, TEMP[0].xxxx +SUB OUT[0], TEMP[0], IMM[1] +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sge.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sge.sh new file mode 100644 index 00000000000..3d92cd5aaeb --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-sge.sh @@ -0,0 +1,16 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +IMM FLT32 { -0.1, -0.1, 1.0, 0.0 } + +SGE TEMP[0], IN[0], IMM[0] +MOV OUT[0], IN[0] +MUL OUT[1], IN[1], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-slt.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-slt.sh new file mode 100644 index 00000000000..85c60ff4ec8 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-slt.sh @@ -0,0 +1,16 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +IMM FLT32 { 0.6, 0.6, 0.0, 0.0 } + +SLT TEMP[0], IN[0], IMM[0] +MOV OUT[0], IN[0] +MUL OUT[1], IN[1], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 97f6240dec5..196fcc2d983 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -218,9 +218,18 @@ def main(): 'dst', 'ex2', 'frc', + 'lg2', + 'lit', 'lrp', + 'mad', + 'max', + 'min', 'mov', 'mul', + 'rcp', + 'rsq', + 'sge', + 'slt', 'sub', 'xpd', ] -- cgit v1.2.3 From fbabeb9b56d2e4691ae39339a805d24e860603bb Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 2 Apr 2009 09:59:04 +0200 Subject: python/regress: Do not create zbuf for vertex shader test. --- .../python/tests/regress/vertex-shader/vertex-shader.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 196fcc2d983..362dec3b9cd 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -59,7 +59,7 @@ def test(dev, name): # depth/stencil/alpha depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 1 + depth_stencil_alpha.depth.enabled = 0 depth_stencil_alpha.depth.writemask = 1 depth_stencil_alpha.depth.func = PIPE_FUNC_LESS ctx.set_depth_stencil_alpha(depth_stencil_alpha) @@ -116,20 +116,13 @@ def test(dev, name): width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() - zbuf = dev.texture_create( - PIPE_FORMAT_Z32_UNORM, - width, height, - tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL, - ).get_surface() fb = Framebuffer() fb.width = width fb.height = height fb.nr_cbufs = 1 fb.set_cbuf(0, cbuf) - fb.set_zsbuf(zbuf) ctx.set_framebuffer(fb) ctx.surface_clear(cbuf, 0x80808080) - ctx.surface_clear(zbuf, 0xffffffff) # vertex shader vs = Shader(file('vert-' + name + '.sh', 'rt').read()) -- cgit v1.2.3 From 39c2fae657b35be043a002a87da574928e06fac1 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 2 Apr 2009 12:19:44 +0200 Subject: python/regress: Do not generate HTML summary for vertex shader test. --- .../python/tests/regress/vertex-shader/vertex-shader.py | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 362dec3b9cd..4a326faa88e 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -226,25 +226,10 @@ def main(): 'sub', 'xpd', ] - - html = ''' - - - - -
    -

    regression tests for vertex shader

    - -''' dev = Device() for t in tests: test(dev, t) - html += '' - html += '\n' - - html += '
    ' + t + '
    \n\n\n' - file('vertex-shader.htm', 'wt').write(html) if __name__ == '__main__': main() -- cgit v1.2.3 From 030533dd10b3b30ed5b132fe59f89040ce56e3a0 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Wed, 1 Apr 2009 08:37:36 +1000 Subject: nv50: fix viewport state update --- src/gallium/drivers/nv50/nv50_state_validate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index fc6157dbd09..c13d3de1cb9 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -244,7 +244,7 @@ nv50_state_validate(struct nv50_context *nv50) } scissor_uptodate: - if (nv50->dirty & NV50_NEW_VIEWPORT) { + if (nv50->dirty & (NV50_NEW_VIEWPORT | NV50_NEW_RASTERIZER)) { unsigned bypass; if (!nv50->rasterizer->pipe.bypass_vs_clip_and_viewport) @@ -281,6 +281,7 @@ scissor_uptodate: so_ref(so, &nv50->state.viewport); so_ref(NULL, &so); + nv50->state.dirty |= NV50_NEW_VIEWPORT; } viewport_uptodate: -- cgit v1.2.3 From 016052c18ff6f7ea7f4cf0e7e93c796688f772ed Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 08:26:53 +0200 Subject: python/regress: Add vertex shader source modifier tests. --- .../tests/regress/vertex-shader/vert-srcmod-abs.sh | 15 +++++++++++++++ .../tests/regress/vertex-shader/vert-srcmod-absneg.sh | 16 ++++++++++++++++ .../tests/regress/vertex-shader/vert-srcmod-neg.sh | 12 ++++++++++++ .../tests/regress/vertex-shader/vert-srcmod-swz.sh | 12 ++++++++++++ .../python/tests/regress/vertex-shader/vertex-shader.py | 4 ++++ 5 files changed, 59 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-abs.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-neg.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-abs.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-abs.sh new file mode 100644 index 00000000000..6db417a62e5 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-abs.sh @@ -0,0 +1,15 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] + +IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +MOV OUT[0], |TEMP[0]| +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh new file mode 100644 index 00000000000..fc832380520 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh @@ -0,0 +1,16 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] + +IMM FLT32 { -0.2, -0.2, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +MOV OUT[0].xy, -|TEMP[0]| +MOV OUT[0].zw, IN[0] +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-neg.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-neg.sh new file mode 100644 index 00000000000..ce4e90b5e10 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-neg.sh @@ -0,0 +1,12 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +MOV OUT[0].xy, -IN[0] +MOV OUT[0].zw, IN[0] +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh new file mode 100644 index 00000000000..7617b6d5200 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh @@ -0,0 +1,12 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL TEMP[0] + +MOV OUT[0], IN[0].yxzw +MOV OUT[1], IN[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 4a326faa88e..7fc5f5ec514 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -223,6 +223,10 @@ def main(): 'rsq', 'sge', 'slt', + 'srcmod-abs', + 'srcmod-absneg', + 'srcmod-neg', + 'srcmod-swz', 'sub', 'xpd', ] -- cgit v1.2.3 From cc770e0a0cbb2c0ff4327ffb0bf20f52ccc218cc Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 14:54:20 +0200 Subject: tgsi/text: Allow `-|src|` variant of `-(|src|)`. --- src/gallium/auxiliary/tgsi/tgsi_text.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index fdaee9b060b..bb1c7dc6ccf 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -562,6 +562,7 @@ parse_src_operand( uint ind_file; int ind_index; uint swizzle[4]; + boolean parsed_ext_negate_paren = FALSE; boolean parsed_swizzle; boolean parsed_extswizzle; @@ -574,10 +575,17 @@ parse_src_operand( src->SrcRegisterExtMod.Negate = 1; eat_opt_white( &cur ); ctx->cur = cur; + parsed_ext_negate_paren = TRUE; + } + else if (*cur == '|') { + cur++; + src->SrcRegisterExtMod.Negate = 1; + src->SrcRegisterExtMod.Absolute = 1; + eat_opt_white(&cur); + ctx->cur = cur; } } - - if (*ctx->cur == '|') { + else if (*ctx->cur == '|') { ctx->cur++; eat_opt_white( &ctx->cur ); src->SrcRegisterExtMod.Absolute = 1; @@ -715,7 +723,7 @@ parse_src_operand( ctx->cur++; } - if (src->SrcRegisterExtMod.Negate) { + if (parsed_ext_negate_paren) { eat_opt_white( &ctx->cur ); if (*ctx->cur != ')') { report_error( ctx, "Expected `)'" ); -- cgit v1.2.3 From d2ed91201e1abcc61e30b367c00c6e0f036d9214 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 14:58:39 +0200 Subject: util/debug: Initialise local variables. --- src/gallium/auxiliary/util/u_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 1b984425b59..96a2222f9b6 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -720,8 +720,8 @@ debug_dump_surface_bmp(const char *filename, struct pipe_surface *surface) { struct pipe_transfer *transfer; - struct pipe_texture *texture; - struct pipe_screen *screen; + struct pipe_texture *texture = surface->texture; + struct pipe_screen *screen = texture->screen; transfer = screen->get_tex_transfer(screen, texture, surface->face, surface->level, surface->zslice, -- cgit v1.2.3 From 37661516ea3862ac4c94d8bcf5064bbb95f31aea Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 16:36:20 +0200 Subject: python/regress: Add relative addressing tests. --- .../python/tests/regress/vertex-shader/vert-arl.sh | 23 ++++++++++++++++++++++ .../python/tests/regress/vertex-shader/vert-arr.sh | 23 ++++++++++++++++++++++ .../python/tests/regress/vertex-shader/vert-flr.sh | 23 ++++++++++++++++++++++ .../tests/regress/vertex-shader/vertex-shader.py | 3 +++ 4 files changed, 72 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arl.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arr.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-flr.sh (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arl.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arl.sh new file mode 100644 index 00000000000..7638e96346e --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arl.sh @@ -0,0 +1,23 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +DCL ADDR[0] + +IMM FLT32 { 3.0, 1.0, 1.0, 1.0 } +IMM FLT32 { 1.0, 0.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 1.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +IMM FLT32 { 1.0, 1.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 1.0, 1.0, 1.0 } + +MOV OUT[0], IN[0] +MUL TEMP[0], IN[0], IMM[0] +ARL ADDR[0].x, TEMP[0] +MOV OUT[1], IMM[ADDR[0].x + 3] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arr.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arr.sh new file mode 100644 index 00000000000..28ce6f9a0cf --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-arr.sh @@ -0,0 +1,23 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +DCL ADDR[0] + +IMM FLT32 { 3.0, 1.0, 1.0, 1.0 } +IMM FLT32 { 1.0, 0.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 1.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +IMM FLT32 { 1.0, 1.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 1.0, 1.0, 1.0 } + +MOV OUT[0], IN[0] +MUL TEMP[0], IN[0], IMM[0] +ARR ADDR[0].x, TEMP[0] +MOV OUT[1], IMM[ADDR[0].x + 3] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-flr.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-flr.sh new file mode 100644 index 00000000000..44ad708119d --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-flr.sh @@ -0,0 +1,23 @@ +VERT1.1 + +DCL IN[0], POSITION +DCL OUT[0], POSITION +DCL OUT[1], COLOR + +DCL TEMP[0] + +DCL ADDR[0] + +IMM FLT32 { 3.0, 1.0, 1.0, 1.0 } +IMM FLT32 { 1.0, 0.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 1.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } +IMM FLT32 { 1.0, 1.0, 0.0, 1.0 } +IMM FLT32 { 0.0, 1.0, 1.0, 1.0 } + +MOV OUT[0], IN[0] +MUL TEMP[0], IN[0], IMM[0] +FLR ADDR[0].x, TEMP[0] +MOV OUT[1], IMM[ADDR[0].x + 3] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 7fc5f5ec514..6a927f59575 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -206,10 +206,13 @@ def main(): tests = [ 'abs', 'add', + 'arl', + 'arr', 'dp3', 'dp4', 'dst', 'ex2', + 'flr', 'frc', 'lg2', 'lit', -- cgit v1.2.3 From 3b7c9a9a1633fcd6930d7b8c7ed962add2be3dd8 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 16:37:34 +0200 Subject: python/regress: vertex shader FRC test does not use IN[1]. --- .../state_trackers/python/tests/regress/vertex-shader/vert-frc.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh index 91c0f9c70dd..d179749de84 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-frc.sh @@ -1,7 +1,6 @@ VERT1.1 DCL IN[0], POSITION -DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR -- cgit v1.2.3 From dfab375c07545a9068a9b25efee746efd275bf89 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 17:06:36 +0200 Subject: tgsi/text: Allow optional component selection for indirect registers. --- src/gallium/auxiliary/tgsi/tgsi_text.c | 43 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index bb1c7dc6ccf..a40fcab2126 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -358,9 +358,9 @@ parse_register_dst( /* Parse source register operand. * ::= `]' | - * `]' | - * `+' `]' | - * `-' `]' + * [`.' (`x' | `y' | `z' | `w')] `]' | + * [`.' (`x' | `y' | `z' | `w')] `+' `]' | + * [`.' (`x' | `y' | `z' | `w')] `-' `]' */ static boolean parse_register_src( @@ -368,11 +368,13 @@ parse_register_src( uint *file, int *index, uint *ind_file, - int *ind_index ) + int *ind_index, + uint *ind_comp) { const char *cur; uint uindex; + *ind_comp = TGSI_SWIZZLE_X; if (!parse_register_file_bracket( ctx, file )) return FALSE; eat_opt_white( &ctx->cur ); @@ -381,6 +383,32 @@ parse_register_src( if (!parse_register_dst( ctx, ind_file, ind_index )) return FALSE; eat_opt_white( &ctx->cur ); + + if (*ctx->cur == '.') { + ctx->cur++; + eat_opt_white(&ctx->cur); + + switch (uprcase(*ctx->cur)) { + case 'X': + *ind_comp = TGSI_SWIZZLE_X; + break; + case 'Y': + *ind_comp = TGSI_SWIZZLE_Y; + break; + case 'Z': + *ind_comp = TGSI_SWIZZLE_Z; + break; + case 'W': + *ind_comp = TGSI_SWIZZLE_W; + break; + default: + report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'"); + return FALSE; + } + ctx->cur++; + eat_opt_white(&ctx->cur); + } + if (*ctx->cur == '+' || *ctx->cur == '-') { boolean negate; @@ -561,6 +589,7 @@ parse_src_operand( int index; uint ind_file; int ind_index; + uint ind_comp; uint swizzle[4]; boolean parsed_ext_negate_paren = FALSE; boolean parsed_swizzle; @@ -643,7 +672,7 @@ parse_src_operand( } } - if (!parse_register_src( ctx, &file, &index, &ind_file, &ind_index )) + if (!parse_register_src(ctx, &file, &index, &ind_file, &ind_index, &ind_comp)) return FALSE; src->SrcRegister.File = file; src->SrcRegister.Index = index; @@ -651,6 +680,10 @@ parse_src_operand( src->SrcRegister.Indirect = 1; src->SrcRegisterInd.File = ind_file; src->SrcRegisterInd.Index = ind_index; + src->SrcRegisterInd.SwizzleX = ind_comp; + src->SrcRegisterInd.SwizzleY = ind_comp; + src->SrcRegisterInd.SwizzleZ = ind_comp; + src->SrcRegisterInd.SwizzleW = ind_comp; } /* Parse optional swizzle. -- cgit v1.2.3 From e3d5e0aead06dc066f3df4bb5a0c8f30bef55248 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 17:25:29 +0200 Subject: tgsi/exec: Actually enable switch-case for FLR. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 80b8c92445a..e8bd7cda3b1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1904,7 +1904,7 @@ exec_instruction( switch (inst->Instruction.Opcode) { case TGSI_OPCODE_ARL: - /* TGSI_OPCODE_FLOOR */ + case TGSI_OPCODE_FLOOR: /* TGSI_OPCODE_FLR */ FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( &r[0], 0, chan_index ); -- cgit v1.2.3 From be4c2d9a335aa38418000dd55845cea39c84261f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 17:55:21 +0200 Subject: python/regress: vertex shader srcmod swz test does not use TEMP[0]. --- .../state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh index 7617b6d5200..c03de4c674e 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-srcmod-swz.sh @@ -4,7 +4,6 @@ DCL IN[0], POSITION DCL IN[1], COLOR DCL OUT[0], POSITION DCL OUT[1], COLOR -DCL TEMP[0] MOV OUT[0], IN[0].yxzw MOV OUT[1], IN[1] -- cgit v1.2.3 From a7b6a28b0c2bac9cbafb193923e3bc84855369d3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 3 Apr 2009 18:53:16 +0200 Subject: python/regress: Use A8R8G8B8 rendertarget format. --- .../state_trackers/python/tests/regress/vertex-shader/vertex-shader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 6a927f59575..99fe7877389 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -112,7 +112,7 @@ def test(dev, name): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_A8R8G8B8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() -- cgit v1.2.3 From 5d3b1494b699184ba9363ee199490104048e9a2c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 3 Apr 2009 15:43:13 -0600 Subject: softpipe: add additional surface formats in tile cache code --- src/gallium/drivers/softpipe/sp_tile_cache.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 69292753f13..fd1097f41c9 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -608,18 +608,21 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue) switch (tc->transfer->format) { case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8X8_UNORM: r = (clearValue >> 24) & 0xff; g = (clearValue >> 16) & 0xff; b = (clearValue >> 8) & 0xff; a = (clearValue ) & 0xff; break; case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: r = (clearValue >> 16) & 0xff; g = (clearValue >> 8) & 0xff; b = (clearValue ) & 0xff; a = (clearValue >> 24) & 0xff; break; case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: r = (clearValue >> 8) & 0xff; g = (clearValue >> 16) & 0xff; b = (clearValue >> 24) & 0xff; -- cgit v1.2.3 From a7dc04fa73f9879d94ab4abf8fcd6f38ee2e9531 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 00:29:56 -0700 Subject: r300-gallium: r500 surface_copy fragment shader. --- src/gallium/drivers/r300/r300_state_shader.h | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 76f2989fd13..185fdd90f0c 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -187,26 +187,41 @@ static struct r300_fragment_shader r300_texture_fragment_shader = { }; static struct r500_fragment_shader r500_texture_fragment_shader = { - .shader.stack_size = 0, - .instruction_count = 1, - .instructions[0].inst0 = R500_INST_TYPE_OUT | + .shader.stack_size = 1, + .instruction_count = 2, + .instructions[0].inst0 = R500_INST_TYPE_TEX | + R500_INST_TEX_SEM_WAIT | + R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK | + R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, + .instructions[0].inst1 = R500_TEX_ID(0) | R500_TEX_INST_LD | + R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED, + .instructions[0].inst2 = R500_TEX_SRC_ADDR(0) | + R500_TEX_SRC_S_SWIZ_R | R500_TEX_SRC_T_SWIZ_G | + R500_TEX_SRC_R_SWIZ_B | R500_TEX_SRC_Q_SWIZ_A | + R500_TEX_DST_ADDR(0) | + R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G | + R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A, + .instructions[0].inst3 = 0x0, + .instructions[0].inst4 = 0x0, + .instructions[0].inst5 = 0x0, + .instructions[1].inst0 = R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT | R500_INST_LAST | R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK | R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, - .instructions[0].inst1 = + .instructions[1].inst1 = R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST | R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST, - .instructions[0].inst2 = + .instructions[1].inst2 = R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST | R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST, - .instructions[0].inst3 = + .instructions[1].inst3 = R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R | R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B | R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R | R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B, - .instructions[0].inst4 = + .instructions[1].inst4 = R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A, - .instructions[0].inst5 = + .instructions[1].inst5 = R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 | R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 | R500_ALU_RGBA_A_SWIZ_0, -- cgit v1.2.3 From be1dbba0a4d0d75468461aff8c281a512a537ecc Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 00:31:49 -0700 Subject: r300-gallium: Clean up compile warnings and strict compile errors. --- src/gallium/drivers/r300/r300_emit.c | 20 +++++++++----------- src/gallium/drivers/r300/r300_query.c | 8 ++++---- src/gallium/drivers/r300/r300_state.c | 1 + src/gallium/drivers/r300/r300_surface.c | 12 ++++++------ src/gallium/drivers/r300/r300_surface.h | 6 +++--- 5 files changed, 23 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 989fba74df0..0ee32334460 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -82,8 +82,8 @@ void r300_emit_dsa_state(struct r300_context* r300, void r300_emit_fragment_shader(struct r300_context* r300, struct r300_fragment_shader* fs) { - CS_LOCALS(r300); int i; + CS_LOCALS(r300); BEGIN_CS(22); @@ -114,10 +114,10 @@ void r300_emit_fragment_shader(struct r300_context* r300, void r500_emit_fragment_shader(struct r300_context* r300, struct r500_fragment_shader* fs) { - CS_LOCALS(r300); + int i; struct r300_constant_buffer* constants = &r300->shader_constants[PIPE_SHADER_FRAGMENT]; - int i; + CS_LOCALS(r300); BEGIN_CS(9 + (fs->instruction_count * 6) + (constants->count ? 3 : 0) + (constants->count * 4)); @@ -156,9 +156,9 @@ void r500_emit_fragment_shader(struct r300_context* r300, void r300_emit_fb_state(struct r300_context* r300, struct pipe_framebuffer_state* fb) { - CS_LOCALS(r300); - struct r300_texture* tex; int i; + struct r300_texture* tex; + CS_LOCALS(r300); BEGIN_CS((6 * fb->nr_cbufs) + (fb->zsbuf ? 6 : 0) + 4); for (i = 0; i < fb->nr_cbufs; i++) { @@ -217,9 +217,9 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs) void r300_emit_rs_block_state(struct r300_context* r300, struct r300_rs_block* rs) { + int i; struct r300_screen* r300screen = r300_screen(r300->context.screen); CS_LOCALS(r300); - int i; BEGIN_CS(21); if (r300screen->caps->is_r500) { @@ -293,8 +293,8 @@ void r300_emit_texture(struct r300_context* r300, void r300_emit_vertex_format_state(struct r300_context* r300) { - CS_LOCALS(r300); int i; + CS_LOCALS(r300); BEGIN_CS(26); OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info.vinfo.size); @@ -328,9 +328,9 @@ void r300_emit_vertex_format_state(struct r300_context* r300) void r300_emit_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs) { - CS_LOCALS(r300); - struct r300_screen* r300screen = r300_screen(r300->context.screen); int i; + struct r300_screen* r300screen = r300_screen(r300->context.screen); + CS_LOCALS(r300); if (!r300screen->caps->has_tcl) { debug_printf("r300: Implementation error: emit_vertex_shader called," @@ -368,8 +368,6 @@ void r300_emit_vertex_shader(struct r300_context* r300, void r300_emit_viewport_state(struct r300_context* r300, struct r300_viewport_state* viewport) { - /* XXX has_tcl */ - return; CS_LOCALS(r300); BEGIN_CS(7); diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 5f5f4c4dbd4..8fc61c2dec7 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -46,12 +46,12 @@ static void r300_destroy_query(struct pipe_context* pipe, static void r300_begin_query(struct pipe_context* pipe, struct pipe_query* query) { + uint32_t* map; struct r300_context* r300 = r300_context(pipe); struct r300_query* q = (struct r300_query*)query; CS_LOCALS(r300); - uint32_t* map = pipe_buffer_map(pipe->screen, q->buf, - PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pipe->screen, q->buf, PIPE_BUFFER_USAGE_CPU_WRITE); *map = ~0; pipe_buffer_unmap(pipe->screen, q->buf); @@ -79,6 +79,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe, uint64_t* result) { struct r300_query* q = (struct r300_query*)query; + uint32_t* map; uint32_t temp; if (wait) { @@ -88,8 +89,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe, pipe->flush(pipe, 0, NULL); } - uint32_t* map = pipe_buffer_map(pipe->screen, q->buf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe->screen, q->buf, PIPE_BUFFER_USAGE_CPU_READ); temp = *map; pipe_buffer_unmap(pipe->screen, q->buf); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index c9a20c9e8ac..b1d85260cc1 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -593,6 +593,7 @@ static void* r300_create_vs_state(struct pipe_context* pipe, const struct pipe_shader_state* state) { struct r300_context* context = r300_context(pipe); + tgsi_dump(state->tokens); /* XXX handing this off to Draw for now */ return draw_create_vertex_shader(context->draw, state); } diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index ab0ecac35a4..dc4b29eb40a 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -29,10 +29,10 @@ static void r300_surface_setup(struct pipe_context* pipe, unsigned w, unsigned h) { struct r300_context* r300 = r300_context(pipe); - CS_LOCALS(r300); struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* tex = (struct r300_texture*)dest->texture; unsigned pixpitch = tex->stride / tex->tex.block.size; + CS_LOCALS(r300); r300_emit_blend_state(r300, &blend_clear_state); r300_emit_blend_color_state(r300, &blend_color_clear_state); @@ -80,13 +80,13 @@ static void r300_surface_fill(struct pipe_context* pipe, unsigned w, unsigned h, unsigned color) { + int i; + float r, g, b, a, depth; struct r300_context* r300 = r300_context(pipe); - CS_LOCALS(r300); struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* tex = (struct r300_texture*)dest->texture; - int i; - float r, g, b, a, depth; unsigned pixpitch = tex->stride / tex->tex.block.size; + CS_LOCALS(r300); a = (float)((color >> 24) & 0xff) / 255.0f; r = (float)((color >> 16) & 0xff) / 255.0f; @@ -201,12 +201,12 @@ static void r300_surface_copy(struct pipe_context* pipe, unsigned w, unsigned h) { struct r300_context* r300 = r300_context(pipe); - CS_LOCALS(r300); struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* srctex = (struct r300_texture*)src->texture; struct r300_texture* desttex = (struct r300_texture*)dest->texture; - unsigned pixpitch = srctex->stride / srctex->tex.block.size; + CS_LOCALS(r300); + debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d)," " dimensions %dx%d (pixel pitch %d)\n", src, srcx, srcy, dest, destx, desty, w, h, pixpitch); diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h index 36090882f13..894def07aa8 100644 --- a/src/gallium/drivers/r300/r300_surface.h +++ b/src/gallium/drivers/r300/r300_surface.h @@ -105,11 +105,11 @@ static struct r300_rs_block r300_rs_block_copy_state = { }; static struct r300_rs_block r500_rs_block_copy_state = { - .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) | - R500_RS_SEL_T(R500_RS_IP_PTR_K0) | + .ip[0] = R500_RS_SEL_S(0) | + R500_RS_SEL_T(1) | R500_RS_SEL_R(R500_RS_IP_PTR_K0) | R500_RS_SEL_Q(R500_RS_IP_PTR_K1), - .inst[0] = R500_RS_INST_COL_CN_WRITE, + .inst[0] = R500_RS_INST_TEX_CN_WRITE, .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN, .inst_count = R300_RS_TX_OFFSET(6), }; -- cgit v1.2.3 From d6fd672bf9a9b7b24147341338055da3b9f81f89 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 00:33:23 -0700 Subject: radeon: Fix compile warnings, compile errors. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index c7b6813014f..ce03bf2260b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -79,10 +79,15 @@ struct r300_winsys* radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) { struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys); + struct radeon_cs_manager* csm; + + if (winsys == NULL) { + return NULL; + } do_ioctls(winsys, fd); - struct radeon_cs_manager* csm = radeon_cs_manager_gem_ctor(fd); + csm = radeon_cs_manager_gem_ctor(fd); winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); -- cgit v1.2.3 From b7ffe1e8763efdf042e2d5eb33ce4f3d5d365121 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 00:34:10 -0700 Subject: Add scons build support for radeon/r300. --- SConstruct | 2 +- src/gallium/drivers/r300/SConscript | 28 ++++++++++++++++++--------- src/gallium/winsys/drm/SConscript | 5 +++++ src/gallium/winsys/drm/radeon/SConscript | 28 +++------------------------ src/gallium/winsys/drm/radeon/core/SConscript | 17 ++++++++++++++++ src/gallium/winsys/drm/radeon/dri2/SConscript | 14 ++++++++++++++ 6 files changed, 59 insertions(+), 35 deletions(-) create mode 100644 src/gallium/winsys/drm/radeon/core/SConscript create mode 100644 src/gallium/winsys/drm/radeon/dri2/SConscript (limited to 'src/gallium') diff --git a/SConstruct b/SConstruct index 7e7f51516e8..1e5fd71adce 100644 --- a/SConstruct +++ b/SConstruct @@ -48,7 +48,7 @@ opts.Add(ListOption('statetrackers', 'state trackers to build', default_statetra opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers, ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300'])) opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys, - ['xlib', 'intel', 'gdi', 'amd'])) + ['xlib', 'intel', 'gdi', 'radeon'])) opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript index 18684c3e7f9..c914bc7c40a 100644 --- a/src/gallium/drivers/r300/SConscript +++ b/src/gallium/drivers/r300/SConscript @@ -3,15 +3,25 @@ Import('*') env = env.Clone() r300 = env.ConvenienceLibrary( - target = 'r300', - source = [ - 'r300_blit.c', - 'r300_clear.c', - 'r300_context.c', - 'r300_screen.c', - 'r300_state.c', - 'r300_surface.c', - ]) + target = 'r300', + source = [ + 'r300_chipset.c', + 'r300_clear.c', + 'r300_context.c', + 'r300_debug.c', + 'r300_emit.c', + 'r300_flush.c', + 'r300_query.c', + 'r300_screen.c', + 'r300_state.c', + 'r300_state_derived.c', + 'r300_state_invariant.c', + 'r300_state_shader.c', + 'r300_state_tcl.c', + 'r300_surface.c', + 'r300_swtcl_emit.c', + 'r300_texture.c', + ]) Export('r300') diff --git a/src/gallium/winsys/drm/SConscript b/src/gallium/winsys/drm/SConscript index aef5210a32d..a9e9f2682a7 100644 --- a/src/gallium/winsys/drm/SConscript +++ b/src/gallium/winsys/drm/SConscript @@ -52,3 +52,8 @@ if env['dri']: SConscript([ 'intel/SConscript', ]) + + if 'radeon' in env['winsys']: + SConscript([ + 'radeon/SConscript', + ]) diff --git a/src/gallium/winsys/drm/radeon/SConscript b/src/gallium/winsys/drm/radeon/SConscript index 2435211a327..8f99055b2f7 100644 --- a/src/gallium/winsys/drm/radeon/SConscript +++ b/src/gallium/winsys/drm/radeon/SConscript @@ -1,29 +1,7 @@ Import('*') -if 'mesa' in env['statetrackers']: - - env = drienv.Clone() - - DRIVER_SOURCES = [ - 'radeon_buffer.c', - 'radeon_context.c', - 'radeon_screen.c', - 'radeon_winsys_softpipe.c', - ] +SConscript(['core/SConscript',]) - sources = \ - COMMON_GALLIUM_SOURCES + \ - DRIVER_SOURCES - - drivers = [ - softpipe, - r300 - ] - - # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions - env.SharedLibrary( - target ='radeon_dri.so', - source = sources, - LIBS = drivers + mesa + auxiliaries + env['LIBS'], - ) +if 'mesa' in env['statetrackers']: + SConscript(['dri2/SConscript']) diff --git a/src/gallium/winsys/drm/radeon/core/SConscript b/src/gallium/winsys/drm/radeon/core/SConscript new file mode 100644 index 00000000000..578174e32ba --- /dev/null +++ b/src/gallium/winsys/drm/radeon/core/SConscript @@ -0,0 +1,17 @@ +Import('*') + +env = drienv.Clone() + +radeon_sources = [ + 'radeon_buffer.c', + 'radeon_drm.c', + 'radeon_r300.c', + 'radeon_winsys_softpipe.c', +] + +env.Append(CPPPATH = '#/src/gallium/drivers/r300') + +env.ConvenienceLibrary( + target ='radeonwinsys', + source = radeon_sources, +) diff --git a/src/gallium/winsys/drm/radeon/dri2/SConscript b/src/gallium/winsys/drm/radeon/dri2/SConscript new file mode 100644 index 00000000000..f2cdee97d92 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/dri2/SConscript @@ -0,0 +1,14 @@ +Import('*') + +env = drienv.Clone() + +drivers = [ + softpipe, + r300 +] + +env.SharedLibrary( + target ='radeon_dri.so', + source = COMMON_GALLIUM_SOURCES, + LIBS = drivers + mesa + auxiliaries + env['LIBS'], +) -- cgit v1.2.3 From 5c50218d009a4c8276aa561bd1483742cf6aa20e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 02:05:45 -0700 Subject: r300-gallium: Move swtcl_emit to render to reflect its true purpose. --- src/gallium/drivers/r300/Makefile | 2 +- src/gallium/drivers/r300/SConscript | 2 +- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/drivers/r300/r300_context.h | 2 +- src/gallium/drivers/r300/r300_render.c | 316 +++++++++++++++++++++++++++++ src/gallium/drivers/r300/r300_swtcl_emit.c | 316 ----------------------------- 6 files changed, 320 insertions(+), 320 deletions(-) create mode 100644 src/gallium/drivers/r300/r300_render.c delete mode 100644 src/gallium/drivers/r300/r300_swtcl_emit.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 9330c286d2b..e44f9b9dfc5 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -11,6 +11,7 @@ C_SOURCES = \ r300_emit.c \ r300_flush.c \ r300_query.c \ + r300_render.c \ r300_screen.c \ r300_state.c \ r300_state_derived.c \ @@ -18,7 +19,6 @@ C_SOURCES = \ r300_state_shader.c \ r300_state_tcl.c \ r300_surface.c \ - r300_swtcl_emit.c \ r300_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript index c914bc7c40a..182ed2d459a 100644 --- a/src/gallium/drivers/r300/SConscript +++ b/src/gallium/drivers/r300/SConscript @@ -12,6 +12,7 @@ r300 = env.ConvenienceLibrary( 'r300_emit.c', 'r300_flush.c', 'r300_query.c', + 'r300_render.c', 'r300_screen.c', 'r300_state.c', 'r300_state_derived.c', @@ -19,7 +20,6 @@ r300 = env.ConvenienceLibrary( 'r300_state_shader.c', 'r300_state_tcl.c', 'r300_surface.c', - 'r300_swtcl_emit.c', 'r300_texture.c', ]) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index b8584702aad..31efe914171 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -125,7 +125,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.draw_range_elements = r300_draw_range_elements; r300->draw = draw_create(); - draw_set_rasterize_stage(r300->draw, r300_draw_swtcl_stage(r300)); + draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300)); r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state); r300->rs_block = CALLOC_STRUCT(r300_rs_block); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 0ca445c0918..9d2a07a7d97 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -306,7 +306,7 @@ static struct r300_context* r300_context(struct pipe_context* context) { } /* Context initialization. */ -struct draw_stage* r300_draw_swtcl_stage(struct r300_context* r300); +struct draw_stage* r300_draw_stage(struct r300_context* r300); void r300_init_state_functions(struct r300_context* r300); void r300_init_surface_functions(struct r300_context* r300); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c new file mode 100644 index 00000000000..57bbc7a9944 --- /dev/null +++ b/src/gallium/drivers/r300/r300_render.c @@ -0,0 +1,316 @@ +/* + * Copyright 2009 Corbin Simpson + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include "draw/draw_pipe.h" +#include "draw/draw_vbuf.h" +#include "util/u_memory.h" + +#include "r300_cs.h" +#include "r300_context.h" +#include "r300_reg.h" +#include "r300_state_derived.h" + +/* r300_render: Vertex and index buffer primitive emission. */ + +struct r300_render { + /* Parent class */ + struct vbuf_render base; + + /* Pipe context */ + struct r300_context* r300; + + /* Vertex information */ + size_t vertex_size; + unsigned prim; + unsigned hwprim; + + /* VBO */ + struct pipe_buffer* vbo; + size_t vbo_size; + size_t vbo_offset; + void* vbo_map; + size_t vbo_alloc_size; + size_t vbo_max_used; +}; + +static INLINE struct r300_render* +r300_render(struct vbuf_render* render) +{ + return (struct r300_render*)render; +} + +static const struct vertex_info* +r300_render_get_vertex_info(struct vbuf_render* render) +{ + struct r300_render* r300render = r300_render(render); + struct r300_context* r300 = r300render->r300; + + r300_update_derived_state(r300); + + return &r300->vertex_info.vinfo; +} + +static boolean r300_render_allocate_vertices(struct vbuf_render* render, + ushort vertex_size, + ushort count) +{ + struct r300_render* r300render = r300_render(render); + struct r300_context* r300 = r300render->r300; + struct pipe_screen* screen = r300->context.screen; + size_t size = (size_t)vertex_size * (size_t)count; + + if (r300render->vbo) { + pipe_buffer_reference(&r300render->vbo, NULL); + } + + r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size); + r300render->vbo_offset = 0; + r300render->vbo = pipe_buffer_create(screen, + 64, + PIPE_BUFFER_USAGE_VERTEX, + r300render->vbo_size); + + r300render->vertex_size = vertex_size; + + if (r300render->vbo) { + return TRUE; + } else { + return FALSE; + } +} + +static void* r300_render_map_vertices(struct vbuf_render* render) +{ + struct r300_render* r300render = r300_render(render); + struct pipe_screen* screen = r300render->r300->context.screen; + + r300render->vbo_map = pipe_buffer_map(screen, r300render->vbo, + PIPE_BUFFER_USAGE_CPU_WRITE); + + return (unsigned char*)r300render->vbo_map + r300render->vbo_offset; +} + +static void r300_render_unmap_vertices(struct vbuf_render* render, + ushort min, + ushort max) +{ + struct r300_render* r300render = r300_render(render); + struct pipe_screen* screen = r300render->r300->context.screen; + + r300render->vbo_max_used = MAX2(r300render->vbo_max_used, + r300render->vertex_size * (max + 1)); + + pipe_buffer_unmap(screen, r300render->vbo); +} + +static void r300_render_release_vertices(struct vbuf_render* render) +{ + struct r300_render* r300render = r300_render(render); + + pipe_buffer_reference(&r300render->vbo, NULL); +} + +static boolean r300_render_set_primitive(struct vbuf_render* render, + unsigned prim) +{ + struct r300_render* r300render = r300_render(render); + r300render->prim = prim; + + switch (prim) { + case PIPE_PRIM_POINTS: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POINTS; + break; + case PIPE_PRIM_LINES: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINES; + break; + case PIPE_PRIM_LINE_LOOP: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_LOOP; + break; + case PIPE_PRIM_LINE_STRIP: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_STRIP; + break; + case PIPE_PRIM_TRIANGLES: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLES; + break; + case PIPE_PRIM_TRIANGLE_STRIP: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP; + break; + case PIPE_PRIM_TRIANGLE_FAN: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN; + break; + case PIPE_PRIM_QUADS: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUADS; + break; + case PIPE_PRIM_QUAD_STRIP: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP; + break; + case PIPE_PRIM_POLYGON: + r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POLYGON; + break; + default: + return FALSE; + break; + } + + return TRUE; +} + +static void prepare_render(struct r300_render* render, unsigned count) +{ + struct r300_context* r300 = render->r300; + + CS_LOCALS(r300); + + /* Make sure that all possible state is emitted. */ + r300_emit_dirty_state(r300); + + debug_printf("r300: Preparing vertex buffer %p for render, " + "vertex size %d, vertex count %d\n", render->vbo, + r300->vertex_info.vinfo.size, count); + /* Set the pointer to our vertex buffer. The emitted values are this: + * PACKET3 [3D_LOAD_VBPNTR] + * COUNT [1] + * FORMAT [size | stride << 8] + * OFFSET [0] + * VBPNTR [relocated BO] + */ + BEGIN_CS(7); + OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3); + OUT_CS(1); + OUT_CS(r300->vertex_info.vinfo.size | + (r300->vertex_info.vinfo.size << 8)); + OUT_CS(render->vbo_offset); + OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); + END_CS; +} + +static void r300_render_draw_arrays(struct vbuf_render* render, + unsigned start, + unsigned count) +{ + struct r300_render* r300render = r300_render(render); + struct r300_context* r300 = r300render->r300; + + CS_LOCALS(r300); + + r300render->vbo_offset = start; + + prepare_render(r300render, count); + + debug_printf("r300: Doing vbuf render, count %d\n", count); + + BEGIN_CS(2); + OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); + OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | + r300render->hwprim); + END_CS; +} + +static void r300_render_draw(struct vbuf_render* render, + const ushort* indices, + uint count) +{ + struct r300_render* r300render = r300_render(render); + struct r300_context* r300 = r300render->r300; + struct pipe_screen* screen = r300->context.screen; + struct pipe_buffer* index_buffer; + void* index_map; + + CS_LOCALS(r300); + + prepare_render(r300render, count); + + /* Send our indices into an index buffer. */ + index_buffer = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, + count); + if (!index_buffer) { + return; + } + + index_map = pipe_buffer_map(screen, index_buffer, + PIPE_BUFFER_USAGE_CPU_WRITE); + memcpy(index_map, indices, count); + pipe_buffer_unmap(screen, index_buffer); + + debug_printf("r300: Doing indexbuf render, count %d\n", count); + + BEGIN_CS(5); + OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0); + OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | + r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); + + OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2); + OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2)); + OUT_CS_RELOC(index_buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); + END_CS; +} + +static void r300_render_destroy(struct vbuf_render* render) +{ + FREE(render); +} + +static struct vbuf_render* r300_render_create(struct r300_context* r300) +{ + struct r300_render* r300render = CALLOC_STRUCT(r300_render); + + r300render->r300 = r300; + + /* XXX find real numbers plz */ + r300render->base.max_vertex_buffer_bytes = 128 * 1024; + r300render->base.max_indices = 16 * 1024; + + r300render->base.get_vertex_info = r300_render_get_vertex_info; + r300render->base.allocate_vertices = r300_render_allocate_vertices; + r300render->base.map_vertices = r300_render_map_vertices; + r300render->base.unmap_vertices = r300_render_unmap_vertices; + r300render->base.set_primitive = r300_render_set_primitive; + r300render->base.draw = r300_render_draw; + r300render->base.draw_arrays = r300_render_draw_arrays; + r300render->base.release_vertices = r300_render_release_vertices; + r300render->base.destroy = r300_render_destroy; + + return &r300render->base; +} + +struct draw_stage* r300_draw_stage(struct r300_context* r300) +{ + struct vbuf_render* render; + struct draw_stage* stage; + + render = r300_render_create(r300); + + if (!render) { + return NULL; + } + + stage = draw_vbuf_stage(r300->draw, render); + + if (!stage) { + render->destroy(render); + return NULL; + } + + draw_set_render(r300->draw, render); + + return stage; +} diff --git a/src/gallium/drivers/r300/r300_swtcl_emit.c b/src/gallium/drivers/r300/r300_swtcl_emit.c deleted file mode 100644 index 83c25f496bf..00000000000 --- a/src/gallium/drivers/r300/r300_swtcl_emit.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "draw/draw_pipe.h" -#include "draw/draw_vbuf.h" -#include "util/u_memory.h" - -#include "r300_cs.h" -#include "r300_context.h" -#include "r300_reg.h" -#include "r300_state_derived.h" - -/* r300_swtcl_emit: Vertex and index buffer primitive emission. No HW TCL. */ - -struct r300_swtcl_render { - /* Parent class */ - struct vbuf_render base; - - /* Pipe context */ - struct r300_context* r300; - - /* Vertex information */ - size_t vertex_size; - unsigned prim; - unsigned hwprim; - - /* VBO */ - struct pipe_buffer* vbo; - size_t vbo_size; - size_t vbo_offset; - void* vbo_map; - size_t vbo_alloc_size; - size_t vbo_max_used; -}; - -static INLINE struct r300_swtcl_render* -r300_swtcl_render(struct vbuf_render* render) -{ - return (struct r300_swtcl_render*)render; -} - -static const struct vertex_info* -r300_swtcl_render_get_vertex_info(struct vbuf_render* render) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - struct r300_context* r300 = r300render->r300; - - r300_update_derived_state(r300); - - return &r300->vertex_info.vinfo; -} - -static boolean r300_swtcl_render_allocate_vertices(struct vbuf_render* render, - ushort vertex_size, - ushort count) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - struct r300_context* r300 = r300render->r300; - struct pipe_screen* screen = r300->context.screen; - size_t size = (size_t)vertex_size * (size_t)count; - - if (r300render->vbo) { - pipe_buffer_reference(&r300render->vbo, NULL); - } - - r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size); - r300render->vbo_offset = 0; - r300render->vbo = pipe_buffer_create(screen, - 64, - PIPE_BUFFER_USAGE_VERTEX, - r300render->vbo_size); - - r300render->vertex_size = vertex_size; - - if (r300render->vbo) { - return TRUE; - } else { - return FALSE; - } -} - -static void* r300_swtcl_render_map_vertices(struct vbuf_render* render) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - struct pipe_screen* screen = r300render->r300->context.screen; - - r300render->vbo_map = pipe_buffer_map(screen, r300render->vbo, - PIPE_BUFFER_USAGE_CPU_WRITE); - - return (unsigned char*)r300render->vbo_map + r300render->vbo_offset; -} - -static void r300_swtcl_render_unmap_vertices(struct vbuf_render* render, - ushort min, - ushort max) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - struct pipe_screen* screen = r300render->r300->context.screen; - - r300render->vbo_max_used = MAX2(r300render->vbo_max_used, - r300render->vertex_size * (max + 1)); - - pipe_buffer_unmap(screen, r300render->vbo); -} - -static void r300_swtcl_render_release_vertices(struct vbuf_render* render) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - - pipe_buffer_reference(&r300render->vbo, NULL); -} - -static boolean r300_swtcl_render_set_primitive(struct vbuf_render* render, - unsigned prim) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - r300render->prim = prim; - - switch (prim) { - case PIPE_PRIM_POINTS: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POINTS; - break; - case PIPE_PRIM_LINES: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINES; - break; - case PIPE_PRIM_LINE_LOOP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_LOOP; - break; - case PIPE_PRIM_LINE_STRIP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_STRIP; - break; - case PIPE_PRIM_TRIANGLES: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLES; - break; - case PIPE_PRIM_TRIANGLE_STRIP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP; - break; - case PIPE_PRIM_TRIANGLE_FAN: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN; - break; - case PIPE_PRIM_QUADS: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUADS; - break; - case PIPE_PRIM_QUAD_STRIP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP; - break; - case PIPE_PRIM_POLYGON: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POLYGON; - break; - default: - return FALSE; - break; - } - - return TRUE; -} - -static void prepare_render(struct r300_swtcl_render* render, unsigned count) -{ - struct r300_context* r300 = render->r300; - - CS_LOCALS(r300); - - /* Make sure that all possible state is emitted. */ - r300_emit_dirty_state(r300); - - debug_printf("r300: Preparing vertex buffer %p for render, " - "vertex size %d, vertex count %d\n", render->vbo, - r300->vertex_info.vinfo.size, count); - /* Set the pointer to our vertex buffer. The emitted values are this: - * PACKET3 [3D_LOAD_VBPNTR] - * COUNT [1] - * FORMAT [size | stride << 8] - * OFFSET [0] - * VBPNTR [relocated BO] - */ - BEGIN_CS(7); - OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3); - OUT_CS(1); - OUT_CS(r300->vertex_info.vinfo.size | - (r300->vertex_info.vinfo.size << 8)); - OUT_CS(render->vbo_offset); - OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); - END_CS; -} - -static void r300_swtcl_render_draw_arrays(struct vbuf_render* render, - unsigned start, - unsigned count) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - struct r300_context* r300 = r300render->r300; - - CS_LOCALS(r300); - - r300render->vbo_offset = start; - - prepare_render(r300render, count); - - debug_printf("r300: Doing vbuf render, count %d\n", count); - - BEGIN_CS(2); - OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); - OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | - r300render->hwprim); - END_CS; -} - -static void r300_swtcl_render_draw(struct vbuf_render* render, - const ushort* indices, - uint count) -{ - struct r300_swtcl_render* r300render = r300_swtcl_render(render); - struct r300_context* r300 = r300render->r300; - struct pipe_screen* screen = r300->context.screen; - struct pipe_buffer* index_buffer; - void* index_map; - - CS_LOCALS(r300); - - prepare_render(r300render, count); - - /* Send our indices into an index buffer. */ - index_buffer = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, - count); - if (!index_buffer) { - return; - } - - index_map = pipe_buffer_map(screen, index_buffer, - PIPE_BUFFER_USAGE_CPU_WRITE); - memcpy(index_map, indices, count); - pipe_buffer_unmap(screen, index_buffer); - - debug_printf("r300: Doing indexbuf render, count %d\n", count); - - BEGIN_CS(5); - OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0); - OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | - r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); - - OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2); - OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2)); - OUT_CS_RELOC(index_buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); - END_CS; -} - -static void r300_swtcl_render_destroy(struct vbuf_render* render) -{ - FREE(render); -} - -static struct vbuf_render* r300_swtcl_render_create(struct r300_context* r300) -{ - struct r300_swtcl_render* r300render = CALLOC_STRUCT(r300_swtcl_render); - - r300render->r300 = r300; - - /* XXX find real numbers plz */ - r300render->base.max_vertex_buffer_bytes = 128 * 1024; - r300render->base.max_indices = 16 * 1024; - - r300render->base.get_vertex_info = r300_swtcl_render_get_vertex_info; - r300render->base.allocate_vertices = r300_swtcl_render_allocate_vertices; - r300render->base.map_vertices = r300_swtcl_render_map_vertices; - r300render->base.unmap_vertices = r300_swtcl_render_unmap_vertices; - r300render->base.set_primitive = r300_swtcl_render_set_primitive; - r300render->base.draw = r300_swtcl_render_draw; - r300render->base.draw_arrays = r300_swtcl_render_draw_arrays; - r300render->base.release_vertices = r300_swtcl_render_release_vertices; - r300render->base.destroy = r300_swtcl_render_destroy; - - return &r300render->base; -} - -struct draw_stage* r300_draw_swtcl_stage(struct r300_context* r300) -{ - struct vbuf_render* render; - struct draw_stage* stage; - - render = r300_swtcl_render_create(r300); - - if (!render) { - return NULL; - } - - stage = draw_vbuf_stage(r300->draw, render); - - if (!stage) { - render->destroy(render); - return NULL; - } - - draw_set_render(r300->draw, render); - - return stage; -} -- cgit v1.2.3 From 23639ddbaea67185c87c9e2332f10ba95723b2cb Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 02:19:48 -0700 Subject: r300-gallium: Fix bad register write. --- src/gallium/drivers/r300/r300_emit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 0ee32334460..f28404152f0 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -370,15 +370,16 @@ void r300_emit_viewport_state(struct r300_context* r300, { CS_LOCALS(r300); - BEGIN_CS(7); - OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 7); + BEGIN_CS(9); + OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); OUT_CS_32F(viewport->xscale); OUT_CS_32F(viewport->xoffset); OUT_CS_32F(viewport->yscale); OUT_CS_32F(viewport->yoffset); OUT_CS_32F(viewport->zscale); OUT_CS_32F(viewport->zoffset); - OUT_CS(viewport->vte_control); + + OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); END_CS; } -- cgit v1.2.3 From 21f1cdbe075ee6c24ebd6db2902f19a9d33beb22 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 02:20:29 -0700 Subject: radeon: If the CS emit fails, dump it to stderr. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index ce03bf2260b..293b6c2d389 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -39,7 +39,13 @@ static void radeon_r300_write_cs_reloc(struct radeon_cs* cs, static void radeon_r300_flush_cs(struct radeon_cs* cs) { - radeon_cs_emit(cs); + int retval = 0; + + retval = radeon_cs_emit(cs); + if (retval) { + debug_printf("radeon: Bad CS, dumping...\n"); + radeon_cs_print(cs, stderr); + } radeon_cs_erase(cs); } -- cgit v1.2.3 From 48688e5e8f9501cad3d2862f8e057166992fddc0 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 02:38:13 -0700 Subject: r300-gallium: Calculate vert shader inputs for HW TCL. This is definitely not perfect. --- src/gallium/drivers/r300/r300_state_derived.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 0e7a2b6726f..2f34698e359 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -30,9 +30,9 @@ * The vertex_info struct describes the post-TCL format of vertices. It is * required for Draw when doing SW TCL, and also for describing the * dreaded RS block on R300 chipsets. */ -/* XXX this function should be able to handle vert shaders as well as draw */ static void r300_update_vertex_layout(struct r300_context* r300) { + struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_vertex_format vformat; struct vertex_info vinfo; boolean pos = FALSE, psize = FALSE, fog = FALSE; @@ -74,6 +74,13 @@ static void r300_update_vertex_layout(struct r300_context* r300) } } + if (r300screen->caps->has_tcl) { + for (i = 0; i < info->num_inputs; i++) { + /* XXX should probably do real lookup with vert shader */ + tab[i] = i; + } + } + /* Do the actual vertex_info setup. * * vertex_info has four uints of hardware-specific data in it. -- cgit v1.2.3 From 024817649f61d303f799c7b0449e71b84a52b6de Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 02:43:09 -0700 Subject: radeon: A bit of indent and line break cleanup. --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 17 +++++++++++------ src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 3 ++- .../winsys/drm/radeon/core/radeon_winsys_softpipe.c | 17 +++++++++-------- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 9dca510c815..611ee68da63 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -82,7 +82,8 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, { struct radeon_pipe_buffer *radeon_buffer; - radeon_buffer = (struct radeon_pipe_buffer*)radeon_buffer_create(ws, 0, 0, bytes); + radeon_buffer = + (struct radeon_pipe_buffer*)radeon_buffer_create(ws, 0, 0, bytes); if (radeon_buffer == NULL) { return NULL; } @@ -94,7 +95,8 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, static void radeon_buffer_del(struct pipe_buffer *buffer) { - struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; + struct radeon_pipe_buffer *radeon_buffer = + (struct radeon_pipe_buffer*)buffer; radeon_bo_unref(radeon_buffer->bo); free(radeon_buffer); @@ -104,7 +106,8 @@ static void *radeon_buffer_map(struct pipe_winsys *ws, struct pipe_buffer *buffer, unsigned flags) { - struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; + struct radeon_pipe_buffer *radeon_buffer = + (struct radeon_pipe_buffer*)buffer; int write = 0; if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { @@ -120,9 +123,11 @@ static void *radeon_buffer_map(struct pipe_winsys *ws, return radeon_buffer->bo->ptr; } -static void radeon_buffer_unmap(struct pipe_winsys *ws, struct pipe_buffer *buffer) +static void radeon_buffer_unmap(struct pipe_winsys *ws, + struct pipe_buffer *buffer) { - struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; + struct radeon_pipe_buffer *radeon_buffer = + (struct radeon_pipe_buffer*)buffer; radeon_bo_unmap(radeon_buffer->bo); } @@ -151,7 +156,7 @@ static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys, struct pipe_surface *pipe_surface, void *context_private) { - /* TODO: call dri2CopyRegion */ + /* XXX TODO: call dri2CopyRegion */ } struct radeon_winsys* radeon_pipe_winsys(int fd) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index 40ad0fc8d19..163422f2969 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -59,9 +59,10 @@ struct radeon_winsys { }; struct radeon_winsys* radeon_pipe_winsys(int fb); +#if 0 struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context, uint32_t handle, enum pipe_format format, int w, int h, int pitch); - +#endif #endif diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c index 226e16674c8..33f9ac15ab1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c @@ -39,16 +39,17 @@ struct radeon_softpipe_winsys { /** * Return list of surface formats supported by this driver. */ -static boolean radeon_is_format_supported(struct softpipe_winsys *sws, uint format) +static boolean radeon_is_format_supported(struct softpipe_winsys *sws, + uint format) { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - return TRUE; - default: - break; - }; + case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: + return TRUE; + default: + break; + } return FALSE; } -- cgit v1.2.3 From 2d8bf51ffc2dfdd3a1c44f550385250c3398e1d0 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sat, 4 Apr 2009 11:52:19 +0200 Subject: python/regress: Use X8R8G8B8 rendertarget in vertex shader test. --- .../state_trackers/python/tests/regress/vertex-shader/vertex-shader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 99fe7877389..6a927f59575 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -112,7 +112,7 @@ def test(dev, name): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() -- cgit v1.2.3 From 4661817dacec5ef77d013828423c7ebeacf807c5 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sat, 4 Apr 2009 13:34:27 +0200 Subject: python/regress: Initial fragment shader test suite. --- .../tests/regress/fragment-shader/frag-abs.sh | 13 ++ .../tests/regress/fragment-shader/frag-add.sh | 8 + .../tests/regress/fragment-shader/frag-dp3.sh | 8 + .../tests/regress/fragment-shader/frag-dp4.sh | 8 + .../tests/regress/fragment-shader/frag-dst.sh | 8 + .../tests/regress/fragment-shader/frag-ex2.sh | 11 ++ .../tests/regress/fragment-shader/frag-flr.sh | 15 ++ .../tests/regress/fragment-shader/frag-frc.sh | 13 ++ .../tests/regress/fragment-shader/frag-lg2.sh | 15 ++ .../tests/regress/fragment-shader/frag-lit.sh | 8 + .../tests/regress/fragment-shader/frag-lrp.sh | 11 ++ .../tests/regress/fragment-shader/frag-mad.sh | 11 ++ .../tests/regress/fragment-shader/frag-max.sh | 10 + .../tests/regress/fragment-shader/frag-min.sh | 10 + .../tests/regress/fragment-shader/frag-mov.sh | 8 + .../tests/regress/fragment-shader/frag-mul.sh | 10 + .../tests/regress/fragment-shader/frag-rcp.sh | 15 ++ .../tests/regress/fragment-shader/frag-rsq.sh | 15 ++ .../tests/regress/fragment-shader/frag-sge.sh | 13 ++ .../tests/regress/fragment-shader/frag-slt.sh | 13 ++ .../regress/fragment-shader/frag-srcmod-abs.sh | 13 ++ .../regress/fragment-shader/frag-srcmod-absneg.sh | 15 ++ .../regress/fragment-shader/frag-srcmod-neg.sh | 11 ++ .../regress/fragment-shader/frag-srcmod-swz.sh | 8 + .../tests/regress/fragment-shader/frag-sub.sh | 8 + .../tests/regress/fragment-shader/frag-xpd.sh | 8 + .../regress/fragment-shader/fragment-shader.py | 213 +++++++++++++++++++++ 27 files changed, 499 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-add.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp3.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp4.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dst.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ex2.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-flr.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-frc.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lg2.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lit.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lrp.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mad.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-max.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-min.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mov.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mul.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rcp.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rsq.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sge.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-abs.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-neg.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-swz.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sub.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-xpd.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.sh new file mode 100644 index 00000000000..7a0006bf660 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.sh @@ -0,0 +1,13 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { -0.5, -0.4, -0.6, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +ABS OUT[0], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-add.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-add.sh new file mode 100644 index 00000000000..f7836c85ddb --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-add.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +ADD OUT[0], IN[0], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp3.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp3.sh new file mode 100644 index 00000000000..c89cd748a80 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp3.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DP3 OUT[0], IN[0], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp4.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp4.sh new file mode 100644 index 00000000000..6517e3c4945 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dp4.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DP4 OUT[0], IN[0].xyzx, IN[0].xyzx + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dst.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dst.sh new file mode 100644 index 00000000000..464880ba68f --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-dst.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DST OUT[0], IN[0], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ex2.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ex2.sh new file mode 100644 index 00000000000..2684076f1d6 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-ex2.sh @@ -0,0 +1,11 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +EX2 TEMP[0], IN[0].xxxx +MUL OUT[0], TEMP[0], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-flr.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-flr.sh new file mode 100644 index 00000000000..ad11e28918a --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-flr.sh @@ -0,0 +1,15 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 2.5, 4.0, 2.0, 1.0 } +IMM FLT32 { 0.4, 0.25, 0.5, 1.0 } + +MUL TEMP[0], IN[0], IMM[0] +FLR TEMP[0], TEMP[0] +MUL OUT[0], TEMP[0], IMM[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-frc.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-frc.sh new file mode 100644 index 00000000000..4f3aa30d666 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-frc.sh @@ -0,0 +1,13 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 2.7, 3.1, 4.5, 1.0 } + +MUL TEMP[0], IN[0], IMM[0] +FRC OUT[0], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lg2.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lg2.sh new file mode 100644 index 00000000000..54c7c644598 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lg2.sh @@ -0,0 +1,15 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } +IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +LG2 TEMP[0].x, TEMP[0].xxxx +ADD OUT[0], TEMP[0], IMM[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lit.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lit.sh new file mode 100644 index 00000000000..0e78ef86b54 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lit.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +LIT OUT[0], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lrp.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lrp.sh new file mode 100644 index 00000000000..e9ee0f81478 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-lrp.sh @@ -0,0 +1,11 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +ABS TEMP[0], IN[0] +LRP OUT[0], TEMP[0], IN[0].xxxx, IN[0].yyyy + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mad.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mad.sh new file mode 100644 index 00000000000..439acd5bbde --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mad.sh @@ -0,0 +1,11 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +IMM FLT32 { 0.5, 0.4, 0.6, 1.0 } +IMM FLT32 { 0.5, 0.4, 0.6, 0.0 } + +MAD OUT[0], IN[0], IMM[0], IMM[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-max.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-max.sh new file mode 100644 index 00000000000..ab21b245dd8 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-max.sh @@ -0,0 +1,10 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +IMM FLT32 { 0.4, 0.4, 0.4, 0.0 } + +MAX OUT[0], IN[0], IMM[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-min.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-min.sh new file mode 100644 index 00000000000..969ae73d98e --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-min.sh @@ -0,0 +1,10 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +IMM FLT32 { 0.6, 0.6, 0.6, 1.0 } + +MIN OUT[0], IN[0], IMM[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mov.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mov.sh new file mode 100644 index 00000000000..612975e0570 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mov.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +MOV OUT[0], IN[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mul.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mul.sh new file mode 100644 index 00000000000..ed158b0fc69 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-mul.sh @@ -0,0 +1,10 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +IMM FLT32 { 0.5, 0.6, 0.7, 1.0 } + +MUL OUT[0], IN[0], IMM[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rcp.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rcp.sh new file mode 100644 index 00000000000..cc9feef07e1 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rcp.sh @@ -0,0 +1,15 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } +IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +RCP TEMP[0].x, TEMP[0].xxxx +SUB OUT[0], TEMP[0], IMM[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rsq.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rsq.sh new file mode 100644 index 00000000000..695621fdc97 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-rsq.sh @@ -0,0 +1,15 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } +IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +RSQ TEMP[0].x, TEMP[0].xxxx +SUB OUT[0], TEMP[0], IMM[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sge.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sge.sh new file mode 100644 index 00000000000..9505bc3c3e3 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sge.sh @@ -0,0 +1,13 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 0.6, 0.6, 0.6, 0.0 } + +SGE TEMP[0], IN[0], IMM[0] +MUL OUT[0], IN[0], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh new file mode 100644 index 00000000000..f2a1521cbf0 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh @@ -0,0 +1,13 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { 0.6, 0.6, 0.6, 0.0 } + +SLT TEMP[0], IN[0], IMM[0] +MUL OUT[0], IN[0], TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-abs.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-abs.sh new file mode 100644 index 00000000000..9cd4b682955 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-abs.sh @@ -0,0 +1,13 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { -0.3, -0.5, -0.4, 0.0 } + +ADD TEMP[0], IN[0], IMM[0] +MOV OUT[0], |TEMP[0]| + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh new file mode 100644 index 00000000000..acd6aa750dd --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh @@ -0,0 +1,15 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +IMM FLT32 { -0.2, -0.3, -0.4, 0.0 } +IMM FLT32 { -1.0, -1.0, -1.0, -1.0 } + +ADD TEMP[0], IN[0], IMM[0] +MOV TEMP[0], -|TEMP[0]| +MUL OUT[0], TEMP[0], IMM[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-neg.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-neg.sh new file mode 100644 index 00000000000..ba1b61503b8 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-neg.sh @@ -0,0 +1,11 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +DCL TEMP[0] + +SUB TEMP[0], IN[0], IN[0].yzxw +MOV OUT[0], -TEMP[0] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-swz.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-swz.sh new file mode 100644 index 00000000000..192aa7bb26b --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-srcmod-swz.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +MOV OUT[0], IN[0].yxzw + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sub.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sub.sh new file mode 100644 index 00000000000..83441fa8207 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-sub.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +SUB OUT[0], IN[0], IN[0].yzxw + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-xpd.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-xpd.sh new file mode 100644 index 00000000000..d6f66c4927a --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-xpd.sh @@ -0,0 +1,8 @@ +FRAG1.1 + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR + +XPD OUT[0], IN[0], IN[0].yzxw + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py new file mode 100644 index 00000000000..14d8dc60bba --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2009 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################## + + +from gallium import * + +def make_image(surface): + 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) + outimage.save(filename, "PNG") + +def test(dev, name): + ctx = dev.context_create() + + width = 320 + height = 320 + minz = 0.0 + maxz = 1.0 + + # disabled blending/masking + blend = Blend() + blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.colormask = PIPE_MASK_RGBA + ctx.set_blend(blend) + + # depth/stencil/alpha + depth_stencil_alpha = DepthStencilAlpha() + depth_stencil_alpha.depth.enabled = 0 + depth_stencil_alpha.depth.writemask = 1 + depth_stencil_alpha.depth.func = PIPE_FUNC_LESS + ctx.set_depth_stencil_alpha(depth_stencil_alpha) + + # rasterizer + rasterizer = Rasterizer() + rasterizer.front_winding = PIPE_WINDING_CW + rasterizer.cull_mode = PIPE_WINDING_NONE + rasterizer.scissor = 1 + ctx.set_rasterizer(rasterizer) + + # viewport + viewport = Viewport() + scale = FloatArray(4) + scale[0] = width / 2.0 + scale[1] = -height / 2.0 + scale[2] = (maxz - minz) / 2.0 + scale[3] = 1.0 + viewport.scale = scale + translate = FloatArray(4) + translate[0] = width / 2.0 + translate[1] = height / 2.0 + translate[2] = (maxz - minz) / 2.0 + translate[3] = 0.0 + viewport.translate = translate + ctx.set_viewport(viewport) + + # samplers + sampler = Sampler() + sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE + sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE + sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST + sampler.normalized_coords = 1 + ctx.set_sampler(0, sampler) + + # scissor + scissor = Scissor() + scissor.minx = 0 + scissor.miny = 0 + scissor.maxx = width + scissor.maxy = height + ctx.set_scissor(scissor) + + clip = Clip() + clip.nr = 0 + ctx.set_clip(clip) + + # framebuffer + cbuf = dev.texture_create( + PIPE_FORMAT_X8R8G8B8_UNORM, + width, height, + tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, + ).get_surface() + fb = Framebuffer() + fb.width = width + fb.height = height + fb.nr_cbufs = 1 + fb.set_cbuf(0, cbuf) + ctx.set_framebuffer(fb) + ctx.surface_clear(cbuf, 0x80808080) + + # vertex shader + vs = Shader(''' + VERT1.1 + DCL IN[0], POSITION + DCL IN[1], COLOR + DCL OUT[0], POSITION + DCL OUT[1], COLOR + MOV OUT[0], IN[0] + MOV OUT[1], IN[1] + END + ''') + ctx.set_vertex_shader(vs) + + # fragment shader + fs = Shader(file('frag-' + name + '.sh', 'rt').read()) + ctx.set_fragment_shader(fs) + + xy = [ + -0.8, -0.8, + 0.8, -0.8, + 0.0, 0.8, + ] + color = [ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + ] + + nverts = 3 + nattrs = 2 + verts = FloatArray(nverts * nattrs * 4) + + for i in range(0, nverts): + verts[i * nattrs * 4 + 0] = xy[i * 2 + 0] # x + verts[i * nattrs * 4 + 1] = xy[i * 2 + 1] # y + verts[i * nattrs * 4 + 2] = 0.5 # z + verts[i * nattrs * 4 + 3] = 1.0 # w + verts[i * nattrs * 4 + 4] = color[i * 3 + 0] # r + verts[i * nattrs * 4 + 5] = color[i * 3 + 1] # g + verts[i * nattrs * 4 + 6] = color[i * 3 + 2] # b + verts[i * nattrs * 4 + 7] = 1.0 # a + + ctx.draw_vertices(PIPE_PRIM_TRIANGLES, + nverts, + nattrs, + verts) + + ctx.flush() + + save_image('frag-' + name + '.png', cbuf) + +def main(): + tests = [ + 'abs', + 'add', + 'dp3', + 'dp4', + 'dst', + 'ex2', + 'flr', + 'frc', + 'lg2', + 'lit', + 'lrp', + 'mad', + 'max', + 'min', + 'mov', + 'mul', + 'rcp', + 'rsq', + 'sge', + 'slt', + 'srcmod-abs', + 'srcmod-absneg', + 'srcmod-neg', + 'srcmod-swz', + 'sub', + 'xpd', + ] + + dev = Device() + for t in tests: + test(dev, t) + +if __name__ == '__main__': + main() -- cgit v1.2.3 From b0ce91518646b62169594da661dd92ac899cbd6f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sat, 4 Apr 2009 13:42:31 +0200 Subject: python/regress: Remove trailing whitespace. --- .../python/tests/regress/fragment-shader/fragment-shader.py | 2 +- .../state_trackers/python/tests/regress/vertex-shader/vertex-shader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py index 14d8dc60bba..9f6c0572630 100644 --- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py @@ -112,7 +112,7 @@ def test(dev, name): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 6a927f59575..434ac9b3fc8 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -112,7 +112,7 @@ def test(dev, name): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET, ).get_surface() -- cgit v1.2.3 From ba14b043bc1ab87e8e5e46e6e909a8def9535028 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Sat, 4 Apr 2009 16:04:59 +0200 Subject: gallium: Add utility helper for packing combined depth/stencil values. --- src/gallium/auxiliary/util/u_pack_color.h | 20 ++++++++++++++++++++ src/mesa/state_tracker/st_cb_clear.c | 16 +++------------- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index e0e8aa8e9fe..e05d0322532 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -440,6 +440,26 @@ util_pack_z(enum pipe_format format, double z) return 0; } } + + +/** + * Note: it's assumed that z is in [0,1] and s in [0,255] + */ +static INLINE uint +util_pack_z_stencil(enum pipe_format format, double z, uint s) +{ + switch (format) { + case PIPE_FORMAT_S8Z24_UNORM: + return util_pack_z(format, z) | s << 24; + case PIPE_FORMAT_Z24S8_UNORM: + return util_pack_z(format, z) | s; + default: + debug_print_format("gallium: unhandled format in util_pack_z_stencil()", + format); + assert(0); + return 0; + } +} /** diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 020684b4e14..bec32db0502 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -460,19 +460,9 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) } else { /* clear whole buffer w/out masking */ - GLuint clearValue = util_pack_z(strb->surface->format, ctx->Depth.Clear); - - switch (strb->surface->format) { - case PIPE_FORMAT_S8Z24_UNORM: - clearValue |= ctx->Stencil.Clear << 24; - break; - case PIPE_FORMAT_Z24S8_UNORM: - clearValue |= ctx->Stencil.Clear; - break; - default: - assert(0); - } - + GLuint clearValue = util_pack_z_stencil(strb->surface->format, + ctx->Depth.Clear, + ctx->Stencil.Clear); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); } } -- cgit v1.2.3 From eb168e26aa63f11a47d70c4555cae30691a2cd57 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Sat, 4 Apr 2009 19:01:51 +0200 Subject: gallium: Clean up driver clear() interface. Only allows clearing currently bound buffers, but colour and depth/stencil in a single call. --- src/gallium/auxiliary/util/u_clear.h | 60 +++++++ src/gallium/auxiliary/util/u_pack_color.h | 14 +- src/gallium/drivers/i915simple/i915_clear.c | 13 +- src/gallium/drivers/i915simple/i915_context.h | 4 +- src/gallium/drivers/nv10/nv10_clear.c | 8 +- src/gallium/drivers/nv10/nv10_context.h | 5 +- src/gallium/drivers/nv20/nv20_clear.c | 8 +- src/gallium/drivers/nv20/nv20_context.h | 4 +- src/gallium/drivers/nv30/nv30_clear.c | 8 +- src/gallium/drivers/nv30/nv30_context.h | 4 +- src/gallium/drivers/nv40/nv40_clear.c | 8 +- src/gallium/drivers/nv40/nv40_context.h | 4 +- src/gallium/drivers/nv50/nv50_context.h | 4 +- src/gallium/drivers/softpipe/sp_clear.c | 65 +++----- src/gallium/drivers/softpipe/sp_clear.h | 4 +- src/gallium/drivers/trace/tr_context.c | 21 ++- src/gallium/include/pipe/p_context.h | 16 +- src/gallium/include/pipe/p_defines.h | 9 + src/gallium/state_trackers/g3dvl/vl_basic_csc.c | 3 +- src/gallium/state_trackers/python/p_context.i | 41 +---- .../state_trackers/python/retrace/interpreter.py | 4 +- src/gallium/state_trackers/python/samples/tri.py | 8 +- .../tests/regress/vertex-shader/vertex-shader.py | 7 +- .../state_trackers/python/tests/texture_render.py | 7 +- .../state_trackers/python/tests/texture_sample.py | 7 +- src/mesa/state_tracker/st_cb_clear.c | 183 +++++++-------------- 26 files changed, 263 insertions(+), 256 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_clear.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h new file mode 100644 index 00000000000..7c16b32cf9f --- /dev/null +++ b/src/gallium/auxiliary/util/u_clear.h @@ -0,0 +1,60 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Authors: + * Michel Dänzer + */ + + +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "util/u_pack_color.h" + + +/** + * Clear the given buffers to the specified values. + * No masking, no scissor (clear entire buffer). + */ +static INLINE void +util_clear(struct pipe_context *pipe, + struct pipe_framebuffer_state *framebuffer, unsigned buffers, + const float *rgba, double depth, unsigned stencil) +{ + if (buffers & PIPE_CLEAR_COLOR) { + struct pipe_surface *ps = framebuffer->cbufs[0]; + unsigned color; + + util_pack_color(rgba, ps->format, &color); + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color); + } + + if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { + struct pipe_surface *ps = framebuffer->zsbuf; + + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, + util_pack_z_stencil(ps->format, depth, stencil)); + } +} diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index e05d0322532..4ec7aee192b 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -448,17 +448,19 @@ util_pack_z(enum pipe_format format, double z) static INLINE uint util_pack_z_stencil(enum pipe_format format, double z, uint s) { + unsigned packed = util_pack_z(format, z); + switch (format) { case PIPE_FORMAT_S8Z24_UNORM: - return util_pack_z(format, z) | s << 24; + packed |= s << 24; + break; case PIPE_FORMAT_Z24S8_UNORM: - return util_pack_z(format, z) | s; + packed |= s; default: - debug_print_format("gallium: unhandled format in util_pack_z_stencil()", - format); - assert(0); - return 0; + break; } + + return packed; } diff --git a/src/gallium/drivers/i915simple/i915_clear.c b/src/gallium/drivers/i915simple/i915_clear.c index cde69daacc0..90530f2826f 100644 --- a/src/gallium/drivers/i915simple/i915_clear.c +++ b/src/gallium/drivers/i915simple/i915_clear.c @@ -25,23 +25,24 @@ * **************************************************************************/ -/* Author: +/* Authors: * Brian Paul */ -#include "pipe/p_defines.h" +#include "util/u_clear.h" #include "i915_context.h" #include "i915_state.h" /** - * Clear the given surface to the specified value. + * Clear the given buffers to the specified values. * No masking, no scissor (clear entire buffer). */ void -i915_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +i915_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + util_clear(pipe, &i915_context(pipe)->framebuffer, buffers, rgba, depth, + stencil); } diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h index 3cdabe45f9d..b6983ba86e7 100644 --- a/src/gallium/drivers/i915simple/i915_context.h +++ b/src/gallium/drivers/i915simple/i915_context.h @@ -314,8 +314,8 @@ void i915_emit_hardware_state(struct i915_context *i915 ); /*********************************************************************** * i915_clear.c: */ -void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +void i915_clear( struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil); /*********************************************************************** diff --git a/src/gallium/drivers/nv10/nv10_clear.c b/src/gallium/drivers/nv10/nv10_clear.c index be7e09cf4b0..a39a2b5f525 100644 --- a/src/gallium/drivers/nv10/nv10_clear.c +++ b/src/gallium/drivers/nv10/nv10_clear.c @@ -1,12 +1,14 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "util/u_clear.h" #include "nv10_context.h" void -nv10_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +nv10_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + util_clear(pipe, nv10_context(pipe)->framebuffer, buffers, rgba, depth, + stencil); } diff --git a/src/gallium/drivers/nv10/nv10_context.h b/src/gallium/drivers/nv10/nv10_context.h index f3b56de25a7..f1e003c9537 100644 --- a/src/gallium/drivers/nv10/nv10_context.h +++ b/src/gallium/drivers/nv10/nv10_context.h @@ -118,8 +118,9 @@ extern void nv10_init_surface_functions(struct nv10_context *nv10); extern void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen); /* nv10_clear.c */ -extern void nv10_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +extern void nv10_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil); + /* nv10_draw.c */ extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10); diff --git a/src/gallium/drivers/nv20/nv20_clear.c b/src/gallium/drivers/nv20/nv20_clear.c index 81b6f3e78ac..2b4490fa5e1 100644 --- a/src/gallium/drivers/nv20/nv20_clear.c +++ b/src/gallium/drivers/nv20/nv20_clear.c @@ -1,12 +1,14 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "util/u_clear.h" #include "nv20_context.h" void -nv20_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +nv20_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + util_clear(pipe, nv20_context(pipe)->framebuffer, buffers, rgba, depth, + stencil); } diff --git a/src/gallium/drivers/nv20/nv20_context.h b/src/gallium/drivers/nv20/nv20_context.h index 8ad926db20a..fc932f1f90e 100644 --- a/src/gallium/drivers/nv20/nv20_context.h +++ b/src/gallium/drivers/nv20/nv20_context.h @@ -118,8 +118,8 @@ extern void nv20_init_surface_functions(struct nv20_context *nv20); extern void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen); /* nv20_clear.c */ -extern void nv20_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +extern void nv20_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil); /* nv20_draw.c */ extern struct draw_stage *nv20_draw_render_stage(struct nv20_context *nv20); diff --git a/src/gallium/drivers/nv30/nv30_clear.c b/src/gallium/drivers/nv30/nv30_clear.c index 71f413588ee..c4ba9266647 100644 --- a/src/gallium/drivers/nv30/nv30_clear.c +++ b/src/gallium/drivers/nv30/nv30_clear.c @@ -1,12 +1,14 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "util/u_clear.h" #include "nv30_context.h" void -nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +nv30_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + util_clear(pipe, &nv30_context(pipe)->framebuffer, buffers, rgba, depth, + stencil); } diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index b9337697008..4229c0a0e14 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -206,7 +206,7 @@ extern boolean nv30_draw_elements(struct pipe_context *pipe, unsigned count); /* nv30_clear.c */ -extern void nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +extern void nv30_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil); #endif diff --git a/src/gallium/drivers/nv40/nv40_clear.c b/src/gallium/drivers/nv40/nv40_clear.c index 2c4e8f01fda..ddf13addf3b 100644 --- a/src/gallium/drivers/nv40/nv40_clear.c +++ b/src/gallium/drivers/nv40/nv40_clear.c @@ -1,12 +1,14 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "util/u_clear.h" #include "nv40_context.h" void -nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +nv40_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + util_clear(pipe, &nv40_context(pipe)->framebuffer, buffers, rgba, depth, + stencil); } diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index adcfbdd85a8..97bc83292d4 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -227,7 +227,7 @@ extern boolean nv40_draw_elements(struct pipe_context *pipe, unsigned count); /* nv40_clear.c */ -extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +extern void nv40_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil); #endif diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 313e435e7a5..7b67a754397 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -184,8 +184,8 @@ extern boolean nv50_draw_elements(struct pipe_context *pipe, extern void nv50_vbo_validate(struct nv50_context *nv50); /* nv50_clear.c */ -extern void nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +extern void nv50_clear(struct pipe_context *pipe, unsigned buffers, + const float *rgba, double depth, unsigned stencil); /* nv50_program.c */ extern void nv50_vertprog_validate(struct nv50_context *nv50); diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index a60c6c4c16f..f72c6c63e76 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -2,6 +2,7 @@ * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. + * Copyright 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -27,6 +28,7 @@ /* Author: * Brian Paul + * Michel Dänzer */ @@ -40,34 +42,15 @@ /** - * Convert packed pixel from one format to another. - */ -static unsigned -convert_color(enum pipe_format srcFormat, unsigned srcColor, - enum pipe_format dstFormat) -{ - ubyte r, g, b, a; - unsigned dstColor; - - util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a); - util_pack_color_ub(r, g, b, a, dstFormat, &dstColor); - - return dstColor; -} - - - -/** - * Clear the given surface to the specified value. + * Clear the given buffers to the specified values. * No masking, no scissor (clear entire buffer). - * Note: when clearing a color buffer, the clearValue is always - * encoded as PIPE_FORMAT_A8R8G8B8_UNORM. */ void -softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil) { struct softpipe_context *softpipe = softpipe_context(pipe); + unsigned cv; uint i; if (softpipe->no_rast) @@ -77,29 +60,29 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, softpipe_update_derived(softpipe); /* not needed?? */ #endif - if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) { - sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue); -#if TILE_CLEAR_OPTIMIZATION - return; -#endif - } + if (buffers & PIPE_CLEAR_COLOR) { + for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { + struct pipe_surface *ps = softpipe->framebuffer.cbufs[i]; - for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { - if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) { - unsigned cv; - if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) { - cv = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue, - ps->format); - } - else { - cv = clearValue; - } + util_pack_color(rgba, ps->format, &cv); sp_tile_cache_clear(softpipe->cbuf_cache[i], cv); + +#if !TILE_CLEAR_OPTIMIZATION + /* non-cached surface */ + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv); +#endif } } + if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { + struct pipe_surface *ps = softpipe->framebuffer.zsbuf; + + cv = util_pack_z_stencil(ps->format, depth, stencil); + sp_tile_cache_clear(softpipe->zsbuf_cache, cv); + #if !TILE_CLEAR_OPTIMIZATION - /* non-cached surface */ - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + /* non-cached surface */ + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv); #endif + } } diff --git a/src/gallium/drivers/softpipe/sp_clear.h b/src/gallium/drivers/softpipe/sp_clear.h index a8ed1c4ecc4..2e450672f58 100644 --- a/src/gallium/drivers/softpipe/sp_clear.h +++ b/src/gallium/drivers/softpipe/sp_clear.h @@ -36,8 +36,8 @@ struct pipe_context; extern void -softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil); #endif /* SP_CLEAR_H */ diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index b69ed2cb526..6e86a5dfddf 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -973,21 +973,26 @@ trace_context_surface_fill(struct pipe_context *_pipe, static INLINE void trace_context_clear(struct pipe_context *_pipe, - struct pipe_surface *surface, - unsigned clearValue) + unsigned surfaces, + const float *rgba, + double depth, + unsigned stencil) { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - surface = trace_surface_unwrap(tr_ctx, surface); - trace_dump_call_begin("pipe_context", "clear"); trace_dump_arg(ptr, pipe); - trace_dump_arg(ptr, surface); - trace_dump_arg(uint, clearValue); - - pipe->clear(pipe, surface, clearValue);; + trace_dump_arg(uint, surfaces); + trace_dump_arg(float, rgba[0]); + trace_dump_arg(float, rgba[1]); + trace_dump_arg(float, rgba[2]); + trace_dump_arg(float, rgba[3]); + trace_dump_arg(float, depth); + trace_dump_arg(uint, stencil); + + pipe->clear(pipe, surfaces, rgba, depth, stencil); trace_dump_call_end(); } diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 2452bf3522b..29095dcdc3b 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -205,12 +205,20 @@ struct pipe_context { unsigned dstx, unsigned dsty, unsigned width, unsigned height, unsigned value); - - void (*clear)(struct pipe_context *pipe, - struct pipe_surface *ps, - unsigned clearValue); /*@}*/ + /** + * Clear the specified set of currently bound buffers to specified values. + * + * buffers is a bitfield of PIPE_CLEAR_* values. + * + * rgba is a pointer to an array of one float for each of r, g, b, a. + */ + void (*clear)(struct pipe_context *pipe, + unsigned buffers, + const float *rgba, + double depth, + unsigned stencil); /** Flush rendering (flags = bitmask of PIPE_FLUSH_x tokens) */ void (*flush)( struct pipe_context *pipe, diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 8e4f253359a..81defa445bf 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -185,6 +185,15 @@ enum pipe_texture_target { #define PIPE_SURFACE_LAYOUT_LINEAR 0 +/** + * Clear buffer bits + */ +/** All color buffers currently bound */ +#define PIPE_CLEAR_COLOR (1 << 0) +/** Depth/stencil combined */ +#define PIPE_CLEAR_DEPTHSTENCIL (1 << 1) + + /** * Transfer object usage flags */ diff --git a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c index b61b49a2f8a..16d4f1e32c9 100644 --- a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c +++ b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c @@ -98,7 +98,8 @@ static int vlResizeFrameBuffer ); /* Clear to black, in case video doesn't fill the entire window */ - pipe->clear(pipe, basic_csc->framebuffer.cbufs[0], 0); + pipe->set_framebuffer_state(pipe, &basic_csc->framebuffer); + pipe->clear(pipe, PIPE_CLEAR_COLOR, 0, 0.0f, 0); return 0; } diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index a0bf063d814..9a3003a56c4 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -308,45 +308,10 @@ error1: pipe_surface_reference(&_dst, NULL); } - void surface_clear(struct st_surface *surface, unsigned value = 0) + void clear(unsigned buffers, const float *rgba, double depth = 0.0f, + unsigned stencil = 0) { - unsigned i; - struct pipe_surface *_surface = NULL; - - if(!surface) - SWIG_exception(SWIG_TypeError, "surface must not be null"); - - for(i = 0; i < $self->framebuffer.nr_cbufs; ++i) { - struct pipe_surface *cbuf = $self->framebuffer.cbufs[i]; - if(cbuf) { - if(cbuf->texture == surface->texture && - cbuf->face == surface->face && - cbuf->level == surface->level && - cbuf->zslice == surface->zslice) { - _surface = cbuf; - break; - } - } - } - - if(!_surface) { - struct pipe_surface *zsbuf = $self->framebuffer.zsbuf; - if(zsbuf) { - if(zsbuf->texture == surface->texture && - zsbuf->face == surface->face && - zsbuf->level == surface->level && - zsbuf->zslice == surface->zslice) { - _surface = zsbuf; - } - } - } - - if(!_surface) - SWIG_exception(SWIG_ValueError, "surface not bound"); - - $self->pipe->clear($self->pipe, _surface, value); - fail: - return; + $self->pipe->clear($self->pipe, buffers, rgba, depth, stencil); } }; diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 510adcc2425..d02099389fb 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -531,8 +531,8 @@ class Context(Object): self.dirty = False return None - def clear(self, surface, value): - self.real.surface_clear(surface, value) + def clear(self, buffers, rgba, depth, stencil): + self.real.clear(buffers, rgba, depth, stencil) def _present(self): self.real.flush() diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index 4c84d121c49..4b9659861df 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -150,8 +150,12 @@ def test(dev): fb.set_cbuf(0, cbuf) fb.set_zsbuf(zbuf) ctx.set_framebuffer(fb) - ctx.surface_clear(cbuf, 0x00000000) - ctx.surface_clear(zbuf, 0xffffffff) + rgba = FloatArray(4); + rgba[0] = 0.0 + rgba[1] = 0.0 + rgba[2] = 0.0 + rgba[3] = 0.0 + ctx.clear(PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0xff) # vertex shader vs = Shader(''' diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 434ac9b3fc8..472769f2592 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -122,7 +122,12 @@ def test(dev, name): fb.nr_cbufs = 1 fb.set_cbuf(0, cbuf) ctx.set_framebuffer(fb) - ctx.surface_clear(cbuf, 0x80808080) + rgba = FloatArray(4); + rgba[0] = 0.5 + rgba[1] = 0.5 + rgba[2] = 0.5 + rgba[3] = 0.5 + ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) # vertex shader vs = Shader(file('vert-' + name + '.sh', 'rt').read()) diff --git a/src/gallium/state_trackers/python/tests/texture_render.py b/src/gallium/state_trackers/python/tests/texture_render.py index 580bf65c13b..0b76932b6ed 100755 --- a/src/gallium/state_trackers/python/tests/texture_render.py +++ b/src/gallium/state_trackers/python/tests/texture_render.py @@ -161,7 +161,12 @@ class TextureTest(TestCase): fb.nr_cbufs = 1 fb.set_cbuf(0, dst_surface) ctx.set_framebuffer(fb) - ctx.surface_clear(dst_surface, 0x00000000) + rgba = FloatArray(4); + rgba[0] = 0.0 + rgba[1] = 0.0 + rgba[2] = 0.0 + rgba[3] = 0.0 + ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) del fb # vertex shader diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py index f5f49f6e515..a382424667c 100755 --- a/src/gallium/state_trackers/python/tests/texture_sample.py +++ b/src/gallium/state_trackers/python/tests/texture_sample.py @@ -206,7 +206,12 @@ class TextureTest(TestCase): fb.nr_cbufs = 1 fb.set_cbuf(0, cbuf) ctx.set_framebuffer(fb) - ctx.surface_clear(cbuf, 0x00000000) + rgba = FloatArray(4); + rgba[0] = 0.5 + rgba[1] = 0.5 + rgba[2] = 0.5 + rgba[3] = 0.5 + ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) del fb # vertex shader diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index bec32db0502..5bdc6a13309 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -2,6 +2,7 @@ * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. + * Copyright 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -29,6 +30,7 @@ * Authors: * Keith Whitwell * Brian Paul + * Michel Dänzer */ #include "main/glheader.h" @@ -373,101 +375,6 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) -static void -clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - struct st_renderbuffer *strb = st_renderbuffer(rb); - - if (!strb->surface) - return; - - if (check_clear_color_with_quad( ctx, rb )) { - /* masking or scissoring */ - clear_with_quad(ctx, GL_TRUE, GL_FALSE, GL_FALSE); - } - else { - /* clear whole buffer w/out masking */ - uint clearValue; - /* NOTE: we always pass the clear color as PIPE_FORMAT_A8R8G8B8_UNORM - * at this time! - */ - util_pack_color(ctx->Color.ClearColor, PIPE_FORMAT_A8R8G8B8_UNORM, &clearValue); - ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); - } -} - - -static void -clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - struct st_renderbuffer *strb = st_renderbuffer(rb); - - if (!strb->surface) - return; - - if (check_clear_depth_with_quad(ctx, rb)) { - /* scissoring or we have a combined depth/stencil buffer */ - clear_with_quad(ctx, GL_FALSE, GL_TRUE, GL_FALSE); - } - else { - /* simple clear of whole buffer */ - uint clearValue = util_pack_z(strb->surface->format, ctx->Depth.Clear); - ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); - } -} - - -static void -clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - struct st_renderbuffer *strb = st_renderbuffer(rb); - - if (!strb->surface) - return; - - if (check_clear_stencil_with_quad(ctx, rb)) { - /* masking or scissoring or combined depth/stencil buffer */ - clear_with_quad(ctx, GL_FALSE, GL_FALSE, GL_TRUE); - } - else { - /* simple clear of whole buffer */ - GLuint clearValue = ctx->Stencil.Clear; - - switch (strb->surface->format) { - case PIPE_FORMAT_S8Z24_UNORM: - clearValue <<= 24; - break; - default: - ; /* no-op, stencil value is in least significant bits */ - } - - ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); - } -} - - -static void -clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - struct st_renderbuffer *strb = st_renderbuffer(rb); - - if (!strb->surface) - return; - - if (check_clear_depth_stencil_with_quad(ctx, rb)) { - /* masking or scissoring */ - clear_with_quad(ctx, GL_FALSE, GL_TRUE, GL_TRUE); - } - else { - /* clear whole buffer w/out masking */ - GLuint clearValue = util_pack_z_stencil(strb->surface->format, - ctx->Depth.Clear, - ctx->Stencil.Clear); - ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); - } -} - - void st_flush_clear( struct st_context *st ) { /* Release vertex buffer to avoid synchronous rendering if we were @@ -493,51 +400,89 @@ static void st_clear(GLcontext *ctx, GLbitfield mask) = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; struct gl_renderbuffer *stencilRb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - GLbitfield cmask = mask & BUFFER_BITS_COLOR; + GLbitfield quad_buffers = 0; + GLbitfield clear_buffers = 0; + GLuint i; - /* This makes sure the softpipe has the latest scissor, etc values */ + /* This makes sure the pipe has the latest scissor, etc values */ st_validate_state( st ); - /* - * XXX TO-DO: - * If we're going to use clear_with_quad() for any reason, use it to - * clear as many other buffers as possible. - * As it is now, we sometimes call clear_with_quad() three times to clear - * color/depth/stencil individually... - */ + if (mask & BUFFER_BITS_COLOR) { + for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { + GLuint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; - if (cmask) { - GLuint b; - for (b = 0; cmask; b++) { - if (cmask & (1 << b)) { + if (mask & (1 << b)) { struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[b].Renderbuffer; + struct st_renderbuffer *strb; + assert(rb); - clear_color_buffer(ctx, rb); - cmask &= ~(1 << b); /* turn off bit */ + + strb = st_renderbuffer(rb); + + if (!strb->surface) + continue; + + if (check_clear_color_with_quad( ctx, rb )) + quad_buffers |= PIPE_CLEAR_COLOR; + else + clear_buffers |= PIPE_CLEAR_COLOR; } - assert(b < BUFFER_COUNT); } } - if (mask & BUFFER_BIT_ACCUM) { - st_clear_accum_buffer(ctx, - ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); - } - if ((mask & BUFFER_BITS_DS) == BUFFER_BITS_DS && depthRb == stencilRb) { /* clearing combined depth + stencil */ - clear_depth_stencil_buffer(ctx, depthRb); + struct st_renderbuffer *strb = st_renderbuffer(depthRb); + + if (strb->surface) { + if (check_clear_depth_stencil_with_quad(ctx, depthRb)) + quad_buffers |= PIPE_CLEAR_DEPTHSTENCIL; + else + clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL; + } } else { /* separate depth/stencil clears */ if (mask & BUFFER_BIT_DEPTH) { - clear_depth_buffer(ctx, depthRb); + struct st_renderbuffer *strb = st_renderbuffer(depthRb); + + if (strb->surface) { + if (check_clear_depth_with_quad(ctx, depthRb)) + quad_buffers |= PIPE_CLEAR_DEPTHSTENCIL; + else + clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL; + } } if (mask & BUFFER_BIT_STENCIL) { - clear_stencil_buffer(ctx, stencilRb); + struct st_renderbuffer *strb = st_renderbuffer(stencilRb); + + if (strb->surface) { + if (check_clear_stencil_with_quad(ctx, stencilRb)) + quad_buffers |= PIPE_CLEAR_DEPTHSTENCIL; + else + clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL; + } } } + + /* + * If we're going to use clear_with_quad() for any reason, use it for + * everything possible. + */ + if (quad_buffers) { + quad_buffers |= clear_buffers; + clear_with_quad(ctx, + quad_buffers & PIPE_CLEAR_COLOR, + mask & BUFFER_BIT_DEPTH, + mask & BUFFER_BIT_STENCIL); + } else if (clear_buffers) + ctx->st->pipe->clear(ctx->st->pipe, clear_buffers, ctx->Color.ClearColor, + ctx->Depth.Clear, ctx->Stencil.Clear); + + if (mask & BUFFER_BIT_ACCUM) + st_clear_accum_buffer(ctx, + ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); } -- cgit v1.2.3 From 1bf6af141f0d50f5efb1c4e03819b875fab57905 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sat, 4 Apr 2009 21:16:37 +0200 Subject: python/regress: Clean up driver clear() interface. --- .../python/tests/regress/fragment-shader/fragment-shader.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py index 9f6c0572630..d60fb38d1ae 100644 --- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py @@ -122,7 +122,12 @@ def test(dev, name): fb.nr_cbufs = 1 fb.set_cbuf(0, cbuf) ctx.set_framebuffer(fb) - ctx.surface_clear(cbuf, 0x80808080) + rgba = FloatArray(4); + rgba[0] = 0.5 + rgba[1] = 0.5 + rgba[2] = 0.5 + rgba[3] = 0.5 + ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) # vertex shader vs = Shader(''' -- cgit v1.2.3 From 7a164411ab678622d6f3194cf708b2884bfde90e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 4 Apr 2009 13:45:14 -0600 Subject: cell: update clear() code to catch up to gallium changes --- src/gallium/drivers/cell/ppu/cell_clear.c | 56 ++++++++++++----------------- src/gallium/drivers/cell/ppu/cell_clear.h | 6 ++-- src/gallium/drivers/cell/ppu/cell_context.c | 2 +- 3 files changed, 25 insertions(+), 39 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c index 34be5f3dc7d..79ad687ea94 100644 --- a/src/gallium/drivers/cell/ppu/cell_clear.c +++ b/src/gallium/drivers/cell/ppu/cell_clear.c @@ -45,54 +45,42 @@ #include "cell_state.h" -/** - * Convert packed pixel from one format to another. - */ -static unsigned -convert_color(enum pipe_format srcFormat, unsigned srcColor, - enum pipe_format dstFormat) -{ - ubyte r, g, b, a; - unsigned dstColor; - - util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a); - util_pack_color_ub(r, g, b, a, dstFormat, &dstColor); - - return dstColor; -} - - - /** * Called via pipe->clear() */ void -cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil) { struct cell_context *cell = cell_context(pipe); - uint surfIndex; if (cell->dirty) cell_update_derived(cell); - if (ps == cell->framebuffer.zsbuf) { - /* clear z/stencil buffer */ - surfIndex = 1; - } - else { - /* clear color buffer */ - surfIndex = 0; + if (buffers & PIPE_CLEAR_COLOR) { + uint surfIndex = 0; + uint clearValue; - if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) { - clearValue = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue, - ps->format); - } + util_pack_color(rgba, cell->framebuffer.cbufs[0]->format, &clearValue); + + /* Build a CLEAR command and place it in the current batch buffer */ + STATIC_ASSERT(sizeof(struct cell_command_clear_surface) % 16 == 0); + struct cell_command_clear_surface *clr + = (struct cell_command_clear_surface *) + cell_batch_alloc16(cell, sizeof(*clr)); + clr->opcode[0] = CELL_CMD_CLEAR_SURFACE; + clr->surface = surfIndex; + clr->value = clearValue; } + if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { + uint surfIndex = 1; + uint clearValue; + + clearValue = util_pack_z_stencil(cell->framebuffer.zsbuf->format, + depth, stencil); - /* Build a CLEAR command and place it in the current batch buffer */ - { + /* Build a CLEAR command and place it in the current batch buffer */ STATIC_ASSERT(sizeof(struct cell_command_clear_surface) % 16 == 0); struct cell_command_clear_surface *clr = (struct cell_command_clear_surface *) diff --git a/src/gallium/drivers/cell/ppu/cell_clear.h b/src/gallium/drivers/cell/ppu/cell_clear.h index ff47d43f4cd..08e091adfdb 100644 --- a/src/gallium/drivers/cell/ppu/cell_clear.h +++ b/src/gallium/drivers/cell/ppu/cell_clear.h @@ -31,13 +31,11 @@ struct pipe_context; -struct pipe_surface; extern void -cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); - +cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil); #endif /* CELL_CLEAR_H */ diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index ae82ded334a..808be589bd9 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -119,7 +119,7 @@ cell_create_context(struct pipe_screen *screen, cell->pipe.screen = screen; cell->pipe.destroy = cell_destroy_context; - cell->pipe.clear = cell_clear_surface; + cell->pipe.clear = cell_clear; cell->pipe.flush = cell_flush; #if 0 -- cgit v1.2.3 From a4a853e593c257d3b25f8229706d11b92e1ec8c8 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 22:30:14 -0700 Subject: r300-gallium: Update clear() code. We have a huge optimization opportunity, but for now we'll just use the util. --- src/gallium/drivers/r300/r300_clear.c | 13 ++++++++----- src/gallium/drivers/r300/r300_clear.h | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_clear.c b/src/gallium/drivers/r300/r300_clear.c index 8506ed29424..8b9cb819ae6 100644 --- a/src/gallium/drivers/r300/r300_clear.c +++ b/src/gallium/drivers/r300/r300_clear.c @@ -22,11 +22,14 @@ #include "r300_clear.h" -/* This gets its own file because Intel's is in its own file. - * I assume there's a good reason. */ +/* Clears currently bound buffers. */ void r300_clear(struct pipe_context* pipe, - struct pipe_surface* ps, - unsigned color) + unsigned buffers, + const float* rgba, + double depth, + unsigned stencil) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color); + /* XXX we can and should do one clear if both color and zs are set */ + util_clear(pipe, &r300_context(pipe)->framebuffer_state, + buffers, rgba, depth, stencil); } diff --git a/src/gallium/drivers/r300/r300_clear.h b/src/gallium/drivers/r300/r300_clear.h index e24a0690c9b..cd5900565e8 100644 --- a/src/gallium/drivers/r300/r300_clear.h +++ b/src/gallium/drivers/r300/r300_clear.h @@ -20,8 +20,17 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "pipe/p_context.h" +#ifndef R300_CLEAR_H +#define R300_CLEAR_H + +#include "util/u_clear.h" + +#include "r300_context.h" void r300_clear(struct pipe_context* pipe, - struct pipe_surface* ps, - unsigned color); + unsigned buffers, + const float* rgba, + double depth, + unsigned stencil); + +#endif /* R300_CLEAR_H */ -- cgit v1.2.3 From 7cd535b47805cc086783cc4aa857292b5986672e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 22:57:45 -0700 Subject: r300-gallium: vs: Expand instruction emission. --- src/gallium/drivers/r300/r300_state_tcl.c | 57 +++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index ddf43604b9a..457da5b7ef1 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -54,6 +54,34 @@ static void r300_vs_declare(struct r300_vs_asm* assembler, assembler->temp_offset = assembler->color_count + assembler->tex_count; } +static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, + struct tgsi_src_register* src) +{ + switch (src->File) { + case TGSI_FILE_TEMPORARY: + return R300_PVS_SRC_REG_TEMPORARY; + break; + default: + debug_printf("r300: vs: Unimplemented src type %d\n", src->File); + break; + } + return 0; +} + +static INLINE unsigned r300_vs_dst_type(struct r300_vs_asm* assembler, + struct tgsi_dst_register* dst) +{ + switch (dst->File) { + case TGSI_FILE_OUTPUT: + return R300_PVS_DST_REG_OUT; + break; + default: + debug_printf("r300: vs: Unimplemented dst type %d\n", dst->File); + break; + } + return 0; +} + static INLINE unsigned r300_vs_src(struct r300_vs_asm* assembler, struct tgsi_src_register* src) { @@ -105,12 +133,37 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, static void r300_vs_emit_inst(struct r300_vertex_shader* vs, struct r300_vs_asm* assembler, struct tgsi_full_src_register* src, - struct tgsi_full_dst_register* dst) + struct tgsi_full_dst_register* dst, + unsigned op, + unsigned count) { int i = vs->instruction_count; vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | - R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | + R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, dst->DstRegister)) | R300_PVS_DST_OFFSET(dst->DstRegister.Index); + switch (count) { + case 3: + vs->instructions[i].inst3 = + R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, + &src[2].SrcRegister)) | + R300_PVS_SRC_OFFSET(src[2].SrcRegister.Index) | + R300_PVS_SRC_SWIZZLE(R300_PVS_SRC_SWIZZLE_XYZW); + /* Fall through */ + case 2: + vs->instructions[i].inst2 = + R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, + &src[1].SrcRegister)) | + R300_PVS_SRC_OFFSET(src[1].SrcRegister.Index) | + R300_PVS_SRC_SWIZZLE(R300_PVS_SRC_SWIZZLE_XYZW); + /* Fall through */ + case 1: + vs->instructions[i].inst1 = + R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, + &src[0].SrcRegister)) | + R300_PVS_SRC_OFFSET(src[0].SrcRegister.Index) | + R300_PVS_SRC_SWIZZLE(R300_PVS_SRC_SWIZZLE_XYZW); + break; + } } static void r300_vs_instruction(struct r300_vertex_shader* vs, -- cgit v1.2.3 From 316b244ff1b18b3916ebd31078ba4c920e9585c1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 4 Apr 2009 23:44:37 -0700 Subject: r300-gallium: vs: Moar vert shaders. --- src/gallium/drivers/r300/r300_state_tcl.c | 34 ++++++++++++++++++++++++++----- src/gallium/drivers/r300/r300_state_tcl.h | 9 ++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 457da5b7ef1..f01db2df3a2 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -58,6 +58,9 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, struct tgsi_src_register* src) { switch (src->File) { + case TGSI_FILE_INPUT: + return R300_PVS_SRC_REG_INPUT; + break; case TGSI_FILE_TEMPORARY: return R300_PVS_SRC_REG_TEMPORARY; break; @@ -72,6 +75,9 @@ static INLINE unsigned r300_vs_dst_type(struct r300_vs_asm* assembler, struct tgsi_dst_register* dst) { switch (dst->File) { + case TGSI_FILE_TEMPORARY: + return R300_PVS_DST_REG_TEMPORARY; + break; case TGSI_FILE_OUTPUT: return R300_PVS_DST_REG_OUT; break; @@ -130,6 +136,21 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, return 0; } +static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) +{ + if (reg->SrcRegister.Extended) { + return reg->SrcRegisterExtSwz.ExtSwizzleX | + (reg->SrcRegisterExtSwz.ExtSwizzleY << 3) | + (reg->SrcRegisterExtSwz.ExtSwizzleZ << 6) | + (reg->SrcRegisterExtSwz.ExtSwizzleW << 9); + } else { + return reg->SrcRegister.SwizzleX | + (reg->SrcRegister.SwizzleY << 3) | + (reg->SrcRegister.SwizzleZ << 6) | + (reg->SrcRegister.SwizzleW << 9); + } +} + static void r300_vs_emit_inst(struct r300_vertex_shader* vs, struct r300_vs_asm* assembler, struct tgsi_full_src_register* src, @@ -139,7 +160,7 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, { int i = vs->instruction_count; vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | - R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, dst->DstRegister)) | + R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, &dst->DstRegister)) | R300_PVS_DST_OFFSET(dst->DstRegister.Index); switch (count) { case 3: @@ -147,21 +168,21 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[2].SrcRegister)) | R300_PVS_SRC_OFFSET(src[2].SrcRegister.Index) | - R300_PVS_SRC_SWIZZLE(R300_PVS_SRC_SWIZZLE_XYZW); + R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[2])); /* Fall through */ case 2: vs->instructions[i].inst2 = R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[1].SrcRegister)) | R300_PVS_SRC_OFFSET(src[1].SrcRegister.Index) | - R300_PVS_SRC_SWIZZLE(R300_PVS_SRC_SWIZZLE_XYZW); + R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[1])); /* Fall through */ case 1: vs->instructions[i].inst1 = R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler, &src[0].SrcRegister)) | R300_PVS_SRC_OFFSET(src[0].SrcRegister.Index) | - R300_PVS_SRC_SWIZZLE(R300_PVS_SRC_SWIZZLE_XYZW); + R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[0])); break; } } @@ -172,8 +193,11 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, { switch (inst->Instruction.Opcode) { case TGSI_OPCODE_MOV: + case TGSI_OPCODE_SWZ: + inst->FullSrcRegisters[1] = r300_constant_zero; r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, - &inst->FullDstRegisters[0]); + &inst->FullDstRegisters[0], inst->Instruction.Opcode, + 2); break; case TGSI_OPCODE_END: break; diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index b947f0d1cf6..ae8ff6c3147 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -69,6 +69,15 @@ (R300_PVS_SRC_SELECT_FORCE_1 << 6) | \ (R300_PVS_SRC_SELECT_FORCE_1 << 9)) << 13) +static const struct tgsi_full_src_register r300_constant_zero = { + .SrcRegister.Extended = TRUE, + .SrcRegister.File = TGSI_FILE_NULL, + .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO, + .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO, + .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO, + .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO, +}; + /* Temporary struct used to hold assembly state while putting together * fragment programs. */ struct r300_vs_asm { -- cgit v1.2.3 From 484795ff14faa794b7a150f29554a73e0113f67d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 5 Apr 2009 00:15:19 -0700 Subject: r300-gallium: Update state handlers/setters for vertex shaders. --- src/gallium/drivers/r300/r300_state.c | 65 ++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index b1d85260cc1..4dee4ab8ce1 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -333,9 +333,12 @@ static void* r300_create_rs_state(struct pipe_context* pipe, { struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); - /* XXX this is part of HW TCL */ /* XXX endian control */ - rs->vap_control_status = R300_VAP_TCL_BYPASS; + if (r300_screen(pipe->screen)->caps->has_tcl) { + rs->vap_control_status = 0; + } else { + rs->vap_control_status = R300_VAP_TCL_BYPASS; + } rs->point_size = pack_float_16_6x(state->point_size) | (pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT); @@ -584,31 +587,61 @@ static void r300_set_vertex_elements(struct pipe_context* pipe, const struct pipe_vertex_element* elements) { struct r300_context* r300 = r300_context(pipe); - /* XXX Draw */ + draw_flush(r300->draw); draw_set_vertex_elements(r300->draw, count, elements); } static void* r300_create_vs_state(struct pipe_context* pipe, - const struct pipe_shader_state* state) + const struct pipe_shader_state* shader) { - struct r300_context* context = r300_context(pipe); - tgsi_dump(state->tokens); - /* XXX handing this off to Draw for now */ - return draw_create_vertex_shader(context->draw, state); + struct r300_context* r300 = r300_context(pipe); + + if (r300_screen(pipe->screen)->caps->has_tcl) { + struct r300_vertex_shader* vs = CALLOC_STRUCT(r300_vertex_shader); + /* Copy state directly into shader. */ + vs->state = *shader; + + tgsi_scan_shader(shader->tokens, &vs->info); + + return (void*)vs; + } else { + return draw_create_vertex_shader(r300->draw, shader); + } } -static void r300_bind_vs_state(struct pipe_context* pipe, void* state) { - struct r300_context* context = r300_context(pipe); - /* XXX handing this off to Draw for now */ - draw_bind_vertex_shader(context->draw, (struct draw_vertex_shader*)state); +static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) +{ + struct r300_context* r300 = r300_context(pipe); + + if (r300_screen(pipe->screen)->caps->has_tcl) { + struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; + + if (vs == NULL) { + r300->vs = NULL; + return; + } else if (!vs->translated) { + r300_translate_vertex_shader(r300, vs); + } + + r300->vs = vs; + r300->dirty_state |= R300_NEW_VERTEX_SHADER; + } else { + draw_bind_vertex_shader(r300->draw, + (struct draw_vertex_shader*)shader); + } } -static void r300_delete_vs_state(struct pipe_context* pipe, void* state) +static void r300_delete_vs_state(struct pipe_context* pipe, void* shader) { - struct r300_context* context = r300_context(pipe); - /* XXX handing this off to Draw for now */ - draw_delete_vertex_shader(context->draw, (struct draw_vertex_shader*)state); + struct r300_context* r300 = r300_context(pipe); + + if (r300_screen(pipe->screen)->caps->has_tcl) { + FREE(shader); + } else { + draw_delete_vertex_shader(r300->draw, + (struct draw_vertex_shader*)shader); + } } void r300_init_state_functions(struct r300_context* r300) -- cgit v1.2.3 From ce7963f338ab95b06619074bc6aaf99c96ff5f11 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 5 Apr 2009 01:00:25 -0700 Subject: r300-gallium: Properly interface with Draw for vert shaders. --- src/gallium/drivers/r300/r300_context.h | 3 +++ src/gallium/drivers/r300/r300_debug.c | 12 ++++++++++++ src/gallium/drivers/r300/r300_debug.h | 3 +++ src/gallium/drivers/r300/r300_state.c | 12 ++++++++++++ src/gallium/drivers/r300/r300_state_tcl.c | 1 + 5 files changed, 31 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 9d2a07a7d97..fec2bad5461 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -236,6 +236,9 @@ struct r300_vertex_shader { struct pipe_shader_state state; struct tgsi_shader_info info; + /* Fallback shader, because Draw has issues */ + struct draw_vertex_shader* draw; + /* Has this shader been translated yet? */ boolean translated; diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 8d44756c332..dd63136c9d6 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -224,3 +224,15 @@ void r500_fs_dump(struct r500_fragment_shader* fs) } } } + +void r300_vs_dump(struct r300_vertex_shader* vs) +{ + int i; + + for (i = 0; i < vs->instruction_count; i++) { + debug_printf("inst0: 0x%x\n", vs->instructions[i].inst0); + debug_printf("inst1: 0x%x\n", vs->instructions[i].inst1); + debug_printf("inst2: 0x%x\n", vs->instructions[i].inst2); + debug_printf("inst3: 0x%x\n", vs->instructions[i].inst3); + } +} diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h index de5d701ed9c..a1f873656dc 100644 --- a/src/gallium/drivers/r300/r300_debug.h +++ b/src/gallium/drivers/r300/r300_debug.h @@ -25,7 +25,10 @@ #include "r300_reg.h" #include "r300_state_shader.h" +#include "r300_state_tcl.h" void r500_fs_dump(struct r500_fragment_shader* fs); +void r300_vs_dump(struct r300_vertex_shader* vs); + #endif /* R300_DEBUG_H */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 4dee4ab8ce1..5b3bb328ddf 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -403,6 +403,11 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->rs = *state; + /* If using HW TCL, tell Draw to not do its magic. */ + if (r300_screen(pipe->screen)->caps->has_tcl) { + rs->rs.bypass_vs_clip_and_viewport = TRUE; + } + return (void*)rs; } @@ -604,6 +609,9 @@ static void* r300_create_vs_state(struct pipe_context* pipe, tgsi_scan_shader(shader->tokens, &vs->info); + /* Appease Draw. */ + vs->draw = draw_create_vertex_shader(r300->draw, shader); + return (void*)vs; } else { return draw_create_vertex_shader(r300->draw, shader); @@ -624,6 +632,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300_translate_vertex_shader(r300, vs); } + draw_bind_vertex_shader(r300->draw, vs->draw); r300->vs = vs; r300->dirty_state |= R300_NEW_VERTEX_SHADER; } else { @@ -637,6 +646,9 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader) struct r300_context* r300 = r300_context(pipe); if (r300_screen(pipe->screen)->caps->has_tcl) { + struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; + + draw_delete_vertex_shader(r300->draw, vs->draw); FREE(shader); } else { draw_delete_vertex_shader(r300->draw, diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index f01db2df3a2..d0dc4ef1114 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -267,6 +267,7 @@ void r300_translate_vertex_shader(struct r300_context* r300, tgsi_dump(vs->state.tokens); /* XXX finish r300 vertex shader dumper */ + r300_vs_dump(vs); tgsi_parse_free(&parser); FREE(assembler); -- cgit v1.2.3 From 50ee103cf02b66d68a2728840c9c2f990773576b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 5 Apr 2009 01:32:00 -0700 Subject: r300-gallium: Re-translate shaders if constants change. --- src/gallium/drivers/r300/r300_state.c | 9 +++++++-- src/gallium/drivers/r300/r300_state_derived.c | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 5b3bb328ddf..095df04630f 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -153,8 +153,13 @@ static void /* If the number of constants have changed, invalidate the shader. */ if (r300->shader_constants[shader].user_count != i) { - r300->fs->translated = FALSE; - r300_translate_fragment_shader(r300, r300->fs); + if (shader == PIPE_SHADER_FRAGMENT && r300->fs) { + r300->fs->translated = FALSE; + r300_translate_fragment_shader(r300, r300->fs); + } else if (shader == PIPE_SHADER_VERTEX && r300->vs) { + r300->vs->translated = FALSE; + r300_translate_vertex_shader(r300, r300->vs); + } } } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 2f34698e359..f1feafbcf91 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -305,7 +305,8 @@ static void r300_update_rs_block(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { - if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) { + if (r300->dirty_state & + (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) { r300_update_vertex_layout(r300); } -- cgit v1.2.3 From 84d76607ec0e43edd7dd28d1d5b6a538fd087434 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 5 Apr 2009 01:32:55 -0700 Subject: r300-gallium: vs: Use a tab to properly set up OVM. --- src/gallium/drivers/r300/r300_state_tcl.c | 55 +++++++++---------------------- src/gallium/drivers/r300/r300_state_tcl.h | 6 ++-- 2 files changed, 17 insertions(+), 44 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index d0dc4ef1114..a00abfd02fd 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -27,12 +27,18 @@ static void r300_vs_declare(struct r300_vs_asm* assembler, { switch (decl->Declaration.File) { case TGSI_FILE_INPUT: + break; + case TGSI_FILE_OUTPUT: switch (decl->Semantic.SemanticName) { + case TGSI_SEMANTIC_POSITION: + assembler->tab[decl->DeclarationRange.First] = 0; + break; case TGSI_SEMANTIC_COLOR: - assembler->color_count++; + assembler->tab[decl->DeclarationRange.First] = 2; break; case TGSI_SEMANTIC_GENERIC: - assembler->tex_count++; + /* XXX multiple? */ + assembler->tab[decl->DeclarationRange.First] = 6; break; default: debug_printf("r300: vs: Bad semantic declaration %d\n", @@ -40,7 +46,6 @@ static void r300_vs_declare(struct r300_vs_asm* assembler, break; } break; - case TGSI_FILE_OUTPUT: case TGSI_FILE_CONSTANT: break; case TGSI_FILE_TEMPORARY: @@ -50,8 +55,6 @@ static void r300_vs_declare(struct r300_vs_asm* assembler, debug_printf("r300: vs: Bad file %d\n", decl->Declaration.File); break; } - - assembler->temp_offset = assembler->color_count + assembler->tex_count; } static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, @@ -88,46 +91,15 @@ static INLINE unsigned r300_vs_dst_type(struct r300_vs_asm* assembler, return 0; } -static INLINE unsigned r300_vs_src(struct r300_vs_asm* assembler, - struct tgsi_src_register* src) -{ - switch (src->File) { - case TGSI_FILE_NULL: - return 0; - case TGSI_FILE_INPUT: - /* XXX may be wrong */ - return src->Index; - break; - case TGSI_FILE_TEMPORARY: - return src->Index + assembler->temp_offset; - break; - case TGSI_FILE_IMMEDIATE: - return (src->Index + assembler->imm_offset) | (1 << 8); - break; - case TGSI_FILE_CONSTANT: - /* XXX magic */ - return src->Index | (1 << 8); - break; - default: - debug_printf("r300: vs: Unimplemented src %d\n", src->File); - break; - } - return 0; -} - static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, struct tgsi_dst_register* dst) { switch (dst->File) { - case TGSI_FILE_NULL: - /* This happens during KIL instructions. */ - return 0; + case TGSI_FILE_TEMPORARY: + return dst->Index; break; case TGSI_FILE_OUTPUT: - return 0; - break; - case TGSI_FILE_TEMPORARY: - return dst->Index + assembler->temp_offset; + return assembler->tab[dst->Index]; break; default: debug_printf("r300: vs: Unimplemented dst %d\n", dst->File); @@ -161,7 +133,7 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, int i = vs->instruction_count; vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, &dst->DstRegister)) | - R300_PVS_DST_OFFSET(dst->DstRegister.Index); + R300_PVS_DST_OFFSET(r300_vs_dst(assembler, &dst->DstRegister)); switch (count) { case 3: vs->instructions[i].inst3 = @@ -265,6 +237,9 @@ void r300_translate_vertex_shader(struct r300_context* r300, "%d from user and %d from immediates\n", consts->count, consts->user_count, assembler->imm_count); + debug_printf("r300: vs: tab: %d %d %d %d\n", assembler->tab[0], + assembler->tab[1], assembler->tab[2], assembler->tab[3]); + tgsi_dump(vs->state.tokens); /* XXX finish r300 vertex shader dumper */ r300_vs_dump(vs); diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index ae8ff6c3147..75fe44aec50 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -87,10 +87,6 @@ struct r300_vs_asm { unsigned color_count; /* Number of texcoords. */ unsigned tex_count; - /* Offset for temporary registers. Inputs and temporaries have no - * distinguishing markings, so inputs start at 0 and the first usable - * temporary register is after all inputs. */ - unsigned temp_offset; /* Number of requested temporary registers. */ unsigned temp_count; /* Offset for immediate constants. Neither R300 nor R500 can do four @@ -99,6 +95,8 @@ struct r300_vs_asm { unsigned imm_offset; /* Number of immediate constants. */ unsigned imm_count; + /* Offsets into vertex output memory. */ + unsigned tab[16]; }; static struct r300_vertex_shader r300_passthrough_vertex_shader = { -- cgit v1.2.3 From 36ae0766b90a1545ea3d9381974602d8e6fe8642 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 5 Apr 2009 02:05:08 -0700 Subject: r300-gallium: vp: Moar. --- src/gallium/drivers/r300/r300_state_tcl.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index a00abfd02fd..0f9abb598f0 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -61,6 +61,10 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, struct tgsi_src_register* src) { switch (src->File) { + case TGSI_FILE_NULL: + /* Probably a zero or one swizzle */ + return R300_PVS_SRC_REG_INPUT; + break; case TGSI_FILE_INPUT: return R300_PVS_SRC_REG_INPUT; break; @@ -108,6 +112,19 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, return 0; } +static uint32_t r300_vs_op(unsigned op) +{ + switch (op) { + case TGSI_OPCODE_ADD: + case TGSI_OPCODE_MOV: + case TGSI_OPCODE_SWZ: + return R300_VE_ADD; + default: + break; + } + return 0; +} + static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) { if (reg->SrcRegister.Extended) { @@ -131,9 +148,10 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, unsigned count) { int i = vs->instruction_count; - vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) | + vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(r300_vs_op(op)) | R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, &dst->DstRegister)) | - R300_PVS_DST_OFFSET(r300_vs_dst(assembler, &dst->DstRegister)); + R300_PVS_DST_OFFSET(r300_vs_dst(assembler, &dst->DstRegister)) | + R300_PVS_DST_WE_XYZW; switch (count) { case 3: vs->instructions[i].inst3 = @@ -157,6 +175,7 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs, R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[0])); break; } + vs->instruction_count++; } static void r300_vs_instruction(struct r300_vertex_shader* vs, @@ -164,6 +183,11 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, struct tgsi_full_instruction* inst) { switch (inst->Instruction.Opcode) { + case TGSI_OPCODE_ADD: + r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], inst->Instruction.Opcode, + 2); + break; case TGSI_OPCODE_MOV: case TGSI_OPCODE_SWZ: inst->FullSrcRegisters[1] = r300_constant_zero; -- cgit v1.2.3 From 2d56d0839e6db0861131893d67fe23734800085a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 6 Apr 2009 15:51:27 +0100 Subject: r300-gallium: Skeleton for integrating into the python statetracker. --- src/gallium/winsys/drm/radeon/python/README | 15 + src/gallium/winsys/drm/radeon/python/SConscript | 33 ++ .../drm/radeon/python/radeon_hardpipe_winsys.c | 140 +++++ src/gallium/winsys/drm/radeon/python/xf86dri.c | 605 +++++++++++++++++++++ src/gallium/winsys/drm/radeon/python/xf86dri.h | 123 +++++ src/gallium/winsys/drm/radeon/python/xf86dristr.h | 389 +++++++++++++ 6 files changed, 1305 insertions(+) create mode 100644 src/gallium/winsys/drm/radeon/python/README create mode 100644 src/gallium/winsys/drm/radeon/python/SConscript create mode 100644 src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c create mode 100644 src/gallium/winsys/drm/radeon/python/xf86dri.c create mode 100644 src/gallium/winsys/drm/radeon/python/xf86dri.h create mode 100644 src/gallium/winsys/drm/radeon/python/xf86dristr.h (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/python/README b/src/gallium/winsys/drm/radeon/python/README new file mode 100644 index 00000000000..d9e49bce67b --- /dev/null +++ b/src/gallium/winsys/drm/radeon/python/README @@ -0,0 +1,15 @@ +Python bindings for the radeon gallium driver. + + +See gallium/src/gallium/state_trackers/python/README for more information. + + +Build as: + + scons debug=1 statetrackers=python winsys=drm/radeon/python + +Run as: + + export PYTHONPATH=$PWD/build/linux-x86-debug/gallium/winsys/drm/radeon/python:$PWD/build/linux-x86-debug/gallium/state_trackers/python + + python src/gallium/state_trackers/python/samples/tri.py diff --git a/src/gallium/winsys/drm/radeon/python/SConscript b/src/gallium/winsys/drm/radeon/python/SConscript new file mode 100644 index 00000000000..3200fd8d1b0 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/python/SConscript @@ -0,0 +1,33 @@ +import os.path + +Import('*') + +if env['platform'] == 'linux': + + env = env.Clone() + + env.Tool('python') + + env.ParseConfig('pkg-config --cflags --libs libdrm') + + env.Prepend(CPPPATH = [ + '#src/gallium/state_trackers/python', + '../core', + ]) + + drivers = [ + softpipe, + radeon, + trace, + ] + + sources = [ + 'radeon_hardpipe_winsys.c', + 'xf86dri.c', + ] + + env.SharedLibrary( + target ='_gallium', + source = sources, + LIBS = [pyst] + drivers + auxiliaries + env['LIBS'], + ) diff --git a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c b/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c new file mode 100644 index 00000000000..c3ec24aaf78 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c @@ -0,0 +1,140 @@ + /************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include +#include +#include + +#include +#include +#include + +#include "pipe/p_screen.h" +#include "pipe/p_context.h" + +#include "st_winsys.h" + +#include "radeon_winsys.h" + +#include "xf86dri.h" + + +/* XXX: Force init_gallium symbol to be linked */ +extern void init_gallium(void); +void (*force_init_gallium_linkage)(void) = &init_gallium; + + +static struct pipe_screen * +radeon_hardpipe_screen_create(void) +{ + Display *dpy; + Window rootWin; + XWindowAttributes winAttr; + int isCapable; + int screen; + char *driverName; + char *curBusID; + unsigned magic; + int ddxDriverMajor; + int ddxDriverMinor; + int ddxDriverPatch; + drm_handle_t sAreaOffset; + int ret; + int drmFD; + drm_context_t hHWContext; + XID id; + + dpy = XOpenDisplay(":0"); + if (!dpy) { + fprintf(stderr, "Open Display Failed\n"); + return NULL; + } + + screen = DefaultScreen(dpy); + rootWin = RootWindow(dpy, screen); + XGetWindowAttributes(dpy, rootWin, &winAttr); + + ret = uniDRIQueryDirectRenderingCapable(dpy, screen, &isCapable); + if (!ret || !isCapable) { + fprintf(stderr, "No DRI on this display:sceen\n"); + goto error; + } + + if (!uniDRIOpenConnection(dpy, screen, &sAreaOffset, + &curBusID)) { + fprintf(stderr, "Could not open DRI connection.\n"); + goto error; + } + + if (!uniDRIGetClientDriverName(dpy, screen, &ddxDriverMajor, + &ddxDriverMinor, &ddxDriverPatch, + &driverName)) { + fprintf(stderr, "Could not get DRI driver name.\n"); + goto error; + } + + if ((drmFD = drmOpen(NULL, curBusID)) < 0) { + perror("DRM Device could not be opened"); + goto error; + } + + drmGetMagic(drmFD, &magic); + if (!uniDRIAuthConnection(dpy, screen, magic)) { + fprintf(stderr, "Could not get X server to authenticate us.\n"); + goto error; + } + + if (!uniDRICreateContext(dpy, screen, winAttr.visual, + &id, &hHWContext)) { + fprintf(stderr, "Could not create DRI context.\n"); + goto error; + } + + /* FIXME: create a radeon pipe_screen from drmFD and hHWContext */ + + return NULL; + +error: + return NULL; +} + + +static struct pipe_context * +radeon_hardpipe_context_create(struct pipe_screen *screen) +{ + /* FIXME: create a radon pipe_context from screen */ + + return NULL; +} + + +const struct st_winsys st_hardpipe_winsys = { + &radeon_hardpipe_screen_create, + &radeon_hardpipe_context_create, +}; + diff --git a/src/gallium/winsys/drm/radeon/python/xf86dri.c b/src/gallium/winsys/drm/radeon/python/xf86dri.c new file mode 100644 index 00000000000..1736f1e54f8 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/python/xf86dri.c @@ -0,0 +1,605 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Jens Owen + * Rickard E. (Rik) Faith + * + */ + +/* THIS IS NOT AN X CONSORTIUM STANDARD */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define NEED_REPLIES +#include +#include +#include +#include "xf86dristr.h" + +static XExtensionInfo _xf86dri_info_data; +static XExtensionInfo *xf86dri_info = &_xf86dri_info_data; +static char xf86dri_extension_name[] = XF86DRINAME; + +#define uniDRICheckExtension(dpy,i,val) \ + XextCheckExtension (dpy, i, xf86dri_extension_name, val) + +/***************************************************************************** + * * + * private utility routines * + * * + *****************************************************************************/ + +static int close_display(Display * dpy, XExtCodes * extCodes); +static /* const */ XExtensionHooks xf86dri_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + close_display, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + +static +XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info, + xf86dri_extension_name, &xf86dri_extension_hooks, + 0, NULL) + + static XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info) + +/***************************************************************************** + * * + * public XFree86-DRI Extension routines * + * * + *****************************************************************************/ +#if 0 +#include +#define TRACE(msg) fprintf(stderr,"uniDRI%s\n", msg); +#else +#define TRACE(msg) +#endif + Bool uniDRIQueryExtension(dpy, event_basep, error_basep) + Display *dpy; + int *event_basep, *error_basep; +{ + XExtDisplayInfo *info = find_display(dpy); + + TRACE("QueryExtension..."); + if (XextHasExtension(info)) { + *event_basep = info->codes->first_event; + *error_basep = info->codes->first_error; + TRACE("QueryExtension... return True"); + return True; + } else { + TRACE("QueryExtension... return False"); + return False; + } +} + +Bool +uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) + Display *dpy; + int *majorVersion; + int *minorVersion; + int *patchVersion; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIQueryVersionReply rep; + xXF86DRIQueryVersionReq *req; + + TRACE("QueryVersion..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIQueryVersion, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIQueryVersion; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryVersion... return False"); + return False; + } + *majorVersion = rep.majorVersion; + *minorVersion = rep.minorVersion; + *patchVersion = rep.patchVersion; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryVersion... return True"); + return True; +} + +Bool +uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable) + Display *dpy; + int screen; + Bool *isCapable; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIQueryDirectRenderingCapableReply rep; + xXF86DRIQueryDirectRenderingCapableReq *req; + + TRACE("QueryDirectRenderingCapable..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIQueryDirectRenderingCapable, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIQueryDirectRenderingCapable; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryDirectRenderingCapable... return False"); + return False; + } + *isCapable = rep.isCapable; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryDirectRenderingCapable... return True"); + return True; +} + +Bool +uniDRIOpenConnection(dpy, screen, hSAREA, busIdString) + Display *dpy; + int screen; + drm_handle_t *hSAREA; + char **busIdString; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIOpenConnectionReply rep; + xXF86DRIOpenConnectionReq *req; + + TRACE("OpenConnection..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIOpenConnection, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIOpenConnection; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("OpenConnection... return False"); + return False; + } + + *hSAREA = rep.hSAREALow; +#ifdef LONG64 + if (sizeof(drm_handle_t) == 8) { + *hSAREA |= ((unsigned long)rep.hSAREAHigh) << 32; + } +#endif + if (rep.length) { + if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) { + _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("OpenConnection... return False"); + return False; + } + _XReadPad(dpy, *busIdString, rep.busIdStringLength); + } else { + *busIdString = NULL; + } + UnlockDisplay(dpy); + SyncHandle(); + TRACE("OpenConnection... return True"); + return True; +} + +Bool +uniDRIAuthConnection(dpy, screen, magic) + Display *dpy; + int screen; + drm_magic_t magic; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIAuthConnectionReq *req; + xXF86DRIAuthConnectionReply rep; + + TRACE("AuthConnection..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIAuthConnection, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIAuthConnection; + req->screen = screen; + req->magic = magic; + rep.authenticated = 0; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("AuthConnection... return False"); + return False; + } + UnlockDisplay(dpy); + SyncHandle(); + TRACE("AuthConnection... return True"); + return True; +} + +Bool +uniDRICloseConnection(dpy, screen) + Display *dpy; + int screen; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRICloseConnectionReq *req; + + TRACE("CloseConnection..."); + + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRICloseConnection, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRICloseConnection; + req->screen = screen; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CloseConnection... return True"); + return True; +} + +Bool +uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, + ddxDriverMinorVersion, ddxDriverPatchVersion, + clientDriverName) + Display *dpy; + int screen; + int *ddxDriverMajorVersion; + int *ddxDriverMinorVersion; + int *ddxDriverPatchVersion; + char **clientDriverName; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIGetClientDriverNameReply rep; + xXF86DRIGetClientDriverNameReq *req; + + TRACE("GetClientDriverName..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIGetClientDriverName, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIGetClientDriverName; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return False"); + return False; + } + + *ddxDriverMajorVersion = rep.ddxDriverMajorVersion; + *ddxDriverMinorVersion = rep.ddxDriverMinorVersion; + *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; + + if (rep.length) { + if (!(*clientDriverName = + (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) { + _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return False"); + return False; + } + _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); + } else { + *clientDriverName = NULL; + } + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return True"); + return True; +} + +Bool +uniDRICreateContextWithConfig(dpy, screen, configID, context, hHWContext) + Display *dpy; + int screen; + int configID; + XID *context; + drm_context_t *hHWContext; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRICreateContextReply rep; + xXF86DRICreateContextReq *req; + + TRACE("CreateContext..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRICreateContext, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRICreateContext; + req->visual = configID; + req->screen = screen; + *context = XAllocID(dpy); + req->context = *context; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateContext... return False"); + return False; + } + *hHWContext = rep.hHWContext; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateContext... return True"); + return True; +} + +Bool +uniDRICreateContext(dpy, screen, visual, context, hHWContext) + Display *dpy; + int screen; + Visual *visual; + XID *context; + drm_context_t *hHWContext; +{ + return uniDRICreateContextWithConfig(dpy, screen, visual->visualid, + context, hHWContext); +} + +Bool +uniDRIDestroyContext(Display * ndpy, int screen, XID context) +{ + Display *const dpy = (Display *) ndpy; + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIDestroyContextReq *req; + + TRACE("DestroyContext..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIDestroyContext, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIDestroyContext; + req->screen = screen; + req->context = context; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("DestroyContext... return True"); + return True; +} + +Bool +uniDRICreateDrawable(Display * ndpy, int screen, + Drawable drawable, drm_drawable_t * hHWDrawable) +{ + Display *const dpy = (Display *) ndpy; + XExtDisplayInfo *info = find_display(dpy); + xXF86DRICreateDrawableReply rep; + xXF86DRICreateDrawableReq *req; + + TRACE("CreateDrawable..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRICreateDrawable, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRICreateDrawable; + req->screen = screen; + req->drawable = drawable; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateDrawable... return False"); + return False; + } + *hHWDrawable = rep.hHWDrawable; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateDrawable... return True"); + return True; +} + +Bool +uniDRIDestroyDrawable(Display * ndpy, int screen, Drawable drawable) +{ + Display *const dpy = (Display *) ndpy; + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIDestroyDrawableReq *req; + + TRACE("DestroyDrawable..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIDestroyDrawable, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIDestroyDrawable; + req->screen = screen; + req->drawable = drawable; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("DestroyDrawable... return True"); + return True; +} + +Bool +uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, + unsigned int *index, unsigned int *stamp, + int *X, int *Y, int *W, int *H, + int *numClipRects, drm_clip_rect_t ** pClipRects, + int *backX, int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIGetDrawableInfoReply rep; + xXF86DRIGetDrawableInfoReq *req; + int total_rects; + + TRACE("GetDrawableInfo..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIGetDrawableInfo, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIGetDrawableInfo; + req->screen = screen; + req->drawable = drawable; + + if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return False"); + return False; + } + *index = rep.drawableTableIndex; + *stamp = rep.drawableTableStamp; + *X = (int)rep.drawableX; + *Y = (int)rep.drawableY; + *W = (int)rep.drawableWidth; + *H = (int)rep.drawableHeight; + *numClipRects = rep.numClipRects; + total_rects = *numClipRects; + + *backX = rep.backX; + *backY = rep.backY; + *numBackClipRects = rep.numBackClipRects; + total_rects += *numBackClipRects; + +#if 0 + /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks + * backwards compatibility (Because of the >> 2 shift) but the fix + * enables multi-threaded apps to work. + */ + if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - + SIZEOF(xGenericReply) + + total_rects * sizeof(drm_clip_rect_t)) + + 3) & ~3) >> 2)) { + _XEatData(dpy, rep.length); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return False"); + return False; + } +#endif + + if (*numClipRects) { + int len = sizeof(drm_clip_rect_t) * (*numClipRects); + + *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); + if (*pClipRects) + _XRead(dpy, (char *)*pClipRects, len); + } else { + *pClipRects = NULL; + } + + if (*numBackClipRects) { + int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); + + *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); + if (*pBackClipRects) + _XRead(dpy, (char *)*pBackClipRects, len); + } else { + *pBackClipRects = NULL; + } + + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return True"); + return True; +} + +Bool +uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer, + fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate) + Display *dpy; + int screen; + drm_handle_t *hFrameBuffer; + int *fbOrigin; + int *fbSize; + int *fbStride; + int *devPrivateSize; + void **pDevPrivate; +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIGetDeviceInfoReply rep; + xXF86DRIGetDeviceInfoReq *req; + + TRACE("GetDeviceInfo..."); + uniDRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIGetDeviceInfo, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIGetDeviceInfo; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return False"); + return False; + } + + *hFrameBuffer = rep.hFrameBufferLow; +#ifdef LONG64 + if (sizeof(drm_handle_t) == 8) { + *hFrameBuffer |= ((unsigned long)rep.hFrameBufferHigh) << 32; + } +#endif + + *fbOrigin = rep.framebufferOrigin; + *fbSize = rep.framebufferSize; + *fbStride = rep.framebufferStride; + *devPrivateSize = rep.devPrivateSize; + + if (rep.length) { + if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) { + _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return False"); + return False; + } + _XRead(dpy, (char *)*pDevPrivate, rep.devPrivateSize); + } else { + *pDevPrivate = NULL; + } + + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return True"); + return True; +} diff --git a/src/gallium/winsys/drm/radeon/python/xf86dri.h b/src/gallium/winsys/drm/radeon/python/xf86dri.h new file mode 100644 index 00000000000..bf6de37d9dd --- /dev/null +++ b/src/gallium/winsys/drm/radeon/python/xf86dri.h @@ -0,0 +1,123 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/** + * \file xf86dri.h + * Protocol numbers and function prototypes for DRI X protocol. + * + * \author Kevin E. Martin + * \author Jens Owen + * \author Rickard E. (Rik) Faith + */ + +#ifndef _XF86DRI_H_ +#define _XF86DRI_H_ + +#include +#include +#include + +#define X_XF86DRIQueryVersion 0 +#define X_XF86DRIQueryDirectRenderingCapable 1 +#define X_XF86DRIOpenConnection 2 +#define X_XF86DRICloseConnection 3 +#define X_XF86DRIGetClientDriverName 4 +#define X_XF86DRICreateContext 5 +#define X_XF86DRIDestroyContext 6 +#define X_XF86DRICreateDrawable 7 +#define X_XF86DRIDestroyDrawable 8 +#define X_XF86DRIGetDrawableInfo 9 +#define X_XF86DRIGetDeviceInfo 10 +#define X_XF86DRIAuthConnection 11 +#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ +#define X_XF86DRICloseFullScreen 13 /* Deprecated */ + +#define XF86DRINumberEvents 0 + +#define XF86DRIClientNotLocal 0 +#define XF86DRIOperationNotSupported 1 +#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) + +#ifndef _XF86DRI_SERVER_ + +_XFUNCPROTOBEGIN + Bool uniDRIQueryExtension(Display * dpy, int *event_base, + int *error_base); + +Bool uniDRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, + int *patchVersion); + +Bool uniDRIQueryDirectRenderingCapable(Display * dpy, int screen, + Bool * isCapable); + +Bool uniDRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, + char **busIDString); + +Bool uniDRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); + +Bool uniDRICloseConnection(Display * dpy, int screen); + +Bool uniDRIGetClientDriverName(Display * dpy, int screen, + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName); + +Bool uniDRICreateContext(Display * dpy, int screen, Visual * visual, + XID * ptr_to_returned_context_id, + drm_context_t * hHWContext); + +Bool uniDRICreateContextWithConfig(Display * dpy, int screen, int configID, + XID * ptr_to_returned_context_id, + drm_context_t * hHWContext); + +extern Bool uniDRIDestroyContext(Display * dpy, int screen, XID context_id); + +extern Bool uniDRICreateDrawable(Display * dpy, int screen, + Drawable drawable, + drm_drawable_t * hHWDrawable); + +extern Bool uniDRIDestroyDrawable(Display * dpy, int screen, + Drawable drawable); + +Bool uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, + unsigned int *index, unsigned int *stamp, + int *X, int *Y, int *W, int *H, + int *numClipRects, drm_clip_rect_t ** pClipRects, + int *backX, int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects); + +Bool uniDRIGetDeviceInfo(Display * dpy, int screen, + drm_handle_t * hFrameBuffer, int *fbOrigin, + int *fbSize, int *fbStride, int *devPrivateSize, + void **pDevPrivate); + +_XFUNCPROTOEND +#endif /* _XF86DRI_SERVER_ */ +#endif /* _XF86DRI_H_ */ diff --git a/src/gallium/winsys/drm/radeon/python/xf86dristr.h b/src/gallium/winsys/drm/radeon/python/xf86dristr.h new file mode 100644 index 00000000000..d8989963609 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/python/xf86dristr.h @@ -0,0 +1,389 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Jens Owen + * Rickard E. (Rik) Fiath + * + */ + +#ifndef _XF86DRISTR_H_ +#define _XF86DRISTR_H_ + +#include "xf86dri.h" + +#define XF86DRINAME "XFree86-DRI" + +/* The DRI version number. This was originally set to be the same of the + * XFree86 version number. However, this version is really indepedent of + * the XFree86 version. + * + * Version History: + * 4.0.0: Original + * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02 + * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02 + */ +#define XF86DRI_MAJOR_VERSION 4 +#define XF86DRI_MINOR_VERSION 1 +#define XF86DRI_PATCH_VERSION 0 + +typedef struct _XF86DRIQueryVersion +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIQueryVersion */ + CARD16 length B16; +} xXF86DRIQueryVersionReq; + +#define sz_xXF86DRIQueryVersionReq 4 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD16 majorVersion B16; /* major version of DRI protocol */ + CARD16 minorVersion B16; /* minor version of DRI protocol */ + CARD32 patchVersion B32; /* patch version of DRI protocol */ + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIQueryVersionReply; + +#define sz_xXF86DRIQueryVersionReply 32 + +typedef struct _XF86DRIQueryDirectRenderingCapable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIQueryDirectRenderingCapableReq; + +#define sz_xXF86DRIQueryDirectRenderingCapableReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + BOOL isCapable; + BOOL pad2; + BOOL pad3; + BOOL pad4; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; + CARD32 pad9 B32; +} xXF86DRIQueryDirectRenderingCapableReply; + +#define sz_xXF86DRIQueryDirectRenderingCapableReply 32 + +typedef struct _XF86DRIOpenConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIOpenConnection */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIOpenConnectionReq; + +#define sz_xXF86DRIOpenConnectionReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hSAREALow B32; + CARD32 hSAREAHigh B32; + CARD32 busIdStringLength B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; +} xXF86DRIOpenConnectionReply; + +#define sz_xXF86DRIOpenConnectionReply 32 + +typedef struct _XF86DRIAuthConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseConnection */ + CARD16 length B16; + CARD32 screen B32; + CARD32 magic B32; +} xXF86DRIAuthConnectionReq; + +#define sz_xXF86DRIAuthConnectionReq 12 + +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 authenticated B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIAuthConnectionReply; + +#define zx_xXF86DRIAuthConnectionReply 32 + +typedef struct _XF86DRICloseConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseConnection */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRICloseConnectionReq; + +#define sz_xXF86DRICloseConnectionReq 8 + +typedef struct _XF86DRIGetClientDriverName +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIGetClientDriverName */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIGetClientDriverNameReq; + +#define sz_xXF86DRIGetClientDriverNameReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 ddxDriverMajorVersion B32; + CARD32 ddxDriverMinorVersion B32; + CARD32 ddxDriverPatchVersion B32; + CARD32 clientDriverNameLength B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIGetClientDriverNameReply; + +#define sz_xXF86DRIGetClientDriverNameReply 32 + +typedef struct _XF86DRICreateContext +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICreateContext */ + CARD16 length B16; + CARD32 screen B32; + CARD32 visual B32; + CARD32 context B32; +} xXF86DRICreateContextReq; + +#define sz_xXF86DRICreateContextReq 16 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hHWContext B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRICreateContextReply; + +#define sz_xXF86DRICreateContextReply 32 + +typedef struct _XF86DRIDestroyContext +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIDestroyContext */ + CARD16 length B16; + CARD32 screen B32; + CARD32 context B32; +} xXF86DRIDestroyContextReq; + +#define sz_xXF86DRIDestroyContextReq 12 + +typedef struct _XF86DRICreateDrawable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICreateDrawable */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRICreateDrawableReq; + +#define sz_xXF86DRICreateDrawableReq 12 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hHWDrawable B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRICreateDrawableReply; + +#define sz_xXF86DRICreateDrawableReply 32 + +typedef struct _XF86DRIDestroyDrawable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIDestroyDrawable */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRIDestroyDrawableReq; + +#define sz_xXF86DRIDestroyDrawableReq 12 + +typedef struct _XF86DRIGetDrawableInfo +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIGetDrawableInfo */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRIGetDrawableInfoReq; + +#define sz_xXF86DRIGetDrawableInfoReq 12 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 drawableTableIndex B32; + CARD32 drawableTableStamp B32; + INT16 drawableX B16; + INT16 drawableY B16; + INT16 drawableWidth B16; + INT16 drawableHeight B16; + CARD32 numClipRects B32; + INT16 backX B16; + INT16 backY B16; + CARD32 numBackClipRects B32; +} xXF86DRIGetDrawableInfoReply; + +#define sz_xXF86DRIGetDrawableInfoReply 36 + +typedef struct _XF86DRIGetDeviceInfo +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIGetDeviceInfo */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIGetDeviceInfoReq; + +#define sz_xXF86DRIGetDeviceInfoReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hFrameBufferLow B32; + CARD32 hFrameBufferHigh B32; + CARD32 framebufferOrigin B32; + CARD32 framebufferSize B32; + CARD32 framebufferStride B32; + CARD32 devPrivateSize B32; +} xXF86DRIGetDeviceInfoReply; + +#define sz_xXF86DRIGetDeviceInfoReply 32 + +typedef struct _XF86DRIOpenFullScreen +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIOpenFullScreen */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRIOpenFullScreenReq; + +#define sz_xXF86DRIOpenFullScreenReq 12 + +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 isFullScreen B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIOpenFullScreenReply; + +#define sz_xXF86DRIOpenFullScreenReply 32 + +typedef struct _XF86DRICloseFullScreen +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseFullScreen */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRICloseFullScreenReq; + +#define sz_xXF86DRICloseFullScreenReq 12 + +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; +} xXF86DRICloseFullScreenReply; + +#define sz_xXF86DRICloseFullScreenReply 32 + +#endif /* _XF86DRISTR_H_ */ -- cgit v1.2.3 From f4d744af24e07103f0f297b485f3dbca1fb7bc3b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 6 Apr 2009 15:31:58 -0600 Subject: softpipe: clean up the buffer clear and tile cache code a little --- src/gallium/drivers/softpipe/sp_clear.c | 5 +-- src/gallium/drivers/softpipe/sp_tile_cache.c | 46 ++++++---------------------- src/gallium/drivers/softpipe/sp_tile_cache.h | 3 +- 3 files changed, 15 insertions(+), 39 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index f72c6c63e76..fa59277438c 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -65,7 +65,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, struct pipe_surface *ps = softpipe->framebuffer.cbufs[i]; util_pack_color(rgba, ps->format, &cv); - sp_tile_cache_clear(softpipe->cbuf_cache[i], cv); + sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, cv); #if !TILE_CLEAR_OPTIMIZATION /* non-cached surface */ @@ -75,10 +75,11 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, } if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { + static const float zero[4] = { 0.0F, 0.0F, 0.0F, 0.0F }; struct pipe_surface *ps = softpipe->framebuffer.zsbuf; cv = util_pack_z_stencil(ps->format, depth, stencil); - sp_tile_cache_clear(softpipe->zsbuf_cache, cv); + sp_tile_cache_clear(softpipe->zsbuf_cache, zero, cv); #if !TILE_CLEAR_OPTIMIZATION /* non-cached surface */ diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index fd1097f41c9..1f9b8f1f4fb 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -57,9 +57,9 @@ struct softpipe_tile_cache struct pipe_texture *texture; /**< if caching a texture */ struct softpipe_cached_tile entries[NUM_ENTRIES]; uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32]; - float clear_color[4]; - uint clear_val; - boolean depth_stencil; /** Is the surface a depth/stencil format? */ + float clear_color[4]; /**< for color bufs */ + uint clear_val; /**< for z+stencil, or packed color clear value */ + boolean depth_stencil; /**< Is the surface a depth/stencil format? */ struct pipe_transfer *tex_trans; void *tex_trans_map; @@ -599,43 +599,17 @@ sp_get_cached_tile_tex(struct softpipe_context *sp, * Save the color and set a 'clearflag' for each tile of the screen. */ void -sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue) +sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba, + uint clearValue) { - uint r, g, b, a; uint pos; - tc->clear_val = clearValue; - - switch (tc->transfer->format) { - case PIPE_FORMAT_R8G8B8A8_UNORM: - case PIPE_FORMAT_R8G8B8X8_UNORM: - r = (clearValue >> 24) & 0xff; - g = (clearValue >> 16) & 0xff; - b = (clearValue >> 8) & 0xff; - a = (clearValue ) & 0xff; - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: - r = (clearValue >> 16) & 0xff; - g = (clearValue >> 8) & 0xff; - b = (clearValue ) & 0xff; - a = (clearValue >> 24) & 0xff; - break; - case PIPE_FORMAT_B8G8R8A8_UNORM: - case PIPE_FORMAT_B8G8R8X8_UNORM: - r = (clearValue >> 8) & 0xff; - g = (clearValue >> 16) & 0xff; - b = (clearValue >> 24) & 0xff; - a = (clearValue ) & 0xff; - break; - default: - r = g = b = a = 0; - } + tc->clear_color[0] = rgba[0]; + tc->clear_color[1] = rgba[1]; + tc->clear_color[2] = rgba[2]; + tc->clear_color[3] = rgba[3]; - tc->clear_color[0] = r / 255.0f; - tc->clear_color[1] = g / 255.0f; - tc->clear_color[2] = b / 255.0f; - tc->clear_color[3] = a / 255.0f; + tc->clear_val = clearValue; #if TILE_CLEAR_OPTIMIZATION /* set flags to indicate all the tiles are cleared */ diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h index 9ac3fdda948..8f247d0e580 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tile_cache.h @@ -89,7 +89,8 @@ sp_flush_tile_cache(struct softpipe_context *softpipe, struct softpipe_tile_cache *tc); extern void -sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue); +sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba, + uint clearValue); extern struct softpipe_cached_tile * sp_get_cached_tile(struct softpipe_context *softpipe, -- cgit v1.2.3 From b4c0e1f9e16ba61acd781ed6cbe448460e2b3153 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 6 Apr 2009 23:09:02 +0100 Subject: stw: Choose a color buffer format that matches the visual. The massive ifs are ugly, but it's not worth to automate this for just a handful of formats. Fixes conform bcolor.c. --- .../state_trackers/wgl/shared/stw_framebuffer.c | 42 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 4641884f950..c289a8aeffc 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -69,6 +69,14 @@ window_proc( return CallWindowProc( fb->WndProc, hWnd, uMsg, wParam, lParam ); } +static INLINE boolean +stw_is_supported_color(enum pipe_format format) +{ + struct pipe_screen *screen = stw_dev->screen; + return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); +} + static INLINE boolean stw_is_supported_depth_stencil(enum pipe_format format) { @@ -89,13 +97,33 @@ framebuffer_create( struct stw_framebuffer *fb; enum pipe_format colorFormat, depthFormat, stencilFormat; - fb = CALLOC_STRUCT( stw_framebuffer ); - if (fb == NULL) - return NULL; - /* Determine PIPE_FORMATs for buffers. */ - colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + + if(visual->alphaBits <= 0 && visual->redBits <= 5 && visual->blueBits <= 6 && visual->greenBits <= 5 && + stw_is_supported_color(PIPE_FORMAT_R5G6B5_UNORM)) { + colorFormat = PIPE_FORMAT_R5G6B5_UNORM; + } + else if(visual->alphaBits <= 0 && visual->redBits <= 8 && visual->blueBits <= 8 && visual->greenBits <= 8 && + stw_is_supported_color(PIPE_FORMAT_X8R8G8B8_UNORM)) { + colorFormat = PIPE_FORMAT_X8R8G8B8_UNORM; + } + else if(visual->alphaBits <= 1 && visual->redBits <= 5 && visual->blueBits <= 5 && visual->greenBits <= 5 && + stw_is_supported_color(PIPE_FORMAT_A1R5G5B5_UNORM)) { + colorFormat = PIPE_FORMAT_A1R5G5B5_UNORM; + } + else if(visual->alphaBits <= 4 && visual->redBits <= 4 && visual->blueBits <= 4 && visual->greenBits <= 4 && + stw_is_supported_color(PIPE_FORMAT_A4R4G4B4_UNORM)) { + colorFormat = PIPE_FORMAT_A4R4G4B4_UNORM; + } + else if(visual->alphaBits <= 8 && visual->redBits <= 8 && visual->blueBits <= 8 && visual->greenBits <= 8 && + stw_is_supported_color(PIPE_FORMAT_A8R8G8B8_UNORM)) { + colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + } + else { + assert(0); + return NULL; + } if (visual->depthBits == 0) depthFormat = PIPE_FORMAT_NONE; @@ -141,6 +169,10 @@ framebuffer_create( stencilFormat = PIPE_FORMAT_NONE; } + fb = CALLOC_STRUCT( stw_framebuffer ); + if (fb == NULL) + return NULL; + fb->stfb = st_create_framebuffer( visual, colorFormat, -- cgit v1.2.3 From ffbf3f4952fa9e7c2971a73d9540ed977fdc6c9a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 6 Apr 2009 23:17:33 -0700 Subject: r300-gallium: Properly setup HW/SW TCL controls. This keeps non-TCL chipsets from locking up, and also fully unbreaks RADEON_NO_TCL rendering. --- src/gallium/drivers/r300/r300_state.c | 21 ++++++++++----------- src/gallium/drivers/r300/r300_surface.c | 3 ++- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 095df04630f..2a77fd17390 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -338,11 +338,17 @@ static void* r300_create_rs_state(struct pipe_context* pipe, { struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); - /* XXX endian control */ - if (r300_screen(pipe->screen)->caps->has_tcl) { - rs->vap_control_status = 0; - } else { + /* Copy rasterizer state for Draw. */ + rs->rs = *state; + + /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL. + * Else, enable HW TCL and force Draw's TCL off. */ + if (state->bypass_vs_clip_and_viewport || + !r300_screen(pipe->screen)->caps->has_tcl) { rs->vap_control_status = R300_VAP_TCL_BYPASS; + } else { + rs->rs.bypass_vs_clip_and_viewport = TRUE; + rs->vap_control_status = 0; } rs->point_size = pack_float_16_6x(state->point_size) | @@ -406,13 +412,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->color_control = R300_SHADE_MODEL_SMOOTH; } - rs->rs = *state; - - /* If using HW TCL, tell Draw to not do its magic. */ - if (r300_screen(pipe->screen)->caps->has_tcl) { - rs->rs.bypass_vs_clip_and_viewport = TRUE; - } - return (void*)rs; } diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index dc4b29eb40a..6bc39954b71 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -109,7 +109,8 @@ static void r300_surface_fill(struct pipe_context* pipe, if (caps->has_tcl) { r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader); } else { - BEGIN_CS(2); + BEGIN_CS(4); + OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VAP_TCL_BYPASS); OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | R300_PVS_NUM_CNTLRS(5) | R300_PVS_NUM_FPUS(caps->num_vert_fpus) | -- cgit v1.2.3 From 6a1be41af93ef0ad835c75b993603c54917f934d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 6 Apr 2009 23:25:27 -0700 Subject: r300-gallium: Fix surface_copy too. --- src/gallium/drivers/r300/r300_surface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 6bc39954b71..79bed032538 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -228,7 +228,8 @@ static void r300_surface_copy(struct pipe_context* pipe, if (caps->has_tcl) { r300_emit_vertex_shader(r300, &r300_texture_vertex_shader); } else { - BEGIN_CS(2); + BEGIN_CS(4); + OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VAP_TCL_BYPASS); OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | R300_PVS_NUM_CNTLRS(5) | R300_PVS_NUM_FPUS(caps->num_vert_fpus) | -- cgit v1.2.3 From 00bb3deed24bd721686d6db45506fffb2a442dc9 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 6 Apr 2009 23:26:38 -0700 Subject: r300-gallium: vs: Add MUL. --- src/gallium/drivers/r300/r300_state_tcl.c | 3 +++ src/gallium/drivers/r300/r300_state_tcl.h | 1 + 2 files changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 0f9abb598f0..24e522ce8be 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -115,6 +115,8 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler, static uint32_t r300_vs_op(unsigned op) { switch (op) { + case TGSI_OPCODE_MUL: + return R300_VE_MULTIPLY; case TGSI_OPCODE_ADD: case TGSI_OPCODE_MOV: case TGSI_OPCODE_SWZ: @@ -184,6 +186,7 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, { switch (inst->Instruction.Opcode) { case TGSI_OPCODE_ADD: + case TGSI_OPCODE_MUL: r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 2); diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index 75fe44aec50..cbad1c31fdb 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -32,6 +32,7 @@ /* XXX get these to r300_reg */ #define R300_PVS_DST_OPCODE(x) ((x) << 0) +# define R300_VE_MULTIPLY 2 # define R300_VE_ADD 3 #define R300_PVS_DST_REG_TYPE(x) ((x) << 8) # define R300_PVS_DST_REG_TEMPORARY 0 -- cgit v1.2.3 From 799f43f2e01be8b3143c44fbd45485220174febd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 6 Apr 2009 23:36:34 -0700 Subject: r300-gallium: vs: Add MAD. --- src/gallium/drivers/r300/r300_state_tcl.c | 7 +++++++ src/gallium/drivers/r300/r300_state_tcl.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 24e522ce8be..44365f563c4 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -121,6 +121,8 @@ static uint32_t r300_vs_op(unsigned op) case TGSI_OPCODE_MOV: case TGSI_OPCODE_SWZ: return R300_VE_ADD; + case TGSI_OPCODE_MAD: + return R300_PVS_DST_MACRO_INST | R300_PVS_MACRO_OP_2CLK_MADD; default: break; } @@ -198,6 +200,11 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 2); break; + case TGSI_OPCODE_MAD: + r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], inst->Instruction.Opcode, + 3); + break; case TGSI_OPCODE_END: break; default: diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index cbad1c31fdb..3d10e248e15 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -34,6 +34,8 @@ #define R300_PVS_DST_OPCODE(x) ((x) << 0) # define R300_VE_MULTIPLY 2 # define R300_VE_ADD 3 +#define R300_PVS_DST_MACRO_INST (1 << 7) +# define R300_PVS_MACRO_OP_2CLK_MADD 0 #define R300_PVS_DST_REG_TYPE(x) ((x) << 8) # define R300_PVS_DST_REG_TEMPORARY 0 # define R300_PVS_DST_REG_A0 1 -- cgit v1.2.3 From fbcd78b5d1b649640454e0ed7ac8af340457f86b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Apr 2009 17:31:49 -0600 Subject: softpipe: minor debug-help changes in softpipe_transfer_map() --- src/gallium/drivers/softpipe/sp_texture.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index e3c577c2494..c0113c47adb 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -327,7 +327,7 @@ static void * softpipe_transfer_map( struct pipe_screen *screen, struct pipe_transfer *transfer ) { - ubyte *map; + ubyte *map, *xfer_map; struct softpipe_texture *spt; unsigned flags = 0; @@ -357,9 +357,11 @@ softpipe_transfer_map( struct pipe_screen *screen, softpipe_screen(screen)->timestamp++; } - return map + softpipe_transfer(transfer)->offset + + xfer_map = map + softpipe_transfer(transfer)->offset + transfer->y / transfer->block.height * transfer->stride + transfer->x / transfer->block.width * transfer->block.size; + /*printf("map = %p xfer map = %p\n", map, xfer_map);*/ + return xfer_map; } -- cgit v1.2.3 From a3277c542b40169684778122a8b6e1cdfb1f9f92 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 8 Apr 2009 08:23:01 -0600 Subject: gallium: handle the case of util_pack_z_stencil(format=PIPE_FORMAT_S8_UNORM) Fixes failed assertion in glean fbo test. --- src/gallium/auxiliary/util/u_pack_color.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 4ec7aee192b..eda883b3b92 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -434,6 +434,9 @@ util_pack_z(enum pipe_format format, double z) if (z == 1.0) return 0xffffff00; return ((uint) (z * 0xffffff)) << 8; + case PIPE_FORMAT_S8_UNORM: + /* this case can get it via util_pack_z_stencil() */ + return 0; default: debug_print_format("gallium: unhandled format in util_pack_z()", format); assert(0); @@ -443,6 +446,7 @@ util_pack_z(enum pipe_format format, double z) /** + * Pack Z and/or stencil values into a 32-bit value described by format. * Note: it's assumed that z is in [0,1] and s in [0,255] */ static INLINE uint @@ -456,6 +460,10 @@ util_pack_z_stencil(enum pipe_format format, double z, uint s) break; case PIPE_FORMAT_Z24S8_UNORM: packed |= s; + break; + case PIPE_FORMAT_S8_UNORM: + packed |= s; + break; default: break; } -- cgit v1.2.3 From 7000b9d74a4b9690c236ee40ddbeba1f24df1ab4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:23:48 +0100 Subject: trace: Match pipe_context::clear prototype. --- src/gallium/drivers/trace/tr_context.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 6e86a5dfddf..d50d872a777 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -973,7 +973,7 @@ trace_context_surface_fill(struct pipe_context *_pipe, static INLINE void trace_context_clear(struct pipe_context *_pipe, - unsigned surfaces, + unsigned buffers, const float *rgba, double depth, unsigned stencil) @@ -984,15 +984,12 @@ trace_context_clear(struct pipe_context *_pipe, trace_dump_call_begin("pipe_context", "clear"); trace_dump_arg(ptr, pipe); - trace_dump_arg(uint, surfaces); - trace_dump_arg(float, rgba[0]); - trace_dump_arg(float, rgba[1]); - trace_dump_arg(float, rgba[2]); - trace_dump_arg(float, rgba[3]); + trace_dump_arg(uint, buffers); + trace_dump_arg_array(float, rgba, 4); trace_dump_arg(float, depth); trace_dump_arg(uint, stencil); - pipe->clear(pipe, surfaces, rgba, depth, stencil); + pipe->clear(pipe, buffers, rgba, depth, stencil); trace_dump_call_end(); } -- cgit v1.2.3 From 927eb8fe4cc8a5ed583aad1dafa98d091d7602f4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:29:50 +0100 Subject: trace: Simplify cast wrappers. --- src/gallium/drivers/trace/tr_context.c | 8 ++------ src/gallium/drivers/trace/tr_dump.c | 11 +++-------- src/gallium/drivers/trace/tr_screen.c | 29 ++++++++++++----------------- src/gallium/drivers/trace/tr_texture.c | 12 +++--------- src/gallium/drivers/trace/tr_texture.h | 27 +++++++++------------------ 5 files changed, 29 insertions(+), 58 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index d50d872a777..d8d5821a1d1 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -58,16 +58,14 @@ static INLINE struct pipe_texture * trace_texture_unwrap(struct trace_context *tr_ctx, struct pipe_texture *texture) { - struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); struct trace_texture *tr_tex; if(!texture) return NULL; - tr_tex = trace_texture(tr_scr, texture); + tr_tex = trace_texture(texture); assert(tr_tex->texture); - assert(tr_tex->texture->screen == tr_scr->screen); return tr_tex->texture; } @@ -77,7 +75,6 @@ trace_surface_unwrap(struct trace_context *tr_ctx, struct pipe_surface *surface) { struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); - struct trace_texture *tr_tex; struct trace_surface *tr_surf; if(!surface) @@ -87,8 +84,7 @@ trace_surface_unwrap(struct trace_context *tr_ctx, if(!surface->texture) return surface; - tr_tex = trace_texture(tr_scr, surface->texture); - tr_surf = trace_surface(tr_tex, surface); + tr_surf = trace_surface(surface); assert(tr_surf->surface); assert(tr_surf->surface->texture->screen == tr_scr->screen); diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index 97872be784d..314e4fa350b 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -428,8 +428,7 @@ void trace_dump_buffer_ptr(struct pipe_buffer *_buffer) void trace_dump_texture_ptr(struct pipe_texture *_texture) { if (_texture) { - struct trace_screen *tr_scr = trace_screen(_texture->screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _texture); + struct trace_texture *tr_tex = trace_texture(_texture); trace_dump_ptr(tr_tex->texture); } else { trace_dump_null(); @@ -439,9 +438,7 @@ void trace_dump_texture_ptr(struct pipe_texture *_texture) void trace_dump_surface_ptr(struct pipe_surface *_surface) { if (_surface) { - struct trace_screen *tr_scr = trace_screen(_surface->texture->screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture); - struct trace_surface *tr_surf = trace_surface(tr_tex, _surface); + struct trace_surface *tr_surf = trace_surface(_surface); trace_dump_ptr(tr_surf->surface); } else { trace_dump_null(); @@ -451,9 +448,7 @@ void trace_dump_surface_ptr(struct pipe_surface *_surface) void trace_dump_transfer_ptr(struct pipe_transfer *_transfer) { if (_transfer) { - struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture); - struct trace_transfer *tr_tran = trace_transfer(tr_tex, _transfer); + struct trace_transfer *tr_tran = trace_transfer(_transfer); trace_dump_ptr(tr_tran->transfer); } else { trace_dump_null(); diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index c83ec4e30e6..67925053833 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -159,8 +159,7 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen, void *context_private) { struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture); - struct trace_surface *tr_surf = trace_surface(tr_tex, _surface); + struct trace_surface *tr_surf = trace_surface(_surface); struct pipe_screen *screen = tr_scr->screen; struct pipe_surface *surface = tr_surf->surface; @@ -242,7 +241,7 @@ static void trace_screen_texture_destroy(struct pipe_texture *_texture) { struct trace_screen *tr_scr = trace_screen(_texture->screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _texture); + struct trace_texture *tr_tex = trace_texture(_texture); struct pipe_screen *screen = tr_scr->screen; struct pipe_texture *texture = tr_tex->texture; @@ -255,7 +254,7 @@ trace_screen_texture_destroy(struct pipe_texture *_texture) trace_dump_call_end(); - trace_texture_destroy(tr_scr, _texture); + trace_texture_destroy(tr_tex); } @@ -272,7 +271,7 @@ trace_screen_get_tex_surface(struct pipe_screen *_screen, unsigned usage) { struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _texture); + struct trace_texture *tr_tex = trace_texture(_texture); struct pipe_screen *screen = tr_scr->screen; struct pipe_texture *texture = tr_tex->texture; struct pipe_surface *result = NULL; @@ -304,8 +303,7 @@ static void trace_screen_tex_surface_destroy(struct pipe_surface *_surface) { struct trace_screen *tr_scr = trace_screen(_surface->texture->screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture); - struct trace_surface *tr_surf = trace_surface(tr_tex, _surface); + struct trace_surface *tr_surf = trace_surface(_surface); struct pipe_screen *screen = tr_scr->screen; struct pipe_surface *surface = tr_surf->surface; @@ -316,7 +314,7 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface) trace_dump_call_end(); - trace_surface_destroy(tr_tex, _surface); + trace_surface_destroy(tr_surf); } @@ -334,7 +332,7 @@ trace_screen_get_tex_transfer(struct pipe_screen *_screen, unsigned x, unsigned y, unsigned w, unsigned h) { struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _texture); + struct trace_texture *tr_tex = trace_texture(_texture); struct pipe_screen *screen = tr_scr->screen; struct pipe_texture *texture = tr_tex->texture; struct pipe_transfer *result = NULL; @@ -372,10 +370,9 @@ static void trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer) { struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture); - struct trace_transfer *tr_tran = trace_transfer(tr_tex, _transfer); + struct trace_transfer *tr_trans = trace_transfer(_transfer); struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_tran->transfer; + struct pipe_transfer *transfer = tr_trans->transfer; trace_dump_call_begin("pipe_screen", "tex_transfer_destroy"); @@ -384,7 +381,7 @@ trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer) trace_dump_call_end(); - trace_transfer_destroy(tr_tex, _transfer); + trace_transfer_destroy(tr_trans); } @@ -393,8 +390,7 @@ trace_screen_transfer_map(struct pipe_screen *_screen, struct pipe_transfer *_transfer) { struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture); - struct trace_transfer *tr_trans = trace_transfer(tr_tex, _transfer); + struct trace_transfer *tr_trans = trace_transfer(_transfer); struct pipe_screen *screen = tr_scr->screen; struct pipe_transfer *transfer = tr_trans->transfer; void *map; @@ -416,8 +412,7 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen, struct pipe_transfer *_transfer) { struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture); - struct trace_transfer *tr_trans = trace_transfer(tr_tex, _transfer); + struct trace_transfer *tr_trans = trace_transfer(_transfer); struct pipe_screen *screen = tr_scr->screen; struct pipe_transfer *transfer = tr_trans->transfer; diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c index 7b392f07286..f4e433792b1 100644 --- a/src/gallium/drivers/trace/tr_texture.c +++ b/src/gallium/drivers/trace/tr_texture.c @@ -62,10 +62,8 @@ error: void -trace_texture_destroy(struct trace_screen *tr_scr, - struct pipe_texture *texture) +trace_texture_destroy(struct trace_texture *tr_tex) { - struct trace_texture *tr_tex = trace_texture(tr_scr, texture); pipe_texture_reference(&tr_tex->texture, NULL); FREE(tr_tex); } @@ -102,10 +100,8 @@ error: void -trace_surface_destroy(struct trace_texture *tr_tex, - struct pipe_surface *surface) +trace_surface_destroy(struct trace_surface *tr_surf) { - struct trace_surface *tr_surf = trace_surface(tr_tex, surface); pipe_texture_reference(&tr_surf->base.texture, NULL); pipe_surface_reference(&tr_surf->surface, NULL); FREE(tr_surf); @@ -143,10 +139,8 @@ error: void -trace_transfer_destroy(struct trace_texture *tr_tex, - struct pipe_transfer *transfer) +trace_transfer_destroy(struct trace_transfer *tr_trans) { - struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer); struct pipe_screen *screen = tr_trans->transfer->texture->screen; pipe_texture_reference(&tr_trans->base.texture, NULL); screen->tex_transfer_destroy(tr_trans->transfer); diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h index 9c21bc7d276..14dafd8b2c3 100644 --- a/src/gallium/drivers/trace/tr_texture.h +++ b/src/gallium/drivers/trace/tr_texture.h @@ -62,37 +62,31 @@ struct trace_transfer static INLINE struct trace_texture * -trace_texture(struct trace_screen *tr_scr, - struct pipe_texture *texture) +trace_texture(struct pipe_texture *texture) { if(!texture) return NULL; - assert(tr_scr); - assert(texture->screen == &tr_scr->base); + (void)trace_screen(texture->screen); return (struct trace_texture *)texture; } static INLINE struct trace_surface * -trace_surface(struct trace_texture *tr_tex, - struct pipe_surface *surface) +trace_surface(struct pipe_surface *surface) { if(!surface) return NULL; - assert(tr_tex); - assert(surface->texture == &tr_tex->base); + (void)trace_texture(surface->texture); return (struct trace_surface *)surface; } static INLINE struct trace_transfer * -trace_transfer(struct trace_texture *tr_tex, - struct pipe_transfer *transfer) +trace_transfer(struct pipe_transfer *transfer) { if(!transfer) return NULL; - assert(tr_tex); - assert(transfer->texture == &tr_tex->base); + (void)trace_texture(transfer->texture); return (struct trace_transfer *)transfer; } @@ -102,24 +96,21 @@ trace_texture_create(struct trace_screen *tr_scr, struct pipe_texture *texture); void -trace_texture_destroy(struct trace_screen *tr_scr, - struct pipe_texture *texture); +trace_texture_destroy(struct trace_texture *tr_tex); struct pipe_surface * trace_surface_create(struct trace_texture *tr_tex, struct pipe_surface *surface); void -trace_surface_destroy(struct trace_texture *tr_tex, - struct pipe_surface *surface); +trace_surface_destroy(struct trace_surface *tr_surf); struct pipe_transfer * trace_transfer_create(struct trace_texture *tr_tex, struct pipe_transfer *transfer); void -trace_transfer_destroy(struct trace_texture *tr_tex, - struct pipe_transfer *transfer); +trace_transfer_destroy(struct trace_transfer *tr_trans); #endif /* TR_TEXTURE_H_ */ -- cgit v1.2.3 From 923b4413a63530be37cd44eed29910db21b39ac6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:30:31 +0100 Subject: wgl: Integrate the trace driver on debug builds. --- .../state_trackers/wgl/shared/stw_context.c | 23 ++++++++++++++++- src/gallium/state_trackers/wgl/shared/stw_device.c | 28 ++++++++++++++++++--- src/gallium/state_trackers/wgl/shared/stw_device.h | 5 ++++ .../state_trackers/wgl/shared/stw_framebuffer.c | 29 ++++++++++++++++------ src/gallium/winsys/gdi/SConscript | 1 + 5 files changed, 73 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 82aabe0a7ee..f890225242a 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -33,6 +33,12 @@ #include "pipe/p_context.h" #include "state_tracker/st_context.h" #include "state_tracker/st_public.h" + +#ifdef DEBUG +#include "trace/tr_screen.h" +#include "trace/tr_context.h" +#endif + #include "shared/stw_device.h" #include "shared/stw_winsys.h" #include "shared/stw_framebuffer.h" @@ -77,6 +83,7 @@ stw_create_layer_context( const struct pixelformat_info *pf = NULL; struct stw_context *ctx = NULL; GLvisual *visual = NULL; + struct pipe_screen *screen = NULL; struct pipe_context *pipe = NULL; UINT_PTR hglrc = 0; @@ -120,10 +127,24 @@ stw_create_layer_context( if (visual == NULL) goto fail; - pipe = stw_dev->stw_winsys->create_context( stw_dev->screen ); + screen = stw_dev->screen; + +#ifdef DEBUG + /* Unwrap screen */ + if(stw_dev->trace_running) + screen = trace_screen(screen)->screen; +#endif + + pipe = stw_dev->stw_winsys->create_context( screen ); if (pipe == NULL) goto fail; +#ifdef DEBUG + /* Wrap context */ + if(stw_dev->trace_running) + pipe = trace_context_create(stw_dev->screen, pipe); +#endif + assert(!pipe->priv); pipe->priv = hdc; diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index c5501727d4e..51936c2bdd6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -31,6 +31,11 @@ #include "util/u_debug.h" #include "pipe/p_screen.h" +#ifdef DEBUG +#include "trace/tr_screen.h" +#include "trace/tr_texture.h" +#endif + #include "shared/stw_device.h" #include "shared/stw_winsys.h" #include "shared/stw_pixelformat.h" @@ -52,13 +57,20 @@ struct stw_device *stw_dev = NULL; */ static void st_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, + struct pipe_surface *surface, void *context_private ) { const struct stw_winsys *stw_winsys = stw_dev->stw_winsys; HDC hdc = (HDC)context_private; - stw_winsys->flush_frontbuffer(screen, surf, hdc); +#ifdef DEBUG + if(stw_dev->trace_running) { + screen = trace_screen(screen)->screen; + surface = trace_surface(surface)->surface; + } +#endif + + stw_winsys->flush_frontbuffer(screen, surface, hdc); } @@ -66,6 +78,7 @@ boolean st_init(const struct stw_winsys *stw_winsys) { static struct stw_device stw_dev_storage; + struct pipe_screen *screen; debug_printf("%s\n", __FUNCTION__); @@ -86,10 +99,17 @@ st_init(const struct stw_winsys *stw_winsys) _glthread_INIT_MUTEX(OneTimeLock); #endif - stw_dev->screen = stw_winsys->create_screen(); - if(!stw_dev->screen) + screen = stw_winsys->create_screen(); + if(!screen) goto error1; +#ifdef DEBUG + stw_dev->screen = trace_screen_create(screen); + stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE; +#else + stw_dev->screen = screen; +#endif + stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer; pipe_mutex_init( stw_dev->mutex ); diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h index 6a9cee0d028..703cb670816 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.h +++ b/src/gallium/state_trackers/wgl/shared/stw_device.h @@ -39,8 +39,13 @@ struct pipe_screen; struct stw_device { const struct stw_winsys *stw_winsys; + struct pipe_screen *screen; +#ifdef DEBUG + boolean trace_running; +#endif + pipe_mutex mutex; struct handle_table *ctx_table; diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index c289a8aeffc..c96c4b8dfa8 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -32,6 +32,12 @@ #include "pipe/p_screen.h" #include "state_tracker/st_context.h" #include "state_tracker/st_public.h" + +#ifdef DEBUG +#include "trace/tr_screen.h" +#include "trace/tr_texture.h" +#endif + #include "stw_framebuffer.h" #include "stw_device.h" #include "stw_public.h" @@ -246,7 +252,8 @@ stw_swap_buffers( HDC hdc ) { struct stw_framebuffer *fb; - struct pipe_surface *surf; + struct pipe_screen *screen; + struct pipe_surface *surface; fb = framebuffer_from_hdc( hdc ); if (fb == NULL) @@ -257,14 +264,20 @@ stw_swap_buffers( */ st_notify_swapbuffers( fb->stfb ); - if(st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf )) { - stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen, - surf, - hdc ); - } - else { - /* FIXME: this shouldn't happen, but does on glean */ + screen = stw_dev->screen; + + if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surface )) + /* FIXME: this shouldn't happen, but does on glean */ + return FALSE; + +#ifdef DEBUG + if(stw_dev->trace_running) { + screen = trace_screen(screen)->screen; + surface = trace_surface(surface)->surface; } +#endif + stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc ); + return TRUE; } diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 42290d7603e..aabab95f3a8 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -27,6 +27,7 @@ if env['platform'] == 'windows': sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] drivers = [ + trace, softpipe, ] -- cgit v1.2.3 From 724929db3ca39ac63ca6f020b3f1faa31948f46b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:30:53 +0100 Subject: python: Cope with null surfaces. --- src/gallium/state_trackers/python/p_state.i | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i index fc8607ba72f..90f157e0ab0 100644 --- a/src/gallium/state_trackers/python/p_state.i +++ b/src/gallium/state_trackers/python/p_state.i @@ -66,9 +66,11 @@ if(index >= PIPE_MAX_COLOR_BUFS) SWIG_exception(SWIG_ValueError, "index out of bounds"); - _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE); - if(!_surface) - SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing"); + if(surface) { + _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_surface) + SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing"); + } pipe_surface_reference(&$self->cbufs[index], _surface); @@ -81,9 +83,11 @@ { struct pipe_surface *_surface = NULL; - _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE); - if(!_surface) - SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing"); + if(surface) { + _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_surface) + SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing"); + } pipe_surface_reference(&$self->zsbuf, _surface); -- cgit v1.2.3 From aaea658dbe6f0738aaa207d080e1ea73b8023029 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:32:08 +0100 Subject: python: Fix method renaming. --- src/gallium/state_trackers/python/p_texture.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 276fa795cce..f41a95e6eb0 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -398,8 +398,8 @@ struct st_surface %} /* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */ -%rename(read) pipe_buffer_read_; -%rename(write) pipe_buffer_write_; +%rename(read) read_; +%rename(write) write_; %extend pipe_buffer { -- cgit v1.2.3 From c14562d3b1e5d93d5704f3195a7f83fc5c17eddb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:36:17 +0100 Subject: python/retrace: Handle recent traces. Try to keep backwards compatability with old traces as much as possible. --- .../state_trackers/python/retrace/interpreter.py | 115 +++++++++++++++------ 1 file changed, 85 insertions(+), 30 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index d02099389fb..708937119f0 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -181,8 +181,12 @@ class Global(Object): def pipe_winsys_create(self): return Winsys(self.interpreter, gallium.Device()) - def pipe_screen_create(self, winsys): - return Screen(self.interpreter, winsys.real) + def pipe_screen_create(self, winsys=None): + if winsys is None: + real = gallium.Device() + else: + real = winsys.real + return Screen(self.interpreter, real) def pipe_context_create(self, screen): context = screen.real.context_create() @@ -234,6 +238,16 @@ class Winsys(Object): pass +class Transfer: + + def __init__(self, surface, x, y, w, h): + self.surface = surface + self.x = x + self.y = y + self.w = w + self.h = h + + class Screen(Object): def destroy(self): @@ -254,15 +268,15 @@ class Screen(Object): def is_format_supported(self, format, target, tex_usage, geom_flags): return self.real.is_format_supported(format, target, tex_usage, geom_flags) - def texture_create(self, template): + def texture_create(self, templat): return self.real.texture_create( - format = template.format, - width = template.width[0], - height = template.height[0], - depth = template.depth[0], - last_level = template.last_level, - target = template.target, - tex_usage = template.tex_usage, + format = templat.format, + width = templat.width[0], + height = templat.height[0], + depth = templat.depth[0], + last_level = templat.last_level, + target = templat.target, + tex_usage = templat.tex_usage, ) def texture_destroy(self, texture): @@ -284,6 +298,44 @@ class Screen(Object): assert surface.nblocksy * stride == size surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride) + def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h): + return Transfer(texture.get_surface(face, level, zslice), x, y, w, h) + + def tex_transfer_destroy(self, transfer): + self.interpreter.unregister_object(transfer) + + def transfer_write(self, transfer, stride, data, size): + transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride) + + def user_buffer_create(self, data, size): + # We don't really care to distinguish between user and regular buffers + buffer = self.real.buffer_create(size, + 4, + gallium.PIPE_BUFFER_USAGE_CPU_READ | + gallium.PIPE_BUFFER_USAGE_CPU_WRITE ) + assert size == len(data) + buffer.write(data) + return buffer + + def buffer_create(self, alignment, usage, size): + return self.real.buffer_create(size, alignment, usage) + + def buffer_destroy(self, buffer): + pass + + def buffer_write(self, buffer, data, size, offset=0): + assert size == len(data) + buffer.write(data) + + def fence_finish(self, fence, flags): + pass + + def fence_reference(self, dst, src): + pass + + def flush_frontbuffer(self, surface): + pass + class Context(Object): @@ -314,8 +366,8 @@ class Context(Object): def delete_sampler_state(self, state): pass - def bind_sampler_states(self, n, states): - for i in range(n): + def bind_sampler_states(self, num_states, states): + for i in range(num_states): self.real.set_sampler(i, states[i]) def create_rasterizer_state(self, state): @@ -383,11 +435,11 @@ class Context(Object): sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w)) index += 1 - def set_constant_buffer(self, shader, index, state): - if state is not None: - self.real.set_constant_buffer(shader, index, state.buffer) + def set_constant_buffer(self, shader, index, buffer): + if buffer is not None: + self.real.set_constant_buffer(shader, index, buffer.buffer) - self.dump_constant_buffer(state.buffer) + self.dump_constant_buffer(buffer.buffer) def set_framebuffer_state(self, state): _state = gallium.Framebuffer() @@ -411,14 +463,14 @@ class Context(Object): def set_viewport_state(self, state): self.real.set_viewport(state) - def set_sampler_textures(self, n, textures): - for i in range(n): + def set_sampler_textures(self, num_textures, textures): + for i in range(num_textures): self.real.set_sampler_texture(i, textures[i]) - def set_vertex_buffers(self, n, vbufs): - self.vbufs = vbufs[0:n] - for i in range(n): - vbuf = vbufs[i] + def set_vertex_buffers(self, num_buffers, buffers): + self.vbufs = buffers[0:num_buffers] + for i in range(num_buffers): + vbuf = buffers[i] self.real.set_vertex_buffer( i, stride = vbuf.stride, @@ -427,11 +479,11 @@ class Context(Object): buffer = vbuf.buffer, ) - def set_vertex_elements(self, n, elements): - self.velems = elements[0:n] - for i in range(n): + def set_vertex_elements(self, num_elements, elements): + self.velems = elements[0:num_elements] + for i in range(num_elements): self.real.set_vertex_element(i, elements[i]) - self.real.set_vertex_elements(n) + self.real.set_vertex_elements(num_elements) def set_edgeflags(self, bitfield): # FIXME @@ -532,7 +584,10 @@ class Context(Object): return None def clear(self, buffers, rgba, depth, stencil): - self.real.clear(buffers, rgba, depth, stencil) + _rgba = gallium.FloatArray(4) + for i in range(4): + _rgba[i] = rgba[i] + self.real.clear(buffers, _rgba, depth, stencil) def _present(self): self.real.flush() @@ -581,16 +636,16 @@ class Interpreter(parser.TraceDumper): if self.verbosity(1): parser.TraceDumper.handle_call(self, call) - args = [self.interpret_arg(arg) for name, arg in call.args] + args = [(str(name), self.interpret_arg(arg)) for name, arg in call.args] if call.klass: - obj = args[0] + name, obj = args[0] args = args[1:] else: obj = self.globl method = getattr(obj, call.method) - ret = method(*args) + ret = method(**dict(args)) if call.ret and isinstance(call.ret, model.Pointer): self.register_object(call.ret.address, ret) -- cgit v1.2.3 From d2cdf6253cf06fbed6a5ca7ae17ddadf644afe26 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 15:41:08 +0100 Subject: trace: Make call no global. --- src/gallium/drivers/trace/tr_dump.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index 314e4fa350b..f9ee7876cbe 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -58,6 +58,7 @@ static struct util_stream *stream = NULL; static unsigned refcount = 0; +static long unsigned call_no = 0; static INLINE void @@ -218,6 +219,7 @@ trace_dump_trace_close(void) util_stream_close(stream); stream = NULL; refcount = 0; + call_no = 0; } } @@ -265,11 +267,10 @@ void trace_dump_trace_end(void) void trace_dump_call_begin(const char *klass, const char *method) { - static long unsigned no = 0; - ++no; + ++call_no; trace_dump_indent(1); trace_dump_writes(" Date: Wed, 8 Apr 2009 16:24:31 +0100 Subject: trace: Make calls dumping threadsafe. --- src/gallium/drivers/trace/tr_dump.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index f9ee7876cbe..2618883e70d 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -45,6 +45,7 @@ #endif #include "pipe/p_compiler.h" +#include "pipe/p_thread.h" #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_string.h" @@ -58,6 +59,7 @@ static struct util_stream *stream = NULL; static unsigned refcount = 0; +static pipe_mutex call_mutex; static long unsigned call_no = 0; @@ -220,6 +222,7 @@ trace_dump_trace_close(void) stream = NULL; refcount = 0; call_no = 0; + pipe_mutex_destroy(call_mutex); } } @@ -237,6 +240,8 @@ boolean trace_dump_trace_begin() if(!stream) return FALSE; + pipe_mutex_init(call_mutex); + trace_dump_writes("\n"); trace_dump_writes("\n"); trace_dump_writes("\n"); @@ -267,6 +272,7 @@ void trace_dump_trace_end(void) void trace_dump_call_begin(const char *klass, const char *method) { + pipe_mutex_lock(call_mutex); ++call_no; trace_dump_indent(1); trace_dump_writes(" Date: Wed, 8 Apr 2009 16:25:29 +0100 Subject: python/retrace: Allow to specify the range of calls of interest. --- src/gallium/state_trackers/python/retrace/interpreter.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 708937119f0..0f1c56075af 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -627,6 +627,8 @@ class Interpreter(parser.TraceDumper): self.interpret_call(call) def handle_call(self, call): + if self.options.stop and call.no >= self.options.stop: + sys.exit(0) if (call.klass, call.method) in self.ignore_calls: return @@ -660,6 +662,9 @@ class Interpreter(parser.TraceDumper): return self.options.verbosity >= level def present(self, surface, description): + if self.call_no < self.options.start: + return + if self.options.images: filename = '%s_%04u.png' % (description, self.call_no) save_image(filename, surface) @@ -676,6 +681,8 @@ class Main(parser.Main): 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("-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") return optparser def process_arg(self, stream, options): -- cgit v1.2.3 From 4342d6a91f754c9d3e7087ed91b7acf89abbb293 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 21:11:24 +0100 Subject: python/retrace: Use colors on windows console. --- .../state_trackers/python/retrace/format.py | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/format.py b/src/gallium/state_trackers/python/retrace/format.py index d56d72f606f..a4285bfe075 100755 --- a/src/gallium/state_trackers/python/retrace/format.py +++ b/src/gallium/state_trackers/python/retrace/format.py @@ -94,10 +94,80 @@ class AnsiFormatter(Formatter): self._escape(self._normal) +class WindowsConsoleFormatter(Formatter): + '''Formatter for the Windows Console. See + http://code.activestate.com/recipes/496901/ for more information. + ''' + + STD_INPUT_HANDLE = -10 + STD_OUTPUT_HANDLE = -11 + STD_ERROR_HANDLE = -12 + + FOREGROUND_BLUE = 0x01 + FOREGROUND_GREEN = 0x02 + FOREGROUND_RED = 0x04 + FOREGROUND_INTENSITY = 0x08 + BACKGROUND_BLUE = 0x10 + BACKGROUND_GREEN = 0x20 + BACKGROUND_RED = 0x40 + BACKGROUND_INTENSITY = 0x80 + + _normal = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED + _bold = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY + _italic = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED + _red = FOREGROUND_RED | FOREGROUND_INTENSITY + _green = FOREGROUND_GREEN | FOREGROUND_INTENSITY + _blue = FOREGROUND_BLUE | FOREGROUND_INTENSITY + + def __init__(self, stream): + Formatter.__init__(self, stream) + + if stream is sys.stdin: + nStdHandle = self.STD_INPUT_HANDLE + elif stream is sys.stdout: + nStdHandle = self.STD_OUTPUT_HANDLE + elif stream is sys.stderr: + nStdHandle = self.STD_ERROR_HANDLE + else: + nStdHandle = None + + if nStdHandle: + import ctypes + self.handle = ctypes.windll.kernel32.GetStdHandle(nStdHandle) + else: + self.handle = None + + def _attribute(self, attr): + if self.handle: + import ctypes + ctypes.windll.kernel32.SetConsoleTextAttribute(self.handle, attr) + + def function(self, name): + self._attribute(self._bold) + Formatter.function(self, name) + self._attribute(self._normal) + + def variable(self, name): + self._attribute(self._italic) + Formatter.variable(self, name) + self._attribute(self._normal) + + def literal(self, value): + self._attribute(self._blue) + Formatter.literal(self, value) + self._attribute(self._normal) + + def address(self, value): + self._attribute(self._green) + Formatter.address(self, value) + self._attribute(self._normal) + def DefaultFormatter(stream): if sys.platform in ('linux2', 'cygwin'): return AnsiFormatter(stream) + elif sys.platform in ('win32',): + return WindowsConsoleFormatter(stream) else: return Formatter(stream) -- cgit v1.2.3 From c89eba0f31623084bc754de724384c80a3e57c91 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 21:11:51 +0100 Subject: python: Don't try to finish a null fence. --- src/gallium/state_trackers/python/p_context.i | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 9a3003a56c4..a40aa1e5187 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -258,9 +258,11 @@ error1: flush(unsigned flags = 0) { struct pipe_fence_handle *fence = NULL; $self->pipe->flush($self->pipe, flags | PIPE_FLUSH_RENDER_CACHE, &fence); - /* TODO: allow asynchronous operation */ - $self->pipe->screen->fence_finish( $self->pipe->screen, fence, 0 ); - $self->pipe->screen->fence_reference( $self->pipe->screen, &fence, NULL ); + if(fence) { + /* TODO: allow asynchronous operation */ + $self->pipe->screen->fence_finish( $self->pipe->screen, fence, 0 ); + $self->pipe->screen->fence_reference( $self->pipe->screen, &fence, NULL ); + } } /* -- cgit v1.2.3 From 71504c770086797ef8cf0a57f89565ec3e574ee3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 8 Apr 2009 21:13:57 +0100 Subject: python/retrace: Try to cope with failures creating textures. --- src/gallium/state_trackers/python/retrace/interpreter.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 0f1c56075af..5ea07724a50 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -286,6 +286,8 @@ class Screen(Object): pass def get_tex_surface(self, texture, face, level, zslice, usage): + if texture is None: + return None return texture.get_surface(face, level, zslice) def tex_surface_destroy(self, surface): @@ -295,16 +297,22 @@ class Screen(Object): pass def surface_write(self, surface, data, stride, size): + if surface is None: + return assert surface.nblocksy * stride == size surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride) 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) def tex_transfer_destroy(self, transfer): self.interpreter.unregister_object(transfer) def transfer_write(self, transfer, stride, data, size): + if transfer is None: + return transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride) def user_buffer_create(self, data, size): @@ -650,6 +658,8 @@ class Interpreter(parser.TraceDumper): ret = method(**dict(args)) if call.ret and isinstance(call.ret, model.Pointer): + if ret is None: + sys.stderr.write('warning: NULL returned\n') self.register_object(call.ret.address, ret) self.call_no = None -- cgit v1.2.3 From b3639d43f2085c893bb6136c8febe5bc7944869e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 7 Apr 2009 02:04:07 -0700 Subject: r300-gallium: Add vertex shader constant emit. --- src/gallium/drivers/r300/r300_emit.c | 19 +++++++++++++++++-- src/gallium/drivers/r300/r300_state_tcl.c | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index f28404152f0..a3d83376b66 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -330,6 +330,8 @@ void r300_emit_vertex_shader(struct r300_context* r300, { int i; struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct r300_constant_buffer* constants = + &r300->shader_constants[PIPE_SHADER_VERTEX]; CS_LOCALS(r300); if (!r300screen->caps->has_tcl) { @@ -338,8 +340,7 @@ void r300_emit_vertex_shader(struct r300_context* r300, return; } - BEGIN_CS(13 + (vs->instruction_count * 4)); - OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); + BEGIN_CS(13 + (vs->instruction_count * 4) + (constants->count * 4)); OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) | R300_PVS_LAST_INST(vs->instruction_count - 1)); @@ -357,10 +358,24 @@ void r300_emit_vertex_shader(struct r300_context* r300, OUT_CS(vs->instructions[i].inst3); } + if (constants->count) { + OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, + (r300screen->caps->is_r500 ? + R500_PVS_CONST_START : R300_PVS_CONST_START)); + OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, constants->count * 4); + for (i = 0; i < constants->count; i++) { + OUT_CS_32F(constants->constants[i][0]); + OUT_CS_32F(constants->constants[i][1]); + OUT_CS_32F(constants->constants[i][2]); + OUT_CS_32F(constants->constants[i][3]); + } + } + OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(10) | R300_PVS_NUM_CNTLRS(5) | R300_PVS_NUM_FPUS(r300screen->caps->num_vert_fpus) | R300_PVS_VF_MAX_VTX_NUM(12)); + OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); END_CS; } diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 44365f563c4..47d6c6dfcdf 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -71,6 +71,8 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler, case TGSI_FILE_TEMPORARY: return R300_PVS_SRC_REG_TEMPORARY; break; + case TGSI_FILE_CONSTANT: + return R300_PVS_SRC_REG_CONSTANT; default: debug_printf("r300: vs: Unimplemented src type %d\n", src->File); break; -- cgit v1.2.3 From 8648c2685870174cf620ef15de70ef030a8d5a20 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 8 Apr 2009 14:54:17 -0700 Subject: r300-gallium: Properly emit indexbufs. This fixes hardlocks with anything using elts. --- src/gallium/drivers/r300/r300_cs.h | 10 ++++++++++ src/gallium/drivers/r300/r300_render.c | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 9913678d272..5d9799dd723 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -132,4 +132,14 @@ OUT_CS(CP_PACKET3(op, count)); \ } while (0) +#define OUT_CS_INDEX_RELOC(bo, offset, count, rd, wd, flags) do { \ + debug_printf("r300: writing relocation for index buffer %p," \ + "offset %d\n", bo, offset); \ + assert(bo); \ + OUT_CS(offset); \ + OUT_CS(count); \ + cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \ + cs_count -= 2; \ +} while (0) + #endif /* R300_CS_H */ diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 57bbc7a9944..b7ee8fb8a94 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -241,7 +241,7 @@ static void r300_render_draw(struct vbuf_render* render, /* Send our indices into an index buffer. */ index_buffer = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, - count); + count * 2); if (!index_buffer) { return; } @@ -253,14 +253,13 @@ static void r300_render_draw(struct vbuf_render* render, debug_printf("r300: Doing indexbuf render, count %d\n", count); - BEGIN_CS(5); + BEGIN_CS(6); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | - r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); - + r300render->hwprim); OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2); OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2)); - OUT_CS_RELOC(index_buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); + OUT_CS_INDEX_RELOC(index_buffer, 0, count, RADEON_GEM_DOMAIN_GTT, 0, 0); END_CS; } -- cgit v1.2.3