summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-01-08 15:42:57 +0000
committerJosé Fonseca <jfonseca@vmware.com>2010-01-08 15:42:57 +0000
commit080c40ab32b2abd6d8381b4a0cc143d36a1652b2 (patch)
treee173767ebc5a82d81b9fc086449d915e29348976 /src/gallium/auxiliary
parent9cdf6f025b2ed55cfb13dd09f870f01d0c7947d3 (diff)
parenta1de400e8de06a80ab140bb0fa950e990607572d (diff)
Merge remote branch 'origin/master' into lp-binning
Conflicts: src/gallium/auxiliary/util/u_surface.c src/gallium/drivers/llvmpipe/Makefile src/gallium/drivers/llvmpipe/SConscript src/gallium/drivers/llvmpipe/lp_bld_arit.c src/gallium/drivers/llvmpipe/lp_bld_flow.c src/gallium/drivers/llvmpipe/lp_bld_interp.c src/gallium/drivers/llvmpipe/lp_clear.c src/gallium/drivers/llvmpipe/lp_context.c src/gallium/drivers/llvmpipe/lp_context.h src/gallium/drivers/llvmpipe/lp_draw_arrays.c src/gallium/drivers/llvmpipe/lp_jit.c src/gallium/drivers/llvmpipe/lp_jit.h src/gallium/drivers/llvmpipe/lp_prim_vbuf.c src/gallium/drivers/llvmpipe/lp_setup.c src/gallium/drivers/llvmpipe/lp_setup_point.c src/gallium/drivers/llvmpipe/lp_state.h src/gallium/drivers/llvmpipe/lp_state_blend.c src/gallium/drivers/llvmpipe/lp_state_derived.c src/gallium/drivers/llvmpipe/lp_state_fs.c src/gallium/drivers/llvmpipe/lp_state_sampler.c src/gallium/drivers/llvmpipe/lp_state_surface.c src/gallium/drivers/llvmpipe/lp_tex_cache.c src/gallium/drivers/llvmpipe/lp_tex_cache.h src/gallium/drivers/llvmpipe/lp_tex_sample.h src/gallium/drivers/llvmpipe/lp_tile_cache.c
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/Makefile181
-rw-r--r--src/gallium/auxiliary/SConscript185
-rw-r--r--src/gallium/auxiliary/cso_cache/Makefile11
-rw-r--r--src/gallium/auxiliary/cso_cache/SConscript11
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c212
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h34
-rw-r--r--src/gallium/auxiliary/draw/Makefile46
-rw-r--r--src/gallium/auxiliary/draw/SConscript46
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c84
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h22
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.c338
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.h76
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c126
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c294
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_cull.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c79
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_point.c14
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h35
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c12
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h8
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch.c35
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c56
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_post_vs.c65
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_util.c16
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.c250
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_varient.c5
-rw-r--r--src/gallium/auxiliary/gallivm/Makefile92
-rw-r--r--src/gallium/auxiliary/gallivm/SConscript16
-rw-r--r--src/gallium/auxiliary/gallivm/tgsitollvm.cpp70
-rw-r--r--src/gallium/auxiliary/indices/Makefile16
-rw-r--r--src/gallium/auxiliary/indices/SConscript28
-rw-r--r--src/gallium/auxiliary/pipebuffer/Makefile19
-rw-r--r--src/gallium/auxiliary/pipebuffer/SConscript19
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h5
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c295
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.h2
-rw-r--r--src/gallium/auxiliary/rbug/Makefile14
-rw-r--r--src/gallium/auxiliary/rbug/README4
-rw-r--r--src/gallium/auxiliary/rbug/SConscript14
-rw-r--r--src/gallium/auxiliary/rbug/rbug_connection.c1
-rw-r--r--src/gallium/auxiliary/rbug/rbug_context.h2
-rw-r--r--src/gallium/auxiliary/rbug/rbug_proto.h2
-rw-r--r--src/gallium/auxiliary/rtasm/Makefile13
-rw-r--r--src/gallium/auxiliary/rtasm/SConscript13
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_execmem.c32
-rw-r--r--src/gallium/auxiliary/sct/Makefile9
-rw-r--r--src/gallium/auxiliary/sct/SConscript9
-rw-r--r--src/gallium/auxiliary/sct/sct.c453
-rw-r--r--src/gallium/auxiliary/sct/sct.h123
-rw-r--r--src/gallium/auxiliary/sct/usage.c61
-rw-r--r--src/gallium/auxiliary/tgsi/Makefile22
-rw-r--r--src/gallium/auxiliary/tgsi/SConscript23
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt32
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c832
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.h169
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c273
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.h5
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump_c.c400
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c2958
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h75
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c38
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_iterate.c7
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_iterate.h6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h28
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.c208
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.h50
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.c81
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sanity.c321
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.c99
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.h9
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c110
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c731
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_transform.c35
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_transform.h4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c431
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h299
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_util.c161
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_util.h24
-rw-r--r--src/gallium/auxiliary/translate/Makefile12
-rw-r--r--src/gallium/auxiliary/translate/SConscript12
-rw-r--r--src/gallium/auxiliary/util/Makefile45
-rw-r--r--src/gallium/auxiliary/util/SConscript59
-rw-r--r--src/gallium/auxiliary/util/u_bitmask.c32
-rw-r--r--src/gallium/auxiliary/util/u_blit.c54
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c726
-rw-r--r--src/gallium/auxiliary/util/u_blitter.h230
-rw-r--r--src/gallium/auxiliary/util/u_clear.h20
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.c63
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.h2
-rw-r--r--src/gallium/auxiliary/util/u_debug.c42
-rw-r--r--src/gallium/auxiliary/util/u_debug.h13
-rw-r--r--src/gallium/auxiliary/util/u_debug_dump.c78
-rw-r--r--src/gallium/auxiliary/util/u_debug_dump.h12
-rw-r--r--src/gallium/auxiliary/util/u_debug_memory.c8
-rw-r--r--src/gallium/auxiliary/util/u_debug_profile.c320
-rw-r--r--src/gallium/auxiliary/util/u_dl.c79
-rw-r--r--src/gallium/auxiliary/util/u_dl.h73
-rw-r--r--src/gallium/auxiliary/util/u_format.c15
-rw-r--r--src/gallium/auxiliary/util/u_format.csv32
-rw-r--r--src/gallium/auxiliary/util/u_format.h292
-rw-r--r--src/gallium/auxiliary/util/u_format_access.py4
-rwxr-xr-xsrc/gallium/auxiliary/util/u_format_table.py37
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c112
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.c95
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.h35
-rw-r--r--src/gallium/auxiliary/util/u_keymap.c4
-rw-r--r--src/gallium/auxiliary/util/u_linear.c2
-rw-r--r--src/gallium/auxiliary/util/u_linear.h19
-rw-r--r--src/gallium/auxiliary/util/u_math.h60
-rw-r--r--src/gallium/auxiliary/util/u_mm.c7
-rw-r--r--src/gallium/auxiliary/util/u_network.c8
-rw-r--r--src/gallium/auxiliary/util/u_network.h2
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h189
-rw-r--r--src/gallium/auxiliary/util/u_prim.h35
-rw-r--r--src/gallium/auxiliary/util/u_rect.c90
-rw-r--r--src/gallium/auxiliary/util/u_rect.h6
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c88
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.h13
-rw-r--r--src/gallium/auxiliary/util/u_stream_stdc.c2
-rw-r--r--src/gallium/auxiliary/util/u_surface.c8
-rw-r--r--src/gallium/auxiliary/util/u_texture.c102
-rw-r--r--src/gallium/auxiliary/util/u_texture.h54
-rw-r--r--src/gallium/auxiliary/util/u_tile.c113
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.c2
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.h2
-rw-r--r--src/gallium/auxiliary/vl/Makefile13
-rw-r--r--src/gallium/auxiliary/vl/SConscript13
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c36
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h1
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c147
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h1
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.c91
144 files changed, 8326 insertions, 6304 deletions
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 5446eb68a9..e3af41c6e0 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -1,12 +1,177 @@
-# src/gallium/auxiliary/Makefile
TOP = ../../..
include $(TOP)/configs/current
-SUBDIRS = $(GALLIUM_AUXILIARY_DIRS)
+LIBNAME = gallium
-default install clean:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) $@) || exit 1; \
- fi \
- done
+C_SOURCES = \
+ cso_cache/cso_context.c \
+ cso_cache/cso_cache.c \
+ cso_cache/cso_hash.c \
+ draw/draw_context.c \
+ draw/draw_gs.c \
+ draw/draw_pipe.c \
+ draw/draw_pipe_aaline.c \
+ draw/draw_pipe_aapoint.c \
+ draw/draw_pipe_clip.c \
+ draw/draw_pipe_cull.c \
+ draw/draw_pipe_flatshade.c \
+ draw/draw_pipe_offset.c \
+ draw/draw_pipe_pstipple.c \
+ draw/draw_pipe_stipple.c \
+ draw/draw_pipe_twoside.c \
+ draw/draw_pipe_unfilled.c \
+ draw/draw_pipe_util.c \
+ draw/draw_pipe_validate.c \
+ draw/draw_pipe_vbuf.c \
+ draw/draw_pipe_wide_line.c \
+ draw/draw_pipe_wide_point.c \
+ draw/draw_pt.c \
+ draw/draw_pt_elts.c \
+ draw/draw_pt_emit.c \
+ draw/draw_pt_fetch.c \
+ draw/draw_pt_fetch_emit.c \
+ draw/draw_pt_fetch_shade_emit.c \
+ draw/draw_pt_fetch_shade_pipeline.c \
+ draw/draw_pt_post_vs.c \
+ draw/draw_pt_util.c \
+ draw/draw_pt_varray.c \
+ draw/draw_pt_vcache.c \
+ draw/draw_vertex.c \
+ draw/draw_vs.c \
+ draw/draw_vs_varient.c \
+ draw/draw_vs_aos.c \
+ draw/draw_vs_aos_io.c \
+ draw/draw_vs_aos_machine.c \
+ draw/draw_vs_exec.c \
+ draw/draw_vs_llvm.c \
+ draw/draw_vs_ppc.c \
+ draw/draw_vs_sse.c \
+ indices/u_indices_gen.c \
+ indices/u_unfilled_gen.c \
+ pipebuffer/pb_buffer_fenced.c \
+ pipebuffer/pb_buffer_malloc.c \
+ pipebuffer/pb_bufmgr_alt.c \
+ pipebuffer/pb_bufmgr_cache.c \
+ pipebuffer/pb_bufmgr_debug.c \
+ pipebuffer/pb_bufmgr_fenced.c \
+ pipebuffer/pb_bufmgr_mm.c \
+ pipebuffer/pb_bufmgr_ondemand.c \
+ pipebuffer/pb_bufmgr_pool.c \
+ pipebuffer/pb_bufmgr_slab.c \
+ pipebuffer/pb_validate.c \
+ rbug/rbug_connection.c \
+ rbug/rbug_core.c \
+ rbug/rbug_texture.c \
+ rbug/rbug_context.c \
+ rbug/rbug_shader.c \
+ rbug/rbug_demarshal.c \
+ rtasm/rtasm_cpu.c \
+ rtasm/rtasm_execmem.c \
+ rtasm/rtasm_x86sse.c \
+ rtasm/rtasm_ppc.c \
+ rtasm/rtasm_ppc_spe.c \
+ tgsi/tgsi_sanity.c \
+ tgsi/tgsi_build.c \
+ tgsi/tgsi_dump.c \
+ tgsi/tgsi_exec.c \
+ tgsi/tgsi_info.c \
+ tgsi/tgsi_iterate.c \
+ tgsi/tgsi_parse.c \
+ tgsi/tgsi_ppc.c \
+ tgsi/tgsi_scan.c \
+ tgsi/tgsi_sse2.c \
+ tgsi/tgsi_text.c \
+ tgsi/tgsi_transform.c \
+ tgsi/tgsi_ureg.c \
+ tgsi/tgsi_util.c \
+ translate/translate_generic.c \
+ translate/translate_sse.c \
+ translate/translate.c \
+ translate/translate_cache.c \
+ util/u_debug.c \
+ util/u_debug_dump.c \
+ util/u_debug_symbol.c \
+ util/u_debug_stack.c \
+ util/u_blit.c \
+ util/u_blitter.c \
+ util/u_cache.c \
+ util/u_cpu_detect.c \
+ util/u_dl.c \
+ util/u_draw_quad.c \
+ util/u_format.c \
+ util/u_format_access.c \
+ util/u_format_table.c \
+ util/u_gen_mipmap.c \
+ util/u_handle_table.c \
+ util/u_hash_table.c \
+ util/u_hash.c \
+ util/u_keymap.c \
+ util/u_linear.c \
+ util/u_network.c \
+ util/u_math.c \
+ util/u_mm.c \
+ util/u_rect.c \
+ util/u_simple_shaders.c \
+ util/u_snprintf.c \
+ util/u_stream_stdc.c \
+ util/u_stream_wd.c \
+ util/u_surface.c \
+ util/u_texture.c \
+ util/u_tile.c \
+ util/u_time.c \
+ util/u_timed_winsys.c \
+ util/u_upload_mgr.c \
+ util/u_simple_screen.c \
+ vl/vl_bitstream_parser.c \
+ vl/vl_mpeg12_mc_renderer.c \
+ vl/vl_compositor.c \
+ vl/vl_csc.c \
+ vl/vl_shader_build.c
+
+GALLIVM_SOURCES = \
+ gallivm/gallivm.cpp \
+ gallivm/gallivm_cpu.cpp \
+ gallivm/instructions.cpp \
+ gallivm/loweringpass.cpp \
+ gallivm/tgsitollvm.cpp \
+ gallivm/storage.cpp \
+ gallivm/storagesoa.cpp \
+ gallivm/instructionssoa.cpp
+
+INC_SOURCES = \
+ gallivm/gallivm_builtins.cpp \
+ gallivm/gallivmsoabuiltins.cpp
+
+# XXX: gallivm doesn't build correctly so disable for now
+#ifeq ($(MESA_LLVM),1)
+#DEFINES += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
+#CPP_SOURCES += \
+# $(GALLIVM_SOURCES)
+#endif
+
+
+include ../Makefile.template
+
+
+gallivm/gallivm_builtins.cpp: gallivm/llvm_builtins.c
+ clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp1.bin
+ (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
+ rm temp1.bin
+
+gallivm/gallivmsoabuiltins.cpp: gallivm/soabuiltins.c
+ clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp2.bin
+ (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
+ rm temp2.bin
+
+
+indices/u_indices_gen.c: indices/u_indices_gen.py
+ python $< > $@
+
+indices/u_unfilled_gen.c: indices/u_unfilled_gen.py
+ python $< > $@
+
+util/u_format_table.c: util/u_format_table.py util/u_format_parse.py util/u_format.csv
+ python util/u_format_table.py util/u_format.csv > $@
+
+util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv
+ python util/u_format_access.py util/u_format.csv > $@
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
new file mode 100644
index 0000000000..782eb53386
--- /dev/null
+++ b/src/gallium/auxiliary/SConscript
@@ -0,0 +1,185 @@
+Import('*')
+
+from sys import executable as python_cmd
+
+env.Append(CPPPATH = [
+ 'indices',
+ 'util',
+])
+
+env.CodeGenerate(
+ target = 'indices/u_indices_gen.c',
+ script = 'indices/u_indices_gen.py',
+ source = [],
+ command = python_cmd + ' $SCRIPT > $TARGET'
+)
+
+env.CodeGenerate(
+ target = 'indices/u_unfilled_gen.c',
+ script = 'indices/u_unfilled_gen.py',
+ source = [],
+ command = python_cmd + ' $SCRIPT > $TARGET'
+)
+
+env.CodeGenerate(
+ target = 'util/u_format_table.c',
+ script = 'util/u_format_table.py',
+ source = ['util/u_format.csv'],
+ command = 'python $SCRIPT $SOURCE > $TARGET'
+)
+
+env.CodeGenerate(
+ target = 'util/u_format_access.c',
+ script = 'util/u_format_access.py',
+ source = ['util/u_format.csv'],
+ command = 'python $SCRIPT $SOURCE > $TARGET'
+)
+
+source = [
+ 'cso_cache/cso_context.c',
+ 'cso_cache/cso_cache.c',
+ 'cso_cache/cso_hash.c',
+ 'draw/draw_context.c',
+ 'draw/draw_pipe.c',
+ 'draw/draw_pipe_aaline.c',
+ 'draw/draw_pipe_aapoint.c',
+ 'draw/draw_pipe_clip.c',
+ 'draw/draw_pipe_cull.c',
+ 'draw/draw_pipe_flatshade.c',
+ 'draw/draw_pipe_offset.c',
+ 'draw/draw_pipe_pstipple.c',
+ 'draw/draw_pipe_stipple.c',
+ 'draw/draw_pipe_twoside.c',
+ 'draw/draw_pipe_unfilled.c',
+ 'draw/draw_pipe_util.c',
+ 'draw/draw_pipe_validate.c',
+ 'draw/draw_pipe_vbuf.c',
+ 'draw/draw_pipe_wide_line.c',
+ 'draw/draw_pipe_wide_point.c',
+ 'draw/draw_pt.c',
+ 'draw/draw_pt_elts.c',
+ 'draw/draw_pt_emit.c',
+ 'draw/draw_pt_fetch.c',
+ 'draw/draw_pt_fetch_emit.c',
+ 'draw/draw_pt_fetch_shade_emit.c',
+ 'draw/draw_pt_fetch_shade_pipeline.c',
+ 'draw/draw_pt_post_vs.c',
+ 'draw/draw_pt_util.c',
+ 'draw/draw_pt_varray.c',
+ 'draw/draw_pt_vcache.c',
+ 'draw/draw_vertex.c',
+ 'draw/draw_vs.c',
+ 'draw/draw_vs_aos.c',
+ 'draw/draw_vs_aos_io.c',
+ 'draw/draw_vs_aos_machine.c',
+ 'draw/draw_vs_exec.c',
+ 'draw/draw_vs_llvm.c',
+ 'draw/draw_vs_ppc.c',
+ 'draw/draw_vs_sse.c',
+ 'draw/draw_vs_varient.c',
+ 'draw/draw_gs.c',
+ #'indices/u_indices.c',
+ #'indices/u_unfilled_indices.c',
+ 'indices/u_indices_gen.c',
+ 'indices/u_unfilled_gen.c',
+ 'pipebuffer/pb_buffer_fenced.c',
+ 'pipebuffer/pb_buffer_malloc.c',
+ 'pipebuffer/pb_bufmgr_alt.c',
+ 'pipebuffer/pb_bufmgr_cache.c',
+ 'pipebuffer/pb_bufmgr_debug.c',
+ 'pipebuffer/pb_bufmgr_fenced.c',
+ 'pipebuffer/pb_bufmgr_mm.c',
+ 'pipebuffer/pb_bufmgr_ondemand.c',
+ 'pipebuffer/pb_bufmgr_pool.c',
+ 'pipebuffer/pb_bufmgr_slab.c',
+ 'pipebuffer/pb_validate.c',
+ 'rbug/rbug_core.c',
+ 'rbug/rbug_shader.c',
+ 'rbug/rbug_context.c',
+ 'rbug/rbug_texture.c',
+ 'rbug/rbug_demarshal.c',
+ 'rbug/rbug_connection.c',
+ 'rtasm/rtasm_cpu.c',
+ 'rtasm/rtasm_execmem.c',
+ 'rtasm/rtasm_x86sse.c',
+ 'rtasm/rtasm_ppc.c',
+ 'rtasm/rtasm_ppc_spe.c',
+ 'tgsi/tgsi_build.c',
+ 'tgsi/tgsi_dump.c',
+ 'tgsi/tgsi_dump_c.c',
+ 'tgsi/tgsi_exec.c',
+ 'tgsi/tgsi_info.c',
+ 'tgsi/tgsi_iterate.c',
+ 'tgsi/tgsi_parse.c',
+ 'tgsi/tgsi_sanity.c',
+ 'tgsi/tgsi_scan.c',
+ 'tgsi/tgsi_ppc.c',
+ 'tgsi/tgsi_sse2.c',
+ 'tgsi/tgsi_text.c',
+ 'tgsi/tgsi_transform.c',
+ 'tgsi/tgsi_ureg.c',
+ 'tgsi/tgsi_util.c',
+ 'translate/translate_generic.c',
+ 'translate/translate_sse.c',
+ 'translate/translate.c',
+ 'translate/translate_cache.c',
+ 'util/u_bitmask.c',
+ 'util/u_blit.c',
+ 'util/u_blitter.c',
+ 'util/u_cache.c',
+ 'util/u_cpu_detect.c',
+ 'util/u_debug.c',
+ 'util/u_debug_dump.c',
+ 'util/u_debug_memory.c',
+ 'util/u_debug_stack.c',
+ 'util/u_debug_symbol.c',
+ 'util/u_dl.c',
+ 'util/u_draw_quad.c',
+ 'util/u_format.c',
+ 'util/u_format_access.c',
+ 'util/u_format_table.c',
+ 'util/u_gen_mipmap.c',
+ 'util/u_handle_table.c',
+ 'util/u_hash.c',
+ 'util/u_hash_table.c',
+ 'util/u_keymap.c',
+ 'util/u_network.c',
+ 'util/u_math.c',
+ 'util/u_mm.c',
+ 'util/u_rect.c',
+ 'util/u_simple_shaders.c',
+ 'util/u_snprintf.c',
+ 'util/u_stream_stdc.c',
+ 'util/u_stream_wd.c',
+ 'util/u_surface.c',
+ 'util/u_texture.c',
+ 'util/u_tile.c',
+ 'util/u_time.c',
+ 'util/u_timed_winsys.c',
+ 'util/u_upload_mgr.c',
+ 'util/u_simple_screen.c',
+ 'vl/vl_bitstream_parser.c',
+ 'vl/vl_mpeg12_mc_renderer.c',
+ 'vl/vl_compositor.c',
+ 'vl/vl_csc.c',
+ 'vl/vl_shader_build.c',
+]
+
+if env['llvm']:
+ source += [
+ 'gallivm/gallivm.cpp',
+ 'gallivm/gallivm_cpu.cpp',
+ 'gallivm/instructions.cpp',
+ 'gallivm/loweringpass.cpp',
+ 'gallivm/tgsitollvm.cpp',
+ 'gallivm/storage.cpp',
+ 'gallivm/storagesoa.cpp',
+ 'gallivm/instructionssoa.cpp',
+ ]
+
+gallium = env.ConvenienceLibrary(
+ target = 'gallium',
+ source = source,
+)
+
+Export('gallium')
diff --git a/src/gallium/auxiliary/cso_cache/Makefile b/src/gallium/auxiliary/cso_cache/Makefile
deleted file mode 100644
index 8726afcd94..0000000000
--- a/src/gallium/auxiliary/cso_cache/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = cso_cache
-
-C_SOURCES = \
- cso_context.c \
- cso_cache.c \
- cso_hash.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/cso_cache/SConscript b/src/gallium/auxiliary/cso_cache/SConscript
deleted file mode 100644
index 651e68a191..0000000000
--- a/src/gallium/auxiliary/cso_cache/SConscript
+++ /dev/null
@@ -1,11 +0,0 @@
-Import('*')
-
-cso_cache = env.ConvenienceLibrary(
- target = 'cso_cache',
- source = [
- 'cso_context.c',
- 'cso_cache.c',
- 'cso_hash.c',
- ])
-
-auxiliaries.insert(0, cso_cache)
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 4f13b3e2ba..2b16332e14 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -42,6 +42,7 @@
#include "cso_cache/cso_context.h"
#include "cso_cache/cso_cache.h"
#include "cso_cache/cso_hash.h"
+#include "cso_context.h"
struct cso_context {
struct pipe_context *pipe;
@@ -50,28 +51,43 @@ struct cso_context {
struct {
void *samplers[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
+
+ void *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+ unsigned nr_vertex_samplers;
} hw;
void *samplers[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
+ void *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+ unsigned nr_vertex_samplers;
+
unsigned nr_samplers_saved;
void *samplers_saved[PIPE_MAX_SAMPLERS];
+ unsigned nr_vertex_samplers_saved;
+ void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS];
+
struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
uint nr_textures;
+ struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
+ uint nr_vertex_textures;
+
uint nr_textures_saved;
struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS];
+ uint nr_vertex_textures_saved;
+ struct pipe_texture *vertex_textures_saved[PIPE_MAX_SAMPLERS];
+
/** Current and saved state.
* The saved state is used as a 1-deep stack.
*/
void *blend, *blend_saved;
void *depth_stencil, *depth_stencil_saved;
void *rasterizer, *rasterizer_saved;
- void *fragment_shader, *fragment_shader_saved;
- void *vertex_shader, *vertex_shader_saved;
+ void *fragment_shader, *fragment_shader_saved, *geometry_shader;
+ void *vertex_shader, *vertex_shader_saved, *geometry_shader_saved;
struct pipe_framebuffer_state fb, fb_saved;
struct pipe_viewport_state vp, vp_saved;
@@ -244,7 +260,9 @@ void cso_release_all( struct cso_context *ctx )
if (ctx->pipe) {
ctx->pipe->bind_blend_state( ctx->pipe, NULL );
ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL );
- ctx->pipe->bind_sampler_states( ctx->pipe, 0, NULL );
+ ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL );
+ if (ctx->pipe->bind_vertex_sampler_states)
+ ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL);
ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL );
ctx->pipe->bind_fs_state( ctx->pipe, NULL );
ctx->pipe->bind_vs_state( ctx->pipe, NULL );
@@ -255,6 +273,11 @@ void cso_release_all( struct cso_context *ctx )
pipe_texture_reference(&ctx->textures_saved[i], NULL);
}
+ for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+ pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+ pipe_texture_reference(&ctx->vertex_textures_saved[i], NULL);
+ }
+
free_framebuffer_state(&ctx->fb);
free_framebuffer_state(&ctx->fb_saved);
@@ -378,6 +401,46 @@ enum pipe_error cso_single_sampler(struct cso_context *ctx,
return PIPE_OK;
}
+enum pipe_error
+cso_single_vertex_sampler(struct cso_context *ctx,
+ unsigned idx,
+ const struct pipe_sampler_state *templ)
+{
+ void *handle = NULL;
+
+ if (templ != NULL) {
+ unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state));
+ struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
+ hash_key, CSO_SAMPLER,
+ (void*)templ);
+
+ if (cso_hash_iter_is_null(iter)) {
+ struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
+ if (!cso)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ memcpy(&cso->state, templ, sizeof(*templ));
+ cso->data = ctx->pipe->create_sampler_state(ctx->pipe, &cso->state);
+ cso->delete_state = (cso_state_callback)ctx->pipe->delete_sampler_state;
+ cso->context = ctx->pipe;
+
+ iter = cso_insert_state(ctx->cache, hash_key, CSO_SAMPLER, cso);
+ if (cso_hash_iter_is_null(iter)) {
+ FREE(cso);
+ return PIPE_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle = cso->data;
+ }
+ else {
+ handle = ((struct cso_sampler *)cso_hash_iter_data(iter))->data;
+ }
+ }
+
+ ctx->vertex_samplers[idx] = handle;
+ return PIPE_OK;
+}
+
void cso_single_sampler_done( struct cso_context *ctx )
{
unsigned i;
@@ -398,7 +461,36 @@ void cso_single_sampler_done( struct cso_context *ctx )
memcpy(ctx->hw.samplers, ctx->samplers, ctx->nr_samplers * sizeof(void *));
ctx->hw.nr_samplers = ctx->nr_samplers;
- ctx->pipe->bind_sampler_states(ctx->pipe, ctx->nr_samplers, ctx->samplers);
+ ctx->pipe->bind_fragment_sampler_states(ctx->pipe, ctx->nr_samplers, ctx->samplers);
+ }
+}
+
+void
+cso_single_vertex_sampler_done(struct cso_context *ctx)
+{
+ unsigned i;
+
+ /* find highest non-null sampler */
+ for (i = PIPE_MAX_VERTEX_SAMPLERS; i > 0; i--) {
+ if (ctx->vertex_samplers[i - 1] != NULL)
+ break;
+ }
+
+ ctx->nr_vertex_samplers = i;
+
+ if (ctx->hw.nr_vertex_samplers != ctx->nr_vertex_samplers ||
+ memcmp(ctx->hw.vertex_samplers,
+ ctx->vertex_samplers,
+ ctx->nr_vertex_samplers * sizeof(void *)) != 0)
+ {
+ memcpy(ctx->hw.vertex_samplers,
+ ctx->vertex_samplers,
+ ctx->nr_vertex_samplers * sizeof(void *));
+ ctx->hw.nr_vertex_samplers = ctx->nr_vertex_samplers;
+
+ ctx->pipe->bind_vertex_sampler_states(ctx->pipe,
+ ctx->nr_vertex_samplers,
+ ctx->vertex_samplers);
}
}
@@ -447,6 +539,21 @@ void cso_restore_samplers(struct cso_context *ctx)
cso_single_sampler_done( ctx );
}
+void
+cso_save_vertex_samplers(struct cso_context *ctx)
+{
+ ctx->nr_vertex_samplers_saved = ctx->nr_vertex_samplers;
+ memcpy(ctx->vertex_samplers_saved, ctx->vertex_samplers, sizeof(ctx->vertex_samplers));
+}
+
+void
+cso_restore_vertex_samplers(struct cso_context *ctx)
+{
+ ctx->nr_vertex_samplers = ctx->nr_vertex_samplers_saved;
+ memcpy(ctx->vertex_samplers, ctx->vertex_samplers_saved, sizeof(ctx->vertex_samplers));
+ cso_single_vertex_sampler_done(ctx);
+}
+
enum pipe_error cso_set_sampler_textures( struct cso_context *ctx,
uint count,
@@ -461,7 +568,7 @@ enum pipe_error cso_set_sampler_textures( struct cso_context *ctx,
for ( ; i < PIPE_MAX_SAMPLERS; i++)
pipe_texture_reference(&ctx->textures[i], NULL);
- ctx->pipe->set_sampler_textures(ctx->pipe, count, textures);
+ ctx->pipe->set_fragment_sampler_textures(ctx->pipe, count, textures);
return PIPE_OK;
}
@@ -491,13 +598,71 @@ void cso_restore_sampler_textures( struct cso_context *ctx )
for ( ; i < PIPE_MAX_SAMPLERS; i++)
pipe_texture_reference(&ctx->textures[i], NULL);
- ctx->pipe->set_sampler_textures(ctx->pipe, ctx->nr_textures, ctx->textures);
+ ctx->pipe->set_fragment_sampler_textures(ctx->pipe, ctx->nr_textures, ctx->textures);
ctx->nr_textures_saved = 0;
}
+enum pipe_error
+cso_set_vertex_sampler_textures(struct cso_context *ctx,
+ uint count,
+ struct pipe_texture **textures)
+{
+ uint i;
+
+ ctx->nr_vertex_textures = count;
+
+ for (i = 0; i < count; i++) {
+ pipe_texture_reference(&ctx->vertex_textures[i], textures[i]);
+ }
+ for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+ pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+ }
+
+ ctx->pipe->set_vertex_sampler_textures(ctx->pipe, count, textures);
+
+ return PIPE_OK;
+}
+
+void
+cso_save_vertex_sampler_textures(struct cso_context *ctx)
+{
+ uint i;
+
+ ctx->nr_vertex_textures_saved = ctx->nr_vertex_textures;
+ for (i = 0; i < ctx->nr_vertex_textures; i++) {
+ assert(!ctx->vertex_textures_saved[i]);
+ pipe_texture_reference(&ctx->vertex_textures_saved[i], ctx->vertex_textures[i]);
+ }
+}
+
+void
+cso_restore_vertex_sampler_textures(struct cso_context *ctx)
+{
+ uint i;
+
+ ctx->nr_vertex_textures = ctx->nr_vertex_textures_saved;
+
+ for (i = 0; i < ctx->nr_vertex_textures; i++) {
+ pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+ ctx->vertex_textures[i] = ctx->vertex_textures_saved[i];
+ ctx->vertex_textures_saved[i] = NULL;
+ }
+ for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+ pipe_texture_reference(&ctx->vertex_textures[i], NULL);
+ }
+
+ ctx->pipe->set_vertex_sampler_textures(ctx->pipe,
+ ctx->nr_vertex_textures,
+ ctx->vertex_textures);
+
+ ctx->nr_vertex_textures_saved = 0;
+}
+
+
+
enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx,
const struct pipe_depth_stencil_alpha_state *templ)
{
@@ -863,3 +1028,38 @@ enum pipe_error cso_set_blend_color(struct cso_context *ctx,
}
return PIPE_OK;
}
+
+enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
+ void *handle)
+{
+ if (ctx->geometry_shader != handle) {
+ ctx->geometry_shader = handle;
+ ctx->pipe->bind_gs_state(ctx->pipe, handle);
+ }
+ return PIPE_OK;
+}
+
+void cso_delete_geometry_shader(struct cso_context *ctx, void *handle)
+{
+ if (handle == ctx->geometry_shader) {
+ /* unbind before deleting */
+ ctx->pipe->bind_gs_state(ctx->pipe, NULL);
+ ctx->geometry_shader = NULL;
+ }
+ ctx->pipe->delete_gs_state(ctx->pipe, handle);
+}
+
+void cso_save_geometry_shader(struct cso_context *ctx)
+{
+ assert(!ctx->geometry_shader_saved);
+ ctx->geometry_shader_saved = ctx->geometry_shader;
+}
+
+void cso_restore_geometry_shader(struct cso_context *ctx)
+{
+ if (ctx->geometry_shader_saved != ctx->geometry_shader) {
+ ctx->pipe->bind_gs_state(ctx->pipe, ctx->geometry_shader_saved);
+ ctx->geometry_shader = ctx->geometry_shader_saved;
+ }
+ ctx->geometry_shader_saved = NULL;
+}
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index b04e98bfa1..b9e313e32d 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -31,7 +31,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#ifdef __cplusplus
@@ -84,6 +84,20 @@ enum pipe_error cso_single_sampler( struct cso_context *cso,
void cso_single_sampler_done( struct cso_context *cso );
+void
+cso_save_vertex_samplers(struct cso_context *cso);
+
+void
+cso_restore_vertex_samplers(struct cso_context *cso);
+
+enum pipe_error
+cso_single_vertex_sampler(struct cso_context *cso,
+ unsigned nr,
+ const struct pipe_sampler_state *states);
+
+void
+cso_single_vertex_sampler_done(struct cso_context *cso);
+
enum pipe_error cso_set_sampler_textures( struct cso_context *cso,
@@ -94,6 +108,17 @@ void cso_restore_sampler_textures( struct cso_context *cso );
+enum pipe_error
+cso_set_vertex_sampler_textures(struct cso_context *cso,
+ uint count,
+ struct pipe_texture **textures);
+void
+cso_save_vertex_sampler_textures(struct cso_context *cso);
+void
+cso_restore_vertex_sampler_textures(struct cso_context *cso);
+
+
+
/* These aren't really sensible -- most of the time the api provides
* object semantics for shaders anyway, and the cases where it doesn't
* (eg mesa's internall-generated texenv programs), it will be up to
@@ -121,6 +146,13 @@ void cso_save_vertex_shader(struct cso_context *cso);
void cso_restore_vertex_shader(struct cso_context *cso);
+enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
+ void *handle);
+void cso_delete_geometry_shader(struct cso_context *ctx, void *handle);
+void cso_save_geometry_shader(struct cso_context *cso);
+void cso_restore_geometry_shader(struct cso_context *cso);
+
+
enum pipe_error cso_set_framebuffer(struct cso_context *cso,
const struct pipe_framebuffer_state *fb);
diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile
deleted file mode 100644
index 5041dcc072..0000000000
--- a/src/gallium/auxiliary/draw/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = draw
-
-C_SOURCES = \
- draw_context.c \
- draw_pipe.c \
- draw_pipe_aaline.c \
- draw_pipe_aapoint.c \
- draw_pipe_clip.c \
- draw_pipe_cull.c \
- draw_pipe_flatshade.c \
- draw_pipe_offset.c \
- draw_pipe_pstipple.c \
- draw_pipe_stipple.c \
- draw_pipe_twoside.c \
- draw_pipe_unfilled.c \
- draw_pipe_util.c \
- draw_pipe_validate.c \
- draw_pipe_vbuf.c \
- draw_pipe_wide_line.c \
- draw_pipe_wide_point.c \
- draw_pt.c \
- draw_pt_elts.c \
- draw_pt_emit.c \
- draw_pt_fetch.c \
- draw_pt_fetch_emit.c \
- draw_pt_fetch_shade_emit.c \
- draw_pt_fetch_shade_pipeline.c \
- draw_pt_post_vs.c \
- draw_pt_util.c \
- draw_pt_varray.c \
- draw_pt_vcache.c \
- draw_vertex.c \
- draw_vs.c \
- draw_vs_varient.c \
- draw_vs_aos.c \
- draw_vs_aos_io.c \
- draw_vs_aos_machine.c \
- draw_vs_exec.c \
- draw_vs_llvm.c \
- draw_vs_ppc.c \
- draw_vs_sse.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript
deleted file mode 100644
index 5f05aa324a..0000000000
--- a/src/gallium/auxiliary/draw/SConscript
+++ /dev/null
@@ -1,46 +0,0 @@
-Import('*')
-
-draw = env.ConvenienceLibrary(
- target = 'draw',
- source = [
- 'draw_context.c',
- 'draw_pipe.c',
- 'draw_pipe_aaline.c',
- 'draw_pipe_aapoint.c',
- 'draw_pipe_clip.c',
- 'draw_pipe_cull.c',
- 'draw_pipe_flatshade.c',
- 'draw_pipe_offset.c',
- 'draw_pipe_pstipple.c',
- 'draw_pipe_stipple.c',
- 'draw_pipe_twoside.c',
- 'draw_pipe_unfilled.c',
- 'draw_pipe_util.c',
- 'draw_pipe_validate.c',
- 'draw_pipe_vbuf.c',
- 'draw_pipe_wide_line.c',
- 'draw_pipe_wide_point.c',
- 'draw_pt.c',
- 'draw_pt_elts.c',
- 'draw_pt_emit.c',
- 'draw_pt_fetch.c',
- 'draw_pt_fetch_emit.c',
- 'draw_pt_fetch_shade_emit.c',
- 'draw_pt_fetch_shade_pipeline.c',
- 'draw_pt_post_vs.c',
- 'draw_pt_util.c',
- 'draw_pt_varray.c',
- 'draw_pt_vcache.c',
- 'draw_vertex.c',
- 'draw_vs.c',
- 'draw_vs_aos.c',
- 'draw_vs_aos_io.c',
- 'draw_vs_aos_machine.c',
- 'draw_vs_exec.c',
- 'draw_vs_llvm.c',
- 'draw_vs_ppc.c',
- 'draw_vs_sse.c',
- 'draw_vs_varient.c'
- ])
-
-auxiliaries.insert(0, draw)
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index a4f1fcddc1..667aa46b20 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -36,6 +36,7 @@
#include "draw_context.h"
#include "draw_vbuf.h"
#include "draw_vs.h"
+#include "draw_gs.h"
#include "draw_pt.h"
#include "draw_pipe.h"
@@ -67,6 +68,9 @@ struct draw_context *draw_create( void )
if (!draw_vs_init( draw ))
goto fail;
+ if (!draw_gs_init( draw ))
+ goto fail;
+
return draw;
fail:
@@ -231,11 +235,19 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw,
void
draw_set_mapped_constant_buffer(struct draw_context *draw,
- const void *buffer,
+ unsigned shader_type,
+ const void *buffer,
unsigned size )
{
- draw->pt.user.constants = buffer;
- draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
+ debug_assert(shader_type == PIPE_SHADER_VERTEX ||
+ shader_type == PIPE_SHADER_GEOMETRY);
+ if (shader_type == PIPE_SHADER_VERTEX) {
+ draw->pt.user.vs_constants = buffer;
+ draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
+ } else if (shader_type == PIPE_SHADER_GEOMETRY) {
+ draw->pt.user.gs_constants = buffer;
+ draw_gs_set_constants( draw, (const float (*)[4])buffer, size );
+ }
}
@@ -298,7 +310,7 @@ draw_set_force_passthrough( struct draw_context *draw, boolean enable )
* a post-transformed vertex.
*
* With this function, drivers that use the draw module should have no reason
- * to track the current vertex shader.
+ * to track the current vertex/geometry shader.
*
* Note that the draw module may sometimes generate vertices with extra
* attributes (such as texcoords for AA lines). The driver can call this
@@ -309,43 +321,59 @@ draw_set_force_passthrough( struct draw_context *draw, boolean enable )
* work for the drivers.
*/
int
-draw_find_vs_output(const struct draw_context *draw,
- uint semantic_name, uint semantic_index)
+draw_find_shader_output(const struct draw_context *draw,
+ uint semantic_name, uint semantic_index)
{
const struct draw_vertex_shader *vs = draw->vs.vertex_shader;
+ const struct draw_geometry_shader *gs = draw->gs.geometry_shader;
uint i;
- for (i = 0; i < vs->info.num_outputs; i++) {
- if (vs->info.output_semantic_name[i] == semantic_name &&
- vs->info.output_semantic_index[i] == semantic_index)
+ const struct tgsi_shader_info *info = &vs->info;
+
+ if (gs)
+ info = &gs->info;
+
+ for (i = 0; i < info->num_outputs; i++) {
+ if (info->output_semantic_name[i] == semantic_name &&
+ info->output_semantic_index[i] == semantic_index)
return i;
}
/* XXX there may be more than one extra vertex attrib.
* For example, simulated gl_FragCoord and gl_PointCoord.
*/
- if (draw->extra_vp_outputs.semantic_name == semantic_name &&
- draw->extra_vp_outputs.semantic_index == semantic_index) {
- return draw->extra_vp_outputs.slot;
+ if (draw->extra_shader_outputs.semantic_name == semantic_name &&
+ draw->extra_shader_outputs.semantic_index == semantic_index) {
+ return draw->extra_shader_outputs.slot;
}
+
return 0;
}
/**
- * Return number of vertex shader outputs.
+ * Return number of the shader outputs.
+ *
+ * If geometry shader is present, its output will be returned,
+ * if not vertex shader is used.
*/
uint
-draw_num_vs_outputs(const struct draw_context *draw)
+draw_num_shader_outputs(const struct draw_context *draw)
{
uint count = draw->vs.vertex_shader->info.num_outputs;
- if (draw->extra_vp_outputs.slot > 0)
+
+ /* if geometry shader is present, its outputs go to te
+ * driver, not the vertex shaders */
+ if (draw->gs.geometry_shader)
+ count = draw->gs.geometry_shader->info.num_outputs;
+
+ if (draw->extra_shader_outputs.slot > 0)
count++;
return count;
}
/**
- * Provide TGSI sampler objects for vertex shaders that use texture fetches.
+ * Provide TGSI sampler objects for vertex/geometry shaders that use texture fetches.
* This might only be used by software drivers for the time being.
*/
void
@@ -355,6 +383,8 @@ draw_texture_samplers(struct draw_context *draw,
{
draw->vs.num_samplers = num_samplers;
draw->vs.samplers = samplers;
+ draw->gs.num_samplers = num_samplers;
+ draw->gs.samplers = samplers;
}
@@ -366,13 +396,6 @@ void draw_set_render( struct draw_context *draw,
draw->render = render;
}
-void draw_set_edgeflags( struct draw_context *draw,
- const unsigned *edgeflag )
-{
- draw->pt.user.edgeflag = edgeflag;
-}
-
-
/**
@@ -428,3 +451,18 @@ void draw_do_flush( struct draw_context *draw, unsigned flags )
draw->flushing = FALSE;
}
}
+
+
+int draw_current_shader_outputs(struct draw_context *draw)
+{
+ if (draw->gs.geometry_shader)
+ return draw->gs.num_gs_outputs;
+ return draw->vs.num_vs_outputs;
+}
+
+int draw_current_shader_position_output(struct draw_context *draw)
+{
+ if (draw->gs.geometry_shader)
+ return draw->gs.position_output;
+ return draw->vs.position_output;
+}
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index d529e4e9a2..b716209df2 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -45,6 +45,7 @@ struct pipe_context;
struct draw_context;
struct draw_stage;
struct draw_vertex_shader;
+struct draw_geometry_shader;
struct tgsi_sampler;
@@ -85,11 +86,11 @@ draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe
int
-draw_find_vs_output(const struct draw_context *draw,
- uint semantic_name, uint semantic_index);
+draw_find_shader_output(const struct draw_context *draw,
+ uint semantic_name, uint semantic_index);
uint
-draw_num_vs_outputs(const struct draw_context *draw);
+draw_num_shader_outputs(const struct draw_context *draw);
void
@@ -112,6 +113,17 @@ void draw_delete_vertex_shader(struct draw_context *draw,
struct draw_vertex_shader *dvs);
+/*
+ * Geometry shader functions
+ */
+struct draw_geometry_shader *
+draw_create_geometry_shader(struct draw_context *draw,
+ const struct pipe_shader_state *shader);
+void draw_bind_geometry_shader(struct draw_context *draw,
+ struct draw_geometry_shader *dvs);
+void draw_delete_geometry_shader(struct draw_context *draw,
+ struct draw_geometry_shader *dvs);
+
/*
* Vertex data functions
@@ -140,12 +152,10 @@ void draw_set_mapped_vertex_buffer(struct draw_context *draw,
unsigned attr, const void *buffer);
void draw_set_mapped_constant_buffer(struct draw_context *draw,
+ unsigned shader_type,
const void *buffer,
unsigned size );
-void draw_set_edgeflags( struct draw_context *draw,
- const unsigned *edgeflag );
-
/***********************************************************************
* draw_prim.c
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
new file mode 100644
index 0000000000..5db2e75542
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -0,0 +1,338 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMWare Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "draw_gs.h"
+
+#include "draw_private.h"
+#include "draw_context.h"
+
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_exec.h"
+
+#include "pipe/p_shader_tokens.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#define MAX_PRIM_VERTICES 6
+/* fixme: move it from here */
+#define MAX_PRIMITIVES 64
+
+boolean
+draw_gs_init( struct draw_context *draw )
+{
+ draw->gs.machine = tgsi_exec_machine_create();
+ if (!draw->gs.machine)
+ return FALSE;
+
+ draw->gs.machine->Primitives = align_malloc(
+ MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector), 16);
+ if (!draw->gs.machine->Primitives)
+ return FALSE;
+ memset(draw->gs.machine->Primitives, 0,
+ MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector));
+
+ return TRUE;
+}
+
+
+void draw_gs_set_constants( struct draw_context *draw,
+ const float (*constants)[4],
+ unsigned size )
+{
+}
+
+
+struct draw_geometry_shader *
+draw_create_geometry_shader(struct draw_context *draw,
+ const struct pipe_shader_state *state)
+{
+ struct draw_geometry_shader *gs;
+ int i;
+
+ gs = CALLOC_STRUCT(draw_geometry_shader);
+
+ if (!gs)
+ return NULL;
+
+ gs->state = *state;
+ gs->state.tokens = tgsi_dup_tokens(state->tokens);
+ if (!gs->state.tokens) {
+ FREE(gs);
+ return NULL;
+ }
+
+ tgsi_scan_shader(state->tokens, &gs->info);
+
+ /* setup the defaults */
+ gs->input_primitive = PIPE_PRIM_TRIANGLES;
+ gs->output_primitive = PIPE_PRIM_TRIANGLE_STRIP;
+ gs->max_output_vertices = 32;
+
+ for (i = 0; i < gs->info.num_properties; ++i) {
+ if (gs->info.properties[i].name ==
+ TGSI_PROPERTY_GS_INPUT_PRIM)
+ gs->input_primitive = gs->info.properties[i].data[0];
+ else if (gs->info.properties[i].name ==
+ TGSI_PROPERTY_GS_OUTPUT_PRIM)
+ gs->output_primitive = gs->info.properties[i].data[0];
+ else if (gs->info.properties[i].name ==
+ TGSI_PROPERTY_GS_MAX_VERTICES)
+ gs->max_output_vertices = gs->info.properties[i].data[0];
+ }
+
+ gs->machine = draw->gs.machine;
+
+ if (gs)
+ {
+ uint i;
+ for (i = 0; i < gs->info.num_outputs; i++) {
+ if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
+ gs->info.output_semantic_index[i] == 0)
+ gs->position_output = i;
+ }
+ }
+
+ return gs;
+}
+
+void draw_bind_geometry_shader(struct draw_context *draw,
+ struct draw_geometry_shader *dgs)
+{
+ draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
+
+ if (dgs) {
+ draw->gs.geometry_shader = dgs;
+ draw->gs.num_gs_outputs = dgs->info.num_outputs;
+ draw->gs.position_output = dgs->position_output;
+ draw_geometry_shader_prepare(dgs, draw);
+ }
+ else {
+ draw->gs.geometry_shader = NULL;
+ draw->gs.num_gs_outputs = 0;
+ }
+}
+
+void draw_delete_geometry_shader(struct draw_context *draw,
+ struct draw_geometry_shader *dgs)
+{
+ FREE(dgs);
+}
+
+static INLINE int num_vertices_for_prim(int prim)
+{
+ switch(prim) {
+ case PIPE_PRIM_POINTS:
+ return 1;
+ case PIPE_PRIM_LINES:
+ return 2;
+ case PIPE_PRIM_LINE_LOOP:
+ return 2;
+ case PIPE_PRIM_LINE_STRIP:
+ return 2;
+ case PIPE_PRIM_TRIANGLES:
+ return 3;
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ return 3;
+ case PIPE_PRIM_TRIANGLE_FAN:
+ return 3;
+ case PIPE_PRIM_LINES_ADJACENCY:
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ return 4;
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ return 6;
+ default:
+ assert(!"Bad geometry shader input");
+ return 0;
+ }
+}
+
+static void draw_fetch_geometry_input(struct draw_geometry_shader *shader,
+ int start_primitive,
+ int num_primitives,
+ const float (*input_ptr)[4],
+ unsigned input_vertex_stride,
+ unsigned inputs_from_vs)
+{
+ struct tgsi_exec_machine *machine = shader->machine;
+ unsigned slot, vs_slot, k, j;
+ unsigned num_vertices = num_vertices_for_prim(shader->input_primitive);
+ int idx = 0;
+
+ for (slot = 0, vs_slot = 0; slot < shader->info.num_inputs; slot++) {
+ /*debug_printf("Slot = %d (semantic = %d)\n", slot,
+ shader->info.input_semantic_name[slot]);*/
+ if (shader->info.input_semantic_name[slot] ==
+ TGSI_SEMANTIC_PRIMID) {
+ for (j = 0; j < num_primitives; ++j) {
+ machine->Inputs[idx].xyzw[0].f[j] = (float)start_primitive + j;
+ machine->Inputs[idx].xyzw[1].f[j] = (float)start_primitive + j;
+ machine->Inputs[idx].xyzw[2].f[j] = (float)start_primitive + j;
+ machine->Inputs[idx].xyzw[3].f[j] = (float)start_primitive + j;
+ }
+ ++idx;
+ } else {
+ for (j = 0; j < num_primitives; ++j) {
+ int vidx = idx;
+ const float (*prim_ptr)[4];
+ /*debug_printf(" %d) Prim (num_verts = %d)\n", start_primitive + j,
+ num_vertices);*/
+ prim_ptr = (const float (*)[4])(
+ (const char *)input_ptr +
+ (j * num_vertices * input_vertex_stride));
+
+ for (k = 0; k < num_vertices; ++k, ++vidx) {
+ const float (*input)[4];
+ input = (const float (*)[4])(
+ (const char *)prim_ptr + (k * input_vertex_stride));
+ vidx = k * TGSI_EXEC_MAX_INPUT_ATTRIBS + slot;
+ /*debug_printf("\t%d)(%d) Input vert:\n", vidx, k);*/
+#if 1
+ assert(!util_is_inf_or_nan(input[vs_slot][0]));
+ assert(!util_is_inf_or_nan(input[vs_slot][1]));
+ assert(!util_is_inf_or_nan(input[vs_slot][2]));
+ assert(!util_is_inf_or_nan(input[vs_slot][3]));
+#endif
+ machine->Inputs[vidx].xyzw[0].f[j] = input[vs_slot][0];
+ machine->Inputs[vidx].xyzw[1].f[j] = input[vs_slot][1];
+ machine->Inputs[vidx].xyzw[2].f[j] = input[vs_slot][2];
+ machine->Inputs[vidx].xyzw[3].f[j] = input[vs_slot][3];
+#if 0
+ debug_printf("\t\t%d %f %f %f %f\n", slot,
+ machine->Inputs[vidx].xyzw[0].f[j],
+ machine->Inputs[vidx].xyzw[1].f[j],
+ machine->Inputs[vidx].xyzw[2].f[j],
+ machine->Inputs[vidx].xyzw[3].f[j]);
+#endif
+ }
+ }
+ ++vs_slot;
+ idx += num_vertices;
+ }
+ }
+}
+
+static INLINE void
+draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
+ int num_primitives,
+ float (*output)[4],
+ unsigned vertex_size)
+{
+ struct tgsi_exec_machine *machine = shader->machine;
+ unsigned prim_idx, j, slot;
+
+ /* Unswizzle all output results.
+ */
+ /* FIXME: handle all the primitives produced by the gs, not just
+ * the first one
+ unsigned prim_count =
+ mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0];*/
+ for (prim_idx = 0; prim_idx < num_primitives; ++prim_idx) {
+ unsigned num_verts_per_prim = machine->Primitives[0];
+ for (j = 0; j < num_verts_per_prim; j++) {
+ int idx = (prim_idx * num_verts_per_prim + j) *
+ shader->info.num_outputs;
+#ifdef DEBUG_OUTPUTS
+ debug_printf("%d) Output vert:\n", idx);
+#endif
+ for (slot = 0; slot < shader->info.num_outputs; slot++) {
+ output[slot][0] = machine->Outputs[idx + slot].xyzw[0].f[prim_idx];
+ output[slot][1] = machine->Outputs[idx + slot].xyzw[1].f[prim_idx];
+ output[slot][2] = machine->Outputs[idx + slot].xyzw[2].f[prim_idx];
+ output[slot][3] = machine->Outputs[idx + slot].xyzw[3].f[prim_idx];
+#ifdef DEBUG_OUTPUTS
+ debug_printf("\t%d: %f %f %f %f\n", slot,
+ output[slot][0],
+ output[slot][1],
+ output[slot][2],
+ output[slot][3]);
+#endif
+ debug_assert(!util_is_inf_or_nan(output[slot][0]));
+ }
+ output = (float (*)[4])((char *)output + vertex_size);
+ }
+ }
+}
+
+void draw_geometry_shader_run(struct draw_geometry_shader *shader,
+ const float (*input)[4],
+ float (*output)[4],
+ const float (*constants)[4],
+ unsigned count,
+ unsigned input_stride,
+ unsigned vertex_size)
+{
+ struct tgsi_exec_machine *machine = shader->machine;
+ unsigned int i;
+ unsigned num_vertices = num_vertices_for_prim(shader->input_primitive);
+ unsigned num_primitives = count/num_vertices;
+ unsigned inputs_from_vs = 0;
+
+ machine->Consts = constants;
+
+ for (i = 0; i < shader->info.num_inputs; ++i) {
+ if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID)
+ ++inputs_from_vs;
+ }
+
+ for (i = 0; i < num_primitives; ++i) {
+ unsigned int max_primitives = 1;
+
+ draw_fetch_geometry_input(shader, i, max_primitives, input,
+ input_stride, inputs_from_vs);
+
+ tgsi_set_exec_mask(machine,
+ 1,
+ max_primitives > 1,
+ max_primitives > 2,
+ max_primitives > 3);
+
+ /* run interpreter */
+ tgsi_exec_machine_run(machine);
+
+ draw_geometry_fetch_outputs(shader, max_primitives,
+ output, vertex_size);
+ }
+}
+
+void draw_geometry_shader_delete(struct draw_geometry_shader *shader)
+{
+ FREE((void*) shader->state.tokens);
+ FREE(shader);
+}
+
+void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
+ struct draw_context *draw)
+{
+ if (shader->machine->Tokens != shader->state.tokens) {
+ tgsi_exec_machine_bind_shader(shader->machine,
+ shader->state.tokens,
+ draw->gs.num_samplers,
+ draw->gs.samplers);
+ }
+}
diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h
new file mode 100644
index 0000000000..d6a97d9c4e
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_gs.h
@@ -0,0 +1,76 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMWare Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef DRAW_GS_H
+#define DRAW_GS_H
+
+#include "draw_context.h"
+#include "draw_private.h"
+
+
+#define MAX_TGSI_PRIMITIVES 4
+
+struct draw_context;
+
+/**
+ * Private version of the compiled geometry shader
+ */
+struct draw_geometry_shader {
+ struct draw_context *draw;
+
+ struct tgsi_exec_machine *machine;
+
+ /* This member will disappear shortly:*/
+ struct pipe_shader_state state;
+
+ struct tgsi_shader_info info;
+ unsigned position_output;
+
+ unsigned max_output_vertices;
+ unsigned input_primitive;
+ unsigned output_primitive;
+
+ /* Extracted from shader:
+ */
+ const float (*immediates)[4];
+};
+
+void draw_geometry_shader_run(struct draw_geometry_shader *shader,
+ const float (*input)[4],
+ float (*output)[4],
+ const float (*constants)[4],
+ unsigned count,
+ unsigned input_stride,
+ unsigned output_stride);
+
+void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
+ struct draw_context *draw);
+
+void draw_geometry_shader_delete(struct draw_geometry_shader *shader);
+
+
+#endif
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 9f956715a2..4585dcdb48 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -35,6 +35,8 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -139,29 +141,29 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
if (decl->Declaration.File == TGSI_FILE_OUTPUT &&
- decl->Semantic.SemanticName == TGSI_SEMANTIC_COLOR &&
- decl->Semantic.SemanticIndex == 0) {
- aactx->colorOutput = decl->DeclarationRange.First;
+ decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+ decl->Semantic.Index == 0) {
+ aactx->colorOutput = decl->Range.First;
}
else if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
uint i;
- for (i = decl->DeclarationRange.First;
- i <= decl->DeclarationRange.Last; i++) {
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
aactx->samplersUsed |= 1 << i;
}
}
else if (decl->Declaration.File == TGSI_FILE_INPUT) {
- if ((int) decl->DeclarationRange.Last > aactx->maxInput)
- aactx->maxInput = decl->DeclarationRange.Last;
- if (decl->Semantic.SemanticName == TGSI_SEMANTIC_GENERIC &&
- (int) decl->Semantic.SemanticIndex > aactx->maxGeneric) {
- aactx->maxGeneric = decl->Semantic.SemanticIndex;
+ if ((int) decl->Range.Last > aactx->maxInput)
+ aactx->maxInput = decl->Range.Last;
+ if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC &&
+ (int) decl->Semantic.Index > aactx->maxGeneric) {
+ aactx->maxGeneric = decl->Semantic.Index;
}
}
else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
uint i;
- for (i = decl->DeclarationRange.First;
- i <= decl->DeclarationRange.Last; i++) {
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
aactx->tempsUsed |= (1 << i);
}
}
@@ -228,30 +230,30 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
/* XXX this could be linear... */
decl.Declaration.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = TGSI_SEMANTIC_GENERIC;
- decl.Semantic.SemanticIndex = aactx->maxGeneric + 1;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = aactx->maxInput + 1;
+ decl.Semantic.Name = TGSI_SEMANTIC_GENERIC;
+ decl.Semantic.Index = aactx->maxGeneric + 1;
+ decl.Range.First =
+ decl.Range.Last = aactx->maxInput + 1;
ctx->emit_declaration(ctx, &decl);
/* declare new sampler */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = aactx->freeSampler;
+ decl.Range.First =
+ decl.Range.Last = aactx->freeSampler;
ctx->emit_declaration(ctx, &decl);
/* declare new temp regs */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = aactx->texTemp;
+ decl.Range.First =
+ decl.Range.Last = aactx->texTemp;
ctx->emit_declaration(ctx, &decl);
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = aactx->colorTemp;
+ decl.Range.First =
+ decl.Range.Last = aactx->colorTemp;
ctx->emit_declaration(ctx, &decl);
aactx->firstInstruction = FALSE;
@@ -265,14 +267,15 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_TEX;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = aactx->texTemp;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = aactx->texTemp;
newInst.Instruction.NumSrcRegs = 2;
- newInst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->maxInput + 1;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
- newInst.FullSrcRegisters[1].SrcRegister.Index = aactx->freeSampler;
+ newInst.Instruction.Texture = TRUE;
+ newInst.Texture.Texture = TGSI_TEXTURE_2D;
+ newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[0].Register.Index = aactx->maxInput + 1;
+ newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
+ newInst.Src[1].Register.Index = aactx->freeSampler;
ctx->emit_instruction(ctx, &newInst);
@@ -280,26 +283,26 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MOV;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
- newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_XYZ;
+ newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+ newInst.Dst[0].Register.Index = aactx->colorOutput;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZ;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = aactx->colorTemp;
ctx->emit_instruction(ctx, &newInst);
/* MUL alpha */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
- newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+ newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+ newInst.Dst[0].Register.Index = aactx->colorOutput;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[1].SrcRegister.Index = aactx->texTemp;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = aactx->colorTemp;
+ newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[1].Register.Index = aactx->texTemp;
ctx->emit_instruction(ctx, &newInst);
/* END */
@@ -316,11 +319,11 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
uint i;
for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
- if (dst->DstRegister.File == TGSI_FILE_OUTPUT &&
- dst->DstRegister.Index == aactx->colorOutput) {
- dst->DstRegister.File = TGSI_FILE_TEMPORARY;
- dst->DstRegister.Index = aactx->colorTemp;
+ struct tgsi_full_dst_register *dst = &inst->Dst[i];
+ if (dst->Register.File == TGSI_FILE_OUTPUT &&
+ dst->Register.Index == aactx->colorOutput) {
+ dst->Register.File = TGSI_FILE_TEMPORARY;
+ dst->Register.Index = aactx->colorTemp;
}
}
@@ -398,10 +401,9 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.target = PIPE_TEXTURE_2D;
texTemp.format = PIPE_FORMAT_A8_UNORM; /* XXX verify supported by driver! */
texTemp.last_level = MAX_TEXTURE_LEVEL;
- texTemp.width[0] = 1 << MAX_TEXTURE_LEVEL;
- texTemp.height[0] = 1 << MAX_TEXTURE_LEVEL;
- texTemp.depth[0] = 1;
- pf_get_block(texTemp.format, &texTemp.block);
+ texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
+ texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
+ texTemp.depth0 = 1;
aaline->texture = screen->texture_create(screen, &texTemp);
if (!aaline->texture)
@@ -413,11 +415,11 @@ aaline_create_texture(struct aaline_stage *aaline)
*/
for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
struct pipe_transfer *transfer;
- const uint size = aaline->texture->width[level];
+ const uint size = u_minify(aaline->texture->width0, level);
ubyte *data;
uint i, j;
- assert(aaline->texture->width[level] == aaline->texture->height[level]);
+ assert(aaline->texture->width0 == aaline->texture->height0);
/* This texture is new, no need to flush.
*/
@@ -658,13 +660,13 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
}
/* update vertex attrib info */
- aaline->tex_slot = draw->vs.num_vs_outputs;
- aaline->pos_slot = draw->vs.position_output;
+ aaline->tex_slot = draw_current_shader_outputs(draw);
+ aaline->pos_slot = draw_current_shader_position_output(draw);;
/* advertise the extra post-transformed vertex attribute */
- draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_vp_outputs.semantic_index = aaline->fs->generic_attrib;
- draw->extra_vp_outputs.slot = aaline->tex_slot;
+ draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+ draw->extra_shader_outputs.semantic_index = aaline->fs->generic_attrib;
+ draw->extra_shader_outputs.slot = aaline->tex_slot;
/* how many samplers? */
/* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
@@ -705,7 +707,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
aaline->state.texture);
draw->suspend_flushing = FALSE;
- draw->extra_vp_outputs.slot = 0;
+ draw->extra_shader_outputs.slot = 0;
}
@@ -896,16 +898,16 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
aaline->driver_bind_fs_state = pipe->bind_fs_state;
aaline->driver_delete_fs_state = pipe->delete_fs_state;
- aaline->driver_bind_sampler_states = pipe->bind_sampler_states;
- aaline->driver_set_sampler_textures = pipe->set_sampler_textures;
+ aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
+ aaline->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
/* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state;
pipe->bind_fs_state = aaline_bind_fs_state;
pipe->delete_fs_state = aaline_delete_fs_state;
- pipe->bind_sampler_states = aaline_bind_sampler_states;
- pipe->set_sampler_textures = aaline_set_sampler_textures;
+ pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
+ pipe->set_fragment_sampler_textures = aaline_set_sampler_textures;
/* Install once everything is known to be OK:
*/
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index ae1712fe12..d86717e518 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -131,22 +131,22 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
if (decl->Declaration.File == TGSI_FILE_OUTPUT &&
- decl->Semantic.SemanticName == TGSI_SEMANTIC_COLOR &&
- decl->Semantic.SemanticIndex == 0) {
- aactx->colorOutput = decl->DeclarationRange.First;
+ decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+ decl->Semantic.Index == 0) {
+ aactx->colorOutput = decl->Range.First;
}
else if (decl->Declaration.File == TGSI_FILE_INPUT) {
- if ((int) decl->DeclarationRange.Last > aactx->maxInput)
- aactx->maxInput = decl->DeclarationRange.Last;
- if (decl->Semantic.SemanticName == TGSI_SEMANTIC_GENERIC &&
- (int) decl->Semantic.SemanticIndex > aactx->maxGeneric) {
- aactx->maxGeneric = decl->Semantic.SemanticIndex;
+ if ((int) decl->Range.Last > aactx->maxInput)
+ aactx->maxInput = decl->Range.Last;
+ if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC &&
+ (int) decl->Semantic.Index > aactx->maxGeneric) {
+ aactx->maxGeneric = decl->Semantic.Index;
}
}
else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
uint i;
- for (i = decl->DeclarationRange.First;
- i <= decl->DeclarationRange.Last; i++) {
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
aactx->tempsUsed |= (1 << i);
}
}
@@ -198,23 +198,23 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
/* XXX this could be linear... */
decl.Declaration.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = TGSI_SEMANTIC_GENERIC;
- decl.Semantic.SemanticIndex = aactx->maxGeneric + 1;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = texInput;
+ decl.Semantic.Name = TGSI_SEMANTIC_GENERIC;
+ decl.Semantic.Index = aactx->maxGeneric + 1;
+ decl.Range.First =
+ decl.Range.Last = texInput;
ctx->emit_declaration(ctx, &decl);
/* declare new temp regs */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = tmp0;
+ decl.Range.First =
+ decl.Range.Last = tmp0;
ctx->emit_declaration(ctx, &decl);
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = aactx->colorTemp;
+ decl.Range.First =
+ decl.Range.Last = aactx->colorTemp;
ctx->emit_declaration(ctx, &decl);
aactx->firstInstruction = FALSE;
@@ -234,30 +234,30 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_XY;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XY;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[0].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
+ newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[0].Register.Index = texInput;
+ newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[1].Register.Index = texInput;
ctx->emit_instruction(ctx, &newInst);
/* ADD t0.x, t0.x, t0.y; # x^2 + y^2 */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_ADD;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[1].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleX = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+ newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[1].Register.Index = tmp0;
+ newInst.Src[1].Register.SwizzleX = TGSI_SWIZZLE_Y;
ctx->emit_instruction(ctx, &newInst);
#if NORMALIZE /* OPTIONAL normalization of length */
@@ -265,24 +265,24 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_RSQ;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
ctx->emit_instruction(ctx, &newInst);
/* RCP t0.x, t0.x; */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_RCP;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
ctx->emit_instruction(ctx, &newInst);
#endif
@@ -290,16 +290,16 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_SGT;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Y;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Y;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+ newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[1].Register.Index = texInput;
+ newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_W;
ctx->emit_instruction(ctx, &newInst);
/* KIL -tmp0.yyyy; # if -tmp0.y < 0, KILL */
@@ -307,13 +307,13 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst.Instruction.Opcode = TGSI_OPCODE_KIL;
newInst.Instruction.NumDstRegs = 0;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.Negate = 1;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.Negate = 1;
ctx->emit_instruction(ctx, &newInst);
@@ -323,77 +323,77 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_SUB;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Z;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Z;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[0].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z;
+ newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[0].Register.Index = texInput;
+ newInst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_W;
+ newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[1].Register.Index = texInput;
+ newInst.Src[1].Register.SwizzleZ = TGSI_SWIZZLE_Z;
ctx->emit_instruction(ctx, &newInst);
/* RCP t0.z, t0.z; # t0.z = 1 / m */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_RCP;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Z;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Z;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_Z;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_Z;
ctx->emit_instruction(ctx, &newInst);
/* SUB t0.y, 1, t0.x; # d = 1 - d */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_SUB;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Y;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Y;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[0].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[1].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
+ newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[0].Register.Index = texInput;
+ newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_W;
+ newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[1].Register.Index = tmp0;
+ newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_X;
ctx->emit_instruction(ctx, &newInst);
/* MUL t0.w, t0.y, t0.z; # coverage = d * m */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[1].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleW = TGSI_SWIZZLE_Z;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_Y;
+ newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[1].Register.Index = tmp0;
+ newInst.Src[1].Register.SwizzleW = TGSI_SWIZZLE_Z;
ctx->emit_instruction(ctx, &newInst);
/* SLE t0.y, t0.x, tex.z; # bool b = distance <= k */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_SLE;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_Y;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_Y;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_Z;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+ newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[1].Register.Index = texInput;
+ newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_Z;
ctx->emit_instruction(ctx, &newInst);
/* CMP t0.w, -t0.y, tex.w, t0.w;
@@ -405,29 +405,29 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_CMP;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = tmp0;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = tmp0;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
newInst.Instruction.NumSrcRegs = 3;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_Y;
- newInst.FullSrcRegisters[0].SrcRegister.Negate = 1;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[1].SrcRegister.Index = texInput;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleX = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleZ = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[1].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[2].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[2].SrcRegister.Index = tmp0;
- newInst.FullSrcRegisters[2].SrcRegister.SwizzleX = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[2].SrcRegister.SwizzleY = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[2].SrcRegister.SwizzleZ = TGSI_SWIZZLE_W;
- newInst.FullSrcRegisters[2].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = tmp0;
+ newInst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_Y;
+ newInst.Src[0].Register.Negate = 1;
+ newInst.Src[1].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[1].Register.Index = texInput;
+ newInst.Src[1].Register.SwizzleX = TGSI_SWIZZLE_W;
+ newInst.Src[1].Register.SwizzleY = TGSI_SWIZZLE_W;
+ newInst.Src[1].Register.SwizzleZ = TGSI_SWIZZLE_W;
+ newInst.Src[1].Register.SwizzleW = TGSI_SWIZZLE_W;
+ newInst.Src[2].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[2].Register.Index = tmp0;
+ newInst.Src[2].Register.SwizzleX = TGSI_SWIZZLE_W;
+ newInst.Src[2].Register.SwizzleY = TGSI_SWIZZLE_W;
+ newInst.Src[2].Register.SwizzleZ = TGSI_SWIZZLE_W;
+ newInst.Src[2].Register.SwizzleW = TGSI_SWIZZLE_W;
ctx->emit_instruction(ctx, &newInst);
}
@@ -439,26 +439,26 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MOV;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
- newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_XYZ;
+ newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+ newInst.Dst[0].Register.Index = aactx->colorOutput;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZ;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = aactx->colorTemp;
ctx->emit_instruction(ctx, &newInst);
/* MUL result.color.w, colorTemp, tmp0.w; */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
- newInst.FullDstRegisters[0].DstRegister.Index = aactx->colorOutput;
- newInst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_W;
+ newInst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
+ newInst.Dst[0].Register.Index = aactx->colorOutput;
+ newInst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_W;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = aactx->colorTemp;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[1].SrcRegister.Index = aactx->tmp0;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = aactx->colorTemp;
+ newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[1].Register.Index = aactx->tmp0;
ctx->emit_instruction(ctx, &newInst);
}
else {
@@ -468,11 +468,11 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
uint i;
for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
- if (dst->DstRegister.File == TGSI_FILE_OUTPUT &&
- dst->DstRegister.Index == aactx->colorOutput) {
- dst->DstRegister.File = TGSI_FILE_TEMPORARY;
- dst->DstRegister.Index = aactx->colorTemp;
+ struct tgsi_full_dst_register *dst = &inst->Dst[i];
+ if (dst->Register.File == TGSI_FILE_OUTPUT &&
+ dst->Register.Index == aactx->colorOutput) {
+ dst->Register.File = TGSI_FILE_TEMPORARY;
+ dst->Register.Index = aactx->colorTemp;
}
}
}
@@ -687,14 +687,14 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
bind_aapoint_fragment_shader(aapoint);
/* update vertex attrib info */
- aapoint->tex_slot = draw->vs.num_vs_outputs;
+ aapoint->tex_slot = draw_current_shader_outputs(draw);
assert(aapoint->tex_slot > 0); /* output[0] is vertex pos */
- aapoint->pos_slot = draw->vs.position_output;
+ aapoint->pos_slot = draw_current_shader_position_output(draw);
- draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_vp_outputs.semantic_index = aapoint->fs->generic_attrib;
- draw->extra_vp_outputs.slot = aapoint->tex_slot;
+ draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+ draw->extra_shader_outputs.semantic_index = aapoint->fs->generic_attrib;
+ draw->extra_shader_outputs.slot = aapoint->tex_slot;
/* find psize slot in post-transform vertex */
aapoint->psize_slot = -1;
@@ -731,7 +731,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
aapoint->driver_bind_fs_state(pipe, aapoint->fs->driver_fs);
draw->suspend_flushing = FALSE;
- draw->extra_vp_outputs.slot = 0;
+ draw->extra_shader_outputs.slot = 0;
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 0670268a19..205cda5eab 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -114,8 +114,8 @@ static void interp( const struct clipper *clip,
const struct vertex_header *out,
const struct vertex_header *in )
{
- const unsigned nr_attrs = clip->stage.draw->vs.num_vs_outputs;
- const unsigned pos_attr = clip->stage.draw->vs.position_output;
+ const unsigned nr_attrs = draw_current_shader_outputs(clip->stage.draw);
+ const unsigned pos_attr = draw_current_shader_position_output(clip->stage.draw);
unsigned j;
/* Vertex header.
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index 0a70483858..11b39db599 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -55,7 +55,7 @@ static INLINE struct cull_stage *cull_stage( struct draw_stage *stage )
static void cull_tri( struct draw_stage *stage,
struct prim_header *header )
{
- const unsigned pos = stage->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(stage->draw);
/* Window coords: */
const float *v0 = header->v[0]->data[pos];
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 40798a5d6e..e829492423 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -63,7 +63,7 @@ static INLINE struct offset_stage *offset_stage( struct draw_stage *stage )
static void do_offset_tri( struct draw_stage *stage,
struct prim_header *header )
{
- const unsigned pos = stage->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(stage->draw);
struct offset_stage *offset = offset_stage(stage);
float inv_det = 1.0f / header->det;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 283502cdf3..0cc2b71864 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -38,6 +38,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -133,20 +134,20 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
uint i;
- for (i = decl->DeclarationRange.First;
- i <= decl->DeclarationRange.Last; i++) {
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
pctx->samplersUsed |= 1 << i;
}
}
else if (decl->Declaration.File == TGSI_FILE_INPUT) {
- pctx->maxInput = MAX2(pctx->maxInput, (int) decl->DeclarationRange.Last);
- if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION)
- pctx->wincoordInput = (int) decl->DeclarationRange.First;
+ pctx->maxInput = MAX2(pctx->maxInput, (int) decl->Range.Last);
+ if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION)
+ pctx->wincoordInput = (int) decl->Range.First;
}
else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
uint i;
- for (i = decl->DeclarationRange.First;
- i <= decl->DeclarationRange.Last; i++) {
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
pctx->tempsUsed |= (1 << i);
}
}
@@ -226,25 +227,25 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Interpolate = TGSI_INTERPOLATE_LINEAR; /* XXX? */
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = TGSI_SEMANTIC_POSITION;
- decl.Semantic.SemanticIndex = 0;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = wincoordInput;
+ decl.Semantic.Name = TGSI_SEMANTIC_POSITION;
+ decl.Semantic.Index = 0;
+ decl.Range.First =
+ decl.Range.Last = wincoordInput;
ctx->emit_declaration(ctx, &decl);
}
/* declare new sampler */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = pctx->freeSampler;
+ decl.Range.First =
+ decl.Range.Last = pctx->freeSampler;
ctx->emit_declaration(ctx, &decl);
/* declare new temp regs */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.DeclarationRange.First =
- decl.DeclarationRange.Last = pctx->texTemp;
+ decl.Range.First =
+ decl.Range.Last = pctx->texTemp;
ctx->emit_declaration(ctx, &decl);
/* emit immediate = {1/32, 1/32, 1, 1}
@@ -280,27 +281,28 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = pctx->texTemp;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = pctx->texTemp;
newInst.Instruction.NumSrcRegs = 2;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- newInst.FullSrcRegisters[0].SrcRegister.Index = wincoordInput;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_IMMEDIATE;
- newInst.FullSrcRegisters[1].SrcRegister.Index = pctx->numImmed;
+ newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[0].Register.Index = wincoordInput;
+ newInst.Src[1].Register.File = TGSI_FILE_IMMEDIATE;
+ newInst.Src[1].Register.Index = pctx->numImmed;
ctx->emit_instruction(ctx, &newInst);
/* TEX texTemp, texTemp, sampler; */
newInst = tgsi_default_full_instruction();
newInst.Instruction.Opcode = TGSI_OPCODE_TEX;
newInst.Instruction.NumDstRegs = 1;
- newInst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullDstRegisters[0].DstRegister.Index = pctx->texTemp;
+ newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Dst[0].Register.Index = pctx->texTemp;
newInst.Instruction.NumSrcRegs = 2;
- newInst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = pctx->texTemp;
- newInst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
- newInst.FullSrcRegisters[1].SrcRegister.Index = pctx->freeSampler;
+ newInst.Instruction.Texture = TRUE;
+ newInst.Texture.Texture = TGSI_TEXTURE_2D;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = pctx->texTemp;
+ newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
+ newInst.Src[1].Register.Index = pctx->freeSampler;
ctx->emit_instruction(ctx, &newInst);
/* KIL -texTemp; # if -texTemp < 0, KILL fragment */
@@ -308,9 +310,9 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
newInst.Instruction.Opcode = TGSI_OPCODE_KIL;
newInst.Instruction.NumDstRegs = 0;
newInst.Instruction.NumSrcRegs = 1;
- newInst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- newInst.FullSrcRegisters[0].SrcRegister.Index = pctx->texTemp;
- newInst.FullSrcRegisters[0].SrcRegister.Negate = 1;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = pctx->texTemp;
+ newInst.Src[0].Register.Negate = 1;
ctx->emit_instruction(ctx, &newInst);
}
@@ -427,10 +429,9 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.target = PIPE_TEXTURE_2D;
texTemp.format = PIPE_FORMAT_A8_UNORM; /* XXX verify supported by driver! */
texTemp.last_level = 0;
- texTemp.width[0] = 32;
- texTemp.height[0] = 32;
- texTemp.depth[0] = 1;
- pf_get_block(texTemp.format, &texTemp.block);
+ texTemp.width0 = 32;
+ texTemp.height0 = 32;
+ texTemp.depth0 = 1;
pstip->texture = screen->texture_create(screen, &texTemp);
if (pstip->texture == NULL)
@@ -754,8 +755,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
pstip->driver_bind_fs_state = pipe->bind_fs_state;
pstip->driver_delete_fs_state = pipe->delete_fs_state;
- pstip->driver_bind_sampler_states = pipe->bind_sampler_states;
- pstip->driver_set_sampler_textures = pipe->set_sampler_textures;
+ pstip->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
+ pstip->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple;
/* override the driver's functions */
@@ -763,8 +764,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
pipe->bind_fs_state = pstip_bind_fs_state;
pipe->delete_fs_state = pstip_delete_fs_state;
- pipe->bind_sampler_states = pstip_bind_sampler_states;
- pipe->set_sampler_textures = pstip_set_sampler_textures;
+ pipe->bind_fragment_sampler_states = pstip_bind_sampler_states;
+ pipe->set_fragment_sampler_textures = pstip_set_sampler_textures;
pipe->set_polygon_stipple = pstip_set_polygon_stipple;
return TRUE;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index 6e921bac27..70fbab9ea7 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -73,7 +73,8 @@ screen_interp( struct draw_context *draw,
const struct vertex_header *v1 )
{
uint attr;
- for (attr = 0; attr < draw->vs.num_vs_outputs; attr++) {
+ int num_outputs = draw_current_shader_outputs(draw);
+ for (attr = 0; attr < num_outputs; attr++) {
const float *val0 = v0->data[attr];
const float *val1 = v1->data[attr];
float *newv = dst->data[attr];
@@ -121,7 +122,7 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
struct stipple_stage *stipple = stipple_stage(stage);
struct vertex_header *v0 = header->v[0];
struct vertex_header *v1 = header->v[1];
- const unsigned pos = stage->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(stage->draw);
const float *pos0 = v0->data[pos];
const float *pos1 = v1->data[pos];
float start = 0;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index f32cbef983..3073c87082 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -59,7 +59,7 @@ static void wideline_line( struct draw_stage *stage,
struct prim_header *header )
{
/*const struct wideline_stage *wide = wideline_stage(stage);*/
- const unsigned pos = stage->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(stage->draw);
const float half_width = 0.5f * stage->draw->rasterizer->line_width;
struct prim_header tri;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index 7d76a7dbf3..8dc50c0ab4 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -112,7 +112,7 @@ static void set_texcoords(const struct widepoint_stage *wide,
if (wide->point_coord_fs_input >= 0) {
/* put gl_PointCoord into the extra vertex slot */
- uint slot = wide->stage.draw->extra_vp_outputs.slot;
+ uint slot = wide->stage.draw->extra_shader_outputs.slot;
v->data[slot][0] = tc[0];
v->data[slot][1] = tc[1];
v->data[slot][2] = 0.0F;
@@ -130,7 +130,7 @@ static void widepoint_point( struct draw_stage *stage,
struct prim_header *header )
{
const struct widepoint_stage *wide = widepoint_stage(stage);
- const unsigned pos = stage->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(stage->draw);
const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
float half_size;
float left_adj, right_adj, bot_adj, top_adj;
@@ -257,13 +257,13 @@ static void widepoint_first_point( struct draw_stage *stage,
wide->point_coord_fs_input = find_pntc_input_attrib(draw);
/* setup extra vp output (point coord implemented as a texcoord) */
- draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_vp_outputs.semantic_index = 0;
- draw->extra_vp_outputs.slot = draw->vs.num_vs_outputs;
+ draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+ draw->extra_shader_outputs.semantic_index = 0;
+ draw->extra_shader_outputs.slot = draw_current_shader_outputs(draw);
}
else {
wide->point_coord_fs_input = -1;
- draw->extra_vp_outputs.slot = 0;
+ draw->extra_shader_outputs.slot = 0;
}
wide->psize_slot = -1;
@@ -287,7 +287,7 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags )
{
stage->point = widepoint_first_point;
stage->next->flush( stage->next, flags );
- stage->draw->extra_vp_outputs.slot = 0;
+ stage->draw->extra_shader_outputs.slot = 0;
}
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 41fcb16a0a..e49041556b 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -142,8 +142,6 @@ struct draw_context
/* user-space vertex data, buffers */
struct {
- const unsigned *edgeflag;
-
/** vertex element/index buffer (ex: glDrawElements) */
const void *elts;
/** bytes per index (0, 1, 2 or 4) */
@@ -154,8 +152,9 @@ struct draw_context
/** vertex arrays */
const void *vbuffer[PIPE_MAX_ATTRIBS];
- /** constant buffer (for vertex shader) */
- const void *constants;
+ /** constant buffer (for vertex/geometry shader) */
+ const void *vs_constants;
+ const void *gs_constants;
} user;
boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */
@@ -184,6 +183,7 @@ struct draw_context
struct draw_vertex_shader *vertex_shader;
uint num_vs_outputs; /**< convenience, from vertex_shader */
uint position_output;
+ uint edgeflag_output;
/** TGSI program interpreter runtime state */
struct tgsi_exec_machine *machine;
@@ -212,6 +212,18 @@ struct draw_context
struct translate_cache *emit_cache;
} vs;
+ struct {
+ struct draw_geometry_shader *geometry_shader;
+ uint num_gs_outputs; /**< convenience, from geometry_shader */
+ uint position_output;
+
+ /** TGSI program interpreter runtime state */
+ struct tgsi_exec_machine *machine;
+
+ uint num_samplers;
+ struct tgsi_sampler **samplers;
+ } gs;
+
/* Clip derived state:
*/
float plane[12][4];
@@ -223,7 +235,7 @@ struct draw_context
uint semantic_name;
uint semantic_index;
int slot;
- } extra_vp_outputs;
+ } extra_shader_outputs;
unsigned reduced_prim;
@@ -246,6 +258,19 @@ void draw_vs_set_constants( struct draw_context *,
+/*******************************************************************************
+ * Geometry shading code:
+ */
+boolean draw_gs_init( struct draw_context *draw );
+void draw_gs_set_constants( struct draw_context *,
+ const float (*constants)[4],
+ unsigned size );
+
+/*******************************************************************************
+ * Common shading code:
+ */
+int draw_current_shader_outputs(struct draw_context *draw);
+int draw_current_shader_position_output(struct draw_context *draw);
/*******************************************************************************
* Vertex processing (was passthrough) code:
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index dbb5ac7182..2801dbafe4 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -192,7 +192,8 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count)
prim, start, count);
for (i = 0; i < count; i++) {
- uint ii, j;
+ uint ii = 0;
+ uint j;
if (draw->pt.user.elts) {
/* indexed arrays */
@@ -313,12 +314,3 @@ draw_arrays(struct draw_context *draw, unsigned prim,
/* drawing done here: */
draw_pt_arrays(draw, prim, start, count);
}
-
-boolean draw_pt_get_edgeflag( struct draw_context *draw,
- unsigned idx )
-{
- if (draw->pt.user.edgeflag)
- return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
- else
- return 1;
-}
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index 7a17a9fb6b..20edf7a227 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -149,11 +149,6 @@ struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw );
struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);
-/* More helpers:
- */
-boolean draw_pt_get_edgeflag( struct draw_context *draw,
- unsigned idx );
-
/*******************************************************************************
* HW vertex emit:
@@ -217,7 +212,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
boolean bypass_clipping,
boolean bypass_viewport,
- boolean opengl );
+ boolean opengl,
+ boolean need_edgeflags );
struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 65c3a34c34..305bfef435 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -42,11 +42,11 @@ struct pt_fetch {
struct translate *translate;
unsigned vertex_size;
- boolean need_edgeflags;
struct translate_cache *cache;
};
+
/* Perform the fetch from API vertex elements & vertex buffers, to a
* contiguous set of float[4] attributes as required for the
* vertex_shader->run_linear() method.
@@ -120,7 +120,12 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
fetch->translate = translate_cache_find(fetch->cache, &key);
{
- static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } };
+ static struct vertex_header vh = { 0,
+ 1,
+ 0,
+ UNDEFINED_VERTEX_ID,
+ { .0f, .0f, .0f, .0f } };
+
fetch->translate->set_buffer(fetch->translate,
draw->pt.nr_vertex_buffers,
&vh,
@@ -128,9 +133,6 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
}
}
- fetch->need_edgeflags = ((draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
- draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) &&
- draw->pt.user.edgeflag);
}
@@ -158,17 +160,6 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
count,
verts );
- /* Edgeflags are hard to fit into a translate program, populate
- * them separately if required. In the setup above they are
- * defaulted to one, so only need this if there is reason to change
- * that default:
- */
- if (fetch->need_edgeflags) {
- for (i = 0; i < count; i++) {
- struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
- vh->edgeflag = draw_pt_get_edgeflag( draw, elts[i] );
- }
- }
}
@@ -193,18 +184,6 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
start,
count,
verts );
-
- /* Edgeflags are hard to fit into a translate program, populate
- * them separately if required. In the setup above they are
- * defaulted to one, so only need this if there is reason to change
- * that default:
- */
- if (fetch->need_edgeflags) {
- for (i = 0; i < count; i++) {
- struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
- vh->edgeflag = draw_pt_get_edgeflag( draw, start + i );
- }
- }
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index df6c265b7e..1a9df4cac5 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -32,6 +32,7 @@
#include "draw/draw_vertex.h"
#include "draw/draw_pt.h"
#include "draw/draw_vs.h"
+#include "draw/draw_gs.h"
#include "translate/translate.h"
@@ -85,9 +86,9 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
draw_pt_post_vs_prepare( fpme->post_vs,
(boolean)draw->bypass_clipping,
(boolean)(draw->identity_viewport ||
- draw->rasterizer->bypass_vs_clip_and_viewport),
- (boolean)draw->rasterizer->gl_rasterization_rules );
-
+ draw->rasterizer->bypass_vs_clip_and_viewport),
+ (boolean)draw->rasterizer->gl_rasterization_rules,
+ (draw->vs.edgeflag_output ? true : false) );
if (!(opt & PT_PIPELINE)) {
draw_pt_emit_prepare( fpme->emit,
@@ -119,7 +120,8 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
{
struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
struct draw_context *draw = fpme->draw;
- struct draw_vertex_shader *shader = draw->vs.vertex_shader;
+ struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
+ struct draw_geometry_shader *gshader = draw->gs.geometry_shader;
unsigned opt = fpme->opt;
unsigned alloc_count = align( fetch_count, 4 );
@@ -147,13 +149,21 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
*/
if (opt & PT_SHADE)
{
- shader->run_linear(shader,
- (const float (*)[4])pipeline_verts->data,
- ( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.constants,
- fetch_count,
- fpme->vertex_size,
- fpme->vertex_size);
+ vshader->run_linear(vshader,
+ (const float (*)[4])pipeline_verts->data,
+ ( float (*)[4])pipeline_verts->data,
+ (const float (*)[4])draw->pt.user.vs_constants,
+ fetch_count,
+ fpme->vertex_size,
+ fpme->vertex_size);
+ if (gshader)
+ draw_geometry_shader_run(gshader,
+ (const float (*)[4])pipeline_verts->data,
+ ( float (*)[4])pipeline_verts->data,
+ (const float (*)[4])draw->pt.user.gs_constants,
+ fetch_count,
+ fpme->vertex_size,
+ fpme->vertex_size);
}
if (draw_pt_post_vs_run( fpme->post_vs,
@@ -196,6 +206,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *shader = draw->vs.vertex_shader;
+ struct draw_geometry_shader *geometry_shader = draw->gs.geometry_shader;
unsigned opt = fpme->opt;
unsigned alloc_count = align( count, 4 );
@@ -226,10 +237,19 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
shader->run_linear(shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.constants,
+ (const float (*)[4])draw->pt.user.vs_constants,
count,
fpme->vertex_size,
fpme->vertex_size);
+
+ if (geometry_shader)
+ draw_geometry_shader_run(geometry_shader,
+ (const float (*)[4])pipeline_verts->data,
+ ( float (*)[4])pipeline_verts->data,
+ (const float (*)[4])draw->pt.user.gs_constants,
+ count,
+ fpme->vertex_size,
+ fpme->vertex_size);
}
if (draw_pt_post_vs_run( fpme->post_vs,
@@ -270,6 +290,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *shader = draw->vs.vertex_shader;
+ struct draw_geometry_shader *geometry_shader = draw->gs.geometry_shader;
unsigned opt = fpme->opt;
unsigned alloc_count = align( count, 4 );
@@ -296,10 +317,19 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
shader->run_linear(shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.constants,
+ (const float (*)[4])draw->pt.user.vs_constants,
count,
fpme->vertex_size,
fpme->vertex_size);
+
+ if (geometry_shader)
+ draw_geometry_shader_run(geometry_shader,
+ (const float (*)[4])pipeline_verts->data,
+ ( float (*)[4])pipeline_verts->data,
+ (const float (*)[4])draw->pt.user.gs_constants,
+ count,
+ fpme->vertex_size,
+ fpme->vertex_size);
}
if (draw_pt_post_vs_run( fpme->post_vs,
diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
index 6c1cb48e8b..55151823a1 100644
--- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c
+++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
@@ -100,7 +100,7 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
struct vertex_header *out = vertices;
const float *scale = pvs->draw->viewport.scale;
const float *trans = pvs->draw->viewport.translate;
- const unsigned pos = pvs->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(pvs->draw);
unsigned clipped = 0;
unsigned j;
@@ -147,6 +147,39 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
+/* As above plus edgeflags
+ */
+static boolean
+post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
+ struct vertex_header *vertices,
+ unsigned count,
+ unsigned stride )
+{
+ unsigned j;
+ boolean needpipe;
+
+ needpipe = post_vs_cliptest_viewport_gl( pvs, vertices, count, stride);
+
+ /* If present, copy edgeflag VS output into vertex header.
+ * Otherwise, leave header as is.
+ */
+ if (pvs->draw->vs.edgeflag_output) {
+ struct vertex_header *out = vertices;
+ int ef = pvs->draw->vs.edgeflag_output;
+
+ for (j = 0; j < count; j++) {
+ const float *edgeflag = out->data[ef];
+ out->edgeflag = !(edgeflag[0] != 1.0f);
+ needpipe |= !out->edgeflag;
+ out = (struct vertex_header *)( (char *)out + stride );
+ }
+ }
+ return needpipe;
+}
+
+
+
+
/* If bypass_clipping is set, skip cliptest and rhw divide.
*/
static boolean post_vs_viewport( struct pt_post_vs *pvs,
@@ -157,7 +190,7 @@ static boolean post_vs_viewport( struct pt_post_vs *pvs,
struct vertex_header *out = vertices;
const float *scale = pvs->draw->viewport.scale;
const float *trans = pvs->draw->viewport.translate;
- const unsigned pos = pvs->draw->vs.position_output;
+ const unsigned pos = draw_current_shader_position_output(pvs->draw);
unsigned j;
if (0) debug_printf("%s\n", __FUNCTION__);
@@ -201,17 +234,29 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
boolean bypass_clipping,
boolean bypass_viewport,
- boolean opengl )
+ boolean opengl,
+ boolean need_edgeflags )
{
- if (bypass_clipping) {
- if (bypass_viewport)
- pvs->run = post_vs_none;
- else
- pvs->run = post_vs_viewport;
+ if (!need_edgeflags) {
+ if (bypass_clipping) {
+ if (bypass_viewport)
+ pvs->run = post_vs_none;
+ else
+ pvs->run = post_vs_viewport;
+ }
+ else {
+ /* if (opengl) */
+ pvs->run = post_vs_cliptest_viewport_gl;
+ }
}
else {
- /* if (opengl) */
- pvs->run = post_vs_cliptest_viewport_gl;
+ /* If we need to copy edgeflags to the vertex header, it should
+ * mean we're running the primitive pipeline. Hence the bypass
+ * flags should be false.
+ */
+ assert(!bypass_clipping);
+ assert(!bypass_viewport);
+ pvs->run = post_vs_cliptest_viewport_gl_edgeflag;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_util.c b/src/gallium/auxiliary/draw/draw_pt_util.c
index b61fa29143..17c3b8cec2 100644
--- a/src/gallium/auxiliary/draw/draw_pt_util.c
+++ b/src/gallium/auxiliary/draw/draw_pt_util.c
@@ -50,16 +50,32 @@ void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr)
*first = 2;
*incr = 1;
break;
+ case PIPE_PRIM_LINES_ADJACENCY:
+ *first = 4;
+ *incr = 2;
+ break;
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ *first = 4;
+ *incr = 1;
+ break;
case PIPE_PRIM_TRIANGLES:
*first = 3;
*incr = 3;
break;
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ *first = 6;
+ *incr = 3;
+ break;
case PIPE_PRIM_TRIANGLE_STRIP:
case PIPE_PRIM_TRIANGLE_FAN:
case PIPE_PRIM_POLYGON:
*first = 3;
*incr = 1;
break;
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ *first = 6;
+ *incr = 1;
+ break;
case PIPE_PRIM_QUADS:
*first = 4;
*incr = 4;
diff --git a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
index 010c7a18a7..f0aec5feba 100644
--- a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
+++ b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
@@ -36,6 +36,10 @@ static void FUNC(struct draw_pt_front_end *frontend,
case PIPE_PRIM_TRIANGLE_STRIP:
case PIPE_PRIM_QUADS:
case PIPE_PRIM_QUAD_STRIP:
+ case PIPE_PRIM_LINES_ADJACENCY:
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
for (j = 0; j < count;) {
unsigned remaining = count - j;
unsigned nr = trim( MIN2(varray->driver_fetch_max, remaining), first, incr );
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index 1a0527be63..757c487454 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -346,7 +346,8 @@ vcache_check_run( struct draw_pt_front_end *frontend,
vcache->fetch_max,
draw_count);
- if (max_index == 0xffffffff ||
+ if (max_index >= DRAW_PIPE_MAX_VERTICES ||
+ fetch_count >= UNDEFINED_VERTEX_ID ||
fetch_count > draw_count) {
if (0) debug_printf("fail\n");
goto fail;
@@ -394,6 +395,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
default:
assert(0);
+ FREE(storage);
return;
}
}
@@ -422,6 +424,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
default:
assert(0);
+ FREE(storage);
return;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 790e89ed82..3553689532 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -101,6 +101,9 @@ draw_create_vertex_shader(struct draw_context *draw,
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
vs->info.output_semantic_index[i] == 0)
vs->position_output = i;
+ else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_EDGEFLAG &&
+ vs->info.output_semantic_index[i] == 0)
+ vs->edgeflag_output = i;
}
}
@@ -120,6 +123,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
draw->vs.vertex_shader = dvs;
draw->vs.num_vs_outputs = dvs->info.num_outputs;
draw->vs.position_output = dvs->position_output;
+ draw->vs.edgeflag_output = dvs->edgeflag_output;
dvs->prepare( dvs, draw );
}
else {
diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h
index 89ae158751..e3b807ebd0 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -107,6 +107,7 @@ struct draw_vertex_shader {
struct tgsi_shader_info info;
unsigned position_output;
+ unsigned edgeflag_output;
/* Extracted from shader:
*/
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index 645d7cccba..1aaae4ab7a 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -361,8 +361,8 @@ static struct x86_reg aos_get_shader_reg_ptr( struct aos_compilation *cp,
static struct x86_reg get_dst_ptr( struct aos_compilation *cp,
const struct tgsi_full_dst_register *dst )
{
- unsigned file = dst->DstRegister.File;
- unsigned idx = dst->DstRegister.Index;
+ unsigned file = dst->Register.File;
+ unsigned idx = dst->Register.Index;
unsigned i;
@@ -529,27 +529,18 @@ static struct x86_reg fetch_src( struct aos_compilation *cp,
const struct tgsi_full_src_register *src )
{
struct x86_reg arg0 = aos_get_shader_reg(cp,
- src->SrcRegister.File,
- src->SrcRegister.Index);
+ src->Register.File,
+ src->Register.Index);
unsigned i;
ubyte swz = 0;
unsigned negs = 0;
unsigned abs = 0;
for (i = 0; i < 4; i++) {
- unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( src, i );
+ unsigned swizzle = tgsi_util_get_full_src_register_swizzle( src, i );
unsigned neg = tgsi_util_get_full_src_register_sign_mode( src, i );
- switch (swizzle) {
- case TGSI_EXTSWIZZLE_ZERO:
- case TGSI_EXTSWIZZLE_ONE:
- AOS_ERROR(cp, "not supporting full swizzles yet in tgsi_aos_sse2");
- break;
-
- default:
- swz |= (swizzle & 0x3) << (i * 2);
- break;
- }
+ swz |= (swizzle & 0x3) << (i * 2);
switch (neg) {
case TGSI_UTIL_SIGN_TOGGLE:
@@ -629,26 +620,13 @@ static void x87_fld_src( struct aos_compilation *cp,
unsigned channel )
{
struct x86_reg arg0 = aos_get_shader_reg_ptr(cp,
- src->SrcRegister.File,
- src->SrcRegister.Index);
+ src->Register.File,
+ src->Register.Index);
- unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( src, channel );
+ unsigned swizzle = tgsi_util_get_full_src_register_swizzle( src, channel );
unsigned neg = tgsi_util_get_full_src_register_sign_mode( src, channel );
- switch (swizzle) {
- case TGSI_EXTSWIZZLE_ZERO:
- x87_fldz( cp->func );
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- x87_fld1( cp->func );
- break;
-
- default:
- x87_fld( cp->func, x86_make_disp(arg0, (swizzle & 3) * sizeof(float)) );
- break;
- }
-
+ x87_fld( cp->func, x86_make_disp(arg0, (swizzle & 3) * sizeof(float)) );
switch (neg) {
case TGSI_UTIL_SIGN_TOGGLE:
@@ -691,15 +669,15 @@ static void store_dest( struct aos_compilation *cp,
{
struct x86_reg dst;
- switch (reg->DstRegister.WriteMask) {
+ switch (reg->Register.WriteMask) {
case 0:
return;
case TGSI_WRITEMASK_XYZW:
aos_adopt_xmm_reg(cp,
get_xmm_writable(cp, result),
- reg->DstRegister.File,
- reg->DstRegister.Index,
+ reg->Register.File,
+ reg->Register.Index,
TRUE);
return;
default:
@@ -707,10 +685,10 @@ static void store_dest( struct aos_compilation *cp,
}
dst = aos_get_shader_reg_xmm(cp,
- reg->DstRegister.File,
- reg->DstRegister.Index);
+ reg->Register.File,
+ reg->Register.Index);
- switch (reg->DstRegister.WriteMask) {
+ switch (reg->Register.WriteMask) {
case TGSI_WRITEMASK_X:
sse_movss(cp->func, dst, get_xmm(cp, result));
break;
@@ -732,14 +710,14 @@ static void store_dest( struct aos_compilation *cp,
break;
default:
- mask_write(cp, dst, result, reg->DstRegister.WriteMask);
+ mask_write(cp, dst, result, reg->Register.WriteMask);
break;
}
aos_adopt_xmm_reg(cp,
dst,
- reg->DstRegister.File,
- reg->DstRegister.Index,
+ reg->Register.File,
+ reg->Register.Index,
TRUE);
}
@@ -759,7 +737,7 @@ static void store_scalar_dest( struct aos_compilation *cp,
const struct tgsi_full_dst_register *reg,
struct x86_reg result )
{
- unsigned writemask = reg->DstRegister.WriteMask;
+ unsigned writemask = reg->Register.WriteMask;
struct x86_reg dst;
if (writemask != TGSI_WRITEMASK_X &&
@@ -776,12 +754,12 @@ static void store_scalar_dest( struct aos_compilation *cp,
result = get_xmm(cp, result);
dst = aos_get_shader_reg_xmm(cp,
- reg->DstRegister.File,
- reg->DstRegister.Index);
+ reg->Register.File,
+ reg->Register.Index);
- switch (reg->DstRegister.WriteMask) {
+ switch (reg->Register.WriteMask) {
case TGSI_WRITEMASK_X:
sse_movss(cp->func, dst, result);
break;
@@ -804,8 +782,8 @@ static void store_scalar_dest( struct aos_compilation *cp,
aos_adopt_xmm_reg(cp,
dst,
- reg->DstRegister.File,
- reg->DstRegister.Index,
+ reg->Register.File,
+ reg->Register.Index,
TRUE);
}
@@ -841,7 +819,7 @@ static void x87_fstp_dest4( struct aos_compilation *cp,
const struct tgsi_full_dst_register *dst )
{
struct x86_reg ptr = get_dst_ptr(cp, dst);
- unsigned writemask = dst->DstRegister.WriteMask;
+ unsigned writemask = dst->Register.WriteMask;
x87_fst_or_nop(cp->func, writemask, 0, ptr);
x87_fst_or_nop(cp->func, writemask, 1, ptr);
@@ -978,7 +956,7 @@ static void emit_print( struct aos_compilation *cp,
static boolean emit_ABS( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
struct x86_reg neg = aos_get_internal(cp, IMM_NEGS);
struct x86_reg tmp = aos_get_xmm_reg(cp);
@@ -986,27 +964,27 @@ static boolean emit_ABS( struct aos_compilation *cp, const struct tgsi_full_inst
sse_mulps(cp->func, tmp, neg);
sse_maxps(cp->func, tmp, arg0);
- store_dest(cp, &op->FullDstRegisters[0], tmp);
+ store_dest(cp, &op->Dst[0], tmp);
return TRUE;
}
static boolean emit_ADD( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_addps(cp->func, dst, arg1);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_COS( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- x87_fld_src(cp, &op->FullSrcRegisters[0], 0);
+ x87_fld_src(cp, &op->Src[0], 0);
x87_fcos(cp->func);
- x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+ x87_fstp_dest4(cp, &op->Dst[0]);
return TRUE;
}
@@ -1015,8 +993,8 @@ static boolean emit_COS( struct aos_compilation *cp, const struct tgsi_full_inst
*/
static boolean emit_DP3( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg tmp = aos_get_xmm_reg(cp);
struct x86_reg dst = get_xmm_writable(cp, arg0);
@@ -1029,14 +1007,14 @@ static boolean emit_DP3( struct aos_compilation *cp, const struct tgsi_full_inst
sse_addss(cp->func, dst, tmp);
aos_release_xmm_reg(cp, tmp.idx);
- store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+ store_scalar_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_DP4( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg tmp = aos_get_xmm_reg(cp);
struct x86_reg dst = get_xmm_writable(cp, arg0);
@@ -1050,14 +1028,14 @@ static boolean emit_DP4( struct aos_compilation *cp, const struct tgsi_full_inst
sse_addss(cp->func, dst, tmp);
aos_release_xmm_reg(cp, tmp.idx);
- store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+ store_scalar_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_DPH( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg tmp = aos_get_xmm_reg(cp);
struct x86_reg dst = get_xmm_writable(cp, arg0);
@@ -1073,14 +1051,14 @@ static boolean emit_DPH( struct aos_compilation *cp, const struct tgsi_full_inst
sse_addss(cp->func, dst, tmp);
aos_release_xmm_reg(cp, tmp.idx);
- store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+ store_scalar_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_DST( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg dst = aos_get_xmm_reg(cp);
struct x86_reg tmp = aos_get_xmm_reg(cp);
struct x86_reg ones = aos_get_internal(cp, IMM_ONES);
@@ -1095,25 +1073,25 @@ static boolean emit_DST( struct aos_compilation *cp, const struct tgsi_full_inst
sse_mulps(cp->func, dst, tmp);
aos_release_xmm_reg(cp, tmp.idx);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_LG2( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
x87_fld1(cp->func); /* 1 */
- x87_fld_src(cp, &op->FullSrcRegisters[0], 0); /* a0 1 */
+ x87_fld_src(cp, &op->Src[0], 0); /* a0 1 */
x87_fyl2x(cp->func); /* log2(a0) */
- x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+ x87_fstp_dest4(cp, &op->Dst[0]);
return TRUE;
}
#if 0
static boolean emit_EX2( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- x87_fld_src(cp, &op->FullSrcRegisters[0], 0);
+ x87_fld_src(cp, &op->Src[0], 0);
x87_emit_ex2(cp);
- x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+ x87_fstp_dest4(cp, &op->Dst[0]);
return TRUE;
}
#endif
@@ -1121,8 +1099,8 @@ static boolean emit_EX2( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_FLR( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]);
- unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+ struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]);
+ unsigned writemask = op->Dst[0].Register.WriteMask;
int i;
set_fpu_round_neg_inf( cp );
@@ -1131,7 +1109,7 @@ static boolean emit_FLR( struct aos_compilation *cp, const struct tgsi_full_inst
*/
for (i = 3; i >= 0; i--) {
if (writemask & (1<<i)) {
- x87_fld_src(cp, &op->FullSrcRegisters[0], i);
+ x87_fld_src(cp, &op->Src[0], i);
}
}
@@ -1148,8 +1126,8 @@ static boolean emit_FLR( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_RND( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]);
- unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+ struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]);
+ unsigned writemask = op->Dst[0].Register.WriteMask;
int i;
set_fpu_round_nearest( cp );
@@ -1158,7 +1136,7 @@ static boolean emit_RND( struct aos_compilation *cp, const struct tgsi_full_inst
*/
for (i = 3; i >= 0; i--) {
if (writemask & (1<<i)) {
- x87_fld_src(cp, &op->FullSrcRegisters[0], i);
+ x87_fld_src(cp, &op->Src[0], i);
}
}
@@ -1175,10 +1153,10 @@ static boolean emit_RND( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_FRC( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]);
+ struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]);
struct x86_reg st0 = x86_make_reg(file_x87, 0);
struct x86_reg st1 = x86_make_reg(file_x87, 1);
- unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+ unsigned writemask = op->Dst[0].Register.WriteMask;
int i;
set_fpu_round_neg_inf( cp );
@@ -1188,7 +1166,7 @@ static boolean emit_FRC( struct aos_compilation *cp, const struct tgsi_full_inst
*/
for (i = 3; i >= 0; i--) {
if (writemask & (1<<i)) {
- x87_fld_src(cp, &op->FullSrcRegisters[0], i);
+ x87_fld_src(cp, &op->Src[0], i);
}
}
@@ -1212,7 +1190,7 @@ static boolean emit_FRC( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
struct x86_reg ecx = x86_make_reg( file_REG32, reg_CX );
- unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+ unsigned writemask = op->Dst[0].Register.WriteMask;
unsigned lit_count = cp->lit_count++;
struct x86_reg result, arg0;
unsigned i;
@@ -1231,10 +1209,10 @@ static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_inst
if (writemask != TGSI_WRITEMASK_XYZW)
result = x86_make_disp(cp->machine_EDX, Offset(struct aos_machine, tmp[0]));
else
- result = get_dst_ptr(cp, &op->FullDstRegisters[0]);
+ result = get_dst_ptr(cp, &op->Dst[0]);
- arg0 = fetch_src( cp, &op->FullSrcRegisters[0] );
+ arg0 = fetch_src( cp, &op->Src[0] );
if (arg0.file == file_XMM) {
struct x86_reg tmp = x86_make_disp(cp->machine_EDX,
Offset(struct aos_machine, tmp[1]));
@@ -1281,7 +1259,7 @@ static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_inst
if (writemask != TGSI_WRITEMASK_XYZW) {
store_dest( cp,
- &op->FullDstRegisters[0],
+ &op->Dst[0],
get_xmm_writable( cp, result ) );
}
@@ -1291,8 +1269,8 @@ static boolean emit_LIT( struct aos_compilation *cp, const struct tgsi_full_inst
#if 0
static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg dst = get_dst_ptr(cp, &op->FullDstRegisters[0]);
- unsigned writemask = op->FullDstRegisters[0].DstRegister.WriteMask;
+ struct x86_reg dst = get_dst_ptr(cp, &op->Dst[0]);
+ unsigned writemask = op->Dst[0].Register.WriteMask;
if (writemask & TGSI_WRITEMASK_YZ) {
struct x86_reg st1 = x86_make_reg(file_x87, 1);
@@ -1308,13 +1286,13 @@ static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_fu
*/
x87_fldz(cp->func); /* 1 0 */
#endif
- x87_fld_src(cp, &op->FullSrcRegisters[0], 1); /* a1 1 0 */
+ x87_fld_src(cp, &op->Src[0], 1); /* a1 1 0 */
x87_fcomi(cp->func, st2); /* a1 1 0 */
x87_fcmovb(cp->func, st1); /* a1' 1 0 */
x87_fstp(cp->func, st1); /* a1' 0 */
x87_fstp(cp->func, st1); /* a1' */
- x87_fld_src(cp, &op->FullSrcRegisters[0], 3); /* a3 a1' */
+ x87_fld_src(cp, &op->Src[0], 3); /* a3 a1' */
x87_fxch(cp->func, st1); /* a1' a3 */
@@ -1327,7 +1305,7 @@ static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_fu
/* a0' = max2(a0, 0):
*/
x87_fldz(cp->func); /* 0 r2 */
- x87_fld_src(cp, &op->FullSrcRegisters[0], 0); /* a0 0 r2 */
+ x87_fld_src(cp, &op->Src[0], 0); /* a0 0 r2 */
x87_fcomi(cp->func, st1);
x87_fcmovb(cp->func, st1); /* a0' 0 r2 */
@@ -1355,58 +1333,58 @@ static boolean emit_inline_LIT( struct aos_compilation *cp, const struct tgsi_fu
static boolean emit_MAX( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_maxps(cp->func, dst, arg1);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_MIN( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_minps(cp->func, dst, arg1);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_MOV( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
struct x86_reg dst = get_xmm_writable(cp, arg0);
/* potentially nothing to do */
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_MUL( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_mulps(cp->func, dst, arg1);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_MAD( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
- struct x86_reg arg2 = fetch_src(cp, &op->FullSrcRegisters[2]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
+ struct x86_reg arg2 = fetch_src(cp, &op->Src[2]);
/* If we can't clobber old contents of arg0, get a temporary & copy
* it there, then clobber it...
@@ -1415,7 +1393,7 @@ static boolean emit_MAD( struct aos_compilation *cp, const struct tgsi_full_inst
sse_mulps(cp->func, arg0, arg1);
sse_addps(cp->func, arg0, arg2);
- store_dest(cp, &op->FullDstRegisters[0], arg0);
+ store_dest(cp, &op->Dst[0], arg0);
return TRUE;
}
@@ -1447,13 +1425,13 @@ static float PIPE_CDECL _exp2(float x)
static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
#if 0
- x87_fld_src(cp, &op->FullSrcRegisters[1], 0); /* a1.x */
- x87_fld_src(cp, &op->FullSrcRegisters[0], 0); /* a0.x a1.x */
+ x87_fld_src(cp, &op->Src[1], 0); /* a1.x */
+ x87_fld_src(cp, &op->Src[0], 0); /* a0.x a1.x */
x87_fyl2x(cp->func); /* a1*log2(a0) */
x87_emit_ex2( cp ); /* 2^(a1*log2(a0)) */
- x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+ x87_fstp_dest4(cp, &op->Dst[0]);
#else
uint i;
@@ -1472,9 +1450,9 @@ static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_inst
x86_lea( cp->func, cp->stack_ESP, x86_make_disp(cp->stack_ESP, -8) );
- x87_fld_src( cp, &op->FullSrcRegisters[1], 0 );
+ x87_fld_src( cp, &op->Src[1], 0 );
x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 4 ) );
- x87_fld_src( cp, &op->FullSrcRegisters[0], 0 );
+ x87_fld_src( cp, &op->Src[0], 0 );
x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 0 ) );
/* tmp_EAX has been pushed & will be restored below */
@@ -1489,7 +1467,7 @@ static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_inst
*/
cp->func->x87_stack++;
- x87_fstp_dest4( cp, &op->FullDstRegisters[0] );
+ x87_fstp_dest4( cp, &op->Dst[0] );
#endif
return TRUE;
}
@@ -1515,7 +1493,7 @@ static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full
x86_lea( cp->func, cp->stack_ESP, x86_make_disp(cp->stack_ESP, -4) );
- x87_fld_src( cp, &op->FullSrcRegisters[0], 0 );
+ x87_fld_src( cp, &op->Src[0], 0 );
x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 0 ) );
/* tmp_EAX has been pushed & will be restored below */
@@ -1530,7 +1508,7 @@ static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full
*/
cp->func->x87_stack++;
- x87_fstp_dest4( cp, &op->FullDstRegisters[0] );
+ x87_fstp_dest4( cp, &op->Dst[0] );
return TRUE;
}
@@ -1539,7 +1517,7 @@ static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full
static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
struct x86_reg dst = aos_get_xmm_reg(cp);
if (cp->have_sse2) {
@@ -1553,7 +1531,7 @@ static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_inst
sse_divss(cp->func, dst, arg0);
}
- store_scalar_dest(cp, &op->FullDstRegisters[0], dst);
+ store_scalar_dest(cp, &op->Dst[0], dst);
return TRUE;
}
@@ -1573,14 +1551,14 @@ static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
if (0) {
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
struct x86_reg r = aos_get_xmm_reg(cp);
sse_rsqrtss(cp->func, r, arg0);
- store_scalar_dest(cp, &op->FullDstRegisters[0], r);
+ store_scalar_dest(cp, &op->Dst[0], r);
return TRUE;
}
else {
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
struct x86_reg r = aos_get_xmm_reg(cp);
struct x86_reg neg_half = get_reg_ptr( cp, AOS_FILE_INTERNAL, IMM_RSQ );
@@ -1600,7 +1578,7 @@ static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_inst
sse_addss( cp->func, tmp, one_point_five ); /* 1.5 - .5 * a * r * r */
sse_mulss( cp->func, r, tmp ); /* r * (1.5 - .5 * a * r * r) */
- store_scalar_dest(cp, &op->FullDstRegisters[0], r);
+ store_scalar_dest(cp, &op->Dst[0], r);
aos_release_xmm_reg(cp, tmp.idx);
@@ -1611,23 +1589,23 @@ static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_SGE( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg ones = aos_get_internal(cp, IMM_ONES);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_cmpps(cp->func, dst, arg1, cc_NotLessThan);
sse_andps(cp->func, dst, ones);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_SIN( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- x87_fld_src(cp, &op->FullSrcRegisters[0], 0);
+ x87_fld_src(cp, &op->Src[0], 0);
x87_fsin(cp->func);
- x87_fstp_dest4(cp, &op->FullDstRegisters[0]);
+ x87_fstp_dest4(cp, &op->Dst[0]);
return TRUE;
}
@@ -1635,46 +1613,46 @@ static boolean emit_SIN( struct aos_compilation *cp, const struct tgsi_full_inst
static boolean emit_SLT( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg ones = aos_get_internal(cp, IMM_ONES);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_cmpps(cp->func, dst, arg1, cc_LessThan);
sse_andps(cp->func, dst, ones);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_SUB( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg dst = get_xmm_writable(cp, arg0);
sse_subps(cp->func, dst, arg1);
- store_dest(cp, &op->FullDstRegisters[0], dst);
+ store_dest(cp, &op->Dst[0], dst);
return TRUE;
}
static boolean emit_TRUNC( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
struct x86_reg tmp0 = aos_get_xmm_reg(cp);
sse2_cvttps2dq(cp->func, tmp0, arg0);
sse2_cvtdq2ps(cp->func, tmp0, tmp0);
- store_dest(cp, &op->FullDstRegisters[0], tmp0);
+ store_dest(cp, &op->Dst[0], tmp0);
return TRUE;
}
static boolean emit_XPD( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg arg1 = fetch_src(cp, &op->FullSrcRegisters[1]);
+ struct x86_reg arg0 = fetch_src(cp, &op->Src[0]);
+ struct x86_reg arg1 = fetch_src(cp, &op->Src[1]);
struct x86_reg tmp0 = aos_get_xmm_reg(cp);
struct x86_reg tmp1 = aos_get_xmm_reg(cp);
@@ -1692,7 +1670,7 @@ static boolean emit_XPD( struct aos_compilation *cp, const struct tgsi_full_inst
aos_release_xmm_reg(cp, tmp0.idx);
- store_dest(cp, &op->FullDstRegisters[0], tmp1);
+ store_dest(cp, &op->Dst[0], tmp1);
return TRUE;
}
@@ -1919,10 +1897,10 @@ static void find_last_write_outputs( struct aos_compilation *cp )
continue;
for (i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++) {
- if (parse.FullToken.FullInstruction.FullDstRegisters[i].DstRegister.File ==
+ if (parse.FullToken.FullInstruction.Dst[i].Register.File ==
TGSI_FILE_OUTPUT)
{
- unsigned idx = parse.FullToken.FullInstruction.FullDstRegisters[i].DstRegister.Index;
+ unsigned idx = parse.FullToken.FullInstruction.Dst[i].Register.Index;
cp->output_last_write[idx] = this_instruction;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c
index 7ee567d478..d16692584e 100644
--- a/src/gallium/auxiliary/draw/draw_vs_varient.c
+++ b/src/gallium/auxiliary/draw/draw_vs_varient.c
@@ -147,11 +147,12 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient,
vsvg->base.vs->run_linear( vsvg->base.vs,
temp_buffer,
temp_buffer,
- (const float (*)[4])vsvg->base.vs->draw->pt.user.constants,
+ (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
count,
temp_vertex_stride,
temp_vertex_stride);
+ /* FIXME: geometry shading? */
if (vsvg->base.key.clip) {
/* not really handling clipping, just do the rhw so we can
@@ -207,7 +208,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient,
vsvg->base.vs->run_linear( vsvg->base.vs,
temp_buffer,
temp_buffer,
- (const float (*)[4])vsvg->base.vs->draw->pt.user.constants,
+ (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
count,
temp_vertex_stride,
temp_vertex_stride);
diff --git a/src/gallium/auxiliary/gallivm/Makefile b/src/gallium/auxiliary/gallivm/Makefile
deleted file mode 100644
index 5a96d94ec3..0000000000
--- a/src/gallium/auxiliary/gallivm/Makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*-makefile-*-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = gallivm
-
-
-GALLIVM_SOURCES = \
- gallivm.cpp \
- gallivm_cpu.cpp \
- instructions.cpp \
- loweringpass.cpp \
- tgsitollvm.cpp \
- storage.cpp \
- storagesoa.cpp \
- instructionssoa.cpp
-
-INC_SOURCES = gallivm_builtins.cpp gallivmsoabuiltins.cpp
-
-CPP_SOURCES = \
- $(GALLIVM_SOURCES)
-
-C_SOURCES =
-ASM_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/mesa \
- -I$(TOP)/include
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(LLVM_CFLAGS) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(LLVM_CXXFLAGS) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-##### TARGETS #####
-
-default:: depend symlinks $(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) Makefile
- $(TOP)/bin/mklib -o $@ -static $(OBJECTS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(INC_SOURCES)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) $(INC_SOURCES) 2> /dev/null
-
-
-gallivm_builtins.cpp: llvm_builtins.c
- clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp1.bin
- (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
- rm temp1.bin
-
-gallivmsoabuiltins.cpp: soabuiltins.c
- clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp2.bin
- (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/,0x00};/") >$@
- rm temp2.bin
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean:
- -rm -f *.o */*.o *~ *.so *~ server/*.o
- -rm -f depend depend.bak
- -rm -f gallivm_builtins.cpp
- -rm -f gallivmsoabuiltins.cpp
-
-symlinks:
-
-
-include depend
diff --git a/src/gallium/auxiliary/gallivm/SConscript b/src/gallium/auxiliary/gallivm/SConscript
deleted file mode 100644
index c0aa51b90a..0000000000
--- a/src/gallium/auxiliary/gallivm/SConscript
+++ /dev/null
@@ -1,16 +0,0 @@
-Import('*')
-
-gallivm = env.ConvenienceLibrary(
- target = 'gallivm',
- source = [
- 'gallivm.cpp',
- 'gallivm_cpu.cpp',
- 'instructions.cpp',
- 'loweringpass.cpp',
- 'tgsitollvm.cpp',
- 'storage.cpp',
- 'storagesoa.cpp',
- 'instructionssoa.cpp',
- ])
-
-auxiliaries.insert(0, gallivm)
diff --git a/src/gallium/auxiliary/gallivm/tgsitollvm.cpp b/src/gallium/auxiliary/gallivm/tgsitollvm.cpp
index bf84401e11..8f7d3b7100 100644
--- a/src/gallium/auxiliary/gallivm/tgsitollvm.cpp
+++ b/src/gallium/auxiliary/gallivm/tgsitollvm.cpp
@@ -94,8 +94,8 @@ translate_declaration(struct gallivm_ir *prog,
unsigned first, last, mask;
uint interp_method;
- first = decl->DeclarationRange.First;
- last = decl->DeclarationRange.Last;
+ first = decl->Range.First;
+ last = decl->Range.Last;
mask = decl->Declaration.UsageMask;
/* Do not touch WPOS.xy */
@@ -149,7 +149,7 @@ translate_declarationir(struct gallivm_ir *,
struct tgsi_full_declaration *)
{
if (decl->Declaration.File == TGSI_FILE_ADDRESS) {
- int idx = decl->DeclarationRange.First;
+ int idx = decl->Range.First;
storage->addAddress(idx);
}
}
@@ -234,26 +234,26 @@ translate_instruction(llvm::Module *module,
inputs[3] = 0;
for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
+ struct tgsi_full_src_register *src = &inst->Src[i];
llvm::Value *val = 0;
llvm::Value *indIdx = 0;
- if (src->SrcRegister.Indirect) {
- indIdx = storage->addrElement(src->SrcRegisterInd.Index);
+ if (src->Register.Indirect) {
+ indIdx = storage->addrElement(src->Indirect.Index);
indIdx = storage->extractIndex(indIdx);
}
- if (src->SrcRegister.File == TGSI_FILE_CONSTANT) {
- val = storage->constElement(src->SrcRegister.Index, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_INPUT) {
- val = storage->inputElement(src->SrcRegister.Index, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) {
- val = storage->tempElement(src->SrcRegister.Index);
- } else if (src->SrcRegister.File == TGSI_FILE_OUTPUT) {
- val = storage->outputElement(src->SrcRegister.Index, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_IMMEDIATE) {
- val = storage->immediateElement(src->SrcRegister.Index);
+ if (src->Register.File == TGSI_FILE_CONSTANT) {
+ val = storage->constElement(src->Register.Index, indIdx);
+ } else if (src->Register.File == TGSI_FILE_INPUT) {
+ val = storage->inputElement(src->Register.Index, indIdx);
+ } else if (src->Register.File == TGSI_FILE_TEMPORARY) {
+ val = storage->tempElement(src->Register.Index);
+ } else if (src->Register.File == TGSI_FILE_OUTPUT) {
+ val = storage->outputElement(src->Register.Index, indIdx);
+ } else if (src->Register.File == TGSI_FILE_IMMEDIATE) {
+ val = storage->immediateElement(src->Register.Index);
} else {
- fprintf(stderr, "ERROR: not supported llvm source %d\n", src->SrcRegister.File);
+ fprintf(stderr, "ERROR: not supported llvm source %d\n", src->Register.File);
return;
}
@@ -552,7 +552,7 @@ translate_instruction(llvm::Module *module,
break;
case TGSI_OPCODE_SHL:
break;
- case TGSI_OPCODE_SHR:
+ case TGSI_OPCODE_ISHR:
break;
case TGSI_OPCODE_AND:
break;
@@ -656,14 +656,14 @@ translate_instruction(llvm::Module *module,
/* store results */
for (int i = 0; i < inst->Instruction.NumDstRegs; ++i) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-
- if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
- storage->setOutputElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else if (dst->DstRegister.File == TGSI_FILE_TEMPORARY) {
- storage->setTempElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else if (dst->DstRegister.File == TGSI_FILE_ADDRESS) {
- storage->setAddrElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
+ struct tgsi_full_dst_register *dst = &inst->Dst[i];
+
+ if (dst->Register.File == TGSI_FILE_OUTPUT) {
+ storage->setOutputElement(dst->Register.Index, out, dst->Register.WriteMask);
+ } else if (dst->Register.File == TGSI_FILE_TEMPORARY) {
+ storage->setTempElement(dst->Register.Index, out, dst->Register.WriteMask);
+ } else if (dst->Register.File == TGSI_FILE_ADDRESS) {
+ storage->setAddrElement(dst->Register.Index, out, dst->Register.WriteMask);
} else {
fprintf(stderr, "ERROR: unsupported LLVM destination!");
assert(!"wrong destination");
@@ -683,16 +683,16 @@ translate_instructionir(llvm::Module *module,
std::vector< std::vector<llvm::Value*> > inputs(inst->Instruction.NumSrcRegs);
for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
+ struct tgsi_full_src_register *src = &inst->Src[i];
std::vector<llvm::Value*> val;
llvm::Value *indIdx = 0;
int swizzle = swizzleInt(src);
- if (src->SrcRegister.Indirect) {
- indIdx = storage->addrElement(src->SrcRegisterInd.Index);
+ if (src->Register.Indirect) {
+ indIdx = storage->addrElement(src->Indirect.Index);
}
- val = storage->load((enum tgsi_file_type)src->SrcRegister.File,
- src->SrcRegister.Index, swizzle, instr->getIRBuilder(), indIdx);
+ val = storage->load((enum tgsi_file_type)src->Register.File,
+ src->Register.Index, swizzle, instr->getIRBuilder(), indIdx);
inputs[i] = val;
}
@@ -919,7 +919,7 @@ translate_instructionir(llvm::Module *module,
break;
case TGSI_OPCODE_SHL:
break;
- case TGSI_OPCODE_SHR:
+ case TGSI_OPCODE_ISHR:
break;
case TGSI_OPCODE_AND:
break;
@@ -993,9 +993,9 @@ translate_instructionir(llvm::Module *module,
/* store results */
for (int i = 0; i < inst->Instruction.NumDstRegs; ++i) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
- storage->store((enum tgsi_file_type)dst->DstRegister.File,
- dst->DstRegister.Index, out, dst->DstRegister.WriteMask,
+ struct tgsi_full_dst_register *dst = &inst->Dst[i];
+ storage->store((enum tgsi_file_type)dst->Register.File,
+ dst->Register.Index, out, dst->Register.WriteMask,
instr->getIRBuilder() );
}
}
diff --git a/src/gallium/auxiliary/indices/Makefile b/src/gallium/auxiliary/indices/Makefile
deleted file mode 100644
index f2ebc3f410..0000000000
--- a/src/gallium/auxiliary/indices/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = indices
-
-C_SOURCES = \
- u_indices_gen.c \
- u_unfilled_gen.c
-
-include ../../Makefile.template
-
-u_indices_gen.c: u_indices_gen.py
- python $< > $@
-
-u_unfilled_gen.c: u_unfilled_gen.py
- python $< > $@
diff --git a/src/gallium/auxiliary/indices/SConscript b/src/gallium/auxiliary/indices/SConscript
deleted file mode 100644
index 712e215534..0000000000
--- a/src/gallium/auxiliary/indices/SConscript
+++ /dev/null
@@ -1,28 +0,0 @@
-Import('*')
-
-from sys import executable as python_cmd
-
-env.CodeGenerate(
- target = 'u_indices_gen.c',
- script = 'u_indices_gen.py',
- source = [],
- command = python_cmd + ' $SCRIPT > $TARGET'
-)
-
-env.CodeGenerate(
- target = 'u_unfilled_gen.c',
- script = 'u_unfilled_gen.py',
- source = [],
- command = python_cmd + ' $SCRIPT > $TARGET'
-)
-
-indices = env.ConvenienceLibrary(
- target = 'indices',
- source = [
-# 'u_indices.c',
-# 'u_unfilled_indices.c',
- 'u_indices_gen.c',
- 'u_unfilled_gen.c',
- ])
-
-auxiliaries.insert(0, indices)
diff --git a/src/gallium/auxiliary/pipebuffer/Makefile b/src/gallium/auxiliary/pipebuffer/Makefile
deleted file mode 100644
index 1c00ba8d98..0000000000
--- a/src/gallium/auxiliary/pipebuffer/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = pipebuffer
-
-C_SOURCES = \
- pb_buffer_fenced.c \
- pb_buffer_malloc.c \
- pb_bufmgr_alt.c \
- pb_bufmgr_cache.c \
- pb_bufmgr_debug.c \
- pb_bufmgr_fenced.c \
- pb_bufmgr_mm.c \
- pb_bufmgr_ondemand.c \
- pb_bufmgr_pool.c \
- pb_bufmgr_slab.c \
- pb_validate.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/pipebuffer/SConscript b/src/gallium/auxiliary/pipebuffer/SConscript
deleted file mode 100644
index 8e9f06abe4..0000000000
--- a/src/gallium/auxiliary/pipebuffer/SConscript
+++ /dev/null
@@ -1,19 +0,0 @@
-Import('*')
-
-pipebuffer = env.ConvenienceLibrary(
- target = 'pipebuffer',
- source = [
- 'pb_buffer_fenced.c',
- 'pb_buffer_malloc.c',
- 'pb_bufmgr_alt.c',
- 'pb_bufmgr_cache.c',
- 'pb_bufmgr_debug.c',
- 'pb_bufmgr_fenced.c',
- 'pb_bufmgr_mm.c',
- 'pb_bufmgr_ondemand.c',
- 'pb_bufmgr_pool.c',
- 'pb_bufmgr_slab.c',
- 'pb_validate.c',
- ])
-
-auxiliaries.insert(0, pipebuffer)
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 2590546cb4..eb7e84be84 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -46,7 +46,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#include "pipe/p_state.h"
@@ -237,8 +237,9 @@ pb_reference(struct pb_buffer **dst,
{
struct pb_buffer *old = *dst;
- if (pipe_reference((struct pipe_reference**)dst, &src->base.reference))
+ if (pipe_reference(&(*dst)->base.reference, &src->base.reference))
pb_destroy( old );
+ *dst = src;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index d31476228c..ba6f7b15f9 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -42,7 +42,7 @@
#endif
#include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
@@ -80,11 +80,27 @@ struct fenced_buffer_list
*/
struct fenced_buffer
{
+ /*
+ * Immutable members.
+ */
+
struct pb_buffer base;
-
struct pb_buffer *buffer;
+ struct fenced_buffer_list *list;
+
+ /**
+ * Protected by fenced_buffer_list::mutex
+ */
+ struct list_head head;
- /* FIXME: protect access with mutex */
+ /**
+ * Following members are mutable and protected by this mutex.
+ *
+ * You may lock this mutex alone, or lock it with fenced_buffer_list::mutex
+ * held, but in order to prevent deadlocks you must never lock
+ * fenced_buffer_list::mutex with this mutex held.
+ */
+ pipe_mutex mutex;
/**
* A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current
@@ -96,9 +112,6 @@ struct fenced_buffer
struct pb_validate *vl;
unsigned validation_flags;
struct pipe_fence_handle *fence;
-
- struct list_head head;
- struct fenced_buffer_list *list;
};
@@ -110,15 +123,24 @@ fenced_buffer(struct pb_buffer *buf)
}
+/**
+ * Add the buffer to the fenced list.
+ *
+ * fenced_buffer_list::mutex and fenced_buffer::mutex must be held, in this
+ * order, before calling this function.
+ *
+ * Reference count should be incremented before calling this function.
+ */
static INLINE void
-_fenced_buffer_add(struct fenced_buffer *fenced_buf)
+fenced_buffer_add_locked(struct fenced_buffer_list *fenced_list,
+ struct fenced_buffer *fenced_buf)
{
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
-
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
+ /* TODO: Move the reference count increment here */
+
#ifdef DEBUG
LIST_DEL(&fenced_buf->head);
assert(fenced_list->numUnfenced);
@@ -130,32 +152,16 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf)
/**
- * Actually destroy the buffer.
+ * Remove the buffer from the fenced list.
+ *
+ * fenced_buffer_list::mutex and fenced_buffer::mutex must be held, in this
+ * order before calling this function.
+ *
+ * Reference count should be decremented after calling this function.
*/
static INLINE void
-_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
-{
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
-
- assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
- assert(!fenced_buf->fence);
-#ifdef DEBUG
- assert(fenced_buf->head.prev);
- assert(fenced_buf->head.next);
- LIST_DEL(&fenced_buf->head);
- assert(fenced_list->numUnfenced);
- --fenced_list->numUnfenced;
-#else
- (void)fenced_list;
-#endif
- pb_reference(&fenced_buf->buffer, NULL);
- FREE(fenced_buf);
-}
-
-
-static INLINE void
-_fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
- struct fenced_buffer *fenced_buf)
+fenced_buffer_remove_locked(struct fenced_buffer_list *fenced_list,
+ struct fenced_buffer *fenced_buf)
{
struct pb_fence_ops *ops = fenced_list->ops;
@@ -177,37 +183,56 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
++fenced_list->numUnfenced;
#endif
- /**
- * FIXME!!!
- */
-
- if(!pipe_is_referenced(&fenced_buf->base.base.reference))
- _fenced_buffer_destroy(fenced_buf);
+ /* TODO: Move the reference count decrement and destruction here */
}
+/**
+ * Wait for the fence to expire, and remove it from the fenced list.
+ *
+ * fenced_buffer::mutex must be held. fenced_buffer_list::mutex must not be
+ * held -- it will be acquired internally.
+ */
static INLINE enum pipe_error
-_fenced_buffer_finish(struct fenced_buffer *fenced_buf)
+fenced_buffer_finish_locked(struct fenced_buffer_list *fenced_list,
+ struct fenced_buffer *fenced_buf)
{
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
struct pb_fence_ops *ops = fenced_list->ops;
+ enum pipe_error ret = PIPE_ERROR;
#if 0
debug_warning("waiting for GPU");
#endif
+ assert(pipe_is_referenced(&fenced_buf->base.base.reference));
assert(fenced_buf->fence);
+
+ /*
+ * Acquire the global lock. Must release buffer mutex first to preserve
+ * lock order.
+ */
+ pipe_mutex_unlock(fenced_buf->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
+ pipe_mutex_lock(fenced_buf->mutex);
+
if(fenced_buf->fence) {
- if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) {
- return PIPE_ERROR;
+ if(ops->fence_finish(ops, fenced_buf->fence, 0) == 0) {
+ /* Remove from the fenced list */
+ /* TODO: remove consequents */
+ fenced_buffer_remove_locked(fenced_list, fenced_buf);
+
+ p_atomic_dec(&fenced_buf->base.base.reference.count);
+ assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+
+ fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+
+ ret = PIPE_OK;
}
- /* Remove from the fenced list */
- /* TODO: remove consequents */
- _fenced_buffer_remove(fenced_list, fenced_buf);
}
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
- return PIPE_OK;
+ pipe_mutex_unlock(fenced_list->mutex);
+
+ return ret;
}
@@ -215,12 +240,13 @@ _fenced_buffer_finish(struct fenced_buffer *fenced_buf)
* Free as many fenced buffers from the list head as possible.
*/
static void
-_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
- int wait)
+fenced_buffer_list_check_free_locked(struct fenced_buffer_list *fenced_list,
+ int wait)
{
struct pb_fence_ops *ops = fenced_list->ops;
struct list_head *curr, *next;
struct fenced_buffer *fenced_buf;
+ struct pb_buffer *pb_buf;
struct pipe_fence_handle *prev_fence = NULL;
curr = fenced_list->delayed.next;
@@ -228,21 +254,29 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
while(curr != &fenced_list->delayed) {
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+ pipe_mutex_lock(fenced_buf->mutex);
+
if(fenced_buf->fence != prev_fence) {
int signaled;
if (wait)
signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
else
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
- if (signaled != 0)
+ if (signaled != 0) {
+ pipe_mutex_unlock(fenced_buf->mutex);
break;
+ }
prev_fence = fenced_buf->fence;
}
else {
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
}
- _fenced_buffer_remove(fenced_list, fenced_buf);
+ fenced_buffer_remove_locked(fenced_list, fenced_buf);
+ pipe_mutex_unlock(fenced_buf->mutex);
+
+ pb_buf = &fenced_buf->base;
+ pb_reference(&pb_buf, NULL);
curr = next;
next = curr->next;
@@ -256,30 +290,25 @@ fenced_buffer_destroy(struct pb_buffer *buf)
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- pipe_mutex_lock(fenced_list->mutex);
assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
- if (fenced_buf->fence) {
- struct pb_fence_ops *ops = fenced_list->ops;
- if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
- struct list_head *curr, *prev;
- curr = &fenced_buf->head;
- prev = curr->prev;
- do {
- fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
- assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
- _fenced_buffer_remove(fenced_list, fenced_buf);
- curr = prev;
- prev = curr->prev;
- } while (curr != &fenced_list->delayed);
- }
- else {
- /* delay destruction */
- }
- }
- else {
- _fenced_buffer_destroy(fenced_buf);
- }
+ assert(!fenced_buf->fence);
+
+#ifdef DEBUG
+ pipe_mutex_lock(fenced_list->mutex);
+ assert(fenced_buf->head.prev);
+ assert(fenced_buf->head.next);
+ LIST_DEL(&fenced_buf->head);
+ assert(fenced_list->numUnfenced);
+ --fenced_list->numUnfenced;
pipe_mutex_unlock(fenced_list->mutex);
+#else
+ (void)fenced_list;
+#endif
+
+ pb_reference(&fenced_buf->buffer, NULL);
+
+ pipe_mutex_destroy(fenced_buf->mutex);
+ FREE(fenced_buf);
}
@@ -290,24 +319,23 @@ fenced_buffer_map(struct pb_buffer *buf,
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
struct pb_fence_ops *ops = fenced_list->ops;
- void *map;
+ void *map = NULL;
+
+ pipe_mutex_lock(fenced_buf->mutex);
assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
/* Serialize writes */
if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
- if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) &&
+ ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
/* Don't wait for the GPU to finish writing */
- if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0)
- _fenced_buffer_remove(fenced_list, fenced_buf);
- else
- return NULL;
- }
- else {
- /* Wait for the GPU to finish writing */
- _fenced_buffer_finish(fenced_buf);
+ goto done;
}
+
+ /* Wait for the GPU to finish writing */
+ fenced_buffer_finish_locked(fenced_list, fenced_buf);
}
#if 0
@@ -324,6 +352,9 @@ fenced_buffer_map(struct pb_buffer *buf,
fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
}
+done:
+ pipe_mutex_unlock(fenced_buf->mutex);
+
return map;
}
@@ -332,6 +363,9 @@ static void
fenced_buffer_unmap(struct pb_buffer *buf)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+
+ pipe_mutex_lock(fenced_buf->mutex);
+
assert(fenced_buf->mapcount);
if(fenced_buf->mapcount) {
pb_unmap(fenced_buf->buffer);
@@ -339,6 +373,8 @@ fenced_buffer_unmap(struct pb_buffer *buf)
if(!fenced_buf->mapcount)
fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE;
}
+
+ pipe_mutex_unlock(fenced_buf->mutex);
}
@@ -350,11 +386,14 @@ fenced_buffer_validate(struct pb_buffer *buf,
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
enum pipe_error ret;
+ pipe_mutex_lock(fenced_buf->mutex);
+
if(!vl) {
/* invalidate */
fenced_buf->vl = NULL;
fenced_buf->validation_flags = 0;
- return PIPE_OK;
+ ret = PIPE_OK;
+ goto done;
}
assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
@@ -362,14 +401,17 @@ fenced_buffer_validate(struct pb_buffer *buf,
flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
/* Buffer cannot be validated in two different lists */
- if(fenced_buf->vl && fenced_buf->vl != vl)
- return PIPE_ERROR_RETRY;
+ if(fenced_buf->vl && fenced_buf->vl != vl) {
+ ret = PIPE_ERROR_RETRY;
+ goto done;
+ }
#if 0
/* Do not validate if buffer is still mapped */
if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) {
/* TODO: wait for the thread that mapped the buffer to unmap it */
- return PIPE_ERROR_RETRY;
+ ret = PIPE_ERROR_RETRY;
+ goto done;
}
/* Final sanity checking */
assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
@@ -379,17 +421,21 @@ fenced_buffer_validate(struct pb_buffer *buf,
if(fenced_buf->vl == vl &&
(fenced_buf->validation_flags & flags) == flags) {
/* Nothing to do -- buffer already validated */
- return PIPE_OK;
+ ret = PIPE_OK;
+ goto done;
}
ret = pb_validate(fenced_buf->buffer, vl, flags);
if (ret != PIPE_OK)
- return ret;
+ goto done;
fenced_buf->vl = vl;
fenced_buf->validation_flags |= flags;
- return PIPE_OK;
+done:
+ pipe_mutex_unlock(fenced_buf->mutex);
+
+ return ret;
}
@@ -404,29 +450,36 @@ fenced_buffer_fence(struct pb_buffer *buf,
fenced_buf = fenced_buffer(buf);
fenced_list = fenced_buf->list;
ops = fenced_list->ops;
-
- if(fence == fenced_buf->fence) {
- /* Nothing to do */
- return;
- }
- assert(fenced_buf->vl);
- assert(fenced_buf->validation_flags);
-
pipe_mutex_lock(fenced_list->mutex);
- if (fenced_buf->fence)
- _fenced_buffer_remove(fenced_list, fenced_buf);
- if (fence) {
- ops->fence_reference(ops, &fenced_buf->fence, fence);
- fenced_buf->flags |= fenced_buf->validation_flags;
- _fenced_buffer_add(fenced_buf);
- }
- pipe_mutex_unlock(fenced_list->mutex);
+ pipe_mutex_lock(fenced_buf->mutex);
+
+ assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+
+ if(fence != fenced_buf->fence) {
+ assert(fenced_buf->vl);
+ assert(fenced_buf->validation_flags);
+
+ if (fenced_buf->fence) {
+ fenced_buffer_remove_locked(fenced_list, fenced_buf);
+ p_atomic_dec(&fenced_buf->base.base.reference.count);
+ assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+ }
+ if (fence) {
+ ops->fence_reference(ops, &fenced_buf->fence, fence);
+ fenced_buf->flags |= fenced_buf->validation_flags;
+ p_atomic_inc(&fenced_buf->base.base.reference.count);
+ fenced_buffer_add_locked(fenced_list, fenced_buf);
+ }
+
+ pb_fence(fenced_buf->buffer, fence);
- pb_fence(fenced_buf->buffer, fence);
+ fenced_buf->vl = NULL;
+ fenced_buf->validation_flags = 0;
+ }
- fenced_buf->vl = NULL;
- fenced_buf->validation_flags = 0;
+ pipe_mutex_unlock(fenced_buf->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
@@ -436,6 +489,7 @@ fenced_buffer_get_base_buffer(struct pb_buffer *buf,
pb_size *offset)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ /* NOTE: accesses immutable members only -- mutex not necessary */
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
}
@@ -475,6 +529,8 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
buf->buffer = buffer;
buf->list = fenced_list;
+ pipe_mutex_init(buf->mutex);
+
#ifdef DEBUG
pipe_mutex_lock(fenced_list->mutex);
LIST_ADDTAIL(&buf->head, &fenced_list->unfenced);
@@ -516,7 +572,7 @@ fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait)
{
pipe_mutex_lock(fenced_list->mutex);
- _fenced_buffer_list_check_free(fenced_list, wait);
+ fenced_buffer_list_check_free_locked(fenced_list, wait);
pipe_mutex_unlock(fenced_list->mutex);
}
@@ -538,11 +594,13 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
next = curr->next;
while(curr != &fenced_list->unfenced) {
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+ pipe_mutex_lock(fenced_buf->mutex);
assert(!fenced_buf->fence);
debug_printf("%10p %7u %7u\n",
- fenced_buf,
+ (void *) fenced_buf,
fenced_buf->base.base.size,
p_atomic_read(&fenced_buf->base.base.reference.count));
+ pipe_mutex_unlock(fenced_buf->mutex);
curr = next;
next = curr->next;
}
@@ -552,13 +610,15 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
while(curr != &fenced_list->delayed) {
int signaled;
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+ pipe_mutex_lock(fenced_buf->mutex);
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
debug_printf("%10p %7u %7u %10p %s\n",
- fenced_buf,
+ (void *) fenced_buf,
fenced_buf->base.base.size,
p_atomic_read(&fenced_buf->base.base.reference.count),
- fenced_buf->fence,
+ (void *) fenced_buf->fence,
signaled == 0 ? "y" : "n");
+ pipe_mutex_unlock(fenced_buf->mutex);
curr = next;
next = curr->next;
}
@@ -579,8 +639,8 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
sched_yield();
#endif
- _fenced_buffer_list_check_free(fenced_list, 1);
pipe_mutex_lock(fenced_list->mutex);
+ fenced_buffer_list_check_free_locked(fenced_list, 1);
}
#ifdef DEBUG
@@ -588,6 +648,7 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
#endif
pipe_mutex_unlock(fenced_list->mutex);
+ pipe_mutex_destroy(fenced_list->mutex);
fenced_list->ops->destroy(fenced_list->ops);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index 39ab8e722c..8c8d713078 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -51,7 +51,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 57d1ede45a..7b34c8e357 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -294,7 +294,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
LIST_DEL(&buf->head);
pipe_mutex_unlock(mgr->mutex);
/* Increase refcount */
- pb_reference((struct pb_buffer**)&buf, &buf->base);
+ pipe_reference(NULL, &buf->base.base.reference);
return &buf->base;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index e7352e90db..d21910d0bf 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -37,7 +37,6 @@
*/
#include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 150fd50618..ce40c0cf0e 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -34,7 +34,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "util/u_debug.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.h b/src/gallium/auxiliary/pipebuffer/pb_validate.h
index dfb84df1ce..3c93f30f20 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.h
@@ -37,7 +37,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/gallium/auxiliary/rbug/Makefile b/src/gallium/auxiliary/rbug/Makefile
deleted file mode 100644
index cd12e8468f..0000000000
--- a/src/gallium/auxiliary/rbug/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = rbug
-
-C_SOURCES = \
- rbug_connection.c \
- rbug_core.c \
- rbug_texture.c \
- rbug_context.c \
- rbug_shader.c \
- rbug_demarshal.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README
index 33d76371de..d984067893 100644
--- a/src/gallium/auxiliary/rbug/README
+++ b/src/gallium/auxiliary/rbug/README
@@ -16,6 +16,10 @@ for information about applications look in:
progs/rbug/README
+for a GUI see:
+
+ http://cgit.freedesktop.org/mesa/rbug-gui
+
--
Jakob Bornecrantz <jakob@vmware.com>
diff --git a/src/gallium/auxiliary/rbug/SConscript b/src/gallium/auxiliary/rbug/SConscript
deleted file mode 100644
index 4a9afb45d3..0000000000
--- a/src/gallium/auxiliary/rbug/SConscript
+++ /dev/null
@@ -1,14 +0,0 @@
-Import('*')
-
-rbug = env.ConvenienceLibrary(
- target = 'rbug',
- source = [
- 'rbug_core.c',
- 'rbug_shader.c',
- 'rbug_context.c',
- 'rbug_texture.c',
- 'rbug_demarshal.c',
- 'rbug_connection.c',
- ])
-
-auxiliaries.insert(0, rbug)
diff --git a/src/gallium/auxiliary/rbug/rbug_connection.c b/src/gallium/auxiliary/rbug/rbug_connection.c
index 52acb700af..ae4e27f9f6 100644
--- a/src/gallium/auxiliary/rbug/rbug_connection.c
+++ b/src/gallium/auxiliary/rbug/rbug_connection.c
@@ -87,6 +87,7 @@ rbug_get_message(struct rbug_connection *c, uint32_t *serial)
if (!data) {
return NULL;
}
+ data->opcode = 0;
do {
uint8_t *ptr = ((uint8_t*)data) + read;
diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h
index da61c2365b..03126d6b12 100644
--- a/src/gallium/auxiliary/rbug/rbug_context.h
+++ b/src/gallium/auxiliary/rbug/rbug_context.h
@@ -46,7 +46,7 @@ typedef enum
RBUG_BLOCK_BEFORE = 1,
RBUG_BLOCK_AFTER = 2,
RBUG_BLOCK_RULE = 4,
- RBUG_BLOCK_MASK = 7,
+ RBUG_BLOCK_MASK = 7
} rbug_block_t;
struct rbug_proto_context_list
diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h
index d273be0166..4f3eb75dc4 100644
--- a/src/gallium/auxiliary/rbug/rbug_proto.h
+++ b/src/gallium/auxiliary/rbug/rbug_proto.h
@@ -65,7 +65,7 @@ enum rbug_opcode
RBUG_OP_SHADER_DISABLE = 770,
RBUG_OP_SHADER_REPLACE = 771,
RBUG_OP_SHADER_LIST_REPLY = -768,
- RBUG_OP_SHADER_INFO_REPLY = -769,
+ RBUG_OP_SHADER_INFO_REPLY = -769
};
/**
diff --git a/src/gallium/auxiliary/rtasm/Makefile b/src/gallium/auxiliary/rtasm/Makefile
deleted file mode 100644
index ab8ea464c6..0000000000
--- a/src/gallium/auxiliary/rtasm/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = rtasm
-
-C_SOURCES = \
- rtasm_cpu.c \
- rtasm_execmem.c \
- rtasm_x86sse.c \
- rtasm_ppc.c \
- rtasm_ppc_spe.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/rtasm/SConscript b/src/gallium/auxiliary/rtasm/SConscript
deleted file mode 100644
index eb48368acc..0000000000
--- a/src/gallium/auxiliary/rtasm/SConscript
+++ /dev/null
@@ -1,13 +0,0 @@
-Import('*')
-
-rtasm = env.ConvenienceLibrary(
- target = 'rtasm',
- source = [
- 'rtasm_cpu.c',
- 'rtasm_execmem.c',
- 'rtasm_x86sse.c',
- 'rtasm_ppc.c',
- 'rtasm_ppc_spe.c',
- ])
-
-auxiliaries.insert(0, rtasm)
diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
index 01811d5011..ffed768f97 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
@@ -41,6 +41,12 @@
#define MAP_ANONYMOUS MAP_ANON
#endif
+#if defined(PIPE_OS_WINDOWS)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#endif
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
@@ -118,7 +124,29 @@ rtasm_exec_free(void *addr)
}
-#else /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
+#elif defined(PIPE_OS_WINDOWS)
+
+
+/*
+ * Avoid Data Execution Prevention.
+ */
+
+void *
+rtasm_exec_malloc(size_t size)
+{
+ return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+}
+
+
+void
+rtasm_exec_free(void *addr)
+{
+ VirtualFree(addr, 0, MEM_RELEASE);
+}
+
+
+#else
+
/*
* Just use regular memory.
@@ -138,4 +166,4 @@ rtasm_exec_free(void *addr)
}
-#endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
+#endif
diff --git a/src/gallium/auxiliary/sct/Makefile b/src/gallium/auxiliary/sct/Makefile
deleted file mode 100644
index a7d111b689..0000000000
--- a/src/gallium/auxiliary/sct/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = sct
-
-C_SOURCES = \
- sct.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/sct/SConscript b/src/gallium/auxiliary/sct/SConscript
deleted file mode 100644
index 76927d973f..0000000000
--- a/src/gallium/auxiliary/sct/SConscript
+++ /dev/null
@@ -1,9 +0,0 @@
-Import('*')
-
-sct = env.ConvenienceLibrary(
- target = 'sct',
- source = [
- 'sct.c'
- ])
-
-auxiliaries.insert(0, sct)
diff --git a/src/gallium/auxiliary/sct/sct.c b/src/gallium/auxiliary/sct/sct.c
deleted file mode 100644
index 722d2b7e66..0000000000
--- a/src/gallium/auxiliary/sct/sct.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "util/u_memory.h"
-#include "pipe/p_state.h"
-#include "sct.h"
-
-
-struct texture_list
-{
- struct pipe_texture *texture;
- struct texture_list *next;
-};
-
-
-
-#define MAX_SURFACES ((PIPE_MAX_COLOR_BUFS) + 1)
-
-struct sct_context
-{
- const struct pipe_context *context;
-
- /** surfaces the context is drawing into */
- struct pipe_surface *surfaces[MAX_SURFACES];
-
- /** currently bound textures */
- struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
-
- /** previously bound textures, used but not flushed */
- struct texture_list *textures_used;
-
- boolean needs_flush;
-
- struct sct_context *next;
-};
-
-
-
-struct sct_surface
-{
- const struct pipe_surface *surface;
-
- /** list of contexts drawing to this surface */
- struct sct_context_list *contexts;
-
- struct sct_surface *next;
-};
-
-
-
-/**
- * Find the surface_info for the given pipe_surface
- */
-static struct sct_surface *
-find_surface_info(struct surface_context_tracker *sct,
- const struct pipe_surface *surface)
-{
- struct sct_surface *si;
- for (si = sct->surfaces; si; si = si->next)
- if (si->surface == surface)
- return si;
- return NULL;
-}
-
-
-/**
- * As above, but create new surface_info if surface is new.
- */
-static struct sct_surface *
-find_create_surface_info(struct surface_context_tracker *sct,
- const struct pipe_surface *surface)
-{
- struct sct_surface *si = find_surface_info(sct, surface);
- if (si)
- return si;
-
- /* alloc new */
- si = CALLOC_STRUCT(sct_surface);
- if (si) {
- si->surface = surface;
-
- /* insert at head */
- si->next = sct->surfaces;
- sct->surfaces = si;
- }
-
- return si;
-}
-
-
-/**
- * Find a context_info for the given context.
- */
-static struct sct_context *
-find_context_info(struct surface_context_tracker *sct,
- const struct pipe_context *context)
-{
- struct sct_context *ci;
- for (ci = sct->contexts; ci; ci = ci->next)
- if (ci->context == context)
- return ci;
- return NULL;
-}
-
-
-/**
- * As above, but create new context_info if context is new.
- */
-static struct sct_context *
-find_create_context_info(struct surface_context_tracker *sct,
- const struct pipe_context *context)
-{
- struct sct_context *ci = find_context_info(sct, context);
- if (ci)
- return ci;
-
- /* alloc new */
- ci = CALLOC_STRUCT(sct_context);
- if (ci) {
- ci->context = context;
-
- /* insert at head */
- ci->next = sct->contexts;
- sct->contexts = ci;
- }
-
- return ci;
-}
-
-
-/**
- * Is the context already bound to the surface?
- */
-static boolean
-find_surface_context(const struct sct_surface *si,
- const struct pipe_context *context)
-{
- const struct sct_context_list *cl;
- for (cl = si->contexts; cl; cl = cl->next) {
- if (cl->context == context) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-
-/**
- * Add a context to the list of contexts associated with a surface.
- */
-static void
-add_context_to_surface(struct sct_surface *si,
- const struct pipe_context *context)
-{
- struct sct_context_list *cl = CALLOC_STRUCT(sct_context_list);
- if (cl) {
- cl->context = context;
- /* insert at head of list of contexts */
- cl->next = si->contexts;
- si->contexts = cl;
- }
-}
-
-
-/**
- * Remove a context from the list of contexts associated with a surface.
- */
-static void
-remove_context_from_surface(struct sct_surface *si,
- const struct pipe_context *context)
-{
- struct sct_context_list *prev = NULL, *curr, *next;
-
- for (curr = si->contexts; curr; curr = next) {
- if (curr->context == context) {
- /* remove */
- if (prev)
- prev->next = curr->next;
- else
- si->contexts = curr->next;
- next = curr->next;
- FREE(curr);
- }
- else {
- prev = curr;
- next = curr->next;
- }
- }
-}
-
-
-/**
- * Unbind context from surface.
- */
-static void
-unbind_context_surface(struct surface_context_tracker *sct,
- struct pipe_context *context,
- struct pipe_surface *surface)
-{
- struct sct_surface *si = find_surface_info(sct, surface);
- if (si) {
- remove_context_from_surface(si, context);
- }
-}
-
-
-/**
- * Bind context to a set of surfaces (color + Z).
- * Like MakeCurrent().
- */
-void
-sct_bind_surfaces(struct surface_context_tracker *sct,
- struct pipe_context *context,
- uint num_surf,
- struct pipe_surface **surfaces)
-{
- struct sct_context *ci = find_create_context_info(sct, context);
- uint i;
-
- if (!ci) {
- return; /* out of memory */
- }
-
- /* unbind currently bound surfaces */
- for (i = 0; i < MAX_SURFACES; i++) {
- if (ci->surfaces[i]) {
- unbind_context_surface(sct, context, ci->surfaces[i]);
- }
- }
-
- /* bind new surfaces */
- for (i = 0; i < num_surf; i++) {
- struct sct_surface *si = find_create_surface_info(sct, surfaces[i]);
- if (!find_surface_context(si, context)) {
- add_context_to_surface(si, context);
- }
- }
-}
-
-
-/**
- * Return list of contexts bound to a surface.
- */
-const struct sct_context_list *
-sct_get_surface_contexts(struct surface_context_tracker *sct,
- const struct pipe_surface *surface)
-{
- const struct sct_surface *si = find_surface_info(sct, surface);
- return si->contexts;
-}
-
-
-
-static boolean
-find_texture(const struct sct_context *ci,
- const struct pipe_texture *texture)
-{
- const struct texture_list *tl;
-
- for (tl = ci->textures_used; tl; tl = tl->next) {
- if (tl->texture == texture) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-
-/**
- * Add the given texture to the context's list of used textures.
- */
-static void
-add_texture_used(struct sct_context *ci,
- struct pipe_texture *texture)
-{
- if (!find_texture(ci, texture)) {
- /* add to list */
- struct texture_list *tl = CALLOC_STRUCT(texture_list);
- if (tl) {
- pipe_texture_reference(&tl->texture, texture);
- /* insert at head */
- tl->next = ci->textures_used;
- ci->textures_used = tl;
- }
- }
-}
-
-
-/**
- * Bind a texture to a rendering context.
- */
-void
-sct_bind_texture(struct surface_context_tracker *sct,
- struct pipe_context *context,
- uint unit,
- struct pipe_texture *tex)
-{
- struct sct_context *ci = find_context_info(sct, context);
-
- if (ci->textures[unit] != tex) {
- /* put texture on the 'used' list */
- add_texture_used(ci, tex);
- /* bind new */
- pipe_texture_reference(&ci->textures[unit], tex);
- }
-}
-
-
-/**
- * Check if the given texture has been used by the rendering context
- * since the last call to sct_flush_textures().
- */
-boolean
-sct_is_texture_used(struct surface_context_tracker *sct,
- const struct pipe_context *context,
- const struct pipe_texture *texture)
-{
- const struct sct_context *ci = find_context_info(sct, context);
- return find_texture(ci, texture);
-}
-
-
-/**
- * To be called when the image contents of a texture are changed, such
- * as for gl[Copy]TexSubImage().
- * XXX this may not be needed
- */
-void
-sct_update_texture(struct pipe_texture *tex)
-{
-
-}
-
-
-/**
- * When a scene is flushed/rendered we can release the list of
- * used textures.
- */
-void
-sct_flush_textures(struct surface_context_tracker *sct,
- struct pipe_context *context)
-{
- struct sct_context *ci = find_context_info(sct, context);
- struct texture_list *tl, *next;
- uint i;
-
- for (tl = ci->textures_used; tl; tl = next) {
- next = tl->next;
- pipe_texture_reference(&tl->texture, NULL);
- FREE(tl);
- }
- ci->textures_used = NULL;
-
- /* put the currently bound textures on the 'used' list */
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- add_texture_used(ci, ci->textures[i]);
- }
-}
-
-
-
-void
-sct_destroy_context(struct surface_context_tracker *sct,
- struct pipe_context *context)
-{
- /* XXX should we require an unbinding first? */
- {
- struct sct_surface *si;
- for (si = sct->surfaces; si; si = si->next) {
- remove_context_from_surface(si, context);
- }
- }
-
- /* remove context from context_info list */
- {
- struct sct_context *ci, *next, *prev = NULL;
- for (ci = sct->contexts; ci; ci = next) {
- next = ci->next;
- if (ci->context == context) {
- if (prev)
- prev->next = ci->next;
- else
- sct->contexts = ci->next;
- FREE(ci);
- }
- else {
- prev = ci;
- }
- }
- }
-
-}
-
-
-void
-sct_destroy_surface(struct surface_context_tracker *sct,
- struct pipe_surface *surface)
-{
- if (1) {
- /* debug/sanity: no context should be bound to surface */
- struct sct_context *ci;
- uint i;
- for (ci = sct->contexts; ci; ci = ci->next) {
- for (i = 0; i < MAX_SURFACES; i++) {
- assert(ci->surfaces[i] != surface);
- }
- }
- }
-
- /* remove surface from sct_surface list */
- {
- struct sct_surface *si, *next, *prev = NULL;
- for (si = sct->surfaces; si; si = next) {
- next = si->next;
- if (si->surface == surface) {
- /* unlink */
- if (prev)
- prev->next = si->next;
- else
- sct->surfaces = si->next;
- FREE(si);
- }
- else {
- prev = si;
- }
- }
- }
-}
diff --git a/src/gallium/auxiliary/sct/sct.h b/src/gallium/auxiliary/sct/sct.h
deleted file mode 100644
index cf7c4d3bdf..0000000000
--- a/src/gallium/auxiliary/sct/sct.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * Surface/Context Tracking
- *
- * For some drivers, we need to monitor the binding between contexts and
- * surfaces/textures.
- * This code may evolve quite a bit...
- */
-
-
-#ifndef SCT_H
-#define SCT_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct pipe_context;
-struct pipe_surface;
-
-struct sct_context;
-struct sct_surface;
-
-
-/**
- * Per-device info, basically
- */
-struct surface_context_tracker
-{
- struct sct_context *contexts;
- struct sct_surface *surfaces;
-};
-
-
-
-/**
- * Simple linked list of contexts
- */
-struct sct_context_list
-{
- const struct pipe_context *context;
- struct sct_context_list *next;
-};
-
-
-
-extern void
-sct_bind_surfaces(struct surface_context_tracker *sct,
- struct pipe_context *context,
- uint num_surf,
- struct pipe_surface **surfaces);
-
-
-extern void
-sct_bind_texture(struct surface_context_tracker *sct,
- struct pipe_context *context,
- uint unit,
- struct pipe_texture *texture);
-
-
-extern void
-sct_update_texture(struct pipe_texture *tex);
-
-
-extern boolean
-sct_is_texture_used(struct surface_context_tracker *sct,
- const struct pipe_context *context,
- const struct pipe_texture *texture);
-
-extern void
-sct_flush_textures(struct surface_context_tracker *sct,
- struct pipe_context *context);
-
-
-extern const struct sct_context_list *
-sct_get_surface_contexts(struct surface_context_tracker *sct,
- const struct pipe_surface *surf);
-
-
-extern void
-sct_destroy_context(struct surface_context_tracker *sct,
- struct pipe_context *context);
-
-
-extern void
-sct_destroy_surface(struct surface_context_tracker *sct,
- struct pipe_surface *surface);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SCT_H */
diff --git a/src/gallium/auxiliary/sct/usage.c b/src/gallium/auxiliary/sct/usage.c
deleted file mode 100644
index 6227f19962..0000000000
--- a/src/gallium/auxiliary/sct/usage.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* surface / context tracking */
-
-
-/*
-
-context A:
- render to texture T
-
-context B:
- texture from T
-
------------------------
-
-flush surface:
- which contexts are bound to the surface?
-
------------------------
-
-glTexSubImage():
- which contexts need to be flushed?
-
- */
-
-
-/*
-
-in MakeCurrent():
-
- call sct_bind_surfaces(context, list of surfaces) to update the
- dependencies between context and surfaces
-
-
-in SurfaceFlush(), or whatever it is in D3D:
-
- call sct_get_surface_contexts(surface) to get a list of contexts
- which are currently bound to the surface.
-
-
-
-in BindTexture():
-
- call sct_bind_texture(context, texture) to indicate that the texture
- is used in the scene.
-
-
-in glTexSubImage() or RenderToTexture():
-
- call sct_is_texture_used(context, texture) to determine if the texture
- has been used in the scene, but the scene's not flushed. If TRUE is
- returned it means the scene has to be rendered/flushed before the contents
- of the texture can be changed.
-
-
-in psb_scene_flush/terminate():
-
- call sct_flush_textures(context) to tell the SCT that the textures which
- were used in the scene can be released.
-
-
-
-*/
diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile
deleted file mode 100644
index 5f0a580b09..0000000000
--- a/src/gallium/auxiliary/tgsi/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = tgsi
-
-C_SOURCES = \
- tgsi_sanity.c \
- tgsi_build.c \
- tgsi_dump.c \
- tgsi_exec.c \
- tgsi_info.c \
- tgsi_iterate.c \
- tgsi_parse.c \
- tgsi_ppc.c \
- tgsi_scan.c \
- tgsi_sse2.c \
- tgsi_text.c \
- tgsi_transform.c \
- tgsi_ureg.c \
- tgsi_util.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/tgsi/SConscript b/src/gallium/auxiliary/tgsi/SConscript
deleted file mode 100644
index b6bc2924f0..0000000000
--- a/src/gallium/auxiliary/tgsi/SConscript
+++ /dev/null
@@ -1,23 +0,0 @@
-Import('*')
-
-tgsi = env.ConvenienceLibrary(
- target = 'tgsi',
- source = [
- 'tgsi_build.c',
- 'tgsi_dump.c',
- 'tgsi_dump_c.c',
- 'tgsi_exec.c',
- 'tgsi_info.c',
- 'tgsi_iterate.c',
- 'tgsi_parse.c',
- 'tgsi_sanity.c',
- 'tgsi_scan.c',
- 'tgsi_ppc.c',
- 'tgsi_sse2.c',
- 'tgsi_text.c',
- 'tgsi_transform.c',
- 'tgsi_ureg.c',
- 'tgsi_util.c',
- ])
-
-auxiliaries.insert(0, tgsi)
diff --git a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt
index eb492076b7..080fd4c731 100644
--- a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt
+++ b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt
@@ -1129,3 +1129,35 @@ TGSI Instruction Specification
target Label of target instruction.
+
+3 Other tokens
+===============
+
+
+3.1 Declaration Semantic
+-------------------------
+
+
+ Follows Declaration token if Semantic bit is set.
+
+ Since its purpose is to link a shader with other stages of the pipeline,
+ it is valid to follow only those Declaration tokens that declare a register
+ either in INPUT or OUTPUT file.
+
+ SemanticName field contains the semantic name of the register being declared.
+ There is no default value.
+
+ SemanticIndex is an optional subscript that can be used to distinguish
+ different register declarations with the same semantic name. The default value
+ is 0.
+
+ The meanings of the individual semantic names are explained in the following
+ sections.
+
+
+3.1.1 FACE
+
+ Valid only in a fragment shader INPUT declaration.
+
+ FACE.x is negative when the primitive is back facing. FACE.x is positive
+ when the primitive is front facing.
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index e0cfc54420..de9cbc8630 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -30,21 +30,6 @@
#include "tgsi_build.h"
#include "tgsi_parse.h"
-/*
- * version
- */
-
-struct tgsi_version
-tgsi_build_version( void )
-{
- struct tgsi_version version;
-
- version.MajorVersion = 1;
- version.MinorVersion = 1;
- version.Padding = 0;
-
- return version;
-}
/*
* header
@@ -122,7 +107,6 @@ tgsi_default_declaration( void )
declaration.Centroid = 0;
declaration.Invariant = 0;
declaration.Padding = 0;
- declaration.Extended = 0;
return declaration;
}
@@ -173,7 +157,7 @@ tgsi_default_full_declaration( void )
struct tgsi_full_declaration full_declaration;
full_declaration.Declaration = tgsi_default_declaration();
- full_declaration.DeclarationRange = tgsi_default_declaration_range();
+ full_declaration.Range = tgsi_default_declaration_range();
full_declaration.Semantic = tgsi_default_declaration_semantic();
return full_declaration;
@@ -210,8 +194,8 @@ tgsi_build_full_declaration(
size++;
*dr = tgsi_build_declaration_range(
- full_decl->DeclarationRange.First,
- full_decl->DeclarationRange.Last,
+ full_decl->Range.First,
+ full_decl->Range.Last,
declaration,
header );
@@ -224,8 +208,8 @@ tgsi_build_full_declaration(
size++;
*ds = tgsi_build_declaration_semantic(
- full_decl->Semantic.SemanticName,
- full_decl->Semantic.SemanticIndex,
+ full_decl->Semantic.Name,
+ full_decl->Semantic.Index,
declaration,
header );
}
@@ -270,8 +254,8 @@ tgsi_default_declaration_semantic( void )
{
struct tgsi_declaration_semantic ds;
- ds.SemanticName = TGSI_SEMANTIC_POSITION;
- ds.SemanticIndex = 0;
+ ds.Name = TGSI_SEMANTIC_POSITION;
+ ds.Index = 0;
ds.Padding = 0;
return ds;
@@ -290,8 +274,8 @@ tgsi_build_declaration_semantic(
assert( semantic_index <= 0xFFFF );
ds = tgsi_default_declaration_semantic();
- ds.SemanticName = semantic_name;
- ds.SemanticIndex = semantic_index;
+ ds.Name = semantic_name;
+ ds.Index = semantic_index;
declaration_grow( declaration, header );
@@ -311,7 +295,6 @@ tgsi_default_immediate( void )
immediate.NrTokens = 1;
immediate.DataType = TGSI_IMM_FLOAT32;
immediate.Padding = 0;
- immediate.Extended = 0;
return immediate;
}
@@ -416,24 +399,26 @@ tgsi_default_instruction( void )
struct tgsi_instruction instruction;
instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
- instruction.NrTokens = 1;
+ instruction.NrTokens = 0;
instruction.Opcode = TGSI_OPCODE_MOV;
instruction.Saturate = TGSI_SAT_NONE;
+ instruction.Predicate = 0;
instruction.NumDstRegs = 1;
instruction.NumSrcRegs = 1;
+ instruction.Label = 0;
+ instruction.Texture = 0;
instruction.Padding = 0;
- instruction.Extended = 0;
return instruction;
}
struct tgsi_instruction
-tgsi_build_instruction(
- unsigned opcode,
- unsigned saturate,
- unsigned num_dst_regs,
- unsigned num_src_regs,
- struct tgsi_header *header )
+tgsi_build_instruction(unsigned opcode,
+ unsigned saturate,
+ unsigned predicate,
+ unsigned num_dst_regs,
+ unsigned num_src_regs,
+ struct tgsi_header *header)
{
struct tgsi_instruction instruction;
@@ -445,6 +430,7 @@ tgsi_build_instruction(
instruction = tgsi_default_instruction();
instruction.Opcode = opcode;
instruction.Saturate = saturate;
+ instruction.Predicate = predicate;
instruction.NumDstRegs = num_dst_regs;
instruction.NumSrcRegs = num_src_regs;
@@ -472,18 +458,16 @@ tgsi_default_full_instruction( void )
unsigned i;
full_instruction.Instruction = tgsi_default_instruction();
- full_instruction.InstructionExtNv = tgsi_default_instruction_ext_nv();
- full_instruction.InstructionExtLabel = tgsi_default_instruction_ext_label();
- full_instruction.InstructionExtTexture = tgsi_default_instruction_ext_texture();
+ full_instruction.Predicate = tgsi_default_instruction_predicate();
+ full_instruction.Label = tgsi_default_instruction_label();
+ full_instruction.Texture = tgsi_default_instruction_texture();
for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) {
- full_instruction.FullDstRegisters[i] = tgsi_default_full_dst_register();
+ full_instruction.Dst[i] = tgsi_default_full_dst_register();
}
for( i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) {
- full_instruction.FullSrcRegisters[i] = tgsi_default_full_src_register();
+ full_instruction.Src[i] = tgsi_default_full_src_register();
}
- full_instruction.Flags = 0x0;
-
return full_instruction;
}
@@ -504,82 +488,70 @@ tgsi_build_full_instruction(
instruction = (struct tgsi_instruction *) &tokens[size];
size++;
- *instruction = tgsi_build_instruction(
- full_inst->Instruction.Opcode,
- full_inst->Instruction.Saturate,
- full_inst->Instruction.NumDstRegs,
- full_inst->Instruction.NumSrcRegs,
- header );
+ *instruction = tgsi_build_instruction(full_inst->Instruction.Opcode,
+ full_inst->Instruction.Saturate,
+ full_inst->Instruction.Predicate,
+ full_inst->Instruction.NumDstRegs,
+ full_inst->Instruction.NumSrcRegs,
+ header);
prev_token = (struct tgsi_token *) instruction;
- if( tgsi_compare_instruction_ext_nv(
- full_inst->InstructionExtNv,
- tgsi_default_instruction_ext_nv() ) ) {
- struct tgsi_instruction_ext_nv *instruction_ext_nv;
+ if (full_inst->Instruction.Predicate) {
+ struct tgsi_instruction_predicate *instruction_predicate;
- if( maxsize <= size )
+ if (maxsize <= size) {
return 0;
- instruction_ext_nv =
- (struct tgsi_instruction_ext_nv *) &tokens[size];
+ }
+ instruction_predicate = (struct tgsi_instruction_predicate *)&tokens[size];
size++;
- *instruction_ext_nv = tgsi_build_instruction_ext_nv(
- full_inst->InstructionExtNv.Precision,
- full_inst->InstructionExtNv.CondDstIndex,
- full_inst->InstructionExtNv.CondFlowIndex,
- full_inst->InstructionExtNv.CondMask,
- full_inst->InstructionExtNv.CondSwizzleX,
- full_inst->InstructionExtNv.CondSwizzleY,
- full_inst->InstructionExtNv.CondSwizzleZ,
- full_inst->InstructionExtNv.CondSwizzleW,
- full_inst->InstructionExtNv.CondDstUpdate,
- full_inst->InstructionExtNv.CondFlowEnable,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) instruction_ext_nv;
+ *instruction_predicate =
+ tgsi_build_instruction_predicate(full_inst->Predicate.Index,
+ full_inst->Predicate.Negate,
+ full_inst->Predicate.SwizzleX,
+ full_inst->Predicate.SwizzleY,
+ full_inst->Predicate.SwizzleZ,
+ full_inst->Predicate.SwizzleW,
+ instruction,
+ header);
}
- if( tgsi_compare_instruction_ext_label(
- full_inst->InstructionExtLabel,
- tgsi_default_instruction_ext_label() ) ) {
- struct tgsi_instruction_ext_label *instruction_ext_label;
+ if (full_inst->Instruction.Label) {
+ struct tgsi_instruction_label *instruction_label;
if( maxsize <= size )
return 0;
- instruction_ext_label =
- (struct tgsi_instruction_ext_label *) &tokens[size];
+ instruction_label =
+ (struct tgsi_instruction_label *) &tokens[size];
size++;
- *instruction_ext_label = tgsi_build_instruction_ext_label(
- full_inst->InstructionExtLabel.Label,
+ *instruction_label = tgsi_build_instruction_label(
+ full_inst->Label.Label,
prev_token,
instruction,
header );
- prev_token = (struct tgsi_token *) instruction_ext_label;
+ prev_token = (struct tgsi_token *) instruction_label;
}
- if( tgsi_compare_instruction_ext_texture(
- full_inst->InstructionExtTexture,
- tgsi_default_instruction_ext_texture() ) ) {
- struct tgsi_instruction_ext_texture *instruction_ext_texture;
+ if (full_inst->Instruction.Texture) {
+ struct tgsi_instruction_texture *instruction_texture;
if( maxsize <= size )
return 0;
- instruction_ext_texture =
- (struct tgsi_instruction_ext_texture *) &tokens[size];
+ instruction_texture =
+ (struct tgsi_instruction_texture *) &tokens[size];
size++;
- *instruction_ext_texture = tgsi_build_instruction_ext_texture(
- full_inst->InstructionExtTexture.Texture,
+ *instruction_texture = tgsi_build_instruction_texture(
+ full_inst->Texture.Texture,
prev_token,
instruction,
header );
- prev_token = (struct tgsi_token *) instruction_ext_texture;
+ prev_token = (struct tgsi_token *) instruction_texture;
}
for( i = 0; i < full_inst->Instruction.NumDstRegs; i++ ) {
- const struct tgsi_full_dst_register *reg = &full_inst->FullDstRegisters[i];
+ const struct tgsi_full_dst_register *reg = &full_inst->Dst[i];
struct tgsi_dst_register *dst_register;
struct tgsi_token *prev_token;
@@ -589,58 +561,15 @@ tgsi_build_full_instruction(
size++;
*dst_register = tgsi_build_dst_register(
- reg->DstRegister.File,
- reg->DstRegister.WriteMask,
- reg->DstRegister.Indirect,
- reg->DstRegister.Index,
+ reg->Register.File,
+ reg->Register.WriteMask,
+ reg->Register.Indirect,
+ reg->Register.Index,
instruction,
header );
prev_token = (struct tgsi_token *) dst_register;
- if( tgsi_compare_dst_register_ext_concode(
- reg->DstRegisterExtConcode,
- tgsi_default_dst_register_ext_concode() ) ) {
- struct tgsi_dst_register_ext_concode *dst_register_ext_concode;
-
- if( maxsize <= size )
- return 0;
- dst_register_ext_concode =
- (struct tgsi_dst_register_ext_concode *) &tokens[size];
- size++;
-
- *dst_register_ext_concode = tgsi_build_dst_register_ext_concode(
- reg->DstRegisterExtConcode.CondMask,
- reg->DstRegisterExtConcode.CondSwizzleX,
- reg->DstRegisterExtConcode.CondSwizzleY,
- reg->DstRegisterExtConcode.CondSwizzleZ,
- reg->DstRegisterExtConcode.CondSwizzleW,
- reg->DstRegisterExtConcode.CondSrcIndex,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) dst_register_ext_concode;
- }
-
- if( tgsi_compare_dst_register_ext_modulate(
- reg->DstRegisterExtModulate,
- tgsi_default_dst_register_ext_modulate() ) ) {
- struct tgsi_dst_register_ext_modulate *dst_register_ext_modulate;
-
- if( maxsize <= size )
- return 0;
- dst_register_ext_modulate =
- (struct tgsi_dst_register_ext_modulate *) &tokens[size];
- size++;
-
- *dst_register_ext_modulate = tgsi_build_dst_register_ext_modulate(
- reg->DstRegisterExtModulate.Modulate,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) dst_register_ext_modulate;
- }
-
- if( reg->DstRegister.Indirect ) {
+ if( reg->Register.Indirect ) {
struct tgsi_src_register *ind;
if( maxsize <= size )
@@ -649,22 +578,23 @@ tgsi_build_full_instruction(
size++;
*ind = tgsi_build_src_register(
- reg->DstRegisterInd.File,
- reg->DstRegisterInd.SwizzleX,
- reg->DstRegisterInd.SwizzleY,
- reg->DstRegisterInd.SwizzleZ,
- reg->DstRegisterInd.SwizzleW,
- reg->DstRegisterInd.Negate,
- reg->DstRegisterInd.Indirect,
- reg->DstRegisterInd.Dimension,
- reg->DstRegisterInd.Index,
+ reg->Indirect.File,
+ reg->Indirect.SwizzleX,
+ reg->Indirect.SwizzleY,
+ reg->Indirect.SwizzleZ,
+ reg->Indirect.SwizzleW,
+ reg->Indirect.Negate,
+ reg->Indirect.Absolute,
+ reg->Indirect.Indirect,
+ reg->Indirect.Dimension,
+ reg->Indirect.Index,
instruction,
header );
}
}
for( i = 0; i < full_inst->Instruction.NumSrcRegs; i++ ) {
- const struct tgsi_full_src_register *reg = &full_inst->FullSrcRegisters[i];
+ const struct tgsi_full_src_register *reg = &full_inst->Src[i];
struct tgsi_src_register *src_register;
struct tgsi_token *prev_token;
@@ -674,77 +604,21 @@ tgsi_build_full_instruction(
size++;
*src_register = tgsi_build_src_register(
- reg->SrcRegister.File,
- reg->SrcRegister.SwizzleX,
- reg->SrcRegister.SwizzleY,
- reg->SrcRegister.SwizzleZ,
- reg->SrcRegister.SwizzleW,
- reg->SrcRegister.Negate,
- reg->SrcRegister.Indirect,
- reg->SrcRegister.Dimension,
- reg->SrcRegister.Index,
+ reg->Register.File,
+ reg->Register.SwizzleX,
+ reg->Register.SwizzleY,
+ reg->Register.SwizzleZ,
+ reg->Register.SwizzleW,
+ reg->Register.Negate,
+ reg->Register.Absolute,
+ reg->Register.Indirect,
+ reg->Register.Dimension,
+ reg->Register.Index,
instruction,
header );
prev_token = (struct tgsi_token *) src_register;
- if( tgsi_compare_src_register_ext_swz(
- reg->SrcRegisterExtSwz,
- tgsi_default_src_register_ext_swz() ) ) {
- struct tgsi_src_register_ext_swz *src_register_ext_swz;
-
- /* Use of the extended swizzle requires the simple swizzle to be identity.
- */
- assert( reg->SrcRegister.SwizzleX == TGSI_SWIZZLE_X );
- assert( reg->SrcRegister.SwizzleY == TGSI_SWIZZLE_Y );
- assert( reg->SrcRegister.SwizzleZ == TGSI_SWIZZLE_Z );
- assert( reg->SrcRegister.SwizzleW == TGSI_SWIZZLE_W );
- assert( reg->SrcRegister.Negate == FALSE );
-
- if( maxsize <= size )
- return 0;
- src_register_ext_swz =
- (struct tgsi_src_register_ext_swz *) &tokens[size];
- size++;
-
- *src_register_ext_swz = tgsi_build_src_register_ext_swz(
- reg->SrcRegisterExtSwz.ExtSwizzleX,
- reg->SrcRegisterExtSwz.ExtSwizzleY,
- reg->SrcRegisterExtSwz.ExtSwizzleZ,
- reg->SrcRegisterExtSwz.ExtSwizzleW,
- reg->SrcRegisterExtSwz.NegateX,
- reg->SrcRegisterExtSwz.NegateY,
- reg->SrcRegisterExtSwz.NegateZ,
- reg->SrcRegisterExtSwz.NegateW,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) src_register_ext_swz;
- }
-
- if( tgsi_compare_src_register_ext_mod(
- reg->SrcRegisterExtMod,
- tgsi_default_src_register_ext_mod() ) ) {
- struct tgsi_src_register_ext_mod *src_register_ext_mod;
-
- if( maxsize <= size )
- return 0;
- src_register_ext_mod =
- (struct tgsi_src_register_ext_mod *) &tokens[size];
- size++;
-
- *src_register_ext_mod = tgsi_build_src_register_ext_mod(
- reg->SrcRegisterExtMod.Complement,
- reg->SrcRegisterExtMod.Bias,
- reg->SrcRegisterExtMod.Scale2X,
- reg->SrcRegisterExtMod.Absolute,
- reg->SrcRegisterExtMod.Negate,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) src_register_ext_mod;
- }
-
- if( reg->SrcRegister.Indirect ) {
+ if( reg->Register.Indirect ) {
struct tgsi_src_register *ind;
if( maxsize <= size )
@@ -753,23 +627,24 @@ tgsi_build_full_instruction(
size++;
*ind = tgsi_build_src_register(
- reg->SrcRegisterInd.File,
- reg->SrcRegisterInd.SwizzleX,
- reg->SrcRegisterInd.SwizzleY,
- reg->SrcRegisterInd.SwizzleZ,
- reg->SrcRegisterInd.SwizzleW,
- reg->SrcRegisterInd.Negate,
- reg->SrcRegisterInd.Indirect,
- reg->SrcRegisterInd.Dimension,
- reg->SrcRegisterInd.Index,
+ reg->Indirect.File,
+ reg->Indirect.SwizzleX,
+ reg->Indirect.SwizzleY,
+ reg->Indirect.SwizzleZ,
+ reg->Indirect.SwizzleW,
+ reg->Indirect.Negate,
+ reg->Indirect.Absolute,
+ reg->Indirect.Indirect,
+ reg->Indirect.Dimension,
+ reg->Indirect.Index,
instruction,
header );
}
- if( reg->SrcRegister.Dimension ) {
+ if( reg->Register.Dimension ) {
struct tgsi_dimension *dim;
- assert( !reg->SrcRegisterDim.Dimension );
+ assert( !reg->Dimension.Dimension );
if( maxsize <= size )
return 0;
@@ -777,12 +652,12 @@ tgsi_build_full_instruction(
size++;
*dim = tgsi_build_dimension(
- reg->SrcRegisterDim.Indirect,
- reg->SrcRegisterDim.Index,
+ reg->Dimension.Indirect,
+ reg->Dimension.Index,
instruction,
header );
- if( reg->SrcRegisterDim.Indirect ) {
+ if( reg->Dimension.Indirect ) {
struct tgsi_src_register *ind;
if( maxsize <= size )
@@ -791,15 +666,16 @@ tgsi_build_full_instruction(
size++;
*ind = tgsi_build_src_register(
- reg->SrcRegisterDimInd.File,
- reg->SrcRegisterDimInd.SwizzleX,
- reg->SrcRegisterDimInd.SwizzleY,
- reg->SrcRegisterDimInd.SwizzleZ,
- reg->SrcRegisterDimInd.SwizzleW,
- reg->SrcRegisterDimInd.Negate,
- reg->SrcRegisterDimInd.Indirect,
- reg->SrcRegisterDimInd.Dimension,
- reg->SrcRegisterDimInd.Index,
+ reg->DimIndirect.File,
+ reg->DimIndirect.SwizzleX,
+ reg->DimIndirect.SwizzleY,
+ reg->DimIndirect.SwizzleZ,
+ reg->DimIndirect.SwizzleW,
+ reg->DimIndirect.Negate,
+ reg->DimIndirect.Absolute,
+ reg->DimIndirect.Indirect,
+ reg->DimIndirect.Dimension,
+ reg->DimIndirect.Index,
instruction,
header );
}
@@ -809,163 +685,103 @@ tgsi_build_full_instruction(
return size;
}
-struct tgsi_instruction_ext_nv
-tgsi_default_instruction_ext_nv( void )
+struct tgsi_instruction_predicate
+tgsi_default_instruction_predicate(void)
{
- struct tgsi_instruction_ext_nv instruction_ext_nv;
-
- instruction_ext_nv.Type = TGSI_INSTRUCTION_EXT_TYPE_NV;
- instruction_ext_nv.Precision = TGSI_PRECISION_DEFAULT;
- instruction_ext_nv.CondDstIndex = 0;
- instruction_ext_nv.CondFlowIndex = 0;
- instruction_ext_nv.CondMask = TGSI_CC_TR;
- instruction_ext_nv.CondSwizzleX = TGSI_SWIZZLE_X;
- instruction_ext_nv.CondSwizzleY = TGSI_SWIZZLE_Y;
- instruction_ext_nv.CondSwizzleZ = TGSI_SWIZZLE_Z;
- instruction_ext_nv.CondSwizzleW = TGSI_SWIZZLE_W;
- instruction_ext_nv.CondDstUpdate = 0;
- instruction_ext_nv.CondFlowEnable = 0;
- instruction_ext_nv.Padding = 0;
- instruction_ext_nv.Extended = 0;
-
- return instruction_ext_nv;
-}
+ struct tgsi_instruction_predicate instruction_predicate;
+ instruction_predicate.SwizzleX = TGSI_SWIZZLE_X;
+ instruction_predicate.SwizzleY = TGSI_SWIZZLE_Y;
+ instruction_predicate.SwizzleZ = TGSI_SWIZZLE_Z;
+ instruction_predicate.SwizzleW = TGSI_SWIZZLE_W;
+ instruction_predicate.Negate = 0;
+ instruction_predicate.Index = 0;
+ instruction_predicate.Padding = 0;
-/** test for inequality of 32-bit values pointed to by a and b */
-static INLINE boolean
-compare32(const void *a, const void *b)
-{
- return *((uint32_t *) a) != *((uint32_t *) b);
+ return instruction_predicate;
}
-
-unsigned
-tgsi_compare_instruction_ext_nv(
- struct tgsi_instruction_ext_nv a,
- struct tgsi_instruction_ext_nv b )
+struct tgsi_instruction_predicate
+tgsi_build_instruction_predicate(int index,
+ unsigned negate,
+ unsigned swizzleX,
+ unsigned swizzleY,
+ unsigned swizzleZ,
+ unsigned swizzleW,
+ struct tgsi_instruction *instruction,
+ struct tgsi_header *header)
{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
-}
+ struct tgsi_instruction_predicate instruction_predicate;
-struct tgsi_instruction_ext_nv
-tgsi_build_instruction_ext_nv(
- unsigned precision,
- unsigned cond_dst_index,
- unsigned cond_flow_index,
- unsigned cond_mask,
- unsigned cond_swizzle_x,
- unsigned cond_swizzle_y,
- unsigned cond_swizzle_z,
- unsigned cond_swizzle_w,
- unsigned cond_dst_update,
- unsigned cond_flow_enable,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_instruction_ext_nv instruction_ext_nv;
-
- instruction_ext_nv = tgsi_default_instruction_ext_nv();
- instruction_ext_nv.Precision = precision;
- instruction_ext_nv.CondDstIndex = cond_dst_index;
- instruction_ext_nv.CondFlowIndex = cond_flow_index;
- instruction_ext_nv.CondMask = cond_mask;
- instruction_ext_nv.CondSwizzleX = cond_swizzle_x;
- instruction_ext_nv.CondSwizzleY = cond_swizzle_y;
- instruction_ext_nv.CondSwizzleZ = cond_swizzle_z;
- instruction_ext_nv.CondSwizzleW = cond_swizzle_w;
- instruction_ext_nv.CondDstUpdate = cond_dst_update;
- instruction_ext_nv.CondFlowEnable = cond_flow_enable;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
+ instruction_predicate = tgsi_default_instruction_predicate();
+ instruction_predicate.SwizzleX = swizzleX;
+ instruction_predicate.SwizzleY = swizzleY;
+ instruction_predicate.SwizzleZ = swizzleZ;
+ instruction_predicate.SwizzleW = swizzleW;
+ instruction_predicate.Negate = negate;
+ instruction_predicate.Index = index;
+
+ instruction_grow(instruction, header);
- return instruction_ext_nv;
+ return instruction_predicate;
}
-struct tgsi_instruction_ext_label
-tgsi_default_instruction_ext_label( void )
+struct tgsi_instruction_label
+tgsi_default_instruction_label( void )
{
- struct tgsi_instruction_ext_label instruction_ext_label;
+ struct tgsi_instruction_label instruction_label;
- instruction_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
- instruction_ext_label.Label = 0;
- instruction_ext_label.Padding = 0;
- instruction_ext_label.Extended = 0;
-
- return instruction_ext_label;
-}
+ instruction_label.Label = 0;
+ instruction_label.Padding = 0;
-unsigned
-tgsi_compare_instruction_ext_label(
- struct tgsi_instruction_ext_label a,
- struct tgsi_instruction_ext_label b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
+ return instruction_label;
}
-struct tgsi_instruction_ext_label
-tgsi_build_instruction_ext_label(
+struct tgsi_instruction_label
+tgsi_build_instruction_label(
unsigned label,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
{
- struct tgsi_instruction_ext_label instruction_ext_label;
+ struct tgsi_instruction_label instruction_label;
- instruction_ext_label = tgsi_default_instruction_ext_label();
- instruction_ext_label.Label = label;
+ instruction_label = tgsi_default_instruction_label();
+ instruction_label.Label = label;
+ instruction->Label = 1;
- prev_token->Extended = 1;
instruction_grow( instruction, header );
- return instruction_ext_label;
+ return instruction_label;
}
-struct tgsi_instruction_ext_texture
-tgsi_default_instruction_ext_texture( void )
+struct tgsi_instruction_texture
+tgsi_default_instruction_texture( void )
{
- struct tgsi_instruction_ext_texture instruction_ext_texture;
+ struct tgsi_instruction_texture instruction_texture;
- instruction_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
- instruction_ext_texture.Texture = TGSI_TEXTURE_UNKNOWN;
- instruction_ext_texture.Padding = 0;
- instruction_ext_texture.Extended = 0;
+ instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
+ instruction_texture.Padding = 0;
- return instruction_ext_texture;
-}
-
-unsigned
-tgsi_compare_instruction_ext_texture(
- struct tgsi_instruction_ext_texture a,
- struct tgsi_instruction_ext_texture b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
+ return instruction_texture;
}
-struct tgsi_instruction_ext_texture
-tgsi_build_instruction_ext_texture(
+struct tgsi_instruction_texture
+tgsi_build_instruction_texture(
unsigned texture,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
{
- struct tgsi_instruction_ext_texture instruction_ext_texture;
+ struct tgsi_instruction_texture instruction_texture;
- instruction_ext_texture = tgsi_default_instruction_ext_texture();
- instruction_ext_texture.Texture = texture;
+ instruction_texture = tgsi_default_instruction_texture();
+ instruction_texture.Texture = texture;
+ instruction->Texture = 1;
- prev_token->Extended = 1;
instruction_grow( instruction, header );
- return instruction_ext_texture;
+ return instruction_texture;
}
struct tgsi_src_register
@@ -979,10 +795,10 @@ tgsi_default_src_register( void )
src_register.SwizzleZ = TGSI_SWIZZLE_Z;
src_register.SwizzleW = TGSI_SWIZZLE_W;
src_register.Negate = 0;
+ src_register.Absolute = 0;
src_register.Indirect = 0;
src_register.Dimension = 0;
src_register.Index = 0;
- src_register.Extended = 0;
return src_register;
}
@@ -995,6 +811,7 @@ tgsi_build_src_register(
unsigned swizzle_z,
unsigned swizzle_w,
unsigned negate,
+ unsigned absolute,
unsigned indirect,
unsigned dimension,
int index,
@@ -1018,6 +835,7 @@ tgsi_build_src_register(
src_register.SwizzleZ = swizzle_z;
src_register.SwizzleW = swizzle_w;
src_register.Negate = negate;
+ src_register.Absolute = absolute;
src_register.Indirect = indirect;
src_register.Dimension = dimension;
src_register.Index = index;
@@ -1032,145 +850,14 @@ tgsi_default_full_src_register( void )
{
struct tgsi_full_src_register full_src_register;
- full_src_register.SrcRegister = tgsi_default_src_register();
- full_src_register.SrcRegisterExtSwz = tgsi_default_src_register_ext_swz();
- full_src_register.SrcRegisterExtMod = tgsi_default_src_register_ext_mod();
- full_src_register.SrcRegisterInd = tgsi_default_src_register();
- full_src_register.SrcRegisterDim = tgsi_default_dimension();
- full_src_register.SrcRegisterDimInd = tgsi_default_src_register();
+ full_src_register.Register = tgsi_default_src_register();
+ full_src_register.Indirect = tgsi_default_src_register();
+ full_src_register.Dimension = tgsi_default_dimension();
+ full_src_register.DimIndirect = tgsi_default_src_register();
return full_src_register;
}
-struct tgsi_src_register_ext_swz
-tgsi_default_src_register_ext_swz( void )
-{
- struct tgsi_src_register_ext_swz src_register_ext_swz;
-
- src_register_ext_swz.Type = TGSI_SRC_REGISTER_EXT_TYPE_SWZ;
- src_register_ext_swz.ExtSwizzleX = TGSI_EXTSWIZZLE_X;
- src_register_ext_swz.ExtSwizzleY = TGSI_EXTSWIZZLE_Y;
- src_register_ext_swz.ExtSwizzleZ = TGSI_EXTSWIZZLE_Z;
- src_register_ext_swz.ExtSwizzleW = TGSI_EXTSWIZZLE_W;
- src_register_ext_swz.NegateX = 0;
- src_register_ext_swz.NegateY = 0;
- src_register_ext_swz.NegateZ = 0;
- src_register_ext_swz.NegateW = 0;
- src_register_ext_swz.Padding = 0;
- src_register_ext_swz.Extended = 0;
-
- return src_register_ext_swz;
-}
-
-unsigned
-tgsi_compare_src_register_ext_swz(
- struct tgsi_src_register_ext_swz a,
- struct tgsi_src_register_ext_swz b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
-}
-
-struct tgsi_src_register_ext_swz
-tgsi_build_src_register_ext_swz(
- unsigned ext_swizzle_x,
- unsigned ext_swizzle_y,
- unsigned ext_swizzle_z,
- unsigned ext_swizzle_w,
- unsigned negate_x,
- unsigned negate_y,
- unsigned negate_z,
- unsigned negate_w,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_src_register_ext_swz src_register_ext_swz;
-
- assert( ext_swizzle_x <= TGSI_EXTSWIZZLE_ONE );
- assert( ext_swizzle_y <= TGSI_EXTSWIZZLE_ONE );
- assert( ext_swizzle_z <= TGSI_EXTSWIZZLE_ONE );
- assert( ext_swizzle_w <= TGSI_EXTSWIZZLE_ONE );
- assert( negate_x <= 1 );
- assert( negate_y <= 1 );
- assert( negate_z <= 1 );
- assert( negate_w <= 1 );
-
- src_register_ext_swz = tgsi_default_src_register_ext_swz();
- src_register_ext_swz.ExtSwizzleX = ext_swizzle_x;
- src_register_ext_swz.ExtSwizzleY = ext_swizzle_y;
- src_register_ext_swz.ExtSwizzleZ = ext_swizzle_z;
- src_register_ext_swz.ExtSwizzleW = ext_swizzle_w;
- src_register_ext_swz.NegateX = negate_x;
- src_register_ext_swz.NegateY = negate_y;
- src_register_ext_swz.NegateZ = negate_z;
- src_register_ext_swz.NegateW = negate_w;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return src_register_ext_swz;
-}
-
-struct tgsi_src_register_ext_mod
-tgsi_default_src_register_ext_mod( void )
-{
- struct tgsi_src_register_ext_mod src_register_ext_mod;
-
- src_register_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
- src_register_ext_mod.Complement = 0;
- src_register_ext_mod.Bias = 0;
- src_register_ext_mod.Scale2X = 0;
- src_register_ext_mod.Absolute = 0;
- src_register_ext_mod.Negate = 0;
- src_register_ext_mod.Padding = 0;
- src_register_ext_mod.Extended = 0;
-
- return src_register_ext_mod;
-}
-
-unsigned
-tgsi_compare_src_register_ext_mod(
- struct tgsi_src_register_ext_mod a,
- struct tgsi_src_register_ext_mod b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
-}
-
-struct tgsi_src_register_ext_mod
-tgsi_build_src_register_ext_mod(
- unsigned complement,
- unsigned bias,
- unsigned scale_2x,
- unsigned absolute,
- unsigned negate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_src_register_ext_mod src_register_ext_mod;
-
- assert( complement <= 1 );
- assert( bias <= 1 );
- assert( scale_2x <= 1 );
- assert( absolute <= 1 );
- assert( negate <= 1 );
-
- src_register_ext_mod = tgsi_default_src_register_ext_mod();
- src_register_ext_mod.Complement = complement;
- src_register_ext_mod.Bias = bias;
- src_register_ext_mod.Scale2X = scale_2x;
- src_register_ext_mod.Absolute = absolute;
- src_register_ext_mod.Negate = negate;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return src_register_ext_mod;
-}
struct tgsi_dimension
tgsi_default_dimension( void )
@@ -1181,7 +868,6 @@ tgsi_default_dimension( void )
dimension.Dimension = 0;
dimension.Padding = 0;
dimension.Index = 0;
- dimension.Extended = 0;
return dimension;
}
@@ -1215,7 +901,6 @@ tgsi_default_dst_register( void )
dst_register.Dimension = 0;
dst_register.Index = 0;
dst_register.Padding = 0;
- dst_register.Extended = 0;
return dst_register;
}
@@ -1251,118 +936,113 @@ tgsi_default_full_dst_register( void )
{
struct tgsi_full_dst_register full_dst_register;
- full_dst_register.DstRegister = tgsi_default_dst_register();
- full_dst_register.DstRegisterInd = tgsi_default_src_register();
- full_dst_register.DstRegisterExtConcode =
- tgsi_default_dst_register_ext_concode();
- full_dst_register.DstRegisterExtModulate =
- tgsi_default_dst_register_ext_modulate();
+ full_dst_register.Register = tgsi_default_dst_register();
+ full_dst_register.Indirect = tgsi_default_src_register();
return full_dst_register;
}
-struct tgsi_dst_register_ext_concode
-tgsi_default_dst_register_ext_concode( void )
+struct tgsi_property
+tgsi_default_property( void )
{
- struct tgsi_dst_register_ext_concode dst_register_ext_concode;
-
- dst_register_ext_concode.Type = TGSI_DST_REGISTER_EXT_TYPE_CONDCODE;
- dst_register_ext_concode.CondMask = TGSI_CC_TR;
- dst_register_ext_concode.CondSwizzleX = TGSI_SWIZZLE_X;
- dst_register_ext_concode.CondSwizzleY = TGSI_SWIZZLE_Y;
- dst_register_ext_concode.CondSwizzleZ = TGSI_SWIZZLE_Z;
- dst_register_ext_concode.CondSwizzleW = TGSI_SWIZZLE_W;
- dst_register_ext_concode.CondSrcIndex = 0;
- dst_register_ext_concode.Padding = 0;
- dst_register_ext_concode.Extended = 0;
-
- return dst_register_ext_concode;
+ struct tgsi_property property;
+
+ property.Type = TGSI_TOKEN_TYPE_PROPERTY;
+ property.NrTokens = 1;
+ property.PropertyName = TGSI_PROPERTY_GS_INPUT_PRIM;
+ property.Padding = 0;
+
+ return property;
}
-unsigned
-tgsi_compare_dst_register_ext_concode(
- struct tgsi_dst_register_ext_concode a,
- struct tgsi_dst_register_ext_concode b )
+struct tgsi_property
+tgsi_build_property(unsigned property_name,
+ struct tgsi_header *header)
{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
+ struct tgsi_property property;
+
+ property = tgsi_default_property();
+ property.PropertyName = property_name;
+
+ header_bodysize_grow( header );
+
+ return property;
}
-struct tgsi_dst_register_ext_concode
-tgsi_build_dst_register_ext_concode(
- unsigned cc,
- unsigned swizzle_x,
- unsigned swizzle_y,
- unsigned swizzle_z,
- unsigned swizzle_w,
- int index,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
+
+struct tgsi_full_property
+tgsi_default_full_property( void )
{
- struct tgsi_dst_register_ext_concode dst_register_ext_concode;
+ struct tgsi_full_property full_property;
- assert( cc <= TGSI_CC_FL );
- assert( swizzle_x <= TGSI_SWIZZLE_W );
- assert( swizzle_y <= TGSI_SWIZZLE_W );
- assert( swizzle_z <= TGSI_SWIZZLE_W );
- assert( swizzle_w <= TGSI_SWIZZLE_W );
- assert( index >= -32768 && index <= 32767 );
+ full_property.Property = tgsi_default_property();
+ memset(full_property.u, 0,
+ sizeof(struct tgsi_property_data) * 8);
- dst_register_ext_concode = tgsi_default_dst_register_ext_concode();
- dst_register_ext_concode.CondMask = cc;
- dst_register_ext_concode.CondSwizzleX = swizzle_x;
- dst_register_ext_concode.CondSwizzleY = swizzle_y;
- dst_register_ext_concode.CondSwizzleZ = swizzle_z;
- dst_register_ext_concode.CondSwizzleW = swizzle_w;
- dst_register_ext_concode.CondSrcIndex = index;
+ return full_property;
+}
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
+static void
+property_grow(
+ struct tgsi_property *property,
+ struct tgsi_header *header )
+{
+ assert( property->NrTokens < 0xFF );
- return dst_register_ext_concode;
+ property->NrTokens++;
+
+ header_bodysize_grow( header );
}
-struct tgsi_dst_register_ext_modulate
-tgsi_default_dst_register_ext_modulate( void )
+struct tgsi_property_data
+tgsi_build_property_data(
+ unsigned value,
+ struct tgsi_property *property,
+ struct tgsi_header *header )
{
- struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
+ struct tgsi_property_data property_data;
+
+ property_data.Data = value;
- dst_register_ext_modulate.Type = TGSI_DST_REGISTER_EXT_TYPE_MODULATE;
- dst_register_ext_modulate.Modulate = TGSI_MODULATE_1X;
- dst_register_ext_modulate.Padding = 0;
- dst_register_ext_modulate.Extended = 0;
+ property_grow( property, header );
- return dst_register_ext_modulate;
+ return property_data;
}
unsigned
-tgsi_compare_dst_register_ext_modulate(
- struct tgsi_dst_register_ext_modulate a,
- struct tgsi_dst_register_ext_modulate b )
+tgsi_build_full_property(
+ const struct tgsi_full_property *full_prop,
+ struct tgsi_token *tokens,
+ struct tgsi_header *header,
+ unsigned maxsize )
{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return compare32(&a, &b);
-}
+ unsigned size = 0, i;
+ struct tgsi_property *property;
-struct tgsi_dst_register_ext_modulate
-tgsi_build_dst_register_ext_modulate(
- unsigned modulate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
+ if( maxsize <= size )
+ return 0;
+ property = (struct tgsi_property *) &tokens[size];
+ size++;
- assert( modulate <= TGSI_MODULATE_EIGHTH );
+ *property = tgsi_build_property(
+ full_prop->Property.PropertyName,
+ header );
- dst_register_ext_modulate = tgsi_default_dst_register_ext_modulate();
- dst_register_ext_modulate.Modulate = modulate;
+ assert( full_prop->Property.NrTokens <= 8 + 1 );
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
+ for( i = 0; i < full_prop->Property.NrTokens - 1; i++ ) {
+ struct tgsi_property_data *data;
+
+ if( maxsize <= size )
+ return 0;
+ data = (struct tgsi_property_data *) &tokens[size];
+ size++;
- return dst_register_ext_modulate;
+ *data = tgsi_build_property_data(
+ full_prop->u[i].Data,
+ property,
+ header );
+ }
+
+ return size;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.h b/src/gallium/auxiliary/tgsi/tgsi_build.h
index 17d977b059..9de2757fe4 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.h
@@ -36,12 +36,6 @@ struct tgsi_token;
extern "C" {
#endif
-/*
- * version
- */
-
-struct tgsi_version
-tgsi_build_version( void );
/*
* header
@@ -133,6 +127,34 @@ tgsi_build_full_immediate(
unsigned maxsize );
/*
+ * properties
+ */
+
+struct tgsi_property
+tgsi_default_property( void );
+
+struct tgsi_property
+tgsi_build_property(
+ unsigned property_name,
+ struct tgsi_header *header );
+
+struct tgsi_full_property
+tgsi_default_full_property( void );
+
+struct tgsi_property_data
+tgsi_build_property_data(
+ unsigned value,
+ struct tgsi_property *property,
+ struct tgsi_header *header );
+
+unsigned
+tgsi_build_full_property(
+ const struct tgsi_full_property *full_prop,
+ struct tgsi_token *tokens,
+ struct tgsi_header *header,
+ unsigned maxsize );
+
+/*
* instruction
*/
@@ -143,6 +165,7 @@ struct tgsi_instruction
tgsi_build_instruction(
unsigned opcode,
unsigned saturate,
+ unsigned predicate,
unsigned num_dst_regs,
unsigned num_src_regs,
struct tgsi_header *header );
@@ -157,55 +180,34 @@ tgsi_build_full_instruction(
struct tgsi_header *header,
unsigned maxsize );
-struct tgsi_instruction_ext_nv
-tgsi_default_instruction_ext_nv( void );
-
-unsigned
-tgsi_compare_instruction_ext_nv(
- struct tgsi_instruction_ext_nv a,
- struct tgsi_instruction_ext_nv b );
-
-struct tgsi_instruction_ext_nv
-tgsi_build_instruction_ext_nv(
- unsigned precision,
- unsigned cond_dst_index,
- unsigned cond_flow_index,
- unsigned cond_mask,
- unsigned cond_swizzle_x,
- unsigned cond_swizzle_y,
- unsigned cond_swizzle_z,
- unsigned cond_swizzle_w,
- unsigned cond_dst_update,
- unsigned cond_flow_enable,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
+struct tgsi_instruction_predicate
+tgsi_default_instruction_predicate(void);
-struct tgsi_instruction_ext_label
-tgsi_default_instruction_ext_label( void );
+struct tgsi_instruction_predicate
+tgsi_build_instruction_predicate(int index,
+ unsigned negate,
+ unsigned swizzleX,
+ unsigned swizzleY,
+ unsigned swizzleZ,
+ unsigned swizzleW,
+ struct tgsi_instruction *instruction,
+ struct tgsi_header *header);
-unsigned
-tgsi_compare_instruction_ext_label(
- struct tgsi_instruction_ext_label a,
- struct tgsi_instruction_ext_label b );
+struct tgsi_instruction_label
+tgsi_default_instruction_label( void );
-struct tgsi_instruction_ext_label
-tgsi_build_instruction_ext_label(
+struct tgsi_instruction_label
+tgsi_build_instruction_label(
unsigned label,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
-struct tgsi_instruction_ext_texture
-tgsi_default_instruction_ext_texture( void );
-
-unsigned
-tgsi_compare_instruction_ext_texture(
- struct tgsi_instruction_ext_texture a,
- struct tgsi_instruction_ext_texture b );
+struct tgsi_instruction_texture
+tgsi_default_instruction_texture( void );
-struct tgsi_instruction_ext_texture
-tgsi_build_instruction_ext_texture(
+struct tgsi_instruction_texture
+tgsi_build_instruction_texture(
unsigned texture,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
@@ -222,6 +224,7 @@ tgsi_build_src_register(
unsigned swizzle_z,
unsigned swizzle_w,
unsigned negate,
+ unsigned absolute,
unsigned indirect,
unsigned dimension,
int index,
@@ -231,46 +234,6 @@ tgsi_build_src_register(
struct tgsi_full_src_register
tgsi_default_full_src_register( void );
-struct tgsi_src_register_ext_swz
-tgsi_default_src_register_ext_swz( void );
-
-unsigned
-tgsi_compare_src_register_ext_swz(
- struct tgsi_src_register_ext_swz a,
- struct tgsi_src_register_ext_swz b );
-
-struct tgsi_src_register_ext_swz
-tgsi_build_src_register_ext_swz(
- unsigned ext_swizzle_x,
- unsigned ext_swizzle_y,
- unsigned ext_swizzle_z,
- unsigned ext_swizzle_w,
- unsigned negate_x,
- unsigned negate_y,
- unsigned negate_z,
- unsigned negate_w,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_src_register_ext_mod
-tgsi_default_src_register_ext_mod( void );
-
-unsigned
-tgsi_compare_src_register_ext_mod(
- struct tgsi_src_register_ext_mod a,
- struct tgsi_src_register_ext_mod b );
-
-struct tgsi_src_register_ext_mod
-tgsi_build_src_register_ext_mod(
- unsigned complement,
- unsigned bias,
- unsigned scale_2x,
- unsigned absolute,
- unsigned negate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
struct tgsi_dimension
tgsi_default_dimension( void );
@@ -297,40 +260,6 @@ tgsi_build_dst_register(
struct tgsi_full_dst_register
tgsi_default_full_dst_register( void );
-struct tgsi_dst_register_ext_concode
-tgsi_default_dst_register_ext_concode( void );
-
-unsigned
-tgsi_compare_dst_register_ext_concode(
- struct tgsi_dst_register_ext_concode a,
- struct tgsi_dst_register_ext_concode b );
-
-struct tgsi_dst_register_ext_concode
-tgsi_build_dst_register_ext_concode(
- unsigned cc,
- unsigned swizzle_x,
- unsigned swizzle_y,
- unsigned swizzle_z,
- unsigned swizzle_w,
- int index,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_dst_register_ext_modulate
-tgsi_default_dst_register_ext_modulate( void );
-
-unsigned
-tgsi_compare_dst_register_ext_modulate(
- struct tgsi_dst_register_ext_modulate a,
- struct tgsi_dst_register_ext_modulate b );
-
-struct tgsi_dst_register_ext_modulate
-tgsi_build_dst_register_ext_modulate(
- unsigned modulate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
#if defined __cplusplus
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 111d95b666..e2e5394f86 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -100,7 +100,9 @@ static const char *file_names[TGSI_FILE_COUNT] =
"SAMP",
"ADDR",
"IMM",
- "LOOP"
+ "LOOP",
+ "PRED",
+ "SV"
};
static const char *interpolate_names[] =
@@ -119,12 +121,16 @@ static const char *semantic_names[] =
"PSIZE",
"GENERIC",
"NORMAL",
- "FACE"
+ "FACE",
+ "EDGEFLAG",
+ "PRIM_ID"
};
static const char *immediate_type_names[] =
{
- "FLT32"
+ "FLT32",
+ "UINT32",
+ "INT32"
};
static const char *swizzle_names[] =
@@ -148,35 +154,42 @@ static const char *texture_names[] =
"SHADOWRECT"
};
-static const char *extswizzle_names[] =
+static const char *property_names[] =
{
- "x",
- "y",
- "z",
- "w",
- "0",
- "1"
+ "GS_INPUT_PRIMITIVE",
+ "GS_OUTPUT_PRIMITIVE",
+ "GS_MAX_OUTPUT_VERTICES"
};
-static const char *modulate_names[TGSI_MODULATE_COUNT] =
+static const char *primitive_names[] =
{
- "",
- "_2X",
- "_4X",
- "_8X",
- "_D2",
- "_D4",
- "_D8"
+ "POINTS",
+ "LINES",
+ "LINE_LOOP",
+ "LINE_STRIP",
+ "TRIANGLES",
+ "TRIANGLE_STRIP",
+ "TRIANGLE_FAN",
+ "QUADS",
+ "QUAD_STRIP",
+ "POLYGON"
};
+
static void
-_dump_register(
+_dump_register_decl(
struct dump_ctx *ctx,
uint file,
int first,
int last )
{
ENM( file, file_names );
+
+ /* all geometry shader inputs are two dimensional */
+ if (file == TGSI_FILE_INPUT &&
+ ctx->iter.processor.Processor == TGSI_PROCESSOR_GEOMETRY)
+ TXT("[]");
+
CHR( '[' );
SID( first );
if (first != last) {
@@ -187,6 +200,52 @@ _dump_register(
}
static void
+_dump_register_dst(
+ struct dump_ctx *ctx,
+ uint file,
+ int index)
+{
+ ENM( file, file_names );
+
+ CHR( '[' );
+ SID( index );
+ CHR( ']' );
+}
+
+
+static void
+_dump_register_src(
+ struct dump_ctx *ctx,
+ const struct tgsi_full_src_register *src )
+{
+ if (src->Register.Indirect) {
+ ENM( src->Register.File, file_names );
+ CHR( '[' );
+ ENM( src->Indirect.File, file_names );
+ CHR( '[' );
+ SID( src->Indirect.Index );
+ TXT( "]." );
+ ENM( src->Indirect.SwizzleX, swizzle_names );
+ if (src->Register.Index != 0) {
+ if (src->Register.Index > 0)
+ CHR( '+' );
+ SID( src->Register.Index );
+ }
+ CHR( ']' );
+ } else {
+ ENM( src->Register.File, file_names );
+ CHR( '[' );
+ SID( src->Register.Index );
+ CHR( ']' );
+ }
+ if (src->Register.Dimension) {
+ CHR( '[' );
+ SID( src->Dimension.Index );
+ CHR( ']' );
+ }
+}
+
+static void
_dump_register_ind(
struct dump_ctx *ctx,
uint file,
@@ -240,22 +299,22 @@ iter_declaration(
TXT( "DCL " );
- _dump_register(
+ _dump_register_decl(
ctx,
decl->Declaration.File,
- decl->DeclarationRange.First,
- decl->DeclarationRange.Last );
+ decl->Range.First,
+ decl->Range.Last );
_dump_writemask(
ctx,
decl->Declaration.UsageMask );
if (decl->Declaration.Semantic) {
TXT( ", " );
- ENM( decl->Semantic.SemanticName, semantic_names );
- if (decl->Semantic.SemanticIndex != 0 ||
- decl->Semantic.SemanticName == TGSI_SEMANTIC_GENERIC) {
+ ENM( decl->Semantic.Name, semantic_names );
+ if (decl->Semantic.Index != 0 ||
+ decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
CHR( '[' );
- UID( decl->Semantic.SemanticIndex );
+ UID( decl->Semantic.Index );
CHR( ']' );
}
}
@@ -292,6 +351,50 @@ tgsi_dump_declaration(
}
static boolean
+iter_property(
+ struct tgsi_iterate_context *iter,
+ struct tgsi_full_property *prop )
+{
+ int i;
+ struct dump_ctx *ctx = (struct dump_ctx *)iter;
+
+ assert(Elements(property_names) == TGSI_PROPERTY_COUNT);
+
+ TXT( "PROPERTY " );
+ ENM(prop->Property.PropertyName, property_names);
+
+ if (prop->Property.NrTokens > 1)
+ TXT(" ");
+
+ for (i = 0; i < prop->Property.NrTokens - 1; ++i) {
+ switch (prop->Property.PropertyName) {
+ case TGSI_PROPERTY_GS_INPUT_PRIM:
+ case TGSI_PROPERTY_GS_OUTPUT_PRIM:
+ ENM(prop->u[i].Data, primitive_names);
+ break;
+ default:
+ SID( prop->u[i].Data );
+ break;
+ }
+ if (i < prop->Property.NrTokens - 2)
+ TXT( ", " );
+ }
+ EOL();
+
+ return TRUE;
+}
+
+void tgsi_dump_property(
+ const struct tgsi_full_property *prop )
+{
+ struct dump_ctx ctx;
+
+ ctx.printf = dump_ctx_printf;
+
+ iter_property( &ctx.iter, (struct tgsi_full_property *)prop );
+}
+
+static boolean
iter_immediate(
struct tgsi_iterate_context *iter,
struct tgsi_full_immediate *imm )
@@ -311,6 +414,12 @@ iter_immediate(
case TGSI_IMM_FLOAT32:
FLT( imm->u[i].Float );
break;
+ case TGSI_IMM_UINT32:
+ UID(imm->u[i].Uint);
+ break;
+ case TGSI_IMM_INT32:
+ SID(imm->u[i].Int);
+ break;
default:
assert( 0 );
}
@@ -371,117 +480,66 @@ iter_instruction(
}
for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
- const struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
+ const struct tgsi_full_dst_register *dst = &inst->Dst[i];
if (!first_reg)
CHR( ',' );
CHR( ' ' );
- if (dst->DstRegister.Indirect) {
+ if (dst->Register.Indirect) {
_dump_register_ind(
ctx,
- dst->DstRegister.File,
- dst->DstRegister.Index,
- dst->DstRegisterInd.File,
- dst->DstRegisterInd.Index,
- dst->DstRegisterInd.SwizzleX );
+ dst->Register.File,
+ dst->Register.Index,
+ dst->Indirect.File,
+ dst->Indirect.Index,
+ dst->Indirect.SwizzleX );
}
else {
- _dump_register(
+ _dump_register_dst(
ctx,
- dst->DstRegister.File,
- dst->DstRegister.Index,
- dst->DstRegister.Index );
+ dst->Register.File,
+ dst->Register.Index );
}
- ENM( dst->DstRegisterExtModulate.Modulate, modulate_names );
- _dump_writemask( ctx, dst->DstRegister.WriteMask );
+ _dump_writemask( ctx, dst->Register.WriteMask );
first_reg = FALSE;
}
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
- const struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
+ const struct tgsi_full_src_register *src = &inst->Src[i];
if (!first_reg)
CHR( ',' );
CHR( ' ' );
- if (src->SrcRegisterExtMod.Negate)
- TXT( "-(" );
- if (src->SrcRegisterExtMod.Absolute)
- CHR( '|' );
- if (src->SrcRegisterExtMod.Scale2X)
- TXT( "2*(" );
- if (src->SrcRegisterExtMod.Bias)
- CHR( '(' );
- if (src->SrcRegisterExtMod.Complement)
- TXT( "1-(" );
- if (src->SrcRegister.Negate)
+ if (src->Register.Negate)
CHR( '-' );
+ if (src->Register.Absolute)
+ CHR( '|' );
- if (src->SrcRegister.Indirect) {
- _dump_register_ind(
- ctx,
- src->SrcRegister.File,
- src->SrcRegister.Index,
- src->SrcRegisterInd.File,
- src->SrcRegisterInd.Index,
- src->SrcRegisterInd.SwizzleX );
- }
- else {
- _dump_register(
- ctx,
- src->SrcRegister.File,
- src->SrcRegister.Index,
- src->SrcRegister.Index );
- }
+ _dump_register_src(ctx, src);
- if (src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
- src->SrcRegister.SwizzleY != TGSI_SWIZZLE_Y ||
- src->SrcRegister.SwizzleZ != TGSI_SWIZZLE_Z ||
- src->SrcRegister.SwizzleW != TGSI_SWIZZLE_W) {
- CHR( '.' );
- ENM( src->SrcRegister.SwizzleX, swizzle_names );
- ENM( src->SrcRegister.SwizzleY, swizzle_names );
- ENM( src->SrcRegister.SwizzleZ, swizzle_names );
- ENM( src->SrcRegister.SwizzleW, swizzle_names );
- }
- if (src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X ||
- src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
- src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
- src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) {
+ if (src->Register.SwizzleX != TGSI_SWIZZLE_X ||
+ src->Register.SwizzleY != TGSI_SWIZZLE_Y ||
+ src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleW != TGSI_SWIZZLE_W) {
CHR( '.' );
- if (src->SrcRegisterExtSwz.NegateX)
- TXT("-");
- ENM( src->SrcRegisterExtSwz.ExtSwizzleX, extswizzle_names );
- if (src->SrcRegisterExtSwz.NegateY)
- TXT("-");
- ENM( src->SrcRegisterExtSwz.ExtSwizzleY, extswizzle_names );
- if (src->SrcRegisterExtSwz.NegateZ)
- TXT("-");
- ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, extswizzle_names );
- if (src->SrcRegisterExtSwz.NegateW)
- TXT("-");
- ENM( src->SrcRegisterExtSwz.ExtSwizzleW, extswizzle_names );
+ ENM( src->Register.SwizzleX, swizzle_names );
+ ENM( src->Register.SwizzleY, swizzle_names );
+ ENM( src->Register.SwizzleZ, swizzle_names );
+ ENM( src->Register.SwizzleW, swizzle_names );
}
- if (src->SrcRegisterExtMod.Complement)
- CHR( ')' );
- if (src->SrcRegisterExtMod.Bias)
- TXT( ")-.5" );
- if (src->SrcRegisterExtMod.Scale2X)
- CHR( ')' );
- if (src->SrcRegisterExtMod.Absolute)
+ if (src->Register.Absolute)
CHR( '|' );
- if (src->SrcRegisterExtMod.Negate)
- CHR( ')' );
first_reg = FALSE;
}
- if (inst->InstructionExtTexture.Texture != TGSI_TEXTURE_UNKNOWN) {
+ if (inst->Instruction.Texture) {
TXT( ", " );
- ENM( inst->InstructionExtTexture.Texture, texture_names );
+ ENM( inst->Texture.Texture, texture_names );
}
switch (inst->Instruction.Opcode) {
@@ -491,7 +549,7 @@ iter_instruction(
case TGSI_OPCODE_ENDLOOP:
case TGSI_OPCODE_CAL:
TXT( " :" );
- UID( inst->InstructionExtLabel.Label );
+ UID( inst->Label.Label );
break;
}
@@ -529,9 +587,6 @@ prolog(
{
struct dump_ctx *ctx = (struct dump_ctx *) iter;
ENM( iter->processor.Processor, processor_type_names );
- UID( iter->version.MajorVersion );
- CHR( '.' );
- UID( iter->version.MinorVersion );
EOL();
return TRUE;
}
@@ -547,6 +602,7 @@ tgsi_dump(
ctx.iter.iterate_instruction = iter_instruction;
ctx.iter.iterate_declaration = iter_declaration;
ctx.iter.iterate_immediate = iter_immediate;
+ ctx.iter.iterate_property = iter_property;
ctx.iter.epilog = NULL;
ctx.instno = 0;
@@ -601,6 +657,7 @@ tgsi_dump_str(
ctx.base.iter.iterate_instruction = iter_instruction;
ctx.base.iter.iterate_declaration = iter_declaration;
ctx.base.iter.iterate_immediate = iter_immediate;
+ ctx.base.iter.iterate_property = iter_property;
ctx.base.iter.epilog = NULL;
ctx.base.instno = 0;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.h b/src/gallium/auxiliary/tgsi/tgsi_dump.h
index ad1e647ec9..4cd27317b3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.h
@@ -49,6 +49,7 @@ tgsi_dump(
struct tgsi_full_immediate;
struct tgsi_full_instruction;
struct tgsi_full_declaration;
+struct tgsi_full_property;
void
tgsi_dump_immediate(
@@ -63,6 +64,10 @@ void
tgsi_dump_declaration(
const struct tgsi_full_declaration *decl );
+void
+tgsi_dump_property(
+ const struct tgsi_full_property *prop );
+
#if defined __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
index 4a9c02b141..47fd1dd590 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
@@ -79,7 +79,8 @@ static const char *TGSI_FILES[TGSI_FILE_COUNT] =
"FILE_SAMPLER",
"FILE_ADDRESS",
"FILE_IMMEDIATE",
- "FILE_LOOP"
+ "FILE_LOOP",
+ "FILE_PREDICATE"
};
static const char *TGSI_INTERPOLATES[] =
@@ -112,34 +113,6 @@ static const char *TGSI_SATS[] =
"SAT_MINUS_PLUS_ONE"
};
-static const char *TGSI_INSTRUCTION_EXTS[] =
-{
- "INSTRUCTION_EXT_TYPE_NV",
- "INSTRUCTION_EXT_TYPE_LABEL",
- "INSTRUCTION_EXT_TYPE_TEXTURE"
-};
-
-static const char *TGSI_PRECISIONS[] =
-{
- "PRECISION_DEFAULT",
- "PRECISION_FLOAT32",
- "PRECISION_FLOAT16",
- "PRECISION_FIXED12"
-};
-
-static const char *TGSI_CCS[] =
-{
- "CC_GT",
- "CC_EQ",
- "CC_LT",
- "CC_UN",
- "CC_GE",
- "CC_LE",
- "CC_NE",
- "CC_TR",
- "CC_FL"
-};
-
static const char *TGSI_SWIZZLES[] =
{
"SWIZZLE_X",
@@ -161,22 +134,6 @@ static const char *TGSI_TEXTURES[] =
"TEXTURE_SHADOWRECT"
};
-static const char *TGSI_SRC_REGISTER_EXTS[] =
-{
- "SRC_REGISTER_EXT_TYPE_SWZ",
- "SRC_REGISTER_EXT_TYPE_MOD"
-};
-
-static const char *TGSI_EXTSWIZZLES[] =
-{
- "EXTSWIZZLE_X",
- "EXTSWIZZLE_Y",
- "EXTSWIZZLE_Z",
- "EXTSWIZZLE_W",
- "EXTSWIZZLE_ZERO",
- "EXTSWIZZLE_ONE"
-};
-
static const char *TGSI_WRITEMASKS[] =
{
"0",
@@ -197,23 +154,6 @@ static const char *TGSI_WRITEMASKS[] =
"WRITEMASK_XYZW"
};
-static const char *TGSI_DST_REGISTER_EXTS[] =
-{
- "DST_REGISTER_EXT_TYPE_CONDCODE",
- "DST_REGISTER_EXT_TYPE_MODULATE"
-};
-
-static const char *TGSI_MODULATES[] =
-{
- "MODULATE_1X",
- "MODULATE_2X",
- "MODULATE_4X",
- "MODULATE_8X",
- "MODULATE_HALF",
- "MODULATE_QUARTER",
- "MODULATE_EIGHTH"
-};
-
static void
dump_declaration_verbose(
struct tgsi_full_declaration *decl,
@@ -246,6 +186,14 @@ dump_declaration_verbose(
TXT( "\nSemantic : " );
UID( decl->Declaration.Semantic );
}
+ if (deflt || fd->Declaration.Centroid != decl->Declaration.Centroid) {
+ TXT("\nCentroid : ");
+ UID(decl->Declaration.Centroid);
+ }
+ if (deflt || fd->Declaration.Invariant != decl->Declaration.Invariant) {
+ TXT("\nInvariant : ");
+ UID(decl->Declaration.Invariant);
+ }
if( ignored ) {
TXT( "\nPadding : " );
UIX( decl->Declaration.Padding );
@@ -253,16 +201,16 @@ dump_declaration_verbose(
EOL();
TXT( "\nFirst: " );
- UID( decl->DeclarationRange.First );
+ UID( decl->Range.First );
TXT( "\nLast : " );
- UID( decl->DeclarationRange.Last );
+ UID( decl->Range.Last );
if( decl->Declaration.Semantic ) {
EOL();
- TXT( "\nSemanticName : " );
- ENM( decl->Semantic.SemanticName, TGSI_SEMANTICS );
- TXT( "\nSemanticIndex: " );
- UID( decl->Semantic.SemanticIndex );
+ TXT( "\nName : " );
+ ENM( decl->Semantic.Name, TGSI_SEMANTICS );
+ TXT( "\nIndex: " );
+ UID( decl->Semantic.Index );
if( ignored ) {
TXT( "\nPadding : " );
UIX( decl->Semantic.Padding );
@@ -322,318 +270,122 @@ dump_instruction_verbose(
TXT( "\nNumSrcRegs : " );
UID( inst->Instruction.NumSrcRegs );
}
+ if (deflt || fi->Instruction.Predicate != inst->Instruction.Predicate) {
+ TXT("\nPredicate : ");
+ UID(inst->Instruction.Predicate);
+ }
+ if (deflt || fi->Instruction.Label != inst->Instruction.Label) {
+ TXT("\nLabel : ");
+ UID(inst->Instruction.Label);
+ }
+ if (deflt || fi->Instruction.Texture != inst->Instruction.Texture) {
+ TXT("\nTexture : ");
+ UID(inst->Instruction.Texture);
+ }
if( ignored ) {
TXT( "\nPadding : " );
UIX( inst->Instruction.Padding );
}
- if( deflt || tgsi_compare_instruction_ext_nv( inst->InstructionExtNv, fi->InstructionExtNv ) ) {
- EOL();
- TXT( "\nType : " );
- ENM( inst->InstructionExtNv.Type, TGSI_INSTRUCTION_EXTS );
- if( deflt || fi->InstructionExtNv.Precision != inst->InstructionExtNv.Precision ) {
- TXT( "\nPrecision : " );
- ENM( inst->InstructionExtNv.Precision, TGSI_PRECISIONS );
- }
- if( deflt || fi->InstructionExtNv.CondDstIndex != inst->InstructionExtNv.CondDstIndex ) {
- TXT( "\nCondDstIndex : " );
- UID( inst->InstructionExtNv.CondDstIndex );
- }
- if( deflt || fi->InstructionExtNv.CondFlowIndex != inst->InstructionExtNv.CondFlowIndex ) {
- TXT( "\nCondFlowIndex : " );
- UID( inst->InstructionExtNv.CondFlowIndex );
- }
- if( deflt || fi->InstructionExtNv.CondMask != inst->InstructionExtNv.CondMask ) {
- TXT( "\nCondMask : " );
- ENM( inst->InstructionExtNv.CondMask, TGSI_CCS );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleX != inst->InstructionExtNv.CondSwizzleX ) {
- TXT( "\nCondSwizzleX : " );
- ENM( inst->InstructionExtNv.CondSwizzleX, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleY != inst->InstructionExtNv.CondSwizzleY ) {
- TXT( "\nCondSwizzleY : " );
- ENM( inst->InstructionExtNv.CondSwizzleY, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleZ != inst->InstructionExtNv.CondSwizzleZ ) {
- TXT( "\nCondSwizzleZ : " );
- ENM( inst->InstructionExtNv.CondSwizzleZ, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleW != inst->InstructionExtNv.CondSwizzleW ) {
- TXT( "\nCondSwizzleW : " );
- ENM( inst->InstructionExtNv.CondSwizzleW, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondDstUpdate != inst->InstructionExtNv.CondDstUpdate ) {
- TXT( "\nCondDstUpdate : " );
- UID( inst->InstructionExtNv.CondDstUpdate );
- }
- if( deflt || fi->InstructionExtNv.CondFlowEnable != inst->InstructionExtNv.CondFlowEnable ) {
- TXT( "\nCondFlowEnable: " );
- UID( inst->InstructionExtNv.CondFlowEnable );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( inst->InstructionExtNv.Padding );
- if( deflt || fi->InstructionExtNv.Extended != inst->InstructionExtNv.Extended ) {
- TXT( "\nExtended : " );
- UID( inst->InstructionExtNv.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_instruction_ext_label( inst->InstructionExtLabel, fi->InstructionExtLabel ) ) {
+ if (deflt || inst->Instruction.Label) {
EOL();
- TXT( "\nType : " );
- ENM( inst->InstructionExtLabel.Type, TGSI_INSTRUCTION_EXTS );
- if( deflt || fi->InstructionExtLabel.Label != inst->InstructionExtLabel.Label ) {
+ if (deflt || fi->Label.Label != inst->Label.Label) {
TXT( "\nLabel : " );
- UID( inst->InstructionExtLabel.Label );
+ UID(inst->Label.Label);
}
if( ignored ) {
TXT( "\nPadding : " );
- UIX( inst->InstructionExtLabel.Padding );
- if( deflt || fi->InstructionExtLabel.Extended != inst->InstructionExtLabel.Extended ) {
- TXT( "\nExtended: " );
- UID( inst->InstructionExtLabel.Extended );
- }
+ UIX(inst->Label.Padding);
}
}
- if( deflt || tgsi_compare_instruction_ext_texture( inst->InstructionExtTexture, fi->InstructionExtTexture ) ) {
+ if (deflt || inst->Instruction.Texture) {
EOL();
- TXT( "\nType : " );
- ENM( inst->InstructionExtTexture.Type, TGSI_INSTRUCTION_EXTS );
- if( deflt || fi->InstructionExtTexture.Texture != inst->InstructionExtTexture.Texture ) {
+ if (deflt || fi->Texture.Texture != inst->Texture.Texture) {
TXT( "\nTexture : " );
- ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES );
+ ENM(inst->Texture.Texture, TGSI_TEXTURES);
}
if( ignored ) {
TXT( "\nPadding : " );
- UIX( inst->InstructionExtTexture.Padding );
- if( deflt || fi->InstructionExtTexture.Extended != inst->InstructionExtTexture.Extended ) {
- TXT( "\nExtended: " );
- UID( inst->InstructionExtTexture.Extended );
- }
+ UIX(inst->Texture.Padding);
}
}
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
- struct tgsi_full_dst_register *fd = &fi->FullDstRegisters[i];
+ struct tgsi_full_dst_register *dst = &inst->Dst[i];
+ struct tgsi_full_dst_register *fd = &fi->Dst[i];
EOL();
TXT( "\nFile : " );
- ENM( dst->DstRegister.File, TGSI_FILES );
- if( deflt || fd->DstRegister.WriteMask != dst->DstRegister.WriteMask ) {
+ ENM( dst->Register.File, TGSI_FILES );
+ if( deflt || fd->Register.WriteMask != dst->Register.WriteMask ) {
TXT( "\nWriteMask: " );
- ENM( dst->DstRegister.WriteMask, TGSI_WRITEMASKS );
+ ENM( dst->Register.WriteMask, TGSI_WRITEMASKS );
}
if( ignored ) {
- if( deflt || fd->DstRegister.Indirect != dst->DstRegister.Indirect ) {
+ if( deflt || fd->Register.Indirect != dst->Register.Indirect ) {
TXT( "\nIndirect : " );
- UID( dst->DstRegister.Indirect );
+ UID( dst->Register.Indirect );
}
- if( deflt || fd->DstRegister.Dimension != dst->DstRegister.Dimension ) {
+ if( deflt || fd->Register.Dimension != dst->Register.Dimension ) {
TXT( "\nDimension: " );
- UID( dst->DstRegister.Dimension );
+ UID( dst->Register.Dimension );
}
}
- if( deflt || fd->DstRegister.Index != dst->DstRegister.Index ) {
+ if( deflt || fd->Register.Index != dst->Register.Index ) {
TXT( "\nIndex : " );
- SID( dst->DstRegister.Index );
+ SID( dst->Register.Index );
}
if( ignored ) {
TXT( "\nPadding : " );
- UIX( dst->DstRegister.Padding );
- if( deflt || fd->DstRegister.Extended != dst->DstRegister.Extended ) {
- TXT( "\nExtended : " );
- UID( dst->DstRegister.Extended );
- }
- }
-
- if( deflt || tgsi_compare_dst_register_ext_concode( dst->DstRegisterExtConcode, fd->DstRegisterExtConcode ) ) {
- EOL();
- TXT( "\nType : " );
- ENM( dst->DstRegisterExtConcode.Type, TGSI_DST_REGISTER_EXTS );
- if( deflt || fd->DstRegisterExtConcode.CondMask != dst->DstRegisterExtConcode.CondMask ) {
- TXT( "\nCondMask : " );
- ENM( dst->DstRegisterExtConcode.CondMask, TGSI_CCS );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleX != dst->DstRegisterExtConcode.CondSwizzleX ) {
- TXT( "\nCondSwizzleX: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleX, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleY != dst->DstRegisterExtConcode.CondSwizzleY ) {
- TXT( "\nCondSwizzleY: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleY, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleZ != dst->DstRegisterExtConcode.CondSwizzleZ ) {
- TXT( "\nCondSwizzleZ: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleZ, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleW != dst->DstRegisterExtConcode.CondSwizzleW ) {
- TXT( "\nCondSwizzleW: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleW, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSrcIndex != dst->DstRegisterExtConcode.CondSrcIndex ) {
- TXT( "\nCondSrcIndex: " );
- UID( dst->DstRegisterExtConcode.CondSrcIndex );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( dst->DstRegisterExtConcode.Padding );
- if( deflt || fd->DstRegisterExtConcode.Extended != dst->DstRegisterExtConcode.Extended ) {
- TXT( "\nExtended : " );
- UID( dst->DstRegisterExtConcode.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_dst_register_ext_modulate( dst->DstRegisterExtModulate, fd->DstRegisterExtModulate ) ) {
- EOL();
- TXT( "\nType : " );
- ENM( dst->DstRegisterExtModulate.Type, TGSI_DST_REGISTER_EXTS );
- if( deflt || fd->DstRegisterExtModulate.Modulate != dst->DstRegisterExtModulate.Modulate ) {
- TXT( "\nModulate: " );
- ENM( dst->DstRegisterExtModulate.Modulate, TGSI_MODULATES );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( dst->DstRegisterExtModulate.Padding );
- if( deflt || fd->DstRegisterExtModulate.Extended != dst->DstRegisterExtModulate.Extended ) {
- TXT( "\nExtended: " );
- UID( dst->DstRegisterExtModulate.Extended );
- }
- }
+ UIX( dst->Register.Padding );
}
}
for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
- struct tgsi_full_src_register *fs = &fi->FullSrcRegisters[i];
+ struct tgsi_full_src_register *src = &inst->Src[i];
+ struct tgsi_full_src_register *fs = &fi->Src[i];
EOL();
TXT( "\nFile : ");
- ENM( src->SrcRegister.File, TGSI_FILES );
- if( deflt || fs->SrcRegister.SwizzleX != src->SrcRegister.SwizzleX ) {
+ ENM( src->Register.File, TGSI_FILES );
+ if( deflt || fs->Register.SwizzleX != src->Register.SwizzleX ) {
TXT( "\nSwizzleX : " );
- ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES );
+ ENM( src->Register.SwizzleX, TGSI_SWIZZLES );
}
- if( deflt || fs->SrcRegister.SwizzleY != src->SrcRegister.SwizzleY ) {
+ if( deflt || fs->Register.SwizzleY != src->Register.SwizzleY ) {
TXT( "\nSwizzleY : " );
- ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES );
+ ENM( src->Register.SwizzleY, TGSI_SWIZZLES );
}
- if( deflt || fs->SrcRegister.SwizzleZ != src->SrcRegister.SwizzleZ ) {
+ if( deflt || fs->Register.SwizzleZ != src->Register.SwizzleZ ) {
TXT( "\nSwizzleZ : " );
- ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES );
+ ENM( src->Register.SwizzleZ, TGSI_SWIZZLES );
}
- if( deflt || fs->SrcRegister.SwizzleW != src->SrcRegister.SwizzleW ) {
+ if( deflt || fs->Register.SwizzleW != src->Register.SwizzleW ) {
TXT( "\nSwizzleW : " );
- ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES );
+ ENM( src->Register.SwizzleW, TGSI_SWIZZLES );
}
- if( deflt || fs->SrcRegister.Negate != src->SrcRegister.Negate ) {
+ if (deflt || fs->Register.Absolute != src->Register.Absolute) {
+ TXT("\nAbsolute : ");
+ UID(src->Register.Absolute);
+ }
+ if( deflt || fs->Register.Negate != src->Register.Negate ) {
TXT( "\nNegate : " );
- UID( src->SrcRegister.Negate );
+ UID( src->Register.Negate );
}
if( ignored ) {
- if( deflt || fs->SrcRegister.Indirect != src->SrcRegister.Indirect ) {
+ if( deflt || fs->Register.Indirect != src->Register.Indirect ) {
TXT( "\nIndirect : " );
- UID( src->SrcRegister.Indirect );
+ UID( src->Register.Indirect );
}
- if( deflt || fs->SrcRegister.Dimension != src->SrcRegister.Dimension ) {
+ if( deflt || fs->Register.Dimension != src->Register.Dimension ) {
TXT( "\nDimension: " );
- UID( src->SrcRegister.Dimension );
+ UID( src->Register.Dimension );
}
}
- if( deflt || fs->SrcRegister.Index != src->SrcRegister.Index ) {
+ if( deflt || fs->Register.Index != src->Register.Index ) {
TXT( "\nIndex : " );
- SID( src->SrcRegister.Index );
- }
- if( ignored ) {
- if( deflt || fs->SrcRegister.Extended != src->SrcRegister.Extended ) {
- TXT( "\nExtended : " );
- UID( src->SrcRegister.Extended );
- }
- }
-
- if( deflt || tgsi_compare_src_register_ext_swz( src->SrcRegisterExtSwz, fs->SrcRegisterExtSwz ) ) {
- EOL();
- TXT( "\nType : " );
- ENM( src->SrcRegisterExtSwz.Type, TGSI_SRC_REGISTER_EXTS );
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleX != src->SrcRegisterExtSwz.ExtSwizzleX ) {
- TXT( "\nExtSwizzleX: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleX, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleY != src->SrcRegisterExtSwz.ExtSwizzleY ) {
- TXT( "\nExtSwizzleY: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleY, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleZ != src->SrcRegisterExtSwz.ExtSwizzleZ ) {
- TXT( "\nExtSwizzleZ: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleW != src->SrcRegisterExtSwz.ExtSwizzleW ) {
- TXT( "\nExtSwizzleW: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleW, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateX != src->SrcRegisterExtSwz.NegateX ) {
- TXT( "\nNegateX : " );
- UID( src->SrcRegisterExtSwz.NegateX );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateY != src->SrcRegisterExtSwz.NegateY ) {
- TXT( "\nNegateY : " );
- UID( src->SrcRegisterExtSwz.NegateY );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateZ != src->SrcRegisterExtSwz.NegateZ ) {
- TXT( "\nNegateZ : " );
- UID( src->SrcRegisterExtSwz.NegateZ );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateW != src->SrcRegisterExtSwz.NegateW ) {
- TXT( "\nNegateW : " );
- UID( src->SrcRegisterExtSwz.NegateW );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( src->SrcRegisterExtSwz.Padding );
- if( deflt || fs->SrcRegisterExtSwz.Extended != src->SrcRegisterExtSwz.Extended ) {
- TXT( "\nExtended : " );
- UID( src->SrcRegisterExtSwz.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_src_register_ext_mod( src->SrcRegisterExtMod, fs->SrcRegisterExtMod ) ) {
- EOL();
- TXT( "\nType : " );
- ENM( src->SrcRegisterExtMod.Type, TGSI_SRC_REGISTER_EXTS );
- if( deflt || fs->SrcRegisterExtMod.Complement != src->SrcRegisterExtMod.Complement ) {
- TXT( "\nComplement: " );
- UID( src->SrcRegisterExtMod.Complement );
- }
- if( deflt || fs->SrcRegisterExtMod.Bias != src->SrcRegisterExtMod.Bias ) {
- TXT( "\nBias : " );
- UID( src->SrcRegisterExtMod.Bias );
- }
- if( deflt || fs->SrcRegisterExtMod.Scale2X != src->SrcRegisterExtMod.Scale2X ) {
- TXT( "\nScale2X : " );
- UID( src->SrcRegisterExtMod.Scale2X );
- }
- if( deflt || fs->SrcRegisterExtMod.Absolute != src->SrcRegisterExtMod.Absolute ) {
- TXT( "\nAbsolute : " );
- UID( src->SrcRegisterExtMod.Absolute );
- }
- if( deflt || fs->SrcRegisterExtMod.Negate != src->SrcRegisterExtMod.Negate ) {
- TXT( "\nNegate : " );
- UID( src->SrcRegisterExtMod.Negate );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( src->SrcRegisterExtMod.Padding );
- if( deflt || fs->SrcRegisterExtMod.Extended != src->SrcRegisterExtMod.Extended ) {
- TXT( "\nExtended : " );
- UID( src->SrcRegisterExtMod.Extended );
- }
- }
+ SID( src->Register.Index );
}
}
}
@@ -653,12 +405,6 @@ tgsi_dump_c(
TXT( "tgsi-dump begin -----------------" );
- TXT( "\nMajorVersion: " );
- UID( parse.FullVersion.Version.MajorVersion );
- TXT( "\nMinorVersion: " );
- UID( parse.FullVersion.Version.MinorVersion );
- EOL();
-
TXT( "\nHeaderSize: " );
UID( parse.FullHeader.Header.HeaderSize );
TXT( "\nBodySize : " );
@@ -678,10 +424,6 @@ tgsi_dump_c(
if( ignored ) {
TXT( "\nSize : " );
UID( parse.FullToken.Token.NrTokens );
- if( deflt || parse.FullToken.Token.Extended ) {
- TXT( "\nExtended : " );
- UID( parse.FullToken.Token.Extended );
- }
}
switch( parse.FullToken.Token.Type ) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index c79c56debd..2bcb33392a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -2,6 +2,7 @@
*
* Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
+ * 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
@@ -60,21 +61,337 @@
#include "util/u_memory.h"
#include "util/u_math.h"
-#define FAST_MATH 1
-/** for tgsi_full_instruction::Flags */
-#define SOA_DEPENDENCY_FLAG 0x1
+#define FAST_MATH 1
#define TILE_TOP_LEFT 0
#define TILE_TOP_RIGHT 1
#define TILE_BOTTOM_LEFT 2
#define TILE_BOTTOM_RIGHT 3
+static void
+micro_abs(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = fabsf(src->f[0]);
+ dst->f[1] = fabsf(src->f[1]);
+ dst->f[2] = fabsf(src->f[2]);
+ dst->f[3] = fabsf(src->f[3]);
+}
+
+static void
+micro_arl(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = (int)floorf(src->f[0]);
+ dst->i[1] = (int)floorf(src->f[1]);
+ dst->i[2] = (int)floorf(src->f[2]);
+ dst->i[3] = (int)floorf(src->f[3]);
+}
+
+static void
+micro_arr(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = (int)floorf(src->f[0] + 0.5f);
+ dst->i[1] = (int)floorf(src->f[1] + 0.5f);
+ dst->i[2] = (int)floorf(src->f[2] + 0.5f);
+ dst->i[3] = (int)floorf(src->f[3] + 0.5f);
+}
+
+static void
+micro_ceil(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = ceilf(src->f[0]);
+ dst->f[1] = ceilf(src->f[1]);
+ dst->f[2] = ceilf(src->f[2]);
+ dst->f[3] = ceilf(src->f[3]);
+}
+
+static void
+micro_cos(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = cosf(src->f[0]);
+ dst->f[1] = cosf(src->f[1]);
+ dst->f[2] = cosf(src->f[2]);
+ dst->f[3] = cosf(src->f[3]);
+}
+
+static void
+micro_ddx(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] =
+ dst->f[1] =
+ dst->f[2] =
+ dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT];
+}
+
+static void
+micro_ddy(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] =
+ dst->f[1] =
+ dst->f[2] =
+ dst->f[3] = src->f[TILE_BOTTOM_LEFT] - src->f[TILE_TOP_LEFT];
+}
+
+static void
+micro_exp2(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+#if FAST_MATH
+ dst->f[0] = util_fast_exp2(src->f[0]);
+ dst->f[1] = util_fast_exp2(src->f[1]);
+ dst->f[2] = util_fast_exp2(src->f[2]);
+ dst->f[3] = util_fast_exp2(src->f[3]);
+#else
+#if DEBUG
+ /* Inf is okay for this instruction, so clamp it to silence assertions. */
+ uint i;
+ union tgsi_exec_channel clamped;
+
+ for (i = 0; i < 4; i++) {
+ if (src->f[i] > 127.99999f) {
+ clamped.f[i] = 127.99999f;
+ } else if (src->f[i] < -126.99999f) {
+ clamped.f[i] = -126.99999f;
+ } else {
+ clamped.f[i] = src->f[i];
+ }
+ }
+ src = &clamped;
+#endif /* DEBUG */
+
+ dst->f[0] = powf(2.0f, src->f[0]);
+ dst->f[1] = powf(2.0f, src->f[1]);
+ dst->f[2] = powf(2.0f, src->f[2]);
+ dst->f[3] = powf(2.0f, src->f[3]);
+#endif /* FAST_MATH */
+}
+
+static void
+micro_flr(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = floorf(src->f[0]);
+ dst->f[1] = floorf(src->f[1]);
+ dst->f[2] = floorf(src->f[2]);
+ dst->f[3] = floorf(src->f[3]);
+}
+
+static void
+micro_frc(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src->f[0] - floorf(src->f[0]);
+ dst->f[1] = src->f[1] - floorf(src->f[1]);
+ dst->f[2] = src->f[2] - floorf(src->f[2]);
+ dst->f[3] = src->f[3] - floorf(src->f[3]);
+}
+
+static void
+micro_iabs(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src->i[0] >= 0 ? src->i[0] : -src->i[0];
+ dst->i[1] = src->i[1] >= 0 ? src->i[1] : -src->i[1];
+ dst->i[2] = src->i[2] >= 0 ? src->i[2] : -src->i[2];
+ dst->i[3] = src->i[3] >= 0 ? src->i[3] : -src->i[3];
+}
+
+static void
+micro_ineg(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = -src->i[0];
+ dst->i[1] = -src->i[1];
+ dst->i[2] = -src->i[2];
+ dst->i[3] = -src->i[3];
+}
+
+static void
+micro_lg2(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+#if FAST_MATH
+ dst->f[0] = util_fast_log2(src->f[0]);
+ dst->f[1] = util_fast_log2(src->f[1]);
+ dst->f[2] = util_fast_log2(src->f[2]);
+ dst->f[3] = util_fast_log2(src->f[3]);
+#else
+ dst->f[0] = logf(src->f[0]) * 1.442695f;
+ dst->f[1] = logf(src->f[1]) * 1.442695f;
+ dst->f[2] = logf(src->f[2]) * 1.442695f;
+ dst->f[3] = logf(src->f[3]) * 1.442695f;
+#endif
+}
+
+static void
+micro_lrp(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] * (src[1].f[0] - src[2].f[0]) + src[2].f[0];
+ dst->f[1] = src[0].f[1] * (src[1].f[1] - src[2].f[1]) + src[2].f[1];
+ dst->f[2] = src[0].f[2] * (src[1].f[2] - src[2].f[2]) + src[2].f[2];
+ dst->f[3] = src[0].f[3] * (src[1].f[3] - src[2].f[3]) + src[2].f[3];
+}
+
+static void
+micro_mad(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] * src[1].f[0] + src[2].f[0];
+ dst->f[1] = src[0].f[1] * src[1].f[1] + src[2].f[1];
+ dst->f[2] = src[0].f[2] * src[1].f[2] + src[2].f[2];
+ dst->f[3] = src[0].f[3] * src[1].f[3] + src[2].f[3];
+}
+
+static void
+micro_mov(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src->u[0];
+ dst->u[1] = src->u[1];
+ dst->u[2] = src->u[2];
+ dst->u[3] = src->u[3];
+}
+
+static void
+micro_rcp(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = 1.0f / src->f[0];
+ dst->f[1] = 1.0f / src->f[1];
+ dst->f[2] = 1.0f / src->f[2];
+ dst->f[3] = 1.0f / src->f[3];
+}
+
+static void
+micro_rnd(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = floorf(src->f[0] + 0.5f);
+ dst->f[1] = floorf(src->f[1] + 0.5f);
+ dst->f[2] = floorf(src->f[2] + 0.5f);
+ dst->f[3] = floorf(src->f[3] + 0.5f);
+}
+
+static void
+micro_rsq(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = 1.0f / sqrtf(fabsf(src->f[0]));
+ dst->f[1] = 1.0f / sqrtf(fabsf(src->f[1]));
+ dst->f[2] = 1.0f / sqrtf(fabsf(src->f[2]));
+ dst->f[3] = 1.0f / sqrtf(fabsf(src->f[3]));
+}
+
+static void
+micro_seq(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] == src[1].f[0] ? 1.0f : 0.0f;
+ dst->f[1] = src[0].f[1] == src[1].f[1] ? 1.0f : 0.0f;
+ dst->f[2] = src[0].f[2] == src[1].f[2] ? 1.0f : 0.0f;
+ dst->f[3] = src[0].f[3] == src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sge(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] >= src[1].f[0] ? 1.0f : 0.0f;
+ dst->f[1] = src[0].f[1] >= src[1].f[1] ? 1.0f : 0.0f;
+ dst->f[2] = src[0].f[2] >= src[1].f[2] ? 1.0f : 0.0f;
+ dst->f[3] = src[0].f[3] >= src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sgn(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src->f[0] < 0.0f ? -1.0f : src->f[0] > 0.0f ? 1.0f : 0.0f;
+ dst->f[1] = src->f[1] < 0.0f ? -1.0f : src->f[1] > 0.0f ? 1.0f : 0.0f;
+ dst->f[2] = src->f[2] < 0.0f ? -1.0f : src->f[2] > 0.0f ? 1.0f : 0.0f;
+ dst->f[3] = src->f[3] < 0.0f ? -1.0f : src->f[3] > 0.0f ? 1.0f : 0.0f;
+}
+
+static void
+micro_sgt(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] > src[1].f[0] ? 1.0f : 0.0f;
+ dst->f[1] = src[0].f[1] > src[1].f[1] ? 1.0f : 0.0f;
+ dst->f[2] = src[0].f[2] > src[1].f[2] ? 1.0f : 0.0f;
+ dst->f[3] = src[0].f[3] > src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sin(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = sinf(src->f[0]);
+ dst->f[1] = sinf(src->f[1]);
+ dst->f[2] = sinf(src->f[2]);
+ dst->f[3] = sinf(src->f[3]);
+}
+
+static void
+micro_sle(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] <= src[1].f[0] ? 1.0f : 0.0f;
+ dst->f[1] = src[0].f[1] <= src[1].f[1] ? 1.0f : 0.0f;
+ dst->f[2] = src[0].f[2] <= src[1].f[2] ? 1.0f : 0.0f;
+ dst->f[3] = src[0].f[3] <= src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_slt(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] < src[1].f[0] ? 1.0f : 0.0f;
+ dst->f[1] = src[0].f[1] < src[1].f[1] ? 1.0f : 0.0f;
+ dst->f[2] = src[0].f[2] < src[1].f[2] ? 1.0f : 0.0f;
+ dst->f[3] = src[0].f[3] < src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_sne(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = src[0].f[0] != src[1].f[0] ? 1.0f : 0.0f;
+ dst->f[1] = src[0].f[1] != src[1].f[1] ? 1.0f : 0.0f;
+ dst->f[2] = src[0].f[2] != src[1].f[2] ? 1.0f : 0.0f;
+ dst->f[3] = src[0].f[3] != src[1].f[3] ? 1.0f : 0.0f;
+}
+
+static void
+micro_trunc(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = (float)(int)src->f[0];
+ dst->f[1] = (float)(int)src->f[1];
+ dst->f[2] = (float)(int)src->f[2];
+ dst->f[3] = (float)(int)src->f[3];
+}
+
+
#define CHAN_X 0
#define CHAN_Y 1
#define CHAN_Z 2
#define CHAN_W 3
+enum tgsi_exec_datatype {
+ TGSI_EXEC_DATA_FLOAT,
+ TGSI_EXEC_DATA_INT,
+ TGSI_EXEC_DATA_UINT
+};
+
/*
* Shorthand locations of various utility registers (_I = Index, _C = Channel)
*/
@@ -107,12 +424,13 @@
#define TEMP_HALF_I TGSI_EXEC_TEMP_HALF_I
#define TEMP_HALF_C TGSI_EXEC_TEMP_HALF_C
#define TEMP_R0 TGSI_EXEC_TEMP_R0
+#define TEMP_P0 TGSI_EXEC_TEMP_P0
#define IS_CHANNEL_ENABLED(INST, CHAN)\
- ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+ ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
#define IS_CHANNEL_ENABLED2(INST, CHAN)\
- ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
+ ((INST).Dst[1].Register.WriteMask & (1 << (CHAN)))
#define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\
@@ -125,23 +443,19 @@
/** The execution mask depends on the conditional mask and the loop mask */
#define UPDATE_EXEC_MASK(MACH) \
- MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->FuncMask
+ MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->Switch.mask & MACH->FuncMask
static const union tgsi_exec_channel ZeroVec =
{ { 0.0, 0.0, 0.0, 0.0 } };
-#ifdef DEBUG
-static void
-check_inf_or_nan(const union tgsi_exec_channel *chan)
-{
- assert(!util_is_inf_or_nan(chan->f[0]));
- assert(!util_is_inf_or_nan(chan->f[1]));
- assert(!util_is_inf_or_nan(chan->f[2]));
- assert(!util_is_inf_or_nan(chan->f[3]));
-}
-#endif
+#define CHECK_INF_OR_NAN(chan) do {\
+ assert(!util_is_inf_or_nan((chan)->f[0]));\
+ assert(!util_is_inf_or_nan((chan)->f[1]));\
+ assert(!util_is_inf_or_nan((chan)->f[2]));\
+ assert(!util_is_inf_or_nan((chan)->f[3]));\
+ } while (0)
#ifdef DEBUG
@@ -190,7 +504,7 @@ tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst)
{
uint i, chan;
- uint writemask = inst->FullDstRegisters[0].DstRegister.WriteMask;
+ uint writemask = inst->Dst[0].Register.WriteMask;
if (writemask == TGSI_WRITEMASK_X ||
writemask == TGSI_WRITEMASK_Y ||
writemask == TGSI_WRITEMASK_Z ||
@@ -202,17 +516,16 @@ tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst)
/* loop over src regs */
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
- if ((inst->FullSrcRegisters[i].SrcRegister.File ==
- inst->FullDstRegisters[0].DstRegister.File) &&
- (inst->FullSrcRegisters[i].SrcRegister.Index ==
- inst->FullDstRegisters[0].DstRegister.Index)) {
+ if ((inst->Src[i].Register.File ==
+ inst->Dst[0].Register.File) &&
+ (inst->Src[i].Register.Index ==
+ inst->Dst[0].Register.Index)) {
/* loop over dest channels */
uint channelsWritten = 0x0;
FOR_EACH_ENABLED_CHANNEL(*inst, chan) {
/* check if we're reading a channel that's been written */
- uint swizzle = tgsi_util_get_full_src_register_extswizzle(&inst->FullSrcRegisters[i], chan);
- if (swizzle <= TGSI_SWIZZLE_W &&
- (channelsWritten & (1 << swizzle))) {
+ uint swizzle = tgsi_util_get_full_src_register_swizzle(&inst->Src[i], chan);
+ if (channelsWritten & (1 << swizzle)) {
return TRUE;
}
@@ -295,6 +608,14 @@ tgsi_exec_machine_bind_shader(
* sizeof(struct tgsi_full_declaration));
maxDeclarations += 10;
}
+ if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_OUTPUT) {
+ unsigned reg;
+ for (reg = parse.FullToken.FullDeclaration.Range.First;
+ reg <= parse.FullToken.FullDeclaration.Range.Last;
+ ++reg) {
+ ++mach->NumOutputs;
+ }
+ }
memcpy(declarations + numDeclarations,
&parse.FullToken.FullDeclaration,
sizeof(declarations[0]));
@@ -332,20 +653,6 @@ tgsi_exec_machine_bind_shader(
maxInstructions += 10;
}
- if (tgsi_check_soa_dependencies(&parse.FullToken.FullInstruction)) {
- uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
- parse.FullToken.FullInstruction.Flags = SOA_DEPENDENCY_FLAG;
- /* XXX we only handle SOA dependencies properly for MOV/SWZ
- * at this time!
- */
- if (opcode != TGSI_OPCODE_MOV && opcode != TGSI_OPCODE_SWZ) {
- debug_printf("Warning: SOA dependency in instruction"
- " is not handled:\n");
- tgsi_dump_instruction(&parse.FullToken.FullInstruction,
- numInstructions);
- }
- }
-
memcpy(instructions + numInstructions,
&parse.FullToken.FullInstruction,
sizeof(instructions[0]));
@@ -353,6 +660,9 @@ tgsi_exec_machine_bind_shader(
numInstructions++;
break;
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ break;
+
default:
assert( 0 );
}
@@ -386,6 +696,8 @@ tgsi_exec_machine_create( void )
memset(mach, 0, sizeof(*mach));
mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR];
+ mach->MaxGeometryShaderOutputs = TGSI_MAX_TOTAL_VERTICES;
+ mach->Predicates = &mach->Temps[TGSI_EXEC_TEMP_P0];
/* Setup constants. */
for( i = 0; i < 4; i++ ) {
@@ -426,18 +738,6 @@ tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach)
align_free(mach);
}
-
-static void
-micro_abs(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = fabsf( src->f[0] );
- dst->f[1] = fabsf( src->f[1] );
- dst->f[2] = fabsf( src->f[2] );
- dst->f[3] = fabsf( src->f[3] );
-}
-
static void
micro_add(
union tgsi_exec_channel *dst,
@@ -450,76 +750,6 @@ micro_add(
dst->f[3] = src0->f[3] + src1->f[3];
}
-#if 0
-static void
-micro_iadd(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] + src1->i[0];
- dst->i[1] = src0->i[1] + src1->i[1];
- dst->i[2] = src0->i[2] + src1->i[2];
- dst->i[3] = src0->i[3] + src1->i[3];
-}
-#endif
-
-static void
-micro_and(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] & src1->u[0];
- dst->u[1] = src0->u[1] & src1->u[1];
- dst->u[2] = src0->u[2] & src1->u[2];
- dst->u[3] = src0->u[3] & src1->u[3];
-}
-
-static void
-micro_ceil(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = ceilf( src->f[0] );
- dst->f[1] = ceilf( src->f[1] );
- dst->f[2] = ceilf( src->f[2] );
- dst->f[3] = ceilf( src->f[3] );
-}
-
-static void
-micro_cos(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = cosf( src->f[0] );
- dst->f[1] = cosf( src->f[1] );
- dst->f[2] = cosf( src->f[2] );
- dst->f[3] = cosf( src->f[3] );
-}
-
-static void
-micro_ddx(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] =
- dst->f[1] =
- dst->f[2] =
- dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT];
-}
-
-static void
-micro_ddy(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] =
- dst->f[1] =
- dst->f[2] =
- dst->f[3] = src->f[TILE_TOP_LEFT] - src->f[TILE_BOTTOM_LEFT];
-}
-
static void
micro_div(
union tgsi_exec_channel *dst,
@@ -540,81 +770,6 @@ micro_div(
}
}
-#if 0
-static void
-micro_udiv(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] / src1->u[0];
- dst->u[1] = src0->u[1] / src1->u[1];
- dst->u[2] = src0->u[2] / src1->u[2];
- dst->u[3] = src0->u[3] / src1->u[3];
-}
-#endif
-
-static void
-micro_eq(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->f[0] = src0->f[0] == src1->f[0] ? src2->f[0] : src3->f[0];
- dst->f[1] = src0->f[1] == src1->f[1] ? src2->f[1] : src3->f[1];
- dst->f[2] = src0->f[2] == src1->f[2] ? src2->f[2] : src3->f[2];
- dst->f[3] = src0->f[3] == src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-#if 0
-static void
-micro_ieq(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->i[0] = src0->i[0] == src1->i[0] ? src2->i[0] : src3->i[0];
- dst->i[1] = src0->i[1] == src1->i[1] ? src2->i[1] : src3->i[1];
- dst->i[2] = src0->i[2] == src1->i[2] ? src2->i[2] : src3->i[2];
- dst->i[3] = src0->i[3] == src1->i[3] ? src2->i[3] : src3->i[3];
-}
-#endif
-
-static void
-micro_exp2(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src)
-{
-#if FAST_MATH
- dst->f[0] = util_fast_exp2( src->f[0] );
- dst->f[1] = util_fast_exp2( src->f[1] );
- dst->f[2] = util_fast_exp2( src->f[2] );
- dst->f[3] = util_fast_exp2( src->f[3] );
-#else
- dst->f[0] = powf( 2.0f, src->f[0] );
- dst->f[1] = powf( 2.0f, src->f[1] );
- dst->f[2] = powf( 2.0f, src->f[2] );
- dst->f[3] = powf( 2.0f, src->f[3] );
-#endif
-}
-
-#if 0
-static void
-micro_f2ut(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->u[0] = (uint) src->f[0];
- dst->u[1] = (uint) src->f[1];
- dst->u[2] = (uint) src->f[2];
- dst->u[3] = (uint) src->f[3];
-}
-#endif
-
static void
micro_float_clamp(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src)
@@ -642,71 +797,6 @@ micro_float_clamp(union tgsi_exec_channel *dst,
}
static void
-micro_flr(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = floorf( src->f[0] );
- dst->f[1] = floorf( src->f[1] );
- dst->f[2] = floorf( src->f[2] );
- dst->f[3] = floorf( src->f[3] );
-}
-
-static void
-micro_frc(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = src->f[0] - floorf( src->f[0] );
- dst->f[1] = src->f[1] - floorf( src->f[1] );
- dst->f[2] = src->f[2] - floorf( src->f[2] );
- dst->f[3] = src->f[3] - floorf( src->f[3] );
-}
-
-static void
-micro_i2f(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) src->i[0];
- dst->f[1] = (float) src->i[1];
- dst->f[2] = (float) src->i[2];
- dst->f[3] = (float) src->i[3];
-}
-
-static void
-micro_lg2(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
-#if FAST_MATH
- dst->f[0] = util_fast_log2( src->f[0] );
- dst->f[1] = util_fast_log2( src->f[1] );
- dst->f[2] = util_fast_log2( src->f[2] );
- dst->f[3] = util_fast_log2( src->f[3] );
-#else
- dst->f[0] = logf( src->f[0] ) * 1.442695f;
- dst->f[1] = logf( src->f[1] ) * 1.442695f;
- dst->f[2] = logf( src->f[2] ) * 1.442695f;
- dst->f[3] = logf( src->f[3] ) * 1.442695f;
-#endif
-}
-
-static void
-micro_le(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->f[0] = src0->f[0] <= src1->f[0] ? src2->f[0] : src3->f[0];
- dst->f[1] = src0->f[1] <= src1->f[1] ? src2->f[1] : src3->f[1];
- dst->f[2] = src0->f[2] <= src1->f[2] ? src2->f[2] : src3->f[2];
- dst->f[3] = src0->f[3] <= src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-static void
micro_lt(
union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src0,
@@ -720,38 +810,6 @@ micro_lt(
dst->f[3] = src0->f[3] < src1->f[3] ? src2->f[3] : src3->f[3];
}
-#if 0
-static void
-micro_ilt(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->i[0] = src0->i[0] < src1->i[0] ? src2->i[0] : src3->i[0];
- dst->i[1] = src0->i[1] < src1->i[1] ? src2->i[1] : src3->i[1];
- dst->i[2] = src0->i[2] < src1->i[2] ? src2->i[2] : src3->i[2];
- dst->i[3] = src0->i[3] < src1->i[3] ? src2->i[3] : src3->i[3];
-}
-#endif
-
-#if 0
-static void
-micro_ult(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->u[0] = src0->u[0] < src1->u[0] ? src2->u[0] : src3->u[0];
- dst->u[1] = src0->u[1] < src1->u[1] ? src2->u[1] : src3->u[1];
- dst->u[2] = src0->u[2] < src1->u[2] ? src2->u[2] : src3->u[2];
- dst->u[3] = src0->u[3] < src1->u[3] ? src2->u[3] : src3->u[3];
-}
-#endif
-
static void
micro_max(
union tgsi_exec_channel *dst,
@@ -764,34 +822,6 @@ micro_max(
dst->f[3] = src0->f[3] > src1->f[3] ? src0->f[3] : src1->f[3];
}
-#if 0
-static void
-micro_imax(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] > src1->i[0] ? src0->i[0] : src1->i[0];
- dst->i[1] = src0->i[1] > src1->i[1] ? src0->i[1] : src1->i[1];
- dst->i[2] = src0->i[2] > src1->i[2] ? src0->i[2] : src1->i[2];
- dst->i[3] = src0->i[3] > src1->i[3] ? src0->i[3] : src1->i[3];
-}
-#endif
-
-#if 0
-static void
-micro_umax(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] > src1->u[0] ? src0->u[0] : src1->u[0];
- dst->u[1] = src0->u[1] > src1->u[1] ? src0->u[1] : src1->u[1];
- dst->u[2] = src0->u[2] > src1->u[2] ? src0->u[2] : src1->u[2];
- dst->u[3] = src0->u[3] > src1->u[3] ? src0->u[3] : src1->u[3];
-}
-#endif
-
static void
micro_min(
union tgsi_exec_channel *dst,
@@ -804,48 +834,6 @@ micro_min(
dst->f[3] = src0->f[3] < src1->f[3] ? src0->f[3] : src1->f[3];
}
-#if 0
-static void
-micro_imin(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] < src1->i[0] ? src0->i[0] : src1->i[0];
- dst->i[1] = src0->i[1] < src1->i[1] ? src0->i[1] : src1->i[1];
- dst->i[2] = src0->i[2] < src1->i[2] ? src0->i[2] : src1->i[2];
- dst->i[3] = src0->i[3] < src1->i[3] ? src0->i[3] : src1->i[3];
-}
-#endif
-
-#if 0
-static void
-micro_umin(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] < src1->u[0] ? src0->u[0] : src1->u[0];
- dst->u[1] = src0->u[1] < src1->u[1] ? src0->u[1] : src1->u[1];
- dst->u[2] = src0->u[2] < src1->u[2] ? src0->u[2] : src1->u[2];
- dst->u[3] = src0->u[3] < src1->u[3] ? src0->u[3] : src1->u[3];
-}
-#endif
-
-#if 0
-static void
-micro_umod(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] % src1->u[0];
- dst->u[1] = src0->u[1] % src1->u[1];
- dst->u[2] = src0->u[2] % src1->u[2];
- dst->u[3] = src0->u[3] % src1->u[3];
-}
-#endif
-
static void
micro_mul(
union tgsi_exec_channel *dst,
@@ -860,20 +848,6 @@ micro_mul(
#if 0
static void
-micro_imul(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] * src1->i[0];
- dst->i[1] = src0->i[1] * src1->i[1];
- dst->i[2] = src0->i[2] * src1->i[2];
- dst->i[3] = src0->i[3] * src1->i[3];
-}
-#endif
-
-#if 0
-static void
micro_imul64(
union tgsi_exec_channel *dst0,
union tgsi_exec_channel *dst1,
@@ -937,42 +911,6 @@ micro_neg(
dst->f[3] = -src->f[3];
}
-#if 0
-static void
-micro_ineg(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->i[0] = -src->i[0];
- dst->i[1] = -src->i[1];
- dst->i[2] = -src->i[2];
- dst->i[3] = -src->i[3];
-}
-#endif
-
-static void
-micro_not(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->u[0] = ~src->u[0];
- dst->u[1] = ~src->u[1];
- dst->u[2] = ~src->u[2];
- dst->u[3] = ~src->u[3];
-}
-
-static void
-micro_or(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] | src1->u[0];
- dst->u[1] = src0->u[1] | src1->u[1];
- dst->u[2] = src0->u[2] | src1->u[2];
- dst->u[3] = src0->u[3] | src1->u[3];
-}
-
static void
micro_pow(
union tgsi_exec_channel *dst,
@@ -993,88 +931,6 @@ micro_pow(
}
static void
-micro_rnd(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = floorf( src->f[0] + 0.5f );
- dst->f[1] = floorf( src->f[1] + 0.5f );
- dst->f[2] = floorf( src->f[2] + 0.5f );
- dst->f[3] = floorf( src->f[3] + 0.5f );
-}
-
-static void
-micro_sgn(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = src->f[0] < 0.0f ? -1.0f : src->f[0] > 0.0f ? 1.0f : 0.0f;
- dst->f[1] = src->f[1] < 0.0f ? -1.0f : src->f[1] > 0.0f ? 1.0f : 0.0f;
- dst->f[2] = src->f[2] < 0.0f ? -1.0f : src->f[2] > 0.0f ? 1.0f : 0.0f;
- dst->f[3] = src->f[3] < 0.0f ? -1.0f : src->f[3] > 0.0f ? 1.0f : 0.0f;
-}
-
-static void
-micro_shl(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] << src1->i[0];
- dst->i[1] = src0->i[1] << src1->i[1];
- dst->i[2] = src0->i[2] << src1->i[2];
- dst->i[3] = src0->i[3] << src1->i[3];
-}
-
-static void
-micro_ishr(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] >> src1->i[0];
- dst->i[1] = src0->i[1] >> src1->i[1];
- dst->i[2] = src0->i[2] >> src1->i[2];
- dst->i[3] = src0->i[3] >> src1->i[3];
-}
-
-static void
-micro_trunc(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0 )
-{
- dst->f[0] = (float) (int) src0->f[0];
- dst->f[1] = (float) (int) src0->f[1];
- dst->f[2] = (float) (int) src0->f[2];
- dst->f[3] = (float) (int) src0->f[3];
-}
-
-#if 0
-static void
-micro_ushr(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] >> src1->u[0];
- dst->u[1] = src0->u[1] >> src1->u[1];
- dst->u[2] = src0->u[2] >> src1->u[2];
- dst->u[3] = src0->u[3] >> src1->u[3];
-}
-#endif
-
-static void
-micro_sin(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = sinf( src->f[0] );
- dst->f[1] = sinf( src->f[1] );
- dst->f[2] = sinf( src->f[2] );
- dst->f[3] = sinf( src->f[3] );
-}
-
-static void
micro_sqrt( union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src )
{
@@ -1096,31 +952,6 @@ micro_sub(
dst->f[3] = src0->f[3] - src1->f[3];
}
-#if 0
-static void
-micro_u2f(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) src->u[0];
- dst->f[1] = (float) src->u[1];
- dst->f[2] = (float) src->u[2];
- dst->f[3] = (float) src->u[3];
-}
-#endif
-
-static void
-micro_xor(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] ^ src1->u[0];
- dst->u[1] = src0->u[1] ^ src1->u[1];
- dst->u[2] = src0->u[2] ^ src1->u[2];
- dst->u[3] = src0->u[3] ^ src1->u[3];
-}
-
static void
fetch_src_file_channel(
const struct tgsi_exec_machine *mach,
@@ -1130,10 +961,10 @@ fetch_src_file_channel(
union tgsi_exec_channel *chan )
{
switch( swizzle ) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
+ case TGSI_SWIZZLE_X:
+ case TGSI_SWIZZLE_Y:
+ case TGSI_SWIZZLE_Z:
+ case TGSI_SWIZZLE_W:
switch( file ) {
case TGSI_FILE_CONSTANT:
assert(mach->Consts);
@@ -1156,6 +987,7 @@ fetch_src_file_channel(
break;
case TGSI_FILE_INPUT:
+ case TGSI_FILE_SYSTEM_VALUE:
chan->u[0] = mach->Inputs[index->i[0]].xyzw[swizzle].u[0];
chan->u[1] = mach->Inputs[index->i[1]].xyzw[swizzle].u[1];
chan->u[2] = mach->Inputs[index->i[2]].xyzw[swizzle].u[2];
@@ -1188,6 +1020,17 @@ fetch_src_file_channel(
chan->u[3] = mach->Addrs[index->i[3]].xyzw[swizzle].u[3];
break;
+ case TGSI_FILE_PREDICATE:
+ assert(index->i[0] < TGSI_EXEC_NUM_PREDS);
+ assert(index->i[1] < TGSI_EXEC_NUM_PREDS);
+ assert(index->i[2] < TGSI_EXEC_NUM_PREDS);
+ assert(index->i[3] < TGSI_EXEC_NUM_PREDS);
+ chan->u[0] = mach->Predicates[0].xyzw[swizzle].u[0];
+ chan->u[1] = mach->Predicates[0].xyzw[swizzle].u[1];
+ chan->u[2] = mach->Predicates[0].xyzw[swizzle].u[2];
+ chan->u[3] = mach->Predicates[0].xyzw[swizzle].u[3];
+ break;
+
case TGSI_FILE_OUTPUT:
/* vertex/fragment output vars can be read too */
chan->u[0] = mach->Outputs[index->i[0]].xyzw[swizzle].u[0];
@@ -1201,25 +1044,17 @@ fetch_src_file_channel(
}
break;
- case TGSI_EXTSWIZZLE_ZERO:
- *chan = mach->Temps[TEMP_0_I].xyzw[TEMP_0_C];
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- *chan = mach->Temps[TEMP_1_I].xyzw[TEMP_1_C];
- break;
-
default:
assert( 0 );
}
}
static void
-fetch_source(
- const struct tgsi_exec_machine *mach,
- union tgsi_exec_channel *chan,
- const struct tgsi_full_src_register *reg,
- const uint chan_index )
+fetch_source(const struct tgsi_exec_machine *mach,
+ union tgsi_exec_channel *chan,
+ const struct tgsi_full_src_register *reg,
+ const uint chan_index,
+ enum tgsi_exec_datatype src_datatype)
{
union tgsi_exec_channel index;
uint swizzle;
@@ -1228,13 +1063,13 @@ fetch_source(
*
* file[1],
* where:
- * file = SrcRegister.File
- * [1] = SrcRegister.Index
+ * file = Register.File
+ * [1] = Register.Index
*/
index.i[0] =
index.i[1] =
index.i[2] =
- index.i[3] = reg->SrcRegister.Index;
+ index.i[3] = reg->Register.Index;
/* There is an extra source register that indirectly subscripts
* a register file. The direct index now becomes an offset
@@ -1242,11 +1077,11 @@ fetch_source(
*
* file[ind[2].x+1],
* where:
- * ind = SrcRegisterInd.File
- * [2] = SrcRegisterInd.Index
- * .x = SrcRegisterInd.SwizzleX
+ * ind = Indirect.File
+ * [2] = Indirect.Index
+ * .x = Indirect.SwizzleX
*/
- if (reg->SrcRegister.Indirect) {
+ if (reg->Register.Indirect) {
union tgsi_exec_channel index2;
union tgsi_exec_channel indir_index;
const uint execmask = mach->ExecMask;
@@ -1256,22 +1091,22 @@ fetch_source(
index2.i[0] =
index2.i[1] =
index2.i[2] =
- index2.i[3] = reg->SrcRegisterInd.Index;
+ index2.i[3] = reg->Indirect.Index;
/* get current value of address register[swizzle] */
- swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterInd, CHAN_X );
+ swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, CHAN_X );
fetch_src_file_channel(
mach,
- reg->SrcRegisterInd.File,
+ reg->Indirect.File,
swizzle,
&index2,
&indir_index );
/* add value of address register to the offset */
- index.i[0] += (int) indir_index.f[0];
- index.i[1] += (int) indir_index.f[1];
- index.i[2] += (int) indir_index.f[2];
- index.i[3] += (int) indir_index.f[3];
+ index.i[0] += indir_index.i[0];
+ index.i[1] += indir_index.i[1];
+ index.i[2] += indir_index.i[2];
+ index.i[3] += indir_index.i[3];
/* for disabled execution channels, zero-out the index to
* avoid using a potential garbage value.
@@ -1288,15 +1123,16 @@ fetch_source(
*
* file[1][3] == file[1*sizeof(file[1])+3],
* where:
- * [3] = SrcRegisterDim.Index
+ * [3] = Dimension.Index
*/
- if (reg->SrcRegister.Dimension) {
+ if (reg->Register.Dimension) {
/* The size of the first-order array depends on the register file type.
* We need to multiply the index to the first array to get an effective,
* "flat" index that points to the beginning of the second-order array.
*/
- switch (reg->SrcRegister.File) {
+ switch (reg->Register.File) {
case TGSI_FILE_INPUT:
+ case TGSI_FILE_SYSTEM_VALUE:
index.i[0] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
index.i[1] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
index.i[2] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
@@ -1312,10 +1148,10 @@ fetch_source(
assert( 0 );
}
- index.i[0] += reg->SrcRegisterDim.Index;
- index.i[1] += reg->SrcRegisterDim.Index;
- index.i[2] += reg->SrcRegisterDim.Index;
- index.i[3] += reg->SrcRegisterDim.Index;
+ index.i[0] += reg->Dimension.Index;
+ index.i[1] += reg->Dimension.Index;
+ index.i[2] += reg->Dimension.Index;
+ index.i[3] += reg->Dimension.Index;
/* Again, the second subscript index can be addressed indirectly
* identically to the first one.
@@ -1324,11 +1160,11 @@ fetch_source(
*
* file[1][ind[4].y+3],
* where:
- * ind = SrcRegisterDimInd.File
- * [4] = SrcRegisterDimInd.Index
- * .y = SrcRegisterDimInd.SwizzleX
+ * ind = DimIndirect.File
+ * [4] = DimIndirect.Index
+ * .y = DimIndirect.SwizzleX
*/
- if (reg->SrcRegisterDim.Indirect) {
+ if (reg->Dimension.Indirect) {
union tgsi_exec_channel index2;
union tgsi_exec_channel indir_index;
const uint execmask = mach->ExecMask;
@@ -1337,20 +1173,20 @@ fetch_source(
index2.i[0] =
index2.i[1] =
index2.i[2] =
- index2.i[3] = reg->SrcRegisterDimInd.Index;
+ index2.i[3] = reg->DimIndirect.Index;
- swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterDimInd, CHAN_X );
+ swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, CHAN_X );
fetch_src_file_channel(
mach,
- reg->SrcRegisterDimInd.File,
+ reg->DimIndirect.File,
swizzle,
&index2,
&indir_index );
- index.i[0] += (int) indir_index.f[0];
- index.i[1] += (int) indir_index.f[1];
- index.i[2] += (int) indir_index.f[2];
- index.i[3] += (int) indir_index.f[3];
+ index.i[0] += indir_index.i[0];
+ index.i[1] += indir_index.i[1];
+ index.i[2] += indir_index.i[2];
+ index.i[3] += indir_index.i[3];
/* for disabled execution channels, zero-out the index to
* avoid using a potential garbage value.
@@ -1362,49 +1198,43 @@ fetch_source(
}
/* If by any chance there was a need for a 3D array of register
- * files, we would have to check whether SrcRegisterDim is followed
+ * files, we would have to check whether Dimension is followed
* by a dimension register and continue the saga.
*/
}
- swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
+ swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
fetch_src_file_channel(
mach,
- reg->SrcRegister.File,
+ reg->Register.File,
swizzle,
&index,
chan );
- switch (tgsi_util_get_full_src_register_sign_mode( reg, chan_index )) {
- case TGSI_UTIL_SIGN_CLEAR:
- micro_abs( chan, chan );
- break;
-
- case TGSI_UTIL_SIGN_SET:
- micro_abs( chan, chan );
- micro_neg( chan, chan );
- break;
-
- case TGSI_UTIL_SIGN_TOGGLE:
- micro_neg( chan, chan );
- break;
-
- case TGSI_UTIL_SIGN_KEEP:
- break;
+ if (reg->Register.Absolute) {
+ if (src_datatype == TGSI_EXEC_DATA_FLOAT) {
+ micro_abs(chan, chan);
+ } else {
+ micro_iabs(chan, chan);
+ }
}
- if (reg->SrcRegisterExtMod.Complement) {
- micro_sub( chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], chan );
+ if (reg->Register.Negate) {
+ if (src_datatype == TGSI_EXEC_DATA_FLOAT) {
+ micro_neg(chan, chan);
+ } else {
+ micro_ineg(chan, chan);
+ }
}
}
static void
-store_dest(
- struct tgsi_exec_machine *mach,
- const union tgsi_exec_channel *chan,
- const struct tgsi_full_dst_register *reg,
- const struct tgsi_full_instruction *inst,
- uint chan_index )
+store_dest(struct tgsi_exec_machine *mach,
+ const union tgsi_exec_channel *chan,
+ const struct tgsi_full_dst_register *reg,
+ const struct tgsi_full_instruction *inst,
+ uint chan_index,
+ enum tgsi_exec_datatype dst_datatype)
{
uint i;
union tgsi_exec_channel null;
@@ -1413,9 +1243,9 @@ store_dest(
int offset = 0; /* indirection offset */
int index;
-#ifdef DEBUG
- check_inf_or_nan(chan);
-#endif
+ if (dst_datatype == TGSI_EXEC_DATA_FLOAT) {
+ CHECK_INF_OR_NAN(chan);
+ }
/* There is an extra source register that indirectly subscripts
* a register file. The direct index now becomes an offset
@@ -1423,11 +1253,11 @@ store_dest(
*
* file[ind[2].x+1],
* where:
- * ind = DstRegisterInd.File
- * [2] = DstRegisterInd.Index
- * .x = DstRegisterInd.SwizzleX
+ * ind = Indirect.File
+ * [2] = Indirect.Index
+ * .x = Indirect.SwizzleX
*/
- if (reg->DstRegister.Indirect) {
+ if (reg->Register.Indirect) {
union tgsi_exec_channel index;
union tgsi_exec_channel indir_index;
uint swizzle;
@@ -1436,155 +1266,110 @@ store_dest(
index.i[0] =
index.i[1] =
index.i[2] =
- index.i[3] = reg->DstRegisterInd.Index;
+ index.i[3] = reg->Indirect.Index;
/* get current value of address register[swizzle] */
- swizzle = tgsi_util_get_src_register_swizzle( &reg->DstRegisterInd, CHAN_X );
+ swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, CHAN_X );
/* fetch values from the address/indirection register */
fetch_src_file_channel(
mach,
- reg->DstRegisterInd.File,
+ reg->Indirect.File,
swizzle,
&index,
&indir_index );
/* save indirection offset */
- offset = (int) indir_index.f[0];
+ offset = indir_index.i[0];
}
- switch (reg->DstRegister.File) {
+ switch (reg->Register.File) {
case TGSI_FILE_NULL:
dst = &null;
break;
case TGSI_FILE_OUTPUT:
index = mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
- + reg->DstRegister.Index;
+ + reg->Register.Index;
dst = &mach->Outputs[offset + index].xyzw[chan_index];
+#if 0
+ if (TGSI_PROCESSOR_GEOMETRY == mach->Processor) {
+ fprintf(stderr, "STORING OUT[%d] mask(%d), = (", offset + index, execmask);
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (execmask & (1 << i))
+ fprintf(stderr, "%f, ", chan->f[i]);
+ fprintf(stderr, ")\n");
+ }
+#endif
break;
case TGSI_FILE_TEMPORARY:
- index = reg->DstRegister.Index;
+ index = reg->Register.Index;
assert( index < TGSI_EXEC_NUM_TEMPS );
dst = &mach->Temps[offset + index].xyzw[chan_index];
break;
case TGSI_FILE_ADDRESS:
- index = reg->DstRegister.Index;
+ index = reg->Register.Index;
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);
+ dst = &mach->Predicates[index].xyzw[chan_index];
+ break;
+
default:
assert( 0 );
return;
}
- if (inst->InstructionExtNv.CondFlowEnable) {
- union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C];
+ if (inst->Instruction.Predicate) {
uint swizzle;
- uint shift;
- uint mask;
- uint test;
-
- /* Only CC0 supported.
- */
- assert( inst->InstructionExtNv.CondFlowIndex < 1 );
+ union tgsi_exec_channel *pred;
switch (chan_index) {
case CHAN_X:
- swizzle = inst->InstructionExtNv.CondSwizzleX;
+ swizzle = inst->Predicate.SwizzleX;
break;
case CHAN_Y:
- swizzle = inst->InstructionExtNv.CondSwizzleY;
+ swizzle = inst->Predicate.SwizzleY;
break;
case CHAN_Z:
- swizzle = inst->InstructionExtNv.CondSwizzleZ;
+ swizzle = inst->Predicate.SwizzleZ;
break;
case CHAN_W:
- swizzle = inst->InstructionExtNv.CondSwizzleW;
+ swizzle = inst->Predicate.SwizzleW;
break;
default:
- assert( 0 );
+ assert(0);
return;
}
- switch (swizzle) {
- case TGSI_SWIZZLE_X:
- shift = TGSI_EXEC_CC_X_SHIFT;
- mask = TGSI_EXEC_CC_X_MASK;
- break;
- case TGSI_SWIZZLE_Y:
- shift = TGSI_EXEC_CC_Y_SHIFT;
- mask = TGSI_EXEC_CC_Y_MASK;
- break;
- case TGSI_SWIZZLE_Z:
- shift = TGSI_EXEC_CC_Z_SHIFT;
- mask = TGSI_EXEC_CC_Z_MASK;
- break;
- case TGSI_SWIZZLE_W:
- shift = TGSI_EXEC_CC_W_SHIFT;
- mask = TGSI_EXEC_CC_W_MASK;
- break;
- default:
- assert( 0 );
- return;
- }
+ assert(inst->Predicate.Index == 0);
- switch (inst->InstructionExtNv.CondMask) {
- case TGSI_CC_GT:
- test = ~(TGSI_EXEC_CC_GT << shift) & mask;
- for (i = 0; i < QUAD_SIZE; i++)
- if (cc->u[i] & test)
- execmask &= ~(1 << i);
- break;
+ pred = &mach->Predicates[inst->Predicate.Index].xyzw[swizzle];
- case TGSI_CC_EQ:
- test = ~(TGSI_EXEC_CC_EQ << shift) & mask;
- for (i = 0; i < QUAD_SIZE; i++)
- if (cc->u[i] & test)
- execmask &= ~(1 << i);
- break;
-
- case TGSI_CC_LT:
- test = ~(TGSI_EXEC_CC_LT << shift) & mask;
- for (i = 0; i < QUAD_SIZE; i++)
- if (cc->u[i] & test)
- execmask &= ~(1 << i);
- break;
-
- case TGSI_CC_GE:
- test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_EQ) << shift) & mask;
- for (i = 0; i < QUAD_SIZE; i++)
- if (cc->u[i] & test)
- execmask &= ~(1 << i);
- break;
-
- case TGSI_CC_LE:
- test = ~((TGSI_EXEC_CC_LT | TGSI_EXEC_CC_EQ) << shift) & mask;
- for (i = 0; i < QUAD_SIZE; i++)
- if (cc->u[i] & test)
+ if (inst->Predicate.Negate) {
+ for (i = 0; i < QUAD_SIZE; i++) {
+ if (pred->u[i]) {
execmask &= ~(1 << i);
- break;
-
- case TGSI_CC_NE:
- test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_LT | TGSI_EXEC_CC_UN) << shift) & mask;
- for (i = 0; i < QUAD_SIZE; i++)
- if (cc->u[i] & test)
+ }
+ }
+ } else {
+ for (i = 0; i < QUAD_SIZE; i++) {
+ if (!pred->u[i]) {
execmask &= ~(1 << i);
- break;
-
- case TGSI_CC_TR:
- break;
-
- case TGSI_CC_FL:
- for (i = 0; i < QUAD_SIZE; i++)
- execmask &= ~(1 << i);
- break;
-
- default:
- assert( 0 );
- return;
+ }
+ }
}
}
@@ -1622,58 +1407,13 @@ store_dest(
default:
assert( 0 );
}
-
- if (inst->InstructionExtNv.CondDstUpdate) {
- union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C];
- uint shift;
- uint mask;
-
- /* Only CC0 supported.
- */
- assert( inst->InstructionExtNv.CondDstIndex < 1 );
-
- switch (chan_index) {
- case CHAN_X:
- shift = TGSI_EXEC_CC_X_SHIFT;
- mask = ~TGSI_EXEC_CC_X_MASK;
- break;
- case CHAN_Y:
- shift = TGSI_EXEC_CC_Y_SHIFT;
- mask = ~TGSI_EXEC_CC_Y_MASK;
- break;
- case CHAN_Z:
- shift = TGSI_EXEC_CC_Z_SHIFT;
- mask = ~TGSI_EXEC_CC_Z_MASK;
- break;
- case CHAN_W:
- shift = TGSI_EXEC_CC_W_SHIFT;
- mask = ~TGSI_EXEC_CC_W_MASK;
- break;
- default:
- assert( 0 );
- return;
- }
-
- for (i = 0; i < QUAD_SIZE; i++)
- if (execmask & (1 << i)) {
- cc->u[i] &= mask;
- if (dst->f[i] < 0.0f)
- cc->u[i] |= TGSI_EXEC_CC_LT << shift;
- else if (dst->f[i] > 0.0f)
- cc->u[i] |= TGSI_EXEC_CC_GT << shift;
- else if (dst->f[i] == 0.0f)
- cc->u[i] |= TGSI_EXEC_CC_EQ << shift;
- else
- cc->u[i] |= TGSI_EXEC_CC_UN << shift;
- }
- }
}
#define FETCH(VAL,INDEX,CHAN)\
- fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN)
+ fetch_source(mach, VAL, &inst->Src[INDEX], CHAN, TGSI_EXEC_DATA_FLOAT)
#define STORE(VAL,INDEX,CHAN)\
- store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN )
+ store_dest(mach, VAL, &inst->Dst[INDEX], inst, CHAN, TGSI_EXEC_DATA_FLOAT)
/**
@@ -1689,10 +1429,8 @@ exec_kil(struct tgsi_exec_machine *mach,
uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
union tgsi_exec_channel r[1];
- /* This mask stores component bits that were already tested. Note that
- * we test if the value is less than zero, so 1.0 and 0.0 need not to be
- * tested. */
- uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
+ /* This mask stores component bits that were already tested. */
+ uniquemask = 0;
for (chan_index = 0; chan_index < 4; chan_index++)
{
@@ -1700,8 +1438,8 @@ exec_kil(struct tgsi_exec_machine *mach,
uint i;
/* unswizzle channel */
- swizzle = tgsi_util_get_full_src_register_extswizzle (
- &inst->FullSrcRegisters[0],
+ swizzle = tgsi_util_get_full_src_register_swizzle (
+ &inst->Src[0],
chan_index);
/* check if the component has not been already tested */
@@ -1728,35 +1466,40 @@ exec_kilp(struct tgsi_exec_machine *mach,
{
uint kilmask; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
- if (inst->InstructionExtNv.CondFlowEnable) {
- uint swizzle[4];
- uint chan_index;
-
- kilmask = 0x0;
-
- swizzle[0] = inst->InstructionExtNv.CondSwizzleX;
- swizzle[1] = inst->InstructionExtNv.CondSwizzleY;
- swizzle[2] = inst->InstructionExtNv.CondSwizzleZ;
- swizzle[3] = inst->InstructionExtNv.CondSwizzleW;
-
- for (chan_index = 0; chan_index < 4; chan_index++)
- {
- uint i;
+ /* "unconditional" kil */
+ kilmask = mach->ExecMask;
+ mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
+}
- for (i = 0; i < 4; i++) {
- /* TODO: evaluate the condition code */
- if (0)
- kilmask |= 1 << i;
- }
- }
- }
- else {
- /* "unconditional" kil */
- kilmask = mach->ExecMask;
+static void
+emit_vertex(struct tgsi_exec_machine *mach)
+{
+ /* FIXME: check for exec mask correctly
+ unsigned i;
+ for (i = 0; i < QUAD_SIZE; ++i) {
+ if ((mach->ExecMask & (1 << i)))
+ */
+ if (mach->ExecMask) {
+ mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += mach->NumOutputs;
+ mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
}
- mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
}
+static void
+emit_primitive(struct tgsi_exec_machine *mach)
+{
+ unsigned *prim_count = &mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0];
+ /* FIXME: check for exec mask correctly
+ unsigned i;
+ for (i = 0; i < QUAD_SIZE; ++i) {
+ if ((mach->ExecMask & (1 << i)))
+ */
+ if (mach->ExecMask) {
+ ++(*prim_count);
+ debug_assert((*prim_count * mach->NumOutputs) < mach->MaxGeometryShaderOutputs);
+ mach->Primitives[*prim_count] = 0;
+ }
+}
/*
* Fetch a four texture samples using STR texture coordinates.
@@ -1766,7 +1509,8 @@ fetch_texel( struct tgsi_sampler *sampler,
const union tgsi_exec_channel *s,
const union tgsi_exec_channel *t,
const union tgsi_exec_channel *p,
- float lodbias, /* XXX should be float[4] */
+ const union tgsi_exec_channel *c0,
+ enum tgsi_sampler_control control,
union tgsi_exec_channel *r,
union tgsi_exec_channel *g,
union tgsi_exec_channel *b,
@@ -1775,7 +1519,7 @@ fetch_texel( struct tgsi_sampler *sampler,
uint j;
float rgba[NUM_CHANNELS][QUAD_SIZE];
- sampler->get_samples(sampler, s->f, t->f, p->f, lodbias, rgba);
+ sampler->get_samples(sampler, s->f, t->f, p->f, c0->f, control, rgba);
for (j = 0; j < 4; j++) {
r->f[j] = rgba[0][j];
@@ -1786,102 +1530,156 @@ fetch_texel( struct tgsi_sampler *sampler,
}
+#define TEX_MODIFIER_NONE 0
+#define TEX_MODIFIER_PROJECTED 1
+#define TEX_MODIFIER_LOD_BIAS 2
+#define TEX_MODIFIER_EXPLICIT_LOD 3
+
+
static void
exec_tex(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst,
- boolean biasLod,
- boolean projected)
+ uint modifier)
{
- const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+ const uint unit = inst->Src[1].Register.Index;
union tgsi_exec_channel r[4];
+ const union tgsi_exec_channel *lod = &ZeroVec;
+ enum tgsi_sampler_control control;
uint chan_index;
- float lodBias;
- /* debug_printf("Sampler %u unit %u\n", sampler, unit); */
+ if (modifier != TEX_MODIFIER_NONE) {
+ FETCH(&r[3], 0, CHAN_W);
+ if (modifier != TEX_MODIFIER_PROJECTED) {
+ lod = &r[3];
+ }
+ }
+
+ if (modifier == TEX_MODIFIER_EXPLICIT_LOD) {
+ control = tgsi_sampler_lod_explicit;
+ } else {
+ control = tgsi_sampler_lod_bias;
+ }
- switch (inst->InstructionExtTexture.Texture) {
+ switch (inst->Texture.Texture) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
-
FETCH(&r[0], 0, CHAN_X);
- if (projected) {
- FETCH(&r[1], 0, CHAN_W);
- micro_div( &r[0], &r[0], &r[1] );
- }
-
- if (biasLod) {
- FETCH(&r[1], 0, CHAN_W);
- lodBias = r[2].f[0];
+ if (modifier == TEX_MODIFIER_PROJECTED) {
+ micro_div(&r[0], &r[0], &r[3]);
}
- else
- lodBias = 0.0;
fetch_texel(mach->Samplers[unit],
- &r[0], &ZeroVec, &ZeroVec, lodBias, /* S, T, P, BIAS */
- &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
+ &r[0], &ZeroVec, &ZeroVec, lod, /* S, T, P, LOD */
+ control,
+ &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
break;
case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOWRECT:
-
FETCH(&r[0], 0, CHAN_X);
FETCH(&r[1], 0, CHAN_Y);
FETCH(&r[2], 0, CHAN_Z);
- if (projected) {
- FETCH(&r[3], 0, CHAN_W);
- micro_div( &r[0], &r[0], &r[3] );
- micro_div( &r[1], &r[1], &r[3] );
- micro_div( &r[2], &r[2], &r[3] );
- }
-
- if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
- lodBias = r[3].f[0];
+ if (modifier == TEX_MODIFIER_PROJECTED) {
+ micro_div(&r[0], &r[0], &r[3]);
+ micro_div(&r[1], &r[1], &r[3]);
+ micro_div(&r[2], &r[2], &r[3]);
}
- else
- lodBias = 0.0;
fetch_texel(mach->Samplers[unit],
- &r[0], &r[1], &r[2], lodBias, /* inputs */
+ &r[0], &r[1], &r[2], lod, /* S, T, P, LOD */
+ control,
&r[0], &r[1], &r[2], &r[3]); /* outputs */
break;
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE:
-
FETCH(&r[0], 0, CHAN_X);
FETCH(&r[1], 0, CHAN_Y);
FETCH(&r[2], 0, CHAN_Z);
- if (projected) {
- FETCH(&r[3], 0, CHAN_W);
- micro_div( &r[0], &r[0], &r[3] );
- micro_div( &r[1], &r[1], &r[3] );
- micro_div( &r[2], &r[2], &r[3] );
+ if (modifier == TEX_MODIFIER_PROJECTED) {
+ micro_div(&r[0], &r[0], &r[3]);
+ micro_div(&r[1], &r[1], &r[3]);
+ micro_div(&r[2], &r[2], &r[3]);
}
- if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
- lodBias = r[3].f[0];
- }
- else
- lodBias = 0.0;
+ fetch_texel(mach->Samplers[unit],
+ &r[0], &r[1], &r[2], lod,
+ control,
+ &r[0], &r[1], &r[2], &r[3]);
+ break;
+
+ default:
+ assert(0);
+ }
+
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&r[chan_index], 0, chan_index);
+ }
+}
+
+static void
+exec_txd(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ const uint unit = inst->Src[3].Register.Index;
+ union tgsi_exec_channel r[4];
+ uint chan_index;
+
+ /*
+ * XXX: This is fake TXD -- the derivatives are not taken into account, yet.
+ */
+
+ switch (inst->Texture.Texture) {
+ case TGSI_TEXTURE_1D:
+ case TGSI_TEXTURE_SHADOW1D:
+
+ FETCH(&r[0], 0, CHAN_X);
+
+ fetch_texel(mach->Samplers[unit],
+ &r[0], &ZeroVec, &ZeroVec, &ZeroVec, /* S, T, P, BIAS */
+ tgsi_sampler_lod_bias,
+ &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
+ break;
+
+ case TGSI_TEXTURE_2D:
+ case TGSI_TEXTURE_RECT:
+ case TGSI_TEXTURE_SHADOW2D:
+ case TGSI_TEXTURE_SHADOWRECT:
+
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
fetch_texel(mach->Samplers[unit],
- &r[0], &r[1], &r[2], lodBias,
+ &r[0], &r[1], &r[2], &ZeroVec, /* inputs */
+ tgsi_sampler_lod_bias,
+ &r[0], &r[1], &r[2], &r[3]); /* outputs */
+ break;
+
+ case TGSI_TEXTURE_3D:
+ case TGSI_TEXTURE_CUBE:
+
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
+
+ fetch_texel(mach->Samplers[unit],
+ &r[0], &r[1], &r[2], &ZeroVec,
+ tgsi_sampler_lod_bias,
&r[0], &r[1], &r[2], &r[3]);
break;
default:
- assert (0);
+ assert(0);
}
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[chan_index], 0, chan_index );
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&r[chan_index], 0, chan_index);
}
}
@@ -1954,53 +1752,59 @@ typedef void (* eval_coef_func)(
unsigned chan );
static void
-exec_declaration(
- struct tgsi_exec_machine *mach,
- const struct tgsi_full_declaration *decl )
+exec_declaration(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_declaration *decl)
{
- if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
- unsigned first, last, mask;
- eval_coef_func eval;
+ if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
+ if (decl->Declaration.File == TGSI_FILE_INPUT ||
+ decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE) {
+ uint first, last, mask;
- first = decl->DeclarationRange.First;
- last = decl->DeclarationRange.Last;
+ first = decl->Range.First;
+ last = decl->Range.Last;
mask = decl->Declaration.UsageMask;
- switch( decl->Declaration.Interpolate ) {
- case TGSI_INTERPOLATE_CONSTANT:
- eval = eval_constant_coef;
- break;
-
- case TGSI_INTERPOLATE_LINEAR:
- eval = eval_linear_coef;
- break;
+ if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
+ assert(decl->Semantic.Index == 0);
+ assert(first == last);
+ assert(mask == TGSI_WRITEMASK_XYZW);
- case TGSI_INTERPOLATE_PERSPECTIVE:
- eval = eval_perspective_coef;
- break;
+ mach->Inputs[first] = mach->QuadPos;
+ } else if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
+ uint i;
- default:
- eval = NULL;
- assert( 0 );
- }
+ assert(decl->Semantic.Index == 0);
+ assert(first == last);
- if( mask == TGSI_WRITEMASK_XYZW ) {
- unsigned i, j;
-
- for( i = first; i <= last; i++ ) {
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- eval( mach, i, j );
- }
+ for (i = 0; i < QUAD_SIZE; i++) {
+ mach->Inputs[first].xyzw[0].f[i] = mach->Face;
+ }
+ } else {
+ eval_coef_func eval;
+ uint i, j;
+
+ switch (decl->Declaration.Interpolate) {
+ case TGSI_INTERPOLATE_CONSTANT:
+ eval = eval_constant_coef;
+ break;
+
+ case TGSI_INTERPOLATE_LINEAR:
+ eval = eval_linear_coef;
+ break;
+
+ case TGSI_INTERPOLATE_PERSPECTIVE:
+ eval = eval_perspective_coef;
+ break;
+
+ default:
+ assert(0);
+ return;
}
- }
- else {
- unsigned i, j;
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- if( mask & (1 << j) ) {
- for( i = first; i <= last; i++ ) {
- eval( mach, i, j );
+ for (j = 0; j < NUM_CHANNELS; j++) {
+ if (mask & (1 << j)) {
+ for (i = first; i <= last; i++) {
+ eval(mach, i, j);
}
}
}
@@ -2009,6 +1813,585 @@ exec_declaration(
}
}
+typedef void (* micro_op)(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src);
+
+static void
+exec_scalar_unary(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst,
+ micro_op op,
+ enum tgsi_exec_datatype dst_datatype,
+ enum tgsi_exec_datatype src_datatype)
+{
+ unsigned int chan;
+ union tgsi_exec_channel src;
+ union tgsi_exec_channel dst;
+
+ fetch_source(mach, &src, &inst->Src[0], CHAN_X, src_datatype);
+ op(&dst, &src);
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &dst, &inst->Dst[0], inst, chan, dst_datatype);
+ }
+ }
+}
+
+static void
+exec_vector_unary(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst,
+ micro_op op,
+ enum tgsi_exec_datatype dst_datatype,
+ enum tgsi_exec_datatype src_datatype)
+{
+ unsigned int chan;
+ struct tgsi_exec_vector dst;
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ union tgsi_exec_channel src;
+
+ fetch_source(mach, &src, &inst->Src[0], chan, src_datatype);
+ op(&dst.xyzw[chan], &src);
+ }
+ }
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &dst.xyzw[chan], &inst->Dst[0], inst, chan, dst_datatype);
+ }
+ }
+}
+
+static void
+exec_vector_binary(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst,
+ micro_op op,
+ enum tgsi_exec_datatype dst_datatype,
+ enum tgsi_exec_datatype src_datatype)
+{
+ unsigned int chan;
+ struct tgsi_exec_vector dst;
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ union tgsi_exec_channel src[2];
+
+ fetch_source(mach, &src[0], &inst->Src[0], chan, src_datatype);
+ fetch_source(mach, &src[1], &inst->Src[1], chan, src_datatype);
+ op(&dst.xyzw[chan], src);
+ }
+ }
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &dst.xyzw[chan], &inst->Dst[0], inst, chan, dst_datatype);
+ }
+ }
+}
+
+static void
+exec_vector_trinary(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst,
+ micro_op op,
+ enum tgsi_exec_datatype dst_datatype,
+ enum tgsi_exec_datatype src_datatype)
+{
+ unsigned int chan;
+ struct tgsi_exec_vector dst;
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ union tgsi_exec_channel src[3];
+
+ fetch_source(mach, &src[0], &inst->Src[0], chan, src_datatype);
+ fetch_source(mach, &src[1], &inst->Src[1], chan, src_datatype);
+ fetch_source(mach, &src[2], &inst->Src[2], chan, src_datatype);
+ op(&dst.xyzw[chan], src);
+ }
+ }
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &dst.xyzw[chan], &inst->Dst[0], inst, chan, dst_datatype);
+ }
+ }
+}
+
+static void
+exec_dp3(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ unsigned int chan;
+ union tgsi_exec_channel arg[3];
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ micro_mul(&arg[2], &arg[0], &arg[1]);
+
+ for (chan = CHAN_Y; chan <= CHAN_Z; chan++) {
+ fetch_source(mach, &arg[0], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], chan, TGSI_EXEC_DATA_FLOAT);
+ micro_mad(&arg[2], arg);
+ }
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &arg[2], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
+ }
+ }
+}
+
+static void
+exec_dp4(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ unsigned int chan;
+ union tgsi_exec_channel arg[3];
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ micro_mul(&arg[2], &arg[0], &arg[1]);
+
+ for (chan = CHAN_Y; chan <= CHAN_W; chan++) {
+ fetch_source(mach, &arg[0], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], chan, TGSI_EXEC_DATA_FLOAT);
+ micro_mad(&arg[2], arg);
+ }
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &arg[2], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
+ }
+ }
+}
+
+static void
+exec_dp2a(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ unsigned int chan;
+ union tgsi_exec_channel arg[3];
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ micro_mul(&arg[2], &arg[0], &arg[1]);
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+ micro_mad(&arg[0], arg);
+
+ fetch_source(mach, &arg[1], &inst->Src[2], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ micro_add(&arg[0], &arg[0], &arg[1]);
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &arg[0], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
+ }
+ }
+}
+
+static void
+exec_dph(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ unsigned int chan;
+ union tgsi_exec_channel arg[3];
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ micro_mul(&arg[2], &arg[0], &arg[1]);
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+ micro_mad(&arg[2], arg);
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
+ micro_mad(&arg[0], arg);
+
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_W, TGSI_EXEC_DATA_FLOAT);
+ micro_add(&arg[0], &arg[0], &arg[1]);
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &arg[0], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
+ }
+ }
+}
+
+static void
+exec_dp2(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ unsigned int chan;
+ union tgsi_exec_channel arg[3];
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ micro_mul(&arg[2], &arg[0], &arg[1]);
+
+ fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+ fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
+ micro_mad(&arg[2], arg);
+
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
+ if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
+ store_dest(mach, &arg[2], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
+ }
+ }
+}
+
+static void
+exec_break(struct tgsi_exec_machine *mach)
+{
+ if (mach->BreakType == TGSI_EXEC_BREAK_INSIDE_LOOP) {
+ /* turn off loop channels for each enabled exec channel */
+ mach->LoopMask &= ~mach->ExecMask;
+ /* Todo: if mach->LoopMask == 0, jump to end of loop */
+ UPDATE_EXEC_MASK(mach);
+ } else {
+ assert(mach->BreakType == TGSI_EXEC_BREAK_INSIDE_SWITCH);
+
+ mach->Switch.mask = 0x0;
+
+ UPDATE_EXEC_MASK(mach);
+ }
+}
+
+static void
+exec_switch(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ assert(mach->SwitchStackTop < TGSI_EXEC_MAX_SWITCH_NESTING);
+ assert(mach->BreakStackTop < TGSI_EXEC_MAX_BREAK_STACK);
+
+ mach->SwitchStack[mach->SwitchStackTop++] = mach->Switch;
+ fetch_source(mach, &mach->Switch.selector, &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_UINT);
+ mach->Switch.mask = 0x0;
+ mach->Switch.defaultMask = 0x0;
+
+ mach->BreakStack[mach->BreakStackTop++] = mach->BreakType;
+ mach->BreakType = TGSI_EXEC_BREAK_INSIDE_SWITCH;
+
+ UPDATE_EXEC_MASK(mach);
+}
+
+static void
+exec_case(struct tgsi_exec_machine *mach,
+ const struct tgsi_full_instruction *inst)
+{
+ uint prevMask = mach->SwitchStack[mach->SwitchStackTop - 1].mask;
+ union tgsi_exec_channel src;
+ uint mask = 0;
+
+ fetch_source(mach, &src, &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_UINT);
+
+ if (mach->Switch.selector.u[0] == src.u[0]) {
+ mask |= 0x1;
+ }
+ if (mach->Switch.selector.u[1] == src.u[1]) {
+ mask |= 0x2;
+ }
+ if (mach->Switch.selector.u[2] == src.u[2]) {
+ mask |= 0x4;
+ }
+ if (mach->Switch.selector.u[3] == src.u[3]) {
+ mask |= 0x8;
+ }
+
+ mach->Switch.defaultMask |= mask;
+
+ mach->Switch.mask |= mask & prevMask;
+
+ UPDATE_EXEC_MASK(mach);
+}
+
+static void
+exec_default(struct tgsi_exec_machine *mach)
+{
+ uint prevMask = mach->SwitchStack[mach->SwitchStackTop - 1].mask;
+
+ mach->Switch.mask |= ~mach->Switch.defaultMask & prevMask;
+
+ UPDATE_EXEC_MASK(mach);
+}
+
+static void
+exec_endswitch(struct tgsi_exec_machine *mach)
+{
+ mach->Switch = mach->SwitchStack[--mach->SwitchStackTop];
+ mach->BreakType = mach->BreakStack[--mach->BreakStackTop];
+
+ UPDATE_EXEC_MASK(mach);
+}
+
+static void
+micro_i2f(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = (float)src->i[0];
+ dst->f[1] = (float)src->i[1];
+ dst->f[2] = (float)src->i[2];
+ dst->f[3] = (float)src->i[3];
+}
+
+static void
+micro_not(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = ~src->u[0];
+ dst->u[1] = ~src->u[1];
+ dst->u[2] = ~src->u[2];
+ dst->u[3] = ~src->u[3];
+}
+
+static void
+micro_shl(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] << src[1].u[0];
+ dst->u[1] = src[0].u[1] << src[1].u[1];
+ dst->u[2] = src[0].u[2] << src[1].u[2];
+ dst->u[3] = src[0].u[3] << src[1].u[3];
+}
+
+static void
+micro_and(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] & src[1].u[0];
+ dst->u[1] = src[0].u[1] & src[1].u[1];
+ dst->u[2] = src[0].u[2] & src[1].u[2];
+ dst->u[3] = src[0].u[3] & src[1].u[3];
+}
+
+static void
+micro_or(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] | src[1].u[0];
+ dst->u[1] = src[0].u[1] | src[1].u[1];
+ dst->u[2] = src[0].u[2] | src[1].u[2];
+ dst->u[3] = src[0].u[3] | src[1].u[3];
+}
+
+static void
+micro_xor(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] ^ src[1].u[0];
+ dst->u[1] = src[0].u[1] ^ src[1].u[1];
+ dst->u[2] = src[0].u[2] ^ src[1].u[2];
+ dst->u[3] = src[0].u[3] ^ src[1].u[3];
+}
+
+static void
+micro_f2i(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = (int)src->f[0];
+ dst->i[1] = (int)src->f[1];
+ dst->i[2] = (int)src->f[2];
+ dst->i[3] = (int)src->f[3];
+}
+
+static void
+micro_idiv(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src[0].i[0] / src[1].i[0];
+ dst->i[1] = src[0].i[1] / src[1].i[1];
+ dst->i[2] = src[0].i[2] / src[1].i[2];
+ dst->i[3] = src[0].i[3] / src[1].i[3];
+}
+
+static void
+micro_imax(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src[0].i[0] > src[1].i[0] ? src[0].i[0] : src[1].i[0];
+ dst->i[1] = src[0].i[1] > src[1].i[1] ? src[0].i[1] : src[1].i[1];
+ dst->i[2] = src[0].i[2] > src[1].i[2] ? src[0].i[2] : src[1].i[2];
+ dst->i[3] = src[0].i[3] > src[1].i[3] ? src[0].i[3] : src[1].i[3];
+}
+
+static void
+micro_imin(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src[0].i[0] < src[1].i[0] ? src[0].i[0] : src[1].i[0];
+ dst->i[1] = src[0].i[1] < src[1].i[1] ? src[0].i[1] : src[1].i[1];
+ dst->i[2] = src[0].i[2] < src[1].i[2] ? src[0].i[2] : src[1].i[2];
+ dst->i[3] = src[0].i[3] < src[1].i[3] ? src[0].i[3] : src[1].i[3];
+}
+
+static void
+micro_isge(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src[0].i[0] >= src[1].i[0] ? -1 : 0;
+ dst->i[1] = src[0].i[1] >= src[1].i[1] ? -1 : 0;
+ dst->i[2] = src[0].i[2] >= src[1].i[2] ? -1 : 0;
+ dst->i[3] = src[0].i[3] >= src[1].i[3] ? -1 : 0;
+}
+
+static void
+micro_ishr(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src[0].i[0] >> src[1].i[0];
+ dst->i[1] = src[0].i[1] >> src[1].i[1];
+ dst->i[2] = src[0].i[2] >> src[1].i[2];
+ dst->i[3] = src[0].i[3] >> src[1].i[3];
+}
+
+static void
+micro_islt(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->i[0] = src[0].i[0] < src[1].i[0] ? -1 : 0;
+ dst->i[1] = src[0].i[1] < src[1].i[1] ? -1 : 0;
+ dst->i[2] = src[0].i[2] < src[1].i[2] ? -1 : 0;
+ dst->i[3] = src[0].i[3] < src[1].i[3] ? -1 : 0;
+}
+
+static void
+micro_f2u(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = (uint)src->f[0];
+ dst->u[1] = (uint)src->f[1];
+ dst->u[2] = (uint)src->f[2];
+ dst->u[3] = (uint)src->f[3];
+}
+
+static void
+micro_u2f(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->f[0] = (float)src->u[0];
+ dst->f[1] = (float)src->u[1];
+ dst->f[2] = (float)src->u[2];
+ dst->f[3] = (float)src->u[3];
+}
+
+static void
+micro_uadd(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] + src[1].u[0];
+ dst->u[1] = src[0].u[1] + src[1].u[1];
+ dst->u[2] = src[0].u[2] + src[1].u[2];
+ dst->u[3] = src[0].u[3] + src[1].u[3];
+}
+
+static void
+micro_udiv(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] / src[1].u[0];
+ dst->u[1] = src[0].u[1] / src[1].u[1];
+ dst->u[2] = src[0].u[2] / src[1].u[2];
+ dst->u[3] = src[0].u[3] / src[1].u[3];
+}
+
+static void
+micro_umad(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] * src[1].u[0] + src[2].u[0];
+ dst->u[1] = src[0].u[1] * src[1].u[1] + src[2].u[1];
+ dst->u[2] = src[0].u[2] * src[1].u[2] + src[2].u[2];
+ dst->u[3] = src[0].u[3] * src[1].u[3] + src[2].u[3];
+}
+
+static void
+micro_umax(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] > src[1].u[0] ? src[0].u[0] : src[1].u[0];
+ dst->u[1] = src[0].u[1] > src[1].u[1] ? src[0].u[1] : src[1].u[1];
+ dst->u[2] = src[0].u[2] > src[1].u[2] ? src[0].u[2] : src[1].u[2];
+ dst->u[3] = src[0].u[3] > src[1].u[3] ? src[0].u[3] : src[1].u[3];
+}
+
+static void
+micro_umin(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] < src[1].u[0] ? src[0].u[0] : src[1].u[0];
+ dst->u[1] = src[0].u[1] < src[1].u[1] ? src[0].u[1] : src[1].u[1];
+ dst->u[2] = src[0].u[2] < src[1].u[2] ? src[0].u[2] : src[1].u[2];
+ dst->u[3] = src[0].u[3] < src[1].u[3] ? src[0].u[3] : src[1].u[3];
+}
+
+static void
+micro_umod(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] % src[1].u[0];
+ dst->u[1] = src[0].u[1] % src[1].u[1];
+ dst->u[2] = src[0].u[2] % src[1].u[2];
+ dst->u[3] = src[0].u[3] % src[1].u[3];
+}
+
+static void
+micro_umul(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] * src[1].u[0];
+ dst->u[1] = src[0].u[1] * src[1].u[1];
+ dst->u[2] = src[0].u[2] * src[1].u[2];
+ dst->u[3] = src[0].u[3] * src[1].u[3];
+}
+
+static void
+micro_useq(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] == src[1].u[0] ? ~0 : 0;
+ dst->u[1] = src[0].u[1] == src[1].u[1] ? ~0 : 0;
+ dst->u[2] = src[0].u[2] == src[1].u[2] ? ~0 : 0;
+ dst->u[3] = src[0].u[3] == src[1].u[3] ? ~0 : 0;
+}
+
+static void
+micro_usge(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] >= src[1].u[0] ? ~0 : 0;
+ dst->u[1] = src[0].u[1] >= src[1].u[1] ? ~0 : 0;
+ dst->u[2] = src[0].u[2] >= src[1].u[2] ? ~0 : 0;
+ dst->u[3] = src[0].u[3] >= src[1].u[3] ? ~0 : 0;
+}
+
+static void
+micro_ushr(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] >> src[1].u[0];
+ dst->u[1] = src[0].u[1] >> src[1].u[1];
+ dst->u[2] = src[0].u[2] >> src[1].u[2];
+ dst->u[3] = src[0].u[3] >> src[1].u[3];
+}
+
+static void
+micro_uslt(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] < src[1].u[0] ? ~0 : 0;
+ dst->u[1] = src[0].u[1] < src[1].u[1] ? ~0 : 0;
+ dst->u[2] = src[0].u[2] < src[1].u[2] ? ~0 : 0;
+ dst->u[3] = src[0].u[3] < src[1].u[3] ? ~0 : 0;
+}
+
+static void
+micro_usne(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ dst->u[0] = src[0].u[0] != src[1].u[0] ? ~0 : 0;
+ dst->u[1] = src[0].u[1] != src[1].u[1] ? ~0 : 0;
+ dst->u[2] = src[0].u[2] != src[1].u[2] ? ~0 : 0;
+ dst->u[3] = src[0].u[3] != src[1].u[3] ? ~0 : 0;
+}
+
static void
exec_instruction(
struct tgsi_exec_machine *mach,
@@ -2017,51 +2400,24 @@ exec_instruction(
{
uint chan_index;
union tgsi_exec_channel r[10];
+ union tgsi_exec_channel d[8];
(*pc)++;
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
- case TGSI_OPCODE_FLR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_flr( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_arl, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_MOV:
- case TGSI_OPCODE_SWZ:
- if (inst->Flags & SOA_DEPENDENCY_FLAG) {
- /* Do all fetches into temp regs, then do all stores to avoid
- * intermediate/accidental clobbering. This could be done all the
- * time for MOV but for other instructions we'll need more temps...
- */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[chan_index], 0, chan_index );
- }
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[chan_index], 0, chan_index );
- }
- }
- else {
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- STORE( &r[0], 0, chan_index );
- }
- }
+ exec_vector_unary(mach, inst, micro_mov, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_LIT:
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
- }
-
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
FETCH( &r[0], 0, CHAN_X );
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- micro_max( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, CHAN_Y );
+ micro_max(&d[CHAN_Y], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]);
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
@@ -2072,34 +2428,30 @@ exec_instruction(
micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] );
micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] );
micro_pow( &r[1], &r[1], &r[2] );
- micro_lt( &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, CHAN_Z );
+ micro_lt(&d[CHAN_Z], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]);
}
- }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ STORE(&d[CHAN_Y], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ STORE(&d[CHAN_Z], 0, CHAN_Z);
+ }
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
+ }
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
break;
case TGSI_OPCODE_RCP:
- /* TGSI_OPCODE_RECIP */
- FETCH( &r[0], 0, CHAN_X );
- micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_scalar_unary(mach, inst, micro_rcp, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_RSQ:
- /* TGSI_OPCODE_RECIPSQRT */
- FETCH( &r[0], 0, CHAN_X );
- micro_abs( &r[0], &r[0] );
- micro_sqrt( &r[0], &r[0] );
- micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_scalar_unary(mach, inst, micro_rsq, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_EXP:
@@ -2144,14 +2496,13 @@ exec_instruction(
break;
case TGSI_OPCODE_MUL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index )
- {
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
FETCH(&r[0], 0, chan_index);
FETCH(&r[1], 1, chan_index);
-
- micro_mul( &r[0], &r[0], &r[1] );
-
- STORE(&r[0], 0, chan_index);
+ micro_mul(&d[chan_index], &r[0], &r[1]);
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
@@ -2159,82 +2510,45 @@ exec_instruction(
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( &r[0], 0, chan_index );
FETCH( &r[1], 1, chan_index );
- micro_add( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
+ micro_add(&d[chan_index], &r[0], &r[1]);
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
case TGSI_OPCODE_DP3:
- /* TGSI_OPCODE_DOT3 */
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Z );
- FETCH( &r[2], 1, CHAN_Z );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_dp3(mach, inst);
break;
- case TGSI_OPCODE_DP4:
- /* TGSI_OPCODE_DOT4 */
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Y);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Z);
- FETCH(&r[2], 1, CHAN_Z);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_W);
- FETCH(&r[2], 1, CHAN_W);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ case TGSI_OPCODE_DP4:
+ exec_dp4(mach, inst);
break;
case TGSI_OPCODE_DST:
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
- }
-
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
FETCH( &r[0], 0, CHAN_Y );
FETCH( &r[1], 1, CHAN_Y);
- micro_mul( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, CHAN_Y );
+ micro_mul(&d[CHAN_Y], &r[0], &r[1]);
}
-
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_Z );
- STORE( &r[0], 0, CHAN_Z );
+ FETCH(&d[CHAN_Z], 0, CHAN_Z);
}
-
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- FETCH( &r[0], 1, CHAN_W );
- STORE( &r[0], 0, CHAN_W );
+ FETCH(&d[CHAN_W], 1, CHAN_W);
+ }
+
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ STORE(&d[CHAN_Y], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ STORE(&d[CHAN_Z], 0, CHAN_Z);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ STORE(&d[CHAN_W], 0, CHAN_W);
}
break;
@@ -2244,9 +2558,10 @@ exec_instruction(
FETCH(&r[1], 1, chan_index);
/* XXX use micro_min()?? */
- micro_lt( &r[0], &r[0], &r[1], &r[0], &r[1] );
-
- STORE(&r[0], 0, chan_index);
+ micro_lt(&d[chan_index], &r[0], &r[1], &r[0], &r[1]);
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
@@ -2256,67 +2571,38 @@ exec_instruction(
FETCH(&r[1], 1, chan_index);
/* XXX use micro_max()?? */
- micro_lt( &r[0], &r[0], &r[1], &r[1], &r[0] );
-
- STORE(&r[0], 0, chan_index );
+ micro_lt(&d[chan_index], &r[0], &r[1], &r[1], &r[0] );
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
case TGSI_OPCODE_SLT:
- /* TGSI_OPCODE_SETLT */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_lt( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_slt, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SGE:
- /* TGSI_OPCODE_SETGE */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_le( &r[0], &r[1], &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_sge, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_MAD:
- /* TGSI_OPCODE_MADD */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_mul( &r[0], &r[0], &r[1] );
- FETCH( &r[1], 2, chan_index );
- micro_add( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_trinary(mach, inst, micro_mad, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SUB:
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH(&r[0], 0, chan_index);
FETCH(&r[1], 1, chan_index);
-
- micro_sub( &r[0], &r[0], &r[1] );
-
- STORE(&r[0], 0, chan_index);
+ micro_sub(&d[chan_index], &r[0], &r[1]);
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
case TGSI_OPCODE_LRP:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
- FETCH(&r[2], 2, chan_index);
-
- micro_sub( &r[1], &r[1], &r[2] );
- micro_mul( &r[0], &r[0], &r[1] );
- micro_add( &r[0], &r[0], &r[2] );
-
- STORE(&r[0], 0, chan_index);
- }
+ exec_vector_trinary(mach, inst, micro_lrp, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_CND:
@@ -2324,35 +2610,19 @@ exec_instruction(
FETCH(&r[0], 0, chan_index);
FETCH(&r[1], 1, chan_index);
FETCH(&r[2], 2, chan_index);
- micro_lt(&r[0], &mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C], &r[2], &r[0], &r[1]);
- STORE(&r[0], 0, chan_index);
+ micro_lt(&d[chan_index], &mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C], &r[2], &r[0], &r[1]);
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
case TGSI_OPCODE_DP2A:
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH( &r[2], 2, CHAN_X );
- micro_add( &r[0], &r[0], &r[2] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_dp2a(mach, inst);
break;
case TGSI_OPCODE_FRC:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_frc( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_frc, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_CLAMP:
@@ -2361,40 +2631,27 @@ exec_instruction(
FETCH(&r[1], 1, chan_index);
micro_max(&r[0], &r[0], &r[1]);
FETCH(&r[1], 2, chan_index);
- micro_min(&r[0], &r[0], &r[1]);
- STORE(&r[0], 0, chan_index);
+ micro_min(&d[chan_index], &r[0], &r[1]);
}
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
+ }
+ break;
+
+ case TGSI_OPCODE_FLR:
+ exec_vector_unary(mach, inst, micro_flr, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_ROUND:
- case TGSI_OPCODE_ARR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_rnd( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_rnd, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_EX2:
- FETCH(&r[0], 0, CHAN_X);
-
-#if FAST_MATH
- micro_exp2( &r[0], &r[0] );
-#else
- micro_pow( &r[0], &mach->Temps[TEMP_2_I].xyzw[TEMP_2_C], &r[0] );
-#endif
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_scalar_unary(mach, inst, micro_exp2, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_LG2:
- FETCH( &r[0], 0, CHAN_X );
- micro_lg2( &r[0], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_scalar_unary(mach, inst, micro_lg2, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_POW:
@@ -2418,11 +2675,7 @@ exec_instruction(
FETCH(&r[4], 1, CHAN_Y);
micro_mul( &r[5], &r[3], &r[4] );
- micro_sub( &r[2], &r[2], &r[5] );
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &r[2], 0, CHAN_X );
- }
+ micro_sub(&d[CHAN_X], &r[2], &r[5]);
FETCH(&r[2], 1, CHAN_X);
@@ -2431,34 +2684,29 @@ exec_instruction(
FETCH(&r[5], 0, CHAN_X);
micro_mul( &r[1], &r[1], &r[5] );
- micro_sub( &r[3], &r[3], &r[1] );
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- STORE( &r[3], 0, CHAN_Y );
- }
+ micro_sub(&d[CHAN_Y], &r[3], &r[1]);
micro_mul( &r[5], &r[5], &r[4] );
micro_mul( &r[0], &r[0], &r[2] );
- micro_sub( &r[5], &r[5], &r[0] );
+ micro_sub(&d[CHAN_Z], &r[5], &r[0]);
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- STORE( &r[5], 0, CHAN_Z );
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ STORE(&d[CHAN_X], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ STORE(&d[CHAN_Y], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ STORE(&d[CHAN_Z], 0, CHAN_Z);
}
-
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
break;
- case TGSI_OPCODE_ABS:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
-
- micro_abs( &r[0], &r[0] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
+ case TGSI_OPCODE_ABS:
+ exec_vector_unary(mach, inst, micro_abs, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
+ break;
case TGSI_OPCODE_RCC:
FETCH(&r[0], 0, CHAN_X);
@@ -2470,56 +2718,19 @@ exec_instruction(
break;
case TGSI_OPCODE_DPH:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Y);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Z);
- FETCH(&r[2], 1, CHAN_Z);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 1, CHAN_W);
-
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_dph(mach, inst);
break;
case TGSI_OPCODE_COS:
- FETCH(&r[0], 0, CHAN_X);
-
- micro_cos( &r[0], &r[0] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_scalar_unary(mach, inst, micro_cos, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_DDX:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_ddx( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_ddx, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_DDY:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_ddy( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_ddy, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_KILP:
@@ -2596,14 +2807,7 @@ exec_instruction(
break;
case TGSI_OPCODE_SEQ:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_eq( &r[0], &r[0], &r[1],
- &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C],
- &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_seq, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SFL:
@@ -2613,38 +2817,19 @@ exec_instruction(
break;
case TGSI_OPCODE_SGT:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_le( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_sgt, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SIN:
- FETCH( &r[0], 0, CHAN_X );
- micro_sin( &r[0], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_scalar_unary(mach, inst, micro_sin, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SLE:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_le( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_sle, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SNE:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_eq( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_sne, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_STR:
@@ -2657,14 +2842,14 @@ exec_instruction(
/* simple texture lookup */
/* src[0] = texcoord */
/* src[1] = sampler unit */
- exec_tex(mach, inst, FALSE, FALSE);
+ exec_tex(mach, inst, TEX_MODIFIER_NONE);
break;
case TGSI_OPCODE_TXB:
/* Texture lookup with lod bias */
/* src[0] = texcoord (src[0].w = LOD bias) */
/* src[1] = sampler unit */
- exec_tex(mach, inst, TRUE, FALSE);
+ exec_tex(mach, inst, TEX_MODIFIER_LOD_BIAS);
break;
case TGSI_OPCODE_TXD:
@@ -2673,21 +2858,21 @@ exec_instruction(
/* src[1] = d[strq]/dx */
/* src[2] = d[strq]/dy */
/* src[3] = sampler unit */
- assert (0);
+ exec_txd(mach, inst);
break;
case TGSI_OPCODE_TXL:
/* Texture lookup with explit LOD */
/* src[0] = texcoord (src[0].w = LOD) */
/* src[1] = sampler unit */
- exec_tex(mach, inst, TRUE, FALSE);
+ exec_tex(mach, inst, TEX_MODIFIER_EXPLICIT_LOD);
break;
case TGSI_OPCODE_TXP:
/* Texture lookup with projection */
/* src[0] = texcoord (src[0].w = projection) */
/* src[1] = sampler unit */
- exec_tex(mach, inst, FALSE, TRUE);
+ exec_tex(mach, inst, TEX_MODIFIER_PROJECTED);
break;
case TGSI_OPCODE_UP2H:
@@ -2717,13 +2902,8 @@ exec_instruction(
micro_mul(&r[3], &r[3], &r[1]);
micro_add(&r[2], &r[2], &r[3]);
FETCH(&r[3], 0, CHAN_X);
- micro_add(&r[2], &r[2], &r[3]);
- if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
- STORE(&r[2], 0, CHAN_X);
- }
- if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
- STORE(&r[2], 0, CHAN_Z);
- }
+ micro_add(&d[CHAN_X], &r[2], &r[3]);
+
}
if (IS_CHANNEL_ENABLED(*inst, CHAN_Y) ||
IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
@@ -2733,13 +2913,20 @@ exec_instruction(
micro_mul(&r[3], &r[3], &r[1]);
micro_add(&r[2], &r[2], &r[3]);
FETCH(&r[3], 0, CHAN_Y);
- micro_add(&r[2], &r[2], &r[3]);
- if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
- STORE(&r[2], 0, CHAN_Y);
- }
- if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
- STORE(&r[2], 0, CHAN_W);
- }
+ micro_add(&d[CHAN_Y], &r[2], &r[3]);
+
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ STORE(&d[CHAN_X], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ STORE(&d[CHAN_Y], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ STORE(&d[CHAN_X], 0, CHAN_Z);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ STORE(&d[CHAN_Y], 0, CHAN_W);
}
break;
@@ -2747,6 +2934,10 @@ exec_instruction(
assert (0);
break;
+ case TGSI_OPCODE_ARR:
+ exec_vector_unary(mach, inst, micro_arr, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_FLOAT);
+ break;
+
case TGSI_OPCODE_BRA:
assert (0);
break;
@@ -2766,6 +2957,8 @@ exec_instruction(
mach->CallStack[mach->CallStackTop].CondStackTop = mach->CondStackTop;
mach->CallStack[mach->CallStackTop].LoopStackTop = mach->LoopStackTop;
mach->CallStack[mach->CallStackTop].ContStackTop = mach->ContStackTop;
+ mach->CallStack[mach->CallStackTop].SwitchStackTop = mach->SwitchStackTop;
+ mach->CallStack[mach->CallStackTop].BreakStackTop = mach->BreakStackTop;
/* note that PC was already incremented above */
mach->CallStack[mach->CallStackTop].ReturnAddr = *pc;
@@ -2773,16 +2966,21 @@ exec_instruction(
/* Second, push the Cond, Loop, Cont, Func stacks */
assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
- mach->CondStack[mach->CondStackTop++] = mach->CondMask;
assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->ContStack[mach->ContStackTop++] = mach->ContMask;
+ assert(mach->SwitchStackTop < TGSI_EXEC_MAX_SWITCH_NESTING);
+ assert(mach->BreakStackTop < TGSI_EXEC_MAX_BREAK_STACK);
assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
+
+ mach->CondStack[mach->CondStackTop++] = mach->CondMask;
+ mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
+ mach->ContStack[mach->ContStackTop++] = mach->ContMask;
+ mach->SwitchStack[mach->SwitchStackTop++] = mach->Switch;
+ mach->BreakStack[mach->BreakStackTop++] = mach->BreakType;
mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask;
/* Finally, jump to the subroutine */
- *pc = inst->InstructionExtLabel.Label;
+ *pc = inst->Label.Label;
}
break;
@@ -2811,6 +3009,12 @@ exec_instruction(
mach->ContStackTop = mach->CallStack[mach->CallStackTop].ContStackTop;
mach->ContMask = mach->ContStack[mach->ContStackTop];
+ mach->SwitchStackTop = mach->CallStack[mach->CallStackTop].SwitchStackTop;
+ mach->Switch = mach->SwitchStack[mach->SwitchStackTop];
+
+ mach->BreakStackTop = mach->CallStack[mach->CallStackTop].BreakStackTop;
+ mach->BreakType = mach->BreakStack[mach->BreakStackTop];
+
assert(mach->FuncStackTop > 0);
mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
@@ -2821,12 +3025,7 @@ exec_instruction(
break;
case TGSI_OPCODE_SSG:
- /* TGSI_OPCODE_SGN */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_sgn( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_sgn, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_CMP:
@@ -2834,10 +3033,10 @@ exec_instruction(
FETCH(&r[0], 0, chan_index);
FETCH(&r[1], 1, chan_index);
FETCH(&r[2], 2, chan_index);
-
- micro_lt( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2] );
-
- STORE(&r[0], 0, chan_index);
+ micro_lt(&d[chan_index], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2]);
+ }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&d[chan_index], 0, chan_index);
}
break;
@@ -2933,18 +3132,7 @@ exec_instruction(
break;
case TGSI_OPCODE_DP2:
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
+ exec_dp2(mach, inst);
break;
case TGSI_OPCODE_IF:
@@ -3010,71 +3198,31 @@ exec_instruction(
break;
case TGSI_OPCODE_CEIL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_ceil( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_ceil, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_I2F:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_i2f( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_i2f, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_INT);
break;
case TGSI_OPCODE_NOT:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_not( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_not, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
case TGSI_OPCODE_TRUNC:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_trunc( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_unary(mach, inst, micro_trunc, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_SHL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_shl( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SHR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_ishr( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_shl, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
case TGSI_OPCODE_AND:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_and( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_and, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
case TGSI_OPCODE_OR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_or( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_or, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
case TGSI_OPCODE_MOD:
@@ -3082,12 +3230,7 @@ exec_instruction(
break;
case TGSI_OPCODE_XOR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_xor( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
+ exec_vector_binary(mach, inst, micro_xor, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
break;
case TGSI_OPCODE_SAD:
@@ -3103,13 +3246,11 @@ exec_instruction(
break;
case TGSI_OPCODE_EMIT:
- mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += 16;
- mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
+ emit_vertex(mach);
break;
case TGSI_OPCODE_ENDPRIM:
- mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]++;
- mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] = 0;
+ emit_primitive(mach);
break;
case TGSI_OPCODE_BGNFOR:
@@ -3117,43 +3258,62 @@ exec_instruction(
for (chan_index = 0; chan_index < 3; chan_index++) {
FETCH( &mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[chan_index], 0, chan_index );
}
- STORE( &mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[CHAN_Y], 0, CHAN_X );
++mach->LoopCounterStackTop;
+ STORE(&mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X], 0, CHAN_X);
+ /* update LoopMask */
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[0] <= 0.0f) {
+ mach->LoopMask &= ~0x1;
+ }
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[1] <= 0.0f) {
+ mach->LoopMask &= ~0x2;
+ }
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[2] <= 0.0f) {
+ mach->LoopMask &= ~0x4;
+ }
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[3] <= 0.0f) {
+ mach->LoopMask &= ~0x8;
+ }
+ /* TODO: if mach->LoopMask == 0, jump to end of loop */
+ UPDATE_EXEC_MASK(mach);
/* fall-through (for now) */
case TGSI_OPCODE_BGNLOOP:
/* push LoopMask and ContMasks */
assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->ContStack[mach->ContStackTop++] = mach->ContMask;
assert(mach->LoopLabelStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ assert(mach->BreakStackTop < TGSI_EXEC_MAX_BREAK_STACK);
+
+ mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
+ mach->ContStack[mach->ContStackTop++] = mach->ContMask;
mach->LoopLabelStack[mach->LoopLabelStackTop++] = *pc - 1;
+ mach->BreakStack[mach->BreakStackTop++] = mach->BreakType;
+ mach->BreakType = TGSI_EXEC_BREAK_INSIDE_LOOP;
break;
case TGSI_OPCODE_ENDFOR:
assert(mach->LoopCounterStackTop > 0);
- micro_sub( &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X],
- &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X],
- &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
+ micro_sub(&mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y],
+ &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y],
+ &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C]);
/* update LoopMask */
- if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[0] <= 0) {
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[0] <= 0.0f) {
mach->LoopMask &= ~0x1;
}
- if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[1] <= 0 ) {
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[1] <= 0.0f) {
mach->LoopMask &= ~0x2;
}
- if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[2] <= 0 ) {
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[2] <= 0.0f) {
mach->LoopMask &= ~0x4;
}
- if( mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X].f[3] <= 0 ) {
+ if (mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y].f[3] <= 0.0f) {
mach->LoopMask &= ~0x8;
}
- micro_add( &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y],
- &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Y],
- &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Z]);
+ micro_add(&mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X],
+ &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_X],
+ &mach->LoopCounterStack[mach->LoopCounterStackTop - 1].xyzw[CHAN_Z]);
assert(mach->LoopLabelStackTop > 0);
inst = mach->Instructions + mach->LoopLabelStack[mach->LoopLabelStackTop - 1];
- STORE( &mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[CHAN_Y], 0, CHAN_X );
+ STORE(&mach->LoopCounterStack[mach->LoopCounterStackTop].xyzw[CHAN_X], 0, CHAN_X);
/* Restore ContMask, but don't pop */
assert(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
@@ -3174,6 +3334,8 @@ exec_instruction(
--mach->LoopLabelStackTop;
assert(mach->LoopCounterStackTop > 0);
--mach->LoopCounterStackTop;
+
+ mach->BreakType = mach->BreakStack[--mach->BreakStackTop];
}
UPDATE_EXEC_MASK(mach);
break;
@@ -3197,15 +3359,14 @@ exec_instruction(
mach->ContMask = mach->ContStack[--mach->ContStackTop];
assert(mach->LoopLabelStackTop > 0);
--mach->LoopLabelStackTop;
+
+ mach->BreakType = mach->BreakStack[--mach->BreakStackTop];
}
UPDATE_EXEC_MASK(mach);
break;
case TGSI_OPCODE_BRK:
- /* turn off loop channels for each enabled exec channel */
- mach->LoopMask &= ~mach->ExecMask;
- /* Todo: if mach->LoopMask == 0, jump to end of loop */
- UPDATE_EXEC_MASK(mach);
+ exec_break(mach);
break;
case TGSI_OPCODE_CONT:
@@ -3220,26 +3381,160 @@ exec_instruction(
break;
case TGSI_OPCODE_ENDSUB:
- /* no-op */
+ /*
+ * XXX: This really should be a no-op. We should never reach this opcode.
+ */
+
+ assert(mach->CallStackTop > 0);
+ mach->CallStackTop--;
+
+ mach->CondStackTop = mach->CallStack[mach->CallStackTop].CondStackTop;
+ mach->CondMask = mach->CondStack[mach->CondStackTop];
+
+ mach->LoopStackTop = mach->CallStack[mach->CallStackTop].LoopStackTop;
+ mach->LoopMask = mach->LoopStack[mach->LoopStackTop];
+
+ mach->ContStackTop = mach->CallStack[mach->CallStackTop].ContStackTop;
+ mach->ContMask = mach->ContStack[mach->ContStackTop];
+
+ mach->SwitchStackTop = mach->CallStack[mach->CallStackTop].SwitchStackTop;
+ mach->Switch = mach->SwitchStack[mach->SwitchStackTop];
+
+ mach->BreakStackTop = mach->CallStack[mach->CallStackTop].BreakStackTop;
+ mach->BreakType = mach->BreakStack[mach->BreakStackTop];
+
+ assert(mach->FuncStackTop > 0);
+ mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
+
+ *pc = mach->CallStack[mach->CallStackTop].ReturnAddr;
+
+ UPDATE_EXEC_MASK(mach);
break;
- case TGSI_OPCODE_NOISE1:
- assert( 0 );
+ case TGSI_OPCODE_NOP:
break;
- case TGSI_OPCODE_NOISE2:
- assert( 0 );
+ case TGSI_OPCODE_BREAKC:
+ FETCH(&r[0], 0, CHAN_X);
+ /* update CondMask */
+ if (r[0].u[0] && (mach->ExecMask & 0x1)) {
+ mach->LoopMask &= ~0x1;
+ }
+ if (r[0].u[1] && (mach->ExecMask & 0x2)) {
+ mach->LoopMask &= ~0x2;
+ }
+ if (r[0].u[2] && (mach->ExecMask & 0x4)) {
+ mach->LoopMask &= ~0x4;
+ }
+ if (r[0].u[3] && (mach->ExecMask & 0x8)) {
+ mach->LoopMask &= ~0x8;
+ }
+ /* Todo: if mach->LoopMask == 0, jump to end of loop */
+ UPDATE_EXEC_MASK(mach);
break;
- case TGSI_OPCODE_NOISE3:
- assert( 0 );
+ case TGSI_OPCODE_F2I:
+ exec_vector_unary(mach, inst, micro_f2i, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_FLOAT);
break;
- case TGSI_OPCODE_NOISE4:
- assert( 0 );
+ case TGSI_OPCODE_IDIV:
+ exec_vector_binary(mach, inst, micro_idiv, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
break;
- case TGSI_OPCODE_NOP:
+ case TGSI_OPCODE_IMAX:
+ exec_vector_binary(mach, inst, micro_imax, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
+ case TGSI_OPCODE_IMIN:
+ exec_vector_binary(mach, inst, micro_imin, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
+ case TGSI_OPCODE_INEG:
+ exec_vector_unary(mach, inst, micro_ineg, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
+ case TGSI_OPCODE_ISGE:
+ exec_vector_binary(mach, inst, micro_isge, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
+ case TGSI_OPCODE_ISHR:
+ exec_vector_binary(mach, inst, micro_ishr, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
+ case TGSI_OPCODE_ISLT:
+ exec_vector_binary(mach, inst, micro_islt, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
+ break;
+
+ case TGSI_OPCODE_F2U:
+ exec_vector_unary(mach, inst, micro_f2u, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_FLOAT);
+ break;
+
+ case TGSI_OPCODE_U2F:
+ exec_vector_unary(mach, inst, micro_u2f, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UADD:
+ exec_vector_binary(mach, inst, micro_uadd, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UDIV:
+ exec_vector_binary(mach, inst, micro_udiv, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UMAD:
+ exec_vector_trinary(mach, inst, micro_umad, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UMAX:
+ exec_vector_binary(mach, inst, micro_umax, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UMIN:
+ exec_vector_binary(mach, inst, micro_umin, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UMOD:
+ exec_vector_binary(mach, inst, micro_umod, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_UMUL:
+ exec_vector_binary(mach, inst, micro_umul, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_USEQ:
+ exec_vector_binary(mach, inst, micro_useq, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_USGE:
+ exec_vector_binary(mach, inst, micro_usge, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_USHR:
+ exec_vector_binary(mach, inst, micro_ushr, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_USLT:
+ exec_vector_binary(mach, inst, micro_uslt, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_USNE:
+ exec_vector_binary(mach, inst, micro_usne, TGSI_EXEC_DATA_UINT, TGSI_EXEC_DATA_UINT);
+ break;
+
+ case TGSI_OPCODE_SWITCH:
+ exec_switch(mach, inst);
+ break;
+
+ case TGSI_OPCODE_CASE:
+ exec_case(mach, inst);
+ break;
+
+ case TGSI_OPCODE_DEFAULT:
+ exec_default(mach);
+ break;
+
+ case TGSI_OPCODE_ENDSWITCH:
+ exec_endswitch(mach);
break;
default:
@@ -3248,6 +3543,9 @@ exec_instruction(
}
+#define DEBUG_EXECUTION 0
+
+
/**
* Run TGSI interpreter.
* \return bitmask of "alive" quad components
@@ -3264,9 +3562,13 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
mach->FuncMask = 0xf;
mach->ExecMask = 0xf;
+ mach->Switch.mask = 0xf;
+
assert(mach->CondStackTop == 0);
assert(mach->LoopStackTop == 0);
assert(mach->ContStackTop == 0);
+ assert(mach->SwitchStackTop == 0);
+ assert(mach->BreakStackTop == 0);
assert(mach->CallStackTop == 0);
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
@@ -3290,10 +3592,67 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
exec_declaration( mach, mach->Declarations+i );
}
- /* execute instructions, until pc is set to -1 */
- while (pc != -1) {
- assert(pc < (int) mach->NumInstructions);
- exec_instruction( mach, mach->Instructions + pc, &pc );
+ {
+#if DEBUG_EXECUTION
+ struct tgsi_exec_vector temps[TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_TEMP_EXTRAS];
+ struct tgsi_exec_vector outputs[PIPE_MAX_ATTRIBS];
+ uint inst = 1;
+
+ memcpy(temps, mach->Temps, sizeof(temps));
+ memcpy(outputs, mach->Outputs, sizeof(outputs));
+#endif
+
+ /* execute instructions, until pc is set to -1 */
+ while (pc != -1) {
+
+#if DEBUG_EXECUTION
+ uint i;
+
+ tgsi_dump_instruction(&mach->Instructions[pc], inst++);
+#endif
+
+ assert(pc < (int) mach->NumInstructions);
+ exec_instruction(mach, mach->Instructions + pc, &pc);
+
+#if DEBUG_EXECUTION
+ for (i = 0; i < TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_TEMP_EXTRAS; i++) {
+ if (memcmp(&temps[i], &mach->Temps[i], sizeof(temps[i]))) {
+ uint j;
+
+ memcpy(&temps[i], &mach->Temps[i], sizeof(temps[i]));
+ debug_printf("TEMP[%2u] = ", i);
+ for (j = 0; j < 4; j++) {
+ if (j > 0) {
+ debug_printf(" ");
+ }
+ debug_printf("(%6f %u, %6f %u, %6f %u, %6f %u)\n",
+ temps[i].xyzw[0].f[j], temps[i].xyzw[0].u[j],
+ temps[i].xyzw[1].f[j], temps[i].xyzw[1].u[j],
+ temps[i].xyzw[2].f[j], temps[i].xyzw[2].u[j],
+ temps[i].xyzw[3].f[j], temps[i].xyzw[3].u[j]);
+ }
+ }
+ }
+ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
+ if (memcmp(&outputs[i], &mach->Outputs[i], sizeof(outputs[i]))) {
+ uint j;
+
+ memcpy(&outputs[i], &mach->Outputs[i], sizeof(outputs[i]));
+ debug_printf("OUT[%2u] = ", i);
+ for (j = 0; j < 4; j++) {
+ if (j > 0) {
+ debug_printf(" ");
+ }
+ debug_printf("(%6f %u, %6f %u, %6f %u, %6f %u)\n",
+ outputs[i].xyzw[0].f[j], outputs[i].xyzw[0].u[j],
+ outputs[i].xyzw[1].f[j], outputs[i].xyzw[1].u[j],
+ outputs[i].xyzw[2].f[j], outputs[i].xyzw[2].u[j],
+ outputs[i].xyzw[3].f[j], outputs[i].xyzw[3].u[j]);
+ }
+ }
+ }
+#endif
+ }
}
#if 0
@@ -3307,5 +3666,12 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
}
#endif
+ assert(mach->CondStackTop == 0);
+ assert(mach->LoopStackTop == 0);
+ assert(mach->ContStackTop == 0);
+ assert(mach->SwitchStackTop == 0);
+ assert(mach->BreakStackTop == 0);
+ assert(mach->CallStackTop == 0);
+
return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0];
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index c72f76809d..59e3b445cc 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -2,6 +2,7 @@
*
* Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
+ * 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
@@ -35,11 +36,13 @@
extern "C" {
#endif
+
#define MAX_LABELS (4 * 1024) /**< basically, max instructions */
#define NUM_CHANNELS 4 /* R,G,B,A */
#define QUAD_SIZE 4 /* 4 pixel/quad */
+
/**
* Registers may be treated as float, signed int or unsigned int.
*/
@@ -69,6 +72,11 @@ struct tgsi_interp_coef
float dady[NUM_CHANNELS];
};
+enum tgsi_sampler_control {
+ tgsi_sampler_lod_bias,
+ tgsi_sampler_lod_explicit
+};
+
/**
* Information for sampling textures, which must be implemented
* by code outside the TGSI executor.
@@ -80,7 +88,8 @@ struct tgsi_sampler
const float s[QUAD_SIZE],
const float t[QUAD_SIZE],
const float p[QUAD_SIZE],
- float lodbias,
+ const float c0[QUAD_SIZE],
+ enum tgsi_sampler_control control,
float rgba[NUM_CHANNELS][QUAD_SIZE]);
};
@@ -168,13 +177,19 @@ struct tgsi_exec_labels
#define TGSI_EXEC_TEMP_ADDR (TGSI_EXEC_NUM_TEMPS + 8)
#define TGSI_EXEC_NUM_ADDRS 1
-#define TGSI_EXEC_NUM_TEMP_EXTRAS 9
+/* predicate register */
+#define TGSI_EXEC_TEMP_P0 (TGSI_EXEC_NUM_TEMPS + 9)
+#define TGSI_EXEC_NUM_PREDS 1
+
+#define TGSI_EXEC_NUM_TEMP_EXTRAS 10
-#define TGSI_EXEC_MAX_COND_NESTING 20
-#define TGSI_EXEC_MAX_LOOP_NESTING 20
-#define TGSI_EXEC_MAX_CALL_NESTING 20
+
+#define TGSI_EXEC_MAX_COND_NESTING 32
+#define TGSI_EXEC_MAX_LOOP_NESTING 32
+#define TGSI_EXEC_MAX_SWITCH_NESTING 32
+#define TGSI_EXEC_MAX_CALL_NESTING 32
/* The maximum number of input attributes per vertex. For 2D
* input register files, this is the stride between two 1D
@@ -186,6 +201,14 @@ struct tgsi_exec_labels
*/
#define TGSI_EXEC_MAX_CONST_BUFFER 4096
+/* The maximum number of vertices per primitive */
+#define TGSI_MAX_PRIM_VERTICES 6
+
+/* The maximum number of primitives to be generated */
+#define TGSI_MAX_PRIMITIVES 64
+
+/* The maximum total number of vertices */
+#define TGSI_MAX_TOTAL_VERTICES (TGSI_MAX_PRIM_VERTICES * TGSI_MAX_PRIMITIVES * PIPE_MAX_ATTRIBS)
/** function call/activation record */
struct tgsi_call_record
@@ -193,10 +216,29 @@ struct tgsi_call_record
uint CondStackTop;
uint LoopStackTop;
uint ContStackTop;
+ int SwitchStackTop;
+ int BreakStackTop;
uint ReturnAddr;
};
+/* Switch-case block state. */
+struct tgsi_switch_record {
+ uint mask; /**< execution mask */
+ union tgsi_exec_channel selector; /**< a value case statements are compared to */
+ uint defaultMask; /**< non-execute mask for default case */
+};
+
+
+enum tgsi_break_type {
+ TGSI_EXEC_BREAK_INSIDE_LOOP,
+ TGSI_EXEC_BREAK_INSIDE_SWITCH
+};
+
+
+#define TGSI_EXEC_MAX_BREAK_STACK (TGSI_EXEC_MAX_LOOP_NESTING + TGSI_EXEC_MAX_SWITCH_NESTING)
+
+
/**
* Run-time virtual machine state for executing TGSI shader.
*/
@@ -209,10 +251,11 @@ struct tgsi_exec_machine
float Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
- struct tgsi_exec_vector Inputs[PIPE_MAX_ATTRIBS];
- struct tgsi_exec_vector Outputs[PIPE_MAX_ATTRIBS];
+ struct tgsi_exec_vector Inputs[TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS];
+ struct tgsi_exec_vector Outputs[TGSI_MAX_TOTAL_VERTICES];
struct tgsi_exec_vector *Addrs;
+ struct tgsi_exec_vector *Predicates;
struct tgsi_sampler **Samplers;
@@ -223,10 +266,13 @@ struct tgsi_exec_machine
/* GEOMETRY processor only. */
unsigned *Primitives;
+ unsigned NumOutputs;
+ unsigned MaxGeometryShaderOutputs;
/* FRAGMENT processor only. */
const struct tgsi_interp_coef *InterpCoefs;
struct tgsi_exec_vector QuadPos;
+ float Face; /**< +1 if front facing, -1 if back facing */
/* Conditional execution masks */
uint CondMask; /**< For IF/ELSE/ENDIF */
@@ -235,6 +281,12 @@ struct tgsi_exec_machine
uint FuncMask; /**< For function calls */
uint ExecMask; /**< = CondMask & LoopMask */
+ /* Current switch-case state. */
+ struct tgsi_switch_record Switch;
+
+ /* Current break type. */
+ enum tgsi_break_type BreakType;
+
/** Condition mask stack (for nested conditionals) */
uint CondStack[TGSI_EXEC_MAX_COND_NESTING];
int CondStackTop;
@@ -247,7 +299,7 @@ struct tgsi_exec_machine
uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING];
int LoopLabelStackTop;
- /** Loop counter stack (x = count, y = current, z = step) */
+ /** Loop counter stack (x = index, y = counter, z = step) */
struct tgsi_exec_vector LoopCounterStack[TGSI_EXEC_MAX_LOOP_NESTING];
int LoopCounterStackTop;
@@ -255,6 +307,13 @@ struct tgsi_exec_machine
uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
int ContStackTop;
+ /** Switch case stack */
+ struct tgsi_switch_record SwitchStack[TGSI_EXEC_MAX_SWITCH_NESTING];
+ int SwitchStackTop;
+
+ enum tgsi_break_type BreakStack[TGSI_EXEC_MAX_BREAK_STACK];
+ int BreakStackTop;
+
/** Function execution mask stack (for executing subroutine code) */
uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING];
int FuncStackTop;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 17af4cb7ad..de0e09cdba 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -119,7 +119,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
{ 1, 1, 0, 0, 0, 0, "NOT", TGSI_OPCODE_NOT },
{ 1, 1, 0, 0, 0, 0, "TRUNC", TGSI_OPCODE_TRUNC },
{ 1, 2, 0, 0, 0, 0, "SHL", TGSI_OPCODE_SHL },
- { 1, 2, 0, 0, 0, 0, "SHR", TGSI_OPCODE_SHR },
+ { 0, 0, 0, 0, 0, 0, "", 88 }, /* removed */
{ 1, 2, 0, 0, 0, 0, "AND", TGSI_OPCODE_AND },
{ 1, 2, 0, 0, 0, 0, "OR", TGSI_OPCODE_OR },
{ 1, 2, 0, 0, 0, 0, "MOD", TGSI_OPCODE_MOD },
@@ -134,10 +134,10 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
{ 0, 0, 0, 0, 0, 1, "BGNSUB", TGSI_OPCODE_BGNSUB },
{ 0, 0, 0, 1, 1, 0, "ENDLOOP", TGSI_OPCODE_ENDLOOP },
{ 0, 0, 0, 0, 1, 0, "ENDSUB", TGSI_OPCODE_ENDSUB },
- { 1, 1, 0, 0, 0, 0, "NOISE1", TGSI_OPCODE_NOISE1 },
- { 1, 1, 0, 0, 0, 0, "NOISE2", TGSI_OPCODE_NOISE2 },
- { 1, 1, 0, 0, 0, 0, "NOISE3", TGSI_OPCODE_NOISE3 },
- { 1, 1, 0, 0, 0, 0, "NOISE4", TGSI_OPCODE_NOISE4 },
+ { 0, 0, 0, 0, 0, 0, "", 103 }, /* removed */
+ { 0, 0, 0, 0, 0, 0, "", 104 }, /* removed */
+ { 0, 0, 0, 0, 0, 0, "", 105 }, /* removed */
+ { 0, 0, 0, 0, 0, 0, "", 106 }, /* removed */
{ 0, 0, 0, 0, 0, 0, "NOP", TGSI_OPCODE_NOP },
{ 0, 0, 0, 0, 0, 0, "", 108 }, /* removed */
{ 0, 0, 0, 0, 0, 0, "", 109 }, /* removed */
@@ -149,7 +149,33 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
{ 0, 1, 0, 0, 0, 0, "BREAKC", TGSI_OPCODE_BREAKC },
{ 0, 1, 0, 0, 0, 0, "KIL", TGSI_OPCODE_KIL },
{ 0, 0, 0, 0, 0, 0, "END", TGSI_OPCODE_END },
- { 1, 1, 0, 0, 0, 0, "SWZ", TGSI_OPCODE_SWZ }
+ { 0, 0, 0, 0, 0, 0, "", 118 }, /* removed */
+ { 1, 1, 0, 0, 0, 0, "F2I", TGSI_OPCODE_F2I },
+ { 1, 2, 0, 0, 0, 0, "IDIV", TGSI_OPCODE_IDIV },
+ { 1, 2, 0, 0, 0, 0, "IMAX", TGSI_OPCODE_IMAX },
+ { 1, 2, 0, 0, 0, 0, "IMIN", TGSI_OPCODE_IMIN },
+ { 1, 1, 0, 0, 0, 0, "INEG", TGSI_OPCODE_INEG },
+ { 1, 2, 0, 0, 0, 0, "ISGE", TGSI_OPCODE_ISGE },
+ { 1, 2, 0, 0, 0, 0, "ISHR", TGSI_OPCODE_ISHR },
+ { 1, 2, 0, 0, 0, 0, "ISLT", TGSI_OPCODE_ISLT },
+ { 1, 1, 0, 0, 0, 0, "F2U", TGSI_OPCODE_F2U },
+ { 1, 1, 0, 0, 0, 0, "U2F", TGSI_OPCODE_U2F },
+ { 1, 2, 0, 0, 0, 0, "UADD", TGSI_OPCODE_UADD },
+ { 1, 2, 0, 0, 0, 0, "UDIV", TGSI_OPCODE_UDIV },
+ { 1, 3, 0, 0, 0, 0, "UMAD", TGSI_OPCODE_UMAD },
+ { 1, 2, 0, 0, 0, 0, "UMAX", TGSI_OPCODE_UMAX },
+ { 1, 2, 0, 0, 0, 0, "UMIN", TGSI_OPCODE_UMIN },
+ { 1, 2, 0, 0, 0, 0, "UMOD", TGSI_OPCODE_UMOD },
+ { 1, 2, 0, 0, 0, 0, "UMUL", TGSI_OPCODE_UMUL },
+ { 1, 2, 0, 0, 0, 0, "USEQ", TGSI_OPCODE_USEQ },
+ { 1, 2, 0, 0, 0, 0, "USGE", TGSI_OPCODE_USGE },
+ { 1, 2, 0, 0, 0, 0, "USHR", TGSI_OPCODE_USHR },
+ { 1, 2, 0, 0, 0, 0, "USLT", TGSI_OPCODE_USLT },
+ { 1, 2, 0, 0, 0, 0, "USNE", TGSI_OPCODE_USNE },
+ { 0, 1, 0, 0, 0, 0, "SWITCH", TGSI_OPCODE_SWITCH },
+ { 0, 1, 0, 0, 0, 0, "CASE", TGSI_OPCODE_CASE },
+ { 0, 0, 0, 0, 0, 0, "DEFAULT", TGSI_OPCODE_DEFAULT },
+ { 0, 0, 0, 0, 0, 0, "ENDSWITCH", TGSI_OPCODE_ENDSWITCH }
};
const struct tgsi_opcode_info *
diff --git a/src/gallium/auxiliary/tgsi/tgsi_iterate.c b/src/gallium/auxiliary/tgsi/tgsi_iterate.c
index d88c2558d8..0ba5fe4841 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_iterate.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_iterate.c
@@ -39,7 +39,6 @@ tgsi_iterate_shader(
return FALSE;
ctx->processor = parse.FullHeader.Processor;
- ctx->version = parse.FullVersion.Version;
if (ctx->prolog)
if (!ctx->prolog( ctx ))
@@ -67,6 +66,12 @@ tgsi_iterate_shader(
goto fail;
break;
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ if (ctx->iterate_property)
+ if (!ctx->iterate_property( ctx, &parse.FullToken.FullProperty ))
+ goto fail;
+ break;
+
default:
assert( 0 );
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_iterate.h b/src/gallium/auxiliary/tgsi/tgsi_iterate.h
index ec7b85bf63..8d67f22c42 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_iterate.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_iterate.h
@@ -57,11 +57,15 @@ struct tgsi_iterate_context
struct tgsi_full_immediate *imm );
boolean
+ (* iterate_property)(
+ struct tgsi_iterate_context *ctx,
+ struct tgsi_full_property *prop );
+
+ boolean
(* epilog)(
struct tgsi_iterate_context *ctx );
struct tgsi_processor processor;
- struct tgsi_version version;
};
boolean
diff --git a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
index e7bcf4bf75..e4af15c156 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
@@ -124,7 +124,6 @@ OP11(I2F)
OP11(NOT)
OP11(TRUNC)
OP12(SHL)
-OP12(SHR)
OP12(AND)
OP12(OR)
OP12(MOD)
@@ -139,10 +138,6 @@ OP00_LBL(BGNLOOP)
OP00(BGNSUB)
OP00_LBL(ENDLOOP)
OP00(ENDSUB)
-OP11(NOISE1)
-OP11(NOISE2)
-OP11(NOISE3)
-OP11(NOISE4)
OP00(NOP)
OP11(NRM4)
OP01(CALLNZ)
@@ -150,7 +145,28 @@ OP01(IFC)
OP01(BREAKC)
OP01(KIL)
OP00(END)
-OP11(SWZ)
+OP11(F2I)
+OP12(IDIV)
+OP12(IMAX)
+OP12(IMIN)
+OP11(INEG)
+OP12(ISGE)
+OP12(ISHR)
+OP12(ISLT)
+OP11(F2U)
+OP11(U2F)
+OP12(UADD)
+OP12(UDIV)
+OP13(UMAD)
+OP12(UMAX)
+OP12(UMIN)
+OP12(UMOD)
+OP12(UMUL)
+OP12(USEQ)
+OP12(USGE)
+OP12(USHR)
+OP12(USLT)
+OP12(USNE)
#undef OP00
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index 4870f82b6b..8c7062d850 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -28,44 +28,23 @@
#include "util/u_debug.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
-#include "tgsi_build.h"
#include "util/u_memory.h"
-void
-tgsi_full_token_init(
- union tgsi_full_token *full_token )
-{
- full_token->Token.Type = TGSI_TOKEN_TYPE_DECLARATION;
-}
-
-void
-tgsi_full_token_free(
- union tgsi_full_token *full_token )
-{
-}
-
unsigned
tgsi_parse_init(
struct tgsi_parse_context *ctx,
const struct tgsi_token *tokens )
{
- ctx->FullVersion.Version = *(struct tgsi_version *) &tokens[0];
- if( ctx->FullVersion.Version.MajorVersion > 1 ) {
- return TGSI_PARSE_ERROR;
- }
-
- ctx->FullHeader.Header = *(struct tgsi_header *) &tokens[1];
+ ctx->FullHeader.Header = *(struct tgsi_header *) &tokens[0];
if( ctx->FullHeader.Header.HeaderSize >= 2 ) {
- ctx->FullHeader.Processor = *(struct tgsi_processor *) &tokens[2];
+ ctx->FullHeader.Processor = *(struct tgsi_processor *) &tokens[1];
}
else {
- ctx->FullHeader.Processor = tgsi_default_processor();
+ return TGSI_PARSE_ERROR;
}
ctx->Tokens = tokens;
- ctx->Position = 1 + ctx->FullHeader.Header.HeaderSize;
-
- tgsi_full_token_init( &ctx->FullToken );
+ ctx->Position = ctx->FullHeader.Header.HeaderSize;
return TGSI_PARSE_OK;
}
@@ -74,7 +53,6 @@ void
tgsi_parse_free(
struct tgsi_parse_context *ctx )
{
- tgsi_full_token_free( &ctx->FullToken );
}
boolean
@@ -82,7 +60,7 @@ tgsi_parse_end_of_tokens(
struct tgsi_parse_context *ctx )
{
return ctx->Position >=
- 1 + ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
+ ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
}
@@ -119,9 +97,6 @@ tgsi_parse_token(
struct tgsi_token token;
unsigned i;
- tgsi_full_token_free( &ctx->FullToken );
- tgsi_full_token_init( &ctx->FullToken );
-
next_token( ctx, &token );
switch( token.Type ) {
@@ -129,10 +104,10 @@ tgsi_parse_token(
{
struct tgsi_full_declaration *decl = &ctx->FullToken.FullDeclaration;
- *decl = tgsi_default_full_declaration();
+ memset(decl, 0, sizeof *decl);
copy_token(&decl->Declaration, &token);
- next_token( ctx, &decl->DeclarationRange );
+ next_token( ctx, &decl->Range );
if( decl->Declaration.Semantic ) {
next_token( ctx, &decl->Semantic );
@@ -144,18 +119,29 @@ tgsi_parse_token(
case TGSI_TOKEN_TYPE_IMMEDIATE:
{
struct tgsi_full_immediate *imm = &ctx->FullToken.FullImmediate;
+ uint imm_count;
- *imm = tgsi_default_full_immediate();
+ memset(imm, 0, sizeof *imm);
copy_token(&imm->Immediate, &token);
- assert( !imm->Immediate.Extended );
+
+ imm_count = imm->Immediate.NrTokens - 1;
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
- {
- uint imm_count = imm->Immediate.NrTokens - 1;
- for (i = 0; i < imm_count; i++) {
- next_token(ctx, &imm->u[i]);
- }
+ for (i = 0; i < imm_count; i++) {
+ next_token(ctx, &imm->u[i].Float);
+ }
+ break;
+
+ case TGSI_IMM_UINT32:
+ for (i = 0; i < imm_count; i++) {
+ next_token(ctx, &imm->u[i].Uint);
+ }
+ break;
+
+ case TGSI_IMM_INT32:
+ for (i = 0; i < imm_count; i++) {
+ next_token(ctx, &imm->u[i].Int);
}
break;
@@ -169,147 +155,76 @@ tgsi_parse_token(
case TGSI_TOKEN_TYPE_INSTRUCTION:
{
struct tgsi_full_instruction *inst = &ctx->FullToken.FullInstruction;
- unsigned extended;
- *inst = tgsi_default_full_instruction();
+ memset(inst, 0, sizeof *inst);
copy_token(&inst->Instruction, &token);
- extended = inst->Instruction.Extended;
-
- while( extended ) {
- struct tgsi_src_register_ext token;
-
- next_token( ctx, &token );
-
- switch( token.Type ) {
- case TGSI_INSTRUCTION_EXT_TYPE_NV:
- copy_token(&inst->InstructionExtNv, &token);
- break;
- case TGSI_INSTRUCTION_EXT_TYPE_LABEL:
- copy_token(&inst->InstructionExtLabel, &token);
- break;
-
- case TGSI_INSTRUCTION_EXT_TYPE_TEXTURE:
- copy_token(&inst->InstructionExtTexture, &token);
- break;
+ if (inst->Instruction.Predicate) {
+ next_token(ctx, &inst->Predicate);
+ }
- default:
- assert( 0 );
- }
+ if (inst->Instruction.Label) {
+ next_token( ctx, &inst->Label);
+ }
- extended = token.Extended;
+ if (inst->Instruction.Texture) {
+ next_token( ctx, &inst->Texture);
}
assert( inst->Instruction.NumDstRegs <= TGSI_FULL_MAX_DST_REGISTERS );
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
- unsigned extended;
- next_token( ctx, &inst->FullDstRegisters[i].DstRegister );
+ next_token( ctx, &inst->Dst[i].Register );
/*
* No support for indirect or multi-dimensional addressing.
*/
- assert( !inst->FullDstRegisters[i].DstRegister.Dimension );
-
- extended = inst->FullDstRegisters[i].DstRegister.Extended;
-
- while( extended ) {
- struct tgsi_src_register_ext token;
-
- next_token( ctx, &token );
-
- switch( token.Type ) {
- case TGSI_DST_REGISTER_EXT_TYPE_CONDCODE:
- copy_token(&inst->FullDstRegisters[i].DstRegisterExtConcode,
- &token);
- break;
-
- case TGSI_DST_REGISTER_EXT_TYPE_MODULATE:
- copy_token(&inst->FullDstRegisters[i].DstRegisterExtModulate,
- &token);
- break;
-
- default:
- assert( 0 );
- }
-
- extended = token.Extended;
- }
+ assert( !inst->Dst[i].Register.Dimension );
- if( inst->FullDstRegisters[i].DstRegister.Indirect ) {
- next_token( ctx, &inst->FullDstRegisters[i].DstRegisterInd );
+ if( inst->Dst[i].Register.Indirect ) {
+ next_token( ctx, &inst->Dst[i].Indirect );
/*
* No support for indirect or multi-dimensional addressing.
*/
- assert( !inst->FullDstRegisters[i].DstRegisterInd.Indirect );
- assert( !inst->FullDstRegisters[i].DstRegisterInd.Dimension );
- assert( !inst->FullDstRegisters[i].DstRegisterInd.Extended );
+ assert( !inst->Dst[i].Indirect.Dimension );
+ assert( !inst->Dst[i].Indirect.Indirect );
}
}
assert( inst->Instruction.NumSrcRegs <= TGSI_FULL_MAX_SRC_REGISTERS );
for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
- unsigned extended;
-
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegister );
-
- extended = inst->FullSrcRegisters[i].SrcRegister.Extended;
-
- while( extended ) {
- struct tgsi_src_register_ext token;
-
- next_token( ctx, &token );
- switch( token.Type ) {
- case TGSI_SRC_REGISTER_EXT_TYPE_SWZ:
- copy_token(&inst->FullSrcRegisters[i].SrcRegisterExtSwz,
- &token);
- break;
+ next_token( ctx, &inst->Src[i].Register );
- case TGSI_SRC_REGISTER_EXT_TYPE_MOD:
- copy_token(&inst->FullSrcRegisters[i].SrcRegisterExtMod,
- &token);
- break;
-
- default:
- assert( 0 );
- }
-
- extended = token.Extended;
- }
-
- if( inst->FullSrcRegisters[i].SrcRegister.Indirect ) {
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterInd );
+ if( inst->Src[i].Register.Indirect ) {
+ next_token( ctx, &inst->Src[i].Indirect );
/*
* No support for indirect or multi-dimensional addressing.
*/
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
+ assert( !inst->Src[i].Indirect.Indirect );
+ assert( !inst->Src[i].Indirect.Dimension );
}
- if( inst->FullSrcRegisters[i].SrcRegister.Dimension ) {
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDim );
+ if( inst->Src[i].Register.Dimension ) {
+ next_token( ctx, &inst->Src[i].Dimension );
/*
* No support for multi-dimensional addressing.
*/
- assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Dimension );
- assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Extended );
+ assert( !inst->Src[i].Dimension.Dimension );
- if( inst->FullSrcRegisters[i].SrcRegisterDim.Indirect ) {
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDimInd );
+ if( inst->Src[i].Dimension.Indirect ) {
+ next_token( ctx, &inst->Src[i].DimIndirect );
/*
* No support for indirect or multi-dimensional addressing.
*/
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
+ assert( !inst->Src[i].Indirect.Indirect );
+ assert( !inst->Src[i].Indirect.Dimension );
}
}
}
@@ -317,6 +232,22 @@ tgsi_parse_token(
break;
}
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ {
+ struct tgsi_full_property *prop = &ctx->FullToken.FullProperty;
+ uint prop_count;
+
+ memset(prop, 0, sizeof *prop);
+ copy_token(&prop->Property, &token);
+
+ prop_count = prop->Property.NrTokens - 1;
+ for (i = 0; i < prop_count; i++) {
+ next_token(ctx, &prop->u[i]);
+ }
+
+ break;
+ }
+
default:
assert( 0 );
}
@@ -329,8 +260,7 @@ tgsi_num_tokens(const struct tgsi_token *tokens)
struct tgsi_parse_context ctx;
if (tgsi_parse_init(&ctx, tokens) == TGSI_PARSE_OK) {
unsigned len = (ctx.FullHeader.Header.HeaderSize +
- ctx.FullHeader.Header.BodySize +
- 1);
+ ctx.FullHeader.Header.BodySize);
return len;
}
return 0;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h
index a26ee5ba86..439a57269b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h
@@ -34,11 +34,6 @@
extern "C" {
#endif
-struct tgsi_full_version
-{
- struct tgsi_version Version;
-};
-
struct tgsi_full_header
{
struct tgsi_header Header;
@@ -47,26 +42,22 @@ struct tgsi_full_header
struct tgsi_full_dst_register
{
- struct tgsi_dst_register DstRegister;
- struct tgsi_src_register DstRegisterInd;
- struct tgsi_dst_register_ext_concode DstRegisterExtConcode;
- struct tgsi_dst_register_ext_modulate DstRegisterExtModulate;
+ struct tgsi_dst_register Register;
+ struct tgsi_src_register Indirect;
};
struct tgsi_full_src_register
{
- struct tgsi_src_register SrcRegister;
- struct tgsi_src_register_ext_swz SrcRegisterExtSwz;
- struct tgsi_src_register_ext_mod SrcRegisterExtMod;
- struct tgsi_src_register SrcRegisterInd;
- struct tgsi_dimension SrcRegisterDim;
- struct tgsi_src_register SrcRegisterDimInd;
+ struct tgsi_src_register Register;
+ struct tgsi_src_register Indirect;
+ struct tgsi_dimension Dimension;
+ struct tgsi_src_register DimIndirect;
};
struct tgsi_full_declaration
{
struct tgsi_declaration Declaration;
- struct tgsi_declaration_range DeclarationRange;
+ struct tgsi_declaration_range Range;
struct tgsi_declaration_semantic Semantic;
};
@@ -76,18 +67,23 @@ struct tgsi_full_immediate
union tgsi_immediate_data u[4];
};
+struct tgsi_full_property
+{
+ struct tgsi_property Property;
+ struct tgsi_property_data u[8];
+};
+
#define TGSI_FULL_MAX_DST_REGISTERS 2
#define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
struct tgsi_full_instruction
{
struct tgsi_instruction Instruction;
- struct tgsi_instruction_ext_nv InstructionExtNv;
- struct tgsi_instruction_ext_label InstructionExtLabel;
- struct tgsi_instruction_ext_texture InstructionExtTexture;
- struct tgsi_full_dst_register FullDstRegisters[TGSI_FULL_MAX_DST_REGISTERS];
- struct tgsi_full_src_register FullSrcRegisters[TGSI_FULL_MAX_SRC_REGISTERS];
- uint Flags; /**< user-defined usage */
+ struct tgsi_instruction_predicate Predicate;
+ struct tgsi_instruction_label Label;
+ struct tgsi_instruction_texture Texture;
+ struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS];
+ struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS];
};
union tgsi_full_token
@@ -96,21 +92,13 @@ union tgsi_full_token
struct tgsi_full_declaration FullDeclaration;
struct tgsi_full_immediate FullImmediate;
struct tgsi_full_instruction FullInstruction;
+ struct tgsi_full_property FullProperty;
};
-void
-tgsi_full_token_init(
- union tgsi_full_token *full_token );
-
-void
-tgsi_full_token_free(
- union tgsi_full_token *full_token );
-
struct tgsi_parse_context
{
const struct tgsi_token *Tokens;
unsigned Position;
- struct tgsi_full_version FullVersion;
struct tgsi_full_header FullHeader;
union tgsi_full_token FullToken;
};
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
index 4b1c7d4e01..138d2d095b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -60,7 +60,7 @@ const float ppc_builtin_constants[] ALIGN16_ATTRIB = {
for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
- ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+ ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
@@ -156,8 +156,8 @@ init_gen_context(struct gen_context *gen, struct ppc_function *func)
static boolean
is_ppc_vec_temporary(const struct tgsi_full_src_register *reg)
{
- return (reg->SrcRegister.File == TGSI_FILE_TEMPORARY &&
- reg->SrcRegister.Index < MAX_PPC_TEMPS);
+ return (reg->Register.File == TGSI_FILE_TEMPORARY &&
+ reg->Register.Index < MAX_PPC_TEMPS);
}
@@ -167,8 +167,8 @@ is_ppc_vec_temporary(const struct tgsi_full_src_register *reg)
static boolean
is_ppc_vec_temporary_dst(const struct tgsi_full_dst_register *reg)
{
- return (reg->DstRegister.File == TGSI_FILE_TEMPORARY &&
- reg->DstRegister.Index < MAX_PPC_TEMPS);
+ return (reg->Register.File == TGSI_FILE_TEMPORARY &&
+ reg->Register.Index < MAX_PPC_TEMPS);
}
@@ -283,18 +283,19 @@ emit_fetch(struct gen_context *gen,
const struct tgsi_full_src_register *reg,
const unsigned chan_index)
{
- uint swizzle = tgsi_util_get_full_src_register_extswizzle(reg, chan_index);
+ uint swizzle = tgsi_util_get_full_src_register_swizzle(reg, chan_index);
int dst_vec = -1;
switch (swizzle) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
- switch (reg->SrcRegister.File) {
+ case TGSI_SWIZZLE_X:
+ case TGSI_SWIZZLE_Y:
+ case TGSI_SWIZZLE_Z:
+ case TGSI_SWIZZLE_W:
+ switch (reg->Register.File) {
case TGSI_FILE_INPUT:
+ case TGSI_FILE_SYSTEM_VALUE:
{
- int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+ int offset = (reg->Register.Index * 4 + swizzle) * 16;
int offset_reg = emit_li_offset(gen, offset);
dst_vec = ppc_allocate_vec_register(gen->f);
ppc_lvx(gen->f, dst_vec, gen->inputs_reg, offset_reg);
@@ -303,11 +304,11 @@ emit_fetch(struct gen_context *gen,
case TGSI_FILE_TEMPORARY:
if (is_ppc_vec_temporary(reg)) {
/* use PPC vec register */
- dst_vec = gen->temps_map[reg->SrcRegister.Index][swizzle];
+ dst_vec = gen->temps_map[reg->Register.Index][swizzle];
}
else {
/* use memory-based temp register "file" */
- int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+ int offset = (reg->Register.Index * 4 + swizzle) * 16;
int offset_reg = emit_li_offset(gen, offset);
dst_vec = ppc_allocate_vec_register(gen->f);
ppc_lvx(gen->f, dst_vec, gen->temps_reg, offset_reg);
@@ -315,7 +316,7 @@ emit_fetch(struct gen_context *gen,
break;
case TGSI_FILE_IMMEDIATE:
{
- int offset = (reg->SrcRegister.Index * 4 + swizzle) * 4;
+ int offset = (reg->Register.Index * 4 + swizzle) * 4;
int offset_reg = emit_li_offset(gen, offset);
dst_vec = ppc_allocate_vec_register(gen->f);
/* Load 4-byte word into vector register.
@@ -331,7 +332,7 @@ emit_fetch(struct gen_context *gen,
break;
case TGSI_FILE_CONSTANT:
{
- int offset = (reg->SrcRegister.Index * 4 + swizzle) * 4;
+ int offset = (reg->Register.Index * 4 + swizzle) * 4;
int offset_reg = emit_li_offset(gen, offset);
dst_vec = ppc_allocate_vec_register(gen->f);
/* Load 4-byte word into vector register.
@@ -349,16 +350,6 @@ emit_fetch(struct gen_context *gen,
assert( 0 );
}
break;
- case TGSI_EXTSWIZZLE_ZERO:
- ppc_vzero(gen->f, dst_vec);
- break;
- case TGSI_EXTSWIZZLE_ONE:
- {
- int one_vec = gen_one_vec(gen);
- dst_vec = ppc_allocate_vec_register(gen->f);
- ppc_vmove(gen->f, dst_vec, one_vec);
- }
- break;
default:
assert( 0 );
}
@@ -414,12 +405,12 @@ equal_src_locs(const struct tgsi_full_src_register *a, uint chan_a,
{
int swz_a, swz_b;
int sign_a, sign_b;
- if (a->SrcRegister.File != b->SrcRegister.File)
+ if (a->Register.File != b->Register.File)
return FALSE;
- if (a->SrcRegister.Index != b->SrcRegister.Index)
+ if (a->Register.Index != b->Register.Index)
return FALSE;
- swz_a = tgsi_util_get_full_src_register_extswizzle(a, chan_a);
- swz_b = tgsi_util_get_full_src_register_extswizzle(b, chan_b);
+ swz_a = tgsi_util_get_full_src_register_swizzle(a, chan_a);
+ swz_b = tgsi_util_get_full_src_register_swizzle(b, chan_b);
if (swz_a != swz_b)
return FALSE;
sign_a = tgsi_util_get_full_src_register_sign_mode(a, chan_a);
@@ -441,7 +432,7 @@ get_src_vec(struct gen_context *gen,
struct tgsi_full_instruction *inst, int src_reg, uint chan)
{
const const struct tgsi_full_src_register *src =
- &inst->FullSrcRegisters[src_reg];
+ &inst->Src[src_reg];
int vec;
uint i;
@@ -492,10 +483,10 @@ get_dst_vec(struct gen_context *gen,
const struct tgsi_full_instruction *inst,
unsigned chan_index)
{
- const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[0];
+ const struct tgsi_full_dst_register *reg = &inst->Dst[0];
if (is_ppc_vec_temporary_dst(reg)) {
- int vec = gen->temps_map[reg->DstRegister.Index][chan_index];
+ int vec = gen->temps_map[reg->Register.Index][chan_index];
return vec;
}
else {
@@ -515,12 +506,12 @@ emit_store(struct gen_context *gen,
unsigned chan_index,
boolean free_vec)
{
- const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[0];
+ const struct tgsi_full_dst_register *reg = &inst->Dst[0];
- switch (reg->DstRegister.File) {
+ switch (reg->Register.File) {
case TGSI_FILE_OUTPUT:
{
- int offset = (reg->DstRegister.Index * 4 + chan_index) * 16;
+ int offset = (reg->Register.Index * 4 + chan_index) * 16;
int offset_reg = emit_li_offset(gen, offset);
ppc_stvx(gen->f, src_vec, gen->outputs_reg, offset_reg);
}
@@ -528,14 +519,14 @@ emit_store(struct gen_context *gen,
case TGSI_FILE_TEMPORARY:
if (is_ppc_vec_temporary_dst(reg)) {
if (!free_vec) {
- int dst_vec = gen->temps_map[reg->DstRegister.Index][chan_index];
+ int dst_vec = gen->temps_map[reg->Register.Index][chan_index];
if (dst_vec != src_vec)
ppc_vmove(gen->f, dst_vec, src_vec);
}
free_vec = FALSE;
}
else {
- int offset = (reg->DstRegister.Index * 4 + chan_index) * 16;
+ int offset = (reg->Register.Index * 4 + chan_index) * 16;
int offset_reg = emit_li_offset(gen, offset);
ppc_stvx(gen->f, src_vec, gen->temps_reg, offset_reg);
}
@@ -545,7 +536,7 @@ emit_store(struct gen_context *gen,
emit_addrs(
func,
xmm,
- reg->DstRegister.Index,
+ reg->Register.Index,
chan_index );
break;
#endif
@@ -635,7 +626,6 @@ emit_unaryop(struct gen_context *gen, struct tgsi_full_instruction *inst)
ppc_vlogefp(gen->f, v1, v0); /* v1 = log2(v0) */
break;
case TGSI_OPCODE_MOV:
- case TGSI_OPCODE_SWZ:
if (v0 != v1)
ppc_vmove(gen->f, v1, v0);
break;
@@ -1119,7 +1109,6 @@ emit_instruction(struct gen_context *gen,
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_MOV:
- case TGSI_OPCODE_SWZ:
case TGSI_OPCODE_ABS:
case TGSI_OPCODE_FLR:
case TGSI_OPCODE_FRC:
@@ -1185,13 +1174,14 @@ emit_declaration(
struct ppc_function *func,
struct tgsi_full_declaration *decl )
{
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
+ if( decl->Declaration.File == TGSI_FILE_INPUT ||
+ decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE ) {
#if 0
unsigned first, last, mask;
unsigned i, j;
- first = decl->DeclarationRange.First;
- last = decl->DeclarationRange.Last;
+ first = decl->Range.First;
+ last = decl->Range.Last;
mask = decl->Declaration.UsageMask;
for( i = first; i <= last; i++ ) {
@@ -1351,6 +1341,9 @@ tgsi_emit_ppc(const struct tgsi_token *tokens,
}
break;
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ break;
+
default:
ok = 0;
assert( 0 );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
index 53e13b30e6..7f1c8e5dd6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
@@ -26,32 +26,112 @@
**************************************************************************/
#include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "util/u_prim.h"
+#include "cso_cache/cso_hash.h"
#include "tgsi_sanity.h"
#include "tgsi_info.h"
#include "tgsi_iterate.h"
-typedef uint reg_flag;
-
-#define BITS_IN_REG_FLAG (sizeof( reg_flag ) * 8)
-
-#define MAX_REGISTERS 256
-#define MAX_REG_FLAGS ((MAX_REGISTERS + BITS_IN_REG_FLAG - 1) / BITS_IN_REG_FLAG)
+typedef struct {
+ uint file : 28;
+ /* max 2 dimensions */
+ uint dimensions : 4;
+ uint indices[2];
+} scan_register;
struct sanity_check_ctx
{
struct tgsi_iterate_context iter;
+ struct cso_hash *regs_decl;
+ struct cso_hash *regs_used;
+ struct cso_hash *regs_ind_used;
- reg_flag regs_decl[TGSI_FILE_COUNT][MAX_REG_FLAGS];
- reg_flag regs_used[TGSI_FILE_COUNT][MAX_REG_FLAGS];
- boolean regs_ind_used[TGSI_FILE_COUNT];
uint num_imms;
uint num_instructions;
uint index_of_END;
uint errors;
uint warnings;
+ uint implied_array_size;
};
+static INLINE unsigned
+scan_register_key(const scan_register *reg)
+{
+ unsigned key = reg->file;
+ key |= (reg->indices[0] << 4);
+ key |= (reg->indices[1] << 18);
+
+ return key;
+}
+
+static void
+fill_scan_register1d(scan_register *reg,
+ uint file, uint index)
+{
+ reg->file = file;
+ reg->dimensions = 1;
+ reg->indices[0] = index;
+ reg->indices[1] = 0;
+}
+
+static void
+fill_scan_register2d(scan_register *reg,
+ uint file, uint index1, uint index2)
+{
+ reg->file = file;
+ reg->dimensions = 2;
+ reg->indices[0] = index1;
+ reg->indices[1] = index2;
+}
+
+static void
+scan_register_dst(scan_register *reg,
+ struct tgsi_full_dst_register *dst)
+{
+ fill_scan_register1d(reg,
+ dst->Register.File,
+ dst->Register.Index);
+}
+
+static void
+scan_register_src(scan_register *reg,
+ struct tgsi_full_src_register *src)
+{
+ if (src->Register.Dimension) {
+ /*FIXME: right now we don't support indirect
+ * multidimensional addressing */
+ debug_assert(!src->Dimension.Indirect);
+ fill_scan_register2d(reg,
+ src->Register.File,
+ src->Register.Index,
+ src->Dimension.Index);
+ } else {
+ fill_scan_register1d(reg,
+ src->Register.File,
+ src->Register.Index);
+ }
+}
+
+static scan_register *
+create_scan_register_src(struct tgsi_full_src_register *src)
+{
+ scan_register *reg = MALLOC(sizeof(scan_register));
+ scan_register_src(reg, src);
+
+ return reg;
+}
+
+static scan_register *
+create_scan_register_dst(struct tgsi_full_dst_register *dst)
+{
+ scan_register *reg = MALLOC(sizeof(scan_register));
+ scan_register_dst(reg, dst);
+
+ return reg;
+}
+
static void
report_error(
struct sanity_check_ctx *ctx,
@@ -99,12 +179,12 @@ check_file_name(
static boolean
is_register_declared(
struct sanity_check_ctx *ctx,
- uint file,
- int index )
+ const scan_register *reg)
{
- assert( index >= 0 && index < MAX_REGISTERS );
-
- return (ctx->regs_decl[file][index / BITS_IN_REG_FLAG] & (1 << (index % BITS_IN_REG_FLAG))) ? TRUE : FALSE;
+ void *data = cso_hash_find_data_from_template(
+ ctx->regs_decl, scan_register_key(reg),
+ (void*)reg, sizeof(scan_register));
+ return data ? TRUE : FALSE;
}
static boolean
@@ -112,23 +192,37 @@ is_any_register_declared(
struct sanity_check_ctx *ctx,
uint file )
{
- uint i;
+ struct cso_hash_iter iter =
+ cso_hash_first_node(ctx->regs_decl);
- for (i = 0; i < MAX_REG_FLAGS; i++)
- if (ctx->regs_decl[file][i])
+ while (!cso_hash_iter_is_null(iter)) {
+ scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
+ if (reg->file == file)
return TRUE;
+ iter = cso_hash_iter_next(iter);
+ }
+
return FALSE;
}
static boolean
is_register_used(
struct sanity_check_ctx *ctx,
- uint file,
- int index )
+ scan_register *reg)
{
- assert( index < MAX_REGISTERS );
+ void *data = cso_hash_find_data_from_template(
+ ctx->regs_used, scan_register_key(reg),
+ reg, sizeof(scan_register));
+ return data ? TRUE : FALSE;
+}
- return (ctx->regs_used[file][index / BITS_IN_REG_FLAG] & (1 << (index % BITS_IN_REG_FLAG))) ? TRUE : FALSE;
+
+static boolean
+is_ind_register_used(
+ struct sanity_check_ctx *ctx,
+ scan_register *reg)
+{
+ return cso_hash_contains(ctx->regs_ind_used, reg->file);
}
static const char *file_names[TGSI_FILE_COUNT] =
@@ -141,37 +235,49 @@ static const char *file_names[TGSI_FILE_COUNT] =
"SAMP",
"ADDR",
"IMM",
- "LOOP"
+ "LOOP",
+ "PRED"
};
static boolean
check_register_usage(
struct sanity_check_ctx *ctx,
- uint file,
- int index,
+ scan_register *reg,
const char *name,
boolean indirect_access )
{
- if (!check_file_name( ctx, file ))
+ if (!check_file_name( ctx, reg->file )) {
+ FREE(reg);
return FALSE;
+ }
if (indirect_access) {
/* Note that 'index' is an offset relative to the value of the
- * address register. No range checking done here.
- */
- if (!is_any_register_declared( ctx, file ))
- report_error( ctx, "%s: Undeclared %s register", file_names[file], name );
- ctx->regs_ind_used[file] = TRUE;
+ * address register. No range checking done here.*/
+ reg->indices[0] = 0;
+ reg->indices[1] = 0;
+ if (!is_any_register_declared( ctx, reg->file ))
+ report_error( ctx, "%s: Undeclared %s register", file_names[reg->file], name );
+ if (!is_ind_register_used(ctx, reg))
+ cso_hash_insert(ctx->regs_ind_used, reg->file, reg);
+ else
+ FREE(reg);
}
else {
- if (index < 0 || index >= MAX_REGISTERS) {
- report_error( ctx, "%s[%d]: Invalid %s index", file_names[file], index, name );
- return FALSE;
+ if (!is_register_declared( ctx, reg )) {
+ if (reg->dimensions == 2) {
+ report_error( ctx, "%s[%d][%d]: Undeclared %s register", file_names[reg->file],
+ reg->indices[0], reg->indices[1], name );
+ }
+ else {
+ report_error( ctx, "%s[%d]: Undeclared %s register", file_names[reg->file],
+ reg->indices[0], name );
+ }
}
-
- if (!is_register_declared( ctx, file, index ))
- report_error( ctx, "%s[%d]: Undeclared %s register", file_names[file], index, name );
- ctx->regs_used[file][index / BITS_IN_REG_FLAG] |= (1 << (index % BITS_IN_REG_FLAG));
+ if (!is_register_used( ctx, reg ))
+ cso_hash_insert(ctx->regs_used, scan_register_key(reg), reg);
+ else
+ FREE(reg);
}
return TRUE;
}
@@ -209,43 +315,43 @@ iter_instruction(
* Mark the registers as used.
*/
for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
+ scan_register *reg = create_scan_register_dst(&inst->Dst[i]);
check_register_usage(
ctx,
- inst->FullDstRegisters[i].DstRegister.File,
- inst->FullDstRegisters[i].DstRegister.Index,
+ reg,
"destination",
FALSE );
}
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
+ scan_register *reg = create_scan_register_src(&inst->Src[i]);
check_register_usage(
ctx,
- inst->FullSrcRegisters[i].SrcRegister.File,
- inst->FullSrcRegisters[i].SrcRegister.Index,
+ reg,
"source",
- (boolean)inst->FullSrcRegisters[i].SrcRegister.Indirect );
- if (inst->FullSrcRegisters[i].SrcRegister.Indirect) {
- uint file;
- int index;
-
- file = inst->FullSrcRegisters[i].SrcRegisterInd.File;
- index = inst->FullSrcRegisters[i].SrcRegisterInd.Index;
+ (boolean)inst->Src[i].Register.Indirect );
+ if (inst->Src[i].Register.Indirect) {
+ scan_register *ind_reg = MALLOC(sizeof(scan_register));
+
+ fill_scan_register1d(ind_reg,
+ inst->Src[i].Indirect.File,
+ inst->Src[i].Indirect.Index);
+ if (!(reg->file == TGSI_FILE_ADDRESS || reg->file == TGSI_FILE_LOOP) ||
+ reg->indices[0] != 0) {
+ report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
+ }
check_register_usage(
ctx,
- file,
- index,
+ reg,
"indirect",
FALSE );
- if (!(file == TGSI_FILE_ADDRESS || file == TGSI_FILE_LOOP) || index != 0) {
- report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
- }
}
}
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_BGNFOR:
case TGSI_OPCODE_ENDFOR:
- if (inst->FullDstRegisters[0].DstRegister.File != TGSI_FILE_LOOP ||
- inst->FullDstRegisters[0].DstRegister.Index != 0) {
+ if (inst->Dst[0].Register.File != TGSI_FILE_LOOP ||
+ inst->Dst[0].Register.Index != 0) {
report_error(ctx, "Destination register must be LOOP[0]");
}
break;
@@ -253,8 +359,8 @@ iter_instruction(
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_BGNFOR:
- if (inst->FullSrcRegisters[0].SrcRegister.File != TGSI_FILE_CONSTANT &&
- inst->FullSrcRegisters[0].SrcRegister.File != TGSI_FILE_IMMEDIATE) {
+ if (inst->Src[0].Register.File != TGSI_FILE_CONSTANT &&
+ inst->Src[0].Register.File != TGSI_FILE_IMMEDIATE) {
report_error(ctx, "Source register file must be either CONST or IMM");
}
break;
@@ -265,6 +371,19 @@ iter_instruction(
return TRUE;
}
+static void
+check_and_declare(struct sanity_check_ctx *ctx,
+ scan_register *reg)
+{
+ if (is_register_declared( ctx, reg))
+ report_error( ctx, "%s[%u]: The same register declared more than once",
+ file_names[reg->file], reg->indices[0] );
+ cso_hash_insert(ctx->regs_decl,
+ scan_register_key(reg),
+ reg);
+}
+
+
static boolean
iter_declaration(
struct tgsi_iterate_context *iter,
@@ -285,10 +404,22 @@ iter_declaration(
file = decl->Declaration.File;
if (!check_file_name( ctx, file ))
return TRUE;
- for (i = decl->DeclarationRange.First; i <= decl->DeclarationRange.Last; i++) {
- if (is_register_declared( ctx, file, i ))
- report_error( ctx, "%s[%u]: The same register declared more than once", file_names[file], i );
- ctx->regs_decl[file][i / BITS_IN_REG_FLAG] |= (1 << (i % BITS_IN_REG_FLAG));
+ for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ /* declared TGSI_FILE_INPUT's for geometry processor
+ * have an implied second dimension */
+ if (file == TGSI_FILE_INPUT &&
+ ctx->iter.processor.Processor == TGSI_PROCESSOR_GEOMETRY) {
+ uint vert;
+ for (vert = 0; vert < ctx->implied_array_size; ++vert) {
+ scan_register *reg = MALLOC(sizeof(scan_register));
+ fill_scan_register2d(reg, file, vert, i);
+ check_and_declare(ctx, reg);
+ }
+ } else {
+ scan_register *reg = MALLOC(sizeof(scan_register));
+ fill_scan_register1d(reg, file, i);
+ check_and_declare(ctx, reg);
+ }
}
return TRUE;
@@ -300,8 +431,7 @@ iter_immediate(
struct tgsi_full_immediate *imm )
{
struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
-
- assert( ctx->num_imms < MAX_REGISTERS );
+ scan_register *reg;
/* No immediates allowed after the first instruction.
*/
@@ -310,12 +440,16 @@ iter_immediate(
/* Mark the register as declared.
*/
- ctx->regs_decl[TGSI_FILE_IMMEDIATE][ctx->num_imms / BITS_IN_REG_FLAG] |= (1 << (ctx->num_imms % BITS_IN_REG_FLAG));
+ reg = MALLOC(sizeof(scan_register));
+ fill_scan_register1d(reg, TGSI_FILE_IMMEDIATE, ctx->num_imms);
+ cso_hash_insert(ctx->regs_decl, scan_register_key(reg), reg);
ctx->num_imms++;
/* Check data type validity.
*/
- if (imm->Immediate.DataType != TGSI_IMM_FLOAT32) {
+ if (imm->Immediate.DataType != TGSI_IMM_FLOAT32 &&
+ imm->Immediate.DataType != TGSI_IMM_UINT32 &&
+ imm->Immediate.DataType != TGSI_IMM_INT32) {
report_error( ctx, "(%u): Invalid immediate data type", imm->Immediate.DataType );
return TRUE;
}
@@ -323,12 +457,26 @@ iter_immediate(
return TRUE;
}
+
+static boolean
+iter_property(
+ struct tgsi_iterate_context *iter,
+ struct tgsi_full_property *prop )
+{
+ struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
+
+ if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY &&
+ prop->Property.PropertyName == TGSI_PROPERTY_GS_INPUT_PRIM) {
+ ctx->implied_array_size = u_vertices_per_prim(prop->u[0].Data);
+ }
+ return TRUE;
+}
+
static boolean
epilog(
struct tgsi_iterate_context *iter )
{
struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
- uint file;
/* There must be an END instruction somewhere.
*/
@@ -338,13 +486,17 @@ epilog(
/* Check if all declared registers were used.
*/
- for (file = TGSI_FILE_NULL; file < TGSI_FILE_COUNT; file++) {
- uint i;
-
- for (i = 0; i < MAX_REGISTERS; i++) {
- if (is_register_declared( ctx, file, i ) && !is_register_used( ctx, file, i ) && !ctx->regs_ind_used[file]) {
- report_warning( ctx, "%s[%u]: Register never used", file_names[file], i );
+ {
+ struct cso_hash_iter iter =
+ cso_hash_first_node(ctx->regs_decl);
+
+ while (!cso_hash_iter_is_null(iter)) {
+ scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
+ if (!is_register_used(ctx, reg) && !is_ind_register_used(ctx, reg)) {
+ report_warning( ctx, "%s[%u]: Register never used",
+ file_names[reg->file], reg->indices[0] );
}
+ iter = cso_hash_iter_next(iter);
}
}
@@ -356,6 +508,19 @@ epilog(
return TRUE;
}
+static void
+regs_hash_destroy(struct cso_hash *hash)
+{
+ struct cso_hash_iter iter = cso_hash_first_node(hash);
+ while (!cso_hash_iter_is_null(iter)) {
+ scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
+ iter = cso_hash_erase(hash, iter);
+ assert(reg->file < TGSI_FILE_COUNT);
+ FREE(reg);
+ }
+ cso_hash_delete(hash);
+}
+
boolean
tgsi_sanity_check(
const struct tgsi_token *tokens )
@@ -366,20 +531,26 @@ tgsi_sanity_check(
ctx.iter.iterate_instruction = iter_instruction;
ctx.iter.iterate_declaration = iter_declaration;
ctx.iter.iterate_immediate = iter_immediate;
+ ctx.iter.iterate_property = iter_property;
ctx.iter.epilog = epilog;
- memset( ctx.regs_decl, 0, sizeof( ctx.regs_decl ) );
- memset( ctx.regs_used, 0, sizeof( ctx.regs_used ) );
- memset( ctx.regs_ind_used, 0, sizeof( ctx.regs_ind_used ) );
+ ctx.regs_decl = cso_hash_create();
+ ctx.regs_used = cso_hash_create();
+ ctx.regs_ind_used = cso_hash_create();
+
ctx.num_imms = 0;
ctx.num_instructions = 0;
ctx.index_of_END = ~0;
ctx.errors = 0;
ctx.warnings = 0;
+ ctx.implied_array_size = 0;
if (!tgsi_iterate_shader( tokens, &ctx.iter ))
return FALSE;
+ regs_hash_destroy(ctx.regs_decl);
+ regs_hash_destroy(ctx.regs_used);
+ regs_hash_destroy(ctx.regs_ind_used);
return ctx.errors == 0;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 0db4481a3d..a6cc773003 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -35,7 +35,6 @@
#include "util/u_math.h"
-#include "tgsi/tgsi_build.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_scan.h"
@@ -97,14 +96,15 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
uint i;
for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
const struct tgsi_full_src_register *src =
- &fullinst->FullSrcRegisters[i];
- if (src->SrcRegister.File == TGSI_FILE_INPUT) {
- const int ind = src->SrcRegister.Index;
+ &fullinst->Src[i];
+ if (src->Register.File == TGSI_FILE_INPUT ||
+ src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
+ const int ind = src->Register.Index;
if (info->input_semantic_name[ind] == TGSI_SEMANTIC_FOG) {
- if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_X) {
+ if (src->Register.SwizzleX == TGSI_SWIZZLE_X) {
info->uses_fogcoord = TRUE;
}
- else if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_Y) {
+ else if (src->Register.SwizzleX == TGSI_SWIZZLE_Y) {
info->uses_frontfacing = TRUE;
}
}
@@ -120,8 +120,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
= &parse.FullToken.FullDeclaration;
const uint file = fulldecl->Declaration.File;
uint reg;
- for (reg = fulldecl->DeclarationRange.First;
- reg <= fulldecl->DeclarationRange.Last;
+ for (reg = fulldecl->Range.First;
+ reg <= fulldecl->Range.Last;
reg++) {
/* only first 32 regs will appear in this bitfield */
@@ -129,25 +129,29 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
info->file_count[file]++;
info->file_max[file] = MAX2(info->file_max[file], (int)reg);
- if (file == TGSI_FILE_INPUT) {
- info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName;
- info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.SemanticIndex;
+ if (file == TGSI_FILE_INPUT || file == TGSI_FILE_SYSTEM_VALUE) {
+ info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
+ info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
info->input_interpolate[reg] = (ubyte)fulldecl->Declaration.Interpolate;
info->num_inputs++;
}
else if (file == TGSI_FILE_OUTPUT) {
- info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName;
- info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.SemanticIndex;
+ info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
+ info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
info->num_outputs++;
- }
- /* special case */
- if (procType == TGSI_PROCESSOR_FRAGMENT &&
- file == TGSI_FILE_OUTPUT &&
- fulldecl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
- info->writes_z = TRUE;
+ /* extra info for special outputs */
+ if (procType == TGSI_PROCESSOR_FRAGMENT &&
+ fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
+ info->writes_z = TRUE;
+ }
+ if (procType == TGSI_PROCESSOR_VERTEX &&
+ fulldecl->Semantic.Name == TGSI_SEMANTIC_EDGEFLAG) {
+ info->writes_edgeflag = TRUE;
+ }
}
- }
+
+ }
}
break;
@@ -161,6 +165,19 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
info->file_max[file] = MAX2(info->file_max[file], (int)reg);
}
break;
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ {
+ const struct tgsi_full_property *fullprop
+ = &parse.FullToken.FullProperty;
+
+ info->properties[info->num_properties].name =
+ fullprop->Property.PropertyName;
+ memcpy(info->properties[info->num_properties].data,
+ fullprop->u, 8 * sizeof(unsigned));;
+
+ ++info->num_properties;
+ }
+ break;
default:
assert( 0 );
@@ -206,34 +223,26 @@ tgsi_is_passthrough_shader(const struct tgsi_token *tokens)
struct tgsi_full_instruction *fullinst =
&parse.FullToken.FullInstruction;
const struct tgsi_full_src_register *src =
- &fullinst->FullSrcRegisters[0];
+ &fullinst->Src[0];
const struct tgsi_full_dst_register *dst =
- &fullinst->FullDstRegisters[0];
+ &fullinst->Dst[0];
/* Do a whole bunch of checks for a simple move */
if (fullinst->Instruction.Opcode != TGSI_OPCODE_MOV ||
- src->SrcRegister.File != TGSI_FILE_INPUT ||
- dst->DstRegister.File != TGSI_FILE_OUTPUT ||
- src->SrcRegister.Index != dst->DstRegister.Index ||
-
- src->SrcRegister.Negate ||
- src->SrcRegisterExtMod.Negate ||
- src->SrcRegisterExtMod.Absolute ||
- src->SrcRegisterExtMod.Scale2X ||
- src->SrcRegisterExtMod.Bias ||
- src->SrcRegisterExtMod.Complement ||
-
- src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
- src->SrcRegister.SwizzleY != TGSI_SWIZZLE_Y ||
- src->SrcRegister.SwizzleZ != TGSI_SWIZZLE_Z ||
- src->SrcRegister.SwizzleW != TGSI_SWIZZLE_W ||
-
- src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X ||
- src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
- src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
- src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W ||
-
- dst->DstRegister.WriteMask != TGSI_WRITEMASK_XYZW)
+ (src->Register.File != TGSI_FILE_INPUT &&
+ src->Register.File != TGSI_FILE_SYSTEM_VALUE) ||
+ dst->Register.File != TGSI_FILE_OUTPUT ||
+ src->Register.Index != dst->Register.Index ||
+
+ src->Register.Negate ||
+ src->Register.Absolute ||
+
+ src->Register.SwizzleX != TGSI_SWIZZLE_X ||
+ src->Register.SwizzleY != TGSI_SWIZZLE_Y ||
+ src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleW != TGSI_SWIZZLE_W ||
+
+ dst->Register.WriteMask != TGSI_WRITEMASK_XYZW)
{
tgsi_parse_free(&parse);
return FALSE;
@@ -245,6 +254,8 @@ tgsi_is_passthrough_shader(const struct tgsi_token *tokens)
/* fall-through */
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* fall-through */
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ /* fall-through */
default:
; /* no-op */
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 8a7ee0c7e4..dae5376c24 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -33,7 +33,6 @@
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
-
/**
* Shader summary info
*/
@@ -58,11 +57,17 @@ struct tgsi_shader_info
uint opcode_count[TGSI_OPCODE_LAST]; /**< opcode histogram */
boolean writes_z; /**< does fragment shader write Z value? */
+ boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
boolean uses_kill; /**< KIL or KILP instruction used? */
boolean uses_fogcoord; /**< fragment shader uses fog coord? */
boolean uses_frontfacing; /**< fragment shader uses front/back-face flag? */
-};
+ struct {
+ unsigned name;
+ unsigned data[8];
+ } properties[TGSI_PROPERTY_COUNT];
+ uint num_properties;
+};
extern void
tgsi_scan_shader(const struct tgsi_token *tokens,
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 5f6b83b236..2e13a7aaf9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -2,6 +2,7 @@
*
* Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
+ * 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
@@ -58,7 +59,7 @@
for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
- ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+ ((INST).Dst[0].Register.WriteMask & (1 << (CHAN)))
#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
@@ -1260,38 +1261,39 @@ emit_fetch(
const struct tgsi_full_src_register *reg,
const unsigned chan_index )
{
- unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
+ unsigned swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
switch (swizzle) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
- switch (reg->SrcRegister.File) {
+ case TGSI_SWIZZLE_X:
+ case TGSI_SWIZZLE_Y:
+ case TGSI_SWIZZLE_Z:
+ case TGSI_SWIZZLE_W:
+ switch (reg->Register.File) {
case TGSI_FILE_CONSTANT:
emit_const(
func,
xmm,
- reg->SrcRegister.Index,
+ reg->Register.Index,
swizzle,
- reg->SrcRegister.Indirect,
- reg->SrcRegisterInd.File,
- reg->SrcRegisterInd.Index );
+ reg->Register.Indirect,
+ reg->Indirect.File,
+ reg->Indirect.Index );
break;
case TGSI_FILE_IMMEDIATE:
emit_immediate(
func,
xmm,
- reg->SrcRegister.Index,
+ reg->Register.Index,
swizzle );
break;
case TGSI_FILE_INPUT:
+ case TGSI_FILE_SYSTEM_VALUE:
emit_inputf(
func,
xmm,
- reg->SrcRegister.Index,
+ reg->Register.Index,
swizzle );
break;
@@ -1299,7 +1301,7 @@ emit_fetch(
emit_tempf(
func,
xmm,
- reg->SrcRegister.Index,
+ reg->Register.Index,
swizzle );
break;
@@ -1308,22 +1310,6 @@ emit_fetch(
}
break;
- case TGSI_EXTSWIZZLE_ZERO:
- emit_tempf(
- func,
- xmm,
- TGSI_EXEC_TEMP_00000000_I,
- TGSI_EXEC_TEMP_00000000_C );
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- emit_tempf(
- func,
- xmm,
- TEMP_ONE_I,
- TEMP_ONE_C );
- break;
-
default:
assert( 0 );
}
@@ -1347,7 +1333,7 @@ emit_fetch(
}
#define FETCH( FUNC, INST, XMM, INDEX, CHAN )\
- emit_fetch( FUNC, XMM, &(INST).FullSrcRegisters[INDEX], CHAN )
+ emit_fetch( FUNC, XMM, &(INST).Src[INDEX], CHAN )
/**
* Register store.
@@ -1387,12 +1373,12 @@ emit_store(
}
- switch( reg->DstRegister.File ) {
+ switch( reg->Register.File ) {
case TGSI_FILE_OUTPUT:
emit_output(
func,
xmm,
- reg->DstRegister.Index,
+ reg->Register.Index,
chan_index );
break;
@@ -1400,7 +1386,7 @@ emit_store(
emit_temps(
func,
xmm,
- reg->DstRegister.Index,
+ reg->Register.Index,
chan_index );
break;
@@ -1408,7 +1394,7 @@ emit_store(
emit_addrs(
func,
xmm,
- reg->DstRegister.Index,
+ reg->Register.Index,
chan_index );
break;
@@ -1418,7 +1404,7 @@ emit_store(
}
#define STORE( FUNC, INST, XMM, INDEX, CHAN )\
- emit_store( FUNC, XMM, &(INST).FullDstRegisters[INDEX], &(INST), CHAN )
+ emit_store( FUNC, XMM, &(INST).Dst[INDEX], &(INST), CHAN )
static void PIPE_CDECL
@@ -1433,13 +1419,13 @@ fetch_texel( struct tgsi_sampler **sampler,
sampler, *sampler,
store );
- debug_printf("lodbias %f\n", store[12]);
-
for (j = 0; j < 4; j++)
- debug_printf("sample %d texcoord %f %f\n",
+ debug_printf("sample %d texcoord %f %f %f lodbias %f\n",
j,
store[0+j],
- store[4+j]);
+ store[4+j],
+ store[8 + j],
+ store[12 + j]);
#endif
{
@@ -1448,7 +1434,8 @@ fetch_texel( struct tgsi_sampler **sampler,
&store[0], /* s */
&store[4], /* t */
&store[8], /* r */
- store[12], /* lodbias */
+ &store[12], /* lodbias */
+ tgsi_sampler_lod_bias,
rgba); /* results */
memcpy( store, rgba, 16 * sizeof(float));
@@ -1475,12 +1462,13 @@ emit_tex( struct x86_function *func,
boolean lodbias,
boolean projected)
{
- const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+ const uint unit = inst->Src[1].Register.Index;
struct x86_reg args[2];
unsigned count;
unsigned i;
- switch (inst->InstructionExtTexture.Texture) {
+ assert(inst->Instruction.Texture);
+ switch (inst->Texture.Texture) {
case TGSI_TEXTURE_1D:
count = 1;
break;
@@ -1582,13 +1570,13 @@ emit_kil(
/* This mask stores component bits that were already tested. Note that
* we test if the value is less than zero, so 1.0 and 0.0 need not to be
* tested. */
- uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
+ uniquemask = 0;
FOR_EACH_CHANNEL( chan_index ) {
unsigned swizzle;
/* unswizzle channel */
- swizzle = tgsi_util_get_full_src_register_extswizzle(
+ swizzle = tgsi_util_get_full_src_register_swizzle(
reg,
chan_index );
@@ -1735,15 +1723,15 @@ indirect_temp_reference(const struct tgsi_full_instruction *inst)
{
uint i;
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
- const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[i];
- if (reg->SrcRegister.File == TGSI_FILE_TEMPORARY &&
- reg->SrcRegister.Indirect)
+ const struct tgsi_full_src_register *reg = &inst->Src[i];
+ if (reg->Register.File == TGSI_FILE_TEMPORARY &&
+ reg->Register.Indirect)
return TRUE;
}
for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
- const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[i];
- if (reg->DstRegister.File == TGSI_FILE_TEMPORARY &&
- reg->DstRegister.Indirect)
+ const struct tgsi_full_dst_register *reg = &inst->Dst[i];
+ if (reg->Register.File == TGSI_FILE_TEMPORARY &&
+ reg->Register.Indirect)
return TRUE;
}
return FALSE;
@@ -1772,7 +1760,6 @@ emit_instruction(
break;
case TGSI_OPCODE_MOV:
- case TGSI_OPCODE_SWZ:
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( func, *inst, 4 + chan_index, 0, chan_index );
}
@@ -2260,7 +2247,7 @@ emit_instruction(
case TGSI_OPCODE_KIL:
/* conditional kill */
- emit_kil( func, &inst->FullSrcRegisters[0] );
+ emit_kil( func, &inst->Src[0] );
break;
case TGSI_OPCODE_PK2H:
@@ -2521,7 +2508,7 @@ emit_instruction(
break;
case TGSI_OPCODE_TXL:
- emit_tex( func, inst, TRUE, FALSE );
+ return 0;
break;
case TGSI_OPCODE_TXP:
@@ -2593,7 +2580,7 @@ emit_instruction(
return 0;
break;
- case TGSI_OPCODE_SHR:
+ case TGSI_OPCODE_ISHR:
return 0;
break;
@@ -2649,12 +2636,13 @@ emit_declaration(
struct x86_function *func,
struct tgsi_full_declaration *decl )
{
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
+ if( decl->Declaration.File == TGSI_FILE_INPUT ||
+ decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE ) {
unsigned first, last, mask;
unsigned i, j;
- first = decl->DeclarationRange.First;
- last = decl->DeclarationRange.Last;
+ first = decl->Range.First;
+ last = decl->Range.Last;
mask = decl->Declaration.UsageMask;
for( i = first; i <= last; i++ ) {
@@ -2938,8 +2926,7 @@ tgsi_emit_sse2(
* the result in the cases where the code is too opaque to
* fix.
*/
- if (opcode != TGSI_OPCODE_MOV &&
- opcode != TGSI_OPCODE_SWZ) {
+ if (opcode != TGSI_OPCODE_MOV) {
debug_printf("Warning: src/dst aliasing in instruction"
" is not handled:\n");
tgsi_dump_instruction(&parse.FullToken.FullInstruction, 1);
@@ -2969,6 +2956,9 @@ tgsi_emit_sse2(
num_immediates++;
}
break;
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ /* we just ignore them for now */
+ break;
default:
ok = 0;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index d438450b1e..9fcffeda36 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -27,6 +27,9 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
+#include "util/u_prim.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#include "tgsi_text.h"
#include "tgsi_build.h"
#include "tgsi_info.h"
@@ -59,6 +62,23 @@ static boolean uprcase( char c )
return c;
}
+/*
+ * Ignore case of str1 and assume str1 is already uppercase.
+ * Return TRUE iff str1 and str2 are equal.
+ */
+static int
+streq_nocase_uprcase(const char *str1,
+ const char *str2)
+{
+ while (*str1 && *str2) {
+ if (*str1 != uprcase(*str2))
+ return FALSE;
+ str1++;
+ str2++;
+ }
+ return TRUE;
+}
+
static boolean str_match_no_case( const char **pcur, const char *str )
{
const char *cur = *pcur;
@@ -110,6 +130,20 @@ static boolean parse_uint( const char **pcur, uint *val )
return FALSE;
}
+static boolean parse_identifier( const char **pcur, char *ret )
+{
+ const char *cur = *pcur;
+ int i = 0;
+ if (is_alpha_underscore( cur )) {
+ ret[i++] = *cur++;
+ while (is_alpha_underscore( cur ))
+ ret[i++] = *cur++;
+ *pcur = cur;
+ return TRUE;
+ }
+ return FALSE;
+}
+
/* Parse floating point.
*/
static boolean parse_float( const char **pcur, float *val )
@@ -163,28 +197,43 @@ struct translate_ctx
struct tgsi_token *tokens_cur;
struct tgsi_token *tokens_end;
struct tgsi_header *header;
+ unsigned processor : 4;
+ int implied_array_size : 5;
};
static void report_error( struct translate_ctx *ctx, const char *msg )
{
- debug_printf( "\nError: %s", msg );
+ int line = 1;
+ int column = 1;
+ const char *itr = ctx->text;
+
+ while (itr != ctx->cur) {
+ if (*itr == '\n') {
+ column = 1;
+ ++line;
+ }
+ ++column;
+ ++itr;
+ }
+
+ debug_printf( "\nTGSI asm error: %s [%d : %d] \n", msg, line, column );
}
/* Parse shader header.
* Return TRUE for one of the following headers.
- * FRAG1.1
- * GEOM1.1
- * VERT1.1
+ * FRAG
+ * GEOM
+ * VERT
*/
static boolean parse_header( struct translate_ctx *ctx )
{
uint processor;
- if (str_match_no_case( &ctx->cur, "FRAG1.1" ))
+ if (str_match_no_case( &ctx->cur, "FRAG" ))
processor = TGSI_PROCESSOR_FRAGMENT;
- else if (str_match_no_case( &ctx->cur, "VERT1.1" ))
+ else if (str_match_no_case( &ctx->cur, "VERT" ))
processor = TGSI_PROCESSOR_VERTEX;
- else if (str_match_no_case( &ctx->cur, "GEOM1.1" ))
+ else if (str_match_no_case( &ctx->cur, "GEOM" ))
processor = TGSI_PROCESSOR_GEOMETRY;
else {
report_error( ctx, "Unknown header" );
@@ -193,16 +242,13 @@ static boolean parse_header( struct translate_ctx *ctx )
if (ctx->tokens_cur >= ctx->tokens_end)
return FALSE;
- *(struct tgsi_version *) ctx->tokens_cur++ = tgsi_build_version();
-
- if (ctx->tokens_cur >= ctx->tokens_end)
- return FALSE;
ctx->header = (struct tgsi_header *) ctx->tokens_cur++;
*ctx->header = tgsi_build_header();
if (ctx->tokens_cur >= ctx->tokens_end)
return FALSE;
*(struct tgsi_processor *) ctx->tokens_cur++ = tgsi_build_processor( processor, ctx->header );
+ ctx->processor = processor;
return TRUE;
}
@@ -232,7 +278,9 @@ static const char *file_names[TGSI_FILE_COUNT] =
"SAMP",
"ADDR",
"IMM",
- "LOOP"
+ "LOOP",
+ "PRED",
+ "SV"
};
static boolean
@@ -297,92 +345,36 @@ parse_opt_writemask(
return TRUE;
}
-/* <register_file_bracket> ::= <file> `['
- */
static boolean
-parse_register_file_bracket(
- struct translate_ctx *ctx,
- uint *file )
-{
- if (!parse_file( &ctx->cur, file )) {
- report_error( ctx, "Unknown register file" );
- return FALSE;
- }
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != '[') {
- report_error( ctx, "Expected `['" );
- return FALSE;
- }
- ctx->cur++;
- return TRUE;
-}
+parse_register_dst( struct translate_ctx *ctx,
+ uint *file,
+ int *index );
-/* <register_file_bracket_index> ::= <register_file_bracket> <uint>
- */
-static boolean
-parse_register_file_bracket_index(
- struct translate_ctx *ctx,
- uint *file,
- int *index )
-{
- uint uindex;
+struct parsed_src_bracket {
+ int index;
- if (!parse_register_file_bracket( ctx, file ))
- return FALSE;
- eat_opt_white( &ctx->cur );
- if (!parse_uint( &ctx->cur, &uindex )) {
- report_error( ctx, "Expected literal unsigned integer" );
- return FALSE;
- }
- *index = (int) uindex;
- return TRUE;
-}
+ uint ind_file;
+ int ind_index;
+ uint ind_comp;
+};
-/* Parse destination register operand.
- * <register_dst> ::= <register_file_bracket_index> `]'
- */
-static boolean
-parse_register_dst(
- struct translate_ctx *ctx,
- uint *file,
- int *index )
-{
- if (!parse_register_file_bracket_index( ctx, file, index ))
- return FALSE;
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != ']') {
- report_error( ctx, "Expected `]'" );
- return FALSE;
- }
- ctx->cur++;
- return TRUE;
-}
-/* Parse source register operand.
- * <register_src> ::= <register_file_bracket_index> `]' |
- * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `]' |
- * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
- * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
- */
static boolean
-parse_register_src(
+parse_register_src_bracket(
struct translate_ctx *ctx,
- uint *file,
- int *index,
- uint *ind_file,
- int *ind_index,
- uint *ind_comp)
+ struct parsed_src_bracket *brackets)
{
const char *cur;
uint uindex;
- *ind_comp = TGSI_SWIZZLE_X;
- if (!parse_register_file_bracket( ctx, file ))
- return FALSE;
+ memset(brackets, 0, sizeof(struct parsed_src_bracket));
+
eat_opt_white( &ctx->cur );
+
cur = ctx->cur;
- if (parse_file( &cur, ind_file )) {
- if (!parse_register_dst( ctx, ind_file, ind_index ))
+ if (parse_file( &cur, &brackets->ind_file )) {
+ if (!parse_register_dst( ctx, &brackets->ind_file,
+ &brackets->ind_index ))
return FALSE;
eat_opt_white( &ctx->cur );
@@ -392,16 +384,16 @@ parse_register_src(
switch (uprcase(*ctx->cur)) {
case 'X':
- *ind_comp = TGSI_SWIZZLE_X;
+ brackets->ind_comp = TGSI_SWIZZLE_X;
break;
case 'Y':
- *ind_comp = TGSI_SWIZZLE_Y;
+ brackets->ind_comp = TGSI_SWIZZLE_Y;
break;
case 'Z':
- *ind_comp = TGSI_SWIZZLE_Z;
+ brackets->ind_comp = TGSI_SWIZZLE_Z;
break;
case 'W':
- *ind_comp = TGSI_SWIZZLE_W;
+ brackets->ind_comp = TGSI_SWIZZLE_W;
break;
default:
report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'");
@@ -422,12 +414,12 @@ parse_register_src(
return FALSE;
}
if (negate)
- *index = -(int) uindex;
+ brackets->index = -(int) uindex;
else
- *index = (int) uindex;
+ brackets->index = (int) uindex;
}
else {
- *index = 0;
+ brackets->index = 0;
}
}
else {
@@ -435,9 +427,9 @@ parse_register_src(
report_error( ctx, "Expected literal unsigned integer" );
return FALSE;
}
- *index = (int) uindex;
- *ind_file = TGSI_FILE_NULL;
- *ind_index = 0;
+ brackets->index = (int) uindex;
+ brackets->ind_file = TGSI_FILE_NULL;
+ brackets->ind_index = 0;
}
eat_opt_white( &ctx->cur );
if (*ctx->cur != ']') {
@@ -448,20 +440,123 @@ parse_register_src(
return TRUE;
}
-/* Parse register declaration.
- * <register_dcl> ::= <register_file_bracket_index> `]' |
- * <register_file_bracket_index> `..' <index> `]'
+static boolean
+parse_opt_register_src_bracket(
+ struct translate_ctx *ctx,
+ struct parsed_src_bracket *brackets,
+ int *parsed_brackets)
+{
+ const char *cur = ctx->cur;
+
+ *parsed_brackets = 0;
+
+ eat_opt_white( &cur );
+ if (cur[0] == '[') {
+ ++cur;
+ ctx->cur = cur;
+
+ if (!parse_register_src_bracket(ctx, brackets))
+ return FALSE;
+
+ *parsed_brackets = 1;
+ }
+
+ return TRUE;
+}
+
+/* <register_file_bracket> ::= <file> `['
*/
static boolean
-parse_register_dcl(
+parse_register_file_bracket(
+ struct translate_ctx *ctx,
+ uint *file )
+{
+ if (!parse_file( &ctx->cur, file )) {
+ report_error( ctx, "Unknown register file" );
+ return FALSE;
+ }
+ eat_opt_white( &ctx->cur );
+ if (*ctx->cur != '[') {
+ report_error( ctx, "Expected `['" );
+ return FALSE;
+ }
+ ctx->cur++;
+ return TRUE;
+}
+
+/* <register_file_bracket_index> ::= <register_file_bracket> <uint>
+ */
+static boolean
+parse_register_file_bracket_index(
+ struct translate_ctx *ctx,
+ uint *file,
+ int *index )
+{
+ uint uindex;
+
+ if (!parse_register_file_bracket( ctx, file ))
+ return FALSE;
+ eat_opt_white( &ctx->cur );
+ if (!parse_uint( &ctx->cur, &uindex )) {
+ report_error( ctx, "Expected literal unsigned integer" );
+ return FALSE;
+ }
+ *index = (int) uindex;
+ return TRUE;
+}
+
+/* Parse source register operand.
+ * <register_src> ::= <register_file_bracket_index> `]' |
+ * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `]' |
+ * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
+ * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
+ */
+static boolean
+parse_register_src(
struct translate_ctx *ctx,
uint *file,
- int *first,
- int *last )
+ struct parsed_src_bracket *brackets)
{
- if (!parse_register_file_bracket_index( ctx, file, first ))
+
+ brackets->ind_comp = TGSI_SWIZZLE_X;
+ if (!parse_register_file_bracket( ctx, file ))
return FALSE;
+ if (!parse_register_src_bracket( ctx, brackets ))
+ return FALSE;
+
+ return TRUE;
+}
+
+struct parsed_dcl_bracket {
+ uint first;
+ uint last;
+};
+
+static boolean
+parse_register_dcl_bracket(
+ struct translate_ctx *ctx,
+ struct parsed_dcl_bracket *bracket)
+{
+ uint uindex;
+ memset(bracket, 0, sizeof(struct parsed_dcl_bracket));
+
eat_opt_white( &ctx->cur );
+
+ if (!parse_uint( &ctx->cur, &uindex )) {
+ /* it can be an empty bracket [] which means its range
+ * is from 0 to some implied size */
+ if (ctx->cur[0] == ']' && ctx->implied_array_size != 0) {
+ bracket->first = 0;
+ bracket->last = ctx->implied_array_size - 1;
+ goto cleanup;
+ }
+ report_error( ctx, "Expected literal unsigned integer" );
+ return FALSE;
+ }
+ bracket->first = (int) uindex;
+
+ eat_opt_white( &ctx->cur );
+
if (ctx->cur[0] == '.' && ctx->cur[1] == '.') {
uint uindex;
@@ -471,12 +566,14 @@ parse_register_dcl(
report_error( ctx, "Expected literal integer" );
return FALSE;
}
- *last = (int) uindex;
+ bracket->last = (int) uindex;
eat_opt_white( &ctx->cur );
}
else {
- *last = *first;
+ bracket->last = bracket->first;
}
+
+cleanup:
if (*ctx->cur != ']') {
report_error( ctx, "Expected `]' or `..'" );
return FALSE;
@@ -485,16 +582,70 @@ parse_register_dcl(
return TRUE;
}
-static const char *modulate_names[TGSI_MODULATE_COUNT] =
+/* Parse register declaration.
+ * <register_dcl> ::= <register_file_bracket_index> `]' |
+ * <register_file_bracket_index> `..' <index> `]'
+ */
+static boolean
+parse_register_dcl(
+ struct translate_ctx *ctx,
+ uint *file,
+ struct parsed_dcl_bracket *brackets,
+ int *num_brackets)
{
- "_1X",
- "_2X",
- "_4X",
- "_8X",
- "_D2",
- "_D4",
- "_D8"
-};
+ const char *cur;
+
+ *num_brackets = 0;
+
+ if (!parse_register_file_bracket( ctx, file ))
+ return FALSE;
+ if (!parse_register_dcl_bracket( ctx, &brackets[0] ))
+ return FALSE;
+
+ *num_brackets = 1;
+
+ cur = ctx->cur;
+ eat_opt_white( &cur );
+
+ if (cur[0] == '[') {
+ ++cur;
+ ctx->cur = cur;
+ if (!parse_register_dcl_bracket( ctx, &brackets[1] ))
+ return FALSE;
+ /* for geometry shader we don't really care about
+ * the first brackets it's always the size of the
+ * input primitive. so we want to declare just
+ * the index relevant to the semantics which is in
+ * the second bracket */
+ if (ctx->processor == TGSI_PROCESSOR_GEOMETRY) {
+ brackets[0] = brackets[1];
+ }
+ *num_brackets = 2;
+ }
+
+ return TRUE;
+}
+
+
+/* Parse destination register operand.
+ * <register_dst> ::= <register_file_bracket_index> `]'
+ */
+static boolean
+parse_register_dst(
+ struct translate_ctx *ctx,
+ uint *file,
+ int *index )
+{
+ if (!parse_register_file_bracket_index( ctx, file, index ))
+ return FALSE;
+ eat_opt_white( &ctx->cur );
+ if (*ctx->cur != ']') {
+ report_error( ctx, "Expected `]'" );
+ return FALSE;
+ }
+ ctx->cur++;
+ return TRUE;
+}
static boolean
parse_dst_operand(
@@ -511,26 +662,13 @@ parse_dst_operand(
cur = ctx->cur;
eat_opt_white( &cur );
- if (*cur == '_') {
- uint i;
-
- for (i = 0; i < TGSI_MODULATE_COUNT; i++) {
- if (str_match_no_case( &cur, modulate_names[i] )) {
- if (!is_digit_alpha_underscore( cur )) {
- dst->DstRegisterExtModulate.Modulate = i;
- ctx->cur = cur;
- break;
- }
- }
- }
- }
if (!parse_opt_writemask( ctx, &writemask ))
return FALSE;
- dst->DstRegister.File = file;
- dst->DstRegister.Index = index;
- dst->DstRegister.WriteMask = writemask;
+ dst->Register.File = file;
+ dst->Register.Index = index;
+ dst->Register.WriteMask = writemask;
return TRUE;
}
@@ -538,13 +676,11 @@ static boolean
parse_optional_swizzle(
struct translate_ctx *ctx,
uint swizzle[4],
- boolean *parsed_swizzle,
- boolean *parsed_extswizzle )
+ boolean *parsed_swizzle )
{
const char *cur = ctx->cur;
*parsed_swizzle = FALSE;
- *parsed_extswizzle = FALSE;
eat_opt_white( &cur );
if (*cur == '.') {
@@ -562,15 +698,8 @@ parse_optional_swizzle(
else if (uprcase( *cur ) == 'W')
swizzle[i] = TGSI_SWIZZLE_W;
else {
- if (*cur == '0')
- swizzle[i] = TGSI_EXTSWIZZLE_ZERO;
- else if (*cur == '1')
- swizzle[i] = TGSI_EXTSWIZZLE_ONE;
- else {
- report_error( ctx, "Expected register swizzle component `x', `y', `z', `w', `0' or `1'" );
- return FALSE;
- }
- *parsed_extswizzle = TRUE;
+ report_error( ctx, "Expected register swizzle component `x', `y', `z', `w', `0' or `1'" );
+ return FALSE;
}
cur++;
}
@@ -585,171 +714,59 @@ parse_src_operand(
struct translate_ctx *ctx,
struct tgsi_full_src_register *src )
{
- const char *cur;
- float value;
uint file;
- int index;
- uint ind_file;
- int ind_index;
- uint ind_comp;
uint swizzle[4];
- boolean parsed_ext_negate_paren = FALSE;
boolean parsed_swizzle;
- boolean parsed_extswizzle;
+ struct parsed_src_bracket bracket[2];
+ int parsed_opt_brackets;
if (*ctx->cur == '-') {
- cur = ctx->cur;
- cur++;
- eat_opt_white( &cur );
- if (*cur == '(') {
- cur++;
- src->SrcRegisterExtMod.Negate = 1;
- eat_opt_white( &cur );
- ctx->cur = cur;
- parsed_ext_negate_paren = TRUE;
- }
- else if (*cur == '|') {
- cur++;
- src->SrcRegisterExtMod.Negate = 1;
- src->SrcRegisterExtMod.Absolute = 1;
- eat_opt_white(&cur);
- ctx->cur = cur;
- }
- }
- else if (*ctx->cur == '|') {
ctx->cur++;
eat_opt_white( &ctx->cur );
- src->SrcRegisterExtMod.Absolute = 1;
+ src->Register.Negate = 1;
}
- if (*ctx->cur == '-') {
+ if (*ctx->cur == '|') {
ctx->cur++;
eat_opt_white( &ctx->cur );
- src->SrcRegister.Negate = 1;
+ src->Register.Absolute = 1;
}
- cur = ctx->cur;
- if (parse_float( &cur, &value )) {
- if (value == 2.0f) {
- eat_opt_white( &cur );
- if (*cur != '*') {
- report_error( ctx, "Expected `*'" );
- return FALSE;
- }
- cur++;
- if (*cur != '(') {
- report_error( ctx, "Expected `('" );
- return FALSE;
- }
- cur++;
- src->SrcRegisterExtMod.Scale2X = 1;
- eat_opt_white( &cur );
- ctx->cur = cur;
- }
- }
-
- if (*ctx->cur == '(') {
- ctx->cur++;
- eat_opt_white( &ctx->cur );
- src->SrcRegisterExtMod.Bias = 1;
- }
+ if (!parse_register_src(ctx, &file, &bracket[0]))
+ return FALSE;
+ if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets))
+ return FALSE;
- cur = ctx->cur;
- if (parse_float( &cur, &value )) {
- if (value == 1.0f) {
- eat_opt_white( &cur );
- if (*cur != '-') {
- report_error( ctx, "Expected `-'" );
- return FALSE;
- }
- cur++;
- if (*cur != '(') {
- report_error( ctx, "Expected `('" );
- return FALSE;
- }
- cur++;
- src->SrcRegisterExtMod.Complement = 1;
- eat_opt_white( &cur );
- ctx->cur = cur;
- }
+ src->Register.File = file;
+ src->Register.Index = bracket[0].index;
+ if (bracket[0].ind_file != TGSI_FILE_NULL) {
+ src->Register.Indirect = 1;
+ src->Indirect.File = bracket[0].ind_file;
+ src->Indirect.Index = bracket[0].ind_index;
+ src->Indirect.SwizzleX = bracket[0].ind_comp;
+ src->Indirect.SwizzleY = bracket[0].ind_comp;
+ src->Indirect.SwizzleZ = bracket[0].ind_comp;
+ src->Indirect.SwizzleW = bracket[0].ind_comp;
}
-
- if (!parse_register_src(ctx, &file, &index, &ind_file, &ind_index, &ind_comp))
- return FALSE;
- src->SrcRegister.File = file;
- src->SrcRegister.Index = index;
- if (ind_file != TGSI_FILE_NULL) {
- src->SrcRegister.Indirect = 1;
- src->SrcRegisterInd.File = ind_file;
- src->SrcRegisterInd.Index = ind_index;
- src->SrcRegisterInd.SwizzleX = ind_comp;
- src->SrcRegisterInd.SwizzleY = ind_comp;
- src->SrcRegisterInd.SwizzleZ = ind_comp;
- src->SrcRegisterInd.SwizzleW = ind_comp;
+ if (parsed_opt_brackets) {
+ src->Register.Dimension = 1;
+ src->Dimension.Indirect = 0;
+ src->Dimension.Dimension = 0;
+ src->Dimension.Index = bracket[1].index;
}
/* Parse optional swizzle.
*/
- if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, &parsed_extswizzle )) {
- if (parsed_extswizzle) {
- assert( parsed_swizzle );
-
- src->SrcRegisterExtSwz.ExtSwizzleX = swizzle[0];
- src->SrcRegisterExtSwz.ExtSwizzleY = swizzle[1];
- src->SrcRegisterExtSwz.ExtSwizzleZ = swizzle[2];
- src->SrcRegisterExtSwz.ExtSwizzleW = swizzle[3];
- }
- else if (parsed_swizzle) {
- src->SrcRegister.SwizzleX = swizzle[0];
- src->SrcRegister.SwizzleY = swizzle[1];
- src->SrcRegister.SwizzleZ = swizzle[2];
- src->SrcRegister.SwizzleW = swizzle[3];
- }
- }
-
- if (src->SrcRegisterExtMod.Complement) {
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != ')') {
- report_error( ctx, "Expected `)'" );
- return FALSE;
- }
- ctx->cur++;
- }
-
- if (src->SrcRegisterExtMod.Bias) {
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != ')') {
- report_error( ctx, "Expected `)'" );
- return FALSE;
- }
- ctx->cur++;
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != '-') {
- report_error( ctx, "Expected `-'" );
- return FALSE;
- }
- ctx->cur++;
- eat_opt_white( &ctx->cur );
- if (!parse_float( &ctx->cur, &value )) {
- report_error( ctx, "Expected literal floating point" );
- return FALSE;
- }
- if (value != 0.5f) {
- report_error( ctx, "Expected 0.5" );
- return FALSE;
+ if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle )) {
+ if (parsed_swizzle) {
+ src->Register.SwizzleX = swizzle[0];
+ src->Register.SwizzleY = swizzle[1];
+ src->Register.SwizzleZ = swizzle[2];
+ src->Register.SwizzleW = swizzle[3];
}
}
- if (src->SrcRegisterExtMod.Scale2X) {
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != ')') {
- report_error( ctx, "Expected `)'" );
- return FALSE;
- }
- ctx->cur++;
- }
-
- if (src->SrcRegisterExtMod.Absolute) {
+ if (src->Register.Absolute) {
eat_opt_white( &ctx->cur );
if (*ctx->cur != '|') {
report_error( ctx, "Expected `|'" );
@@ -758,14 +775,6 @@ parse_src_operand(
ctx->cur++;
}
- if (parsed_ext_negate_paren) {
- eat_opt_white( &ctx->cur );
- if (*ctx->cur != ')') {
- report_error( ctx, "Expected `)'" );
- return FALSE;
- }
- ctx->cur++;
- }
return TRUE;
}
@@ -857,11 +866,11 @@ parse_instruction(
}
if (i < info->num_dst) {
- if (!parse_dst_operand( ctx, &inst.FullDstRegisters[i] ))
+ if (!parse_dst_operand( ctx, &inst.Dst[i] ))
return FALSE;
}
else if (i < info->num_dst + info->num_src) {
- if (!parse_src_operand( ctx, &inst.FullSrcRegisters[i - info->num_dst] ))
+ if (!parse_src_operand( ctx, &inst.Src[i - info->num_dst] ))
return FALSE;
}
else {
@@ -870,7 +879,8 @@ parse_instruction(
for (j = 0; j < TGSI_TEXTURE_COUNT; j++) {
if (str_match_no_case( &ctx->cur, texture_names[j] )) {
if (!is_digit_alpha_underscore( ctx->cur )) {
- inst.InstructionExtTexture.Texture = j;
+ inst.Instruction.Texture = 1;
+ inst.Texture.Texture = j;
break;
}
}
@@ -896,7 +906,8 @@ parse_instruction(
report_error( ctx, "Expected a label" );
return FALSE;
}
- inst.InstructionExtLabel.Label = target;
+ inst.Instruction.Label = 1;
+ inst.Label.Label = target;
}
advance = tgsi_build_full_instruction(
@@ -920,7 +931,9 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
"PSIZE",
"GENERIC",
"NORMAL",
- "FACE"
+ "FACE",
+ "EDGEFLAG",
+ "PRIM_ID"
};
static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
@@ -934,8 +947,8 @@ static boolean parse_declaration( struct translate_ctx *ctx )
{
struct tgsi_full_declaration decl;
uint file;
- int first;
- int last;
+ struct parsed_dcl_bracket brackets[2];
+ int num_brackets;
uint writemask;
const char *cur;
uint advance;
@@ -947,7 +960,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
report_error( ctx, "Syntax error" );
return FALSE;
}
- if (!parse_register_dcl( ctx, &file, &first, &last ))
+ if (!parse_register_dcl( ctx, &file, brackets, &num_brackets))
return FALSE;
if (!parse_opt_writemask( ctx, &writemask ))
return FALSE;
@@ -955,8 +968,8 @@ static boolean parse_declaration( struct translate_ctx *ctx )
decl = tgsi_default_full_declaration();
decl.Declaration.File = file;
decl.Declaration.UsageMask = writemask;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Range.First = brackets[0].first;
+ decl.Range.Last = brackets[0].last;
cur = ctx->cur;
eat_opt_white( &cur );
@@ -987,13 +1000,13 @@ static boolean parse_declaration( struct translate_ctx *ctx )
}
cur2++;
- decl.Semantic.SemanticIndex = index;
+ decl.Semantic.Index = index;
cur = cur2;
}
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = i;
+ decl.Semantic.Name = i;
ctx->cur = cur;
break;
@@ -1099,6 +1112,110 @@ static boolean parse_immediate( struct translate_ctx *ctx )
return TRUE;
}
+static const char *property_names[] =
+{
+ "GS_INPUT_PRIMITIVE",
+ "GS_OUTPUT_PRIMITIVE",
+ "GS_MAX_OUTPUT_VERTICES"
+};
+
+static const char *primitive_names[] =
+{
+ "POINTS",
+ "LINES",
+ "LINE_LOOP",
+ "LINE_STRIP",
+ "TRIANGLES",
+ "TRIANGLE_STRIP",
+ "TRIANGLE_FAN",
+ "QUADS",
+ "QUAD_STRIP",
+ "POLYGON"
+};
+
+static boolean
+parse_primitive( const char **pcur, uint *primitive )
+{
+ uint i;
+
+ for (i = 0; i < PIPE_PRIM_MAX; i++) {
+ const char *cur = *pcur;
+
+ if (str_match_no_case( &cur, primitive_names[i])) {
+ *primitive = i;
+ *pcur = cur;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+static boolean parse_property( struct translate_ctx *ctx )
+{
+ struct tgsi_full_property prop;
+ uint property_name;
+ uint values[8];
+ uint advance;
+ char id[64];
+
+ if (!eat_white( &ctx->cur )) {
+ report_error( ctx, "Syntax error" );
+ return FALSE;
+ }
+ if (!parse_identifier( &ctx->cur, id )) {
+ report_error( ctx, "Syntax error" );
+ return FALSE;
+ }
+ for (property_name = 0; property_name < TGSI_PROPERTY_COUNT;
+ ++property_name) {
+ if (streq_nocase_uprcase(property_names[property_name], id)) {
+ break;
+ }
+ }
+ if (property_name >= TGSI_PROPERTY_COUNT) {
+ debug_printf( "\nError: Unknown property : '%s'", id );
+ return FALSE;
+ }
+
+ eat_opt_white( &ctx->cur );
+ switch(property_name) {
+ case TGSI_PROPERTY_GS_INPUT_PRIM:
+ case TGSI_PROPERTY_GS_OUTPUT_PRIM:
+ if (!parse_primitive(&ctx->cur, &values[0] )) {
+ report_error( ctx, "Unknown primitive name as property!" );
+ return FALSE;
+ }
+ if (property_name == TGSI_PROPERTY_GS_INPUT_PRIM &&
+ ctx->processor == TGSI_PROCESSOR_GEOMETRY) {
+ ctx->implied_array_size = u_vertices_per_prim(values[0]);
+ }
+ break;
+ default:
+ if (!parse_uint(&ctx->cur, &values[0] )) {
+ report_error( ctx, "Expected unsigned integer as property!" );
+ return FALSE;
+ }
+ }
+
+ prop = tgsi_default_full_property();
+ prop.Property.PropertyName = property_name;
+ prop.Property.NrTokens += 1;
+ prop.u[0].Data = values[0];
+
+ advance = tgsi_build_full_property(
+ &prop,
+ ctx->tokens_cur,
+ ctx->header,
+ (uint) (ctx->tokens_end - ctx->tokens_cur) );
+ if (advance == 0)
+ return FALSE;
+ ctx->tokens_cur += advance;
+
+ return TRUE;
+}
+
+
static boolean translate( struct translate_ctx *ctx )
{
eat_opt_white( &ctx->cur );
@@ -1107,7 +1224,6 @@ static boolean translate( struct translate_ctx *ctx )
while (*ctx->cur != '\0') {
uint label_val = 0;
-
if (!eat_white( &ctx->cur )) {
report_error( ctx, "Syntax error" );
return FALSE;
@@ -1115,7 +1231,6 @@ static boolean translate( struct translate_ctx *ctx )
if (*ctx->cur == '\0')
break;
-
if (parse_label( ctx, &label_val )) {
if (!parse_instruction( ctx, TRUE ))
return FALSE;
@@ -1128,6 +1243,10 @@ static boolean translate( struct translate_ctx *ctx )
if (!parse_immediate( ctx ))
return FALSE;
}
+ else if (str_match_no_case( &ctx->cur, "PROPERTY" )) {
+ if (!parse_property( ctx ))
+ return FALSE;
+ }
else if (!parse_instruction( ctx, FALSE )) {
return FALSE;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c
index bc9c18fd4a..ae875f29ab 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c
@@ -79,6 +79,19 @@ emit_immediate(struct tgsi_transform_context *ctx,
}
+static void
+emit_property(struct tgsi_transform_context *ctx,
+ const struct tgsi_full_property *prop)
+{
+ uint ti = ctx->ti;
+
+ ti += tgsi_build_full_property(prop,
+ ctx->tokens_out + ti,
+ ctx->header,
+ ctx->max_tokens_out - ti);
+ ctx->ti = ti;
+}
+
/**
* Apply user-defined transformations to the input shader to produce
@@ -110,6 +123,7 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
ctx->emit_instruction = emit_instruction;
ctx->emit_declaration = emit_declaration;
ctx->emit_immediate = emit_immediate;
+ ctx->emit_property = emit_property;
ctx->tokens_out = tokens_out;
ctx->max_tokens_out = max_tokens_out;
@@ -130,15 +144,13 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
/**
** Setup output shader
**/
- *(struct tgsi_version *) &tokens_out[0] = tgsi_build_version();
-
- ctx->header = (struct tgsi_header *) (tokens_out + 1);
+ ctx->header = (struct tgsi_header *)tokens_out;
*ctx->header = tgsi_build_header();
- processor = (struct tgsi_processor *) (tokens_out + 2);
+ processor = (struct tgsi_processor *) (tokens_out + 1);
*processor = tgsi_build_processor( procType, ctx->header );
- ctx->ti = 3;
+ ctx->ti = 2;
/**
@@ -184,6 +196,17 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
ctx->emit_immediate(ctx, fullimm);
}
break;
+ case TGSI_TOKEN_TYPE_PROPERTY:
+ {
+ struct tgsi_full_property *fullprop
+ = &parse.FullToken.FullProperty;
+
+ if (ctx->transform_property)
+ ctx->transform_property(ctx, fullprop);
+ else
+ ctx->emit_property(ctx, fullprop);
+ }
+ break;
default:
assert( 0 );
@@ -215,7 +238,7 @@ tgsi_transform_foo( struct tgsi_token *tokens_out,
uint max_tokens_out )
{
const char *text =
- "FRAG1.1\n"
+ "FRAG\n"
"DCL IN[0], COLOR, CONSTANT\n"
"DCL OUT[0], COLOR\n"
" 0: MOV OUT[0], IN[0]\n"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.h b/src/gallium/auxiliary/tgsi/tgsi_transform.h
index a121adbaef..818478e277 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.h
@@ -53,6 +53,8 @@ struct tgsi_transform_context
void (*transform_immediate)(struct tgsi_transform_context *ctx,
struct tgsi_full_immediate *imm);
+ void (*transform_property)(struct tgsi_transform_context *ctx,
+ struct tgsi_full_property *prop);
/**
* Called at end of input program to allow caller to append extra
@@ -73,6 +75,8 @@ struct tgsi_transform_context
const struct tgsi_full_declaration *decl);
void (*emit_immediate)(struct tgsi_transform_context *ctx,
const struct tgsi_full_immediate *imm);
+ void (*emit_property)(struct tgsi_transform_context *ctx,
+ const struct tgsi_full_property *prop);
struct tgsi_header *header;
uint max_tokens_out;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 654426a903..e64e2b731d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -29,6 +29,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "tgsi/tgsi_ureg.h"
+#include "tgsi/tgsi_build.h"
#include "tgsi/tgsi_info.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_sanity.h"
@@ -36,7 +37,6 @@
#include "util/u_math.h"
union tgsi_any_token {
- struct tgsi_version version;
struct tgsi_header header;
struct tgsi_processor processor;
struct tgsi_token token;
@@ -46,18 +46,12 @@ union tgsi_any_token {
struct tgsi_immediate imm;
union tgsi_immediate_data imm_data;
struct tgsi_instruction insn;
- struct tgsi_instruction_ext_nv insn_ext_nv;
- struct tgsi_instruction_ext_label insn_ext_label;
- struct tgsi_instruction_ext_texture insn_ext_texture;
- struct tgsi_instruction_ext_predicate insn_ext_predicate;
+ struct tgsi_instruction_predicate insn_predicate;
+ struct tgsi_instruction_label insn_label;
+ struct tgsi_instruction_texture insn_texture;
struct tgsi_src_register src;
- struct tgsi_src_register_ext_swz src_ext_swz;
- struct tgsi_src_register_ext_mod src_ext_mod;
struct tgsi_dimension dim;
struct tgsi_dst_register dst;
- struct tgsi_dst_register_ext_concode dst_ext_code;
- struct tgsi_dst_register_ext_modulate dst_ext_mod;
- struct tgsi_dst_register_ext_predicate dst_ext_pred;
unsigned value;
};
@@ -75,6 +69,8 @@ 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
#define DOMAIN_DECL 0
#define DOMAIN_INSN 1
@@ -94,14 +90,24 @@ struct ureg_program
unsigned vs_inputs[UREG_MAX_INPUT/32];
struct {
+ unsigned index;
+ } gs_input[UREG_MAX_INPUT];
+ unsigned nr_gs_inputs;
+
+ struct {
unsigned semantic_name;
unsigned semantic_index;
} output[UREG_MAX_OUTPUT];
unsigned nr_outputs;
struct {
- float v[4];
+ union {
+ float f[4];
+ unsigned u[4];
+ int i[4];
+ } value;
unsigned nr;
+ unsigned type;
} immediate[UREG_MAX_IMMEDIATE];
unsigned nr_immediates;
@@ -118,6 +124,8 @@ struct ureg_program
unsigned nr_constant_ranges;
unsigned nr_addrs;
+ unsigned nr_preds;
+ unsigned nr_loops;
unsigned nr_instructions;
struct ureg_tokens domain[2];
@@ -141,8 +149,9 @@ static void tokens_expand( struct ureg_tokens *tokens,
{
unsigned old_size = tokens->size * sizeof(unsigned);
- if (tokens->tokens == error_tokens)
- goto fail;
+ if (tokens->tokens == error_tokens) {
+ return;
+ }
while (tokens->count + count > tokens->size) {
tokens->size = (1 << ++tokens->order);
@@ -151,13 +160,9 @@ static void tokens_expand( struct ureg_tokens *tokens,
tokens->tokens = REALLOC(tokens->tokens,
old_size,
tokens->size * sizeof(unsigned));
- if (tokens->tokens == NULL)
- goto fail;
-
- return;
-
-fail:
- tokens_error(tokens);
+ if (tokens->tokens == NULL) {
+ tokens_error(tokens);
+ }
}
static void set_bad( struct ureg_program *ureg )
@@ -207,9 +212,13 @@ ureg_dst_register( unsigned file,
dst.IndirectIndex = 0;
dst.IndirectSwizzle = 0;
dst.Saturate = 0;
+ dst.Predicate = 0;
+ dst.PredNegate = 0;
+ dst.PredSwizzleX = TGSI_SWIZZLE_X;
+ dst.PredSwizzleY = TGSI_SWIZZLE_Y;
+ dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
+ dst.PredSwizzleW = TGSI_SWIZZLE_W;
dst.Index = index;
- dst.Pad1 = 0;
- dst.Pad2 = 0;
return dst;
}
@@ -279,6 +288,22 @@ ureg_DECL_vs_input( struct ureg_program *ureg,
}
+struct ureg_src
+ureg_DECL_gs_input(struct ureg_program *ureg,
+ unsigned index)
+{
+ if (ureg->nr_gs_inputs < UREG_MAX_INPUT) {
+ ureg->gs_input[ureg->nr_gs_inputs].index = index;
+ ureg->nr_gs_inputs++;
+ } else {
+ set_bad(ureg);
+ }
+
+ /* XXX: Add suport for true 2D input registers. */
+ return ureg_src_register(TGSI_FILE_INPUT, index);
+}
+
+
struct ureg_dst
ureg_DECL_output( struct ureg_program *ureg,
unsigned name,
@@ -350,6 +375,7 @@ struct ureg_src ureg_DECL_constant(struct ureg_program *ureg,
i = ureg->nr_constant_ranges++;
ureg->constant_range[i].first = index;
ureg->constant_range[i].last = index;
+ goto out;
}
/* Collapse all ranges down to one:
@@ -417,6 +443,32 @@ 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
+ureg_DECL_predicate(struct ureg_program *ureg)
+{
+ if (ureg->nr_preds < UREG_MAX_PRED) {
+ return ureg_dst_register(TGSI_FILE_PREDICATE, ureg->nr_preds++);
+ }
+
+ assert(0);
+ return ureg_dst_register(TGSI_FILE_PREDICATE, 0);
+}
+
/* Allocate a new sampler.
*/
struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
@@ -439,22 +491,22 @@ struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
}
-
-
-static int match_or_expand_immediate( const float *v,
- unsigned nr,
- float *v2,
- unsigned *nr2,
- unsigned *swizzle )
+static int
+match_or_expand_immediate( const unsigned *v,
+ unsigned nr,
+ unsigned *v2,
+ unsigned *pnr2,
+ unsigned *swizzle )
{
+ unsigned nr2 = *pnr2;
unsigned i, j;
-
+
*swizzle = 0;
for (i = 0; i < nr; i++) {
boolean found = FALSE;
- for (j = 0; j < *nr2 && !found; j++) {
+ for (j = 0; j < nr2 && !found; j++) {
if (v[i] == v2[j]) {
*swizzle |= j << (i * 2);
found = TRUE;
@@ -462,24 +514,28 @@ static int match_or_expand_immediate( const float *v,
}
if (!found) {
- if (*nr2 >= 4)
+ if (nr2 >= 4) {
return FALSE;
+ }
- v2[*nr2] = v[i];
- *swizzle |= *nr2 << (i * 2);
- (*nr2)++;
+ v2[nr2] = v[i];
+ *swizzle |= nr2 << (i * 2);
+ nr2++;
}
}
+ /* Actually expand immediate only when fully succeeded.
+ */
+ *pnr2 = nr2;
return TRUE;
}
-
-
-struct ureg_src ureg_DECL_immediate( struct ureg_program *ureg,
- const float *v,
- unsigned nr )
+static struct ureg_src
+decl_immediate( struct ureg_program *ureg,
+ const unsigned *v,
+ unsigned nr,
+ unsigned type )
{
unsigned i, j;
unsigned swizzle;
@@ -489,38 +545,82 @@ struct ureg_src ureg_DECL_immediate( struct ureg_program *ureg,
*/
for (i = 0; i < ureg->nr_immediates; i++) {
- if (match_or_expand_immediate( v,
- nr,
- ureg->immediate[i].v,
- &ureg->immediate[i].nr,
- &swizzle ))
+ if (ureg->immediate[i].type != type) {
+ continue;
+ }
+ if (match_or_expand_immediate(v,
+ nr,
+ ureg->immediate[i].value.u,
+ &ureg->immediate[i].nr,
+ &swizzle)) {
goto out;
+ }
}
if (ureg->nr_immediates < UREG_MAX_IMMEDIATE) {
i = ureg->nr_immediates++;
- if (match_or_expand_immediate( v,
- nr,
- ureg->immediate[i].v,
- &ureg->immediate[i].nr,
- &swizzle ))
+ ureg->immediate[i].type = type;
+ if (match_or_expand_immediate(v,
+ nr,
+ ureg->immediate[i].value.u,
+ &ureg->immediate[i].nr,
+ &swizzle)) {
goto out;
+ }
}
- set_bad( ureg );
+ set_bad(ureg);
out:
/* Make sure that all referenced elements are from this immediate.
* Has the effect of making size-one immediates into scalars.
*/
- for (j = nr; j < 4; j++)
+ for (j = nr; j < 4; j++) {
swizzle |= (swizzle & 0x3) << (j * 2);
+ }
+
+ return ureg_swizzle(ureg_src_register(TGSI_FILE_IMMEDIATE, i),
+ (swizzle >> 0) & 0x3,
+ (swizzle >> 2) & 0x3,
+ (swizzle >> 4) & 0x3,
+ (swizzle >> 6) & 0x3);
+}
+
+
+struct ureg_src
+ureg_DECL_immediate( struct ureg_program *ureg,
+ const float *v,
+ unsigned nr )
+{
+ union {
+ float f[4];
+ unsigned u[4];
+ } fu;
+ unsigned int i;
+
+ for (i = 0; i < nr; i++) {
+ fu.f[i] = v[i];
+ }
+
+ return decl_immediate(ureg, fu.u, nr, TGSI_IMM_FLOAT32);
+}
- return ureg_swizzle( ureg_src_register( TGSI_FILE_IMMEDIATE, i ),
- (swizzle >> 0) & 0x3,
- (swizzle >> 2) & 0x3,
- (swizzle >> 4) & 0x3,
- (swizzle >> 6) & 0x3);
+
+struct ureg_src
+ureg_DECL_immediate_uint( struct ureg_program *ureg,
+ const unsigned *v,
+ unsigned nr )
+{
+ return decl_immediate(ureg, v, nr, TGSI_IMM_UINT32);
+}
+
+
+struct ureg_src
+ureg_DECL_immediate_int( struct ureg_program *ureg,
+ const int *v,
+ unsigned nr )
+{
+ return decl_immediate(ureg, (const unsigned *)v, nr, TGSI_IMM_INT32);
}
@@ -528,9 +628,7 @@ void
ureg_emit_src( struct ureg_program *ureg,
struct ureg_src src )
{
- unsigned size = (1 +
- (src.Absolute ? 1 : 0) +
- (src.Indirect ? 1 : 0));
+ unsigned size = 1 + (src.Indirect ? 1 : 0);
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
unsigned n = 0;
@@ -547,17 +645,8 @@ ureg_emit_src( struct ureg_program *ureg,
out[n].src.SwizzleW = src.SwizzleW;
out[n].src.Index = src.Index;
out[n].src.Negate = src.Negate;
+ out[0].src.Absolute = src.Absolute;
n++;
-
- if (src.Absolute) {
- out[0].src.Extended = 1;
- out[0].src.Negate = 0;
- out[n].value = 0;
- out[n].src_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
- out[n].src_ext_mod.Absolute = 1;
- out[n].src_ext_mod.Negate = src.Negate;
- n++;
- }
if (src.Indirect) {
out[0].src.Indirect = 1;
@@ -628,37 +717,54 @@ static void validate( unsigned opcode,
#endif
}
-unsigned
+struct ureg_emit_insn_result
ureg_emit_insn(struct ureg_program *ureg,
unsigned opcode,
boolean saturate,
+ boolean predicate,
+ boolean pred_negate,
+ unsigned pred_swizzle_x,
+ unsigned pred_swizzle_y,
+ unsigned pred_swizzle_z,
+ unsigned pred_swizzle_w,
unsigned num_dst,
unsigned num_src )
{
union tgsi_any_token *out;
+ uint count = predicate ? 2 : 1;
+ struct ureg_emit_insn_result result;
validate( opcode, num_dst, num_src );
- out = get_tokens( ureg, DOMAIN_INSN, 1 );
- out[0].value = 0;
- out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
- out[0].insn.NrTokens = 0;
+ out = get_tokens( ureg, DOMAIN_INSN, count );
+ out[0].insn = tgsi_default_instruction();
out[0].insn.Opcode = opcode;
out[0].insn.Saturate = saturate;
out[0].insn.NumDstRegs = num_dst;
out[0].insn.NumSrcRegs = num_src;
- out[0].insn.Padding = 0;
- out[0].insn.Extended = 0;
-
+
+ result.insn_token = ureg->domain[DOMAIN_INSN].count - count;
+ result.extended_token = result.insn_token;
+
+ if (predicate) {
+ out[0].insn.Predicate = 1;
+ out[1].insn_predicate = tgsi_default_instruction_predicate();
+ out[1].insn_predicate.Negate = pred_negate;
+ out[1].insn_predicate.SwizzleX = pred_swizzle_x;
+ out[1].insn_predicate.SwizzleY = pred_swizzle_y;
+ out[1].insn_predicate.SwizzleZ = pred_swizzle_z;
+ out[1].insn_predicate.SwizzleW = pred_swizzle_w;
+ }
+
ureg->nr_instructions++;
-
- return ureg->domain[DOMAIN_INSN].count - 1;
+
+ return result;
}
void
ureg_emit_label(struct ureg_program *ureg,
- unsigned insn_token,
+ unsigned extended_token,
unsigned *label_token )
{
union tgsi_any_token *out, *insn;
@@ -667,13 +773,11 @@ ureg_emit_label(struct ureg_program *ureg,
return;
out = get_tokens( ureg, DOMAIN_INSN, 1 );
- insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
+ out[0].value = 0;
- insn->insn.Extended = 1;
+ insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
+ insn->insn.Label = 1;
- out[0].value = 0;
- out[0].insn_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
-
*label_token = ureg->domain[DOMAIN_INSN].count - 1;
}
@@ -696,26 +800,24 @@ ureg_fixup_label(struct ureg_program *ureg,
{
union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, label_token );
- assert(out->insn_ext_label.Type == TGSI_INSTRUCTION_EXT_TYPE_LABEL);
- out->insn_ext_label.Label = instruction_number;
+ out->insn_label.Label = instruction_number;
}
void
ureg_emit_texture(struct ureg_program *ureg,
- unsigned insn_token,
+ unsigned extended_token,
unsigned target )
{
union tgsi_any_token *out, *insn;
out = get_tokens( ureg, DOMAIN_INSN, 1 );
- insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
+ insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
- insn->insn.Extended = 1;
+ insn->insn.Texture = 1;
out[0].value = 0;
- out[0].insn_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
- out[0].insn_ext_texture.Texture = target;
+ out[0].insn_texture.Texture = target;
}
@@ -738,12 +840,34 @@ ureg_insn(struct ureg_program *ureg,
const struct ureg_src *src,
unsigned nr_src )
{
- unsigned insn, i;
+ struct ureg_emit_insn_result insn;
+ unsigned i;
boolean saturate;
+ boolean predicate;
+ boolean negate = FALSE;
+ unsigned swizzle[4] = { 0 };
saturate = nr_dst ? dst[0].Saturate : FALSE;
+ predicate = nr_dst ? dst[0].Predicate : FALSE;
+ if (predicate) {
+ negate = dst[0].PredNegate;
+ swizzle[0] = dst[0].PredSwizzleX;
+ swizzle[1] = dst[0].PredSwizzleY;
+ swizzle[2] = dst[0].PredSwizzleZ;
+ swizzle[3] = dst[0].PredSwizzleW;
+ }
- insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+ insn = ureg_emit_insn(ureg,
+ opcode,
+ saturate,
+ predicate,
+ negate,
+ swizzle[0],
+ swizzle[1],
+ swizzle[2],
+ swizzle[3],
+ nr_dst,
+ nr_src);
for (i = 0; i < nr_dst; i++)
ureg_emit_dst( ureg, dst[i] );
@@ -751,7 +875,7 @@ ureg_insn(struct ureg_program *ureg,
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
- ureg_fixup_insn_size( ureg, insn );
+ ureg_fixup_insn_size( ureg, insn.insn_token );
}
void
@@ -763,14 +887,36 @@ ureg_tex_insn(struct ureg_program *ureg,
const struct ureg_src *src,
unsigned nr_src )
{
- unsigned insn, i;
+ struct ureg_emit_insn_result insn;
+ unsigned i;
boolean saturate;
+ boolean predicate;
+ boolean negate = FALSE;
+ unsigned swizzle[4] = { 0 };
saturate = nr_dst ? dst[0].Saturate : FALSE;
+ predicate = nr_dst ? dst[0].Predicate : FALSE;
+ if (predicate) {
+ negate = dst[0].PredNegate;
+ swizzle[0] = dst[0].PredSwizzleX;
+ swizzle[1] = dst[0].PredSwizzleY;
+ swizzle[2] = dst[0].PredSwizzleZ;
+ swizzle[3] = dst[0].PredSwizzleW;
+ }
- insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+ insn = ureg_emit_insn(ureg,
+ opcode,
+ saturate,
+ predicate,
+ negate,
+ swizzle[0],
+ swizzle[1],
+ swizzle[2],
+ swizzle[3],
+ nr_dst,
+ nr_src);
- ureg_emit_texture( ureg, insn, target ); \
+ ureg_emit_texture( ureg, insn.extended_token, target );
for (i = 0; i < nr_dst; i++)
ureg_emit_dst( ureg, dst[i] );
@@ -778,7 +924,7 @@ ureg_tex_insn(struct ureg_program *ureg,
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
- ureg_fixup_insn_size( ureg, insn );
+ ureg_fixup_insn_size( ureg, insn.insn_token );
}
@@ -789,16 +935,27 @@ ureg_label_insn(struct ureg_program *ureg,
unsigned nr_src,
unsigned *label_token )
{
- unsigned insn, i;
+ struct ureg_emit_insn_result insn;
+ unsigned i;
- insn = ureg_emit_insn( ureg, opcode, FALSE, 0, nr_src );
+ insn = ureg_emit_insn(ureg,
+ opcode,
+ FALSE,
+ FALSE,
+ FALSE,
+ TGSI_SWIZZLE_X,
+ TGSI_SWIZZLE_Y,
+ TGSI_SWIZZLE_Z,
+ TGSI_SWIZZLE_W,
+ 0,
+ nr_src);
- ureg_emit_label( ureg, insn, label_token ); \
+ ureg_emit_label( ureg, insn.extended_token, label_token );
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
- ureg_fixup_insn_size( ureg, insn );
+ ureg_fixup_insn_size( ureg, insn.insn_token );
}
@@ -825,8 +982,8 @@ static void emit_decl( struct ureg_program *ureg,
out[1].decl_range.Last = index;
out[2].value = 0;
- out[2].decl_semantic.SemanticName = semantic_name;
- out[2].decl_semantic.SemanticIndex = semantic_index;
+ out[2].decl_semantic.Name = semantic_name;
+ out[2].decl_semantic.Index = semantic_index;
}
@@ -851,22 +1008,23 @@ static void emit_decl_range( struct ureg_program *ureg,
out[1].decl_range.Last = first + count - 1;
}
-static void emit_immediate( struct ureg_program *ureg,
- const float *v )
+static void
+emit_immediate( struct ureg_program *ureg,
+ const unsigned *v,
+ unsigned type )
{
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 5 );
out[0].value = 0;
out[0].imm.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
out[0].imm.NrTokens = 5;
- out[0].imm.DataType = TGSI_IMM_FLOAT32;
+ out[0].imm.DataType = type;
out[0].imm.Padding = 0;
- out[0].imm.Extended = 0;
- out[1].imm_data.Float = v[0];
- out[2].imm_data.Float = v[1];
- out[3].imm_data.Float = v[2];
- out[4].imm_data.Float = v[3];
+ out[1].imm_data.Uint = v[0];
+ out[2].imm_data.Uint = v[1];
+ out[3].imm_data.Uint = v[2];
+ out[4].imm_data.Uint = v[3];
}
@@ -882,8 +1040,7 @@ static void emit_decls( struct ureg_program *ureg )
emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 );
}
}
- }
- else {
+ } else if (ureg->processor == TGSI_PROCESSOR_FRAGMENT) {
for (i = 0; i < ureg->nr_fs_inputs; i++) {
emit_decl( ureg,
TGSI_FILE_INPUT,
@@ -892,6 +1049,13 @@ static void emit_decls( struct ureg_program *ureg )
ureg->fs_input[i].semantic_index,
ureg->fs_input[i].interp );
}
+ } else {
+ for (i = 0; i < ureg->nr_gs_inputs; i++) {
+ emit_decl_range(ureg,
+ TGSI_FILE_INPUT,
+ ureg->gs_input[i].index,
+ 1);
+ }
}
for (i = 0; i < ureg->nr_outputs; i++) {
@@ -930,9 +1094,24 @@ 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,
+ 0,
+ ureg->nr_preds);
+ }
+
for (i = 0; i < ureg->nr_immediates; i++) {
emit_immediate( ureg,
- ureg->immediate[i].v );
+ ureg->immediate[i].value.u,
+ ureg->immediate[i].type );
}
}
@@ -955,26 +1134,22 @@ static void copy_instructions( struct ureg_program *ureg )
static void
fixup_header_size(struct ureg_program *ureg)
{
- union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 1 );
+ union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 0 );
- out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 3;
+ out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 2;
}
static void
emit_header( struct ureg_program *ureg )
{
- union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 3 );
-
- out[0].version.MajorVersion = 1;
- out[0].version.MinorVersion = 1;
- out[0].version.Padding = 0;
+ union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
- out[1].header.HeaderSize = 2;
- out[1].header.BodySize = 0;
+ out[0].header.HeaderSize = 2;
+ out[0].header.BodySize = 0;
- out[2].processor.Processor = ureg->processor;
- out[2].processor.Padding = 0;
+ out[1].processor.Processor = ureg->processor;
+ out[1].processor.Padding = 0;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index f04f443b9e..6f11273320 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -67,9 +67,13 @@ struct ureg_dst
unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
unsigned Indirect : 1; /* BOOL */
unsigned Saturate : 1; /* BOOL */
+ unsigned Predicate : 1;
+ unsigned PredNegate : 1; /* BOOL */
+ unsigned PredSwizzleX: 2; /* TGSI_SWIZZLE_ */
+ unsigned PredSwizzleY: 2; /* TGSI_SWIZZLE_ */
+ unsigned PredSwizzleZ: 2; /* TGSI_SWIZZLE_ */
+ unsigned PredSwizzleW: 2; /* TGSI_SWIZZLE_ */
int Index : 16; /* SINT */
- unsigned Pad1 : 5;
- unsigned Pad2 : 1; /* BOOL */
int IndirectIndex : 16; /* SINT */
int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */
};
@@ -129,6 +133,10 @@ struct ureg_src
ureg_DECL_vs_input( struct ureg_program *,
unsigned index );
+struct ureg_src
+ureg_DECL_gs_input(struct ureg_program *,
+ unsigned index);
+
struct ureg_dst
ureg_DECL_output( struct ureg_program *,
unsigned semantic_name,
@@ -140,6 +148,16 @@ ureg_DECL_immediate( struct ureg_program *,
unsigned nr );
struct ureg_src
+ureg_DECL_immediate_uint( struct ureg_program *,
+ const unsigned *v,
+ unsigned nr );
+
+struct ureg_src
+ureg_DECL_immediate_int( struct ureg_program *,
+ const int *v,
+ unsigned nr );
+
+struct ureg_src
ureg_DECL_constant( struct ureg_program *,
unsigned index );
@@ -153,6 +171,12 @@ 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 *);
+
/* Supply an index to the sampler declaration as this is the hook to
* the external pipe_sampler state. Users of this function probably
* don't want just any sampler, but a specific one which they've set
@@ -207,6 +231,90 @@ ureg_imm1f( struct ureg_program *ureg,
return ureg_DECL_immediate( ureg, v, 1 );
}
+static INLINE struct ureg_src
+ureg_imm4u( struct ureg_program *ureg,
+ unsigned a, unsigned b,
+ unsigned c, unsigned d)
+{
+ unsigned v[4];
+ v[0] = a;
+ v[1] = b;
+ v[2] = c;
+ v[3] = d;
+ return ureg_DECL_immediate_uint( ureg, v, 4 );
+}
+
+static INLINE struct ureg_src
+ureg_imm3u( struct ureg_program *ureg,
+ unsigned a, unsigned b,
+ unsigned c)
+{
+ unsigned v[3];
+ v[0] = a;
+ v[1] = b;
+ v[2] = c;
+ return ureg_DECL_immediate_uint( ureg, v, 3 );
+}
+
+static INLINE struct ureg_src
+ureg_imm2u( struct ureg_program *ureg,
+ unsigned a, unsigned b)
+{
+ unsigned v[2];
+ v[0] = a;
+ v[1] = b;
+ return ureg_DECL_immediate_uint( ureg, v, 2 );
+}
+
+static INLINE struct ureg_src
+ureg_imm1u( struct ureg_program *ureg,
+ unsigned a)
+{
+ return ureg_DECL_immediate_uint( ureg, &a, 1 );
+}
+
+static INLINE struct ureg_src
+ureg_imm4i( struct ureg_program *ureg,
+ int a, int b,
+ int c, int d)
+{
+ int v[4];
+ v[0] = a;
+ v[1] = b;
+ v[2] = c;
+ v[3] = d;
+ return ureg_DECL_immediate_int( ureg, v, 4 );
+}
+
+static INLINE struct ureg_src
+ureg_imm3i( struct ureg_program *ureg,
+ int a, int b,
+ int c)
+{
+ int v[3];
+ v[0] = a;
+ v[1] = b;
+ v[2] = c;
+ return ureg_DECL_immediate_int( ureg, v, 3 );
+}
+
+static INLINE struct ureg_src
+ureg_imm2i( struct ureg_program *ureg,
+ int a, int b)
+{
+ int v[2];
+ v[0] = a;
+ v[1] = b;
+ return ureg_DECL_immediate_int( ureg, v, 2 );
+}
+
+static INLINE struct ureg_src
+ureg_imm1i( struct ureg_program *ureg,
+ int a)
+{
+ return ureg_DECL_immediate_int( ureg, &a, 1 );
+}
+
/***********************************************************************
* Functions for patching up labels
*/
@@ -266,10 +374,21 @@ ureg_label_insn(struct ureg_program *ureg,
* Internal instruction helpers, don't call these directly:
*/
-unsigned
+struct ureg_emit_insn_result {
+ unsigned insn_token; /*< Used to fixup insn size. */
+ unsigned extended_token; /*< Used to set the Extended bit, usually the same as insn_token. */
+};
+
+struct ureg_emit_insn_result
ureg_emit_insn(struct ureg_program *ureg,
unsigned opcode,
boolean saturate,
+ boolean predicate,
+ boolean pred_negate,
+ unsigned pred_swizzle_x,
+ unsigned pred_swizzle_y,
+ unsigned pred_swizzle_z,
+ unsigned pred_swizzle_w,
unsigned num_dst,
unsigned num_src );
@@ -300,7 +419,17 @@ ureg_fixup_insn_size(struct ureg_program *ureg,
static INLINE void ureg_##op( struct ureg_program *ureg ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
+ unsigned insn = ureg_emit_insn(ureg, \
+ opcode, \
+ FALSE, \
+ FALSE, \
+ FALSE, \
+ TGSI_SWIZZLE_X, \
+ TGSI_SWIZZLE_Y, \
+ TGSI_SWIZZLE_Z, \
+ TGSI_SWIZZLE_W, \
+ 0, \
+ 0).insn_token; \
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -309,7 +438,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
+ unsigned insn = ureg_emit_insn(ureg, \
+ opcode, \
+ FALSE, \
+ FALSE, \
+ FALSE, \
+ TGSI_SWIZZLE_X, \
+ TGSI_SWIZZLE_Y, \
+ TGSI_SWIZZLE_Z, \
+ TGSI_SWIZZLE_W, \
+ 0, \
+ 1).insn_token; \
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -319,9 +458,20 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
unsigned *label_token ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
- ureg_emit_label( ureg, insn, label_token ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ FALSE, \
+ FALSE, \
+ FALSE, \
+ TGSI_SWIZZLE_X, \
+ TGSI_SWIZZLE_Y, \
+ TGSI_SWIZZLE_Z, \
+ TGSI_SWIZZLE_W, \
+ 0, \
+ 0); \
+ ureg_emit_label( ureg, insn.extended_token, label_token ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
#define OP01_LBL( op ) \
@@ -330,10 +480,21 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
unsigned *label_token ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
- ureg_emit_label( ureg, insn, label_token ); \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ FALSE, \
+ FALSE, \
+ FALSE, \
+ TGSI_SWIZZLE_X, \
+ TGSI_SWIZZLE_Y, \
+ TGSI_SWIZZLE_Z, \
+ TGSI_SWIZZLE_W, \
+ 0, \
+ 1); \
+ ureg_emit_label( ureg, insn.extended_token, label_token ); \
ureg_emit_src( ureg, src ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
#define OP10( op ) \
@@ -341,7 +502,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_dst dst ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 0 ); \
+ unsigned insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 0).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -353,7 +524,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 1 ); \
+ unsigned insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 1).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
@@ -366,7 +547,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src1 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 ); \
+ unsigned insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 2).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -381,12 +572,23 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src1 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 ); \
- ureg_emit_texture( ureg, insn, target ); \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 2); \
+ ureg_emit_texture( ureg, insn.extended_token, target ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
#define OP13( op ) \
@@ -397,7 +599,17 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src2 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 3 ); \
+ unsigned insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 3).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -415,14 +627,25 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src3 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 4 ); \
- ureg_emit_texture( ureg, insn, target ); \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 4); \
+ ureg_emit_texture( ureg, insn.extended_token, target ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
ureg_emit_src( ureg, src2 ); \
ureg_emit_src( ureg, src3 ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
@@ -497,6 +720,24 @@ ureg_saturate( struct ureg_dst reg )
return reg;
}
+static INLINE struct ureg_dst
+ureg_predicate(struct ureg_dst reg,
+ boolean negate,
+ unsigned swizzle_x,
+ unsigned swizzle_y,
+ unsigned swizzle_z,
+ unsigned swizzle_w)
+{
+ assert(reg.File != TGSI_FILE_NULL);
+ reg.Predicate = 1;
+ reg.PredNegate = negate;
+ reg.PredSwizzleX = swizzle_x;
+ reg.PredSwizzleY = swizzle_y;
+ reg.PredSwizzleZ = swizzle_z;
+ reg.PredSwizzleW = swizzle_w;
+ return reg;
+}
+
static INLINE struct ureg_dst
ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr )
{
@@ -530,9 +771,13 @@ ureg_dst( struct ureg_src src )
dst.IndirectIndex = src.IndirectIndex;
dst.IndirectSwizzle = src.IndirectSwizzle;
dst.Saturate = 0;
+ dst.Predicate = 0;
+ dst.PredNegate = 0;
+ dst.PredSwizzleX = TGSI_SWIZZLE_X;
+ dst.PredSwizzleY = TGSI_SWIZZLE_Y;
+ dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
+ dst.PredSwizzleW = TGSI_SWIZZLE_W;
dst.Index = src.Index;
- dst.Pad1 = 0;
- dst.Pad2 = 0;
return dst;
}
@@ -571,9 +816,13 @@ ureg_dst_undef( void )
dst.IndirectIndex = 0;
dst.IndirectSwizzle = 0;
dst.Saturate = 0;
+ dst.Predicate = 0;
+ dst.PredNegate = 0;
+ dst.PredSwizzleX = TGSI_SWIZZLE_X;
+ dst.PredSwizzleY = TGSI_SWIZZLE_Y;
+ dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
+ dst.PredSwizzleW = TGSI_SWIZZLE_W;
dst.Index = 0;
- dst.Pad1 = 0;
- dst.Pad2 = 0;
return dst;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c
index 71f8a6ca40..f4ca9e21ed 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_util.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_util.c
@@ -69,59 +69,15 @@ tgsi_util_get_src_register_swizzle(
return 0;
}
-unsigned
-tgsi_util_get_src_register_extswizzle(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->ExtSwizzleX;
- case 1:
- return reg->ExtSwizzleY;
- case 2:
- return reg->ExtSwizzleZ;
- case 3:
- return reg->ExtSwizzleW;
- default:
- assert( 0 );
- }
- return 0;
-}
unsigned
-tgsi_util_get_full_src_register_extswizzle(
+tgsi_util_get_full_src_register_swizzle(
const struct tgsi_full_src_register *reg,
unsigned component )
{
- unsigned swizzle;
-
- /*
- * First, calculate the extended swizzle for a given channel. This will give
- * us either a channel index into the simple swizzle or a constant 1 or 0.
- */
- swizzle = tgsi_util_get_src_register_extswizzle(
- &reg->SrcRegisterExtSwz,
+ return tgsi_util_get_src_register_swizzle(
+ &reg->Register,
component );
-
- assert (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
- assert (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
- assert (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
- assert (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
- assert (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
- assert (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
-
- /*
- * Second, calculate the simple swizzle for the unswizzled channel index.
- * Leave the constants intact, they are not affected by the simple swizzle.
- */
- if( swizzle <= TGSI_SWIZZLE_W ) {
- swizzle = tgsi_util_get_src_register_swizzle(
- &reg->SrcRegister,
- swizzle );
- }
-
- return swizzle;
}
void
@@ -148,74 +104,6 @@ tgsi_util_set_src_register_swizzle(
}
}
-void
-tgsi_util_set_src_register_extswizzle(
- struct tgsi_src_register_ext_swz *reg,
- unsigned swizzle,
- unsigned component )
-{
- switch( component ) {
- case 0:
- reg->ExtSwizzleX = swizzle;
- break;
- case 1:
- reg->ExtSwizzleY = swizzle;
- break;
- case 2:
- reg->ExtSwizzleZ = swizzle;
- break;
- case 3:
- reg->ExtSwizzleW = swizzle;
- break;
- default:
- assert( 0 );
- }
-}
-
-unsigned
-tgsi_util_get_src_register_extnegate(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->NegateX;
- case 1:
- return reg->NegateY;
- case 2:
- return reg->NegateZ;
- case 3:
- return reg->NegateW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-void
-tgsi_util_set_src_register_extnegate(
- struct tgsi_src_register_ext_swz *reg,
- unsigned negate,
- unsigned component )
-{
- switch( component ) {
- case 0:
- reg->NegateX = negate;
- break;
- case 1:
- reg->NegateY = negate;
- break;
- case 2:
- reg->NegateZ = negate;
- break;
- case 3:
- reg->NegateW = negate;
- break;
- default:
- assert( 0 );
- }
-}
-
unsigned
tgsi_util_get_full_src_register_sign_mode(
const struct tgsi_full_src_register *reg,
@@ -223,10 +111,10 @@ tgsi_util_get_full_src_register_sign_mode(
{
unsigned sign_mode;
- if( reg->SrcRegisterExtMod.Absolute ) {
+ if( reg->Register.Absolute ) {
/* Consider only the post-abs negation. */
- if( reg->SrcRegisterExtMod.Negate ) {
+ if( reg->Register.Negate ) {
sign_mode = TGSI_UTIL_SIGN_SET;
}
else {
@@ -234,19 +122,7 @@ tgsi_util_get_full_src_register_sign_mode(
}
}
else {
- /* Accumulate the three negations. */
-
- unsigned negate;
-
- negate = reg->SrcRegister.Negate;
- if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
- negate = !negate;
- }
- if( reg->SrcRegisterExtMod.Negate ) {
- negate = !negate;
- }
-
- if( negate ) {
+ if( reg->Register.Negate ) {
sign_mode = TGSI_UTIL_SIGN_TOGGLE;
}
else {
@@ -262,35 +138,26 @@ tgsi_util_set_full_src_register_sign_mode(
struct tgsi_full_src_register *reg,
unsigned sign_mode )
{
- reg->SrcRegisterExtSwz.NegateX = 0;
- reg->SrcRegisterExtSwz.NegateY = 0;
- reg->SrcRegisterExtSwz.NegateZ = 0;
- reg->SrcRegisterExtSwz.NegateW = 0;
-
switch (sign_mode)
{
case TGSI_UTIL_SIGN_CLEAR:
- reg->SrcRegister.Negate = 0;
- reg->SrcRegisterExtMod.Absolute = 1;
- reg->SrcRegisterExtMod.Negate = 0;
+ reg->Register.Negate = 0;
+ reg->Register.Absolute = 1;
break;
case TGSI_UTIL_SIGN_SET:
- reg->SrcRegister.Negate = 0;
- reg->SrcRegisterExtMod.Absolute = 1;
- reg->SrcRegisterExtMod.Negate = 1;
+ reg->Register.Absolute = 1;
+ reg->Register.Negate = 1;
break;
case TGSI_UTIL_SIGN_TOGGLE:
- reg->SrcRegister.Negate = 1;
- reg->SrcRegisterExtMod.Absolute = 0;
- reg->SrcRegisterExtMod.Negate = 0;
+ reg->Register.Negate = 1;
+ reg->Register.Absolute = 0;
break;
case TGSI_UTIL_SIGN_KEEP:
- reg->SrcRegister.Negate = 0;
- reg->SrcRegisterExtMod.Absolute = 0;
- reg->SrcRegisterExtMod.Negate = 0;
+ reg->Register.Negate = 0;
+ reg->Register.Absolute = 0;
break;
default:
diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.h b/src/gallium/auxiliary/tgsi/tgsi_util.h
index 21eb656327..19ee2e7cf2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_util.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_util.h
@@ -33,7 +33,6 @@ extern "C" {
#endif
struct tgsi_src_register;
-struct tgsi_src_register_ext_swz;
struct tgsi_full_src_register;
void *
@@ -45,13 +44,9 @@ tgsi_util_get_src_register_swizzle(
const struct tgsi_src_register *reg,
unsigned component );
-unsigned
-tgsi_util_get_src_register_extswizzle(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component);
unsigned
-tgsi_util_get_full_src_register_extswizzle(
+tgsi_util_get_full_src_register_swizzle(
const struct tgsi_full_src_register *reg,
unsigned component );
@@ -61,23 +56,6 @@ tgsi_util_set_src_register_swizzle(
unsigned swizzle,
unsigned component );
-void
-tgsi_util_set_src_register_extswizzle(
- struct tgsi_src_register_ext_swz *reg,
- unsigned swizzle,
- unsigned component );
-
-unsigned
-tgsi_util_get_src_register_extnegate(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component );
-
-void
-tgsi_util_set_src_register_extnegate(
- struct tgsi_src_register_ext_swz *reg,
- unsigned negate,
- unsigned component );
-
#define TGSI_UTIL_SIGN_CLEAR 0 /* Force positive */
#define TGSI_UTIL_SIGN_SET 1 /* Force negative */
#define TGSI_UTIL_SIGN_TOGGLE 2 /* Negate */
diff --git a/src/gallium/auxiliary/translate/Makefile b/src/gallium/auxiliary/translate/Makefile
deleted file mode 100644
index 3c82f8ae03..0000000000
--- a/src/gallium/auxiliary/translate/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = translate
-
-C_SOURCES = \
- translate_generic.c \
- translate_sse.c \
- translate.c \
- translate_cache.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/translate/SConscript b/src/gallium/auxiliary/translate/SConscript
deleted file mode 100644
index 9553a67537..0000000000
--- a/src/gallium/auxiliary/translate/SConscript
+++ /dev/null
@@ -1,12 +0,0 @@
-Import('*')
-
-translate = env.ConvenienceLibrary(
- target = 'translate',
- source = [
- 'translate_generic.c',
- 'translate_sse.c',
- 'translate.c',
- 'translate_cache.c',
- ])
-
-auxiliaries.insert(0, translate)
diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile
deleted file mode 100644
index 1d8bb55bbd..0000000000
--- a/src/gallium/auxiliary/util/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = util
-
-C_SOURCES = \
- u_debug.c \
- u_debug_dump.c \
- u_debug_symbol.c \
- u_debug_stack.c \
- u_blit.c \
- u_cache.c \
- u_cpu_detect.c \
- u_draw_quad.c \
- u_format.c \
- u_format_access.c \
- u_format_table.c \
- u_gen_mipmap.c \
- u_handle_table.c \
- u_hash_table.c \
- u_hash.c \
- u_keymap.c \
- u_linear.c \
- u_network.c \
- u_math.c \
- u_mm.c \
- u_rect.c \
- u_simple_shaders.c \
- u_snprintf.c \
- u_stream_stdc.c \
- u_stream_wd.c \
- u_surface.c \
- u_tile.c \
- u_time.c \
- u_timed_winsys.c \
- u_upload_mgr.c \
- u_simple_screen.c
-
-include ../../Makefile.template
-
-u_format_table.c: u_format_table.py u_format_parse.py u_format.csv
- python u_format_table.py u_format.csv > $@
-
-u_format_access.c: u_format_access.py u_format_parse.py u_format.csv
- python u_format_access.py u_format.csv > $@
diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript
deleted file mode 100644
index 2187935fa4..0000000000
--- a/src/gallium/auxiliary/util/SConscript
+++ /dev/null
@@ -1,59 +0,0 @@
-Import('*')
-
-env.Clone()
-
-env.Append(CPPPATH = ['.'])
-
-env.CodeGenerate(
- target = 'u_format_table.c',
- script = 'u_format_table.py',
- source = ['u_format.csv'],
- command = 'python $SCRIPT $SOURCE > $TARGET'
-)
-
-env.CodeGenerate(
- target = 'u_format_access.c',
- script = 'u_format_access.py',
- source = ['u_format.csv'],
- command = 'python $SCRIPT $SOURCE > $TARGET'
-)
-
-util = env.ConvenienceLibrary(
- target = 'util',
- source = [
- 'u_bitmask.c',
- 'u_blit.c',
- 'u_cache.c',
- 'u_cpu_detect.c',
- 'u_debug.c',
- 'u_debug_dump.c',
- 'u_debug_memory.c',
- 'u_debug_profile.c',
- 'u_debug_stack.c',
- 'u_debug_symbol.c',
- 'u_draw_quad.c',
- 'u_format.c',
- 'u_format_access.c',
- 'u_format_table.c',
- 'u_gen_mipmap.c',
- 'u_handle_table.c',
- 'u_hash.c',
- 'u_hash_table.c',
- 'u_keymap.c',
- 'u_network.c',
- 'u_math.c',
- 'u_mm.c',
- 'u_rect.c',
- 'u_simple_shaders.c',
- 'u_snprintf.c',
- 'u_stream_stdc.c',
- 'u_stream_wd.c',
- 'u_surface.c',
- 'u_tile.c',
- 'u_time.c',
- 'u_timed_winsys.c',
- 'u_upload_mgr.c',
- 'u_simple_screen.c',
- ])
-
-auxiliaries.insert(0, util)
diff --git a/src/gallium/auxiliary/util/u_bitmask.c b/src/gallium/auxiliary/util/u_bitmask.c
index 77587c07ec..23c93a3ebc 100644
--- a/src/gallium/auxiliary/util/u_bitmask.c
+++ b/src/gallium/auxiliary/util/u_bitmask.c
@@ -97,12 +97,12 @@ util_bitmask_resize(struct util_bitmask *bm,
if(!minimum_size)
return FALSE;
- if(bm->size > minimum_size)
+ if(bm->size >= minimum_size)
return TRUE;
assert(bm->size % UTIL_BITMASK_BITS_PER_WORD == 0);
new_size = bm->size;
- while(!(new_size > minimum_size)) {
+ while(new_size < minimum_size) {
new_size *= 2;
/* Check integer overflow */
if(new_size < bm->size)
@@ -136,7 +136,7 @@ util_bitmask_filled_set(struct util_bitmask *bm,
unsigned index)
{
assert(bm->filled <= bm->size);
- assert(index <= bm->size);
+ assert(index < bm->size);
if(index == bm->filled) {
++bm->filled;
@@ -149,7 +149,7 @@ util_bitmask_filled_unset(struct util_bitmask *bm,
unsigned index)
{
assert(bm->filled <= bm->size);
- assert(index <= bm->size);
+ assert(index < bm->size);
if(index < bm->filled)
bm->filled = index;
@@ -182,7 +182,7 @@ util_bitmask_add(struct util_bitmask *bm)
mask = 1;
}
found:
-
+
/* grow the bitmask if necessary */
if(!util_bitmask_resize(bm, bm->filled))
return UTIL_BITMASK_INVALID_INDEX;
@@ -198,9 +198,9 @@ unsigned
util_bitmask_set(struct util_bitmask *bm,
unsigned index)
{
- unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
- unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD;
- util_bitmask_word mask = 1 << bit;
+ unsigned word;
+ unsigned bit;
+ util_bitmask_word mask;
assert(bm);
@@ -208,6 +208,10 @@ util_bitmask_set(struct util_bitmask *bm,
if(!util_bitmask_resize(bm, index))
return UTIL_BITMASK_INVALID_INDEX;
+ word = index / UTIL_BITMASK_BITS_PER_WORD;
+ bit = index % UTIL_BITMASK_BITS_PER_WORD;
+ mask = 1 << bit;
+
bm->words[word] |= mask;
util_bitmask_filled_set(bm, index);
@@ -220,15 +224,19 @@ void
util_bitmask_clear(struct util_bitmask *bm,
unsigned index)
{
- unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
- unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD;
- util_bitmask_word mask = 1 << bit;
+ unsigned word;
+ unsigned bit;
+ util_bitmask_word mask;
assert(bm);
if(index >= bm->size)
return;
+ word = index / UTIL_BITMASK_BITS_PER_WORD;
+ bit = index % UTIL_BITMASK_BITS_PER_WORD;
+ mask = 1 << bit;
+
bm->words[word] &= ~mask;
util_bitmask_filled_unset(bm, index);
@@ -250,7 +258,7 @@ util_bitmask_get(struct util_bitmask *bm,
return TRUE;
}
- if(index > bm->size)
+ if(index >= bm->size)
return FALSE;
if(bm->words[word] & mask) {
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index fb00c3abe8..3f74e2aa8b 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -42,10 +42,12 @@
#include "util/u_blit.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "util/u_surface.h"
+#include "util/u_rect.h"
#include "cso_cache/cso_context.h"
@@ -125,7 +127,8 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
}
/* fragment shader */
- ctx->fs[TGSI_WRITEMASK_XYZW] = util_make_fragment_tex_shader(pipe);
+ ctx->fs[TGSI_WRITEMASK_XYZW] =
+ util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
ctx->vbuf = NULL;
/* init vertex data that doesn't change */
@@ -301,7 +304,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
* no overlapping.
* Filter mode should not matter since there's no stretching.
*/
- if (dst->format == src->format &&
+ if (pipe->surface_copy &&
+ dst->format == src->format &&
srcX0 < srcX1 &&
dstX0 < dstX1 &&
srcY0 < srcY1 &&
@@ -352,10 +356,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
texTemp.target = PIPE_TEXTURE_2D;
texTemp.format = src->format;
texTemp.last_level = 0;
- texTemp.width[0] = srcW;
- texTemp.height[0] = srcH;
- texTemp.depth[0] = 1;
- pf_get_block(src->format, &texTemp.block);
+ texTemp.width0 = srcW;
+ texTemp.height0 = srcH;
+ texTemp.depth0 = 1;
tex = screen->texture_create(screen, &texTemp);
if (!tex)
@@ -365,10 +368,17 @@ util_blit_pixels_writemask(struct blit_state *ctx,
PIPE_BUFFER_USAGE_GPU_WRITE);
/* load temp texture */
- pipe->surface_copy(pipe,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
+ if (pipe->surface_copy) {
+ pipe->surface_copy(pipe,
+ texSurf, 0, 0, /* dest */
+ src, srcLeft, srcTop, /* src */
+ srcW, srcH); /* size */
+ } else {
+ util_surface_copy(pipe, FALSE,
+ texSurf, 0, 0, /* dest */
+ src, srcLeft, srcTop, /* src */
+ srcW, srcH); /* size */
+ }
/* free the surface, update the texture if necessary.
*/
@@ -380,10 +390,10 @@ util_blit_pixels_writemask(struct blit_state *ctx,
}
else {
pipe_texture_reference(&tex, src->texture);
- s0 = srcX0 / (float)tex->width[0];
- s1 = srcX1 / (float)tex->width[0];
- t0 = srcY0 / (float)tex->height[0];
- t1 = srcY1 / (float)tex->height[0];
+ s0 = srcX0 / (float)tex->width0;
+ s1 = srcX1 / (float)tex->width0;
+ t0 = srcY0 / (float)tex->height0;
+ t1 = srcY1 / (float)tex->height0;
}
@@ -412,7 +422,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
cso_set_sampler_textures(ctx->cso, 1, &tex);
if (ctx->fs[writemask] == NULL)
- ctx->fs[writemask] = util_make_fragment_tex_shader_writemask(pipe, writemask);
+ ctx->fs[writemask] =
+ util_make_fragment_tex_shader_writemask(pipe, TGSI_TEXTURE_2D,
+ writemask);
/* shaders */
cso_set_fragment_shader_handle(ctx->cso, ctx->fs[writemask]);
@@ -509,13 +521,13 @@ util_blit_pixels_tex(struct blit_state *ctx,
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
filter == PIPE_TEX_MIPFILTER_LINEAR);
- assert(tex->width[0] != 0);
- assert(tex->height[0] != 0);
+ assert(tex->width0 != 0);
+ assert(tex->height0 != 0);
- s0 = srcX0 / (float)tex->width[0];
- s1 = srcX1 / (float)tex->width[0];
- t0 = srcY0 / (float)tex->height[0];
- t1 = srcY1 / (float)tex->height[0];
+ s0 = srcX0 / (float)tex->width0;
+ s1 = srcX1 / (float)tex->width0;
+ t0 = srcY0 / (float)tex->height0;
+ t1 = srcY1 / (float)tex->height0;
assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
PIPE_TEXTURE_2D,
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
new file mode 100644
index 0000000000..cef3b69e46
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -0,0 +1,726 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Blitter utility to facilitate acceleration of the clear, surface_copy,
+ * and surface_fill functions.
+ *
+ * @author Marek Olšák
+ */
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
+
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "util/u_blitter.h"
+#include "util/u_draw_quad.h"
+#include "util/u_pack_color.h"
+#include "util/u_rect.h"
+#include "util/u_simple_shaders.h"
+#include "util/u_texture.h"
+
+#define INVALID_PTR ((void*)~0)
+
+struct blitter_context_priv
+{
+ struct blitter_context blitter;
+
+ struct pipe_context *pipe; /**< pipe context */
+ struct pipe_buffer *vbuf; /**< quad */
+
+ float vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */
+
+ /* Templates for various state objects. */
+ struct pipe_depth_stencil_alpha_state template_dsa;
+ struct pipe_sampler_state template_sampler_state;
+
+ /* Constant state objects. */
+ /* Vertex shaders. */
+ void *vs_col; /**< Vertex shader which passes {pos, color} to the output */
+ void *vs_tex; /**<Vertex shader which passes {pos, texcoord} to the output.*/
+
+ /* Fragment shaders. */
+ /* FS which outputs a color to multiple color buffers. */
+ void *fs_col[PIPE_MAX_COLOR_BUFS];
+
+ /* FS which outputs a color from a texture,
+ where the index is PIPE_TEXTURE_* to be sampled. */
+ void *fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES];
+
+ /* FS which outputs a depth from a texture,
+ where the index is PIPE_TEXTURE_* to be sampled. */
+ void *fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
+
+ /* Blend state. */
+ void *blend_write_color; /**< blend state with writemask of RGBA */
+ void *blend_keep_color; /**< blend state with writemask of 0 */
+
+ /* Depth stencil alpha state. */
+ void *dsa_write_depth_stencil[0xff]; /**< indices are stencil clear values */
+ void *dsa_write_depth_keep_stencil;
+ void *dsa_keep_depth_stencil;
+
+ /* Sampler state for clamping to a miplevel. */
+ void *sampler_state[PIPE_MAX_TEXTURE_LEVELS];
+
+ /* Rasterizer state. */
+ void *rs_state;
+};
+
+struct blitter_context *util_blitter_create(struct pipe_context *pipe)
+{
+ struct blitter_context_priv *ctx;
+ struct pipe_blend_state blend;
+ struct pipe_depth_stencil_alpha_state *dsa;
+ struct pipe_rasterizer_state rs_state;
+ struct pipe_sampler_state *sampler_state;
+ unsigned i;
+
+ ctx = CALLOC_STRUCT(blitter_context_priv);
+ if (!ctx)
+ return NULL;
+
+ ctx->pipe = pipe;
+
+ /* init state objects for them to be considered invalid */
+ ctx->blitter.saved_blend_state = INVALID_PTR;
+ ctx->blitter.saved_dsa_state = INVALID_PTR;
+ ctx->blitter.saved_rs_state = INVALID_PTR;
+ ctx->blitter.saved_fs = INVALID_PTR;
+ ctx->blitter.saved_vs = INVALID_PTR;
+ ctx->blitter.saved_fb_state.nr_cbufs = ~0;
+ ctx->blitter.saved_num_textures = ~0;
+ ctx->blitter.saved_num_sampler_states = ~0;
+
+ /* blend state objects */
+ memset(&blend, 0, sizeof(blend));
+ ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend);
+
+ blend.colormask = PIPE_MASK_RGBA;
+ ctx->blend_write_color = pipe->create_blend_state(pipe, &blend);
+
+ /* depth stencil alpha state objects */
+ dsa = &ctx->template_dsa;
+ ctx->dsa_keep_depth_stencil =
+ pipe->create_depth_stencil_alpha_state(pipe, dsa);
+
+ dsa->depth.enabled = 1;
+ dsa->depth.writemask = 1;
+ dsa->depth.func = PIPE_FUNC_ALWAYS;
+ ctx->dsa_write_depth_keep_stencil =
+ pipe->create_depth_stencil_alpha_state(pipe, dsa);
+
+ dsa->stencil[0].enabled = 1;
+ dsa->stencil[0].func = PIPE_FUNC_ALWAYS;
+ dsa->stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
+ dsa->stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+ dsa->stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
+ dsa->stencil[0].valuemask = 0xff;
+ dsa->stencil[0].writemask = 0xff;
+ /* The DSA state objects which write depth and stencil are created
+ * on-demand. */
+
+ /* sampler state */
+ sampler_state = &ctx->template_sampler_state;
+ sampler_state->wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler_state->wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler_state->wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ /* The sampler state objects which sample from a specified mipmap level
+ * are created on-demand. */
+
+ /* rasterizer state */
+ memset(&rs_state, 0, sizeof(rs_state));
+ rs_state.front_winding = PIPE_WINDING_CW;
+ rs_state.cull_mode = PIPE_WINDING_NONE;
+ rs_state.bypass_vs_clip_and_viewport = 1;
+ rs_state.gl_rasterization_rules = 1;
+ ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
+
+ /* fragment shaders are created on-demand */
+
+ /* vertex shaders */
+ {
+ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+ TGSI_SEMANTIC_COLOR };
+ const uint semantic_indices[] = { 0, 0 };
+ ctx->vs_col =
+ util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
+ semantic_indices);
+ }
+ {
+ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+ TGSI_SEMANTIC_GENERIC };
+ const uint semantic_indices[] = { 0, 0 };
+ ctx->vs_tex =
+ util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
+ semantic_indices);
+ }
+
+ /* set invariant vertex coordinates */
+ for (i = 0; i < 4; i++)
+ ctx->vertices[i][0][3] = 1; /*v.w*/
+
+ /* create the vertex buffer */
+ ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
+ 32,
+ PIPE_BUFFER_USAGE_VERTEX,
+ sizeof(ctx->vertices));
+
+ return &ctx->blitter;
+}
+
+void util_blitter_destroy(struct blitter_context *blitter)
+{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+ struct pipe_context *pipe = ctx->pipe;
+ int i;
+
+ pipe->delete_blend_state(pipe, ctx->blend_write_color);
+ pipe->delete_blend_state(pipe, ctx->blend_keep_color);
+ pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+ pipe->delete_depth_stencil_alpha_state(pipe,
+ ctx->dsa_write_depth_keep_stencil);
+
+ for (i = 0; i < 0xff; i++)
+ if (ctx->dsa_write_depth_stencil[i])
+ pipe->delete_depth_stencil_alpha_state(pipe,
+ ctx->dsa_write_depth_stencil[i]);
+
+ pipe->delete_rasterizer_state(pipe, ctx->rs_state);
+ pipe->delete_vs_state(pipe, ctx->vs_col);
+ pipe->delete_vs_state(pipe, ctx->vs_tex);
+
+ for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) {
+ if (ctx->fs_texfetch_col[i])
+ pipe->delete_fs_state(pipe, ctx->fs_texfetch_col[i]);
+ if (ctx->fs_texfetch_depth[i])
+ pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
+ }
+
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++)
+ if (ctx->fs_col[i])
+ pipe->delete_fs_state(pipe, ctx->fs_col[i]);
+
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (ctx->sampler_state[i])
+ pipe->delete_sampler_state(pipe, ctx->sampler_state[i]);
+
+ pipe_buffer_reference(&ctx->vbuf, NULL);
+ FREE(ctx);
+}
+
+static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx)
+{
+ /* make sure these CSOs have been saved */
+ assert(ctx->blitter.saved_blend_state != INVALID_PTR &&
+ ctx->blitter.saved_dsa_state != INVALID_PTR &&
+ ctx->blitter.saved_rs_state != INVALID_PTR &&
+ ctx->blitter.saved_fs != INVALID_PTR &&
+ ctx->blitter.saved_vs != INVALID_PTR);
+}
+
+static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->pipe;
+
+ /* restore the state objects which are always required to be saved */
+ pipe->bind_blend_state(pipe, ctx->blitter.saved_blend_state);
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->blitter.saved_dsa_state);
+ pipe->bind_rasterizer_state(pipe, ctx->blitter.saved_rs_state);
+ pipe->bind_fs_state(pipe, ctx->blitter.saved_fs);
+ pipe->bind_vs_state(pipe, ctx->blitter.saved_vs);
+
+ ctx->blitter.saved_blend_state = INVALID_PTR;
+ ctx->blitter.saved_dsa_state = INVALID_PTR;
+ ctx->blitter.saved_rs_state = INVALID_PTR;
+ ctx->blitter.saved_fs = INVALID_PTR;
+ ctx->blitter.saved_vs = INVALID_PTR;
+
+ /* restore the state objects which are required to be saved before copy/fill
+ */
+ if (ctx->blitter.saved_fb_state.nr_cbufs != ~0) {
+ pipe->set_framebuffer_state(pipe, &ctx->blitter.saved_fb_state);
+ ctx->blitter.saved_fb_state.nr_cbufs = ~0;
+ }
+
+ if (ctx->blitter.saved_num_sampler_states != ~0) {
+ pipe->bind_fragment_sampler_states(pipe,
+ ctx->blitter.saved_num_sampler_states,
+ ctx->blitter.saved_sampler_states);
+ ctx->blitter.saved_num_sampler_states = ~0;
+ }
+
+ if (ctx->blitter.saved_num_textures != ~0) {
+ pipe->set_fragment_sampler_textures(pipe,
+ ctx->blitter.saved_num_textures,
+ ctx->blitter.saved_textures);
+ ctx->blitter.saved_num_textures = ~0;
+ }
+}
+
+static void blitter_set_rectangle(struct blitter_context_priv *ctx,
+ unsigned x1, unsigned y1,
+ unsigned x2, unsigned y2,
+ float depth)
+{
+ int i;
+
+ /* set vertex positions */
+ ctx->vertices[0][0][0] = x1; /*v0.x*/
+ ctx->vertices[0][0][1] = y1; /*v0.y*/
+
+ ctx->vertices[1][0][0] = x2; /*v1.x*/
+ ctx->vertices[1][0][1] = y1; /*v1.y*/
+
+ ctx->vertices[2][0][0] = x2; /*v2.x*/
+ ctx->vertices[2][0][1] = y2; /*v2.y*/
+
+ ctx->vertices[3][0][0] = x1; /*v3.x*/
+ ctx->vertices[3][0][1] = y2; /*v3.y*/
+
+ for (i = 0; i < 4; i++)
+ ctx->vertices[i][0][2] = depth; /*z*/
+}
+
+static void blitter_set_clear_color(struct blitter_context_priv *ctx,
+ const float *rgba)
+{
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ ctx->vertices[i][1][0] = rgba[0];
+ ctx->vertices[i][1][1] = rgba[1];
+ ctx->vertices[i][1][2] = rgba[2];
+ ctx->vertices[i][1][3] = rgba[3];
+ }
+}
+
+static void blitter_set_texcoords_2d(struct blitter_context_priv *ctx,
+ struct pipe_surface *surf,
+ unsigned x1, unsigned y1,
+ unsigned x2, unsigned y2)
+{
+ int i;
+ float s1 = x1 / (float)surf->width;
+ float t1 = y1 / (float)surf->height;
+ float s2 = x2 / (float)surf->width;
+ float t2 = y2 / (float)surf->height;
+
+ ctx->vertices[0][1][0] = s1; /*t0.s*/
+ ctx->vertices[0][1][1] = t1; /*t0.t*/
+
+ ctx->vertices[1][1][0] = s2; /*t1.s*/
+ ctx->vertices[1][1][1] = t1; /*t1.t*/
+
+ ctx->vertices[2][1][0] = s2; /*t2.s*/
+ ctx->vertices[2][1][1] = t2; /*t2.t*/
+
+ ctx->vertices[3][1][0] = s1; /*t3.s*/
+ ctx->vertices[3][1][1] = t2; /*t3.t*/
+
+ for (i = 0; i < 4; i++) {
+ ctx->vertices[i][1][2] = 0; /*r*/
+ ctx->vertices[i][1][3] = 1; /*q*/
+ }
+}
+
+static void blitter_set_texcoords_3d(struct blitter_context_priv *ctx,
+ struct pipe_surface *surf,
+ unsigned x1, unsigned y1,
+ unsigned x2, unsigned y2)
+{
+ int i;
+ float depth = u_minify(surf->texture->depth0, surf->level);
+ float r = surf->zslice / depth;
+
+ blitter_set_texcoords_2d(ctx, surf, x1, y1, x2, y2);
+
+ for (i = 0; i < 4; i++)
+ ctx->vertices[i][1][2] = r; /*r*/
+}
+
+static void blitter_set_texcoords_cube(struct blitter_context_priv *ctx,
+ struct pipe_surface *surf,
+ unsigned x1, unsigned y1,
+ unsigned x2, unsigned y2)
+{
+ int i;
+ float s1 = x1 / (float)surf->width;
+ float t1 = y1 / (float)surf->height;
+ float s2 = x2 / (float)surf->width;
+ float t2 = y2 / (float)surf->height;
+ const float st[4][2] = {
+ {s1, t1}, {s2, t1}, {s2, t2}, {s1, t2}
+ };
+
+ util_map_texcoords2d_onto_cubemap(surf->face,
+ /* pointer, stride in floats */
+ &st[0][0], 2,
+ &ctx->vertices[0][1][0], 8);
+
+ for (i = 0; i < 4; i++)
+ ctx->vertices[i][1][3] = 1; /*q*/
+}
+
+static void blitter_draw_quad(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->pipe;
+
+ /* write vertices and draw them */
+ pipe_buffer_write(pipe->screen, ctx->vbuf,
+ 0, sizeof(ctx->vertices), ctx->vertices);
+
+ util_draw_vertex_buffer(pipe, ctx->vbuf, 0, PIPE_PRIM_TRIANGLE_FAN,
+ 4, /* verts */
+ 2); /* attribs/vert */
+}
+
+static INLINE
+void *blitter_get_state_write_depth_stencil(
+ struct blitter_context_priv *ctx,
+ unsigned stencil)
+{
+ struct pipe_context *pipe = ctx->pipe;
+
+ stencil &= 0xff;
+
+ /* Create the DSA state on-demand. */
+ if (!ctx->dsa_write_depth_stencil[stencil]) {
+ ctx->template_dsa.stencil[0].ref_value = stencil;
+
+ ctx->dsa_write_depth_stencil[stencil] =
+ pipe->create_depth_stencil_alpha_state(pipe, &ctx->template_dsa);
+ }
+
+ return ctx->dsa_write_depth_stencil[stencil];
+}
+
+static INLINE
+void **blitter_get_sampler_state(struct blitter_context_priv *ctx,
+ int miplevel)
+{
+ struct pipe_context *pipe = ctx->pipe;
+ struct pipe_sampler_state *sampler_state = &ctx->template_sampler_state;
+
+ assert(miplevel < PIPE_MAX_TEXTURE_LEVELS);
+
+ /* Create the sampler state on-demand. */
+ if (!ctx->sampler_state[miplevel]) {
+ sampler_state->lod_bias = miplevel;
+ sampler_state->min_lod = miplevel;
+ sampler_state->max_lod = miplevel;
+
+ ctx->sampler_state[miplevel] = pipe->create_sampler_state(pipe,
+ sampler_state);
+ }
+
+ /* Return void** so that it can be passed to bind_fragment_sampler_states
+ * directly. */
+ return &ctx->sampler_state[miplevel];
+}
+
+static INLINE
+void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
+{
+ struct pipe_context *pipe = ctx->pipe;
+ unsigned index = num_cbufs ? num_cbufs - 1 : 0;
+
+ assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
+
+ if (!ctx->fs_col[index])
+ ctx->fs_col[index] =
+ util_make_fragment_clonecolor_shader(pipe, num_cbufs);
+
+ return ctx->fs_col[index];
+}
+
+static INLINE
+void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
+ unsigned tex_target)
+{
+ struct pipe_context *pipe = ctx->pipe;
+
+ assert(tex_target < PIPE_MAX_TEXTURE_TYPES);
+
+ /* Create the fragment shader on-demand. */
+ if (!ctx->fs_texfetch_col[tex_target]) {
+ switch (tex_target) {
+ case PIPE_TEXTURE_1D:
+ ctx->fs_texfetch_col[PIPE_TEXTURE_1D] =
+ util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_1D);
+ break;
+ case PIPE_TEXTURE_2D:
+ ctx->fs_texfetch_col[PIPE_TEXTURE_2D] =
+ util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
+ break;
+ case PIPE_TEXTURE_3D:
+ ctx->fs_texfetch_col[PIPE_TEXTURE_3D] =
+ util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_3D);
+ break;
+ case PIPE_TEXTURE_CUBE:
+ ctx->fs_texfetch_col[PIPE_TEXTURE_CUBE] =
+ util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
+ break;
+ default:;
+ }
+ }
+
+ return ctx->fs_texfetch_col[tex_target];
+}
+
+static INLINE
+void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx,
+ unsigned tex_target)
+{
+ struct pipe_context *pipe = ctx->pipe;
+
+ assert(tex_target < PIPE_MAX_TEXTURE_TYPES);
+
+ /* Create the fragment shader on-demand. */
+ if (!ctx->fs_texfetch_depth[tex_target]) {
+ switch (tex_target) {
+ case PIPE_TEXTURE_1D:
+ ctx->fs_texfetch_depth[PIPE_TEXTURE_1D] =
+ util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_1D);
+ break;
+ case PIPE_TEXTURE_2D:
+ ctx->fs_texfetch_depth[PIPE_TEXTURE_2D] =
+ util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_2D);
+ break;
+ case PIPE_TEXTURE_3D:
+ ctx->fs_texfetch_depth[PIPE_TEXTURE_3D] =
+ util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_3D);
+ break;
+ case PIPE_TEXTURE_CUBE:
+ ctx->fs_texfetch_depth[PIPE_TEXTURE_CUBE] =
+ util_make_fragment_tex_shader_writedepth(pipe,TGSI_TEXTURE_CUBE);
+ break;
+ default:;
+ }
+ }
+
+ return ctx->fs_texfetch_depth[tex_target];
+}
+
+void util_blitter_clear(struct blitter_context *blitter,
+ unsigned width, unsigned height,
+ unsigned num_cbufs,
+ unsigned clear_buffers,
+ const float *rgba,
+ double depth, unsigned stencil)
+{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+ struct pipe_context *pipe = ctx->pipe;
+
+ assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
+
+ blitter_check_saved_CSOs(ctx);
+
+ /* bind CSOs */
+ if (clear_buffers & PIPE_CLEAR_COLOR)
+ pipe->bind_blend_state(pipe, ctx->blend_write_color);
+ else
+ pipe->bind_blend_state(pipe, ctx->blend_keep_color);
+
+ if (clear_buffers & PIPE_CLEAR_DEPTHSTENCIL)
+ pipe->bind_depth_stencil_alpha_state(pipe,
+ blitter_get_state_write_depth_stencil(ctx, stencil));
+ else
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+
+ pipe->bind_rasterizer_state(pipe, ctx->rs_state);
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs));
+ pipe->bind_vs_state(pipe, ctx->vs_col);
+
+ blitter_set_clear_color(ctx, rgba);
+ blitter_set_rectangle(ctx, 0, 0, width, height, depth);
+ blitter_draw_quad(ctx);
+ blitter_restore_CSOs(ctx);
+}
+
+void util_blitter_copy(struct blitter_context *blitter,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ struct pipe_surface *src,
+ unsigned srcx, unsigned srcy,
+ unsigned width, unsigned height,
+ boolean ignore_stencil)
+{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+ struct pipe_context *pipe = ctx->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_framebuffer_state fb_state;
+ boolean is_stencil, is_depth;
+ unsigned dst_tex_usage;
+
+ /* give up if textures are not set */
+ assert(dst->texture && src->texture);
+ if (!dst->texture || !src->texture)
+ return;
+
+ is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
+ is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
+ dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
+ PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+ /* check if we can sample from and render to the surfaces */
+ /* (assuming copying a stencil buffer is not possible) */
+ if ((!ignore_stencil && is_stencil) ||
+ !screen->is_format_supported(screen, dst->format, dst->texture->target,
+ dst_tex_usage, 0) ||
+ !screen->is_format_supported(screen, src->format, src->texture->target,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
+ width, height);
+ return;
+ }
+
+ /* check whether the states are properly saved */
+ blitter_check_saved_CSOs(ctx);
+ assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ assert(blitter->saved_num_textures != ~0);
+ assert(blitter->saved_num_sampler_states != ~0);
+ assert(src->texture->target < PIPE_MAX_TEXTURE_TYPES);
+
+ /* bind CSOs */
+ fb_state.width = dst->width;
+ fb_state.height = dst->height;
+
+ if (is_depth) {
+ pipe->bind_blend_state(pipe, ctx->blend_keep_color);
+ pipe->bind_depth_stencil_alpha_state(pipe,
+ ctx->dsa_write_depth_keep_stencil);
+ pipe->bind_fs_state(pipe,
+ blitter_get_fs_texfetch_depth(ctx, src->texture->target));
+
+ fb_state.nr_cbufs = 0;
+ fb_state.zsbuf = dst;
+ } else {
+ pipe->bind_blend_state(pipe, ctx->blend_write_color);
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+ pipe->bind_fs_state(pipe,
+ blitter_get_fs_texfetch_col(ctx, src->texture->target));
+
+ fb_state.nr_cbufs = 1;
+ fb_state.cbufs[0] = dst;
+ fb_state.zsbuf = 0;
+ }
+
+ pipe->bind_rasterizer_state(pipe, ctx->rs_state);
+ pipe->bind_vs_state(pipe, ctx->vs_tex);
+ pipe->bind_fragment_sampler_states(pipe, 1,
+ blitter_get_sampler_state(ctx, src->level));
+ pipe->set_fragment_sampler_textures(pipe, 1, &src->texture);
+ pipe->set_framebuffer_state(pipe, &fb_state);
+
+ /* set texture coordinates */
+ switch (src->texture->target) {
+ case PIPE_TEXTURE_1D:
+ case PIPE_TEXTURE_2D:
+ blitter_set_texcoords_2d(ctx, src, srcx, srcy,
+ srcx+width, srcy+height);
+ break;
+ case PIPE_TEXTURE_3D:
+ blitter_set_texcoords_3d(ctx, src, srcx, srcy,
+ srcx+width, srcy+height);
+ break;
+ case PIPE_TEXTURE_CUBE:
+ blitter_set_texcoords_cube(ctx, src, srcx, srcy,
+ srcx+width, srcy+height);
+ break;
+ default:
+ assert(0);
+ }
+
+ blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, 0);
+ blitter_draw_quad(ctx);
+ blitter_restore_CSOs(ctx);
+}
+
+void util_blitter_fill(struct blitter_context *blitter,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height,
+ unsigned value)
+{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+ struct pipe_context *pipe = ctx->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_framebuffer_state fb_state;
+ float rgba[4];
+ ubyte ub_rgba[4] = {0};
+ union util_color color;
+ int i;
+
+ assert(dst->texture);
+ if (!dst->texture)
+ return;
+
+ /* check if we can render to the surface */
+ if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
+ !screen->is_format_supported(screen, dst->format, dst->texture->target,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
+ return;
+ }
+
+ /* unpack the color */
+ color.ui = value;
+ util_unpack_color_ub(dst->format, &color,
+ ub_rgba, ub_rgba+1, ub_rgba+2, ub_rgba+3);
+ for (i = 0; i < 4; i++)
+ rgba[i] = ubyte_to_float(ub_rgba[i]);
+
+ /* check the saved state */
+ blitter_check_saved_CSOs(ctx);
+ assert(blitter->saved_fb_state.nr_cbufs != ~0);
+
+ /* bind CSOs */
+ pipe->bind_blend_state(pipe, ctx->blend_write_color);
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
+ pipe->bind_rasterizer_state(pipe, ctx->rs_state);
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1));
+ pipe->bind_vs_state(pipe, ctx->vs_col);
+
+ /* set a framebuffer state */
+ fb_state.width = dst->width;
+ fb_state.height = dst->height;
+ fb_state.nr_cbufs = 1;
+ fb_state.cbufs[0] = dst;
+ fb_state.zsbuf = 0;
+ pipe->set_framebuffer_state(pipe, &fb_state);
+
+ blitter_set_clear_color(ctx, rgba);
+ blitter_set_rectangle(ctx, 0, 0, width, height, 0);
+ blitter_draw_quad(ctx);
+ blitter_restore_CSOs(ctx);
+}
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
new file mode 100644
index 0000000000..3da5a6ca52
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -0,0 +1,230 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef U_BLITTER_H
+#define U_BLITTER_H
+
+#include "util/u_memory.h"
+
+#include "pipe/p_state.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct pipe_context;
+
+struct blitter_context
+{
+ /* Private members, really. */
+ void *saved_blend_state; /**< blend state */
+ void *saved_dsa_state; /**< depth stencil alpha state */
+ void *saved_rs_state; /**< rasterizer state */
+ void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */
+
+ struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
+
+ int saved_num_sampler_states;
+ void *saved_sampler_states[32];
+
+ int saved_num_textures;
+ struct pipe_texture *saved_textures[32]; /* is 32 enough? */
+};
+
+/**
+ * Create a blitter context.
+ */
+struct blitter_context *util_blitter_create(struct pipe_context *pipe);
+
+/**
+ * Destroy a blitter context.
+ */
+void util_blitter_destroy(struct blitter_context *blitter);
+
+/*
+ * These CSOs must be saved before any of the following functions is called:
+ * - blend state
+ * - depth stencil alpha state
+ * - rasterizer state
+ * - vertex shader
+ * - fragment shader
+ */
+
+/**
+ * Clear a specified set of currently bound buffers to specified values.
+ */
+void util_blitter_clear(struct blitter_context *blitter,
+ unsigned width, unsigned height,
+ unsigned num_cbufs,
+ unsigned clear_buffers,
+ const float *rgba,
+ double depth, unsigned stencil);
+
+/**
+ * Copy a block of pixels from one surface to another.
+ *
+ * You can copy from any color format to any other color format provided
+ * the former can be sampled and the latter can be rendered to. Otherwise,
+ * a software fallback path is taken and both surfaces must be of the same
+ * format.
+ *
+ * The same holds for depth-stencil formats with the exception that stencil
+ * cannot be copied unless you set ignore_stencil to FALSE. In that case,
+ * a software fallback path is taken and both surfaces must be of the same
+ * format.
+ *
+ * Use pipe_screen->is_format_supported to know your options.
+ *
+ * These states must be saved in the blitter in addition to the state objects
+ * already required to be saved:
+ * - framebuffer state
+ * - fragment sampler states
+ * - fragment sampler textures
+ */
+void util_blitter_copy(struct blitter_context *blitter,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ struct pipe_surface *src,
+ unsigned srcx, unsigned srcy,
+ unsigned width, unsigned height,
+ boolean ignore_stencil);
+
+/**
+ * Fill a region of a surface with a constant value.
+ *
+ * If the surface cannot be rendered to or it's a depth-stencil format,
+ * a software fallback path is taken.
+ *
+ * These states must be saved in the blitter in addition to the state objects
+ * already required to be saved:
+ * - framebuffer state
+ */
+void util_blitter_fill(struct blitter_context *blitter,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height,
+ unsigned value);
+
+/**
+ * Copy all pixels from one surface to another.
+ *
+ * The rules are the same as in util_blitter_copy with the addition that
+ * surfaces must have the same size.
+ */
+static INLINE
+void util_blitter_copy_surface(struct blitter_context *blitter,
+ struct pipe_surface *dst,
+ struct pipe_surface *src,
+ boolean ignore_stencil)
+{
+ assert(dst->width == src->width && dst->height == src->height);
+
+ util_blitter_copy(blitter, dst, 0, 0, src, 0, 0, src->width, src->height,
+ ignore_stencil);
+}
+
+
+/* The functions below should be used to save currently bound constant state
+ * objects inside a driver. The objects are automatically restored at the end
+ * of the util_blitter_{clear, fill, copy, copy_surface} functions and then
+ * forgotten.
+ *
+ * CSOs not listed here are not affected by util_blitter. */
+
+static INLINE
+void util_blitter_save_blend(struct blitter_context *blitter,
+ void *state)
+{
+ blitter->saved_blend_state = state;
+}
+
+static INLINE
+void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
+ void *state)
+{
+ blitter->saved_dsa_state = state;
+}
+
+static INLINE
+void util_blitter_save_rasterizer(struct blitter_context *blitter,
+ void *state)
+{
+ blitter->saved_rs_state = state;
+}
+
+static INLINE
+void util_blitter_save_fragment_shader(struct blitter_context *blitter,
+ void *fs)
+{
+ blitter->saved_fs = fs;
+}
+
+static INLINE
+void util_blitter_save_vertex_shader(struct blitter_context *blitter,
+ void *vs)
+{
+ blitter->saved_vs = vs;
+}
+
+static INLINE
+void util_blitter_save_framebuffer(struct blitter_context *blitter,
+ struct pipe_framebuffer_state *state)
+{
+ blitter->saved_fb_state = *state;
+}
+
+static INLINE
+void util_blitter_save_fragment_sampler_states(
+ struct blitter_context *blitter,
+ int num_sampler_states,
+ void **sampler_states)
+{
+ assert(num_sampler_states <= Elements(blitter->saved_sampler_states));
+
+ blitter->saved_num_sampler_states = num_sampler_states;
+ memcpy(blitter->saved_sampler_states, sampler_states,
+ num_sampler_states * sizeof(void *));
+}
+
+static INLINE
+void util_blitter_save_fragment_sampler_textures(
+ struct blitter_context *blitter,
+ int num_textures,
+ struct pipe_texture **textures)
+{
+ assert(num_textures <= Elements(blitter->saved_textures));
+
+ blitter->saved_num_textures = num_textures;
+ memcpy(blitter->saved_textures, textures,
+ num_textures * sizeof(struct pipe_texture *));
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h
index 7c16b32cf9..2c32db6175 100644
--- a/src/gallium/auxiliary/util/u_clear.h
+++ b/src/gallium/auxiliary/util/u_clear.h
@@ -32,6 +32,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_pack_color.h"
+#include "util/u_rect.h"
/**
@@ -45,16 +46,25 @@ util_clear(struct pipe_context *pipe,
{
if (buffers & PIPE_CLEAR_COLOR) {
struct pipe_surface *ps = framebuffer->cbufs[0];
- unsigned color;
+ union util_color uc;
- util_pack_color(rgba, ps->format, &color);
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+ util_pack_color(rgba, ps->format, &uc);
+ if (pipe->surface_fill) {
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
+ } else {
+ util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
+ }
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *ps = framebuffer->zsbuf;
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
- util_pack_z_stencil(ps->format, depth, stencil));
+ if (pipe->surface_fill) {
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+ util_pack_z_stencil(ps->format, depth, stencil));
+ } else {
+ util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+ util_pack_z_stencil(ps->format, depth, stencil));
+ }
}
}
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
index ded361ce70..a08241971c 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -67,18 +67,20 @@
#if defined(PIPE_OS_WINDOWS)
#include <windows.h>
+#if defined(MSVC)
+#include <intrin.h>
+#endif
#endif
struct util_cpu_caps util_cpu_caps;
static int has_cpuid(void);
-static int cpuid(uint32_t ax, uint32_t *p);
#if defined(PIPE_ARCH_X86)
/* The sigill handlers */
-#if defined(PIPE_OS_LINUX) //&& defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
+#if defined(PIPE_OS_LINUX) /*&& defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)*/
static void
sigill_handler_sse(int signal, struct sigcontext sc)
{
@@ -131,7 +133,7 @@ win32_sig_handler_sse(EXCEPTION_POINTERS* ep)
#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_DARWIN)
-static sigjmp_buf __lv_powerpc_jmpbuf;
+static jmp_buf __lv_powerpc_jmpbuf;
static volatile sig_atomic_t __lv_powerpc_canjump = 0;
static void
@@ -143,9 +145,11 @@ sigill_handler(int sig)
}
__lv_powerpc_canjump = 0;
- siglongjmp(__lv_powerpc_jmpbuf, 1);
+ longjmp(__lv_powerpc_jmpbuf, 1);
}
+#endif
+#if defined(PIPE_ARCH_PPC)
static void
check_os_altivec_support(void)
{
@@ -166,7 +170,7 @@ check_os_altivec_support(void)
/* no Darwin, do it the brute-force way */
/* this is borrowed from the libmpeg2 library */
signal(SIGILL, sigill_handler);
- if (sigsetjmp(__lv_powerpc_jmpbuf, 1)) {
+ if (setjmp(__lv_powerpc_jmpbuf)) {
signal(SIGILL, SIG_DFL);
} else {
__lv_powerpc_canjump = 1;
@@ -180,9 +184,9 @@ check_os_altivec_support(void)
signal(SIGILL, SIG_DFL);
util_cpu_caps.has_altivec = 1;
}
-#endif
+#endif /* PIPE_OS_DARWIN */
}
-#endif
+#endif /* PIPE_ARCH_PPC */
/* If we're running on a processor that can do SSE, let's see if we
* are allowed to or not. This will catch 2.4.0 or later kernels that
@@ -190,6 +194,7 @@ check_os_altivec_support(void)
* and RedHat patched 2.2 kernels that have broken exception handling
* support for user space apps that do SSE.
*/
+#if defined(PIPE_ARCH_X86) || defined (PIPE_ARCH_X86_64)
static void
check_os_katmai_support(void)
{
@@ -235,7 +240,7 @@ check_os_katmai_support(void)
__asm __volatile ("xorps %xmm0, %xmm0");
#elif defined(PIPE_CC_MSVC)
__asm {
- xorps xmm0, xmm0 // executing SSE instruction
+ xorps xmm0, xmm0 /* executing SSE instruction */
}
#else
#error Unsupported compiler
@@ -278,7 +283,7 @@ check_os_katmai_support(void)
* and therefore to be safe I'm going to leave this test in here.
*/
if (util_cpu_caps.has_sse) {
- // test_os_katmai_exception_support();
+ /* test_os_katmai_exception_support(); */
}
/* Restore the original signal handlers.
@@ -334,12 +339,11 @@ static int has_cpuid(void)
/**
* @sa cpuid.h included in gcc-4.3 onwards.
+ * @sa http://msdn.microsoft.com/en-us/library/hskdteyh.aspx
*/
-static INLINE int
+static INLINE void
cpuid(uint32_t ax, uint32_t *p)
{
- int ret = -1;
-
#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
__asm __volatile (
"xchgl %%ebx, %1\n\t"
@@ -351,7 +355,6 @@ cpuid(uint32_t ax, uint32_t *p)
"=d" (p[3])
: "0" (ax)
);
- ret = 0;
#elif defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86_64)
__asm __volatile (
"cpuid\n\t"
@@ -361,15 +364,16 @@ cpuid(uint32_t ax, uint32_t *p)
"=d" (p[3])
: "0" (ax)
);
- ret = 0;
#elif defined(PIPE_CC_MSVC)
- __cpuid(ax, p);
-
- ret = 0;
+ __cpuid(p, ax);
+#else
+ p[0] = 0;
+ p[1] = 0;
+ p[2] = 0;
+ p[3] = 0;
#endif
-
- return ret;
}
+#endif /* X86 or X86_64 */
void
util_cpu_detect(void)
@@ -390,19 +394,26 @@ util_cpu_detect(void)
util_cpu_caps.arch = UTIL_CPU_ARCH_SPARC;
#elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
util_cpu_caps.arch = UTIL_CPU_ARCH_X86;
+ util_cpu_caps.little_endian = 1;
#elif defined(PIPE_ARCH_PPC)
util_cpu_caps.arch = UTIL_CPU_ARCH_POWERPC;
+ util_cpu_caps.little_endian = 0;
#else
util_cpu_caps.arch = UTIL_CPU_ARCH_UNKNOWN;
#endif
/* Count the number of CPUs in system */
-#if !defined(PIPE_OS_WINDOWS) && !defined(PIPE_OS_UNKNOWN) && defined(_SC_NPROCESSORS_ONLN)
+#if defined(PIPE_OS_WINDOWS)
+ {
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ util_cpu_caps.nr_cpus = system_info.dwNumberOfProcessors;
+ }
+#elif defined(PIPE_OS_UNIX) && defined(_SC_NPROCESSORS_ONLN)
util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
if (util_cpu_caps.nr_cpus == -1)
util_cpu_caps.nr_cpus = 1;
-
-#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_OPENBSD)
+#elif defined(PIPE_OS_BSD)
{
int mib[2], ncpu;
int len;
@@ -469,7 +480,6 @@ util_cpu_detect(void)
util_cpu_caps.cacheline = regs2[2] & 0xFF;
}
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_NETBSD) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_OPENBSD)
if (util_cpu_caps.has_sse)
check_os_katmai_support();
@@ -477,13 +487,8 @@ util_cpu_detect(void)
util_cpu_caps.has_sse2 = 0;
util_cpu_caps.has_sse3 = 0;
util_cpu_caps.has_ssse3 = 0;
+ util_cpu_caps.has_sse4_1 = 0;
}
-#else
- util_cpu_caps.has_sse = 0;
- util_cpu_caps.has_sse2 = 0;
- util_cpu_caps.has_sse3 = 0;
- util_cpu_caps.has_ssse3 = 0;
-#endif
}
#endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h
index 7ea0121c07..4b3dc39c34 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.h
+++ b/src/gallium/auxiliary/util/u_cpu_detect.h
@@ -54,6 +54,8 @@ struct util_cpu_caps {
int x86_cpu_type;
unsigned cacheline;
+ unsigned little_endian:1;
+
unsigned has_tsc:1;
unsigned has_mmx:1;
unsigned has_mmx2:1;
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 96d400c839..9b4e6ca2a7 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -64,11 +64,13 @@
#include "pipe/p_format.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_string.h"
#include "util/u_stream.h"
#include "util/u_math.h"
#include "util/u_tile.h"
+#include "util/u_prim.h"
#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
@@ -452,7 +454,8 @@ debug_dump_flags(const struct debug_named_value *names,
util_strncat(output, "|", sizeof(output));
else
first = 0;
- util_strncat(output, names->name, sizeof(output));
+ util_strncat(output, names->name, sizeof(output) - 1);
+ output[sizeof(output) - 1] = '\0';
value &= ~names->value;
}
++names;
@@ -465,7 +468,8 @@ debug_dump_flags(const struct debug_named_value *names,
first = 0;
util_snprintf(rest, sizeof(rest), "0x%08lx", value);
- util_strncat(output, rest, sizeof(output));
+ util_strncat(output, rest, sizeof(output) - 1);
+ output[sizeof(output) - 1] = '\0';
}
if(first)
@@ -600,6 +604,32 @@ const char *pf_name( enum pipe_format format )
}
+
+static const struct debug_named_value pipe_prim_names[] = {
+#ifdef DEBUG
+ DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_LINES),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP),
+ DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON),
+#endif
+ DEBUG_NAMED_VALUE_END
+};
+
+
+const char *u_prim_name( unsigned prim )
+{
+ return debug_dump_enum(pipe_prim_names, prim);
+}
+
+
+
+
#ifdef DEBUG
void debug_dump_image(const char *prefix,
unsigned format, unsigned cpp,
@@ -669,10 +699,10 @@ void debug_dump_surface(const char *prefix,
goto error;
debug_dump_image(prefix,
- transfer->format,
- transfer->block.size,
- transfer->nblocksx,
- transfer->nblocksy,
+ texture->format,
+ util_format_get_blocksize(texture->format),
+ util_format_get_nblocksx(texture->format, transfer->width),
+ util_format_get_nblocksy(texture->format, transfer->height),
transfer->stride,
data);
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index b8c56fd600..facc30a553 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -188,7 +188,7 @@ void _debug_assert_fail(const char *expr,
#ifdef DEBUG
#define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
#else
-#define debug_assert(expr) ((void)0)
+#define debug_assert(expr) do { } while (0 && (expr))
#endif
@@ -351,17 +351,6 @@ void
debug_memory_end(unsigned long beginning);
-#if defined(PROFILE) && defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-void
-debug_profile_start(void);
-
-void
-debug_profile_stop(void);
-
-#endif
-
-
#ifdef DEBUG
struct pipe_surface;
struct pipe_transfer;
diff --git a/src/gallium/auxiliary/util/u_debug_dump.c b/src/gallium/auxiliary/util/u_debug_dump.c
index 6bdecde048..61624d05c0 100644
--- a/src/gallium/auxiliary/util/u_debug_dump.c
+++ b/src/gallium/auxiliary/util/u_debug_dump.c
@@ -187,3 +187,81 @@ debug_dump_func_short_names[] = {
};
DEFINE_DEBUG_DUMP_CONTINUOUS(func)
+
+
+static const char *
+debug_dump_tex_target_names[] = {
+ "PIPE_TEXTURE_1D",
+ "PIPE_TEXTURE_2D",
+ "PIPE_TEXTURE_3D",
+ "PIPE_TEXTURE_CUBE"
+};
+
+static const char *
+debug_dump_tex_target_short_names[] = {
+ "1d",
+ "2d",
+ "3d",
+ "cube"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_target)
+
+
+static const char *
+debug_dump_tex_wrap_names[] = {
+ "PIPE_TEX_WRAP_REPEAT",
+ "PIPE_TEX_WRAP_CLAMP",
+ "PIPE_TEX_WRAP_CLAMP_TO_EDGE",
+ "PIPE_TEX_WRAP_CLAMP_TO_BORDER",
+ "PIPE_TEX_WRAP_MIRROR_REPEAT",
+ "PIPE_TEX_WRAP_MIRROR_CLAMP",
+ "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE",
+ "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER"
+};
+
+static const char *
+debug_dump_tex_wrap_short_names[] = {
+ "repeat",
+ "clamp",
+ "clamp_to_edge",
+ "clamp_to_border",
+ "mirror_repeat",
+ "mirror_clamp",
+ "mirror_clamp_to_edge",
+ "mirror_clamp_to_border"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_wrap)
+
+
+static const char *
+debug_dump_tex_mipfilter_names[] = {
+ "PIPE_TEX_MIPFILTER_NEAREST",
+ "PIPE_TEX_MIPFILTER_LINEAR",
+ "PIPE_TEX_MIPFILTER_NONE"
+};
+
+static const char *
+debug_dump_tex_mipfilter_short_names[] = {
+ "nearest",
+ "linear",
+ "none"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_mipfilter)
+
+
+static const char *
+debug_dump_tex_filter_names[] = {
+ "PIPE_TEX_FILTER_NEAREST",
+ "PIPE_TEX_FILTER_LINEAR"
+};
+
+static const char *
+debug_dump_tex_filter_short_names[] = {
+ "nearest",
+ "linear"
+};
+
+DEFINE_DEBUG_DUMP_CONTINUOUS(tex_filter)
diff --git a/src/gallium/auxiliary/util/u_debug_dump.h b/src/gallium/auxiliary/util/u_debug_dump.h
index 102935559c..19b130ad18 100644
--- a/src/gallium/auxiliary/util/u_debug_dump.h
+++ b/src/gallium/auxiliary/util/u_debug_dump.h
@@ -54,6 +54,18 @@ debug_dump_blend_func(unsigned value, boolean shortened);
const char *
debug_dump_func(unsigned value, boolean shortened);
+const char *
+debug_dump_tex_target(unsigned value, boolean shortened);
+
+const char *
+debug_dump_tex_wrap(unsigned value, boolean shortened);
+
+const char *
+debug_dump_tex_mipfilter(unsigned value, boolean shortened);
+
+const char *
+debug_dump_tex_filter(unsigned value, boolean shortened);
+
/* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */
diff --git a/src/gallium/auxiliary/util/u_debug_memory.c b/src/gallium/auxiliary/util/u_debug_memory.c
index 7623cb9398..d6484f4ad5 100644
--- a/src/gallium/auxiliary/util/u_debug_memory.c
+++ b/src/gallium/auxiliary/util/u_debug_memory.c
@@ -297,9 +297,9 @@ debug_memory_end(unsigned long start_no)
if((start_no <= hdr->no && hdr->no < last_no) ||
(last_no < start_no && (hdr->no < last_no || start_no <= hdr->no))) {
- debug_printf("%s:%u:%s: %u bytes at %p not freed\n",
+ debug_printf("%s:%u:%s: %lu bytes at %p not freed\n",
hdr->file, hdr->line, hdr->function,
- hdr->size, ptr);
+ (unsigned long) hdr->size, ptr);
#if DEBUG_MEMORY_STACK
debug_backtrace_dump(hdr->backtrace, DEBUG_MEMORY_STACK);
#endif
@@ -315,8 +315,8 @@ debug_memory_end(unsigned long start_no)
}
if(total_size) {
- debug_printf("Total of %u KB of system memory apparently leaked\n",
- (total_size + 1023)/1024);
+ debug_printf("Total of %lu KB of system memory apparently leaked\n",
+ (unsigned long) (total_size + 1023)/1024);
}
else {
debug_printf("No memory leaks detected.\n");
diff --git a/src/gallium/auxiliary/util/u_debug_profile.c b/src/gallium/auxiliary/util/u_debug_profile.c
deleted file mode 100644
index d765b50144..0000000000
--- a/src/gallium/auxiliary/util/u_debug_profile.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * @file
- * Poor-man profiling.
- *
- * @author José Fonseca <jrfonseca@tungstengraphics.com>
- *
- * @sa http://blogs.msdn.com/joshpoley/archive/2008/03/12/poor-man-s-profiler.aspx
- * @sa http://www.johnpanzer.com/aci_cuj/index.html
- */
-
-#include "pipe/p_config.h"
-
-#if defined(PROFILE) && defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-#include <windows.h>
-#include <winddi.h>
-
-#include "util/u_debug.h"
-#include "util/u_string.h"
-
-
-#define PROFILE_TABLE_SIZE (1024*1024)
-#define FILE_NAME_SIZE 256
-
-struct debug_profile_entry
-{
- uintptr_t caller;
- uintptr_t callee;
- uint64_t samples;
-};
-
-static unsigned long enabled = 0;
-
-static WCHAR wFileName[FILE_NAME_SIZE] = L"\\??\\c:\\00000000.prof";
-static ULONG_PTR iFile = 0;
-
-static struct debug_profile_entry *table = NULL;
-static unsigned long free_table_entries = 0;
-static unsigned long max_table_entries = 0;
-
-uint64_t start_stamp = 0;
-uint64_t end_stamp = 0;
-
-
-static void
-debug_profile_entry(uintptr_t caller, uintptr_t callee, uint64_t samples)
-{
- unsigned hash = ( caller + callee ) & PROFILE_TABLE_SIZE - 1;
-
- while(1) {
- if(table[hash].caller == 0 && table[hash].callee == 0) {
- table[hash].caller = caller;
- table[hash].callee = callee;
- table[hash].samples = samples;
- --free_table_entries;
- break;
- }
- else if(table[hash].caller == caller && table[hash].callee == callee) {
- table[hash].samples += samples;
- break;
- }
- else {
- ++hash;
- }
- }
-}
-
-
-static uintptr_t caller_stack[1024];
-static unsigned last_caller = 0;
-
-
-static int64_t delta(void) {
- int64_t result = end_stamp - start_stamp;
- if(result > UINT64_C(0xffffffff))
- result = 0;
- return result;
-}
-
-
-static void __cdecl
-debug_profile_enter(uintptr_t callee)
-{
- uintptr_t caller = last_caller ? caller_stack[last_caller - 1] : 0;
-
- if (caller)
- debug_profile_entry(caller, 0, delta());
- debug_profile_entry(caller, callee, 1);
- caller_stack[last_caller++] = callee;
-}
-
-
-static void __cdecl
-debug_profile_exit(uintptr_t callee)
-{
- debug_profile_entry(callee, 0, delta());
- if(last_caller)
- --last_caller;
-}
-
-
-/**
- * Called at the start of every method or function.
- *
- * @sa http://msdn.microsoft.com/en-us/library/c63a9b7h.aspx
- */
-void __declspec(naked) __cdecl
-_penter(void) {
- _asm {
- push eax
- mov eax, [enabled]
- test eax, eax
- jz skip
-
- push edx
-
- rdtsc
- mov dword ptr [end_stamp], eax
- mov dword ptr [end_stamp+4], edx
-
- xor eax, eax
- mov [enabled], eax
-
- mov eax, [esp+8]
-
- push ebx
- push ecx
- push ebp
- push edi
- push esi
-
- push eax
- call debug_profile_enter
- add esp, 4
-
- pop esi
- pop edi
- pop ebp
- pop ecx
- pop ebx
-
- mov eax, 1
- mov [enabled], eax
-
- rdtsc
- mov dword ptr [start_stamp], eax
- mov dword ptr [start_stamp+4], edx
-
- pop edx
-skip:
- pop eax
- ret
- }
-}
-
-
-/**
- * Called at the end of Calls the end of every method or function.
- *
- * @sa http://msdn.microsoft.com/en-us/library/xc11y76y.aspx
- */
-void __declspec(naked) __cdecl
-_pexit(void) {
- _asm {
- push eax
- mov eax, [enabled]
- test eax, eax
- jz skip
-
- push edx
-
- rdtsc
- mov dword ptr [end_stamp], eax
- mov dword ptr [end_stamp+4], edx
-
- xor eax, eax
- mov [enabled], eax
-
- mov eax, [esp+8]
-
- push ebx
- push ecx
- push ebp
- push edi
- push esi
-
- push eax
- call debug_profile_exit
- add esp, 4
-
- pop esi
- pop edi
- pop ebp
- pop ecx
- pop ebx
-
- mov eax, 1
- mov [enabled], eax
-
- rdtsc
- mov dword ptr [start_stamp], eax
- mov dword ptr [start_stamp+4], edx
-
- pop edx
-skip:
- pop eax
- ret
- }
-}
-
-
-/**
- * Reference function for calibration.
- */
-void __declspec(naked)
-__debug_profile_reference(void) {
- _asm {
- call _penter
- call _pexit
- ret
- }
-}
-
-
-void
-debug_profile_start(void)
-{
- WCHAR *p;
-
- /* increment starting from the less significant digit */
- p = &wFileName[14];
- while(1) {
- if(*p == '9') {
- *p-- = '0';
- }
- else {
- *p += 1;
- break;
- }
- }
-
- table = EngMapFile(wFileName,
- PROFILE_TABLE_SIZE*sizeof(struct debug_profile_entry),
- &iFile);
- if(table) {
- unsigned i;
-
- free_table_entries = max_table_entries = PROFILE_TABLE_SIZE;
- memset(table, 0, PROFILE_TABLE_SIZE*sizeof(struct debug_profile_entry));
-
- table[0].caller = (uintptr_t)&__debug_profile_reference;
- table[0].callee = 0;
- table[0].samples = 0;
- --free_table_entries;
-
- _asm {
- push edx
- push eax
-
- rdtsc
- mov dword ptr [start_stamp], eax
- mov dword ptr [start_stamp+4], edx
-
- pop edx
- pop eax
- }
-
- last_caller = 0;
-
- enabled = 1;
-
- for(i = 0; i < 8; ++i) {
- _asm {
- call __debug_profile_reference
- }
- }
- }
-}
-
-
-void
-debug_profile_stop(void)
-{
- enabled = 0;
-
- if(iFile)
- EngUnmapFile(iFile);
- iFile = 0;
- table = NULL;
- free_table_entries = max_table_entries = 0;
-}
-
-#endif /* PROFILE */
diff --git a/src/gallium/auxiliary/util/u_dl.c b/src/gallium/auxiliary/util/u_dl.c
new file mode 100644
index 0000000000..b42b429d4d
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_dl.c
@@ -0,0 +1,79 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * Copyright 1999-2008 Brian Paul
+ * 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.
+ *
+ **************************************************************************/
+
+
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_UNIX)
+#include <dlfcn.h>
+#endif
+#if defined(PIPE_OS_WINDOWS)
+#include <windows.h>
+#endif
+
+#include "u_dl.h"
+
+
+struct util_dl_library *
+util_dl_open(const char *filename)
+{
+#if defined(PIPE_OS_UNIX)
+ return (struct util_dl_library *)dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
+#elif defined(PIPE_OS_WINDOWS)
+ return (struct util_dl_library *)LoadLibraryA(filename);
+#else
+ return NULL;
+#endif
+}
+
+
+util_dl_proc
+util_dl_get_proc_address(struct util_dl_library *library,
+ const char *procname)
+{
+#if defined(PIPE_OS_UNIX)
+ return (util_dl_proc)dlsym((void *)library, procname);
+#elif defined(PIPE_OS_WINDOWS)
+ return (util_dl_proc)GetProcAddress((HMODULE)library, procname);
+#else
+ return (util_dl_proc)NULL;
+#endif
+}
+
+
+void
+util_dl_close(struct util_dl_library *library)
+{
+#if defined(PIPE_OS_UNIX)
+ dlclose((void *)library);
+#elif defined(PIPE_OS_WINDOWS)
+ FreeLibrary((HMODULE)library);
+#else
+ (void)library;
+#endif
+}
diff --git a/src/gallium/auxiliary/util/u_dl.h b/src/gallium/auxiliary/util/u_dl.h
new file mode 100644
index 0000000000..85296c58af
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_dl.h
@@ -0,0 +1,73 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE 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 U_DL_H_
+#define U_DL_H_
+
+
+#include "pipe/p_config.h"
+
+
+#if defined(PIPE_OS_WINDOWS)
+# define UTIL_DL_EXT ".dll"
+#elif defined(PIPE_OS_APPLE)
+# define UTIL_DL_EXT ".dylib"
+#else
+# define UTIL_DL_EXT ".so"
+#endif
+
+
+struct util_dl_library;
+
+
+typedef void (*util_dl_proc)(void);
+
+
+/**
+ * Open a library dynamically.
+ */
+struct util_dl_library *
+util_dl_open(const char *filename);
+
+
+/**
+ * Lookup a function in a library.
+ */
+util_dl_proc
+util_dl_get_proc_address(struct util_dl_library *library,
+ const char *procname);
+
+
+/**
+ * Close a library.
+ */
+void
+util_dl_close(struct util_dl_library *library);
+
+
+#endif /* U_DL_H_ */
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index 98ea13b60b..e0724a1a8b 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -32,15 +32,14 @@
const struct util_format_description *
util_format_description(enum pipe_format format)
{
- const struct util_format_description *desc = util_format_description_table;
+ const struct util_format_description *desc;
- while(TRUE) {
- if(desc->format == format)
- return desc;
+ if (format >= PIPE_FORMAT_COUNT) {
+ return NULL;
+ }
- if(desc->format == PIPE_FORMAT_NONE)
- return NULL;
+ desc = &util_format_description_table[format];
+ assert(desc->format == format);
- ++desc;
- };
+ return desc;
}
diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv
index f1bf94f17d..9f16b42944 100644
--- a/src/gallium/auxiliary/util/u_format.csv
+++ b/src/gallium/auxiliary/util/u_format.csv
@@ -11,6 +11,8 @@ PIPE_FORMAT_A8_UNORM , arith , 1, 1, un8 , , , , 000x,
PIPE_FORMAT_I8_UNORM , arith , 1, 1, un8 , , , , xxxx, rgb
PIPE_FORMAT_A8L8_UNORM , arith , 1, 1, un8 , un8 , , , xxxy, rgb
PIPE_FORMAT_L16_UNORM , arith , 1, 1, un16, , , , xxx1, rgb
+PIPE_FORMAT_YCBCR , yuv , 2, 1, x32 , , , , xyz1, yuv
+PIPE_FORMAT_YCBCR_REV , yuv , 2, 1, x32 , , , , xyz1, yuv
PIPE_FORMAT_Z16_UNORM , array , 1, 1, un16, , , , x___, zs
PIPE_FORMAT_Z32_UNORM , array , 1, 1, un32, , , , x___, zs
PIPE_FORMAT_Z32_FLOAT , array , 1, 1, f32 , , , , x___, zs
@@ -74,9 +76,9 @@ PIPE_FORMAT_R8G8_SNORM , array , 1, 1, sn8 , sn8 , , , xy01,
PIPE_FORMAT_R8G8B8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb
PIPE_FORMAT_R8G8B8A8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb
PIPE_FORMAT_R8G8B8X8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb
-PIPE_FORMAT_B6G5R5_SNORM , arith , 1, 1, sn5 , sn5 , sn6 , , zyx1, rgb
-PIPE_FORMAT_A8B8G8R8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , zyxw, rgb
-PIPE_FORMAT_X8B8G8R8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , zyx1, rgb
+PIPE_FORMAT_B6G5R5_SNORM , arith , 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb
+PIPE_FORMAT_A8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb
+PIPE_FORMAT_X8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb
PIPE_FORMAT_R8_SSCALED , array , 1, 1, s8 , , , , x001, rgb
PIPE_FORMAT_R8G8_SSCALED , array , 1, 1, s8 , s8 , , , xy01, rgb
PIPE_FORMAT_R8G8B8_SSCALED , array , 1, 1, s8 , s8 , s8 , , xyz1, rgb
@@ -88,12 +90,20 @@ PIPE_FORMAT_R32G32B32_FIXED , array , 1, 1, h32 , h32 , h32 , , xyz1,
PIPE_FORMAT_R32G32B32A32_FIXED , array , 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb
PIPE_FORMAT_L8_SRGB , arith , 1, 1, u8 , , , , xxx1, srgb
PIPE_FORMAT_A8L8_SRGB , arith , 1, 1, u8 , u8 , , , xxxy, srgb
-PIPE_FORMAT_R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , , xyz1, srgb
-PIPE_FORMAT_R8G8B8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , xyzw, srgb
-PIPE_FORMAT_R8G8B8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , xyz1, srgb
-PIPE_FORMAT_A8R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , wxyz, srgb
-PIPE_FORMAT_X8R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , 1xyz, srgb
-PIPE_FORMAT_B8G8R8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb
-PIPE_FORMAT_B8G8R8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb
-PIPE_FORMAT_X8UB8UG8SR8S_NORM , arith , 1, 1, sn8 , sn8 , un8 , x8 , 1zyx, rgb
+PIPE_FORMAT_R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , , xyz1, srgb
+PIPE_FORMAT_R8G8B8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, srgb
+PIPE_FORMAT_R8G8B8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, srgb
+PIPE_FORMAT_A8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb
+PIPE_FORMAT_X8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb
+PIPE_FORMAT_B8G8R8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb
+PIPE_FORMAT_B8G8R8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb
+PIPE_FORMAT_X8UB8UG8SR8S_NORM , array , 1, 1, sn8 , sn8 , un8 , x8 , wzy1, rgb
PIPE_FORMAT_B6UG5SR5S_NORM , arith , 1, 1, sn5 , sn5 , un6 , , xyz1, rgb
+PIPE_FORMAT_DXT1_RGB , dxt , 4, 4, x64 , , , , xyz1, rgb
+PIPE_FORMAT_DXT1_RGBA , dxt , 4, 4, x64 , , , , xyzw, rgb
+PIPE_FORMAT_DXT3_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb
+PIPE_FORMAT_DXT5_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb
+PIPE_FORMAT_DXT1_SRGB , dxt , 4, 4, x64 , , , , xyz1, srgb
+PIPE_FORMAT_DXT1_SRGBA , dxt , 4, 4, x64 , , , , xyzw, srgb
+PIPE_FORMAT_DXT3_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb
+PIPE_FORMAT_DXT5_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 7b5b7fcda5..a558923b2e 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -32,11 +32,51 @@
#include "pipe/p_format.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Describe how to best pack/unpack pixels into/from the prescribed format.
+ *
+ * These are used for automatic code generation of pixel packing and unpacking
+ * routines (in compile time, e.g., u_format_access.py, or in runtime, like
+ * llvmpipe does).
+ *
+ * Thumb rule is: if you're not code generating pixel packing/unpacking then
+ * these are irrelevant for you.
+ *
+ * Note that this can be deduced from other values in util_format_description
+ * structure. This is by design, to make code generation of pixel
+ * packing/unpacking/sampling routines simple and efficient.
+ *
+ * XXX: This should be renamed to something like util_format_pack.
+ */
enum util_format_layout {
+ /**
+ * Single scalar component.
+ */
UTIL_FORMAT_LAYOUT_SCALAR = 0,
+
+ /**
+ * One or more components of mixed integer formats, arithmetically encoded
+ * in a word up to 32bits.
+ */
UTIL_FORMAT_LAYOUT_ARITH = 1,
+
+ /**
+ * One or more components, no mixed formats, each with equal power of two
+ * number of bytes.
+ */
UTIL_FORMAT_LAYOUT_ARRAY = 2,
+
+ /**
+ * XXX: Not used yet. These might go away and be replaced by a single entry,
+ * for formats where multiple pixels have to be
+ * read in order to determine a single pixel value (i.e., block.width > 1
+ * || block.height > 1)
+ */
UTIL_FORMAT_LAYOUT_YUV = 3,
UTIL_FORMAT_LAYOUT_DXT = 4
};
@@ -50,7 +90,7 @@ struct util_format_block
/** Block height in pixels */
unsigned height;
- /** Block size in bytes */
+ /** Block size in bits */
unsigned bits;
};
@@ -79,7 +119,7 @@ enum util_format_colorspace {
UTIL_FORMAT_COLORSPACE_RGB = 0,
UTIL_FORMAT_COLORSPACE_SRGB = 1,
UTIL_FORMAT_COLORSPACE_YUV = 2,
- UTIL_FORMAT_COLORSPACE_ZS = 3,
+ UTIL_FORMAT_COLORSPACE_ZS = 3
};
@@ -111,6 +151,250 @@ const struct util_format_description *
util_format_description(enum pipe_format format);
+/*
+ * Format query functions.
+ */
+
+static INLINE boolean
+util_format_is_compressed(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return FALSE;
+ }
+
+ return desc->layout == UTIL_FORMAT_LAYOUT_DXT ? TRUE : FALSE;
+}
+
+static INLINE boolean
+util_format_is_depth_or_stencil(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return FALSE;
+ }
+
+ return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ? TRUE : FALSE;
+}
+
+static INLINE boolean
+util_format_is_depth_and_stencil(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return FALSE;
+ }
+
+ if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) {
+ return FALSE;
+ }
+
+ return (desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE &&
+ desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
+}
+
+
+/**
+ * Return total bits needed for the pixel format per block.
+ */
+static INLINE uint
+util_format_get_blocksizebits(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return 0;
+ }
+
+ return desc->block.bits;
+}
+
+/**
+ * Return bytes per block (not pixel) for the given format.
+ */
+static INLINE uint
+util_format_get_blocksize(enum pipe_format format)
+{
+ uint bits = util_format_get_blocksizebits(format);
+
+ assert(bits % 8 == 0);
+
+ return bits / 8;
+}
+
+static INLINE uint
+util_format_get_blockwidth(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return 1;
+ }
+
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_YUV:
+ return 2;
+ case UTIL_FORMAT_LAYOUT_DXT:
+ return 4;
+ default:
+ return 1;
+ }
+}
+
+static INLINE uint
+util_format_get_blockheight(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return 1;
+ }
+
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_DXT:
+ return 4;
+ default:
+ return 1;
+ }
+}
+
+static INLINE unsigned
+util_format_get_nblocksx(enum pipe_format format,
+ unsigned x)
+{
+ unsigned blockwidth = util_format_get_blockwidth(format);
+ return (x + blockwidth - 1) / blockwidth;
+}
+
+static INLINE unsigned
+util_format_get_nblocksy(enum pipe_format format,
+ unsigned y)
+{
+ unsigned blockheight = util_format_get_blockheight(format);
+ return (y + blockheight - 1) / blockheight;
+}
+
+static INLINE unsigned
+util_format_get_nblocks(enum pipe_format format,
+ unsigned width,
+ unsigned height)
+{
+ return util_format_get_nblocksx(format, width) * util_format_get_nblocksy(format, height);
+}
+
+static INLINE size_t
+util_format_get_stride(enum pipe_format format,
+ unsigned width)
+{
+ return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
+}
+
+static INLINE size_t
+util_format_get_2d_size(enum pipe_format format,
+ size_t stride,
+ unsigned height)
+{
+ return util_format_get_nblocksy(format, height) * stride;
+}
+
+static INLINE uint
+util_format_get_component_bits(enum pipe_format format,
+ enum util_format_colorspace colorspace,
+ uint component)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ enum util_format_colorspace desc_colorspace;
+
+ assert(format);
+ if (!format) {
+ return 0;
+ }
+
+ assert(component < 4);
+
+ /* Treat RGB and SRGB as equivalent. */
+ if (colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+ colorspace = UTIL_FORMAT_COLORSPACE_RGB;
+ }
+ if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+ desc_colorspace = UTIL_FORMAT_COLORSPACE_RGB;
+ } else {
+ desc_colorspace = desc->colorspace;
+ }
+
+ if (desc_colorspace != colorspace) {
+ return 0;
+ }
+
+ switch (desc->swizzle[component]) {
+ case UTIL_FORMAT_SWIZZLE_X:
+ return desc->channel[0].size;
+ case UTIL_FORMAT_SWIZZLE_Y:
+ return desc->channel[1].size;
+ case UTIL_FORMAT_SWIZZLE_Z:
+ return desc->channel[2].size;
+ case UTIL_FORMAT_SWIZZLE_W:
+ return desc->channel[3].size;
+ default:
+ return 0;
+ }
+}
+
+static INLINE boolean
+util_format_has_alpha(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return FALSE;
+ }
+
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_SCALAR:
+ case UTIL_FORMAT_LAYOUT_ARITH:
+ case UTIL_FORMAT_LAYOUT_ARRAY:
+ /* FIXME: pf_get_component_bits( PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_COMP_A ) should not return 0 right? */
+ if (format == PIPE_FORMAT_A8_UNORM ||
+ format == PIPE_FORMAT_A8L8_UNORM ||
+ format == PIPE_FORMAT_A8L8_SRGB) {
+ return TRUE;
+ }
+ return util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) != 0;
+ case UTIL_FORMAT_LAYOUT_YUV:
+ return FALSE;
+ case UTIL_FORMAT_LAYOUT_DXT:
+ switch (format) {
+ case PIPE_FORMAT_DXT1_RGBA:
+ case PIPE_FORMAT_DXT3_RGBA:
+ case PIPE_FORMAT_DXT5_RGBA:
+ case PIPE_FORMAT_DXT1_SRGBA:
+ case PIPE_FORMAT_DXT3_SRGBA:
+ case PIPE_FORMAT_DXT5_SRGBA:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ default:
+ assert(0);
+ return FALSE;
+ }
+}
+
+
+/*
+ * Format access functions.
+ */
+
void
util_format_read_4f(enum pipe_format format,
float *dst, unsigned dst_stride,
@@ -135,4 +419,8 @@ util_format_write_4ub(enum pipe_format format,
void *dst, unsigned dst_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
+#ifdef __cplusplus
+} // extern "C" {
+#endif
+
#endif /* ! U_FORMAT_H */
diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py
index eeb1a9657f..0b05ddb931 100644
--- a/src/gallium/auxiliary/util/u_format_access.py
+++ b/src/gallium/auxiliary/util/u_format_access.py
@@ -325,14 +325,14 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix):
elif swizzle == SWIZZLE_0:
value = '0'
elif swizzle == SWIZZLE_1:
- value = '1'
+ value = get_one(dst_type)
else:
assert False
elif format.colorspace == 'zs':
if i < 3:
value = 'z'
else:
- value = '1'
+ value = get_one(dst_type)
else:
assert False
print ' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index 8834568e8e..571cab55dc 100755
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -44,11 +44,10 @@ def colorspace_map(colorspace):
colorspace_channels_map = {
- 'rgb': 'rgba',
- 'rgba': 'rgba',
- 'zs': 'zs',
- 'yuv': ['y1', 'y2', 'u', 'v'],
- 'dxt': []
+ 'rgb': ['r', 'g', 'b', 'a'],
+ 'srgb': ['sr', 'sg', 'sb', 'a'],
+ 'zs': ['z', 's'],
+ 'yuv': ['y', 'u', 'v'],
}
@@ -90,11 +89,20 @@ def write_format_table(formats):
print 'const struct util_format_description'
print 'util_format_description_table[] = '
print "{"
+ print " {"
+ print " PIPE_FORMAT_NONE,"
+ print " \"PIPE_FORMAT_NONE\","
+ print " {0, 0, 0},"
+ print " 0,"
+ print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
+ print " {0, 0, 0, 0},"
+ print " 0"
+ print " },"
for format in formats:
print " {"
print " %s," % (format.name,)
print " \"%s\"," % (format.name,)
- print " {%u, %u, %u}, /* block */" % (format.block_width, format.block_height, format.block_size())
+ print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
print " %s," % (layout_map(format.layout),)
print " {"
for i in range(4):
@@ -103,7 +111,7 @@ def write_format_table(formats):
sep = ","
else:
sep = ""
- print " {%s, %s, %u}%s /* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i])
+ print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i])
print " },"
print " {"
for i in range(4):
@@ -113,22 +121,13 @@ def write_format_table(formats):
else:
sep = ""
try:
- comment = layout_channels_map[format.layout][i]
- except:
+ comment = colorspace_channels_map[format.colorspace][i]
+ except (KeyError, IndexError):
comment = 'ignored'
- print " %s%s /* %s */" % (swizzle_map[swizzle], sep, comment)
+ print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
print " },"
print " %s," % (colorspace_map(format.colorspace),)
print " },"
- print " {"
- print " PIPE_FORMAT_NONE,"
- print " \"PIPE_FORMAT_NONE\","
- print " {0, 0, 0},"
- print " 0,"
- print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
- print " {0, 0, 0, 0},"
- print " 0"
- print " },"
print "};"
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index aa823aa218..76023794dc 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -41,10 +41,13 @@
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_draw_quad.h"
#include "util/u_gen_mipmap.h"
#include "util/u_simple_shaders.h"
+#include "util/u_math.h"
+#include "util/u_texture.h"
#include "cso_cache/cso_context.h"
@@ -60,7 +63,7 @@ struct gen_mipmap_state
struct pipe_sampler_state sampler;
void *vs;
- void *fs;
+ void *fs2d, *fsCube;
struct pipe_buffer *vbuf; /**< quad vertices */
unsigned vbuf_slot;
@@ -995,7 +998,7 @@ reduce_2d(enum pipe_format pformat,
{
enum dtype datatype;
uint comps;
- const int bpt = pf_get_size(pformat);
+ const int bpt = util_format_get_blocksize(pformat);
const ubyte *srcA, *srcB;
ubyte *dst;
int row;
@@ -1034,7 +1037,7 @@ reduce_3d(enum pipe_format pformat,
int dstWidth, int dstHeight, int dstDepth,
int dstRowStride, ubyte *dstPtr)
{
- const int bpt = pf_get_size(pformat);
+ const int bpt = util_format_get_blocksize(pformat);
const int border = 0;
int img, row;
int bytesPerSrcImage, bytesPerDstImage;
@@ -1125,12 +1128,12 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
- pt->width[srcLevel],
- pt->height[srcLevel]);
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel));
dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
- pt->width[dstLevel],
- pt->height[dstLevel]);
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel));
srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
@@ -1158,8 +1161,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
const uint zslice = 0;
uint dstLevel;
- assert(pt->block.width == 1);
- assert(pt->block.height == 1);
+ assert(util_format_get_blockwidth(pt->format) == 1);
+ assert(util_format_get_blockheight(pt->format) == 1);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
@@ -1168,12 +1171,12 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
- pt->width[srcLevel],
- pt->height[srcLevel]);
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel));
dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
- pt->width[dstLevel],
- pt->height[dstLevel]);
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel));
srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
@@ -1203,8 +1206,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice = 0;
- assert(pt->block.width == 1);
- assert(pt->block.height == 1);
+ assert(util_format_get_blockwidth(pt->format) == 1);
+ assert(util_format_get_blockheight(pt->format) == 1);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
@@ -1213,12 +1216,12 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
- pt->width[srcLevel],
- pt->height[srcLevel]);
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel));
dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
- pt->width[dstLevel],
- pt->height[dstLevel]);
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel));
srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
@@ -1316,7 +1319,8 @@ util_create_gen_mipmap(struct pipe_context *pipe,
}
/* fragment shader */
- ctx->fs = util_make_fragment_tex_shader(pipe);
+ ctx->fs2d = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
+ ctx->fsCube = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
/* vertex data that doesn't change */
for (i = 0; i < 4; i++) {
@@ -1382,59 +1386,9 @@ set_vertex_data(struct gen_mipmap_state *ctx,
static const float st[4][2] = {
{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
};
- float rx, ry, rz;
- uint i;
-
- /* loop over quad verts */
- for (i = 0; i < 4; i++) {
- /* Compute sc = +/-scale and tc = +/-scale.
- * Not +/-1 to avoid cube face selection ambiguity near the edges,
- * though that can still sometimes happen with this scale factor...
- */
- const float scale = 0.9999f;
- const float sc = (2.0f * st[i][0] - 1.0f) * scale;
- const float tc = (2.0f * st[i][1] - 1.0f) * scale;
-
- switch (face) {
- case PIPE_TEX_FACE_POS_X:
- rx = 1.0f;
- ry = -tc;
- rz = -sc;
- break;
- case PIPE_TEX_FACE_NEG_X:
- rx = -1.0f;
- ry = -tc;
- rz = sc;
- break;
- case PIPE_TEX_FACE_POS_Y:
- rx = sc;
- ry = 1.0f;
- rz = tc;
- break;
- case PIPE_TEX_FACE_NEG_Y:
- rx = sc;
- ry = -1.0f;
- rz = -tc;
- break;
- case PIPE_TEX_FACE_POS_Z:
- rx = sc;
- ry = -tc;
- rz = 1.0f;
- break;
- case PIPE_TEX_FACE_NEG_Z:
- rx = -sc;
- ry = -tc;
- rz = -1.0f;
- break;
- default:
- rx = ry = rz = 0.0f;
- assert(0);
- }
- ctx->vertices[i][1][0] = rx; /*s*/
- ctx->vertices[i][1][1] = ry; /*t*/
- ctx->vertices[i][1][2] = rz; /*r*/
- }
+ util_map_texcoords2d_onto_cubemap(face, &st[0][0], 2,
+ &ctx->vertices[0][1][0], 8);
}
else {
/* 1D/2D */
@@ -1474,7 +1428,8 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
struct pipe_context *pipe = ctx->pipe;
pipe->delete_vs_state(pipe, ctx->vs);
- pipe->delete_fs_state(pipe, ctx->fs);
+ pipe->delete_fs_state(pipe, ctx->fs2d);
+ pipe->delete_fs_state(pipe, ctx->fsCube);
pipe_buffer_reference(&ctx->vbuf, NULL);
@@ -1512,6 +1467,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_framebuffer_state fb;
+ void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d;
uint dstLevel;
uint zslice = 0;
uint offset;
@@ -1549,7 +1505,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
- cso_set_fragment_shader_handle(ctx->cso, ctx->fs);
+ cso_set_fragment_shader_handle(ctx->cso, fs);
cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
/* init framebuffer state */
@@ -1575,8 +1531,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
* Setup framebuffer / dest surface
*/
fb.cbufs[0] = surf;
- fb.width = pt->width[dstLevel];
- fb.height = pt->height[dstLevel];
+ fb.width = u_minify(pt->width0, dstLevel);
+ fb.height = u_minify(pt->height0, dstLevel);
cso_set_framebuffer(ctx->cso, &fb);
/*
@@ -1597,8 +1553,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
offset = set_vertex_data(ctx,
pt->target,
face,
- (float) pt->width[dstLevel],
- (float) pt->height[dstLevel]);
+ (float) u_minify(pt->width0, dstLevel),
+ (float) u_minify(pt->height0, dstLevel));
util_draw_vertex_buffer(ctx->pipe,
ctx->vbuf,
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c
index 8c2a8f454c..5604e3ac37 100644
--- a/src/gallium/auxiliary/util/u_hash_table.c
+++ b/src/gallium/auxiliary/util/u_hash_table.c
@@ -47,7 +47,7 @@
#include "util/u_hash_table.h"
-struct hash_table
+struct util_hash_table
{
struct cso_hash *cso;
@@ -61,27 +61,27 @@ struct hash_table
};
-struct hash_table_item
+struct util_hash_table_item
{
void *key;
void *value;
};
-static INLINE struct hash_table_item *
-hash_table_item(struct cso_hash_iter iter)
+static INLINE struct util_hash_table_item *
+util_hash_table_item(struct cso_hash_iter iter)
{
- return (struct hash_table_item *)cso_hash_iter_data(iter);
+ return (struct util_hash_table_item *)cso_hash_iter_data(iter);
}
-struct hash_table *
-hash_table_create(unsigned (*hash)(void *key),
- int (*compare)(void *key1, void *key2))
+struct util_hash_table *
+util_hash_table_create(unsigned (*hash)(void *key),
+ int (*compare)(void *key1, void *key2))
{
- struct hash_table *ht;
+ struct util_hash_table *ht;
- ht = MALLOC_STRUCT(hash_table);
+ ht = MALLOC_STRUCT(util_hash_table);
if(!ht)
return NULL;
@@ -99,16 +99,16 @@ hash_table_create(unsigned (*hash)(void *key),
static INLINE struct cso_hash_iter
-hash_table_find_iter(struct hash_table *ht,
- void *key,
- unsigned key_hash)
+util_hash_table_find_iter(struct util_hash_table *ht,
+ void *key,
+ unsigned key_hash)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
iter = cso_hash_find(ht->cso, key_hash);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
if (!ht->compare(item->key, key))
break;
iter = cso_hash_iter_next(iter);
@@ -118,17 +118,17 @@ hash_table_find_iter(struct hash_table *ht,
}
-static INLINE struct hash_table_item *
-hash_table_find_item(struct hash_table *ht,
- void *key,
- unsigned key_hash)
+static INLINE struct util_hash_table_item *
+util_hash_table_find_item(struct util_hash_table *ht,
+ void *key,
+ unsigned key_hash)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
iter = cso_hash_find(ht->cso, key_hash);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
if (!ht->compare(item->key, key))
return item;
iter = cso_hash_iter_next(iter);
@@ -139,12 +139,12 @@ hash_table_find_item(struct hash_table *ht,
enum pipe_error
-hash_table_set(struct hash_table *ht,
- void *key,
- void *value)
+util_hash_table_set(struct util_hash_table *ht,
+ void *key,
+ void *value)
{
unsigned key_hash;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
struct cso_hash_iter iter;
assert(ht);
@@ -153,14 +153,14 @@ hash_table_set(struct hash_table *ht,
key_hash = ht->hash(key);
- item = hash_table_find_item(ht, key, key_hash);
+ item = util_hash_table_find_item(ht, key, key_hash);
if(item) {
/* TODO: key/value destruction? */
item->value = value;
return PIPE_OK;
}
- item = MALLOC_STRUCT(hash_table_item);
+ item = MALLOC_STRUCT(util_hash_table_item);
if(!item)
return PIPE_ERROR_OUT_OF_MEMORY;
@@ -178,11 +178,11 @@ hash_table_set(struct hash_table *ht,
void *
-hash_table_get(struct hash_table *ht,
- void *key)
+util_hash_table_get(struct util_hash_table *ht,
+ void *key)
{
unsigned key_hash;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -190,7 +190,7 @@ hash_table_get(struct hash_table *ht,
key_hash = ht->hash(key);
- item = hash_table_find_item(ht, key, key_hash);
+ item = util_hash_table_find_item(ht, key, key_hash);
if(!item)
return NULL;
@@ -199,12 +199,12 @@ hash_table_get(struct hash_table *ht,
void
-hash_table_remove(struct hash_table *ht,
- void *key)
+util_hash_table_remove(struct util_hash_table *ht,
+ void *key)
{
unsigned key_hash;
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -212,11 +212,11 @@ hash_table_remove(struct hash_table *ht,
key_hash = ht->hash(key);
- iter = hash_table_find_iter(ht, key, key_hash);
+ iter = util_hash_table_find_iter(ht, key, key_hash);
if(cso_hash_iter_is_null(iter))
return;
- item = hash_table_item(iter);
+ item = util_hash_table_item(iter);
assert(item);
FREE(item);
@@ -225,10 +225,10 @@ hash_table_remove(struct hash_table *ht,
void
-hash_table_clear(struct hash_table *ht)
+util_hash_table_clear(struct util_hash_table *ht)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -236,7 +236,7 @@ hash_table_clear(struct hash_table *ht)
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter));
+ item = (struct util_hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter));
FREE(item);
iter = cso_hash_first_node(ht->cso);
}
@@ -244,12 +244,13 @@ hash_table_clear(struct hash_table *ht)
enum pipe_error
-hash_table_foreach(struct hash_table *ht,
- enum pipe_error (*callback)(void *key, void *value, void *data),
- void *data)
+util_hash_table_foreach(struct util_hash_table *ht,
+ enum pipe_error (*callback)
+ (void *key, void *value, void *data),
+ void *data)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
enum pipe_error result;
assert(ht);
@@ -258,7 +259,7 @@ hash_table_foreach(struct hash_table *ht,
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
result = callback(item->key, item->value, data);
if(result != PIPE_OK)
return result;
@@ -270,10 +271,10 @@ hash_table_foreach(struct hash_table *ht,
void
-hash_table_destroy(struct hash_table *ht)
+util_hash_table_destroy(struct util_hash_table *ht)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -281,7 +282,7 @@ hash_table_destroy(struct hash_table *ht)
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
FREE(item);
iter = cso_hash_iter_next(iter);
}
diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h
index feee881582..51ec10a804 100644
--- a/src/gallium/auxiliary/util/u_hash_table.h
+++ b/src/gallium/auxiliary/util/u_hash_table.h
@@ -35,7 +35,7 @@
#define U_HASH_TABLE_H_
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#ifdef __cplusplus
@@ -46,7 +46,7 @@ extern "C" {
/**
* Generic purpose hash table.
*/
-struct hash_table;
+struct util_hash_table;
/**
@@ -55,37 +55,38 @@ struct hash_table;
* @param hash hash function
* @param compare should return 0 for two equal keys.
*/
-struct hash_table *
-hash_table_create(unsigned (*hash)(void *key),
- int (*compare)(void *key1, void *key2));
+struct util_hash_table *
+util_hash_table_create(unsigned (*hash)(void *key),
+ int (*compare)(void *key1, void *key2));
enum pipe_error
-hash_table_set(struct hash_table *ht,
- void *key,
- void *value);
+util_hash_table_set(struct util_hash_table *ht,
+ void *key,
+ void *value);
void *
-hash_table_get(struct hash_table *ht,
- void *key);
+util_hash_table_get(struct util_hash_table *ht,
+ void *key);
void
-hash_table_remove(struct hash_table *ht,
- void *key);
+util_hash_table_remove(struct util_hash_table *ht,
+ void *key);
void
-hash_table_clear(struct hash_table *ht);
+util_hash_table_clear(struct util_hash_table *ht);
enum pipe_error
-hash_table_foreach(struct hash_table *ht,
- enum pipe_error (*callback)(void *key, void *value, void *data),
- void *data);
+util_hash_table_foreach(struct util_hash_table *ht,
+ enum pipe_error (*callback)
+ (void *key, void *value, void *data),
+ void *data);
void
-hash_table_destroy(struct hash_table *ht);
+util_hash_table_destroy(struct util_hash_table *ht);
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/util/u_keymap.c b/src/gallium/auxiliary/util/u_keymap.c
index 508a2ee063..c4b9eb3d9b 100644
--- a/src/gallium/auxiliary/util/u_keymap.c
+++ b/src/gallium/auxiliary/util/u_keymap.c
@@ -28,7 +28,7 @@
/**
* Key lookup/associative container.
*
- * Like Jose's u_hash_table, based on CSO cache code for now.
+ * Like Jose's util_hash_table, based on CSO cache code for now.
*
* Author: Brian Paul
*/
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#include "cso_cache/cso_hash.h"
diff --git a/src/gallium/auxiliary/util/u_linear.c b/src/gallium/auxiliary/util/u_linear.c
index a1dce3f5cf..f1aef21677 100644
--- a/src/gallium/auxiliary/util/u_linear.c
+++ b/src/gallium/auxiliary/util/u_linear.c
@@ -82,7 +82,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
void
pipe_linear_fill_info(struct pipe_tile_info *t,
- const struct pipe_format_block *block,
+ const struct u_linear_format_block *block,
unsigned tile_width, unsigned tile_height,
unsigned tiles_x, unsigned tiles_y)
{
diff --git a/src/gallium/auxiliary/util/u_linear.h b/src/gallium/auxiliary/util/u_linear.h
index b74308ffa3..42c40b2aa7 100644
--- a/src/gallium/auxiliary/util/u_linear.h
+++ b/src/gallium/auxiliary/util/u_linear.h
@@ -35,6 +35,19 @@
#include "pipe/p_format.h"
+struct u_linear_format_block
+{
+ /** Block size in bytes */
+ unsigned size;
+
+ /** Block width in pixels */
+ unsigned width;
+
+ /** Block height in pixels */
+ unsigned height;
+};
+
+
struct pipe_tile_info
{
unsigned size;
@@ -49,10 +62,10 @@ struct pipe_tile_info
unsigned rows;
/* Describe the tile in pixels */
- struct pipe_format_block tile;
+ struct u_linear_format_block tile;
/* Describe each block within the tile */
- struct pipe_format_block block;
+ struct u_linear_format_block block;
};
void pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
@@ -71,7 +84,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
* @tiles_y number of tiles in y axis
*/
void pipe_linear_fill_info(struct pipe_tile_info *t,
- const struct pipe_format_block *block,
+ const struct u_linear_format_block *block,
unsigned tile_width, unsigned tile_height,
unsigned tiles_x, unsigned tiles_y);
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 75b075f160..b2969a210a 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -491,6 +491,47 @@ util_next_power_of_two(unsigned x)
/**
+ * Return number of bits set in n.
+ */
+static INLINE unsigned
+util_bitcount(unsigned n)
+{
+#if defined(PIPE_CC_GCC)
+ return __builtin_popcount(n);
+#else
+ /* K&R classic bitcount.
+ *
+ * For each iteration, clear the LSB from the bitfield.
+ * Requires only one iteration per set bit, instead of
+ * one iteration per bit less than highest set bit.
+ */
+ unsigned bits = 0;
+ for (bits; n; bits++) {
+ n &= n - 1;
+ }
+ return bits;
+#endif
+}
+
+
+/**
+ * Reverse byte order of a 32 bit word.
+ */
+static INLINE uint32_t
+util_bswap32(uint32_t n)
+{
+#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
+ return __builtin_bswap32(n);
+#else
+ return (n >> 24) |
+ ((n >> 8) & 0x0000ff00) |
+ ((n << 8) & 0x00ff0000) |
+ (n << 24);
+#endif
+}
+
+
+/**
* Clamp X to [MIN, MAX].
* This is a macro to allow float, int, uint, etc. types.
*/
@@ -499,6 +540,9 @@ util_next_power_of_two(unsigned x)
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
+#define MIN3( A, B, C ) MIN2( MIN2( A, B ), C )
+#define MAX3( A, B, C ) MAX2( MAX2( A, B ), C )
+
static INLINE int
align(int value, int alignment)
@@ -507,9 +551,9 @@ align(int value, int alignment)
}
static INLINE unsigned
-minify(unsigned value)
+u_minify(unsigned value, unsigned levels)
{
- return MAX2(1, value >> 1);
+ return MAX2(1, value >> levels);
}
#ifndef COPY_4V
@@ -539,6 +583,18 @@ do { \
#endif
+static INLINE uint32_t util_unsigned_fixed(float value, unsigned frac_bits)
+{
+ return value < 0 ? 0 : (uint32_t)(value * (1<<frac_bits));
+}
+
+static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits)
+{
+ return (int32_t)(value * (1<<frac_bits));
+}
+
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/util/u_mm.c b/src/gallium/auxiliary/util/u_mm.c
index 4b75d4ba1d..82f83702d1 100644
--- a/src/gallium/auxiliary/util/u_mm.c
+++ b/src/gallium/auxiliary/util/u_mm.c
@@ -39,13 +39,20 @@ u_mmDumpMemInfo(const struct mem_block *heap)
}
else {
const struct mem_block *p;
+ int total_used = 0, total_free = 0;
for (p = heap->next; p != heap; p = p->next) {
debug_printf(" Offset:%08x, Size:%08x, %c%c\n", p->ofs, p->size,
p->free ? 'F':'.',
p->reserved ? 'R':'.');
+ if (p->free)
+ total_free += p->size;
+ else
+ total_used += p->size;
}
+ debug_printf("'\nMemory stats: total = %d, used = %d, free = %d\n",
+ total_used + total_free, total_used, total_free);
debug_printf("\nFree list:\n");
for (p = heap->next_free; p != heap; p = p->next_free) {
diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c
index 6269c72e12..87ee0e4768 100644
--- a/src/gallium/auxiliary/util/u_network.c
+++ b/src/gallium/auxiliary/util/u_network.c
@@ -6,7 +6,7 @@
#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
# include <winsock2.h>
# include <windows.h>
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
# include <sys/socket.h>
# include <netinet/in.h>
# include <unistd.h>
@@ -54,7 +54,7 @@ u_socket_close(int s)
if (s < 0)
return;
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
shutdown(s, SHUT_RDWR);
close(s);
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
@@ -117,7 +117,7 @@ u_socket_connect(const char *hostname, uint16_t port)
if (!host)
return -1;
- memcpy((char *)&sa.sin_addr,host->h_addr,host->h_length);
+ memcpy((char *)&sa.sin_addr,host->h_addr_list[0],host->h_length);
sa.sin_family= host->h_addrtype;
sa.sin_port = htons(port);
@@ -169,7 +169,7 @@ u_socket_listen_on_port(uint16_t portnum)
void
u_socket_block(int s, boolean block)
{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
int old = fcntl(s, F_GETFL, 0);
if (old == -1)
return;
diff --git a/src/gallium/auxiliary/util/u_network.h b/src/gallium/auxiliary/util/u_network.h
index 0aa898b967..187dcab86e 100644
--- a/src/gallium/auxiliary/util/u_network.h
+++ b/src/gallium/auxiliary/util/u_network.h
@@ -6,7 +6,7 @@
#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
# define PIPE_HAVE_SOCKETS
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_BSD)
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
# define PIPE_HAVE_SOCKETS
#endif
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index eda883b3b9..43eb0153ee 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -37,106 +37,110 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
+#include "util/u_format.h"
#include "util/u_math.h"
+
+union util_color {
+ ubyte ub;
+ ushort us;
+ uint ui;
+ float f[4];
+};
+
/**
* Pack ubyte R,G,B,A into dest pixel.
*/
static INLINE void
util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
- enum pipe_format format, void *dest)
+ enum pipe_format format, union util_color *uc)
{
switch (format) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (r << 24) | (g << 16) | (b << 8) | a;
+ uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
case PIPE_FORMAT_R8G8B8X8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (r << 24) | (g << 16) | (b << 8) | 0xff;
+ uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
}
return;
case PIPE_FORMAT_A8R8G8B8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (a << 24) | (r << 16) | (g << 8) | b;
+ uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
case PIPE_FORMAT_X8R8G8B8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (0xff << 24) | (r << 16) | (g << 8) | b;
+ uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
}
return;
case PIPE_FORMAT_B8G8R8A8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (b << 24) | (g << 16) | (r << 8) | a;
+ uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
case PIPE_FORMAT_B8G8R8X8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (b << 24) | (g << 16) | (r << 8) | 0xff;
+ uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
}
return;
case PIPE_FORMAT_R5G6B5_UNORM:
{
- ushort *d = (ushort *) dest;
- *d = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
+ uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
}
return;
case PIPE_FORMAT_A1R5G5B5_UNORM:
{
- ushort *d = (ushort *) dest;
- *d = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
+ uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
}
return;
case PIPE_FORMAT_A4R4G4B4_UNORM:
{
- ushort *d = (ushort *) dest;
- *d = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
+ uc->us = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
}
return;
case PIPE_FORMAT_A8_UNORM:
{
- ubyte *d = (ubyte *) dest;
- *d = a;
+ uc->ub = a;
}
return;
case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_I8_UNORM:
{
- ubyte *d = (ubyte *) dest;
- *d = r;
+ uc->ub = a;
}
return;
case PIPE_FORMAT_R32G32B32A32_FLOAT:
{
- float *d = (float *) dest;
- d[0] = (float)r / 255.0f;
- d[1] = (float)g / 255.0f;
- d[2] = (float)b / 255.0f;
- d[3] = (float)a / 255.0f;
+ uc->f[0] = (float)r / 255.0f;
+ uc->f[1] = (float)g / 255.0f;
+ uc->f[2] = (float)b / 255.0f;
+ uc->f[3] = (float)a / 255.0f;
}
return;
case PIPE_FORMAT_R32G32B32_FLOAT:
{
- float *d = (float *) dest;
- d[0] = (float)r / 255.0f;
- d[1] = (float)g / 255.0f;
- d[2] = (float)b / 255.0f;
+ uc->f[0] = (float)r / 255.0f;
+ uc->f[1] = (float)g / 255.0f;
+ uc->f[2] = (float)b / 255.0f;
}
return;
- /* XXX lots more cases to add */
+ /* Handle other cases with a generic function.
+ */
default:
- debug_print_format("gallium: unhandled format in util_pack_color_ub()", format);
- assert(0);
+ {
+ ubyte src[4];
+
+ src[0] = r;
+ src[1] = g;
+ src[2] = b;
+ src[3] = a;
+ util_format_write_4ub(format, src, 0, uc, 0, 0, 0, 1, 1);
+ }
}
}
@@ -145,13 +149,13 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
* Unpack RGBA from a packed pixel, returning values as ubytes in [0,255].
*/
static INLINE void
-util_unpack_color_ub(enum pipe_format format, const void *src,
+util_unpack_color_ub(enum pipe_format format, union util_color *uc,
ubyte *r, ubyte *g, ubyte *b, ubyte *a)
{
switch (format) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
{
- uint p = ((const uint *) src)[0];
+ uint p = uc->ui;
*r = (ubyte) ((p >> 24) & 0xff);
*g = (ubyte) ((p >> 16) & 0xff);
*b = (ubyte) ((p >> 8) & 0xff);
@@ -160,7 +164,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_R8G8B8X8_UNORM:
{
- uint p = ((const uint *) src)[0];
+ uint p = uc->ui;
*r = (ubyte) ((p >> 24) & 0xff);
*g = (ubyte) ((p >> 16) & 0xff);
*b = (ubyte) ((p >> 8) & 0xff);
@@ -169,7 +173,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_A8R8G8B8_UNORM:
{
- uint p = ((const uint *) src)[0];
+ uint p = uc->ui;
*r = (ubyte) ((p >> 16) & 0xff);
*g = (ubyte) ((p >> 8) & 0xff);
*b = (ubyte) ((p >> 0) & 0xff);
@@ -178,7 +182,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_X8R8G8B8_UNORM:
{
- uint p = ((const uint *) src)[0];
+ uint p = uc->ui;
*r = (ubyte) ((p >> 16) & 0xff);
*g = (ubyte) ((p >> 8) & 0xff);
*b = (ubyte) ((p >> 0) & 0xff);
@@ -187,7 +191,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_B8G8R8A8_UNORM:
{
- uint p = ((const uint *) src)[0];
+ uint p = uc->ui;
*r = (ubyte) ((p >> 8) & 0xff);
*g = (ubyte) ((p >> 16) & 0xff);
*b = (ubyte) ((p >> 24) & 0xff);
@@ -196,7 +200,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_B8G8R8X8_UNORM:
{
- uint p = ((const uint *) src)[0];
+ uint p = uc->ui;
*r = (ubyte) ((p >> 8) & 0xff);
*g = (ubyte) ((p >> 16) & 0xff);
*b = (ubyte) ((p >> 24) & 0xff);
@@ -205,7 +209,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_R5G6B5_UNORM:
{
- ushort p = ((const ushort *) src)[0];
+ ushort p = uc->us;
*r = (ubyte) (((p >> 8) & 0xf8) | ((p >> 13) & 0x7));
*g = (ubyte) (((p >> 3) & 0xfc) | ((p >> 9) & 0x3));
*b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7));
@@ -214,7 +218,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_A1R5G5B5_UNORM:
{
- ushort p = ((const ushort *) src)[0];
+ ushort p = uc->us;
*r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7));
*g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7));
*b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7));
@@ -223,7 +227,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_A4R4G4B4_UNORM:
{
- ushort p = ((const ushort *) src)[0];
+ ushort p = uc->us;
*r = (ubyte) (((p >> 4) & 0xf0) | ((p >> 8) & 0xf));
*g = (ubyte) (((p >> 0) & 0xf0) | ((p >> 4) & 0xf));
*b = (ubyte) (((p << 4) & 0xf0) | ((p >> 0) & 0xf));
@@ -232,27 +236,27 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_A8_UNORM:
{
- ubyte p = ((const ubyte *) src)[0];
+ ubyte p = uc->ub;
*r = *g = *b = (ubyte) 0xff;
*a = p;
}
return;
case PIPE_FORMAT_L8_UNORM:
{
- ubyte p = ((const ubyte *) src)[0];
+ ubyte p = uc->ub;
*r = *g = *b = p;
*a = (ubyte) 0xff;
}
return;
case PIPE_FORMAT_I8_UNORM:
{
- ubyte p = ((const ubyte *) src)[0];
+ ubyte p = uc->ub;
*r = *g = *b = *a = p;
}
return;
case PIPE_FORMAT_R32G32B32A32_FLOAT:
{
- const float *p = (const float *) src;
+ const float *p = &uc->f[0];
*r = float_to_ubyte(p[0]);
*g = float_to_ubyte(p[1]);
*b = float_to_ubyte(p[2]);
@@ -261,7 +265,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
return;
case PIPE_FORMAT_R32G32B32_FLOAT:
{
- const float *p = (const float *) src;
+ const float *p = &uc->f[0];
*r = float_to_ubyte(p[0]);
*g = float_to_ubyte(p[1]);
*b = float_to_ubyte(p[2]);
@@ -271,7 +275,7 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
case PIPE_FORMAT_R32G32_FLOAT:
{
- const float *p = (const float *) src;
+ const float *p = &uc->f[0];
*r = float_to_ubyte(p[0]);
*g = float_to_ubyte(p[1]);
*b = *a = (ubyte) 0xff;
@@ -280,31 +284,40 @@ util_unpack_color_ub(enum pipe_format format, const void *src,
case PIPE_FORMAT_R32_FLOAT:
{
- const float *p = (const float *) src;
+ const float *p = &uc->f[0];
*r = float_to_ubyte(p[0]);
*g = *b = *a = (ubyte) 0xff;
}
return;
- /* XXX lots more cases to add */
+ /* Handle other cases with a generic function.
+ */
default:
- debug_print_format("gallium: unhandled format in util_unpack_color_ub()",
- format);
- assert(0);
+ {
+ ubyte dst[4];
+
+ util_format_read_4ub(format, dst, 0, uc, 0, 0, 0, 1, 1);
+ *r = dst[0];
+ *g = dst[1];
+ *b = dst[2];
+ *a = dst[3];
+ }
}
}
-
/**
* Note rgba outside [0,1] will be clamped for int pixel formats.
*/
static INLINE void
-util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
+util_pack_color(const float rgba[4], enum pipe_format format, union util_color *uc)
{
- ubyte r, g, b, a;
+ ubyte r = 0;
+ ubyte g = 0;
+ ubyte b = 0;
+ ubyte a = 0;
- if (pf_size_x(format) <= 8) {
+ if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) <= 8) {
/* format uses 8-bit components or less */
r = float_to_ubyte(rgba[0]);
g = float_to_ubyte(rgba[1]);
@@ -315,92 +328,80 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
switch (format) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (r << 24) | (g << 16) | (b << 8) | a;
+ uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
case PIPE_FORMAT_R8G8B8X8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (r << 24) | (g << 16) | (b << 8) | 0xff;
+ uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
}
return;
case PIPE_FORMAT_A8R8G8B8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (a << 24) | (r << 16) | (g << 8) | b;
+ uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
case PIPE_FORMAT_X8R8G8B8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (0xff << 24) | (r << 16) | (g << 8) | b;
+ uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
}
return;
case PIPE_FORMAT_B8G8R8A8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (b << 24) | (g << 16) | (r << 8) | a;
+ uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
case PIPE_FORMAT_B8G8R8X8_UNORM:
{
- uint *d = (uint *) dest;
- *d = (b << 24) | (g << 16) | (r << 8) | 0xff;
+ uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
}
return;
case PIPE_FORMAT_R5G6B5_UNORM:
{
- ushort *d = (ushort *) dest;
- *d = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
+ uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
}
return;
case PIPE_FORMAT_A1R5G5B5_UNORM:
{
- ushort *d = (ushort *) dest;
- *d = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
+ uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
}
return;
case PIPE_FORMAT_A4R4G4B4_UNORM:
{
- ushort *d = (ushort *) dest;
- *d = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
+ uc->ub = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
}
return;
case PIPE_FORMAT_A8_UNORM:
{
- ubyte *d = (ubyte *) dest;
- *d = a;
+ uc->ub = a;
}
return;
case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_I8_UNORM:
{
- ubyte *d = (ubyte *) dest;
- *d = r;
+ uc->ub = r;
}
return;
case PIPE_FORMAT_R32G32B32A32_FLOAT:
{
- float *d = (float *) dest;
- d[0] = rgba[0];
- d[1] = rgba[1];
- d[2] = rgba[2];
- d[3] = rgba[3];
+ uc->f[0] = rgba[0];
+ uc->f[1] = rgba[1];
+ uc->f[2] = rgba[2];
+ uc->f[3] = rgba[3];
}
return;
case PIPE_FORMAT_R32G32B32_FLOAT:
{
- float *d = (float *) dest;
- d[0] = rgba[0];
- d[1] = rgba[1];
- d[2] = rgba[2];
+ uc->f[0] = rgba[0];
+ uc->f[1] = rgba[1];
+ uc->f[2] = rgba[2];
}
return;
- /* XXX lots more cases to add */
+
+ /* Handle other cases with a generic function.
+ */
default:
- debug_print_format("gallium: unhandled format in util_pack_color()", format);
- assert(0);
+ util_format_write_4f(format, rgba, 0, uc, 0, 0, 0, 1, 1);
}
}
diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index a9b533eea7..10a874f341 100644
--- a/src/gallium/auxiliary/util/u_prim.h
+++ b/src/gallium/auxiliary/util/u_prim.h
@@ -135,4 +135,39 @@ static INLINE unsigned u_reduced_prim( unsigned pipe_prim )
}
}
+static INLINE unsigned
+u_vertices_per_prim(int primitive)
+{
+ switch(primitive) {
+ case PIPE_PRIM_POINTS:
+ return 1;
+ case PIPE_PRIM_LINES:
+ case PIPE_PRIM_LINE_LOOP:
+ case PIPE_PRIM_LINE_STRIP:
+ return 2;
+ case PIPE_PRIM_TRIANGLES:
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ case PIPE_PRIM_TRIANGLE_FAN:
+ return 3;
+ case PIPE_PRIM_LINES_ADJACENCY:
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ return 4;
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ return 6;
+
+ /* following primitives should never be used
+ * with geometry shaders abd their size is
+ * undefined */
+ case PIPE_PRIM_POLYGON:
+ case PIPE_PRIM_QUADS:
+ case PIPE_PRIM_QUAD_STRIP:
+ default:
+ debug_printf("Unrecognized geometry shader primitive");
+ return 3;
+ }
+}
+
+const char *u_prim_name( unsigned pipe_prim );
+
#endif
diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c
index 9866b6fc8a..8479161c74 100644
--- a/src/gallium/auxiliary/util/u_rect.c
+++ b/src/gallium/auxiliary/util/u_rect.c
@@ -34,17 +34,18 @@
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
+#include "util/u_format.h"
#include "util/u_rect.h"
/**
* Copy 2D rect from one place to another.
* Position and sizes are in pixels.
- * src_pitch may be negative to do vertical flip of pixels from source.
+ * src_stride may be negative to do vertical flip of pixels from source.
*/
void
util_copy_rect(ubyte * dst,
- const struct pipe_format_block *block,
+ enum pipe_format format,
unsigned dst_stride,
unsigned dst_x,
unsigned dst_y,
@@ -53,31 +54,30 @@ util_copy_rect(ubyte * dst,
const ubyte * src,
int src_stride,
unsigned src_x,
- int src_y)
+ unsigned src_y)
{
unsigned i;
int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
-
- assert(block->size > 0);
- assert(block->width > 0);
- assert(block->height > 0);
- assert(src_x >= 0);
- assert(src_y >= 0);
- assert(dst_x >= 0);
- assert(dst_y >= 0);
-
- dst_x /= block->width;
- dst_y /= block->height;
- width = (width + block->width - 1)/block->width;
- height = (height + block->height - 1)/block->height;
- src_x /= block->width;
- src_y /= block->height;
+ int blocksize = util_format_get_blocksize(format);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
+
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
+
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
+ src_x /= blockwidth;
+ src_y /= blockheight;
- dst += dst_x * block->size;
- src += src_x * block->size;
+ dst += dst_x * blocksize;
+ src += src_x * blocksize;
dst += dst_y * dst_stride;
src += src_y * src_stride_pos;
- width *= block->size;
+ width *= blocksize;
if (width == dst_stride && width == src_stride)
memcpy(dst, src, height * width);
@@ -92,7 +92,7 @@ util_copy_rect(ubyte * dst,
void
util_fill_rect(ubyte * dst,
- const struct pipe_format_block *block,
+ enum pipe_format format,
unsigned dst_stride,
unsigned dst_x,
unsigned dst_y,
@@ -102,23 +102,24 @@ util_fill_rect(ubyte * dst,
{
unsigned i, j;
unsigned width_size;
-
- assert(block->size > 0);
- assert(block->width > 0);
- assert(block->height > 0);
- assert(dst_x >= 0);
- assert(dst_y >= 0);
-
- dst_x /= block->width;
- dst_y /= block->height;
- width = (width + block->width - 1)/block->width;
- height = (height + block->height - 1)/block->height;
+ int blocksize = util_format_get_blocksize(format);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
+
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
+
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
- dst += dst_x * block->size;
+ dst += dst_x * blocksize;
dst += dst_y * dst_stride;
- width_size = width * block->size;
+ width_size = width * blocksize;
- switch (block->size) {
+ switch (blocksize) {
case 1:
if(dst_stride == width_size)
memset(dst, (ubyte) value, height * width_size);
@@ -172,10 +173,15 @@ util_surface_copy(struct pipe_context *pipe,
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 = screen->get_tex_transfer(screen,
src->texture,
src->face,
@@ -192,9 +198,9 @@ util_surface_copy(struct pipe_context *pipe,
PIPE_TRANSFER_WRITE,
dst_x, dst_y, w, h);
- assert(dst_trans->block.size == src_trans->block.size);
- assert(dst_trans->block.width == src_trans->block.width);
- assert(dst_trans->block.height == src_trans->block.height);
+ 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->screen->transfer_map(screen, src_trans);
dst_map = pipe->screen->transfer_map(screen, dst_trans);
@@ -205,7 +211,7 @@ util_surface_copy(struct pipe_context *pipe,
if (src_map && dst_map) {
/* If do_flip, invert src_y position and pass negative src stride */
util_copy_rect(dst_map,
- &dst_trans->block,
+ dst_format,
dst_trans->stride,
0, 0,
w, h,
@@ -259,11 +265,11 @@ util_surface_fill(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (dst_trans->block.size) {
+ switch (util_format_get_blocksize(dst_trans->texture->format)) {
case 1:
case 2:
case 4:
- util_fill_rect(dst_map, &dst_trans->block, dst_trans->stride,
+ util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
0, 0, width, height, value);
break;
case 8:
diff --git a/src/gallium/auxiliary/util/u_rect.h b/src/gallium/auxiliary/util/u_rect.h
index daa50834d3..b44d821904 100644
--- a/src/gallium/auxiliary/util/u_rect.h
+++ b/src/gallium/auxiliary/util/u_rect.h
@@ -42,13 +42,13 @@ struct pipe_surface;
extern void
-util_copy_rect(ubyte * dst, const struct pipe_format_block *block,
+util_copy_rect(ubyte * dst, enum pipe_format format,
unsigned dst_stride, unsigned dst_x, unsigned dst_y,
unsigned width, unsigned height, const ubyte * src,
- int src_stride, unsigned src_x, int src_y);
+ int src_stride, unsigned src_x, unsigned src_y);
extern void
-util_fill_rect(ubyte * dst, const struct pipe_format_block *block,
+util_fill_rect(ubyte * dst, enum pipe_format format,
unsigned dst_stride, unsigned dst_x, unsigned dst_y,
unsigned width, unsigned height, uint32_t value);
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 1c8b157d91..b751e29ab6 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -2,6 +2,7 @@
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -30,6 +31,7 @@
* Simple vertex/fragment shader generators.
*
* @author Brian Paul
+ Marek Olšák
*/
@@ -42,13 +44,15 @@
/**
* Make simple vertex pass-through shader.
+ * \param num_attribs number of attributes to pass through
+ * \param semantic_names array of semantic names for each attribute
+ * \param semantic_indexes array of semantic indexes for each attribute
*/
void *
util_make_vertex_passthrough_shader(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
const uint *semantic_indexes)
-
{
struct ureg_program *ureg;
uint i;
@@ -76,8 +80,6 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
}
-
-
/**
* Make simple fragment texture shader:
* IMM {0,0,0,1} // (if writemask != 0xf)
@@ -87,6 +89,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
*/
void *
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
+ unsigned tex_target,
unsigned writemask )
{
struct ureg_program *ureg;
@@ -116,20 +119,71 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
ureg_TEX( ureg,
ureg_writemask(out, writemask),
- TGSI_TEXTURE_2D, tex, sampler );
+ tex_target, tex, sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
}
+
+/**
+ * Make a simple fragment shader that sets the output color to a color
+ * taken from a texture.
+ * \param tex_target one of PIPE_TEXTURE_x
+ */
void *
-util_make_fragment_tex_shader(struct pipe_context *pipe )
+util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target )
{
return util_make_fragment_tex_shader_writemask( pipe,
+ tex_target,
TGSI_WRITEMASK_XYZW );
}
+/**
+ * Make a simple fragment texture shader which reads an X component from
+ * a texture and writes it as depth.
+ */
+void *
+util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
+ unsigned tex_target)
+{
+ struct ureg_program *ureg;
+ struct ureg_src sampler;
+ struct ureg_src tex;
+ struct ureg_dst out, depth;
+ struct ureg_src imm;
+
+ ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
+ if (ureg == NULL)
+ return NULL;
+
+ sampler = ureg_DECL_sampler( ureg, 0 );
+
+ tex = ureg_DECL_fs_input( ureg,
+ TGSI_SEMANTIC_GENERIC, 0,
+ TGSI_INTERPOLATE_PERSPECTIVE );
+
+ out = ureg_DECL_output( ureg,
+ TGSI_SEMANTIC_COLOR,
+ 0 );
+
+ depth = ureg_DECL_output( ureg,
+ TGSI_SEMANTIC_POSITION,
+ 0 );
+
+ imm = ureg_imm4f( ureg, 0, 0, 0, 1 );
+
+ ureg_MOV( ureg, out, imm );
+
+ ureg_TEX( ureg,
+ ureg_writemask(depth, TGSI_WRITEMASK_Z),
+ tex_target, tex, sampler );
+ ureg_END( ureg );
+
+ return ureg_create_shader_and_destroy( ureg, pipe );
+}
+
/**
* Make simple fragment color pass-through shader.
@@ -137,9 +191,22 @@ util_make_fragment_tex_shader(struct pipe_context *pipe )
void *
util_make_fragment_passthrough_shader(struct pipe_context *pipe)
{
+ return util_make_fragment_clonecolor_shader(pipe, 1);
+}
+
+
+/**
+ * Make a fragment shader that copies the input color to N output colors.
+ */
+void *
+util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs)
+{
struct ureg_program *ureg;
struct ureg_src src;
- struct ureg_dst dst;
+ struct ureg_dst dst[PIPE_MAX_COLOR_BUFS];
+ int i;
+
+ assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
if (ureg == NULL)
@@ -148,12 +215,13 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe)
src = ureg_DECL_fs_input( ureg, TGSI_SEMANTIC_COLOR, 0,
TGSI_INTERPOLATE_PERSPECTIVE );
- dst = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, 0 );
+ for (i = 0; i < num_cbufs; i++)
+ dst[i] = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, i );
+
+ for (i = 0; i < num_cbufs; i++)
+ ureg_MOV( ureg, dst[i], src );
- ureg_MOV( ureg, dst, src );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
}
-
-
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h
index d2e80d6eb4..6e760942e2 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -51,16 +51,25 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
extern void *
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
- unsigned writemask );
+ unsigned tex_target,
+ unsigned writemask);
extern void *
-util_make_fragment_tex_shader(struct pipe_context *pipe);
+util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target);
+
+
+extern void *
+util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
+ unsigned tex_target);
extern void *
util_make_fragment_passthrough_shader(struct pipe_context *pipe);
+extern void *
+util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/util/u_stream_stdc.c b/src/gallium/auxiliary/util/u_stream_stdc.c
index 5cd05b2904..4d976d6dca 100644
--- a/src/gallium/auxiliary/util/u_stream_stdc.c
+++ b/src/gallium/auxiliary/util/u_stream_stdc.c
@@ -32,7 +32,7 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
#include <stdio.h>
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index cfdf7ab8f8..f66376ad75 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -37,6 +37,7 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
+#include "util/u_format.h"
#include "util/u_surface.h"
@@ -80,10 +81,9 @@ util_create_rgba_surface(struct pipe_screen *screen,
templ.target = target;
templ.format = format;
templ.last_level = 0;
- templ.width[0] = width;
- templ.height[0] = height;
- templ.depth[0] = 1;
- pf_get_block(format, &templ.block);
+ templ.width0 = width;
+ templ.height0 = height;
+ templ.depth0 = 1;
templ.tex_usage = usage;
*textureOut = screen->texture_create(screen, &templ);
diff --git a/src/gallium/auxiliary/util/u_texture.c b/src/gallium/auxiliary/util/u_texture.c
new file mode 100644
index 0000000000..cd477ab640
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_texture.c
@@ -0,0 +1,102 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * Copyright 2008 VMware, Inc. All rights reserved.
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Texture mapping utility functions.
+ *
+ * @author Brian Paul
+ * Marek Olšák
+ */
+
+#include "pipe/p_defines.h"
+
+#include "util/u_texture.h"
+
+void util_map_texcoords2d_onto_cubemap(unsigned face,
+ const float *in_st, unsigned in_stride,
+ float *out_str, unsigned out_stride)
+{
+ int i;
+ float rx, ry, rz;
+
+ /* loop over quad verts */
+ for (i = 0; i < 4; i++) {
+ /* Compute sc = +/-scale and tc = +/-scale.
+ * Not +/-1 to avoid cube face selection ambiguity near the edges,
+ * though that can still sometimes happen with this scale factor...
+ */
+ const float scale = 0.9999f;
+ const float sc = (2 * in_st[0] - 1) * scale;
+ const float tc = (2 * in_st[1] - 1) * scale;
+
+ switch (face) {
+ case PIPE_TEX_FACE_POS_X:
+ rx = 1;
+ ry = -tc;
+ rz = -sc;
+ break;
+ case PIPE_TEX_FACE_NEG_X:
+ rx = -1;
+ ry = -tc;
+ rz = sc;
+ break;
+ case PIPE_TEX_FACE_POS_Y:
+ rx = sc;
+ ry = 1;
+ rz = tc;
+ break;
+ case PIPE_TEX_FACE_NEG_Y:
+ rx = sc;
+ ry = -1;
+ rz = -tc;
+ break;
+ case PIPE_TEX_FACE_POS_Z:
+ rx = sc;
+ ry = -tc;
+ rz = 1;
+ break;
+ case PIPE_TEX_FACE_NEG_Z:
+ rx = -sc;
+ ry = -tc;
+ rz = -1;
+ break;
+ default:
+ rx = ry = rz = 0;
+ assert(0);
+ }
+
+ out_str[0] = rx; /*s*/
+ out_str[1] = ry; /*t*/
+ out_str[2] = rz; /*r*/
+
+ in_st += in_stride;
+ out_str += out_stride;
+ }
+}
diff --git a/src/gallium/auxiliary/util/u_texture.h b/src/gallium/auxiliary/util/u_texture.h
new file mode 100644
index 0000000000..93b2f1e4c9
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_texture.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef U_TEXTURE_H
+#define U_TEXTURE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Convert 2D texture coordinates of 4 vertices into cubemap coordinates
+ * in the given face.
+ * Coordinates must be in the range [0,1].
+ *
+ * \param face Cubemap face.
+ * \param in_st 4 pairs of 2D texture coordinates to convert.
+ * \param in_stride Stride of in_st in floats.
+ * \param out_str STR cubemap texture coordinates to compute.
+ * \param out_stride Stride of out_str in floats.
+ */
+void util_map_texcoords2d_onto_cubemap(unsigned face,
+ const float *in_st, unsigned in_stride,
+ float *out_str, unsigned out_stride);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index 8a22f584be..1ba82bb21f 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -34,6 +34,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
@@ -52,7 +53,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
const void *src;
if (dst_stride == 0)
- dst_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
+ dst_stride = util_format_get_stride(pt->texture->format, w);
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -62,7 +63,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
if(!src)
return;
- util_copy_rect(dst, &pt->block, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
+ util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
screen->transfer_unmap(screen, pt);
}
@@ -78,9 +79,10 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
{
struct pipe_screen *screen = pt->texture->screen;
void *dst;
+ enum pipe_format format = pt->texture->format;
if (src_stride == 0)
- src_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
+ src_stride = util_format_get_stride(format, w);
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -90,7 +92,7 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
if(!dst)
return;
- util_copy_rect(dst, &pt->block, pt->stride, x, y, w, h, src, src_stride, 0, 0);
+ util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0);
screen->transfer_unmap(screen, pt);
}
@@ -246,6 +248,53 @@ b8g8r8a8_put_tile_rgba(unsigned *dst,
}
+/*** PIPE_FORMAT_R8G8B8A8_UNORM ***/
+
+static void
+r8g8b8a8_get_tile_rgba(const unsigned *src,
+ unsigned w, unsigned h,
+ float *p,
+ unsigned dst_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ const unsigned pixel = *src++;
+ pRow[0] = ubyte_to_float((pixel >> 24) & 0xff);
+ pRow[1] = ubyte_to_float((pixel >> 16) & 0xff);
+ pRow[2] = ubyte_to_float((pixel >> 8) & 0xff);
+ pRow[3] = ubyte_to_float((pixel >> 0) & 0xff);
+ }
+ p += dst_stride;
+ }
+}
+
+
+static void
+r8g8b8a8_put_tile_rgba(unsigned *dst,
+ unsigned w, unsigned h,
+ const float *p,
+ unsigned src_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ const float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ unsigned r, g, b, a;
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
+ a = float_to_ubyte(pRow[3]);
+ *dst++ = (r << 24) | (g << 16) | (b << 8) | a;
+ }
+ p += src_stride;
+ }
+}
+
+
/*** PIPE_FORMAT_A1R5G5B5_UNORM ***/
static void
@@ -1106,27 +1155,6 @@ ycbcr_get_tile_rgba(const ushort *src,
}
-static void
-fake_get_tile_rgba(const ushort *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] =
- pRow[3] = (i ^ j) & 1 ? 1.0f : 0.0f;
- }
- p += dst_stride;
- }
-}
-
-
void
pipe_tile_raw_to_rgba(enum pipe_format format,
void *src,
@@ -1143,6 +1171,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
break;
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
+ break;
case PIPE_FORMAT_A1R5G5B5_UNORM:
a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
break;
@@ -1206,8 +1237,10 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, TRUE);
break;
default:
- debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
- fake_get_tile_rgba(src, w, h, dst, dst_stride);
+ util_format_read_4f(format,
+ dst, dst_stride * sizeof(float),
+ src, util_format_get_stride(format, w),
+ 0, 0, w, h);
}
}
@@ -1219,21 +1252,22 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
{
unsigned dst_stride = w * 4;
void *packed;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
if (!packed)
return;
- if(pt->format == PIPE_FORMAT_YCBCR || pt->format == PIPE_FORMAT_YCBCR_REV)
+ if(format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV)
assert((x & 1) == 0);
pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
- pipe_tile_raw_to_rgba(pt->format, packed, w, h, p, dst_stride);
+ pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
FREE(packed);
}
@@ -1246,16 +1280,17 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
{
unsigned src_stride = w * 4;
void *packed;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
if (!packed)
return;
- switch (pt->format) {
+ switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
@@ -1265,6 +1300,9 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
+ break;
case PIPE_FORMAT_A1R5G5B5_UNORM:
a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
break;
@@ -1274,9 +1312,6 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
case PIPE_FORMAT_R8G8B8_UNORM:
r8g8b8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
break;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- assert(0);
- break;
case PIPE_FORMAT_A4R4G4B4_UNORM:
a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
break;
@@ -1322,7 +1357,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
break;
default:
- debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(pt->format));
+ debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
}
pipe_put_tile_raw(pt, x, y, w, h, packed, 0);
@@ -1344,6 +1379,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
ubyte *map;
uint *pDest = z;
uint i, j;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -1354,7 +1390,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
return;
}
- switch (pt->format) {
+ switch (format) {
case PIPE_FORMAT_Z32_UNORM:
{
const uint *ptrc
@@ -1428,6 +1464,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
const uint *ptrc = zSrc;
ubyte *map;
uint i, j;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -1438,7 +1475,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
return;
}
- switch (pt->format) {
+ switch (format) {
case PIPE_FORMAT_Z32_UNORM:
{
uint *pDest = (uint *) (map + y * pt->stride + x*4);
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index eb635c9f14..975ee89c45 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -29,7 +29,7 @@
* coalescing small buffers into larger ones.
*/
-#include "pipe/p_error.h"
+#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_screen.h"
#include "util/u_memory.h"
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h
index 745b5834af..e158bed9d0 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -32,6 +32,8 @@
#ifndef U_UPLOAD_MGR_H
#define U_UPLOAD_MGR_H
+#include "pipe/p_defines.h"
+
struct pipe_screen;
struct pipe_buffer;
struct u_upload_mgr;
diff --git a/src/gallium/auxiliary/vl/Makefile b/src/gallium/auxiliary/vl/Makefile
deleted file mode 100644
index 4314c1e8d6..0000000000
--- a/src/gallium/auxiliary/vl/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = vl
-
-C_SOURCES = \
- vl_bitstream_parser.c \
- vl_mpeg12_mc_renderer.c \
- vl_compositor.c \
- vl_csc.c \
- vl_shader_build.c
-
-include ../../Makefile.template
diff --git a/src/gallium/auxiliary/vl/SConscript b/src/gallium/auxiliary/vl/SConscript
deleted file mode 100644
index aed69f5efe..0000000000
--- a/src/gallium/auxiliary/vl/SConscript
+++ /dev/null
@@ -1,13 +0,0 @@
-Import('*')
-
-vl = env.ConvenienceLibrary(
- target = 'vl',
- source = [
- 'vl_bitstream_parser.c',
- 'vl_mpeg12_mc_renderer.c',
- 'vl_compositor.c',
- 'vl_csc.c',
- 'vl_shader_build.c',
- ])
-
-auxiliaries.insert(0, vl)
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index b36dbeb208..fc2a1c59a6 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -95,12 +95,11 @@ create_vert_shader(struct vl_compositor *c)
assert(c);
tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version*)&tokens[0] = tgsi_build_version();
- header = (struct tgsi_header*)&tokens[1];
+ header = (struct tgsi_header*)&tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor*)&tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+ *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Vertex pos
@@ -172,12 +171,11 @@ create_frag_shader(struct vl_compositor *c)
assert(c);
tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version*)&tokens[0] = tgsi_build_version();
- header = (struct tgsi_header*)&tokens[1];
+ header = (struct tgsi_header*)&tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor*)&tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+ *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
- ti = 3;
+ ti = 2;
/* decl i0 ; Texcoords for s0 */
decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, 1, 0, 0, TGSI_INTERPOLATE_LINEAR);
@@ -213,7 +211,7 @@ create_frag_shader(struct vl_compositor *c)
*/
for (i = 0; i < 4; ++i) {
inst = vl_inst3(TGSI_OPCODE_DP4, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, i);
- inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+ inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
}
@@ -455,8 +453,8 @@ void vl_compositor_render(struct vl_compositor *compositor,
assert(dst_area);
assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
- compositor->fb_state.width = dst_surface->width[0];
- compositor->fb_state.height = dst_surface->height[0];
+ compositor->fb_state.width = dst_surface->width0;
+ compositor->fb_state.height = dst_surface->height0;
compositor->fb_state.cbufs[0] = compositor->pipe->screen->get_tex_surface
(
compositor->pipe->screen,
@@ -473,10 +471,14 @@ void vl_compositor_render(struct vl_compositor *compositor,
compositor->viewport.translate[2] = 0;
compositor->viewport.translate[3] = 0;
+ compositor->scissor.maxx = compositor->fb_state.width;
+ compositor->scissor.maxy = compositor->fb_state.height;
+
compositor->pipe->set_framebuffer_state(compositor->pipe, &compositor->fb_state);
compositor->pipe->set_viewport_state(compositor->pipe, &compositor->viewport);
- compositor->pipe->bind_sampler_states(compositor->pipe, 1, &compositor->sampler);
- compositor->pipe->set_sampler_textures(compositor->pipe, 1, &src_surface);
+ compositor->pipe->set_scissor_state(compositor->pipe, &compositor->scissor);
+ compositor->pipe->bind_fragment_sampler_states(compositor->pipe, 1, &compositor->sampler);
+ compositor->pipe->set_fragment_sampler_textures(compositor->pipe, 1, &src_surface);
compositor->pipe->bind_vs_state(compositor->pipe, compositor->vertex_shader);
compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
@@ -500,12 +502,12 @@ void vl_compositor_render(struct vl_compositor *compositor,
vs_consts->dst_trans.z = 0;
vs_consts->dst_trans.w = 0;
- vs_consts->src_scale.x = src_area->w / (float)src_surface->width[0];
- vs_consts->src_scale.y = src_area->h / (float)src_surface->height[0];
+ vs_consts->src_scale.x = src_area->w / (float)src_surface->width0;
+ vs_consts->src_scale.y = src_area->h / (float)src_surface->height0;
vs_consts->src_scale.z = 1;
vs_consts->src_scale.w = 1;
- vs_consts->src_trans.x = src_area->x / (float)src_surface->width[0];
- vs_consts->src_trans.y = src_area->y / (float)src_surface->height[0];
+ vs_consts->src_trans.x = src_area->x / (float)src_surface->width0;
+ vs_consts->src_trans.y = src_area->y / (float)src_surface->height0;
vs_consts->src_trans.z = 0;
vs_consts->src_trans.w = 0;
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index 17e2afd353..f441901a75 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -44,6 +44,7 @@ struct vl_compositor
void *vertex_shader;
void *fragment_shader;
struct pipe_viewport_state viewport;
+ struct pipe_scissor_state scissor;
struct pipe_vertex_buffer vertex_bufs[2];
struct pipe_vertex_element vertex_elems[2];
struct pipe_constant_buffer vs_const_buf, fs_const_buf;
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index 6b3614821c..caf581aca6 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -29,6 +29,7 @@
#include <assert.h>
#include <pipe/p_context.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_math.h>
#include <util/u_memory.h>
#include <tgsi/tgsi_parse.h>
@@ -115,12 +116,11 @@ create_intra_vert_shader(struct vl_mpeg12_mc_renderer *r)
assert(r);
tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
- header = (struct tgsi_header *) &tokens[1];
+ header = (struct tgsi_header *) &tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+ *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Vertex pos
@@ -185,12 +185,11 @@ create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
assert(r);
tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
- header = (struct tgsi_header *) &tokens[1];
+ header = (struct tgsi_header *) &tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+ *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Luma texcoords
@@ -237,10 +236,10 @@ create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
- inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+ inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+ inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
}
@@ -278,12 +277,11 @@ create_frame_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
assert(r);
tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
- header = (struct tgsi_header *) &tokens[1];
+ header = (struct tgsi_header *) &tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+ *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Vertex pos
@@ -336,11 +334,13 @@ create_frame_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
free(tokens);
}
+#if 0
static void
create_field_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
{
assert(false);
}
+#endif
static void
create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
@@ -361,12 +361,11 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
assert(r);
tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
- header = (struct tgsi_header *) &tokens[1];
+ header = (struct tgsi_header *) &tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+ *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Luma texcoords
@@ -415,10 +414,10 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
- inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+ inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+ inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
}
@@ -445,11 +444,13 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
free(tokens);
}
+#if 0
static void
create_field_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
{
assert(false);
}
+#endif
static void
create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
@@ -470,12 +471,11 @@ create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
assert(r);
tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
- header = (struct tgsi_header *) &tokens[1];
+ header = (struct tgsi_header *) &tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
+ *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Vertex pos
@@ -536,11 +536,13 @@ create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
free(tokens);
}
+#if 0
static void
create_field_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
{
assert(false);
}
+#endif
static void
create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
@@ -561,12 +563,11 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
assert(r);
tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- *(struct tgsi_version *) &tokens[0] = tgsi_build_version();
- header = (struct tgsi_header *) &tokens[1];
+ header = (struct tgsi_header *) &tokens[0];
*header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
+ *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
- ti = 3;
+ ti = 2;
/*
* decl i0 ; Luma texcoords
@@ -620,10 +621,10 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
- inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
+ inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+ inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
}
@@ -642,10 +643,10 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
/* lerp t1, c1.x, t1, t2 ; Blend past and future texels */
inst = vl_inst4(TGSI_OPCODE_LRP, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_CONSTANT, 1, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_TEMPORARY, 2);
- inst.FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
- inst.FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
+ inst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_X;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
/* add o0, t0, t1 ; Add past/future ref and differential to form final output */
@@ -663,11 +664,13 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
free(tokens);
}
+#if 0
static void
create_field_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
{
assert(false);
}
+#endif
static void
xfer_buffers_map(struct vl_mpeg12_mc_renderer *r)
@@ -681,7 +684,7 @@ xfer_buffers_map(struct vl_mpeg12_mc_renderer *r)
(
r->pipe->screen, r->textures.all[i],
0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0,
- r->textures.all[i]->width[0], r->textures.all[i]->height[0]
+ r->textures.all[i]->width0, r->textures.all[i]->height0
);
r->texels[i] = r->pipe->screen->transfer_map(r->pipe->screen, r->tex_transfer[i]);
@@ -721,6 +724,11 @@ init_pipe_state(struct vl_mpeg12_mc_renderer *r)
r->viewport.translate[2] = 0;
r->viewport.translate[3] = 0;
+ r->scissor.maxx = r->pot_buffers ?
+ util_next_power_of_two(r->picture_width) : r->picture_width;
+ r->scissor.maxy = r->pot_buffers ?
+ util_next_power_of_two(r->picture_height) : r->picture_height;
+
r->fb_state.width = r->pot_buffers ?
util_next_power_of_two(r->picture_width) : r->picture_width;
r->fb_state.height = r->pot_buffers ?
@@ -830,26 +838,25 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
/* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
template.format = PIPE_FORMAT_R16_SNORM;
template.last_level = 0;
- template.width[0] = r->pot_buffers ?
+ template.width0 = r->pot_buffers ?
util_next_power_of_two(r->picture_width) : r->picture_width;
- template.height[0] = r->pot_buffers ?
+ template.height0 = r->pot_buffers ?
util_next_power_of_two(r->picture_height) : r->picture_height;
- template.depth[0] = 1;
- pf_get_block(template.format, &template.block);
+ template.depth0 = 1;
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- template.width[0] = r->pot_buffers ?
+ template.width0 = r->pot_buffers ?
util_next_power_of_two(r->picture_width / 2) :
r->picture_width / 2;
- template.height[0] = r->pot_buffers ?
+ template.height0 = r->pot_buffers ?
util_next_power_of_two(r->picture_height / 2) :
r->picture_height / 2;
}
else if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422)
- template.height[0] = r->pot_buffers ?
+ template.height0 = r->pot_buffers ?
util_next_power_of_two(r->picture_height / 2) :
r->picture_height / 2;
@@ -1082,6 +1089,9 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r,
assert(ycbcr_vb);
assert(pos < r->macroblocks_per_batch);
+ mo_vec[1].x = 0;
+ mo_vec[1].y = 0;
+
switch (mb->mb_type) {
case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
{
@@ -1270,6 +1280,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
r->pipe->set_viewport_state(r->pipe, &r->viewport);
+ r->pipe->set_scissor_state(r->pipe, &r->scissor);
vs_consts = pipe_buffer_map
(
@@ -1277,8 +1288,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
);
- vs_consts->denorm.x = r->surface->width[0];
- vs_consts->denorm.y = r->surface->height[0];
+ vs_consts->denorm.x = r->surface->width0;
+ vs_consts->denorm.y = r->surface->height0;
pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf.buffer);
@@ -1290,8 +1301,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
r->pipe->set_vertex_elements(r->pipe, 4, r->vertex_elems);
- r->pipe->set_sampler_textures(r->pipe, 3, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 3, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 3, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 3, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->i_vs);
r->pipe->bind_fs_state(r->pipe, r->i_fs);
@@ -1304,8 +1315,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
r->textures.individual.ref[0] = r->past;
- r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
@@ -1318,8 +1329,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
r->textures.individual.ref[0] = r->past;
- r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
@@ -1332,8 +1343,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
r->textures.individual.ref[0] = r->future;
- r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
@@ -1346,8 +1357,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
r->textures.individual.ref[0] = r->future;
- r->pipe->set_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 4, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
@@ -1361,8 +1372,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems);
r->textures.individual.ref[0] = r->past;
r->textures.individual.ref[1] = r->future;
- r->pipe->set_sampler_textures(r->pipe, 5, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 5, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->b_vs[0]);
r->pipe->bind_fs_state(r->pipe, r->b_fs[0]);
@@ -1376,8 +1387,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems);
r->textures.individual.ref[0] = r->past;
r->textures.individual.ref[1] = r->future;
- r->pipe->set_sampler_textures(r->pipe, 5, r->textures.all);
- r->pipe->bind_sampler_states(r->pipe, 5, r->samplers.all);
+ r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
+ r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
r->pipe->bind_vs_state(r->pipe, r->b_vs[1]);
r->pipe->bind_fs_state(r->pipe, r->b_fs[1]);
@@ -1444,7 +1455,7 @@ grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
assert(r);
assert(blocks);
- tex_pitch = r->tex_transfer[0]->stride / r->tex_transfer[0]->block.size;
+ tex_pitch = r->tex_transfer[0]->stride / util_format_get_blocksize(r->tex_transfer[0]->texture->format);
texels = r->texels[0] + mbpy * tex_pitch + mbpx;
for (y = 0; y < 2; ++y) {
@@ -1483,7 +1494,7 @@ grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
mbpy /= 2;
for (tb = 0; tb < 2; ++tb) {
- tex_pitch = r->tex_transfer[tb + 1]->stride / r->tex_transfer[tb + 1]->block.size;
+ tex_pitch = r->tex_transfer[tb + 1]->stride / util_format_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
texels = r->texels[tb + 1] + mbpy * tex_pitch + mbpx;
if ((cbp >> (1 - tb)) & 1) {
@@ -1627,8 +1638,8 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
renderer->past = past;
renderer->future = future;
renderer->fence = fence;
- renderer->surface_tex_inv_size.x = 1.0f / surface->width[0];
- renderer->surface_tex_inv_size.y = 1.0f / surface->height[0];
+ renderer->surface_tex_inv_size.x = 1.0f / surface->width0;
+ renderer->surface_tex_inv_size.y = 1.0f / surface->height0;
}
while (num_macroblocks) {
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
index 5d2c1273ee..64184337a0 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
@@ -62,6 +62,7 @@ struct vl_mpeg12_mc_renderer
unsigned macroblocks_per_batch;
struct pipe_viewport_state viewport;
+ struct pipe_scissor_state scissor;
struct pipe_constant_buffer vs_const_buf;
struct pipe_constant_buffer fs_const_buf;
struct pipe_framebuffer_state fb_state;
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.c b/src/gallium/auxiliary/vl/vl_shader_build.c
index faa20a903c..d011ef97bd 100644
--- a/src/gallium/auxiliary/vl/vl_shader_build.c
+++ b/src/gallium/auxiliary/vl/vl_shader_build.c
@@ -36,10 +36,10 @@ struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = name;
- decl.Semantic.SemanticIndex = index;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Semantic.Name = name;
+ decl.Semantic.Index = index;
+ decl.Range.First = first;
+ decl.Range.Last = last;
return decl;
}
@@ -64,11 +64,11 @@ struct tgsi_full_declaration vl_decl_interpolated_input
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = name;
- decl.Semantic.SemanticIndex = index;
+ decl.Semantic.Name = name;
+ decl.Semantic.Index = index;
decl.Declaration.Interpolate = interpolation;;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Range.First = first;
+ decl.Range.Last = last;
return decl;
}
@@ -79,10 +79,10 @@ struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int i
decl.Declaration.File = TGSI_FILE_CONSTANT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = name;
- decl.Semantic.SemanticIndex = index;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Semantic.Name = name;
+ decl.Semantic.Index = index;
+ decl.Range.First = first;
+ decl.Range.Last = last;
return decl;
}
@@ -93,10 +93,10 @@ struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int inde
decl.Declaration.File = TGSI_FILE_OUTPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = name;
- decl.Semantic.SemanticIndex = index;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Semantic.Name = name;
+ decl.Semantic.Index = index;
+ decl.Range.First = first;
+ decl.Range.Last = last;
return decl;
}
@@ -107,8 +107,8 @@ struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Range.First = first;
+ decl.Range.Last = last;
return decl;
}
@@ -119,8 +119,8 @@ struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int l
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.DeclarationRange.First = first;
- decl.DeclarationRange.Last = last;
+ decl.Range.First = first;
+ decl.Range.Last = last;
return decl;
}
@@ -138,11 +138,11 @@ struct tgsi_full_instruction vl_inst2
inst.Instruction.Opcode = opcode;
inst.Instruction.NumDstRegs = 1;
- inst.FullDstRegisters[0].DstRegister.File = dst_file;
- inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+ inst.Dst[0].Register.File = dst_file;
+ inst.Dst[0].Register.Index = dst_index;
inst.Instruction.NumSrcRegs = 1;
- inst.FullSrcRegisters[0].SrcRegister.File = src_file;
- inst.FullSrcRegisters[0].SrcRegister.Index = src_index;
+ inst.Src[0].Register.File = src_file;
+ inst.Src[0].Register.Index = src_index;
return inst;
}
@@ -162,13 +162,13 @@ struct tgsi_full_instruction vl_inst3
inst.Instruction.Opcode = opcode;
inst.Instruction.NumDstRegs = 1;
- inst.FullDstRegisters[0].DstRegister.File = dst_file;
- inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+ inst.Dst[0].Register.File = dst_file;
+ inst.Dst[0].Register.Index = dst_index;
inst.Instruction.NumSrcRegs = 2;
- inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
- inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
- inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
- inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
+ inst.Src[0].Register.File = src1_file;
+ inst.Src[0].Register.Index = src1_index;
+ inst.Src[1].Register.File = src2_file;
+ inst.Src[1].Register.Index = src2_index;
return inst;
}
@@ -188,14 +188,15 @@ struct tgsi_full_instruction vl_tex
inst.Instruction.Opcode = TGSI_OPCODE_TEX;
inst.Instruction.NumDstRegs = 1;
- inst.FullDstRegisters[0].DstRegister.File = dst_file;
- inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+ inst.Dst[0].Register.File = dst_file;
+ inst.Dst[0].Register.Index = dst_index;
inst.Instruction.NumSrcRegs = 2;
- inst.InstructionExtTexture.Texture = tex;
- inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
- inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
- inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
- inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
+ inst.Instruction.Texture = 1;
+ inst.Texture.Texture = tex;
+ inst.Src[0].Register.File = src1_file;
+ inst.Src[0].Register.Index = src1_index;
+ inst.Src[1].Register.File = src2_file;
+ inst.Src[1].Register.Index = src2_index;
return inst;
}
@@ -217,15 +218,15 @@ struct tgsi_full_instruction vl_inst4
inst.Instruction.Opcode = opcode;
inst.Instruction.NumDstRegs = 1;
- inst.FullDstRegisters[0].DstRegister.File = dst_file;
- inst.FullDstRegisters[0].DstRegister.Index = dst_index;
+ inst.Dst[0].Register.File = dst_file;
+ inst.Dst[0].Register.Index = dst_index;
inst.Instruction.NumSrcRegs = 3;
- inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
- inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
- inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
- inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
- inst.FullSrcRegisters[2].SrcRegister.File = src3_file;
- inst.FullSrcRegisters[2].SrcRegister.Index = src3_index;
+ inst.Src[0].Register.File = src1_file;
+ inst.Src[0].Register.Index = src1_index;
+ inst.Src[1].Register.File = src2_file;
+ inst.Src[1].Register.Index = src2_index;
+ inst.Src[2].Register.File = src3_file;
+ inst.Src[2].Register.Index = src3_index;
return inst;
}