From f86def5e74566c8db1ced1cddfc1a1f7bee9875d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 30 Apr 2010 14:46:18 +0100 Subject: util: Add missing break statement in u_caps.c Thanks Vinson. --- src/gallium/auxiliary/util/u_caps.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_caps.c b/src/gallium/auxiliary/util/u_caps.c index 048bd5c34d..c7c1e830e0 100644 --- a/src/gallium/auxiliary/util/u_caps.c +++ b/src/gallium/auxiliary/util/u_caps.c @@ -73,6 +73,7 @@ util_check_caps_out(struct pipe_screen *screen, const unsigned *list, int *out) *out = i - 2; return FALSE; } + break; case UTIL_CAPS_CHECK_UNIMPLEMENTED: *out = i - 1; return FALSE; -- cgit v1.2.3 From ed94c26ce80a1d370536c4bd406875deba7cbae0 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 20 Apr 2010 23:04:30 +0100 Subject: svga: Init surface functions --- src/gallium/drivers/svga/svga_screen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index aeda3dcad5..9fc613da74 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -397,6 +397,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_finish = svga_fence_finish; svgascreen->sws = sws; + svga_screen_init_surface_functions(svgascreen); svga_init_screen_resource_functions(svgascreen); svgascreen->use_ps30 = -- cgit v1.2.3 From e9bf09a98a624e594bdea2503326bb693b8cf9b8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 30 Apr 2010 19:00:58 +0100 Subject: draw: Fix memory leaks in llvm code. --- src/gallium/auxiliary/draw/draw_llvm.c | 2 ++ .../draw/draw_pt_fetch_shade_pipeline_llvm.c | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 3b2df054c3..2c234285b5 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -207,6 +207,8 @@ draw_llvm_create(struct draw_context *draw) void draw_llvm_destroy(struct draw_llvm *llvm) { + LLVMDisposePassManager(llvm->pass); + FREE(llvm); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index d2a492f2b4..35913a5995 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -349,7 +349,31 @@ static void llvm_middle_end_finish( struct draw_pt_middle_end *middle ) static void llvm_middle_end_destroy( struct draw_pt_middle_end *middle ) { struct llvm_middle_end *fpme = (struct llvm_middle_end *)middle; + struct draw_context *draw = fpme->draw; + struct draw_llvm_variant *variant = NULL; + + variant = fpme->variants; + while(variant) { + struct draw_llvm_variant *next = variant->next; + if (variant->function_elts) { + if (variant->function_elts) + LLVMFreeMachineCodeForFunction(draw->engine, + variant->function_elts); + LLVMDeleteFunction(variant->function_elts); + } + + if (variant->function) { + if (variant->function) + LLVMFreeMachineCodeForFunction(draw->engine, + variant->function); + LLVMDeleteFunction(variant->function); + } + + FREE(variant); + + variant = next; + } if (fpme->fetch) draw_pt_fetch_destroy( fpme->fetch ); -- cgit v1.2.3 From 58590a112aed1354f7592520f8f258df24c89c9b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 21 Apr 2010 01:13:36 +0100 Subject: svga: Fix index offset --- src/gallium/drivers/svga/svga_draw_arrays.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index 005996d05d..da33fae62f 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -277,12 +277,13 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl, ret = svga_hwtnl_simple_draw_range_elements( hwtnl, gen_buf, gen_size, + start, 0, count - 1, gen_prim, 0, - gen_nr, - start ); + gen_nr ); + if (ret) goto done; -- cgit v1.2.3 From 3a757b722d9d24a74b6a79cb2d4aae81ae8152d0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 Apr 2010 13:53:54 -0600 Subject: llvmpipe: added lp_build_sample_nop() for debugging --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 36 ++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 74dc9e1d81..7c9c8e2d9f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2048,6 +2048,24 @@ lp_build_sample_compare(struct lp_build_sample_context *bld, } +/** + * Just set texels to white instead of actually sampling the texture. + * For debugging. + */ +static void +lp_build_sample_nop(struct lp_build_sample_context *bld, + LLVMValueRef *texel) +{ + struct lp_build_context *texel_bld = &bld->texel_bld; + unsigned chan; + + for (chan = 0; chan < 4; chan++) { + /*lp_bld_mov(texel_bld, texel, texel_bld->one);*/ + texel[chan] = texel_bld->one; + } +} + + /** * Build texture sampling code. * 'texel' will return a vector of four LLVMValueRefs corresponding to @@ -2113,13 +2131,17 @@ lp_build_sample_soa(LLVMBuilderRef builder, height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth); - if (util_format_is_rgba8_variant(bld.format_desc) && - static_state->target == PIPE_TEXTURE_2D && - static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR && - static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR && - static_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE && - is_simple_wrap_mode(static_state->wrap_s) && - is_simple_wrap_mode(static_state->wrap_t)) { + if (0) { + /* For debug: no-op texture sampling */ + lp_build_sample_nop(&bld, texel); + } + else if (util_format_is_rgba8_variant(bld.format_desc) && + static_state->target == PIPE_TEXTURE_2D && + static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR && + static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR && + static_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE && + is_simple_wrap_mode(static_state->wrap_s) && + is_simple_wrap_mode(static_state->wrap_t)) { /* special case */ lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec, row_stride_array, data_array, texel); -- cgit v1.2.3 From d225221e7084a1e8e22c41cbd3c58775d6f298a1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 Apr 2010 13:54:31 -0600 Subject: llvmpipe: fix out-of-bounds texture sampling If we're using a wrap mode in which border color sampling is possible it means that texcoords may be outside of the texture image bounds. Fetching the texel may result in a segfault. Use the 'use_border' variable to catch such texcoords and replace the texel offset with zero (which will be in bounds). Fixes segfault in Lightsmark demo, fd.o bug 27877. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 7c9c8e2d9f..54c0ad7ce4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -325,6 +325,18 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, bld->format_desc, x, y, z, y_stride, z_stride); + if (use_border) { + /* If we can sample the border color, it means that texcoords may + * lie outside the bounds of the texture image. We need to do + * something to prevent reading out of bounds and causing a segfault. + * + * Simply AND the texture coords with !use_border. This will cause + * coords which are out of bounds to become zero. Zero's guaranteed + * to be inside the texture image. + */ + offset = lp_build_andc(&bld->uint_coord_bld, offset, use_border); + } + lp_build_fetch_rgba_soa(bld->builder, bld->format_desc, bld->texel_type, -- cgit v1.2.3 From 6df1e5c4aa980d52e98b991e6cdbd20a3c746845 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 29 Apr 2010 22:48:00 +0200 Subject: nv50: don't segfault on OPCODE_END for empty programs --- src/gallium/drivers/nv50/nv50_program.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index b8b6b12120..98f60821fc 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -3169,15 +3169,16 @@ nv50_program_tx_insn(struct nv50_pc *pc, if (pc->p->type == PIPE_SHADER_FRAGMENT) nv50_fp_move_results(pc); - /* last insn must be long so it can have the exit bit set */ - if (!is_long(pc->p->exec_tail)) - convert_to_long(pc, pc->p->exec_tail); - else - if (is_immd(pc->p->exec_tail) || + if (!pc->p->exec_tail || + is_immd(pc->p->exec_tail) || is_join(pc->p->exec_tail) || is_control_flow(pc->p->exec_tail)) emit_nop(pc); + /* last insn must be long so it can have the exit bit set */ + if (!is_long(pc->p->exec_tail)) + convert_to_long(pc, pc->p->exec_tail); + pc->p->exec_tail->inst[1] |= 1; /* set exit bit */ terminate_mbb(pc); -- cgit v1.2.3 From 75ee309ca9f467ba80a88b07735fb2d654a8c433 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 29 Apr 2010 23:15:05 +0200 Subject: nv50: relax restriction on surface_copy format equality a bit --- src/gallium/drivers/nv50/nv50_surface.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index c2d9e83526..d905d95354 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -31,6 +31,27 @@ #include "util/u_tile.h" #include "util/u_format.h" +/* return TRUE for formats that can be converted among each other by NV50_2D */ +static INLINE boolean +nv50_2d_format_faithful(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_SRGB: + case PIPE_FORMAT_B8G8R8X8_SRGB: + case PIPE_FORMAT_B5G6R5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B10G10R10A2_UNORM: + case PIPE_FORMAT_R8_UNORM: + case PIPE_FORMAT_R32G32B32A32_FLOAT: + case PIPE_FORMAT_R32G32B32_FLOAT: + return TRUE; + default: + return FALSE; + } +} + static INLINE int nv50_format(enum pipe_format format) { @@ -47,9 +68,12 @@ nv50_format(enum pipe_format format) return NV50_2D_DST_FORMAT_R5G6B5_UNORM; case PIPE_FORMAT_B5G5R5A1_UNORM: return NV50_2D_DST_FORMAT_A1R5G5B5_UNORM; + case PIPE_FORMAT_B10G10R10A2_UNORM: + return NV50_2D_DST_FORMAT_A2R10G10B10_UNORM; case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: case PIPE_FORMAT_L8_UNORM: + case PIPE_FORMAT_R8_UNORM: return NV50_2D_DST_FORMAT_R8_UNORM; case PIPE_FORMAT_R32G32B32A32_FLOAT: return NV50_2D_DST_FORMAT_R32G32B32A32_FLOAT; @@ -178,7 +202,9 @@ nv50_surface_copy(struct pipe_context *pipe, struct nv50_context *nv50 = nv50_context(pipe); struct nv50_screen *screen = nv50->screen; - assert(src->format == dest->format); + assert((src->format == dest->format) || + (nv50_2d_format_faithful(src->format) && + nv50_2d_format_faithful(dest->format))); nv50_surface_do_copy(screen, dest, destx, desty, src, srcx, srcy, width, height); -- cgit v1.2.3 From f5a4d70189bdd8e25bc1f30b9f4fe8f31999cf0e Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Fri, 30 Apr 2010 22:57:23 +0200 Subject: nv50: raise constant buffers size to maximum Removed the param heaps, haven't been using them for a long time now. --- src/gallium/drivers/nv50/nv50_program.c | 4 ++-- src/gallium/drivers/nv50/nv50_screen.c | 18 +++++++----------- src/gallium/drivers/nv50/nv50_screen.h | 3 +-- 3 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 98f60821fc..0156ff95ff 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -4163,7 +4163,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) struct pipe_transfer *transfer; if (!p->data[0] && p->immd_nr) { - struct nouveau_resource *heap = nv50->screen->immd_heap[0]; + struct nouveau_resource *heap = nv50->screen->immd_heap; if (nouveau_resource_alloc(heap, p->immd_nr, p, &p->data[0])) { while (heap->next && heap->size < p->immd_nr) { @@ -4181,7 +4181,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) p->immd_nr, NV50_CB_PMISC); } - assert(p->param_nr <= 512); + assert(p->param_nr <= 16384); if (p->param_nr) { unsigned cb; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index ad17991be9..2dd1042424 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -190,9 +190,7 @@ nv50_screen_destroy(struct pipe_screen *pscreen) nouveau_grobj_free(&screen->tesla); nouveau_grobj_free(&screen->eng2d); nouveau_grobj_free(&screen->m2mf); - nouveau_resource_destroy(&screen->immd_heap[0]); - nouveau_resource_destroy(&screen->parm_heap[0]); - nouveau_resource_destroy(&screen->parm_heap[1]); + nouveau_resource_destroy(&screen->immd_heap); nouveau_screen_fini(&screen->base); FREE(screen); } @@ -242,7 +240,7 @@ nv50_screen_relocs(struct nv50_screen *screen) OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl); OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl); OUT_RELOC (chan, screen->constbuf_parm[i], - ((NV50_CB_PVP + i) << 16) | 0x0800, rl, 0, 0); + ((NV50_CB_PVP + i) << 16) | 0x0000, rl, 0, 0); } } @@ -411,7 +409,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) OUT_RING (chan, (NV50_CB_AUX << 16) | 0x0200); for (i = 0; i < 3; i++) { - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (256 * 4) * 4, + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (4096 * 4) * 4, &screen->constbuf_parm[i]); if (ret) { nv50_screen_destroy(pscreen); @@ -420,14 +418,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl); OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl); - OUT_RING (chan, ((NV50_CB_PVP + i) << 16) | 0x0800); + /* CB_DEF_SET_SIZE value of 0x0000 means 65536 */ + OUT_RING (chan, ((NV50_CB_PVP + i) << 16) | 0x0000); } - if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) || - nouveau_resource_init(&screen->parm_heap[0], 0, 512) || - nouveau_resource_init(&screen->parm_heap[1], 0, 512)) - { - NOUVEAU_ERR("Error initialising constant buffers.\n"); + if (nouveau_resource_init(&screen->immd_heap, 0, 128)) { + NOUVEAU_ERR("Error initialising shader immediates heap.\n"); nv50_screen_destroy(pscreen); return NULL; } diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index 40ebbee72e..fbf15a7596 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -20,8 +20,7 @@ struct nv50_screen { struct nouveau_bo *constbuf_misc[1]; struct nouveau_bo *constbuf_parm[PIPE_SHADER_TYPES]; - struct nouveau_resource *immd_heap[1]; - struct nouveau_resource *parm_heap[PIPE_SHADER_TYPES]; + struct nouveau_resource *immd_heap; struct pipe_resource *strm_vbuf[16]; -- cgit v1.2.3 From cd502e5f5cb85e5bd464a7d2af920a61068a8399 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 1 May 2010 11:29:20 +0100 Subject: swrastg: Use trace --- src/gallium/targets/dri-swrast/Makefile | 3 ++- src/gallium/targets/dri-swrast/swrast_drm_api.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile index fcfd690e43..3db9781c20 100644 --- a/src/gallium/targets/dri-swrast/Makefile +++ b/src/gallium/targets/dri-swrast/Makefile @@ -8,7 +8,8 @@ DRIVER_DEFINES = -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \ $(TOP)/src/gallium/winsys/sw/dri/libswdri.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a SWRAST_COMMON_GALLIUM_SOURCES = \ $(TOP)/src/mesa/drivers/dri/common/utils.c \ diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index e8d6d8069c..84142be80c 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -31,6 +31,7 @@ #include "state_tracker/drm_api.h" #include "state_tracker/sw_winsys.h" #include "dri_sw_winsys.h" +#include "trace/tr_public.h" /* Copied from targets/libgl-xlib */ @@ -80,7 +81,7 @@ swrast_create_screen(struct sw_winsys *winsys) screen = softpipe_create_screen( winsys ); #endif - return screen; + return trace_screen_create(screen);; } struct pipe_screen * -- cgit v1.2.3 From 70c75310514ef16880e1e3fe9cca83ab646bae99 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 1 May 2010 15:12:45 -0700 Subject: llvmpipe: Remove unused variable. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 965777b641..513e62e39e 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -618,7 +618,6 @@ generate_fragment(struct llvmpipe_context *lp, struct lp_type fs_type; struct lp_type blend_type; LLVMTypeRef fs_elem_type; - LLVMTypeRef fs_vec_type; LLVMTypeRef fs_int_vec_type; LLVMTypeRef blend_vec_type; LLVMTypeRef arg_types[15]; @@ -675,7 +674,6 @@ generate_fragment(struct llvmpipe_context *lp, */ fs_elem_type = lp_build_elem_type(fs_type); - fs_vec_type = lp_build_vec_type(fs_type); fs_int_vec_type = lp_build_int_vec_type(fs_type); blend_vec_type = lp_build_vec_type(blend_type); -- cgit v1.2.3 From 3c86e2f1dce458aec42b5de54fc2cf25cac28172 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 2 May 2010 00:21:04 -0700 Subject: i965g: s/sprintf/util_snprintf/ --- src/gallium/drivers/i965/intel_decode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/intel_decode.c b/src/gallium/drivers/i965/intel_decode.c index 6c47415cac..bd8b9174a8 100644 --- a/src/gallium/drivers/i965/intel_decode.c +++ b/src/gallium/drivers/i965/intel_decode.c @@ -40,6 +40,7 @@ #include #include +#include "util/u_string.h" #include "intel_decode.h" /*#include "intel_chipset.h"*/ @@ -478,7 +479,7 @@ i915_get_instruction_src0(const uint32_t *data, int i, char *srcname) char swizzle[100]; i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname); - sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w); + util_snprintf(swizzle, sizeof(swizzle), ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w); if (strcmp(swizzle, ".xyzw") != 0) strcat(srcname, swizzle); } @@ -496,7 +497,7 @@ i915_get_instruction_src1(const uint32_t *data, int i, char *srcname) char swizzle[100]; i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname); - sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w); + util_snprintf(swizzle, sizeof(swizzle), ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w); if (strcmp(swizzle, ".xyzw") != 0) strcat(srcname, swizzle); } @@ -513,7 +514,7 @@ i915_get_instruction_src2(const uint32_t *data, int i, char *srcname) char swizzle[100]; i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname); - sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w); + util_snprintf(swizzle, sizeof(swizzle), ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w); if (strcmp(swizzle, ".xyzw") != 0) strcat(srcname, swizzle); } @@ -642,7 +643,7 @@ i915_decode_dcl(const uint32_t *data, uint32_t hw_offset, int i, char *instr_pre switch ((d0 >> 19) & 0x3) { case 1: - sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w); + util_snprintf(dcl_mask, sizeof(dcl_mask), ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w); if (strcmp(dcl_mask, ".") == 0) fprintf(out, "bad (empty) dcl mask\n"); @@ -976,7 +977,7 @@ decode_3d_1d(const uint32_t *data, int count, uint32_t hw_offset, int *failures, if (i + 3 >= count) BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_PROGRAM"); - sprintf(instr_prefix, "PS%03d", instr); + util_snprintf(instr_prefix, sizeof(instr_prefix), "PS%03d", instr); i915_decode_instruction(data, hw_offset, i, instr_prefix); i += 3; } -- cgit v1.2.3 From 5c6ea462be7c589d98887b822751bffd6df13418 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 01:48:57 +0200 Subject: r300g: cache tiling flags to reduce the number of DRM calls --- src/gallium/winsys/radeon/drm/radeon_drm_buffer.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c index 9824ada5b3..b836649892 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c @@ -22,6 +22,8 @@ struct radeon_drm_buffer { boolean flinked; uint32_t flink; + uint32_t tileflags; + uint32_t pitch; struct radeon_drm_buffer *next, *prev; }; @@ -318,6 +320,9 @@ void radeon_drm_bufmgr_get_tiling(struct pb_buffer *_buf, radeon_bo_get_tiling(buf->bo, &flags, &pitch); + buf->tileflags = flags; + buf->pitch = pitch; + *microtiled = R300_BUFFER_LINEAR; *macrotiled = R300_BUFFER_LINEAR; if (flags & RADEON_BO_FLAGS_MICRO_TILE) @@ -333,7 +338,7 @@ void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, uint32_t pitch) { struct radeon_drm_buffer *buf = get_drm_buffer(_buf); - uint32_t flags = 0, old_flags, old_pitch; + uint32_t flags = 0; if (microtiled == R300_BUFFER_TILED) flags |= RADEON_BO_FLAGS_MICRO_TILE; /* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */ @@ -344,17 +349,15 @@ void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, if (macrotiled == R300_BUFFER_TILED) flags |= RADEON_BO_FLAGS_MACRO_TILE; - radeon_bo_get_tiling(buf->bo, &old_flags, &old_pitch); - - if (flags != old_flags || pitch != old_pitch) { + if (flags != buf->tileflags || pitch != buf->pitch) { /* Tiling determines how DRM treats the buffer data. * We must flush CS when changing it if the buffer is referenced. */ if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) { buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data); } - } - radeon_bo_set_tiling(buf->bo, flags, pitch); + radeon_bo_set_tiling(buf->bo, flags, pitch); + } } boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf, -- cgit v1.2.3 From 45d79af644349882b4990b775737405be7cd1aa2 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 01:55:44 +0200 Subject: r300g: fix segfault when resizing a DRI2 framebuffer Resetting tiling flags might happen after a texture is destroyed... Looking at the kernel sources, we don't actually need to reset the tiling flags. --- src/gallium/drivers/r300/r300_state.c | 41 ++++------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 9319dadfd1..e3372458f3 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -538,46 +538,12 @@ static void r300_set_stencil_ref(struct pipe_context* pipe, } /* This switcheroo is needed just because of goddamned MACRO_SWITCH. */ -static void r300_fb_update_tiling_flags(struct r300_context *r300, +static void r300_fb_set_tiling_flags(struct r300_context *r300, const struct pipe_framebuffer_state *old_state, const struct pipe_framebuffer_state *new_state) { struct r300_texture *tex; - unsigned i, j, level; - - /* Reset tiling flags for old surfaces to default values. */ - for (i = 0; i < old_state->nr_cbufs; i++) { - for (j = 0; j < new_state->nr_cbufs; j++) { - if (old_state->cbufs[i]->texture == new_state->cbufs[j]->texture) { - break; - } - } - /* If not binding the surface again... */ - if (j != new_state->nr_cbufs) { - continue; - } - - tex = r300_texture(old_state->cbufs[i]->texture); - - if (tex) { - r300->rws->buffer_set_tiling(r300->rws, tex->buffer, - tex->pitch[0], - tex->microtile, - tex->macrotile); - } - } - if (old_state->zsbuf && - (!new_state->zsbuf || - old_state->zsbuf->texture != new_state->zsbuf->texture)) { - tex = r300_texture(old_state->zsbuf->texture); - - if (tex) { - r300->rws->buffer_set_tiling(r300->rws, tex->buffer, - tex->pitch[0], - tex->microtile, - tex->macrotile); - } - } + unsigned i, level; /* Set tiling flags for new surfaces. */ for (i = 0; i < new_state->nr_cbufs; i++) { @@ -644,7 +610,8 @@ static void r300->dsa_state.dirty = TRUE; } - r300_fb_update_tiling_flags(r300, r300->fb_state.state, state); + /* The tiling flags are dependent on the surface miplevel, unfortunately. */ + r300_fb_set_tiling_flags(r300, r300->fb_state.state, state); memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state)); -- cgit v1.2.3 From 35232172db40fc756f3a0d1c17ed19e696a8878d Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 04:21:21 +0200 Subject: r300g: inline update_derived_shader_state --- src/gallium/drivers/r300/r300_state_derived.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 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 ccc4b583a6..43e3d1d701 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -272,10 +272,11 @@ static void r500_rs_tex_write(struct r300_rs_block* rs, int id, int fp_offset) * This is the part of the chipset that actually does the rasterization * of vertices into fragments. This is also the part of the chipset that * locks up if any part of it is even slightly wrong. */ -static void r300_update_rs_block(struct r300_context* r300, - struct r300_shader_semantics* vs_outputs, - struct r300_shader_semantics* fs_inputs) +static void r300_update_rs_block(struct r300_context *r300) { + struct r300_vertex_shader *vs = r300->vs_state.state; + struct r300_shader_semantics *vs_outputs = &vs->outputs; + struct r300_shader_semantics *fs_inputs = &r300_fs(r300)->shader->inputs; struct r300_rs_block rs = { { 0 } }; int i, col_count = 0, tex_count = 0, fp_offset = 0, count; void (*rX00_rs_col)(struct r300_rs_block*, int, int, enum r300_rs_swizzle); @@ -426,14 +427,6 @@ static void r300_update_rs_block(struct r300_context* r300, } } -/* Update the shader-dependant states. */ -static void r300_update_derived_shader_state(struct r300_context* r300) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - - r300_update_rs_block(r300, &vs->outputs, &r300_fs(r300)->shader->inputs); -} - static void r300_merge_textures_and_samplers(struct r300_context* r300) { struct r300_textures_state *state = @@ -529,7 +522,7 @@ void r300_update_derived_state(struct r300_context* r300) } if (r300->rs_block_state.dirty) { - r300_update_derived_shader_state(r300); + r300_update_rs_block(r300); } if (r300->draw) { -- cgit v1.2.3 From 68e720e12d51cf6d5237467a74af8c56b021acb7 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 06:24:55 +0200 Subject: r300g: merge VS output mapping state (VAP) to rasterizer block state (RS) These two should be tied together because what's set in VAP or stuffed in GA should be rasterized in RS. Not doing so causes a hardlock. The reason for the merge is that if stuffed texture coordinates (e.g. point sprite texgen) happen to occupy the texcoord slot dedicated to fog or wpos, the two must be relocated to other free slots, which needs remapping the vertex shader outputs. The rasterizer code is now literally a sequence read-rasterize-write. --- src/gallium/drivers/r300/r300_context.c | 3 - src/gallium/drivers/r300/r300_context.h | 17 ++-- src/gallium/drivers/r300/r300_emit.c | 26 ++--- src/gallium/drivers/r300/r300_emit.h | 3 - src/gallium/drivers/r300/r300_state.c | 12 --- src/gallium/drivers/r300/r300_state_derived.c | 101 +++++++++++++++----- src/gallium/drivers/r300/r300_vs.c | 131 +------------------------- src/gallium/drivers/r300/r300_vs.h | 10 -- 8 files changed, 96 insertions(+), 207 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 4f721ebb59..e84bce0010 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -76,7 +76,6 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->rs_block_state.state); FREE(r300->scissor_state.state); FREE(r300->textures_state.state); - FREE(r300->vap_output_state.state); FREE(r300->viewport_state.state); FREE(r300->ztop_state.state); FREE(r300->fs_constants.state); @@ -125,7 +124,6 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(viewport_state, 9); R300_INIT_ATOM(rs_block_state, 0); R300_INIT_ATOM(vertex_stream_state, 0); - R300_INIT_ATOM(vap_output_state, 6); R300_INIT_ATOM(pvs_flush, 2); R300_INIT_ATOM(vs_state, 0); R300_INIT_ATOM(vs_constants, 0); @@ -149,7 +147,6 @@ static void r300_setup_atoms(struct r300_context* r300) r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); r300->textures_state.state = CALLOC_STRUCT(r300_textures_state); - r300->vap_output_state.state = CALLOC_STRUCT(r300_vap_output_state); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index a05bf3ce09..e9c8fcdc15 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -119,6 +119,10 @@ struct r300_rs_state { }; struct r300_rs_block { + uint32_t vap_vtx_state_cntl; /* R300_VAP_VTX_STATE_CNTL: 0x2180 */ + uint32_t vap_vsm_vtx_assm; /* R300_VAP_VSM_VTX_ASSM: 0x2184 */ + uint32_t vap_out_vtx_fmt[2]; /* R300_VAP_OUTPUT_VTX_FMT_[0-1]: 0x2090 */ + uint32_t ip[8]; /* R300_RS_IP_[0-7], R500_RS_IP_[0-7] */ uint32_t count; /* R300_RS_COUNT */ uint32_t inst_count; /* R300_RS_INST_COUNT */ @@ -190,12 +194,6 @@ struct r300_vertex_stream_state { unsigned count; }; -struct r300_vap_output_state { - uint32_t vap_vtx_state_cntl; /* R300_VAP_VTX_STATE_CNTL: 0x2180 */ - uint32_t vap_vsm_vtx_assm; /* R300_VAP_VSM_VTX_ASSM: 0x2184 */ - uint32_t vap_out_vtx_fmt[2]; /* R300_VAP_OUTPUT_VTX_FMT_[0-1]: 0x2090 */ -}; - struct r300_viewport_state { float xscale; /* R300_VAP_VPORT_XSCALE: 0x2098 */ float xoffset; /* R300_VAP_VPORT_XOFFSET: 0x209c */ @@ -381,7 +379,7 @@ struct r300_context { struct r300_atom query_start; /* Rasterizer state. */ struct r300_atom rs_state; - /* RS block state. */ + /* RS block state + VAP (vertex shader) output mapping state. */ struct r300_atom rs_block_state; /* Scissor state. */ struct r300_atom scissor_state; @@ -389,8 +387,6 @@ struct r300_context { struct r300_atom textures_state; /* Vertex stream formatting state. */ struct r300_atom vertex_stream_state; - /* VAP (vertex shader) output mapping state. */ - struct r300_atom vap_output_state; /* Vertex shader. */ struct r300_atom vs_state; /* Vertex shader constant buffer. */ @@ -424,6 +420,9 @@ struct r300_context { struct pipe_viewport_state viewport; + /* Stream locations for SWTCL. */ + int stream_loc_notcl[16]; + /* Flag indicating whether or not the HW is dirty. */ uint32_t dirty_hw; /* Whether polygon offset is enabled. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 92b7517b8d..23bbc6a99c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -717,6 +717,13 @@ void r300_emit_rs_block_state(struct r300_context* r300, DBG(r300, DBG_DRAW, "r300: RS emit:\n"); BEGIN_CS(size); + OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); + OUT_CS(rs->vap_vtx_state_cntl); + OUT_CS(rs->vap_vsm_vtx_assm); + OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2); + OUT_CS(rs->vap_out_vtx_fmt[0]); + OUT_CS(rs->vap_out_vtx_fmt[1]); + if (r300->screen->caps.is_r500) { OUT_CS_REG_SEQ(R500_RS_IP_0, count); } else { @@ -901,25 +908,6 @@ void r300_emit_vertex_stream_state(struct r300_context* r300, END_CS; } -void r300_emit_vap_output_state(struct r300_context* r300, - unsigned size, void* state) -{ - struct r300_vap_output_state *vap_out_state = - (struct r300_vap_output_state*)state; - CS_LOCALS(r300); - - DBG(r300, DBG_DRAW, "r300: VAP emit:\n"); - - BEGIN_CS(size); - OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); - OUT_CS(vap_out_state->vap_vtx_state_cntl); - OUT_CS(vap_out_state->vap_vsm_vtx_assm); - OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2); - OUT_CS(vap_out_state->vap_out_vtx_fmt[0]); - OUT_CS(vap_out_state->vap_out_vtx_fmt[1]); - END_CS; -} - void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state) { CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index c3eb195d4e..3c0edf6fdc 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -81,9 +81,6 @@ void r300_emit_vertex_buffer(struct r300_context* r300); void r300_emit_vertex_stream_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_vap_output_state(struct r300_context* r300, - unsigned size, void* state); - void r300_emit_vs_constants(struct r300_context* r300, unsigned size, void *state); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index e3372458f3..6a73f388fc 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -686,10 +686,6 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) r300_mark_fs_code_dirty(r300); r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ - - if (r300->vs_state.state && r300_vertex_shader_setup_wpos(r300)) { - r300->vap_output_state.dirty = TRUE; - } } /* Delete fragment shader state. */ @@ -1395,14 +1391,6 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) } r300->vs_state.state = vs; - // VS output mapping for HWTCL or stream mapping for SWTCL to the RS block - if (r300->fs.state) { - r300_vertex_shader_setup_wpos(r300); - } - memcpy(r300->vap_output_state.state, &vs->vap_out, - sizeof(struct r300_vap_output_state)); - r300->vap_output_state.dirty = TRUE; - /* The majority of the RS block bits is dependent on the vertex shader. */ r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 43e3d1d701..e3adace0fa 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -115,12 +115,11 @@ static void r300_draw_emit_all_attribs(struct r300_context* r300) static void r300_swtcl_vertex_psc(struct r300_context *r300) { struct r300_vertex_stream_state *vstream = r300->vertex_stream_state.state; - struct r300_vertex_shader* vs = r300->vs_state.state; - struct vertex_info* vinfo = &r300->vertex_info; + struct vertex_info* vinfo = &r300->vertex_info; uint16_t type, swizzle; enum pipe_format format; unsigned i, attrib_count; - int* vs_output_tab = vs->stream_loc_notcl; + int* vs_output_tab = r300->stream_loc_notcl; /* XXX hax */ memset(vstream, 0, sizeof(struct r300_vertex_stream_state)); @@ -269,22 +268,29 @@ static void r500_rs_tex_write(struct r300_rs_block* rs, int id, int fp_offset) /* Set up the RS block. * - * This is the part of the chipset that actually does the rasterization - * of vertices into fragments. This is also the part of the chipset that - * locks up if any part of it is even slightly wrong. */ + * This is the part of the chipset that is responsible for linking vertex + * and fragment shaders and stuffed texture coordinates. + * + * The rasterizer reads data from VAP, which produces vertex shader outputs, + * and GA, which produces stuffed texture coordinates. VAP outputs have + * precedence over GA. All outputs must be rasterized otherwise it locks up. + * If there are more outputs rasterized than is set in VAP/GA, it locks up + * too. The funky part is that this info has been pretty much obtained by trial + * and error. */ static void r300_update_rs_block(struct r300_context *r300) { struct r300_vertex_shader *vs = r300->vs_state.state; struct r300_shader_semantics *vs_outputs = &vs->outputs; struct r300_shader_semantics *fs_inputs = &r300_fs(r300)->shader->inputs; - struct r300_rs_block rs = { { 0 } }; - int i, col_count = 0, tex_count = 0, fp_offset = 0, count; + struct r300_rs_block rs = {0}; + int i, col_count = 0, tex_count = 0, fp_offset = 0, count, loc = 0; void (*rX00_rs_col)(struct r300_rs_block*, int, int, enum r300_rs_swizzle); void (*rX00_rs_col_write)(struct r300_rs_block*, int, int); void (*rX00_rs_tex)(struct r300_rs_block*, int, int, enum r300_rs_swizzle); void (*rX00_rs_tex_write)(struct r300_rs_block*, int, int); boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED || vs_outputs->bcolor[1] != ATTR_UNUSED; + int *stream_loc_notcl = r300->stream_loc_notcl; if (r300->screen->caps.is_r500) { rX00_rs_col = r500_rs_col; @@ -298,15 +304,31 @@ static void r300_update_rs_block(struct r300_context *r300) rX00_rs_tex_write = r300_rs_tex_write; } - /* Rasterize colors. */ + /* The position is always present in VAP. */ + rs.vap_vsm_vtx_assm |= R300_INPUT_CNTL_POS; + rs.vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; + stream_loc_notcl[loc++] = 0; + + /* Set up the point size in VAP. */ + if (vs_outputs->psize != ATTR_UNUSED) { + rs.vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; + stream_loc_notcl[loc++] = 1; + } + + /* Set up and rasterize colors. */ for (i = 0; i < ATTR_COLOR_COUNT; i++) { if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || vs_outputs->color[1] != ATTR_UNUSED) { - /* Always rasterize if it's written by the VS, - * otherwise it locks up. */ + /* Set up the color in VAP. */ + rs.vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; + rs.vap_out_vtx_fmt[0] |= + R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i; + stream_loc_notcl[loc++] = 2 + i; + + /* Rasterize it. */ rX00_rs_col(&rs, col_count, col_count, SWIZ_XYZW); - /* Write it to the FS input register if it's used by the FS. */ + /* Write it to the FS input register if it's needed by the FS. */ if (fs_inputs->color[i] != ATTR_UNUSED) { rX00_rs_col_write(&rs, col_count, fp_offset); fp_offset++; @@ -329,17 +351,33 @@ static void r300_update_rs_block(struct r300_context *r300) } } + /* Set up back-face colors. The rasterizer will do the color selection + * automatically. */ + if (any_bcolor_used) { + for (i = 0; i < ATTR_COLOR_COUNT; i++) { + rs.vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; + rs.vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i); + stream_loc_notcl[loc++] = 4 + i; + } + } + /* Rasterize texture coordinates. */ - for (i = 0; i < ATTR_GENERIC_COUNT; i++) { + for (i = 0; i < ATTR_GENERIC_COUNT && tex_count < 8; i++) { bool sprite_coord = !!(r300->sprite_coord_enable & (1 << i)); if (vs_outputs->generic[i] != ATTR_UNUSED || sprite_coord) { - /* Always rasterize if it's written by the VS, - * otherwise it locks up. */ + if (!sprite_coord) { + /* Set up the texture coordinates in VAP. */ + rs.vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << tex_count); + rs.vap_out_vtx_fmt[1] |= (4 << (3 * tex_count)); + stream_loc_notcl[loc++] = 6 + tex_count; + } + + /* Rasterize it. */ rX00_rs_tex(&rs, tex_count, tex_count, sprite_coord ? SWIZ_XY01 : SWIZ_XYZW); - /* Write it to the FS input register if it's used by the FS. */ + /* Write it to the FS input register if it's needed by the FS. */ if (fs_inputs->generic[i] != ATTR_UNUSED) { rX00_rs_tex_write(&rs, tex_count, fp_offset); fp_offset++; @@ -366,12 +404,16 @@ static void r300_update_rs_block(struct r300_context *r300) } /* Rasterize fog coordinates. */ - if (vs_outputs->fog != ATTR_UNUSED) { - /* Always rasterize if it's written by the VS, - * otherwise it locks up. */ + if (vs_outputs->fog != ATTR_UNUSED && tex_count < 8) { + /* Set up the fog coordinates in VAP. */ + rs.vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << tex_count); + rs.vap_out_vtx_fmt[1] |= (4 << (3 * tex_count)); + stream_loc_notcl[loc++] = 6 + tex_count; + + /* Rasterize it. */ rX00_rs_tex(&rs, tex_count, tex_count, SWIZ_X001); - /* Write it to the FS input register if it's used by the FS. */ + /* Write it to the FS input register if it's needed by the FS. */ if (fs_inputs->fog != ATTR_UNUSED) { rX00_rs_tex_write(&rs, tex_count, fp_offset); fp_offset++; @@ -392,9 +434,17 @@ static void r300_update_rs_block(struct r300_context *r300) } /* Rasterize WPOS. */ - /* If the FS doesn't need it, it's not written by the VS. */ - if (vs_outputs->wpos != ATTR_UNUSED && fs_inputs->wpos != ATTR_UNUSED) { + /* Don't set it in VAP if the FS doesn't need it. */ + if (fs_inputs->wpos != ATTR_UNUSED && tex_count < 8) { + /* Set up the WPOS coordinates in VAP. */ + rs.vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << tex_count); + rs.vap_out_vtx_fmt[1] |= (4 << (3 * tex_count)); + stream_loc_notcl[loc++] = 6 + tex_count; + + /* Rasterize it. */ rX00_rs_tex(&rs, tex_count, tex_count, SWIZ_XYZW); + + /* Write it to the FS input register. */ rX00_rs_tex_write(&rs, tex_count, fp_offset); DBG(r300, DBG_RS, "r300: Rasterized WPOS written to FS.\n"); @@ -403,6 +453,11 @@ static void r300_update_rs_block(struct r300_context *r300) tex_count++; } + /* Invalidate the rest of the no-TCL (GA) stream locations. */ + for (; loc < 16;) { + stream_loc_notcl[loc++] = -1; + } + /* Rasterize at least one color, or bad things happen. */ if (col_count == 0 && tex_count == 0) { rX00_rs_col(&rs, 0, 0, SWIZ_0001); @@ -423,7 +478,7 @@ static void r300_update_rs_block(struct r300_context *r300) /* Now, after all that, see if we actually need to update the state. */ if (memcmp(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block))) { memcpy(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block)); - r300->rs_block_state.size = 5 + count*2; + r300->rs_block_state.size = 11 + count*2; } } diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index bfab9c3b01..b7609bad81 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -94,94 +94,6 @@ static void r300_shader_read_vs_outputs( vs_outputs->wpos = i; } -/* This function sets up: - * - VAP mapping, which maps VS registers to output semantics and - * at the same time it indicates which attributes are enabled and should - * be rasterized. - * - Stream mapping to VS outputs if TCL is not present. */ -static void r300_init_vs_output_mapping(struct r300_vertex_shader* vs) -{ - struct r300_shader_semantics* vs_outputs = &vs->outputs; - struct r300_vap_output_state *vap_out = &vs->vap_out; - int *stream_loc = vs->stream_loc_notcl; - int i, gen_count, tabi = 0; - boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED || - vs_outputs->bcolor[1] != ATTR_UNUSED; - - vap_out->vap_vtx_state_cntl = 0x5555; /* XXX this is classic Mesa bonghits */ - - /* Position. */ - if (vs_outputs->pos != ATTR_UNUSED) { - vap_out->vap_vsm_vtx_assm |= R300_INPUT_CNTL_POS; - vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; - - stream_loc[tabi++] = 0; - } else { - assert(0); - } - - /* Point size. */ - if (vs_outputs->psize != ATTR_UNUSED) { - vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; - - stream_loc[tabi++] = 1; - } - - /* Colors. */ - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || - vs_outputs->color[1] != ATTR_UNUSED) { - vap_out->vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; - vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i; - - stream_loc[tabi++] = 2 + i; - } - } - - /* Back-face colors. */ - if (any_bcolor_used) { - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - vap_out->vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; - vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i); - - stream_loc[tabi++] = 4 + i; - } - } - - /* Texture coordinates. */ - gen_count = 0; - for (i = 0; i < ATTR_GENERIC_COUNT && gen_count < 8; i++) { - if (vs_outputs->generic[i] != ATTR_UNUSED) { - vap_out->vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << gen_count); - vap_out->vap_out_vtx_fmt[1] |= (4 << (3 * gen_count)); - - stream_loc[tabi++] = 6 + gen_count; - gen_count++; - } - } - - /* Fog coordinates. */ - if (gen_count < 8 && vs_outputs->fog != ATTR_UNUSED) { - vap_out->vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << gen_count); - vap_out->vap_out_vtx_fmt[1] |= (4 << (3 * gen_count)); - - stream_loc[tabi++] = 6 + gen_count; - gen_count++; - } - - /* WPOS. */ - if (gen_count < 8) { - vs->wpos_tex_output = gen_count; - stream_loc[tabi++] = 6 + gen_count; - } else { - vs_outputs->wpos = ATTR_UNUSED; - } - - for (; tabi < 16;) { - stream_loc[tabi++] = -1; - } -} - static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c) { struct r300_vertex_shader * vs = c->UserData; @@ -246,9 +158,7 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c) } /* WPOS. */ - if (outputs->wpos != ATTR_UNUSED) { - c->code->outputs[outputs->wpos] = reg++; - } + c->code->outputs[outputs->wpos] = reg++; } static void r300_dummy_vertex_shader( @@ -286,7 +196,6 @@ void r300_translate_vertex_shader(struct r300_context* r300, tgsi_scan_shader(tokens, &vs->info); r300_shader_read_vs_outputs(&vs->info, &vs->outputs); - r300_init_vs_output_mapping(vs); /* Setup the compiler */ rc_init(&compiler.Base); @@ -307,16 +216,11 @@ void r300_translate_vertex_shader(struct r300_context* r300, r300_tgsi_to_rc(&ttr, tokens); - compiler.RequiredOutputs = - ~(~0 << (vs->info.num_outputs + - (vs->outputs.wpos != ATTR_UNUSED ? 1 : 0))); - + compiler.RequiredOutputs = ~(~0 << (vs->info.num_outputs + 1)); compiler.SetHwInputOutput = &set_vertex_inputs_outputs; /* Insert the WPOS output. */ - if (vs->outputs.wpos != ATTR_UNUSED) { - rc_copy_output(&compiler.Base, 0, vs->outputs.wpos); - } + rc_copy_output(&compiler.Base, 0, vs->outputs.wpos); /* Invoke the compiler */ r3xx_compile_vertex_program(&compiler); @@ -343,32 +247,3 @@ void r300_translate_vertex_shader(struct r300_context* r300, /* And, finally... */ rc_destroy(&compiler.Base); } - -boolean r300_vertex_shader_setup_wpos(struct r300_context* r300) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_vap_output_state *vap_out = &vs->vap_out; - int tex_output = vs->wpos_tex_output; - uint32_t tex_fmt = R300_INPUT_CNTL_TC0 << tex_output; - - if (vs->outputs.wpos == ATTR_UNUSED) { - return FALSE; - } - - if (r300_fs(r300)->shader->inputs.wpos != ATTR_UNUSED) { - /* Enable WPOS in VAP. */ - if (!(vap_out->vap_vsm_vtx_assm & tex_fmt)) { - vap_out->vap_vsm_vtx_assm |= tex_fmt; - vap_out->vap_out_vtx_fmt[1] |= (4 << (3 * tex_output)); - return TRUE; - } - } else { - /* Disable WPOS in VAP. */ - if (vap_out->vap_vsm_vtx_assm & tex_fmt) { - vap_out->vap_vsm_vtx_assm &= ~tex_fmt; - vap_out->vap_out_vtx_fmt[1] &= ~(4 << (3 * tex_output)); - return TRUE; - } - } - return FALSE; -} diff --git a/src/gallium/drivers/r300/r300_vs.h b/src/gallium/drivers/r300/r300_vs.h index 56bcc3b70b..57b3fbca0b 100644 --- a/src/gallium/drivers/r300/r300_vs.h +++ b/src/gallium/drivers/r300/r300_vs.h @@ -39,7 +39,6 @@ struct r300_vertex_shader { struct tgsi_shader_info info; struct r300_shader_semantics outputs; - struct r300_vap_output_state vap_out; /* Whether the shader was replaced by a dummy one due to a shader * compilation failure. */ @@ -49,12 +48,6 @@ struct r300_vertex_shader { unsigned externals_count; unsigned immediates_count; - /* Stream locations for SWTCL or if TCL is bypassed. */ - int stream_loc_notcl[16]; - - /* Output stream location for WPOS. */ - int wpos_tex_output; - /* HWTCL-specific. */ /* Machine code (if translated) */ struct r300_vertex_program_code code; @@ -67,7 +60,4 @@ void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs, const struct tgsi_token *tokens); -/* Return TRUE if VAP (hwfmt) needs to be re-emitted. */ -boolean r300_vertex_shader_setup_wpos(struct r300_context* r300); - #endif /* R300_VS_H */ -- cgit v1.2.3 From 82027b2027d7cdb2cc9cd55b4746f80600a62a4e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 07:06:35 +0200 Subject: Revert "r300g: disable point sprites (again)" This reverts commit 3e0f1719d411b34f77fd2a053ecf83b43bb836ca. --- src/gallium/drivers/r300/r300_state.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 6a73f388fc..bea1b58e06 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -816,11 +816,8 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->clip_rule = state->scissor ? 0xAAAA : 0xFFFF; - /* XXX Disable point sprites until we know what's wrong with them. */ - rs->rs.sprite_coord_enable = 0; - /* Point sprites */ - if (rs->rs.sprite_coord_enable) { + if (state->sprite_coord_enable) { rs->stuffing_enable = R300_GB_POINT_STUFF_ENABLE; for (i = 0; i < 8; i++) { if (state->sprite_coord_enable & (1 << i)) -- cgit v1.2.3 From 9d3360567346036f1c2b0b5e9de9bd123d883762 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 13:27:57 +0200 Subject: r300g: always set the pitch of the first miplevel in the tiling flags This further reduces the number of DRM calls and flushes. --- src/gallium/drivers/r300/r300_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index bea1b58e06..d31e7c53f7 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -551,7 +551,7 @@ static void r300_fb_set_tiling_flags(struct r300_context *r300, level = new_state->cbufs[i]->level; r300->rws->buffer_set_tiling(r300->rws, tex->buffer, - tex->pitch[level], + tex->pitch[0], tex->microtile, tex->mip_macrotile[level]); } @@ -560,7 +560,7 @@ static void r300_fb_set_tiling_flags(struct r300_context *r300, level = new_state->zsbuf->level; r300->rws->buffer_set_tiling(r300->rws, tex->buffer, - tex->pitch[level], + tex->pitch[0], tex->microtile, tex->mip_macrotile[level]); } -- cgit v1.2.3 From db1ed3da6caa51bd07887b78bd30453ccf0b2ef5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 13:03:37 +0100 Subject: trace: Fix typo in method name. --- src/gallium/drivers/trace/tr_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 71ba1e909d..3d1fb96b91 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -812,7 +812,7 @@ trace_context_delete_vertex_elements_state(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - trace_dump_call_begin("pipe_context", "delete_verte_elements_state"); + trace_dump_call_begin("pipe_context", "delete_vertex_elements_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); -- cgit v1.2.3 From 316b6fa50936470ee4f3c14d982ec216ec352ea1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 13:04:08 +0100 Subject: retrace: Add sampler_view_destroy --- src/gallium/tests/python/retrace/interpreter.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/tests/python/retrace/interpreter.py b/src/gallium/tests/python/retrace/interpreter.py index 7118ff85ed..e58a69322e 100755 --- a/src/gallium/tests/python/retrace/interpreter.py +++ b/src/gallium/tests/python/retrace/interpreter.py @@ -432,6 +432,9 @@ class Context(Object): swizzle_b = templ.swizzle_g, swizzle_a = templ.swizzle_a) + def sampler_view_destroy(self, view): + pass + def set_fragment_sampler_views(self, num, views): for i in range(num): self.real.set_fragment_sampler_view(i, views[i]) @@ -456,6 +459,10 @@ class Context(Object): return elements[0:num_elements] def bind_vertex_elements_state(self, state): + if state is None: + self.real.set_vertex_elements(0) + return + elements = state num_elements = len(elements) self.velems = elements -- cgit v1.2.3 From 3b2cf97c5c84c3a92f97f335b27f754aa42c5259 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 17:19:03 +0200 Subject: r300g: fix surface_copy for compressed formats No accelerated blitting for these, it's too messy. --- src/gallium/drivers/r300/r300_blit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 928ad300ee..819d5e3f0c 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -137,7 +137,8 @@ void r300_surface_copy(struct pipe_context* pipe, if (!pipe->screen->is_format_supported(pipe->screen, old_format, src->texture->target, PIPE_BIND_RENDER_TARGET | - PIPE_BIND_SAMPLER_VIEW, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0) && + util_format_description(old_format)->layout == UTIL_FORMAT_LAYOUT_PLAIN) { switch (util_format_get_blocksize(old_format)) { case 1: new_format = PIPE_FORMAT_I8_UNORM; -- cgit v1.2.3 From b08b7b737760bc4ff8c8326763765c22c777580a Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 May 2010 17:31:06 +0200 Subject: r300g: do not validate buffers in check_cs It's already done in r300_emit_buffer_validate. This also fixes Total Annihilation 3D on debug builds at least. --- src/gallium/winsys/radeon/drm/radeon_r300.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c index 80923de937..fb779e4033 100644 --- a/src/gallium/winsys/radeon/drm/radeon_r300.c +++ b/src/gallium/winsys/radeon/drm/radeon_r300.c @@ -181,7 +181,7 @@ static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size) struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); struct radeon_cs *cs = ws->cs; - return radeon_validate(rws) && cs->cdw + size <= cs->ndw; + return cs->cdw + size <= cs->ndw; } static void radeon_begin_cs(struct r300_winsys_screen *rws, -- cgit v1.2.3 From 38e3fb23da9f75632992767fa3a01d335b9bb7ab Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sun, 2 May 2010 16:27:25 -0400 Subject: Update dri state tracker to use new API aware context create --- src/gallium/state_trackers/dri/common/dri_context.c | 2 +- src/gallium/state_trackers/dri/common/dri_context.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index a808d2d9dd..203682ef33 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.c +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -49,7 +49,7 @@ dri_init_extensions(struct dri_context *ctx) } GLboolean -dri_create_context(const __GLcontextModes * visual, +dri_create_context(gl_api api, const __GLcontextModes * visual, __DRIcontext * cPriv, void *sharedContextPrivate) { __DRIscreen *sPriv = cPriv->driScreenPriv; diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h index 9fe6b58101..54e56c6499 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.h +++ b/src/gallium/state_trackers/dri/common/dri_context.h @@ -34,6 +34,7 @@ #include "pipe/p_compiler.h" #include "dri_wrapper.h" +#include "main/mtypes.h" struct pipe_context; struct pipe_fence; @@ -83,7 +84,8 @@ struct dri_context * dri_get_current(__DRIscreen * driScreenPriv); boolean -dri_create_context(const __GLcontextModes * visual, +dri_create_context(gl_api api, + const __GLcontextModes * visual, __DRIcontext * driContextPriv, void *sharedContextPrivate); -- cgit v1.2.3 From 1a30d981591fd16faab4e36db6d434836272f117 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 2 May 2010 13:30:40 -0700 Subject: r300g: Remove unnecessary header. --- src/gallium/drivers/r300/r300_vs.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index b7609bad81..f3186431e1 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -22,7 +22,6 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r300_vs.h" -#include "r300_fs.h" #include "r300_context.h" #include "r300_screen.h" -- cgit v1.2.3 From 6edb18ee35fb15c501d8ff786830ef49ccbf2952 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 2 May 2010 13:34:50 -0700 Subject: svga: Include svga_surface.h in svga_screen.c. Fixes svga_screen_init_surface_functions implicit declaration warning. --- src/gallium/drivers/svga/svga_screen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 9fc613da74..ac310b6aed 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -34,6 +34,7 @@ #include "svga_resource_texture.h" #include "svga_resource.h" #include "svga_debug.h" +#include "svga_surface.h" #include "svga3d_shaderdefs.h" -- cgit v1.2.3 From 59253a79d823a4cfd1d65466c0a165d6d4c43a92 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 21:36:12 +0100 Subject: llvmpipe: Fix alpha blending for formats without alpha channel. Don't use the dst alpha channel from the swizzled tile when it does not exist in the true format. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 53 ++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 513e62e39e..5f861d6ca4 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1061,6 +1061,34 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, } +/** + * Return the blend factor equivalent to a destination alpha of one. + */ +static INLINE unsigned +force_dst_alpha_one(unsigned factor, boolean alpha) +{ + switch(factor) { + case PIPE_BLENDFACTOR_DST_ALPHA: + return PIPE_BLENDFACTOR_ONE; + case PIPE_BLENDFACTOR_INV_DST_ALPHA: + return PIPE_BLENDFACTOR_ZERO; + case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: + return PIPE_BLENDFACTOR_ZERO; + } + + if (alpha) { + switch(factor) { + case PIPE_BLENDFACTOR_DST_COLOR: + return PIPE_BLENDFACTOR_ONE; + case PIPE_BLENDFACTOR_INV_DST_COLOR: + return PIPE_BLENDFACTOR_ZERO; + } + } + + return factor; +} + + /** * We need to generate several variants of the fragment pipeline to match * all the combinations of the contributing state atoms. @@ -1102,6 +1130,7 @@ make_variant_key(struct llvmpipe_context *lp, key->nr_cbufs = lp->framebuffer.nr_cbufs; for (i = 0; i < lp->framebuffer.nr_cbufs; i++) { + struct pipe_rt_blend_state *blend_rt = &key->blend.rt[i]; const struct util_format_description *format_desc; unsigned chan; @@ -1109,7 +1138,7 @@ make_variant_key(struct llvmpipe_context *lp, assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB || format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB); - key->blend.rt[i].colormask = lp->blend->rt[i].colormask; + blend_rt->colormask = lp->blend->rt[i].colormask; /* mask out color channels not present in the color buffer. * Should be simple to incorporate per-cbuf writemasks: @@ -1118,7 +1147,27 @@ make_variant_key(struct llvmpipe_context *lp, enum util_format_swizzle swizzle = format_desc->swizzle[chan]; if(swizzle > UTIL_FORMAT_SWIZZLE_W) - key->blend.rt[i].colormask &= ~(1 << chan); + blend_rt->colormask &= ~(1 << chan); + } + + /* + * Our swizzled render tiles always have an alpha channel, but the linear + * render target format often does not, so force here the dst alpha to be + * one. + * + * This is not a mere optimization. Wrong results will be produced if the + * dst alpha is used, the dst format does not have alpha, and the previous + * rendering was not flushed from the swizzled to linear buffer. For + * example, NonPowTwo DCT. + * + * TODO: This should be generalized to all channels for better + * performance, but only alpha causes correctness issues. + */ + if (format_desc->swizzle[3] > UTIL_FORMAT_SWIZZLE_W) { + blend_rt->rgb_src_factor = force_dst_alpha_one(blend_rt->rgb_src_factor, FALSE); + blend_rt->rgb_dst_factor = force_dst_alpha_one(blend_rt->rgb_dst_factor, FALSE); + blend_rt->alpha_src_factor = force_dst_alpha_one(blend_rt->alpha_src_factor, TRUE); + blend_rt->alpha_dst_factor = force_dst_alpha_one(blend_rt->alpha_dst_factor, TRUE); } } -- cgit v1.2.3 From 4885cd4ff71b184ef38d709f365dd8d46d437960 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 21:37:24 +0100 Subject: softpipe: Fix alpha blending for formats without alpha channel. Don't use the dst alpha channel from the tile cache when it does not exist in the true format. --- src/gallium/drivers/softpipe/sp_quad_blend.c | 168 +++++++++++++++++---------- 1 file changed, 108 insertions(+), 60 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c index ead489393e..00187febf0 100644 --- a/src/gallium/drivers/softpipe/sp_quad_blend.c +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c @@ -33,6 +33,7 @@ #include "pipe/p_defines.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_format.h" #include "sp_context.h" #include "sp_quad.h" #include "sp_tile_cache.h" @@ -224,7 +225,8 @@ static void blend_quad(struct quad_stage *qs, float (*quadColor)[4], float (*dest)[4], - unsigned cbuf) + unsigned cbuf, + boolean has_dst_alpha) { static const float zero[4] = { 0, 0, 0, 0 }; static const float one[4] = { 1, 1, 1, 1 }; @@ -259,24 +261,34 @@ blend_quad(struct quad_stage *qs, VEC4_MUL(source[2], quadColor[2], dest[2]); /* B */ break; case PIPE_BLENDFACTOR_DST_ALPHA: - { - const float *alpha = dest[3]; - VEC4_MUL(source[0], quadColor[0], alpha); /* R */ - VEC4_MUL(source[1], quadColor[1], alpha); /* G */ - VEC4_MUL(source[2], quadColor[2], alpha); /* B */ - } - break; + if (has_dst_alpha) { + const float *alpha = dest[3]; + VEC4_MUL(source[0], quadColor[0], alpha); /* R */ + VEC4_MUL(source[1], quadColor[1], alpha); /* G */ + VEC4_MUL(source[2], quadColor[2], alpha); /* B */ + } + else { + VEC4_COPY(source[0], quadColor[0]); /* R */ + VEC4_COPY(source[1], quadColor[1]); /* G */ + VEC4_COPY(source[2], quadColor[2]); /* B */ + } + break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: - { - const float *alpha = quadColor[3]; - float diff[4], temp[4]; - VEC4_SUB(diff, one, dest[3]); - VEC4_MIN(temp, alpha, diff); - VEC4_MUL(source[0], quadColor[0], temp); /* R */ - VEC4_MUL(source[1], quadColor[1], temp); /* G */ - VEC4_MUL(source[2], quadColor[2], temp); /* B */ - } - break; + if (has_dst_alpha) { + const float *alpha = quadColor[3]; + float diff[4], temp[4]; + VEC4_SUB(diff, one, dest[3]); + VEC4_MIN(temp, alpha, diff); + VEC4_MUL(source[0], quadColor[0], temp); /* R */ + VEC4_MUL(source[1], quadColor[1], temp); /* G */ + VEC4_MUL(source[2], quadColor[2], temp); /* B */ + } + else { + VEC4_COPY(source[0], zero); /* R */ + VEC4_COPY(source[1], zero); /* G */ + VEC4_COPY(source[2], zero); /* B */ + } + break; case PIPE_BLENDFACTOR_CONST_COLOR: { float comp[4]; @@ -329,14 +341,19 @@ blend_quad(struct quad_stage *qs, } break; case PIPE_BLENDFACTOR_INV_DST_ALPHA: - { - float inv_alpha[4]; - VEC4_SUB(inv_alpha, one, dest[3]); - VEC4_MUL(source[0], quadColor[0], inv_alpha); /* R */ - VEC4_MUL(source[1], quadColor[1], inv_alpha); /* G */ - VEC4_MUL(source[2], quadColor[2], inv_alpha); /* B */ - } - break; + if (has_dst_alpha) { + float inv_alpha[4]; + VEC4_SUB(inv_alpha, one, dest[3]); + VEC4_MUL(source[0], quadColor[0], inv_alpha); /* R */ + VEC4_MUL(source[1], quadColor[1], inv_alpha); /* G */ + VEC4_MUL(source[2], quadColor[2], inv_alpha); /* B */ + } + else { + VEC4_COPY(source[0], zero); /* R */ + VEC4_COPY(source[1], zero); /* G */ + VEC4_COPY(source[2], zero); /* B */ + } + break; case PIPE_BLENDFACTOR_INV_DST_COLOR: { float inv_comp[4]; @@ -399,7 +416,10 @@ blend_quad(struct quad_stage *qs, case PIPE_BLENDFACTOR_DST_COLOR: /* fall-through */ case PIPE_BLENDFACTOR_DST_ALPHA: - VEC4_MUL(source[3], quadColor[3], dest[3]); /* A */ + if (has_dst_alpha) + VEC4_MUL(source[3], quadColor[3], dest[3]); /* A */ + else + VEC4_COPY(source[3], quadColor[3]); /* A */ break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* multiply alpha by 1.0 */ @@ -429,12 +449,15 @@ blend_quad(struct quad_stage *qs, case PIPE_BLENDFACTOR_INV_DST_COLOR: /* fall-through */ case PIPE_BLENDFACTOR_INV_DST_ALPHA: - { - float inv_alpha[4]; - VEC4_SUB(inv_alpha, one, dest[3]); - VEC4_MUL(source[3], quadColor[3], inv_alpha); /* A */ - } - break; + if (has_dst_alpha) { + float inv_alpha[4]; + VEC4_SUB(inv_alpha, one, dest[3]); + VEC4_MUL(source[3], quadColor[3], inv_alpha); /* A */ + } + else { + VEC4_COPY(source[3], zero); /* A */ + } + break; case PIPE_BLENDFACTOR_INV_CONST_COLOR: /* fall-through */ case PIPE_BLENDFACTOR_INV_CONST_ALPHA: @@ -468,9 +491,14 @@ blend_quad(struct quad_stage *qs, VEC4_MUL(dest[2], dest[2], quadColor[3]); /* B * A */ break; case PIPE_BLENDFACTOR_DST_ALPHA: - VEC4_MUL(dest[0], dest[0], dest[3]); /* R * A */ - VEC4_MUL(dest[1], dest[1], dest[3]); /* G * A */ - VEC4_MUL(dest[2], dest[2], dest[3]); /* B * A */ + if (has_dst_alpha) { + VEC4_MUL(dest[0], dest[0], dest[3]); /* R * A */ + VEC4_MUL(dest[1], dest[1], dest[3]); /* G * A */ + VEC4_MUL(dest[2], dest[2], dest[3]); /* B * A */ + } + else { + /* dest = dest * 1 NO-OP, leave dest as-is */ + } break; case PIPE_BLENDFACTOR_DST_COLOR: VEC4_MUL(dest[0], dest[0], dest[0]); /* R */ @@ -478,15 +506,20 @@ blend_quad(struct quad_stage *qs, VEC4_MUL(dest[2], dest[2], dest[2]); /* B */ break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: - { - const float *alpha = quadColor[3]; - float diff[4], temp[4]; - VEC4_SUB(diff, one, dest[3]); - VEC4_MIN(temp, alpha, diff); - VEC4_MUL(dest[0], quadColor[0], temp); /* R */ - VEC4_MUL(dest[1], quadColor[1], temp); /* G */ - VEC4_MUL(dest[2], quadColor[2], temp); /* B */ - } + if (has_dst_alpha) { + const float *alpha = quadColor[3]; + float diff[4], temp[4]; + VEC4_SUB(diff, one, dest[3]); + VEC4_MIN(temp, alpha, diff); + VEC4_MUL(dest[0], quadColor[0], temp); /* R */ + VEC4_MUL(dest[1], quadColor[1], temp); /* G */ + VEC4_MUL(dest[2], quadColor[2], temp); /* B */ + } + else { + VEC4_COPY(dest[0], zero); /* R */ + VEC4_COPY(dest[1], zero); /* G */ + VEC4_COPY(dest[2], zero); /* B */ + } break; case PIPE_BLENDFACTOR_CONST_COLOR: { @@ -539,13 +572,18 @@ blend_quad(struct quad_stage *qs, } break; case PIPE_BLENDFACTOR_INV_DST_ALPHA: - { - float inv_comp[4]; - VEC4_SUB(inv_comp, one, dest[3]); /* A */ - VEC4_MUL(dest[0], inv_comp, dest[0]); /* R */ - VEC4_MUL(dest[1], inv_comp, dest[1]); /* G */ - VEC4_MUL(dest[2], inv_comp, dest[2]); /* B */ - } + if (has_dst_alpha) { + float inv_comp[4]; + VEC4_SUB(inv_comp, one, dest[3]); /* A */ + VEC4_MUL(dest[0], inv_comp, dest[0]); /* R */ + VEC4_MUL(dest[1], inv_comp, dest[1]); /* G */ + VEC4_MUL(dest[2], inv_comp, dest[2]); /* B */ + } + else { + VEC4_COPY(dest[0], zero); /* R */ + VEC4_COPY(dest[1], zero); /* G */ + VEC4_COPY(dest[2], zero); /* B */ + } break; case PIPE_BLENDFACTOR_INV_DST_COLOR: { @@ -605,7 +643,12 @@ blend_quad(struct quad_stage *qs, case PIPE_BLENDFACTOR_DST_COLOR: /* fall-through */ case PIPE_BLENDFACTOR_DST_ALPHA: - VEC4_MUL(dest[3], dest[3], dest[3]); /* A */ + if (has_dst_alpha) { + VEC4_MUL(dest[3], dest[3], dest[3]); /* A */ + } + else { + /* dest = dest * 1 NO-OP, leave dest as-is */ + } break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* dest = dest * 1 NO-OP, leave dest as-is */ @@ -634,12 +677,15 @@ blend_quad(struct quad_stage *qs, case PIPE_BLENDFACTOR_INV_DST_COLOR: /* fall-through */ case PIPE_BLENDFACTOR_INV_DST_ALPHA: - { - float inv_comp[4]; - VEC4_SUB(inv_comp, one, dest[3]); /* A */ - VEC4_MUL(dest[3], inv_comp, dest[3]); /* A */ - } - break; + if (has_dst_alpha) { + float inv_comp[4]; + VEC4_SUB(inv_comp, one, dest[3]); /* A */ + VEC4_MUL(dest[3], inv_comp, dest[3]); /* A */ + } + else { + VEC4_COPY(dest[3], zero); /* A */ + } + break; case PIPE_BLENDFACTOR_INV_CONST_COLOR: /* fall-through */ case PIPE_BLENDFACTOR_INV_CONST_ALPHA: @@ -751,6 +797,8 @@ blend_fallback(struct quad_stage *qs, = sp_get_cached_tile(softpipe->cbuf_cache[cbuf], quads[0]->input.x0, quads[0]->input.y0); + boolean has_dst_alpha + = util_format_has_alpha(softpipe->framebuffer.cbufs[cbuf]->format); uint q, i, j; for (q = 0; q < nr; q++) { @@ -774,7 +822,7 @@ blend_fallback(struct quad_stage *qs, logicop_quad( qs, quadColor, dest ); } else if (blend->rt[blend_buf].blend_enable) { - blend_quad( qs, quadColor, dest, cbuf ); + blend_quad( qs, quadColor, dest, cbuf, has_dst_alpha ); } if (blend->rt[blend_buf].colormask != 0xf) -- cgit v1.2.3 From 7e28479c3af6a568d0421113b10f34f66f38d1d1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 22:33:43 +0100 Subject: svga: Update flags documentation. --- src/gallium/drivers/svga/svga_winsys.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index 3892addafd..c155f5dae2 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -85,7 +85,7 @@ struct svga_winsys_context /** * Emit a relocation for a host surface. * - * @param flags PIPE_BUFFER_USAGE_GPU_READ/WRITE + * @param flags bitmask of SVGA_RELOC_* flags * * NOTE: Order of this call does matter. It should be the same order * as relocations appear in the command buffer. @@ -99,7 +99,7 @@ struct svga_winsys_context /** * Emit a relocation for a guest memory region. * - * @param flags PIPE_BUFFER_USAGE_GPU_READ/WRITE + * @param flags bitmask of SVGA_RELOC_* flags * * NOTE: Order of this call does matter. It should be the same order * as relocations appear in the command buffer. @@ -230,7 +230,7 @@ struct svga_winsys_screen /** * Buffer management. Buffer attributes are mostly fixed over its lifetime. * - * XXX usage seems to be a bitmask of SVGA_BUFFER_USAGE_* flags. + * @param usage bitmask of SVGA_BUFFER_USAGE_* flags. * * alignment indicates the client's alignment requirements, eg for * SSE instructions. @@ -243,15 +243,12 @@ struct svga_winsys_screen /** * Map the entire data store of a buffer object into the client's address. - * flags is a bitmask of: - * - PB_USAGE_CPU_READ/WRITE - * - PB_USAGE_DONTBLOCK - * - PB_USAGE_UNSYNCHRONIZED + * flags is a bitmaks of PIPE_TRANSFER_* */ void * (*buffer_map)( struct svga_winsys_screen *sws, struct svga_winsys_buffer *buf, - unsigned usage ); + unsigned flags ); void (*buffer_unmap)( struct svga_winsys_screen *sws, -- cgit v1.2.3 From 49e37469bdafe663fa08a5a446e44f3ede168a13 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 22:35:53 +0100 Subject: svga: Remove empty file. --- src/gallium/drivers/svga/svga_resource_buffer_host.c | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 src/gallium/drivers/svga/svga_resource_buffer_host.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_resource_buffer_host.c b/src/gallium/drivers/svga/svga_resource_buffer_host.c deleted file mode 100644 index 139597f9cb..0000000000 --- a/src/gallium/drivers/svga/svga_resource_buffer_host.c +++ /dev/null @@ -1,2 +0,0 @@ - - -- cgit v1.2.3 From b84590994c4261d85485357263146d5e3d8827eb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 2 May 2010 23:54:42 +0100 Subject: svga: Remove the screen private context. All affected operations have already been moved to context. More cleanup work can be done, in particular with the buffer transfers. --- src/gallium/drivers/svga/svga_context.c | 18 ++++++--- src/gallium/drivers/svga/svga_pipe_query.c | 3 +- src/gallium/drivers/svga/svga_resource_buffer.c | 4 -- src/gallium/drivers/svga/svga_resource_buffer.h | 2 +- .../drivers/svga/svga_resource_buffer_upload.c | 22 +++++++---- src/gallium/drivers/svga/svga_resource_texture.c | 37 ++++++++++--------- src/gallium/drivers/svga/svga_sampler_view.c | 2 +- src/gallium/drivers/svga/svga_screen.c | 25 ------------- src/gallium/drivers/svga/svga_screen.h | 12 ++---- src/gallium/drivers/svga/svga_surface.c | 43 ++++++---------------- src/gallium/drivers/svga/svga_surface.h | 1 - 11 files changed, 63 insertions(+), 106 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 3228a6d3d7..75d8afb2ea 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -194,6 +194,7 @@ void svga_context_flush( struct svga_context *svga, struct pipe_fence_handle **pfence ) { struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); + struct pipe_fence_handle *fence = NULL; svga->curr.nr_fbs = 0; @@ -202,21 +203,26 @@ void svga_context_flush( struct svga_context *svga, u_upload_flush(svga->upload_vb); u_upload_flush(svga->upload_ib); - /* Flush screen, to ensure that texture dma uploads are processed + /* Ensure that texture dma uploads are processed * before submitting commands. */ - svga_screen_flush(svgascreen, NULL); - svga_context_flush_buffers(svga); /* Flush pending commands to hardware: */ - svga->swc->flush(svga->swc, pfence); + svga->swc->flush(svga->swc, &fence); + + svga_screen_cache_flush(svgascreen, fence); if (SVGA_DEBUG & DEBUG_SYNC) { - if (pfence && *pfence) - svga->pipe.screen->fence_finish( svga->pipe.screen, *pfence, 0); + if (fence) + svga->pipe.screen->fence_finish( svga->pipe.screen, fence, 0); } + + if(pfence) + *pfence = fence; + else + svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL); } diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 9c6f5858ba..96fb4b8e53 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -68,6 +68,7 @@ static boolean svga_get_query_result(struct pipe_context *pipe, static struct pipe_query *svga_create_query( struct pipe_context *pipe, unsigned query_type ) { + struct svga_context *svga = svga_context( pipe ); struct svga_screen *svgascreen = svga_screen(pipe->screen); struct svga_winsys_screen *sws = svgascreen->sws; struct svga_query *sq; @@ -80,7 +81,7 @@ static struct pipe_query *svga_create_query( struct pipe_context *pipe, sq->type = SVGA3D_QUERYTYPE_OCCLUSION; - sq->hwbuf = svga_winsys_buffer_create(svgascreen, + sq->hwbuf = svga_winsys_buffer_create(svga, 1, SVGA_BUFFER_USAGE_PINNED, sizeof *sq->queryResult); diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c index 18eeff9c67..198d401332 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.c +++ b/src/gallium/drivers/svga/svga_resource_buffer.c @@ -125,8 +125,6 @@ svga_buffer_map_range( struct pipe_screen *screen, } if(map) { - pipe_mutex_lock(ss->swc_mutex); - ++sbuf->map.count; if (usage & PIPE_TRANSFER_WRITE) { @@ -135,8 +133,6 @@ svga_buffer_map_range( struct pipe_screen *screen, if (usage & PIPE_TRANSFER_FLUSH_EXPLICIT) sbuf->map.flush_explicit = TRUE; } - - pipe_mutex_unlock(ss->swc_mutex); } return map; diff --git a/src/gallium/drivers/svga/svga_resource_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h index 55e7321184..d3ec11bfd5 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.h +++ b/src/gallium/drivers/svga/svga_resource_buffer.h @@ -238,7 +238,7 @@ void svga_context_flush_buffers(struct svga_context *svga); struct svga_winsys_buffer * -svga_winsys_buffer_create(struct svga_screen *ss, +svga_winsys_buffer_create(struct svga_context *svga, unsigned alignment, unsigned usage, unsigned size); diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index acef60f464..3de5216a94 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -40,15 +40,21 @@ #include "svga_debug.h" -/* Allocate a winsys_buffer (ie. DMA, aka GMR memory). +/** + * Allocate a winsys_buffer (ie. DMA, aka GMR memory). + * + * It will flush and retry in case the first attempt to create a DMA buffer + * fails, so it should not be called from any function involved in flushing + * to avoid recursion. */ struct svga_winsys_buffer * -svga_winsys_buffer_create( struct svga_screen *ss, +svga_winsys_buffer_create( struct svga_context *svga, unsigned alignment, unsigned usage, unsigned size ) { - struct svga_winsys_screen *sws = ss->sws; + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); + struct svga_winsys_screen *sws = svgascreen->sws; struct svga_winsys_buffer *buf; /* Just try */ @@ -59,9 +65,8 @@ svga_winsys_buffer_create( struct svga_screen *ss, size); /* Try flushing all pending DMAs */ - svga_screen_flush(ss, NULL); + svga_context_flush(svga, NULL); buf = sws->buffer_create(sws, alignment, usage, size); - } return buf; @@ -95,11 +100,12 @@ svga_buffer_create_hw_storage(struct svga_screen *ss, assert(!sbuf->user); if(!sbuf->hwbuf) { + struct svga_winsys_screen *sws = ss->sws; unsigned alignment = 16; unsigned usage = 0; unsigned size = sbuf->b.b.width0; - sbuf->hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size); + sbuf->hwbuf = sws->buffer_create(sws, alignment, usage, size); if(!sbuf->hwbuf) return PIPE_ERROR_OUT_OF_MEMORY; @@ -476,12 +482,12 @@ svga_buffer_upload_piecewise(struct svga_screen *ss, if (offset + size > range->end) size = range->end - offset; - hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size); + hwbuf = sws->buffer_create(sws, alignment, usage, size); while (!hwbuf) { size /= 2; if (!size) return PIPE_ERROR_OUT_OF_MEMORY; - hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size); + hwbuf = sws->buffer_create(sws, alignment, usage, size); } SVGA_DBG(DEBUG_DMA, " bytes %u - %u\n", diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index f06b0323d8..ff83c750aa 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -163,12 +163,12 @@ svga_translate_format_render(enum pipe_format format) static INLINE void -svga_transfer_dma_band(struct svga_transfer *st, +svga_transfer_dma_band(struct svga_context *svga, + struct svga_transfer *st, SVGA3dTransferType transfer, unsigned y, unsigned h, unsigned srcy) { struct svga_texture *texture = svga_texture(st->base.resource); - struct svga_screen *screen = svga_screen(texture->b.b.screen); SVGA3dCopyBox box; enum pipe_error ret; @@ -195,20 +195,19 @@ svga_transfer_dma_band(struct svga_transfer *st, box.srcy = srcy; box.srcz = 0; - pipe_mutex_lock(screen->swc_mutex); - ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1); + ret = SVGA3D_SurfaceDMA(svga->swc, st, transfer, &box, 1); if(ret != PIPE_OK) { - screen->swc->flush(screen->swc, NULL); - ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1); + svga->swc->flush(svga->swc, NULL); + ret = SVGA3D_SurfaceDMA(svga->swc, st, transfer, &box, 1); assert(ret == PIPE_OK); } - pipe_mutex_unlock(screen->swc_mutex); } static INLINE void -svga_transfer_dma(struct svga_transfer *st, - SVGA3dTransferType transfer) +svga_transfer_dma(struct svga_context *svga, + struct svga_transfer *st, + SVGA3dTransferType transfer) { struct svga_texture *texture = svga_texture(st->base.resource); struct svga_screen *screen = svga_screen(texture->b.b.screen); @@ -223,10 +222,10 @@ svga_transfer_dma(struct svga_transfer *st, if(!st->swbuf) { /* Do the DMA transfer in a single go */ - svga_transfer_dma_band(st, transfer, st->base.box.y, st->base.box.height, 0); + svga_transfer_dma_band(svga, st, transfer, st->base.box.y, st->base.box.height, 0); if(transfer == SVGA3D_READ_HOST_VRAM) { - svga_screen_flush(screen, &fence); + svga_context_flush(svga, &fence); sws->fence_finish(sws, fence, 0); sws->fence_reference(sws, &fence, NULL); } @@ -256,7 +255,7 @@ svga_transfer_dma(struct svga_transfer *st, /* Wait for the previous DMAs to complete */ /* TODO: keep one DMA (at half the size) in the background */ if(y) { - svga_screen_flush(screen, &fence); + svga_context_flush(svga, &fence); sws->fence_finish(sws, fence, 0); sws->fence_reference(sws, &fence, NULL); } @@ -269,10 +268,10 @@ svga_transfer_dma(struct svga_transfer *st, } } - svga_transfer_dma_band(st, transfer, y, h, srcy); + svga_transfer_dma_band(svga, st, transfer, y, h, srcy); if(transfer == SVGA3D_READ_HOST_VRAM) { - svga_screen_flush(screen, &fence); + svga_context_flush(svga, &fence); sws->fence_finish(sws, fence, 0); hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_READ); @@ -342,6 +341,7 @@ svga_texture_get_transfer(struct pipe_context *pipe, unsigned usage, const struct pipe_box *box) { + struct svga_context *svga = svga_context(pipe); struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st; @@ -365,12 +365,12 @@ svga_texture_get_transfer(struct pipe_context *pipe, st->hw_nblocksy = nblocksy; - st->hwbuf = svga_winsys_buffer_create(ss, + st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy*st->base.stride); while(!st->hwbuf && (st->hw_nblocksy /= 2)) { - st->hwbuf = svga_winsys_buffer_create(ss, + st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy*st->base.stride); @@ -393,7 +393,7 @@ svga_texture_get_transfer(struct pipe_context *pipe, } if (usage & PIPE_TRANSFER_READ) - svga_transfer_dma(st, SVGA3D_READ_HOST_VRAM); + svga_transfer_dma(svga, st, SVGA3D_READ_HOST_VRAM); return &st->base; @@ -445,13 +445,14 @@ static void svga_texture_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *transfer) { + struct svga_context *svga = svga_context(pipe); struct svga_texture *tex = svga_texture(transfer->resource); struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st = svga_transfer(transfer); if (st->base.usage & PIPE_TRANSFER_WRITE) { - svga_transfer_dma(st, SVGA3D_WRITE_HOST_VRAM); + svga_transfer_dma(svga, st, SVGA3D_WRITE_HOST_VRAM); ss->texture_timestamp++; tex->view_age[transfer->sr.level] = ++(tex->age); tex->defined[transfer->sr.face][transfer->sr.level] = TRUE; diff --git a/src/gallium/drivers/svga/svga_sampler_view.c b/src/gallium/drivers/svga/svga_sampler_view.c index fbae552f78..6911f13f77 100644 --- a/src/gallium/drivers/svga/svga_sampler_view.c +++ b/src/gallium/drivers/svga/svga_sampler_view.c @@ -169,7 +169,7 @@ svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view * for (i = v->min_lod; i <= v->max_lod; i++) { for (k = 0; k < numFaces; k++) { if (v->age < tex->view_age[i]) - svga_texture_copy_handle(svga, NULL, + svga_texture_copy_handle(svga, tex->handle, 0, 0, 0, i, k, v->handle, 0, 0, 0, i - v->min_lod, k, u_minify(tex->b.b.width0, i), diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index ac310b6aed..45e477e65b 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -347,8 +347,6 @@ svga_destroy_screen( struct pipe_screen *screen ) pipe_mutex_destroy(svgascreen->swc_mutex); pipe_mutex_destroy(svgascreen->tex_mutex); - svgascreen->swc->destroy(svgascreen->swc); - svgascreen->sws->destroy(svgascreen->sws); FREE(svgascreen); @@ -418,10 +416,6 @@ svga_screen_create(struct svga_winsys_screen *sws) svgascreen->use_vs30 = svgascreen->use_ps30 = FALSE; #endif - svgascreen->swc = sws->context_create(sws); - if(!svgascreen->swc) - goto error2; - pipe_mutex_init(svgascreen->tex_mutex); pipe_mutex_init(svgascreen->swc_mutex); @@ -434,25 +428,6 @@ error1: return NULL; } -void svga_screen_flush( struct svga_screen *svgascreen, - struct pipe_fence_handle **pfence ) -{ - struct pipe_fence_handle *fence = NULL; - - SVGA_DBG(DEBUG_PERF, "%s\n", __FUNCTION__); - - pipe_mutex_lock(svgascreen->swc_mutex); - svgascreen->swc->flush(svgascreen->swc, &fence); - pipe_mutex_unlock(svgascreen->swc_mutex); - - svga_screen_cache_flush(svgascreen, fence); - - if(pfence) - *pfence = fence; - else - svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL); -} - struct svga_winsys_screen * svga_winsys_screen(struct pipe_screen *screen) { diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h index 9dc229b0a8..86ec89d88c 100644 --- a/src/gallium/drivers/svga/svga_screen.h +++ b/src/gallium/drivers/svga/svga_screen.h @@ -60,14 +60,11 @@ struct svga_screen boolean no_sampler_view; } debug; - /* The screen needs its own context */ - struct svga_winsys_context *swc; - struct SVGACmdMemory *fifo; - unsigned texture_timestamp; pipe_mutex tex_mutex; - pipe_mutex swc_mutex; /* Protects the use of swc and dirty_buffers */ - + + pipe_mutex swc_mutex; /* Used for buffer uploads */ + struct svga_host_surface_cache cache; }; @@ -83,7 +80,4 @@ struct svga_screen * svga_screen(struct pipe_screen *screen); #endif -void svga_screen_flush( struct svga_screen *svga_screen, - struct pipe_fence_handle **pfence ); - #endif /* SVGA_SCREEN_H */ diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index dc1d9a850d..bd2cc38004 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -43,7 +43,6 @@ void svga_texture_copy_handle(struct svga_context *svga, - struct svga_screen *ss, struct svga_winsys_surface *src_handle, unsigned src_x, unsigned src_y, unsigned src_z, unsigned src_level, unsigned src_face, @@ -56,7 +55,7 @@ svga_texture_copy_handle(struct svga_context *svga, enum pipe_error ret; SVGA3dCopyBox box, *boxes; - assert(svga || ss); + assert(svga); src.handle = src_handle; src.real_level = src_level; @@ -84,39 +83,20 @@ svga_texture_copy_handle(struct svga_context *svga, dst_handle, dst_level, dst_x, dst_y, dst_z); */ - if (svga) { + ret = SVGA3D_BeginSurfaceCopy(svga->swc, + &src.base, + &dst.base, + &boxes, 1); + if(ret != PIPE_OK) { + svga_context_flush(svga, NULL); ret = SVGA3D_BeginSurfaceCopy(svga->swc, &src.base, &dst.base, &boxes, 1); - if(ret != PIPE_OK) { - svga_context_flush(svga, NULL); - ret = SVGA3D_BeginSurfaceCopy(svga->swc, - &src.base, - &dst.base, - &boxes, 1); - assert(ret == PIPE_OK); - } - *boxes = box; - SVGA_FIFOCommitAll(svga->swc); - } else { - pipe_mutex_lock(ss->swc_mutex); - ret = SVGA3D_BeginSurfaceCopy(ss->swc, - &src.base, - &dst.base, - &boxes, 1); - if(ret != PIPE_OK) { - ss->swc->flush(ss->swc, NULL); - ret = SVGA3D_BeginSurfaceCopy(ss->swc, - &src.base, - &dst.base, - &boxes, 1); - assert(ret == PIPE_OK); - } - *boxes = box; - SVGA_FIFOCommitAll(ss->swc); - pipe_mutex_unlock(ss->swc_mutex); + assert(ret == PIPE_OK); } + *boxes = box; + SVGA_FIFOCommitAll(svga->swc); } @@ -183,7 +163,6 @@ svga_texture_view_surface(struct pipe_context *pipe, 1); svga_texture_copy_handle(svga_context(pipe), - ss, tex->handle, 0, 0, z_offset, i + start_mip, @@ -346,7 +325,7 @@ svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf) if (s->handle != tex->handle) { SVGA_DBG(DEBUG_VIEWS, "svga: Surface propagate: tex %p, level %u, from %p\n", tex, surf->level, surf); - svga_texture_copy_handle(svga_context(pipe), ss, + svga_texture_copy_handle(svga_context(pipe), s->handle, 0, 0, 0, s->real_level, s->real_face, tex->handle, 0, 0, surf->zslice, surf->level, surf->face, u_minify(tex->b.b.width0, surf->level), diff --git a/src/gallium/drivers/svga/svga_surface.h b/src/gallium/drivers/svga/svga_surface.h index b50ecdc994..13bd5b19b6 100644 --- a/src/gallium/drivers/svga/svga_surface.h +++ b/src/gallium/drivers/svga/svga_surface.h @@ -74,7 +74,6 @@ svga_texture_view_surface(struct pipe_context *pipe, void svga_texture_copy_handle(struct svga_context *svga, - struct svga_screen *ss, struct svga_winsys_surface *src_handle, unsigned src_x, unsigned src_y, unsigned src_z, unsigned src_level, unsigned src_face, -- cgit v1.2.3 From 5362f77b470f9c003c09ff258b33817bc9a9dbfe Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sun, 2 May 2010 15:57:25 -0700 Subject: llvmpipe: add lp_test_* to .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xavier Chantry Signed-off-by: José Fonseca --- src/gallium/drivers/llvmpipe/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/.gitignore b/src/gallium/drivers/llvmpipe/.gitignore index 257b72d7b2..a1b6f56e0d 100644 --- a/src/gallium/drivers/llvmpipe/.gitignore +++ b/src/gallium/drivers/llvmpipe/.gitignore @@ -1 +1,5 @@ lp_tile_soa.c +lp_test_blend +lp_test_conv +lp_test_format +lp_test_printf -- cgit v1.2.3 From d0f9e7521c6e59852ceb00b30f063d0fe2c72965 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sun, 2 May 2010 16:12:50 -0700 Subject: gallium/util: print \n after DXTn printf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-add commit 2d65a7caf97684aa654088c76a74b632fbd685fa Signed-off-by: Xavier Chantry Signed-off-by: José Fonseca --- src/gallium/auxiliary/util/u_format_s3tc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c index 5b279b8fe2..bb989c29d8 100644 --- a/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/src/gallium/auxiliary/util/u_format_s3tc.c @@ -120,7 +120,7 @@ util_format_s3tc_init(void) library = util_dl_open(DXTN_LIBNAME); if (!library) { debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn " - "compression/decompression unavailable"); + "compression/decompression unavailable\n"); return; } @@ -142,7 +142,7 @@ util_format_s3tc_init(void) !util_format_dxtn_pack) { debug_printf("couldn't reference all symbols in " DXTN_LIBNAME ", software DXTn compression/decompression " - "unavailable"); + "unavailable\n"); util_dl_close(library); return; } -- cgit v1.2.3 From eda7c2506aff13726a265c70711d594ad8fddca3 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 1 May 2010 11:50:36 +0100 Subject: identity: Whitespace & Style --- src/gallium/drivers/identity/id_context.c | 78 +++++++++++++++---------------- src/gallium/drivers/identity/id_objects.c | 4 +- src/gallium/drivers/identity/id_objects.h | 4 +- src/gallium/drivers/identity/id_screen.c | 18 +++---- 4 files changed, 52 insertions(+), 52 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 0bc8bf2196..6e88239d65 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -684,9 +684,9 @@ identity_flush(struct pipe_context *_pipe, static unsigned int identity_is_resource_referenced(struct pipe_context *_pipe, - struct pipe_resource *_resource, - unsigned face, - unsigned level) + struct pipe_resource *_resource, + unsigned face, + unsigned level) { struct identity_context *id_pipe = identity_context(_pipe); struct identity_resource *id_resource = identity_resource(_resource); @@ -694,9 +694,9 @@ identity_is_resource_referenced(struct pipe_context *_pipe, struct pipe_resource *texture = id_resource->resource; return pipe->is_resource_referenced(pipe, - texture, - face, - level); + texture, + face, + level); } static struct pipe_sampler_view * @@ -741,10 +741,10 @@ identity_sampler_view_destroy(struct pipe_context *pipe, static struct pipe_transfer * identity_context_get_transfer(struct pipe_context *_context, - struct pipe_resource *_resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box) + struct pipe_resource *_resource, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box) { struct identity_context *id_context = identity_context(_context); struct identity_resource *id_resource = identity_resource(_resource); @@ -753,10 +753,10 @@ identity_context_get_transfer(struct pipe_context *_context, struct pipe_transfer *result; result = context->get_transfer(context, - texture, - sr, - usage, - box); + texture, + sr, + usage, + box); if (result) return identity_transfer_create(id_context, id_resource, result); @@ -765,7 +765,7 @@ identity_context_get_transfer(struct pipe_context *_context, static void identity_context_transfer_destroy(struct pipe_context *_pipe, - struct pipe_transfer *_transfer) + struct pipe_transfer *_transfer) { identity_transfer_destroy(identity_context(_pipe), identity_transfer(_transfer)); @@ -773,7 +773,7 @@ identity_context_transfer_destroy(struct pipe_context *_pipe, static void * identity_context_transfer_map(struct pipe_context *_context, - struct pipe_transfer *_transfer) + struct pipe_transfer *_transfer) { struct identity_context *id_context = identity_context(_context); struct identity_transfer *id_transfer = identity_transfer(_transfer); @@ -781,15 +781,15 @@ identity_context_transfer_map(struct pipe_context *_context, struct pipe_transfer *transfer = id_transfer->transfer; return context->transfer_map(context, - transfer); + transfer); } static void -identity_context_transfer_flush_region( struct pipe_context *_context, - struct pipe_transfer *_transfer, - const struct pipe_box *box) +identity_context_transfer_flush_region(struct pipe_context *_context, + struct pipe_transfer *_transfer, + const struct pipe_box *box) { struct identity_context *id_context = identity_context(_context); struct identity_transfer *id_transfer = identity_transfer(_transfer); @@ -797,14 +797,14 @@ identity_context_transfer_flush_region( struct pipe_context *_context, struct pipe_transfer *transfer = id_transfer->transfer; context->transfer_flush_region(context, - transfer, - box); + transfer, + box); } static void identity_context_transfer_unmap(struct pipe_context *_context, - struct pipe_transfer *_transfer) + struct pipe_transfer *_transfer) { struct identity_context *id_context = identity_context(_context); struct identity_transfer *id_transfer = identity_transfer(_transfer); @@ -812,19 +812,19 @@ identity_context_transfer_unmap(struct pipe_context *_context, struct pipe_transfer *transfer = id_transfer->transfer; context->transfer_unmap(context, - transfer); + transfer); } static void -identity_context_transfer_inline_write( struct pipe_context *_context, - struct pipe_resource *_resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box, - const void *data, - unsigned stride, - unsigned slice_stride) +identity_context_transfer_inline_write(struct pipe_context *_context, + struct pipe_resource *_resource, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box, + const void *data, + unsigned stride, + unsigned slice_stride) { struct identity_context *id_context = identity_context(_context); struct identity_resource *id_resource = identity_resource(_resource); @@ -832,13 +832,13 @@ identity_context_transfer_inline_write( struct pipe_context *_context, struct pipe_resource *texture = id_resource->resource; context->transfer_inline_write(context, - texture, - sr, - usage, - box, - data, - stride, - slice_stride); + texture, + sr, + usage, + box, + data, + stride, + slice_stride); } diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c index d50914e7d5..5070c0475d 100644 --- a/src/gallium/drivers/identity/id_objects.c +++ b/src/gallium/drivers/identity/id_objects.c @@ -110,7 +110,7 @@ identity_surface_destroy(struct identity_surface *id_surface) struct pipe_transfer * identity_transfer_create(struct identity_context *id_context, - struct identity_resource *id_resource, + struct identity_resource *id_resource, struct pipe_transfer *transfer) { struct identity_transfer *id_transfer; @@ -145,7 +145,7 @@ identity_transfer_destroy(struct identity_context *id_context, { pipe_resource_reference(&id_transfer->base.resource, NULL); id_context->pipe->transfer_destroy(id_context->pipe, - id_transfer->transfer); + id_transfer->transfer); FREE(id_transfer); } diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h index 058cf3009d..611519b6e8 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -142,7 +142,7 @@ identity_transfer_unwrap(struct pipe_transfer *_transfer) struct pipe_resource * identity_resource_create(struct identity_screen *id_screen, - struct pipe_resource *resource); + struct pipe_resource *resource); void identity_resource_destroy(struct identity_resource *id_resource); @@ -156,7 +156,7 @@ identity_surface_destroy(struct identity_surface *id_surface); struct pipe_transfer * identity_transfer_create(struct identity_context *id_context, - struct identity_resource *id_resource, + struct identity_resource *id_resource, struct pipe_transfer *transfer); void diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index 52573b211f..4fddd62ac2 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -120,14 +120,14 @@ identity_screen_context_create(struct pipe_screen *_screen, static struct pipe_resource * identity_screen_resource_create(struct pipe_screen *_screen, - const struct pipe_resource *templat) + const struct pipe_resource *templat) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; struct pipe_resource *result; result = screen->resource_create(screen, - templat); + templat); if (result) return identity_resource_create(id_screen, result); @@ -136,8 +136,8 @@ identity_screen_resource_create(struct pipe_screen *_screen, static struct pipe_resource * identity_screen_resource_from_handle(struct pipe_screen *_screen, - const struct pipe_resource *templ, - struct winsys_handle *handle) + const struct pipe_resource *templ, + struct winsys_handle *handle) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; @@ -154,8 +154,8 @@ identity_screen_resource_from_handle(struct pipe_screen *_screen, static boolean identity_screen_resource_get_handle(struct pipe_screen *_screen, - struct pipe_resource *_texture, - struct winsys_handle *handle) + struct pipe_resource *_texture, + struct winsys_handle *handle) { struct identity_screen *id_screen = identity_screen(_screen); struct identity_resource *id_resource = identity_resource(_texture); @@ -171,7 +171,7 @@ identity_screen_resource_get_handle(struct pipe_screen *_screen, static void identity_screen_resource_destroy(struct pipe_screen *screen, - struct pipe_resource *_texture) + struct pipe_resource *_texture) { identity_resource_destroy(identity_resource(_texture)); } @@ -214,7 +214,7 @@ static struct pipe_resource * identity_screen_user_buffer_create(struct pipe_screen *_screen, void *ptr, unsigned bytes, - unsigned usage) + unsigned usage) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; @@ -223,7 +223,7 @@ identity_screen_user_buffer_create(struct pipe_screen *_screen, result = screen->user_buffer_create(screen, ptr, bytes, - usage); + usage); if (result) return identity_resource_create(id_screen, result); -- cgit v1.2.3 From 59b160d286e5848851848e09c87eb64cd2631c6b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 1 May 2010 12:02:26 +0100 Subject: identity: s/texture/resource/ --- src/gallium/drivers/identity/id_context.c | 22 +++++++++++----------- src/gallium/drivers/identity/id_screen.c | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 6e88239d65..90a669d518 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -691,33 +691,33 @@ identity_is_resource_referenced(struct pipe_context *_pipe, struct identity_context *id_pipe = identity_context(_pipe); struct identity_resource *id_resource = identity_resource(_resource); struct pipe_context *pipe = id_pipe->pipe; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; return pipe->is_resource_referenced(pipe, - texture, + resource, face, level); } static struct pipe_sampler_view * identity_create_sampler_view(struct pipe_context *pipe, - struct pipe_resource *texture, + struct pipe_resource *resource, const struct pipe_sampler_view *templ) { struct identity_context *id_pipe = identity_context(pipe); - struct identity_resource *id_resource = identity_resource(texture); + struct identity_resource *id_resource = identity_resource(resource); struct pipe_context *pipe_unwrapped = id_pipe->pipe; - struct pipe_resource *texture_unwrapped = id_resource->resource; + struct pipe_resource *resource_unwrapped = id_resource->resource; struct identity_sampler_view *view = MALLOC(sizeof(struct identity_sampler_view)); view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped, - texture_unwrapped, + resource_unwrapped, templ); view->base = *templ; view->base.reference.count = 1; view->base.texture = NULL; - pipe_resource_reference(&view->base.texture, texture); + pipe_resource_reference(&view->base.texture, resource); view->base.context = pipe; return &view->base; @@ -749,11 +749,11 @@ identity_context_get_transfer(struct pipe_context *_context, struct identity_context *id_context = identity_context(_context); struct identity_resource *id_resource = identity_resource(_resource); struct pipe_context *context = id_context->pipe; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; struct pipe_transfer *result; result = context->get_transfer(context, - texture, + resource, sr, usage, box); @@ -829,10 +829,10 @@ identity_context_transfer_inline_write(struct pipe_context *_context, struct identity_context *id_context = identity_context(_context); struct identity_resource *id_resource = identity_resource(_resource); struct pipe_context *context = id_context->pipe; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; context->transfer_inline_write(context, - texture, + resource, sr, usage, box, diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index 4fddd62ac2..7671bded98 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -154,44 +154,44 @@ identity_screen_resource_from_handle(struct pipe_screen *_screen, static boolean identity_screen_resource_get_handle(struct pipe_screen *_screen, - struct pipe_resource *_texture, + struct pipe_resource *_resource, struct winsys_handle *handle) { struct identity_screen *id_screen = identity_screen(_screen); - struct identity_resource *id_resource = identity_resource(_texture); + struct identity_resource *id_resource = identity_resource(_resource); struct pipe_screen *screen = id_screen->screen; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; /* TODO trace call */ - return screen->resource_get_handle(screen, texture, handle); + return screen->resource_get_handle(screen, resource, handle); } static void identity_screen_resource_destroy(struct pipe_screen *screen, - struct pipe_resource *_texture) + struct pipe_resource *_resource) { - identity_resource_destroy(identity_resource(_texture)); + identity_resource_destroy(identity_resource(_resource)); } static struct pipe_surface * identity_screen_get_tex_surface(struct pipe_screen *_screen, - struct pipe_resource *_texture, + struct pipe_resource *_resource, unsigned face, unsigned level, unsigned zslice, unsigned usage) { struct identity_screen *id_screen = identity_screen(_screen); - struct identity_resource *id_resource = identity_resource(_texture); + struct identity_resource *id_resource = identity_resource(_resource); struct pipe_screen *screen = id_screen->screen; - struct pipe_resource *texture = id_resource->resource; + struct pipe_resource *resource = id_resource->resource; struct pipe_surface *result; result = screen->get_tex_surface(screen, - texture, + resource, face, level, zslice, -- cgit v1.2.3 From c2c1f60391113490f4f90efb2786544c599ac991 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 1 May 2010 12:38:25 +0100 Subject: identity: Move sampler view create and destroy to id_objects.c --- src/gallium/drivers/identity/id_context.c | 52 ++++++++++++------------------- src/gallium/drivers/identity/id_objects.c | 40 ++++++++++++++++++++++-- src/gallium/drivers/identity/id_objects.h | 9 ++++++ 3 files changed, 67 insertions(+), 34 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 90a669d518..7e62213597 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -700,43 +700,31 @@ identity_is_resource_referenced(struct pipe_context *_pipe, } static struct pipe_sampler_view * -identity_create_sampler_view(struct pipe_context *pipe, - struct pipe_resource *resource, - const struct pipe_sampler_view *templ) +identity_context_create_sampler_view(struct pipe_context *_pipe, + struct pipe_resource *_resource, + const struct pipe_sampler_view *templ) { - struct identity_context *id_pipe = identity_context(pipe); - struct identity_resource *id_resource = identity_resource(resource); - struct pipe_context *pipe_unwrapped = id_pipe->pipe; - struct pipe_resource *resource_unwrapped = id_resource->resource; - struct identity_sampler_view *view = MALLOC(sizeof(struct identity_sampler_view)); - - view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped, - resource_unwrapped, - templ); + struct identity_context *id_context = identity_context(_pipe); + struct identity_resource *id_resource = identity_resource(_resource); + struct pipe_context *pipe = id_context->pipe; + struct pipe_resource *resource = id_resource->resource; + struct pipe_sampler_view *result; - view->base = *templ; - view->base.reference.count = 1; - view->base.texture = NULL; - pipe_resource_reference(&view->base.texture, resource); - view->base.context = pipe; + result = pipe->create_sampler_view(pipe, + resource, + templ); - return &view->base; + if (result) + return identity_sampler_view_create(id_context, id_resource, result); + return NULL; } static void -identity_sampler_view_destroy(struct pipe_context *pipe, - struct pipe_sampler_view *view) +identity_context_sampler_view_destroy(struct pipe_context *_pipe, + struct pipe_sampler_view *_view) { - struct identity_context *id_pipe = identity_context(pipe); - struct identity_sampler_view *id_view = identity_sampler_view(view); - struct pipe_context *pipe_unwrapped = id_pipe->pipe; - struct pipe_sampler_view *view_unwrapped = id_view->sampler_view; - - pipe_unwrapped->sampler_view_destroy(pipe_unwrapped, - view_unwrapped); - - pipe_resource_reference(&view->texture, NULL); - FREE(view); + identity_sampler_view_destroy(identity_context(_pipe), + identity_sampler_view(_view)); } static struct pipe_transfer * @@ -905,8 +893,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.clear = identity_clear; id_pipe->base.flush = identity_flush; id_pipe->base.is_resource_referenced = identity_is_resource_referenced; - id_pipe->base.create_sampler_view = identity_create_sampler_view; - id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy; + id_pipe->base.create_sampler_view = identity_context_create_sampler_view; + id_pipe->base.sampler_view_destroy = identity_context_sampler_view_destroy; id_pipe->base.get_transfer = identity_context_get_transfer; id_pipe->base.transfer_destroy = identity_context_transfer_destroy; id_pipe->base.transfer_map = identity_context_transfer_map; diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c index 5070c0475d..ca4743f9ef 100644 --- a/src/gallium/drivers/identity/id_objects.c +++ b/src/gallium/drivers/identity/id_objects.c @@ -108,6 +108,42 @@ identity_surface_destroy(struct identity_surface *id_surface) } +struct pipe_sampler_view * +identity_sampler_view_create(struct identity_context *id_context, + struct identity_resource *id_resource, + struct pipe_sampler_view *view) +{ + struct identity_sampler_view *id_view; + + if (!view) + goto error; + + assert(view->texture == id_resource->resource); + + id_view = MALLOC(sizeof(struct identity_sampler_view)); + + id_view->base = *view; + id_view->base.reference.count = 1; + id_view->base.texture = NULL; + pipe_resource_reference(&id_view->base.texture, id_resource->resource); + id_view->base.context = id_context->pipe; + + return &id_view->base; +error: + return NULL; +} + +void +identity_sampler_view_destroy(struct identity_context *id_context, + struct identity_sampler_view *id_view) +{ + pipe_resource_reference(&id_view->base.texture, NULL); + id_context->pipe->sampler_view_destroy(id_context->pipe, + id_view->sampler_view); + FREE(id_view); +} + + struct pipe_transfer * identity_transfer_create(struct identity_context *id_context, struct identity_resource *id_resource, @@ -144,8 +180,8 @@ identity_transfer_destroy(struct identity_context *id_context, struct identity_transfer *id_transfer) { pipe_resource_reference(&id_transfer->base.resource, NULL); - id_context->pipe->transfer_destroy(id_context->pipe, - id_transfer->transfer); + id_transfer->pipe->transfer_destroy(id_context->pipe, + id_transfer->transfer); FREE(id_transfer); } diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h index 611519b6e8..5eea10b0b5 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -154,6 +154,15 @@ identity_surface_create(struct identity_resource *id_resource, void identity_surface_destroy(struct identity_surface *id_surface); +struct pipe_sampler_view * +identity_sampler_view_create(struct identity_context *id_context, + struct identity_resource *id_resource, + struct pipe_sampler_view *view); + +void +identity_sampler_view_destroy(struct identity_context *id_context, + struct identity_sampler_view *id_sampler_view); + struct pipe_transfer * identity_transfer_create(struct identity_context *id_context, struct identity_resource *id_resource, -- cgit v1.2.3 From d2b6ed7c4daf094bfe3fa4e0318133d0a8ea3cf6 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Sun, 2 May 2010 21:40:30 -0400 Subject: gallivm: fix nested break and continue statements we were resetting the mask on each new break/continue statement within the same scope. we always need to and the current execution mask with the current break/continue mask to get the correct result (the masks are always ~1 initially) --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index d3c769e28b..f49f278c3d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -255,16 +255,9 @@ static void lp_exec_break(struct lp_exec_mask *mask) mask->exec_mask, "break"); - /* mask->break_stack_size > 1 implies that we encountered a break - * statemant already and if that's the case we want to make sure - * our mask is a combination of the previous break and the current - * execution mask */ - if (mask->break_stack_size > 1) { - mask->break_mask = LLVMBuildAnd(mask->bld->builder, - mask->break_mask, - exec_mask, "break_full"); - } else - mask->break_mask = exec_mask; + mask->break_mask = LLVMBuildAnd(mask->bld->builder, + mask->break_mask, + exec_mask, "break_full"); lp_exec_mask_update(mask); } @@ -275,12 +268,9 @@ static void lp_exec_continue(struct lp_exec_mask *mask) mask->exec_mask, ""); - if (mask->cont_stack_size > 1) { - mask->cont_mask = LLVMBuildAnd(mask->bld->builder, - mask->cont_mask, - exec_mask, ""); - } else - mask->cont_mask = exec_mask; + mask->cont_mask = LLVMBuildAnd(mask->bld->builder, + mask->cont_mask, + exec_mask, ""); lp_exec_mask_update(mask); } -- cgit v1.2.3 From e8f48b1dc99a8db05c07d442acd3baf8f3620f6e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 2 May 2010 17:37:18 +1000 Subject: softpipe: invalidate cache view when swizzles are different. Current code only invalidated if the texture was different, however we store swizzled values in the cache, so we need to invalidate in that case also. Signed-off-by: Dave Airlie --- src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index fbce9e042b..b3e1c49406 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -115,6 +115,20 @@ sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc) } } +static boolean +sp_tex_tile_is_compat_view(struct softpipe_tex_tile_cache *tc, + struct pipe_sampler_view *view) +{ + if (!view) + return FALSE; + return (tc->texture == view->texture && + tc->format == view->format && + tc->swizzle_r == view->swizzle_r && + tc->swizzle_g == view->swizzle_g && + tc->swizzle_b == view->swizzle_b && + tc->swizzle_a == view->swizzle_a); +} + /** * Specify the sampler view to cache. */ @@ -127,7 +141,7 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc, assert(!tc->transfer); - if (tc->texture != texture) { + if (!sp_tex_tile_is_compat_view(tc, view)) { pipe_resource_reference(&tc->texture, texture); if (tc->tex_trans) { -- cgit v1.2.3 From d44c8ee568878899e4ce5d8e1d0fcf523aa62199 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 09:53:12 +0100 Subject: draw: Disable rtasm compilation when using LLVM. Saves time and trouble. --- src/gallium/auxiliary/draw/draw_vs.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index c2832eefa2..b9db886a24 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -85,18 +85,22 @@ struct draw_vertex_shader * draw_create_vertex_shader(struct draw_context *draw, const struct pipe_shader_state *shader) { - struct draw_vertex_shader *vs; + struct draw_vertex_shader *vs = NULL; if (draw->dump_vs) { tgsi_dump(shader->tokens, 0); } - vs = draw_create_vs_sse( draw, shader ); - if (!vs) { + if (!draw->pt.middle.llvm) { +#if defined(PIPE_ARCH_X86) + vs = draw_create_vs_sse( draw, shader ); +#elif defined(PIPE_ARCH_PPC) vs = draw_create_vs_ppc( draw, shader ); - if (!vs) { - vs = draw_create_vs_exec( draw, shader ); - } +#endif + } + + if (!vs) { + vs = draw_create_vs_exec( draw, shader ); } if (vs) -- cgit v1.2.3 From e27983bc08d4eff5effbbcffbf5c9f5862fca2cf Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 09:54:01 +0100 Subject: gallivm: Replace predicate assertion failure with warning message. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index f49f278c3d..faf491fc3c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -579,7 +579,6 @@ emit_store( case TGSI_FILE_PREDICATE: /* FIXME */ - assert(0); break; default: @@ -729,7 +728,7 @@ emit_kilp(struct lp_build_tgsi_soa_context *bld, lp_build_mask_update(bld->mask, mask); } -static int +static void emit_declaration( struct lp_build_tgsi_soa_context *bld, const struct tgsi_full_declaration *decl) @@ -767,13 +766,15 @@ emit_declaration( vec_type, ""); break; + case TGSI_FILE_PREDICATE: + _debug_printf("warning: predicate registers not yet implemented\n"); + break; + default: /* don't need to declare other vars */ break; } } - - return TRUE; } @@ -1755,10 +1756,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, switch( parse.FullToken.Token.Type ) { case TGSI_TOKEN_TYPE_DECLARATION: /* Inputs already interpolated */ - { - if (!emit_declaration( &bld, &parse.FullToken.FullDeclaration )) - _debug_printf("warning: failed to define LLVM variable\n"); - } + emit_declaration( &bld, &parse.FullToken.FullDeclaration ); break; case TGSI_TOKEN_TYPE_INSTRUCTION: -- cgit v1.2.3 From d288698a76e2ad8408d303570578856a05ea96d0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 10:53:32 +0100 Subject: gallium: Remove loop register file. It was only used for D3D's REP/END/BGNFOR/ENDFOR. D3D's aL register is just like another address register now. --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 1 - src/gallium/auxiliary/tgsi/tgsi_exec.c | 7 ------- src/gallium/auxiliary/tgsi/tgsi_exec.h | 4 ---- src/gallium/auxiliary/tgsi/tgsi_sanity.c | 4 ++-- src/gallium/auxiliary/tgsi/tgsi_text.c | 1 - src/gallium/auxiliary/tgsi/tgsi_ureg.c | 22 ---------------------- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 3 --- src/gallium/drivers/i965/brw_wm_debug.c | 3 ++- src/gallium/include/pipe/p_shader_tokens.h | 5 ++--- 9 files changed, 6 insertions(+), 44 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 8300020018..de54a49ec2 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -100,7 +100,6 @@ static const char *file_names[TGSI_FILE_COUNT] = "SAMP", "ADDR", "IMM", - "LOOP", "PRED", "SV" }; diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 82eac05dc4..9b1ca7fa85 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1346,13 +1346,6 @@ store_dest(struct tgsi_exec_machine *mach, dst = &mach->Addrs[index].xyzw[chan_index]; break; - case TGSI_FILE_LOOP: - assert(reg->Register.Index == 0); - assert(mach->LoopCounterStackTop > 0); - assert(chan_index == CHAN_X); - dst = &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[chan_index]; - break; - case TGSI_FILE_PREDICATE: index = reg->Register.Index; assert(index < TGSI_EXEC_NUM_PREDS); diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index a22873e4c2..11bbaf6722 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -299,10 +299,6 @@ struct tgsi_exec_machine uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING]; int LoopLabelStackTop; - /** Loop counter stack (x = index, y = counter, z = step) */ - struct tgsi_exec_vector LoopCounterStack[TGSI_EXEC_MAX_LOOP_NESTING]; - int LoopCounterStackTop; - /** Loop continue mask stack (see comments in tgsi_exec.c) */ uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING]; int ContStackTop; diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index 76b7564cc3..ce0a92f7fb 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -235,8 +235,8 @@ static const char *file_names[TGSI_FILE_COUNT] = "SAMP", "ADDR", "IMM", - "LOOP", - "PRED" + "PRED", + "SV" }; static boolean diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 0b468a9184..f3b17833b5 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -278,7 +278,6 @@ static const char *file_names[TGSI_FILE_COUNT] = "SAMP", "ADDR", "IMM", - "LOOP", "PRED", "SV" }; diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index f725405ade..49b854b123 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -74,7 +74,6 @@ struct ureg_tokens { #define UREG_MAX_IMMEDIATE 32 #define UREG_MAX_TEMP 256 #define UREG_MAX_ADDR 2 -#define UREG_MAX_LOOP 1 #define UREG_MAX_PRED 1 struct const_decl { @@ -151,7 +150,6 @@ struct ureg_program unsigned nr_addrs; unsigned nr_preds; - unsigned nr_loops; unsigned nr_instructions; struct ureg_tokens domain[2]; @@ -537,19 +535,6 @@ struct ureg_dst ureg_DECL_address( struct ureg_program *ureg ) return ureg_dst_register( TGSI_FILE_ADDRESS, 0 ); } -/* Allocate a new loop register. - */ -struct ureg_dst -ureg_DECL_loop(struct ureg_program *ureg) -{ - if (ureg->nr_loops < UREG_MAX_LOOP) { - return ureg_dst_register(TGSI_FILE_LOOP, ureg->nr_loops++); - } - - assert(0); - return ureg_dst_register(TGSI_FILE_LOOP, 0); -} - /* Allocate a new predicate register. */ struct ureg_dst @@ -1356,13 +1341,6 @@ static void emit_decls( struct ureg_program *ureg ) 0, ureg->nr_addrs ); } - if (ureg->nr_loops) { - emit_decl_range(ureg, - TGSI_FILE_LOOP, - 0, - ureg->nr_loops); - } - if (ureg->nr_preds) { emit_decl_range(ureg, TGSI_FILE_PREDICATE, diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 0130a77aad..f32420dd87 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -230,9 +230,6 @@ ureg_release_temporary( struct ureg_program *ureg, struct ureg_dst ureg_DECL_address( struct ureg_program * ); -struct ureg_dst -ureg_DECL_loop( struct ureg_program * ); - struct ureg_dst ureg_DECL_predicate(struct ureg_program *); diff --git a/src/gallium/drivers/i965/brw_wm_debug.c b/src/gallium/drivers/i965/brw_wm_debug.c index 3d11fa074c..e2767264e7 100644 --- a/src/gallium/drivers/i965/brw_wm_debug.c +++ b/src/gallium/drivers/i965/brw_wm_debug.c @@ -202,7 +202,8 @@ static const char *file_strings[TGSI_FILE_COUNT+1] = { "SAMPLER", "ADDR", "IMM", - "LOOP", + "PRED", + "SV", "PAYLOAD" }; diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index e21aaacc18..0a70237f26 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -73,9 +73,8 @@ enum tgsi_file_type { TGSI_FILE_SAMPLER =5, TGSI_FILE_ADDRESS =6, TGSI_FILE_IMMEDIATE =7, - TGSI_FILE_LOOP =8, - TGSI_FILE_PREDICATE =9, - TGSI_FILE_SYSTEM_VALUE =10, + TGSI_FILE_PREDICATE =8, + TGSI_FILE_SYSTEM_VALUE =9, TGSI_FILE_COUNT /**< how many TGSI_FILE_ types */ }; -- cgit v1.2.3 From 14a0328d4b21a2783a43932d2e4ed7ee75d79685 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 12:13:54 +0100 Subject: tgsi: Parse and dump predicates. --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 24 ++++++++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_text.c | 40 +++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index de54a49ec2..1ad183b8dd 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -493,6 +493,30 @@ iter_instruction( TXT( " " ); ctx->indent += info->post_indent; + if (inst->Instruction.Predicate) { + CHR( '(' ); + + if (inst->Predicate.Negate) + CHR( '!' ); + + TXT( "PRED[" ); + SID( inst->Predicate.Index ); + CHR( ']' ); + + if (inst->Predicate.SwizzleX != TGSI_SWIZZLE_X || + inst->Predicate.SwizzleY != TGSI_SWIZZLE_Y || + inst->Predicate.SwizzleZ != TGSI_SWIZZLE_Z || + inst->Predicate.SwizzleW != TGSI_SWIZZLE_W) { + CHR( '.' ); + ENM( inst->Predicate.SwizzleX, swizzle_names ); + ENM( inst->Predicate.SwizzleY, swizzle_names ); + ENM( inst->Predicate.SwizzleZ, swizzle_names ); + ENM( inst->Predicate.SwizzleW, swizzle_names ); + } + + TXT( ") " ); + } + TXT( info->mnemonic ); switch (inst->Instruction.Saturate) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index f3b17833b5..71a0d96331 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -815,6 +815,45 @@ parse_instruction( struct tgsi_full_instruction inst; uint advance; + inst = tgsi_default_full_instruction(); + + /* Parse predicate. + */ + eat_opt_white( &ctx->cur ); + if (*ctx->cur == '(') { + uint file; + int index; + uint swizzle[4]; + boolean parsed_swizzle; + + inst.Instruction.Predicate = 1; + + ctx->cur++; + if (*ctx->cur == '!') { + ctx->cur++; + inst.Predicate.Negate = 1; + } + + if (!parse_register_dst( ctx, &file, &index )) + return FALSE; + + if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle )) { + if (parsed_swizzle) { + inst.Predicate.SwizzleX = swizzle[0]; + inst.Predicate.SwizzleY = swizzle[1]; + inst.Predicate.SwizzleZ = swizzle[2]; + inst.Predicate.SwizzleW = swizzle[3]; + } + } + + if (*ctx->cur != ')') { + report_error( ctx, "Expected `)'" ); + return FALSE; + } + + ctx->cur++; + } + /* Parse instruction name. */ eat_opt_white( &ctx->cur ); @@ -848,7 +887,6 @@ parse_instruction( return FALSE; } - inst = tgsi_default_full_instruction(); inst.Instruction.Opcode = i; inst.Instruction.Saturate = saturate; inst.Instruction.NumDstRegs = info->num_dst; -- cgit v1.2.3 From caede7528d2afad478c49afb98eb96088e1c41cc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 12:15:32 +0100 Subject: draw: Remove draw_pt_fetch_prepare call from llvm middle end. Unneeded since we code generate the vertex fecthes. --- .../auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 35913a5995..6d00b0fbd4 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -66,7 +66,6 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, struct llvm_middle_end *fpme = (struct llvm_middle_end *)middle; struct draw_context *draw = fpme->draw; struct draw_vertex_shader *vs = draw->vs.vertex_shader; - struct draw_geometry_shader *gs = draw->gs.geometry_shader; struct draw_llvm_variant_key key; struct draw_llvm_variant *variant = NULL; unsigned i; @@ -97,17 +96,6 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, fpme->vertex_size = sizeof(struct vertex_header) + nr * 4 * sizeof(float); - - draw_pt_fetch_prepare( fpme->fetch, - vs->info.num_inputs, - fpme->vertex_size, - instance_id_index ); - if (opt & PT_SHADE) { - vs->prepare(vs, draw); - draw_geometry_shader_prepare(gs, draw); - } - - /* XXX: it's not really gl rasterization rules we care about here, * but gl vs dx9 clip spaces. */ -- cgit v1.2.3 From 4b891234f81d441426a62abcff96720022d2ac3d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 12:18:55 +0100 Subject: translate: Make translate_generic truly generic. PIPE_FORMAT_R10G10B10X2_USCALED, half floats, were not supported, so just rely on u_format for (almost) universal format support. --- .../auxiliary/translate/translate_generic.c | 391 +++++---------------- 1 file changed, 90 insertions(+), 301 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index a9272fbb49..f8dbd2b36a 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -31,6 +31,7 @@ */ #include "util/u_memory.h" +#include "util/u_format.h" #include "util/u_math.h" #include "pipe/p_state.h" #include "translate.h" @@ -38,7 +39,9 @@ #define DRAW_DBG 0 -typedef void (*fetch_func)(const void *ptr, float *attrib); +typedef void (*fetch_func)(float *dst, + const uint8_t *src, + unsigned i, unsigned j); typedef void (*emit_func)(const float *attrib, void *ptr); @@ -57,7 +60,7 @@ struct translate_generic { emit_func emit; unsigned output_offset; - char *input_ptr; + const uint8_t *input_ptr; unsigned input_stride; unsigned max_index; @@ -79,22 +82,7 @@ static struct translate_generic *translate_generic( struct translate *translate * This is probably needed/dupliocated elsewhere, eg format * conversion, texture sampling etc. */ -#define ATTRIB( NAME, SZ, TYPE, FROM, TO ) \ -static void \ -fetch_##NAME(const void *ptr, float *attrib) \ -{ \ - const float defaults[4] = { 0.0f,0.0f,0.0f,1.0f }; \ - unsigned i; \ - \ - for (i = 0; i < SZ; i++) { \ - attrib[i] = FROM(i); \ - } \ - \ - for (; i < 4; i++) { \ - attrib[i] = defaults[i]; \ - } \ -} \ - \ +#define ATTRIB( NAME, SZ, TYPE, TO ) \ static void \ emit_##NAME(const float *attrib, void *ptr) \ { \ @@ -107,27 +95,6 @@ emit_##NAME(const float *attrib, void *ptr) \ } -#define FROM_64_FLOAT(i) ((float) ((double *) ptr)[i]) -#define FROM_32_FLOAT(i) (((float *) ptr)[i]) - -#define FROM_8_USCALED(i) ((float) ((unsigned char *) ptr)[i]) -#define FROM_16_USCALED(i) ((float) ((unsigned short *) ptr)[i]) -#define FROM_32_USCALED(i) ((float) ((unsigned int *) ptr)[i]) - -#define FROM_8_SSCALED(i) ((float) ((char *) ptr)[i]) -#define FROM_16_SSCALED(i) ((float) ((short *) ptr)[i]) -#define FROM_32_SSCALED(i) ((float) ((int *) ptr)[i]) - -#define FROM_8_UNORM(i) ((float) ((unsigned char *) ptr)[i] / 255.0f) -#define FROM_16_UNORM(i) ((float) ((unsigned short *) ptr)[i] / 65535.0f) -#define FROM_32_UNORM(i) ((float) ((unsigned int *) ptr)[i] / 4294967295.0f) - -#define FROM_8_SNORM(i) ((float) ((char *) ptr)[i] / 127.0f) -#define FROM_16_SNORM(i) ((float) ((short *) ptr)[i] / 32767.0f) -#define FROM_32_SNORM(i) ((float) ((int *) ptr)[i] / 2147483647.0f) - -#define FROM_32_FIXED(i) (((int *) ptr)[i] / 65536.0f) - #define TO_64_FLOAT(x) ((double) x) #define TO_32_FLOAT(x) (x) @@ -150,95 +117,79 @@ emit_##NAME(const float *attrib, void *ptr) \ #define TO_32_FIXED(x) ((int) (x * 65536.0f)) +ATTRIB( R64G64B64A64_FLOAT, 4, double, TO_64_FLOAT ) +ATTRIB( R64G64B64_FLOAT, 3, double, TO_64_FLOAT ) +ATTRIB( R64G64_FLOAT, 2, double, TO_64_FLOAT ) +ATTRIB( R64_FLOAT, 1, double, TO_64_FLOAT ) + +ATTRIB( R32G32B32A32_FLOAT, 4, float, TO_32_FLOAT ) +ATTRIB( R32G32B32_FLOAT, 3, float, TO_32_FLOAT ) +ATTRIB( R32G32_FLOAT, 2, float, TO_32_FLOAT ) +ATTRIB( R32_FLOAT, 1, float, TO_32_FLOAT ) + +ATTRIB( R32G32B32A32_USCALED, 4, unsigned, TO_32_USCALED ) +ATTRIB( R32G32B32_USCALED, 3, unsigned, TO_32_USCALED ) +ATTRIB( R32G32_USCALED, 2, unsigned, TO_32_USCALED ) +ATTRIB( R32_USCALED, 1, unsigned, TO_32_USCALED ) + +ATTRIB( R32G32B32A32_SSCALED, 4, int, TO_32_SSCALED ) +ATTRIB( R32G32B32_SSCALED, 3, int, TO_32_SSCALED ) +ATTRIB( R32G32_SSCALED, 2, int, TO_32_SSCALED ) +ATTRIB( R32_SSCALED, 1, int, TO_32_SSCALED ) + +ATTRIB( R32G32B32A32_UNORM, 4, unsigned, TO_32_UNORM ) +ATTRIB( R32G32B32_UNORM, 3, unsigned, TO_32_UNORM ) +ATTRIB( R32G32_UNORM, 2, unsigned, TO_32_UNORM ) +ATTRIB( R32_UNORM, 1, unsigned, TO_32_UNORM ) + +ATTRIB( R32G32B32A32_SNORM, 4, int, TO_32_SNORM ) +ATTRIB( R32G32B32_SNORM, 3, int, TO_32_SNORM ) +ATTRIB( R32G32_SNORM, 2, int, TO_32_SNORM ) +ATTRIB( R32_SNORM, 1, int, TO_32_SNORM ) + +ATTRIB( R16G16B16A16_USCALED, 4, ushort, TO_16_USCALED ) +ATTRIB( R16G16B16_USCALED, 3, ushort, TO_16_USCALED ) +ATTRIB( R16G16_USCALED, 2, ushort, TO_16_USCALED ) +ATTRIB( R16_USCALED, 1, ushort, TO_16_USCALED ) + +ATTRIB( R16G16B16A16_SSCALED, 4, short, TO_16_SSCALED ) +ATTRIB( R16G16B16_SSCALED, 3, short, TO_16_SSCALED ) +ATTRIB( R16G16_SSCALED, 2, short, TO_16_SSCALED ) +ATTRIB( R16_SSCALED, 1, short, TO_16_SSCALED ) + +ATTRIB( R16G16B16A16_UNORM, 4, ushort, TO_16_UNORM ) +ATTRIB( R16G16B16_UNORM, 3, ushort, TO_16_UNORM ) +ATTRIB( R16G16_UNORM, 2, ushort, TO_16_UNORM ) +ATTRIB( R16_UNORM, 1, ushort, TO_16_UNORM ) + +ATTRIB( R16G16B16A16_SNORM, 4, short, TO_16_SNORM ) +ATTRIB( R16G16B16_SNORM, 3, short, TO_16_SNORM ) +ATTRIB( R16G16_SNORM, 2, short, TO_16_SNORM ) +ATTRIB( R16_SNORM, 1, short, TO_16_SNORM ) + +ATTRIB( R8G8B8A8_USCALED, 4, ubyte, TO_8_USCALED ) +ATTRIB( R8G8B8_USCALED, 3, ubyte, TO_8_USCALED ) +ATTRIB( R8G8_USCALED, 2, ubyte, TO_8_USCALED ) +ATTRIB( R8_USCALED, 1, ubyte, TO_8_USCALED ) + +ATTRIB( R8G8B8A8_SSCALED, 4, char, TO_8_SSCALED ) +ATTRIB( R8G8B8_SSCALED, 3, char, TO_8_SSCALED ) +ATTRIB( R8G8_SSCALED, 2, char, TO_8_SSCALED ) +ATTRIB( R8_SSCALED, 1, char, TO_8_SSCALED ) + +ATTRIB( R8G8B8A8_UNORM, 4, ubyte, TO_8_UNORM ) +ATTRIB( R8G8B8_UNORM, 3, ubyte, TO_8_UNORM ) +ATTRIB( R8G8_UNORM, 2, ubyte, TO_8_UNORM ) +ATTRIB( R8_UNORM, 1, ubyte, TO_8_UNORM ) + +ATTRIB( R8G8B8A8_SNORM, 4, char, TO_8_SNORM ) +ATTRIB( R8G8B8_SNORM, 3, char, TO_8_SNORM ) +ATTRIB( R8G8_SNORM, 2, char, TO_8_SNORM ) +ATTRIB( R8_SNORM, 1, char, TO_8_SNORM ) + +ATTRIB( A8R8G8B8_UNORM, 4, ubyte, TO_8_UNORM ) +/*ATTRIB( R8G8B8A8_UNORM, 4, ubyte, TO_8_UNORM )*/ -ATTRIB( R64G64B64A64_FLOAT, 4, double, FROM_64_FLOAT, TO_64_FLOAT ) -ATTRIB( R64G64B64_FLOAT, 3, double, FROM_64_FLOAT, TO_64_FLOAT ) -ATTRIB( R64G64_FLOAT, 2, double, FROM_64_FLOAT, TO_64_FLOAT ) -ATTRIB( R64_FLOAT, 1, double, FROM_64_FLOAT, TO_64_FLOAT ) - -ATTRIB( R32G32B32A32_FLOAT, 4, float, FROM_32_FLOAT, TO_32_FLOAT ) -ATTRIB( R32G32B32_FLOAT, 3, float, FROM_32_FLOAT, TO_32_FLOAT ) -ATTRIB( R32G32_FLOAT, 2, float, FROM_32_FLOAT, TO_32_FLOAT ) -ATTRIB( R32_FLOAT, 1, float, FROM_32_FLOAT, TO_32_FLOAT ) - -ATTRIB( R32G32B32A32_USCALED, 4, unsigned, FROM_32_USCALED, TO_32_USCALED ) -ATTRIB( R32G32B32_USCALED, 3, unsigned, FROM_32_USCALED, TO_32_USCALED ) -ATTRIB( R32G32_USCALED, 2, unsigned, FROM_32_USCALED, TO_32_USCALED ) -ATTRIB( R32_USCALED, 1, unsigned, FROM_32_USCALED, TO_32_USCALED ) - -ATTRIB( R32G32B32A32_SSCALED, 4, int, FROM_32_SSCALED, TO_32_SSCALED ) -ATTRIB( R32G32B32_SSCALED, 3, int, FROM_32_SSCALED, TO_32_SSCALED ) -ATTRIB( R32G32_SSCALED, 2, int, FROM_32_SSCALED, TO_32_SSCALED ) -ATTRIB( R32_SSCALED, 1, int, FROM_32_SSCALED, TO_32_SSCALED ) - -ATTRIB( R32G32B32A32_UNORM, 4, unsigned, FROM_32_UNORM, TO_32_UNORM ) -ATTRIB( R32G32B32_UNORM, 3, unsigned, FROM_32_UNORM, TO_32_UNORM ) -ATTRIB( R32G32_UNORM, 2, unsigned, FROM_32_UNORM, TO_32_UNORM ) -ATTRIB( R32_UNORM, 1, unsigned, FROM_32_UNORM, TO_32_UNORM ) - -ATTRIB( R32G32B32A32_SNORM, 4, int, FROM_32_SNORM, TO_32_SNORM ) -ATTRIB( R32G32B32_SNORM, 3, int, FROM_32_SNORM, TO_32_SNORM ) -ATTRIB( R32G32_SNORM, 2, int, FROM_32_SNORM, TO_32_SNORM ) -ATTRIB( R32_SNORM, 1, int, FROM_32_SNORM, TO_32_SNORM ) - -ATTRIB( R16G16B16A16_USCALED, 4, ushort, FROM_16_USCALED, TO_16_USCALED ) -ATTRIB( R16G16B16_USCALED, 3, ushort, FROM_16_USCALED, TO_16_USCALED ) -ATTRIB( R16G16_USCALED, 2, ushort, FROM_16_USCALED, TO_16_USCALED ) -ATTRIB( R16_USCALED, 1, ushort, FROM_16_USCALED, TO_16_USCALED ) - -ATTRIB( R16G16B16A16_SSCALED, 4, short, FROM_16_SSCALED, TO_16_SSCALED ) -ATTRIB( R16G16B16_SSCALED, 3, short, FROM_16_SSCALED, TO_16_SSCALED ) -ATTRIB( R16G16_SSCALED, 2, short, FROM_16_SSCALED, TO_16_SSCALED ) -ATTRIB( R16_SSCALED, 1, short, FROM_16_SSCALED, TO_16_SSCALED ) - -ATTRIB( R16G16B16A16_UNORM, 4, ushort, FROM_16_UNORM, TO_16_UNORM ) -ATTRIB( R16G16B16_UNORM, 3, ushort, FROM_16_UNORM, TO_16_UNORM ) -ATTRIB( R16G16_UNORM, 2, ushort, FROM_16_UNORM, TO_16_UNORM ) -ATTRIB( R16_UNORM, 1, ushort, FROM_16_UNORM, TO_16_UNORM ) - -ATTRIB( R16G16B16A16_SNORM, 4, short, FROM_16_SNORM, TO_16_SNORM ) -ATTRIB( R16G16B16_SNORM, 3, short, FROM_16_SNORM, TO_16_SNORM ) -ATTRIB( R16G16_SNORM, 2, short, FROM_16_SNORM, TO_16_SNORM ) -ATTRIB( R16_SNORM, 1, short, FROM_16_SNORM, TO_16_SNORM ) - -ATTRIB( R8G8B8A8_USCALED, 4, ubyte, FROM_8_USCALED, TO_8_USCALED ) -ATTRIB( R8G8B8_USCALED, 3, ubyte, FROM_8_USCALED, TO_8_USCALED ) -ATTRIB( R8G8_USCALED, 2, ubyte, FROM_8_USCALED, TO_8_USCALED ) -ATTRIB( R8_USCALED, 1, ubyte, FROM_8_USCALED, TO_8_USCALED ) - -ATTRIB( R8G8B8A8_SSCALED, 4, char, FROM_8_SSCALED, TO_8_SSCALED ) -ATTRIB( R8G8B8_SSCALED, 3, char, FROM_8_SSCALED, TO_8_SSCALED ) -ATTRIB( R8G8_SSCALED, 2, char, FROM_8_SSCALED, TO_8_SSCALED ) -ATTRIB( R8_SSCALED, 1, char, FROM_8_SSCALED, TO_8_SSCALED ) - -ATTRIB( R8G8B8A8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM ) -ATTRIB( R8G8B8_UNORM, 3, ubyte, FROM_8_UNORM, TO_8_UNORM ) -ATTRIB( R8G8_UNORM, 2, ubyte, FROM_8_UNORM, TO_8_UNORM ) -ATTRIB( R8_UNORM, 1, ubyte, FROM_8_UNORM, TO_8_UNORM ) - -ATTRIB( R8G8B8A8_SNORM, 4, char, FROM_8_SNORM, TO_8_SNORM ) -ATTRIB( R8G8B8_SNORM, 3, char, FROM_8_SNORM, TO_8_SNORM ) -ATTRIB( R8G8_SNORM, 2, char, FROM_8_SNORM, TO_8_SNORM ) -ATTRIB( R8_SNORM, 1, char, FROM_8_SNORM, TO_8_SNORM ) - -ATTRIB( A8R8G8B8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM ) -/*ATTRIB( R8G8B8A8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM )*/ - -ATTRIB( R32G32B32A32_FIXED, 4, int, FROM_32_FIXED, TO_32_FIXED ) -ATTRIB( R32G32B32_FIXED, 3, int, FROM_32_FIXED, TO_32_FIXED ) -ATTRIB( R32G32_FIXED, 2, int, FROM_32_FIXED, TO_32_FIXED ) -ATTRIB( R32_FIXED, 1, int, FROM_32_FIXED, TO_32_FIXED ) - - - -static void -fetch_B8G8R8A8_UNORM(const void *ptr, float *attrib) -{ - attrib[2] = FROM_8_UNORM(0); - attrib[1] = FROM_8_UNORM(1); - attrib[0] = FROM_8_UNORM(2); - attrib[3] = FROM_8_UNORM(3); -} static void emit_B8G8R8A8_UNORM( const float *attrib, void *ptr) @@ -250,182 +201,14 @@ emit_B8G8R8A8_UNORM( const float *attrib, void *ptr) out[3] = TO_8_UNORM(attrib[3]); } -static void -fetch_NULL( const void *ptr, float *attrib ) -{ - attrib[0] = 0; - attrib[1] = 0; - attrib[2] = 0; - attrib[3] = 1; -} - static void emit_NULL( const float *attrib, void *ptr ) { /* do nothing is the only sensible option */ } -static fetch_func get_fetch_func( enum pipe_format format ) -{ - switch (format) { - case PIPE_FORMAT_R64_FLOAT: - return &fetch_R64_FLOAT; - case PIPE_FORMAT_R64G64_FLOAT: - return &fetch_R64G64_FLOAT; - case PIPE_FORMAT_R64G64B64_FLOAT: - return &fetch_R64G64B64_FLOAT; - case PIPE_FORMAT_R64G64B64A64_FLOAT: - return &fetch_R64G64B64A64_FLOAT; - - case PIPE_FORMAT_R32_FLOAT: - return &fetch_R32_FLOAT; - case PIPE_FORMAT_R32G32_FLOAT: - return &fetch_R32G32_FLOAT; - case PIPE_FORMAT_R32G32B32_FLOAT: - return &fetch_R32G32B32_FLOAT; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - return &fetch_R32G32B32A32_FLOAT; - - case PIPE_FORMAT_R32_UNORM: - return &fetch_R32_UNORM; - case PIPE_FORMAT_R32G32_UNORM: - return &fetch_R32G32_UNORM; - case PIPE_FORMAT_R32G32B32_UNORM: - return &fetch_R32G32B32_UNORM; - case PIPE_FORMAT_R32G32B32A32_UNORM: - return &fetch_R32G32B32A32_UNORM; - - case PIPE_FORMAT_R32_USCALED: - return &fetch_R32_USCALED; - case PIPE_FORMAT_R32G32_USCALED: - return &fetch_R32G32_USCALED; - case PIPE_FORMAT_R32G32B32_USCALED: - return &fetch_R32G32B32_USCALED; - case PIPE_FORMAT_R32G32B32A32_USCALED: - return &fetch_R32G32B32A32_USCALED; - - case PIPE_FORMAT_R32_SNORM: - return &fetch_R32_SNORM; - case PIPE_FORMAT_R32G32_SNORM: - return &fetch_R32G32_SNORM; - case PIPE_FORMAT_R32G32B32_SNORM: - return &fetch_R32G32B32_SNORM; - case PIPE_FORMAT_R32G32B32A32_SNORM: - return &fetch_R32G32B32A32_SNORM; - - case PIPE_FORMAT_R32_SSCALED: - return &fetch_R32_SSCALED; - case PIPE_FORMAT_R32G32_SSCALED: - return &fetch_R32G32_SSCALED; - case PIPE_FORMAT_R32G32B32_SSCALED: - return &fetch_R32G32B32_SSCALED; - case PIPE_FORMAT_R32G32B32A32_SSCALED: - return &fetch_R32G32B32A32_SSCALED; - - case PIPE_FORMAT_R16_UNORM: - return &fetch_R16_UNORM; - case PIPE_FORMAT_R16G16_UNORM: - return &fetch_R16G16_UNORM; - case PIPE_FORMAT_R16G16B16_UNORM: - return &fetch_R16G16B16_UNORM; - case PIPE_FORMAT_R16G16B16A16_UNORM: - return &fetch_R16G16B16A16_UNORM; - - case PIPE_FORMAT_R16_USCALED: - return &fetch_R16_USCALED; - case PIPE_FORMAT_R16G16_USCALED: - return &fetch_R16G16_USCALED; - case PIPE_FORMAT_R16G16B16_USCALED: - return &fetch_R16G16B16_USCALED; - case PIPE_FORMAT_R16G16B16A16_USCALED: - return &fetch_R16G16B16A16_USCALED; - - case PIPE_FORMAT_R16_SNORM: - return &fetch_R16_SNORM; - case PIPE_FORMAT_R16G16_SNORM: - return &fetch_R16G16_SNORM; - case PIPE_FORMAT_R16G16B16_SNORM: - return &fetch_R16G16B16_SNORM; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return &fetch_R16G16B16A16_SNORM; - - case PIPE_FORMAT_R16_SSCALED: - return &fetch_R16_SSCALED; - case PIPE_FORMAT_R16G16_SSCALED: - return &fetch_R16G16_SSCALED; - case PIPE_FORMAT_R16G16B16_SSCALED: - return &fetch_R16G16B16_SSCALED; - case PIPE_FORMAT_R16G16B16A16_SSCALED: - return &fetch_R16G16B16A16_SSCALED; - - case PIPE_FORMAT_R8_UNORM: - return &fetch_R8_UNORM; - case PIPE_FORMAT_R8G8_UNORM: - return &fetch_R8G8_UNORM; - case PIPE_FORMAT_R8G8B8_UNORM: - return &fetch_R8G8B8_UNORM; - case PIPE_FORMAT_R8G8B8A8_UNORM: - return &fetch_R8G8B8A8_UNORM; - - case PIPE_FORMAT_R8_USCALED: - return &fetch_R8_USCALED; - case PIPE_FORMAT_R8G8_USCALED: - return &fetch_R8G8_USCALED; - case PIPE_FORMAT_R8G8B8_USCALED: - return &fetch_R8G8B8_USCALED; - case PIPE_FORMAT_R8G8B8A8_USCALED: - return &fetch_R8G8B8A8_USCALED; - - case PIPE_FORMAT_R8_SNORM: - return &fetch_R8_SNORM; - case PIPE_FORMAT_R8G8_SNORM: - return &fetch_R8G8_SNORM; - case PIPE_FORMAT_R8G8B8_SNORM: - return &fetch_R8G8B8_SNORM; - case PIPE_FORMAT_R8G8B8A8_SNORM: - return &fetch_R8G8B8A8_SNORM; - - case PIPE_FORMAT_R8_SSCALED: - return &fetch_R8_SSCALED; - case PIPE_FORMAT_R8G8_SSCALED: - return &fetch_R8G8_SSCALED; - case PIPE_FORMAT_R8G8B8_SSCALED: - return &fetch_R8G8B8_SSCALED; - case PIPE_FORMAT_R8G8B8A8_SSCALED: - return &fetch_R8G8B8A8_SSCALED; - - case PIPE_FORMAT_B8G8R8A8_UNORM: - return &fetch_B8G8R8A8_UNORM; - - case PIPE_FORMAT_A8R8G8B8_UNORM: - return &fetch_A8R8G8B8_UNORM; - - case PIPE_FORMAT_R32_FIXED: - return &fetch_R32_FIXED; - case PIPE_FORMAT_R32G32_FIXED: - return &fetch_R32G32_FIXED; - case PIPE_FORMAT_R32G32B32_FIXED: - return &fetch_R32G32B32_FIXED; - case PIPE_FORMAT_R32G32B32A32_FIXED: - return &fetch_R32G32B32A32_FIXED; - - default: - assert(0); - return &fetch_NULL; - } -} - - - - static emit_func get_emit_func( enum pipe_format format ) { - /* silence warnings */ - (void) emit_R32G32B32A32_FIXED; - (void) emit_R32G32B32_FIXED; - (void) emit_R32G32_FIXED; - (void) emit_R32_FIXED; - switch (format) { case PIPE_FORMAT_R64_FLOAT: return &emit_R64_FLOAT; @@ -589,7 +372,7 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate, for (attr = 0; attr < nr_attrs; attr++) { float data[4]; - const char *src; + const uint8_t *src; unsigned index; char *dst = (vert + @@ -606,7 +389,7 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate, src = tg->attrib[attr].input_ptr + tg->attrib[attr].input_stride * index; - tg->attrib[attr].fetch( src, data ); + tg->attrib[attr].fetch( data, src, 0, 0 ); if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n", i, elt, attr, data[0], data[1], data[2], data[3]); @@ -644,7 +427,7 @@ static void PIPE_CDECL generic_run( struct translate *translate, tg->attrib[attr].output_offset); if (tg->attrib[attr].type == TRANSLATE_ELEMENT_NORMAL) { - const char *src; + const uint8_t *src; if (tg->attrib[attr].instance_divisor) { src = tg->attrib[attr].input_ptr + @@ -655,7 +438,7 @@ static void PIPE_CDECL generic_run( struct translate *translate, tg->attrib[attr].input_stride * elt; } - tg->attrib[attr].fetch( src, data ); + tg->attrib[attr].fetch( data, src, 0, 0 ); } else { data[0] = (float)instance_id; } @@ -683,7 +466,7 @@ static void generic_set_buffer( struct translate *translate, for (i = 0; i < tg->nr_attrib; i++) { if (tg->attrib[i].buffer == buf) { - tg->attrib[i].input_ptr = ((char *)ptr + + tg->attrib[i].input_ptr = ((const uint8_t *)ptr + tg->attrib[i].input_offset); tg->attrib[i].input_stride = stride; tg->attrib[i].max_index = max_index; @@ -714,9 +497,15 @@ struct translate *translate_generic_create( const struct translate_key *key ) tg->translate.run = generic_run; for (i = 0; i < key->nr_elements; i++) { + const struct util_format_description *format_desc = + util_format_description(key->element[i].input_format); + + assert(format_desc); + assert(format_desc->fetch_rgba_float); + tg->attrib[i].type = key->element[i].type; - tg->attrib[i].fetch = get_fetch_func(key->element[i].input_format); + tg->attrib[i].fetch = format_desc->fetch_rgba_float; tg->attrib[i].buffer = key->element[i].input_buffer; tg->attrib[i].input_offset = key->element[i].input_offset; tg->attrib[i].instance_divisor = key->element[i].instance_divisor; -- cgit v1.2.3 From 9db4a211e96356deb963223038eea074a5fe0eda Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 13:16:09 +0100 Subject: gallivm: Display message instead of crashing when sampler generator was not supplied for tgsi translation. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index faf491fc3c..d998386237 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -606,6 +606,14 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, unsigned num_coords; unsigned i; + if (!bld->sampler) { + _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); + for (i = 0; i < 4; i++) { + texel[i] = bld->base.undef; + } + return; + } + switch (inst->Texture.Texture) { case TGSI_TEXTURE_1D: num_coords = 1; -- cgit v1.2.3 From 723ab664f617e60812ea236761b429e999abc83c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 16:23:44 +0100 Subject: svga: Silent warning. --- src/gallium/drivers/svga/svga_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 45e477e65b..27ac09e275 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -396,7 +396,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_finish = svga_fence_finish; svgascreen->sws = sws; - svga_screen_init_surface_functions(svgascreen); + svga_screen_init_surface_functions(screen); svga_init_screen_resource_functions(svgascreen); svgascreen->use_ps30 = -- cgit v1.2.3 From 15af543f106db9e6ff840828905df4978e68f715 Mon Sep 17 00:00:00 2001 From: Török Edwin Date: Mon, 3 May 2010 07:43:03 -0700 Subject: Reorder LLVM passes, running mem2reg earlier. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This gives a ~30% shader optimization time improvement on blender. Tested by comparing the dumped LLVM modules. Current ordering: time ~/llvm-git/obj/Release-Asserts/bin/opt l.bc -constprop -instcombine -mem2reg -gvn -simplifycfg real 0m1.126s user 0m1.108s sys 0m0.012s With this patch: time ~/llvm-git/obj/Release-Asserts/bin/opt l.bc -mem2reg -constprop -instcombine -gvn -simplifycfg real 0m0.885s user 0m0.880s sys 0m0.000s The overall improvement in blender is ~15%. Blender without the patch takes 1m13s: edwin 5934 87.6 11.5 729440 458296 pts/5 SLl+ 17:35 1:13 blender Blender with the patch takes 1m3s: edwin 5726 94.2 11.2 716424 446168 pts/5 SLl+ 17:32 1:03 blender It is still slow with the patch, but better (most of the optimization time is taken up by GVN, see LLVM PR7023). Signed-off-by: Török Edwin Signed-off-by: José Fonseca --- src/gallium/auxiliary/draw/draw_llvm.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_jit.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 2c234285b5..ea9b7c90a5 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -182,6 +182,8 @@ draw_llvm_create(struct draw_context *draw) /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ /* TODO: Add more passes */ + LLVMAddCFGSimplificationPass(llvm->pass); + LLVMAddPromoteMemoryToRegisterPass(llvm->pass); LLVMAddConstantPropagationPass(llvm->pass); if(util_cpu_caps.has_sse4_1) { /* FIXME: There is a bug in this pass, whereby the combination of fptosi @@ -190,9 +192,7 @@ draw_llvm_create(struct draw_context *draw) */ LLVMAddInstructionCombiningPass(llvm->pass); } - LLVMAddPromoteMemoryToRegisterPass(llvm->pass); LLVMAddGVNPass(llvm->pass); - LLVMAddCFGSimplificationPass(llvm->pass); init_globals(llvm); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 466a2f54fb..30e206a2b4 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -185,6 +185,8 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ /* TODO: Add more passes */ + LLVMAddCFGSimplificationPass(screen->pass); + LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddConstantPropagationPass(screen->pass); if(util_cpu_caps.has_sse4_1) { /* FIXME: There is a bug in this pass, whereby the combination of fptosi @@ -193,9 +195,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) */ LLVMAddInstructionCombiningPass(screen->pass); } - LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddGVNPass(screen->pass); - LLVMAddCFGSimplificationPass(screen->pass); } lp_jit_init_globals(screen); -- cgit v1.2.3 From 0bcb4f10016fb611b2946307d880f4dc1dd05eae Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 3 May 2010 19:05:03 +0200 Subject: r300g: improve texture debug output, split into TEX and TEXALLOC flags --- src/gallium/drivers/r300/r300_debug.c | 1 + src/gallium/drivers/r300/r300_screen.h | 1 + src/gallium/drivers/r300/r300_texture.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 4c2836f36a..8eb321fa08 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -37,6 +37,7 @@ static struct debug_option debug_options[] = { { "cs", DBG_CS, "Command submissions (for debugging)" }, { "draw", DBG_DRAW, "Draw and emit (for debugging)" }, { "tex", DBG_TEX, "Textures (for debugging)" }, + { "texalloc", DBG_TEXALLOC, "Texture allocation (for debugging)" }, { "fall", DBG_FALL, "Fallbacks (for debugging)" }, { "rs", DBG_RS, "Rasterizer (for debugging)" }, { "anisohq", DBG_ANISOHQ, "High quality anisotropic filtering (for benchmarking)" }, diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 735c233c9e..d58aa138a7 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -73,6 +73,7 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) { #define DBG_NO_IMMD 0x0000200 #define DBG_STATS 0x0000400 #define DBG_RS 0x0000800 +#define DBG_TEXALLOC 0x0001000 /*@}*/ static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 69e6a12445..3e3cf33bde 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -585,9 +585,6 @@ static void r300_texture_setup_immutable_state(struct r300_screen* screen, f->tile_config = R300_TXO_MACRO_TILE(tex->macrotile) | R300_TXO_MICRO_TILE(tex->microtile); - - SCREEN_DBG(screen, DBG_TEX, "r300: Set texture state (%dx%d, %d levels)\n", - pt->width0, pt->height0, pt->last_level); } static void r300_texture_setup_fb_state(struct r300_screen* screen, @@ -622,7 +619,7 @@ void r300_texture_reinterpret_format(struct pipe_screen *screen, { struct r300_screen *r300screen = r300_screen(screen); - SCREEN_DBG(r300screen, DBG_TEX, "r300: Reinterpreting format: %s -> %s\n", + SCREEN_DBG(r300screen, DBG_TEX, "r300: texture_reinterpret_format: %s -> %s\n", util_format_name(tex->format), util_format_name(new_format)); tex->format = new_format; @@ -774,7 +771,7 @@ static void r300_setup_miptree(struct r300_screen* screen, unsigned stride, size, layer_size, nblocksy, i; boolean rv350_mode = screen->caps.is_rv350; - SCREEN_DBG(screen, DBG_TEX, "r300: Making miptree for texture, format %s\n", + SCREEN_DBG(screen, DBG_TEXALLOC, "r300: Making miptree for texture, format %s\n", util_format_name(base->format)); for (i = 0; i <= base->last_level; i++) { @@ -801,7 +798,7 @@ static void r300_setup_miptree(struct r300_screen* screen, tex->hwpitch[i] = tex->pitch[i] * util_format_get_blockwidth(base->format); - SCREEN_DBG(screen, DBG_TEX, "r300: Texture miptree: Level %d " + SCREEN_DBG(screen, DBG_TEXALLOC, "r300: Texture miptree: Level %d " "(%dx%dx%d px, pitch %d bytes) %d bytes total, macrotiled %s\n", i, u_minify(base->width0, i), u_minify(base->height0, i), u_minify(base->depth0, i), stride, tex->size, @@ -942,6 +939,15 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen, r300_texture_setup_immutable_state(rscreen, tex); r300_texture_setup_fb_state(rscreen, tex); + SCREEN_DBG(rscreen, DBG_TEX, + "r300: texture_create: Macro: %s, Micro: %s, Pitch: %i, " + "Dim: %ix%ix%i, LastLevel: %i, Format: %s\n", + tex->macrotile ? "YES" : " NO", + tex->microtile ? "YES" : " NO", + tex->hwpitch[0], + base->width0, base->height0, base->depth0, base->last_level, + util_format_name(base->format)); + tex->buffer = rws->buffer_create(rws, 2048, PIPE_BIND_SAMPLER_VIEW, /* XXX */ tex->size); @@ -1039,6 +1045,14 @@ r300_texture_from_handle(struct pipe_screen* screen, rws->buffer_get_tiling(rws, buffer, &tex->microtile, &tex->macrotile); r300_setup_flags(tex); + SCREEN_DBG(rscreen, DBG_TEX, + "r300: texture_from_handle: Macro: %s, Micro: %s, " + "Pitch: % 4i, Dim: %ix%i, Format: %s\n", + tex->macrotile ? "YES" : " NO", + tex->microtile ? "YES" : " NO", + stride / util_format_get_blocksize(base->format), + base->width0, base->height0, + util_format_name(base->format)); /* Enforce microtiled zbuffer. */ override_zb_flags = util_format_is_depth_or_stencil(base->format) && -- cgit v1.2.3 From 5cdedaaf295acae13ac10feeb3143d83bc53d314 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 3 May 2010 19:14:31 +0200 Subject: r300g: refuse to create a texture with size 0 --- src/gallium/drivers/r300/r300_texture.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 3e3cf33bde..506fb73367 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -924,6 +924,17 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen, return NULL; } + /* Refuse to create a texture with size 0. */ + if (!base->width0 || + (!base->height0 && (base->target == PIPE_TEXTURE_2D || + base->target == PIPE_TEXTURE_CUBE)) || + (!base->depth0 && base->target == PIPE_TEXTURE_3D)) { + fprintf(stderr, "r300: texture_create: " + "Got invalid texture dimensions: %ix%ix%i\n", + base->width0, base->height0, base->depth0); + return NULL; + } + tex->b.b = *base; tex->b.vtbl = &r300_texture_vtbl; pipe_reference_init(&tex->b.b.reference, 1); -- cgit v1.2.3 From bc3d9a8b187eb0756f4666a13dbc2dc1c01b0299 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 3 May 2010 19:19:02 +0200 Subject: util: add util_format_is_plain --- src/gallium/auxiliary/util/u_format.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index fb6ade5c06..6514315ea2 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -338,6 +338,21 @@ util_format_name(enum pipe_format format) return desc->name; } +/** + * Whether this format is plain, see UTIL_FORMAT_LAYOUT_PLAIN for more info. + */ +static INLINE boolean +util_format_is_plain(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + + if (!format) { + return FALSE; + } + + return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN ? TRUE : FALSE; +} + static INLINE boolean util_format_is_s3tc(enum pipe_format format) { -- cgit v1.2.3 From 5a6b9f3855e7ba179626f7b30467e62fc3ae0ffb Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 3 May 2010 20:09:14 +0200 Subject: util: add util_format_short_name --- src/gallium/auxiliary/util/u_format.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 6514315ea2..8ba076949b 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -338,6 +338,19 @@ util_format_name(enum pipe_format format) return desc->name; } +static INLINE const char * +util_format_short_name(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + + assert(desc); + if (!desc) { + return "???"; + } + + return desc->short_name; +} + /** * Whether this format is plain, see UTIL_FORMAT_LAYOUT_PLAIN for more info. */ -- cgit v1.2.3 From ac6a26b429d70395cf6def04d2d9c8cf1bd2c964 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 3 May 2010 20:14:17 +0200 Subject: r300g: use util_format_short_name and util_format_is_plain --- src/gallium/drivers/r300/r300_blit.c | 8 ++++---- src/gallium/drivers/r300/r300_state.c | 2 +- src/gallium/drivers/r300/r300_state_inlines.h | 10 +++++----- src/gallium/drivers/r300/r300_texture.c | 26 +++++++------------------- 4 files changed, 17 insertions(+), 29 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 819d5e3f0c..85c2c14901 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -129,8 +129,8 @@ void r300_surface_copy(struct pipe_context* pipe, if (dst->texture->format != src->texture->format) { debug_printf("r300: Implementation error: Format mismatch in %s\n" " : src: %s dst: %s\n", __FUNCTION__, - util_format_name(src->texture->format), - util_format_name(dst->texture->format)); + util_format_short_name(src->texture->format), + util_format_short_name(dst->texture->format)); debug_assert(0); } @@ -138,7 +138,7 @@ void r300_surface_copy(struct pipe_context* pipe, old_format, src->texture->target, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW, 0) && - util_format_description(old_format)->layout == UTIL_FORMAT_LAYOUT_PLAIN) { + util_format_is_plain(old_format)) { switch (util_format_get_blocksize(old_format)) { case 1: new_format = PIPE_FORMAT_I8_UNORM; @@ -155,7 +155,7 @@ void r300_surface_copy(struct pipe_context* pipe, default: debug_printf("r300: surface_copy: Unhandled format: %s. Falling back to software.\n" "r300: surface_copy: Software fallback doesn't work for tiled textures.\n", - util_format_name(old_format)); + util_format_short_name(old_format)); } } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index d31e7c53f7..446422ca0f 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1317,7 +1317,7 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, /* XXX Shouldn't we align the format? */ fprintf(stderr, "r300_create_vertex_elements_state: " "Unaligned format %s:%i isn't supported\n", - util_format_name(*format), size); + util_format_short_name(*format), size); assert(0); abort(); } diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index fcbdb91b67..715601042f 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -371,7 +371,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { desc = util_format_description(format); if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { - fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), + fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_short_name(format), __FUNCTION__, __LINE__); assert(0); abort(); @@ -394,7 +394,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { break; default: fprintf(stderr, "r300: Bad format %s in %s:%d\n", - util_format_name(format), __FUNCTION__, __LINE__); + util_format_short_name(format), __FUNCTION__, __LINE__); assert(0); abort(); } @@ -416,7 +416,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { break; default: fprintf(stderr, "r300: Bad format %s in %s:%d\n", - util_format_name(format), __FUNCTION__, __LINE__); + util_format_short_name(format), __FUNCTION__, __LINE__); fprintf(stderr, "r300: desc->channel[0].size == %d\n", desc->channel[0].size); assert(0); @@ -425,7 +425,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { break; default: fprintf(stderr, "r300: Bad format %s in %s:%d\n", - util_format_name(format), __FUNCTION__, __LINE__); + util_format_short_name(format), __FUNCTION__, __LINE__); assert(0); abort(); } @@ -449,7 +449,7 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { fprintf(stderr, "r300: Bad format %s in %s:%d\n", - util_format_name(format), __FUNCTION__, __LINE__); + util_format_short_name(format), __FUNCTION__, __LINE__); return 0; } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 506fb73367..d6f629cf9c 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -46,18 +46,6 @@ static const unsigned microblock_table[5][3][2] = { {{ 2, 1}, {0, 0}, {0, 0}} /* 128 bits per pixel */ }; -/* Return true for non-compressed and non-YUV formats. */ -static boolean r300_format_is_plain(enum pipe_format format) -{ - const struct util_format_description *desc = util_format_description(format); - - if (!format) { - return FALSE; - } - - return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN; -} - /* Translate a pipe_format into a useful texture format for sampling. * * Some special formats are translated directly using R300_EASY_TX_FORMAT, @@ -620,7 +608,7 @@ void r300_texture_reinterpret_format(struct pipe_screen *screen, struct r300_screen *r300screen = r300_screen(screen); SCREEN_DBG(r300screen, DBG_TEX, "r300: texture_reinterpret_format: %s -> %s\n", - util_format_name(tex->format), util_format_name(new_format)); + util_format_short_name(tex->format), util_format_short_name(new_format)); tex->format = new_format; @@ -711,7 +699,7 @@ unsigned r300_texture_get_stride(struct r300_screen* screen, width = u_minify(tex->b.b.width0, level); - if (r300_format_is_plain(tex->b.b.format)) { + if (util_format_is_plain(tex->b.b.format)) { tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH, tex->mip_macrotile[level]); width = align(width, tile_width); @@ -729,7 +717,7 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex, height = u_minify(tex->b.b.height0, level); - if (r300_format_is_plain(tex->b.b.format)) { + if (util_format_is_plain(tex->b.b.format)) { tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT, tex->mip_macrotile[level]); height = align(height, tile_height); @@ -772,7 +760,7 @@ static void r300_setup_miptree(struct r300_screen* screen, boolean rv350_mode = screen->caps.is_rv350; SCREEN_DBG(screen, DBG_TEXALLOC, "r300: Making miptree for texture, format %s\n", - util_format_name(base->format)); + util_format_short_name(base->format)); for (i = 0; i <= base->last_level; i++) { /* Let's see if this miplevel can be macrotiled. */ @@ -822,7 +810,7 @@ static void r300_setup_tiling(struct pipe_screen *screen, boolean is_zb = util_format_is_depth_or_stencil(format); boolean dbg_no_tiling = SCREEN_DBG_ON(r300_screen(screen), DBG_NO_TILING); - if (!r300_format_is_plain(format)) { + if (!util_format_is_plain(format)) { return; } @@ -957,7 +945,7 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen, tex->microtile ? "YES" : " NO", tex->hwpitch[0], base->width0, base->height0, base->depth0, base->last_level, - util_format_name(base->format)); + util_format_short_name(base->format)); tex->buffer = rws->buffer_create(rws, 2048, PIPE_BIND_SAMPLER_VIEW, /* XXX */ @@ -1063,7 +1051,7 @@ r300_texture_from_handle(struct pipe_screen* screen, tex->microtile ? "YES" : " NO", stride / util_format_get_blocksize(base->format), base->width0, base->height0, - util_format_name(base->format)); + util_format_short_name(base->format)); /* Enforce microtiled zbuffer. */ override_zb_flags = util_format_is_depth_or_stencil(base->format) && -- cgit v1.2.3 From 1fc5a318a64b10567ed6990eb04b2dc3ecb2b347 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 3 May 2010 17:08:17 -0600 Subject: gallium: move framebuffer utility functions into a new file --- src/gallium/auxiliary/Makefile | 1 + src/gallium/auxiliary/SConscript | 1 + src/gallium/auxiliary/util/u_framebuffer.c | 111 ++++++++++++++++++++++++ src/gallium/auxiliary/util/u_framebuffer.h | 49 +++++++++++ src/gallium/auxiliary/util/u_surface.c | 71 --------------- src/gallium/auxiliary/util/u_surface.h | 13 --- src/gallium/drivers/llvmpipe/lp_scene.c | 1 + src/gallium/drivers/llvmpipe/lp_setup.c | 1 + src/gallium/drivers/llvmpipe/lp_state_surface.c | 1 + 9 files changed, 165 insertions(+), 84 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_framebuffer.c create mode 100644 src/gallium/auxiliary/util/u_framebuffer.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 2daed382cf..e0d9b31354 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -113,6 +113,7 @@ C_SOURCES = \ util/u_format_tests.c \ util/u_format_yuv.c \ util/u_format_zs.c \ + util/u_framebuffer.c \ util/u_gen_mipmap.c \ util/u_half.c \ util/u_handle_table.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index a0673df8a8..29a1bd0ecb 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -162,6 +162,7 @@ source = [ 'util/u_format_tests.c', 'util/u_format_yuv.c', 'util/u_format_zs.c', + 'util/u_framebuffer.c', 'util/u_gen_mipmap.c', 'util/u_half.c', 'util/u_handle_table.c', diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c new file mode 100644 index 0000000000..bdac12dbca --- /dev/null +++ b/src/gallium/auxiliary/util/u_framebuffer.c @@ -0,0 +1,111 @@ +/************************************************************************** + * + * Copyright 2009-2010 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 + * Framebuffer utility functions. + * + * @author Brian Paul + */ + + +#include "pipe/p_screen.h" +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "util/u_inlines.h" + +#include "util/u_memory.h" +#include "util/u_framebuffer.h" + + +/** + * Compare pipe_framebuffer_state objects. + * \return TRUE if same, FALSE if different + */ +boolean +util_framebuffer_state_equal(const struct pipe_framebuffer_state *dst, + const struct pipe_framebuffer_state *src) +{ + unsigned i; + + if (dst->width != src->width || + dst->height != src->height) + return FALSE; + + for (i = 0; i < Elements(src->cbufs); i++) { + if (dst->cbufs[i] != src->cbufs[i]) { + return FALSE; + } + } + + if (dst->nr_cbufs != src->nr_cbufs) { + return FALSE; + } + + if (dst->zsbuf != src->zsbuf) { + return FALSE; + } + + return TRUE; +} + + +/** + * Copy framebuffer state from src to dst, updating refcounts. + */ +void +util_copy_framebuffer_state(struct pipe_framebuffer_state *dst, + const struct pipe_framebuffer_state *src) +{ + unsigned i; + + dst->width = src->width; + dst->height = src->height; + + for (i = 0; i < Elements(src->cbufs); i++) { + pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); + } + + dst->nr_cbufs = src->nr_cbufs; + + pipe_surface_reference(&dst->zsbuf, src->zsbuf); +} + + +void +util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb) +{ + unsigned i; + + for (i = 0; i < fb->nr_cbufs; i++) { + pipe_surface_reference(&fb->cbufs[i], NULL); + } + + pipe_surface_reference(&fb->zsbuf, NULL); + + fb->width = fb->height = 0; + fb->nr_cbufs = 0; +} diff --git a/src/gallium/auxiliary/util/u_framebuffer.h b/src/gallium/auxiliary/util/u_framebuffer.h new file mode 100644 index 0000000000..adf1254e1b --- /dev/null +++ b/src/gallium/auxiliary/util/u_framebuffer.h @@ -0,0 +1,49 @@ +/************************************************************************** + * + * Copyright 2009-2010 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_FRAMEBUFFER_H +#define U_FRAMEBUFFER_H + + +#include "pipe/p_compiler.h" +#include "pipe/p_state.h" + + +extern boolean +util_framebuffer_state_equal(const struct pipe_framebuffer_state *dst, + const struct pipe_framebuffer_state *src); + +extern void +util_copy_framebuffer_state(struct pipe_framebuffer_state *dst, + const struct pipe_framebuffer_state *src); + + +extern void +util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb); + + +#endif /* U_FRAMEBUFFER_H */ diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 42440d0d67..35a9b484fc 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -114,74 +114,3 @@ util_destroy_rgba_surface(struct pipe_resource *texture, pipe_surface_reference(&surface, NULL); pipe_resource_reference(&texture, NULL); } - - - -/** - * Compare pipe_framebuffer_state objects. - * \return TRUE if same, FALSE if different - */ -boolean -util_framebuffer_state_equal(const struct pipe_framebuffer_state *dst, - const struct pipe_framebuffer_state *src) -{ - unsigned i; - - if (dst->width != src->width || - dst->height != src->height) - return FALSE; - - for (i = 0; i < Elements(src->cbufs); i++) { - if (dst->cbufs[i] != src->cbufs[i]) { - return FALSE; - } - } - - if (dst->nr_cbufs != src->nr_cbufs) { - return FALSE; - } - - if (dst->zsbuf != src->zsbuf) { - return FALSE; - } - - return TRUE; -} - - -/** - * Copy framebuffer state from src to dst, updating refcounts. - */ -void -util_copy_framebuffer_state(struct pipe_framebuffer_state *dst, - const struct pipe_framebuffer_state *src) -{ - unsigned i; - - dst->width = src->width; - dst->height = src->height; - - for (i = 0; i < Elements(src->cbufs); i++) { - pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); - } - - dst->nr_cbufs = src->nr_cbufs; - - pipe_surface_reference(&dst->zsbuf, src->zsbuf); -} - - -void -util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb) -{ - unsigned i; - - for (i = 0; i < fb->nr_cbufs; i++) { - pipe_surface_reference(&fb->cbufs[i], NULL); - } - - pipe_surface_reference(&fb->zsbuf, NULL); - - fb->width = fb->height = 0; - fb->nr_cbufs = 0; -} diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h index 119fcd4ce8..a61bb29171 100644 --- a/src/gallium/auxiliary/util/u_surface.h +++ b/src/gallium/auxiliary/util/u_surface.h @@ -62,17 +62,4 @@ util_destroy_rgba_surface(struct pipe_resource *texture, struct pipe_surface *surface); -extern boolean -util_framebuffer_state_equal(const struct pipe_framebuffer_state *dst, - const struct pipe_framebuffer_state *src); - -extern void -util_copy_framebuffer_state(struct pipe_framebuffer_state *dst, - const struct pipe_framebuffer_state *src); - - -extern void -util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb); - - #endif /* U_SURFACE_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index 1482a777ff..887f2dbad9 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include "util/u_framebuffer.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_inlines.h" diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 2150956008..1a2cd55b16 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -33,6 +33,7 @@ */ #include "pipe/p_defines.h" +#include "util/u_framebuffer.h" #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_pack_color.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c index 63b8f27b39..4b135aaf8b 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c @@ -30,6 +30,7 @@ #include "pipe/p_state.h" #include "util/u_inlines.h" +#include "util/u_framebuffer.h" #include "util/u_surface.h" #include "lp_context.h" #include "lp_scene.h" -- cgit v1.2.3 From 9b02f41cac36286d6838339532c7a95a0615b645 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 3 May 2010 17:13:21 -0600 Subject: cso: use framebuffer utility functions --- src/gallium/auxiliary/cso_cache/cso_context.c | 48 ++++----------------------- 1 file changed, 7 insertions(+), 41 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index c5fe7efa02..75bf8d5d40 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -36,6 +36,7 @@ */ #include "pipe/p_state.h" +#include "util/u_framebuffer.h" #include "util/u_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" @@ -102,10 +103,6 @@ struct cso_context { }; -static void -free_framebuffer_state(struct pipe_framebuffer_state *fb); - - static boolean delete_blend_state(struct cso_context *ctx, void *state) { struct cso_blend *cso = (struct cso_blend *)state; @@ -303,8 +300,8 @@ void cso_release_all( struct cso_context *ctx ) pipe_sampler_view_reference(&ctx->vertex_sampler_views_saved[i], NULL); } - free_framebuffer_state(&ctx->fb); - free_framebuffer_state(&ctx->fb_saved); + util_unreference_framebuffer_state(&ctx->fb); + util_unreference_framebuffer_state(&ctx->fb_saved); if (ctx->cache) { cso_cache_delete( ctx->cache ); @@ -896,42 +893,11 @@ void cso_restore_vertex_shader(struct cso_context *ctx) } -/** - * Copy framebuffer state from src to dst with refcounting of surfaces. - */ -static void -copy_framebuffer_state(struct pipe_framebuffer_state *dst, - const struct pipe_framebuffer_state *src) -{ - uint i; - - dst->width = src->width; - dst->height = src->height; - dst->nr_cbufs = src->nr_cbufs; - for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { - pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); - } - pipe_surface_reference(&dst->zsbuf, src->zsbuf); -} - - -static void -free_framebuffer_state(struct pipe_framebuffer_state *fb) -{ - uint i; - - for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { - pipe_surface_reference(&fb->cbufs[i], NULL); - } - pipe_surface_reference(&fb->zsbuf, NULL); -} - - enum pipe_error cso_set_framebuffer(struct cso_context *ctx, const struct pipe_framebuffer_state *fb) { if (memcmp(&ctx->fb, fb, sizeof(*fb)) != 0) { - copy_framebuffer_state(&ctx->fb, fb); + util_copy_framebuffer_state(&ctx->fb, fb); ctx->pipe->set_framebuffer_state(ctx->pipe, fb); } return PIPE_OK; @@ -939,15 +905,15 @@ enum pipe_error cso_set_framebuffer(struct cso_context *ctx, void cso_save_framebuffer(struct cso_context *ctx) { - copy_framebuffer_state(&ctx->fb_saved, &ctx->fb); + util_copy_framebuffer_state(&ctx->fb_saved, &ctx->fb); } void cso_restore_framebuffer(struct cso_context *ctx) { if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) { - copy_framebuffer_state(&ctx->fb, &ctx->fb_saved); + util_copy_framebuffer_state(&ctx->fb, &ctx->fb_saved); ctx->pipe->set_framebuffer_state(ctx->pipe, &ctx->fb); - free_framebuffer_state(&ctx->fb_saved); + util_unreference_framebuffer_state(&ctx->fb_saved); } } -- cgit v1.2.3 From a9d1a85f81efacb796578c718ddd399310a2e063 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 17:06:57 +0100 Subject: gallicm: Newton-Raphson step to improve precision. Disabled as it doesn't make VS/PSPrecision DCT happy, and it would unnecessarily slow some cases where it is not needed. --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 20ae958714..f372a48846 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -1177,9 +1177,34 @@ lp_build_rcp(struct lp_build_context *bld, if(LLVMIsConstant(a)) return LLVMConstFDiv(bld->one, a); - if(util_cpu_caps.has_sse && type.width == 32 && type.length == 4) - /* FIXME: improve precision */ + if(util_cpu_caps.has_sse && type.width == 32 && type.length == 4) { + /* + * XXX: Added precision is not always necessary, so only enable this + * when we have a better system in place to track minimum precision. + */ + +#if 0 + /* + * Do one Newton-Raphson step to improve precision: + * + * x1 = (2 - a * rcp(a)) * rcp(a) + */ + + LLVMValueRef two = lp_build_const_vec(bld->type, 2.0); + LLVMValueRef rcp_a; + LLVMValueRef res; + + rcp_a = lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rcp.ps", lp_build_vec_type(type), a); + + res = LLVMBuildMul(bld->builder, a, rcp_a, ""); + res = LLVMBuildSub(bld->builder, two, res, ""); + res = LLVMBuildMul(bld->builder, res, rcp_a, ""); + + return rcp_a; +#else return lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rcp.ps", lp_build_vec_type(type), a); +#endif + } return LLVMBuildFDiv(bld->builder, bld->one, a, ""); } -- cgit v1.2.3 From 6c8c88f02f0dc9cf39ce51d068525a94fccd5dc7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 20:41:01 +0100 Subject: gallivm: Increase the TGSI translation limits and centralize them in a header. --- src/gallium/auxiliary/gallivm/lp_bld_limits.h | 53 +++++++++++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 29 ++++++++------ 2 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 src/gallium/auxiliary/gallivm/lp_bld_limits.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h new file mode 100644 index 0000000000..e095a0abe3 --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h @@ -0,0 +1,53 @@ +/************************************************************************** + * + * Copyright 2010 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 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 COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef LP_BLD_LIMITS_H_ +#define LP_BLD_LIMITS_H_ + +/* + * TGSI translation limits. + * + * Some are slightly above SM 3.0 requirements to give some wiggle room to + * the state trackers. + */ + +#define LP_MAX_TGSI_TEMPS 256 + +#define LP_MAX_TGSI_ADDRS 16 + +#define LP_MAX_TGSI_IMMEDIATES 256 + +/** + * Maximum control flow nesting + * + * SM3.0 requires 24 + */ +#define LP_MAX_TGSI_NESTING 32 + + +#endif /* LP_BLD_LIMITS_H_ */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index d998386237..e699e44a24 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -54,13 +54,10 @@ #include "lp_bld_swizzle.h" #include "lp_bld_flow.h" #include "lp_bld_tgsi.h" +#include "lp_bld_limits.h" #include "lp_bld_debug.h" -#define LP_MAX_TEMPS 256 -#define LP_MAX_IMMEDIATES 256 - - #define FOR_EACH_CHANNEL( CHAN )\ for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++) @@ -84,7 +81,6 @@ #define QUAD_BOTTOM_LEFT 2 #define QUAD_BOTTOM_RIGHT 3 -#define LP_TGSI_MAX_NESTING 16 struct lp_exec_mask { struct lp_build_context *bld; @@ -93,19 +89,19 @@ struct lp_exec_mask { LLVMTypeRef int_vec_type; - LLVMValueRef cond_stack[LP_TGSI_MAX_NESTING]; + LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING]; int cond_stack_size; LLVMValueRef cond_mask; - LLVMValueRef break_stack[LP_TGSI_MAX_NESTING]; + LLVMValueRef break_stack[LP_MAX_TGSI_NESTING]; int break_stack_size; LLVMValueRef break_mask; - LLVMValueRef cont_stack[LP_TGSI_MAX_NESTING]; + LLVMValueRef cont_stack[LP_MAX_TGSI_NESTING]; int cont_stack_size; LLVMValueRef cont_mask; - LLVMBasicBlockRef loop_stack[LP_TGSI_MAX_NESTING]; + LLVMBasicBlockRef loop_stack[LP_MAX_TGSI_NESTING]; int loop_stack_size; LLVMBasicBlockRef loop_block; @@ -124,9 +120,9 @@ struct lp_build_tgsi_soa_context struct lp_build_sampler_soa *sampler; - LLVMValueRef immediates[LP_MAX_IMMEDIATES][NUM_CHANNELS]; - LLVMValueRef temps[LP_MAX_TEMPS][NUM_CHANNELS]; - LLVMValueRef addr[LP_MAX_TEMPS][NUM_CHANNELS]; + LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES][NUM_CHANNELS]; + LLVMValueRef temps[LP_MAX_TGSI_TEMPS][NUM_CHANNELS]; + LLVMValueRef addr[LP_MAX_TGSI_ADDRS][NUM_CHANNELS]; /* we allocate an array of temps if we have indirect * addressing and then the temps above is unused */ @@ -198,6 +194,7 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask) static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, LLVMValueRef val) { + assert(mask->cond_stack_size < LP_MAX_TGSI_NESTING); mask->cond_stack[mask->cond_stack_size++] = mask->cond_mask; mask->cond_mask = LLVMBuildBitCast(mask->bld->builder, val, mask->int_vec_type, ""); @@ -239,6 +236,10 @@ static void lp_exec_bgnloop(struct lp_exec_mask *mask) if (mask->cond_stack_size == 0) mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type); + assert(mask->break_stack_size < LP_MAX_TGSI_NESTING); + assert(mask->cont_stack_size < LP_MAX_TGSI_NESTING); + assert(mask->break_stack_size < LP_MAX_TGSI_NESTING); + mask->break_stack[mask->break_stack_size++] = mask->break_mask; mask->cont_stack[mask->cont_stack_size++] = mask->cont_mask; mask->loop_stack[mask->loop_stack_size++] = mask->loop_block; @@ -750,6 +751,7 @@ emit_declaration( for (idx = first; idx <= last; ++idx) { switch (decl->Declaration.File) { case TGSI_FILE_TEMPORARY: + assert(idx < LP_MAX_TGSI_TEMPS); if (bld->has_indirect_addressing) { LLVMValueRef val = LLVMConstInt(LLVMInt32Type(), last*4 + 4, 0); @@ -769,6 +771,7 @@ emit_declaration( break; case TGSI_FILE_ADDRESS: + assert(idx < LP_MAX_TGSI_ADDRS); for (i = 0; i < NUM_CHANNELS; i++) bld->addr[idx][i] = lp_build_alloca(bld->base.builder, vec_type, ""); @@ -1783,7 +1786,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, { const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1; assert(size <= 4); - assert(num_immediates < LP_MAX_IMMEDIATES); + assert(num_immediates < LP_MAX_TGSI_IMMEDIATES); for( i = 0; i < size; ++i ) bld.immediates[num_immediates][i] = lp_build_const_vec(type, parse.FullToken.FullImmediate.u[i].Float); -- cgit v1.2.3 From 8b0c217f2bc123bffd25cc4977d6abb1b3fa8186 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 3 May 2010 17:28:32 -0600 Subject: gallium: move surface utility functions into u_surface.c This is a better place than in u_rect.c --- src/gallium/auxiliary/util/u_blitter.c | 1 + src/gallium/auxiliary/util/u_clear.h | 1 + src/gallium/auxiliary/util/u_rect.c | 158 ------------------------ src/gallium/auxiliary/util/u_rect.h | 19 --- src/gallium/auxiliary/util/u_surface.c | 157 ++++++++++++++++++++++- src/gallium/auxiliary/util/u_surface.h | 18 +++ src/gallium/drivers/cell/ppu/cell_surface.c | 2 +- src/gallium/drivers/llvmpipe/lp_surface.c | 1 + src/gallium/drivers/softpipe/sp_surface.c | 2 +- src/gallium/state_trackers/dri/drm/dri1.c | 1 + src/gallium/state_trackers/vega/renderer.c | 1 + src/gallium/state_trackers/xorg/xorg_exa.c | 1 + src/gallium/state_trackers/xorg/xorg_renderer.c | 1 + src/mesa/state_tracker/st_context.c | 1 + 14 files changed, 183 insertions(+), 181 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 956aedc8a1..1abe31db46 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -47,6 +47,7 @@ #include "util/u_rect.h" #include "util/u_sampler.h" #include "util/u_simple_shaders.h" +#include "util/u_surface.h" #include "util/u_texture.h" #define INVALID_PTR ((void*)~0) diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h index 2c32db6175..40da2d75a7 100644 --- a/src/gallium/auxiliary/util/u_clear.h +++ b/src/gallium/auxiliary/util/u_clear.h @@ -33,6 +33,7 @@ #include "pipe/p_state.h" #include "util/u_pack_color.h" #include "util/u_rect.h" +#include "util/u_surface.h" /** diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index 098cdfd58b..9bbcf1c8c4 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -30,12 +30,7 @@ */ -#include "pipe/p_defines.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "pipe/p_screen.h" #include "util/u_format.h" -#include "util/u_inlines.h" #include "util/u_rect.h" @@ -152,156 +147,3 @@ util_fill_rect(ubyte * dst, break; } } - - - -/** - * Fallback function for pipe->surface_copy(). - * Note: (X,Y)=(0,0) is always the upper-left corner. - * if do_flip, flip the image vertically on its way from src rect to dst rect. - * XXX should probably put this in new u_surface.c file... - */ -void -util_surface_copy(struct pipe_context *pipe, - boolean do_flip, - struct pipe_surface *dst, - unsigned dst_x, unsigned dst_y, - struct pipe_surface *src, - unsigned src_x, unsigned src_y, - unsigned w, unsigned h) -{ - struct pipe_transfer *src_trans, *dst_trans; - void *dst_map; - const void *src_map; - enum pipe_format src_format, dst_format; - - assert(src->texture && dst->texture); - if (!src->texture || !dst->texture) - return; - - src_format = src->texture->format; - dst_format = dst->texture->format; - - src_trans = pipe_get_transfer(pipe, - src->texture, - src->face, - src->level, - src->zslice, - PIPE_TRANSFER_READ, - src_x, src_y, w, h); - - dst_trans = pipe_get_transfer(pipe, - dst->texture, - dst->face, - dst->level, - dst->zslice, - PIPE_TRANSFER_WRITE, - dst_x, dst_y, w, h); - - assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format)); - assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format)); - assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format)); - - src_map = pipe->transfer_map(pipe, src_trans); - dst_map = pipe->transfer_map(pipe, dst_trans); - - assert(src_map); - assert(dst_map); - - if (src_map && dst_map) { - /* If do_flip, invert src_y position and pass negative src stride */ - util_copy_rect(dst_map, - dst_format, - dst_trans->stride, - 0, 0, - w, h, - src_map, - do_flip ? -(int) src_trans->stride : src_trans->stride, - 0, - do_flip ? h - 1 : 0); - } - - pipe->transfer_unmap(pipe, src_trans); - pipe->transfer_unmap(pipe, dst_trans); - - pipe->transfer_destroy(pipe, src_trans); - pipe->transfer_destroy(pipe, dst_trans); -} - - - -#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8)) - - -/** - * Fallback for pipe->surface_fill() function. - * XXX should probably put this in new u_surface.c file... - */ -void -util_surface_fill(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, unsigned value) -{ - struct pipe_transfer *dst_trans; - void *dst_map; - - assert(dst->texture); - if (!dst->texture) - return; - dst_trans = pipe_get_transfer(pipe, - dst->texture, - dst->face, - dst->level, - dst->zslice, - PIPE_TRANSFER_WRITE, - dstx, dsty, width, height); - - dst_map = pipe->transfer_map(pipe, dst_trans); - - assert(dst_map); - - if (dst_map) { - assert(dst_trans->stride > 0); - - switch (util_format_get_blocksize(dst->texture->format)) { - case 1: - case 2: - case 4: - util_fill_rect(dst_map, dst->texture->format, - dst_trans->stride, - 0, 0, width, height, value); - break; - case 8: - { - /* expand the 4-byte clear value to an 8-byte value */ - ushort *row = (ushort *) dst_map; - ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff); - ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff); - ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff); - ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff); - unsigned i, j; - val0 = (val0 << 8) | val0; - val1 = (val1 << 8) | val1; - val2 = (val2 << 8) | val2; - val3 = (val3 << 8) | val3; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - row[j*4+0] = val0; - row[j*4+1] = val1; - row[j*4+2] = val2; - row[j*4+3] = val3; - } - row += dst_trans->stride/2; - } - } - break; - default: - assert(0); - break; - } - } - - pipe->transfer_unmap(pipe, dst_trans); - pipe->transfer_destroy(pipe, dst_trans); -} diff --git a/src/gallium/auxiliary/util/u_rect.h b/src/gallium/auxiliary/util/u_rect.h index b44d821904..40d57e662d 100644 --- a/src/gallium/auxiliary/util/u_rect.h +++ b/src/gallium/auxiliary/util/u_rect.h @@ -37,9 +37,6 @@ #include "pipe/p_format.h" -struct pipe_context; -struct pipe_surface; - extern void util_copy_rect(ubyte * dst, enum pipe_format format, @@ -53,20 +50,4 @@ util_fill_rect(ubyte * dst, enum pipe_format format, unsigned width, unsigned height, uint32_t value); -extern void -util_surface_copy(struct pipe_context *pipe, - boolean do_flip, - struct pipe_surface *dst, - unsigned dst_x, unsigned dst_y, - struct pipe_surface *src, - unsigned src_x, unsigned src_y, - unsigned w, unsigned h); - -extern void -util_surface_fill(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, unsigned value); - - #endif /* U_RECT_H */ diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 35a9b484fc..b47c92ca28 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -32,12 +32,14 @@ */ +#include "pipe/p_defines.h" #include "pipe/p_screen.h" #include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_inlines.h" #include "util/u_memory.h" +#include "util/u_rect.h" #include "util/u_surface.h" @@ -114,3 +116,154 @@ util_destroy_rgba_surface(struct pipe_resource *texture, pipe_surface_reference(&surface, NULL); pipe_resource_reference(&texture, NULL); } + + + +/** + * Fallback function for pipe->surface_copy(). + * Note: (X,Y)=(0,0) is always the upper-left corner. + * if do_flip, flip the image vertically on its way from src rect to dst rect. + */ +void +util_surface_copy(struct pipe_context *pipe, + boolean do_flip, + struct pipe_surface *dst, + unsigned dst_x, unsigned dst_y, + struct pipe_surface *src, + unsigned src_x, unsigned src_y, + unsigned w, unsigned h) +{ + struct pipe_transfer *src_trans, *dst_trans; + void *dst_map; + const void *src_map; + enum pipe_format src_format, dst_format; + + assert(src->texture && dst->texture); + if (!src->texture || !dst->texture) + return; + + src_format = src->texture->format; + dst_format = dst->texture->format; + + src_trans = pipe_get_transfer(pipe, + src->texture, + src->face, + src->level, + src->zslice, + PIPE_TRANSFER_READ, + src_x, src_y, w, h); + + dst_trans = pipe_get_transfer(pipe, + dst->texture, + dst->face, + dst->level, + dst->zslice, + PIPE_TRANSFER_WRITE, + dst_x, dst_y, w, h); + + assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format)); + assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format)); + assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format)); + + src_map = pipe->transfer_map(pipe, src_trans); + dst_map = pipe->transfer_map(pipe, dst_trans); + + assert(src_map); + assert(dst_map); + + if (src_map && dst_map) { + /* If do_flip, invert src_y position and pass negative src stride */ + util_copy_rect(dst_map, + dst_format, + dst_trans->stride, + 0, 0, + w, h, + src_map, + do_flip ? -(int) src_trans->stride : src_trans->stride, + 0, + do_flip ? h - 1 : 0); + } + + pipe->transfer_unmap(pipe, src_trans); + pipe->transfer_unmap(pipe, dst_trans); + + pipe->transfer_destroy(pipe, src_trans); + pipe->transfer_destroy(pipe, dst_trans); +} + + + +#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8)) + + +/** + * Fallback for pipe->surface_fill() function. + */ +void +util_surface_fill(struct pipe_context *pipe, + struct pipe_surface *dst, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height, unsigned value) +{ + struct pipe_transfer *dst_trans; + void *dst_map; + + assert(dst->texture); + if (!dst->texture) + return; + dst_trans = pipe_get_transfer(pipe, + dst->texture, + dst->face, + dst->level, + dst->zslice, + PIPE_TRANSFER_WRITE, + dstx, dsty, width, height); + + dst_map = pipe->transfer_map(pipe, dst_trans); + + assert(dst_map); + + if (dst_map) { + assert(dst_trans->stride > 0); + + switch (util_format_get_blocksize(dst->texture->format)) { + case 1: + case 2: + case 4: + util_fill_rect(dst_map, dst->texture->format, + dst_trans->stride, + 0, 0, width, height, value); + break; + case 8: + { + /* expand the 4-byte clear value to an 8-byte value */ + ushort *row = (ushort *) dst_map; + ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff); + ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff); + ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff); + ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff); + unsigned i, j; + val0 = (val0 << 8) | val0; + val1 = (val1 << 8) | val1; + val2 = (val2 << 8) | val2; + val3 = (val3 << 8) | val3; + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + row[j*4+0] = val0; + row[j*4+1] = val1; + row[j*4+2] = val2; + row[j*4+3] = val3; + } + row += dst_trans->stride/2; + } + } + break; + default: + assert(0); + break; + } + } + + pipe->transfer_unmap(pipe, dst_trans); + pipe->transfer_destroy(pipe, dst_trans); +} diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h index a61bb29171..c43169b527 100644 --- a/src/gallium/auxiliary/util/u_surface.h +++ b/src/gallium/auxiliary/util/u_surface.h @@ -62,4 +62,22 @@ util_destroy_rgba_surface(struct pipe_resource *texture, struct pipe_surface *surface); + +extern void +util_surface_copy(struct pipe_context *pipe, + boolean do_flip, + struct pipe_surface *dst, + unsigned dst_x, unsigned dst_y, + struct pipe_surface *src, + unsigned src_x, unsigned src_y, + unsigned w, unsigned h); + +extern void +util_surface_fill(struct pipe_context *pipe, + struct pipe_surface *dst, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height, unsigned value); + + + #endif /* U_SURFACE_H */ diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c index ffb8595d82..6696a4591c 100644 --- a/src/gallium/drivers/cell/ppu/cell_surface.c +++ b/src/gallium/drivers/cell/ppu/cell_surface.c @@ -25,7 +25,7 @@ * **************************************************************************/ -#include "util/u_rect.h" +#include "util/u_surface.h" #include "cell_context.h" #include "cell_surface.h" diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 8bd83f576f..245171120d 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -26,6 +26,7 @@ **************************************************************************/ #include "util/u_rect.h" +#include "util/u_surface.h" #include "lp_context.h" #include "lp_flush.h" #include "lp_limits.h" diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c index b04c2a63ad..32cab06004 100644 --- a/src/gallium/drivers/softpipe/sp_surface.c +++ b/src/gallium/drivers/softpipe/sp_surface.c @@ -25,7 +25,7 @@ * **************************************************************************/ -#include "util/u_rect.h" +#include "util/u_surface.h" #include "sp_context.h" #include "sp_surface.h" diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 23c21ed839..326ff8bcad 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -33,6 +33,7 @@ #include "util/u_memory.h" #include "util/u_rect.h" +#include "util/u_surface.h" #include "util/u_inlines.h" #include "pipe/p_context.h" #include "state_tracker/dri1_api.h" diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 48fbc3b330..e6aea482a7 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -40,6 +40,7 @@ #include "util/u_memory.h" #include "util/u_rect.h" #include "util/u_sampler.h" +#include "util/u_surface.h" #include "cso_cache/cso_context.h" diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index d5a1be8174..65be8c332a 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -46,6 +46,7 @@ #include "util/u_math.h" #include "util/u_debug.h" #include "util/u_format.h" +#include "util/u_surface.h" #define DEBUG_PRINT 0 #define ROUND_UP_TEXTURES 1 diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 13fa561390..583493116d 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -9,6 +9,7 @@ #include "util/u_memory.h" #include "util/u_rect.h" #include "util/u_sampler.h" +#include "util/u_surface.h" #include "util/u_inlines.h" diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 2b1174a504..e8a3926e6d 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -64,6 +64,7 @@ #include "pipe/p_context.h" #include "util/u_inlines.h" #include "util/u_rect.h" +#include "util/u_surface.h" #include "draw/draw_context.h" #include "cso_cache/cso_context.h" -- cgit v1.2.3 From 962558daaed43b0111cd062e32821aad106869d7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 4 May 2010 10:06:46 +0100 Subject: gallivm: Implement TXD. --- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 2 + src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 39 +++++++----------- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 5 +++ src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 49 +++++++++++++++++------ src/gallium/drivers/llvmpipe/lp_tex_sample.c | 7 ++-- 5 files changed, 62 insertions(+), 40 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 8ceb20473d..40f2b571f7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -173,6 +173,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, unsigned unit, unsigned num_coords, const LLVMValueRef *coords, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, LLVMValueRef lodbias, LLVMValueRef *texel); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 54c0ad7ce4..5927923271 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -913,6 +913,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, LLVMValueRef s, LLVMValueRef t, LLVMValueRef r, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, LLVMValueRef shader_lod_bias, LLVMValueRef width, LLVMValueRef height, @@ -936,12 +938,6 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, bld->static_state->max_lod); LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0); - LLVMValueRef index1 = LLVMConstInt(LLVMInt32Type(), 1, 0); - LLVMValueRef index2 = LLVMConstInt(LLVMInt32Type(), 2, 0); - - LLVMValueRef s0, s1, s2; - LLVMValueRef t0, t1, t2; - LLVMValueRef r0, r1, r2; LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; LLVMValueRef rho, lod; @@ -952,30 +948,20 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, * dtdy = abs(t[2] - t[0]); * drdx = abs(r[1] - r[0]); * drdy = abs(r[2] - r[0]); - * XXX we're assuming a four-element quad in 2x2 layout here. */ - s0 = LLVMBuildExtractElement(bld->builder, s, index0, "s0"); - s1 = LLVMBuildExtractElement(bld->builder, s, index1, "s1"); - s2 = LLVMBuildExtractElement(bld->builder, s, index2, "s2"); - dsdx = LLVMBuildSub(bld->builder, s1, s0, ""); + dsdx = LLVMBuildExtractElement(bld->builder, ddx[0], index0, "dsdx"); dsdx = lp_build_abs(float_bld, dsdx); - dsdy = LLVMBuildSub(bld->builder, s2, s0, ""); + dsdy = LLVMBuildExtractElement(bld->builder, ddy[0], index0, "dsdy"); dsdy = lp_build_abs(float_bld, dsdy); if (dims > 1) { - t0 = LLVMBuildExtractElement(bld->builder, t, index0, "t0"); - t1 = LLVMBuildExtractElement(bld->builder, t, index1, "t1"); - t2 = LLVMBuildExtractElement(bld->builder, t, index2, "t2"); - dtdx = LLVMBuildSub(bld->builder, t1, t0, ""); + dtdx = LLVMBuildExtractElement(bld->builder, ddx[1], index0, "dsdx"); dtdx = lp_build_abs(float_bld, dtdx); - dtdy = LLVMBuildSub(bld->builder, t2, t0, ""); + dtdy = LLVMBuildExtractElement(bld->builder, ddy[1], index0, "dtdy"); dtdy = lp_build_abs(float_bld, dtdy); if (dims > 2) { - r0 = LLVMBuildExtractElement(bld->builder, r, index0, "r0"); - r1 = LLVMBuildExtractElement(bld->builder, r, index1, "r1"); - r2 = LLVMBuildExtractElement(bld->builder, r, index2, "r2"); - drdx = LLVMBuildSub(bld->builder, r1, r0, ""); + drdx = LLVMBuildExtractElement(bld->builder, ddx[2], index0, "dsdx"); drdx = lp_build_abs(float_bld, drdx); - drdy = LLVMBuildSub(bld->builder, r2, r0, ""); + drdy = LLVMBuildExtractElement(bld->builder, ddy[2], index0, "drdy"); drdy = lp_build_abs(float_bld, drdy); } } @@ -1596,6 +1582,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, LLVMValueRef s, LLVMValueRef t, LLVMValueRef r, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, LLVMValueRef lodbias, LLVMValueRef width, LLVMValueRef height, @@ -1634,7 +1622,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, /* Need to compute lod either to choose mipmap levels or to * distinguish between minification/magnification with one mipmap level. */ - lod = lp_build_lod_selector(bld, s, t, r, lodbias, width, height, depth); + lod = lp_build_lod_selector(bld, s, t, r, ddx, ddy, lodbias, + width, height, depth); } /* @@ -2092,6 +2081,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, unsigned unit, unsigned num_coords, const LLVMValueRef *coords, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, LLVMValueRef lodbias, LLVMValueRef *texel) { @@ -2159,7 +2150,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, row_stride_array, data_array, texel); } else { - lp_build_sample_general(&bld, unit, s, t, r, lodbias, + lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy, lodbias, width, height, depth, width_vec, height_vec, depth_vec, row_stride_array, img_stride_array, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 2eac5da6c6..4ca730a98a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -45,6 +45,9 @@ struct lp_build_context; struct lp_build_mask_context; +#define LP_BLD_SAMPLER_EXPLICIT_DERIVATIVES 1 + + /** * Sampler code generation interface. * @@ -65,6 +68,8 @@ struct lp_build_sampler_soa unsigned unit, unsigned num_coords, const LLVMValueRef *coords, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, LLVMValueRef lodbias, LLVMValueRef *texel); }; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index e699e44a24..6659cff870 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -592,18 +592,26 @@ emit_store( * High-level instruction translators. */ +enum tex_modifier { + TEX_MODIFIER_NONE = 0, + TEX_MODIFIER_PROJECTED, + TEX_MODIFIER_LOD_BIAS, + TEX_MODIFIER_EXPLICIT_LOD, + TEX_MODIFIER_EXPLICIT_DERIV +}; static void emit_tex( struct lp_build_tgsi_soa_context *bld, const struct tgsi_full_instruction *inst, - boolean apply_lodbias, - boolean projected, + enum tex_modifier modifier, LLVMValueRef *texel) { - const uint unit = inst->Src[1].Register.Index; + unsigned unit; LLVMValueRef lodbias; LLVMValueRef oow = NULL; LLVMValueRef coords[3]; + LLVMValueRef ddx[3]; + LLVMValueRef ddy[3]; unsigned num_coords; unsigned i; @@ -635,29 +643,45 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, return; } - if(apply_lodbias) + /* FIXME: Treat TEX_MODIFIER_EXPLICIT_LOD correctly */ + if (modifier == TEX_MODIFIER_LOD_BIAS || TEX_MODIFIER_EXPLICIT_LOD) lodbias = emit_fetch( bld, inst, 0, 3 ); else lodbias = bld->base.zero; - if (projected) { + if (modifier == TEX_MODIFIER_PROJECTED) { oow = emit_fetch( bld, inst, 0, 3 ); oow = lp_build_rcp(&bld->base, oow); } for (i = 0; i < num_coords; i++) { coords[i] = emit_fetch( bld, inst, 0, i ); - if (projected) + if (modifier == TEX_MODIFIER_PROJECTED) coords[i] = lp_build_mul(&bld->base, coords[i], oow); } for (i = num_coords; i < 3; i++) { coords[i] = bld->base.undef; } + if (modifier == TEX_MODIFIER_EXPLICIT_DERIV) { + for (i = 0; i < num_coords; i++) { + ddx[i] = emit_fetch( bld, inst, 1, i ); + ddy[i] = emit_fetch( bld, inst, 2, i ); + } + unit = inst->Src[3].Register.Index; + } else { + for (i = 0; i < num_coords; i++) { + ddx[i] = emit_ddx( bld, coords[i] ); + ddy[i] = emit_ddy( bld, coords[i] ); + } + unit = inst->Src[1].Register.Index; + } + bld->sampler->emit_fetch_texel(bld->sampler, bld->base.builder, bld->base.type, - unit, num_coords, coords, lodbias, + unit, num_coords, coords, + ddx, ddy, lodbias, texel); } @@ -1361,12 +1385,11 @@ emit_instruction( break; case TGSI_OPCODE_TEX: - emit_tex( bld, inst, FALSE, FALSE, dst0 ); + emit_tex( bld, inst, TEX_MODIFIER_NONE, dst0 ); break; case TGSI_OPCODE_TXD: - /* FIXME */ - return FALSE; + emit_tex( bld, inst, TEX_MODIFIER_EXPLICIT_DERIV, dst0 ); break; case TGSI_OPCODE_UP2H: @@ -1468,7 +1491,7 @@ emit_instruction( break; case TGSI_OPCODE_TXB: - emit_tex( bld, inst, TRUE, FALSE, dst0 ); + emit_tex( bld, inst, TEX_MODIFIER_LOD_BIAS, dst0 ); break; case TGSI_OPCODE_NRM: @@ -1573,11 +1596,11 @@ emit_instruction( break; case TGSI_OPCODE_TXL: - emit_tex( bld, inst, TRUE, FALSE, dst0 ); + emit_tex( bld, inst, TEX_MODIFIER_EXPLICIT_LOD, dst0 ); break; case TGSI_OPCODE_TXP: - emit_tex( bld, inst, FALSE, TRUE, dst0 ); + emit_tex( bld, inst, TEX_MODIFIER_PROJECTED, dst0 ); break; case TGSI_OPCODE_BRK: diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 74b7393e4e..3f788e598f 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -170,6 +170,8 @@ lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, unsigned unit, unsigned num_coords, const LLVMValueRef *coords, + const LLVMValueRef *ddx, + const LLVMValueRef *ddy, LLVMValueRef lodbias, LLVMValueRef *texel) { @@ -182,9 +184,8 @@ lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, &sampler->dynamic_state.base, type, unit, - num_coords, - coords, - lodbias, + num_coords, coords, + ddx, ddy, lodbias, texel); } -- cgit v1.2.3 From 4554cdc289f1d97855825127c0bf8c0e7f6a2eda Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 4 May 2010 13:31:50 +0100 Subject: gallivm: Fix several glitches introduced in the prev commit. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 4 ++-- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 3 --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 6 +++++- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 5927923271..d1592c22f4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -954,12 +954,12 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, dsdy = LLVMBuildExtractElement(bld->builder, ddy[0], index0, "dsdy"); dsdy = lp_build_abs(float_bld, dsdy); if (dims > 1) { - dtdx = LLVMBuildExtractElement(bld->builder, ddx[1], index0, "dsdx"); + dtdx = LLVMBuildExtractElement(bld->builder, ddx[1], index0, "dtdx"); dtdx = lp_build_abs(float_bld, dtdx); dtdy = LLVMBuildExtractElement(bld->builder, ddy[1], index0, "dtdy"); dtdy = lp_build_abs(float_bld, dtdy); if (dims > 2) { - drdx = LLVMBuildExtractElement(bld->builder, ddx[2], index0, "dsdx"); + drdx = LLVMBuildExtractElement(bld->builder, ddx[2], index0, "drdx"); drdx = lp_build_abs(float_bld, drdx); drdy = LLVMBuildExtractElement(bld->builder, ddy[2], index0, "drdy"); drdy = lp_build_abs(float_bld, drdy); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 4ca730a98a..71c51db786 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -45,9 +45,6 @@ struct lp_build_context; struct lp_build_mask_context; -#define LP_BLD_SAMPLER_EXPLICIT_DERIVATIVES 1 - - /** * Sampler code generation interface. * diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 6659cff870..022223bb29 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -644,7 +644,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, } /* FIXME: Treat TEX_MODIFIER_EXPLICIT_LOD correctly */ - if (modifier == TEX_MODIFIER_LOD_BIAS || TEX_MODIFIER_EXPLICIT_LOD) + if (modifier == TEX_MODIFIER_LOD_BIAS || modifier == TEX_MODIFIER_EXPLICIT_LOD) lodbias = emit_fetch( bld, inst, 0, 3 ); else lodbias = bld->base.zero; @@ -676,6 +676,10 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, } unit = inst->Src[1].Register.Index; } + for (i = num_coords; i < 3; i++) { + ddx[i] = bld->base.undef; + ddy[i] = bld->base.undef; + } bld->sampler->emit_fetch_texel(bld->sampler, bld->base.builder, -- cgit v1.2.3 From ec43b2eb45a1b2e33f328f76624c987484e329f3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 4 May 2010 13:51:54 +0100 Subject: gallivm: Proper implementation of TXL opcode. --- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 3 +- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 136 ++++++++++++---------- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 3 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 22 ++-- src/gallium/drivers/llvmpipe/lp_tex_sample.c | 6 +- 5 files changed, 100 insertions(+), 70 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 40f2b571f7..955b1d21ee 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -175,7 +175,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, const LLVMValueRef *coords, const LLVMValueRef *ddx, const LLVMValueRef *ddy, - LLVMValueRef lodbias, + LLVMValueRef lod_bias, + LLVMValueRef explicit_lod, LLVMValueRef *texel); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index d1592c22f4..3f0ea05b79 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -30,6 +30,7 @@ * Texture sampling -- SoA. * * @author Jose Fonseca + * @author Brian Paul */ #include "pipe/p_defines.h" @@ -903,10 +904,14 @@ lp_build_minify(struct lp_build_sample_context *bld, * \param s vector of texcoord s values * \param t vector of texcoord t values * \param r vector of texcoord r values - * \param shader_lod_bias vector float with the shader lod bias, + * \param lod_bias optional float vector with the shader lod bias + * \param explicit_lod optional float vector with the explicit lod * \param width scalar int texture width * \param height scalar int texture height * \param depth scalar int texture depth + * + * XXX: The resulting lod is scalar, so ignore all but the first element of + * derivatives, lod_bias, etc that are passed by the shader. */ static LLVMValueRef lp_build_lod_selector(struct lp_build_sample_context *bld, @@ -915,7 +920,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, LLVMValueRef r, const LLVMValueRef *ddx, const LLVMValueRef *ddy, - LLVMValueRef shader_lod_bias, + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ LLVMValueRef width, LLVMValueRef height, LLVMValueRef depth) @@ -928,7 +934,6 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, return LLVMConstReal(LLVMFloatType(), bld->static_state->min_lod); } else { - const int dims = texture_dims(bld->static_state->target); struct lp_build_context *float_bld = &bld->float_bld; LLVMValueRef sampler_lod_bias = LLVMConstReal(LLVMFloatType(), bld->static_state->lod_bias); @@ -936,67 +941,76 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, bld->static_state->min_lod); LLVMValueRef max_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->max_lod); - LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0); - LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; - LLVMValueRef rho, lod; - - /* - * dsdx = abs(s[1] - s[0]); - * dsdy = abs(s[2] - s[0]); - * dtdx = abs(t[1] - t[0]); - * dtdy = abs(t[2] - t[0]); - * drdx = abs(r[1] - r[0]); - * drdy = abs(r[2] - r[0]); - */ - dsdx = LLVMBuildExtractElement(bld->builder, ddx[0], index0, "dsdx"); - dsdx = lp_build_abs(float_bld, dsdx); - dsdy = LLVMBuildExtractElement(bld->builder, ddy[0], index0, "dsdy"); - dsdy = lp_build_abs(float_bld, dsdy); - if (dims > 1) { - dtdx = LLVMBuildExtractElement(bld->builder, ddx[1], index0, "dtdx"); - dtdx = lp_build_abs(float_bld, dtdx); - dtdy = LLVMBuildExtractElement(bld->builder, ddy[1], index0, "dtdy"); - dtdy = lp_build_abs(float_bld, dtdy); - if (dims > 2) { - drdx = LLVMBuildExtractElement(bld->builder, ddx[2], index0, "drdx"); - drdx = lp_build_abs(float_bld, drdx); - drdy = LLVMBuildExtractElement(bld->builder, ddy[2], index0, "drdy"); - drdy = lp_build_abs(float_bld, drdy); - } + LLVMValueRef lod; + + if (explicit_lod) { + lod = LLVMBuildExtractElement(bld->builder, explicit_lod, + index0, ""); } + else { + const int dims = texture_dims(bld->static_state->target); + LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; + LLVMValueRef rho; + + /* + * dsdx = abs(s[1] - s[0]); + * dsdy = abs(s[2] - s[0]); + * dtdx = abs(t[1] - t[0]); + * dtdy = abs(t[2] - t[0]); + * drdx = abs(r[1] - r[0]); + * drdy = abs(r[2] - r[0]); + */ + dsdx = LLVMBuildExtractElement(bld->builder, ddx[0], index0, "dsdx"); + dsdx = lp_build_abs(float_bld, dsdx); + dsdy = LLVMBuildExtractElement(bld->builder, ddy[0], index0, "dsdy"); + dsdy = lp_build_abs(float_bld, dsdy); + if (dims > 1) { + dtdx = LLVMBuildExtractElement(bld->builder, ddx[1], index0, "dtdx"); + dtdx = lp_build_abs(float_bld, dtdx); + dtdy = LLVMBuildExtractElement(bld->builder, ddy[1], index0, "dtdy"); + dtdy = lp_build_abs(float_bld, dtdy); + if (dims > 2) { + drdx = LLVMBuildExtractElement(bld->builder, ddx[2], index0, "drdx"); + drdx = lp_build_abs(float_bld, drdx); + drdy = LLVMBuildExtractElement(bld->builder, ddy[2], index0, "drdy"); + drdy = lp_build_abs(float_bld, drdy); + } + } - /* Compute rho = max of all partial derivatives scaled by texture size. - * XXX this could be vectorized somewhat - */ - rho = LLVMBuildMul(bld->builder, - lp_build_max(float_bld, dsdx, dsdy), - lp_build_int_to_float(float_bld, width), ""); - if (dims > 1) { - LLVMValueRef max; - max = LLVMBuildMul(bld->builder, - lp_build_max(float_bld, dtdx, dtdy), - lp_build_int_to_float(float_bld, height), ""); - rho = lp_build_max(float_bld, rho, max); - if (dims > 2) { + /* Compute rho = max of all partial derivatives scaled by texture size. + * XXX this could be vectorized somewhat + */ + rho = LLVMBuildMul(bld->builder, + lp_build_max(float_bld, dsdx, dsdy), + lp_build_int_to_float(float_bld, width), ""); + if (dims > 1) { + LLVMValueRef max; max = LLVMBuildMul(bld->builder, - lp_build_max(float_bld, drdx, drdy), - lp_build_int_to_float(float_bld, depth), ""); + lp_build_max(float_bld, dtdx, dtdy), + lp_build_int_to_float(float_bld, height), ""); rho = lp_build_max(float_bld, rho, max); + if (dims > 2) { + max = LLVMBuildMul(bld->builder, + lp_build_max(float_bld, drdx, drdy), + lp_build_int_to_float(float_bld, depth), ""); + rho = lp_build_max(float_bld, rho, max); + } } - } - /* compute lod = log2(rho) */ - lod = lp_build_log2(float_bld, rho); + /* compute lod = log2(rho) */ + lod = lp_build_log2(float_bld, rho); - /* add sampler lod bias */ - lod = LLVMBuildAdd(bld->builder, lod, sampler_lod_bias, "sampler LOD bias"); + /* add shader lod bias */ + if (lod_bias) { + lod_bias = LLVMBuildExtractElement(bld->builder, lod_bias, + index0, ""); + lod = LLVMBuildAdd(bld->builder, lod, lod_bias, "shader_lod_bias"); + } + } - /* add shader lod bias */ - /* XXX for now we take only the first element since our lod is scalar */ - shader_lod_bias = LLVMBuildExtractElement(bld->builder, shader_lod_bias, - LLVMConstInt(LLVMInt32Type(), 0, 0), ""); - lod = LLVMBuildAdd(bld->builder, lod, shader_lod_bias, "shader LOD bias"); + /* add sampler lod bias */ + lod = LLVMBuildAdd(bld->builder, lod, sampler_lod_bias, "sampler_lod_bias"); /* clamp lod */ lod = lp_build_clamp(float_bld, lod, min_lod, max_lod); @@ -1584,7 +1598,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, LLVMValueRef r, const LLVMValueRef *ddx, const LLVMValueRef *ddy, - LLVMValueRef lodbias, + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ LLVMValueRef width, LLVMValueRef height, LLVMValueRef depth, @@ -1622,7 +1637,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, /* Need to compute lod either to choose mipmap levels or to * distinguish between minification/magnification with one mipmap level. */ - lod = lp_build_lod_selector(bld, s, t, r, ddx, ddy, lodbias, + lod = lp_build_lod_selector(bld, s, t, r, ddx, ddy, + lod_bias, explicit_lod, width, height, depth); } @@ -2083,7 +2099,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, const LLVMValueRef *coords, const LLVMValueRef *ddx, const LLVMValueRef *ddy, - LLVMValueRef lodbias, + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ LLVMValueRef *texel) { struct lp_build_sample_context bld; @@ -2150,7 +2167,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, row_stride_array, data_array, texel); } else { - lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy, lodbias, + lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy, + lod_bias, explicit_lod, width, height, depth, width_vec, height_vec, depth_vec, row_stride_array, img_stride_array, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 71c51db786..5ce1385c48 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -67,7 +67,8 @@ struct lp_build_sampler_soa const LLVMValueRef *coords, const LLVMValueRef *ddx, const LLVMValueRef *ddy, - LLVMValueRef lodbias, + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ LLVMValueRef *texel); }; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 022223bb29..0b1a28a7ab 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -607,7 +607,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, LLVMValueRef *texel) { unsigned unit; - LLVMValueRef lodbias; + LLVMValueRef lod_bias, explicit_lod; LLVMValueRef oow = NULL; LLVMValueRef coords[3]; LLVMValueRef ddx[3]; @@ -643,11 +643,18 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, return; } - /* FIXME: Treat TEX_MODIFIER_EXPLICIT_LOD correctly */ - if (modifier == TEX_MODIFIER_LOD_BIAS || modifier == TEX_MODIFIER_EXPLICIT_LOD) - lodbias = emit_fetch( bld, inst, 0, 3 ); - else - lodbias = bld->base.zero; + if (modifier == TEX_MODIFIER_LOD_BIAS) { + lod_bias = emit_fetch( bld, inst, 0, 3 ); + explicit_lod = NULL; + } + else if (modifier == TEX_MODIFIER_EXPLICIT_LOD) { + lod_bias = NULL; + explicit_lod = emit_fetch( bld, inst, 0, 3 ); + } + else { + lod_bias = NULL; + explicit_lod = NULL; + } if (modifier == TEX_MODIFIER_PROJECTED) { oow = emit_fetch( bld, inst, 0, 3 ); @@ -685,7 +692,8 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, bld->base.builder, bld->base.type, unit, num_coords, coords, - ddx, ddy, lodbias, + ddx, ddy, + lod_bias, explicit_lod, texel); } diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 3f788e598f..d3a9d39f61 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -172,7 +172,8 @@ lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, const LLVMValueRef *coords, const LLVMValueRef *ddx, const LLVMValueRef *ddy, - LLVMValueRef lodbias, + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ LLVMValueRef *texel) { struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; @@ -185,7 +186,8 @@ lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, type, unit, num_coords, coords, - ddx, ddy, lodbias, + ddx, ddy, + lod_bias, explicit_lod, texel); } -- cgit v1.2.3