aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/Automake.inc3
-rw-r--r--mesalib/src/gallium/Makefile.am13
-rw-r--r--mesalib/src/gallium/auxiliary/Android.mk4
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.am42
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.sources336
-rw-r--r--mesalib/src/gallium/auxiliary/SConscript2
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_context.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_atomic.h56
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blit.c4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c7
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_box.h118
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_pack.py35
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_pstipple.c228
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_pstipple.h5
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_rect.h18
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_simple_shaders.c80
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_simple_shaders.h10
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_snprintf.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tests.c268
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tests.h37
-rw-r--r--mesalib/src/glsl/Makefile.sources4
-rw-r--r--mesalib/src/glsl/ast.h29
-rw-r--r--mesalib/src/glsl/glsl_lexer.ll23
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp10
-rw-r--r--mesalib/src/glsl/glsl_types.cpp59
-rw-r--r--mesalib/src/glsl/glsl_types.h33
-rwxr-xr-xmesalib/src/glsl/ir.cpp48
-rw-r--r--mesalib/src/glsl/ir.h30
-rw-r--r--mesalib/src/glsl/ir_optimization.h1
-rw-r--r--mesalib/src/glsl/ir_reader.cpp2
-rw-r--r--mesalib/src/glsl/ir_uniform.h6
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp50
-rw-r--r--mesalib/src/glsl/linker.cpp44
-rw-r--r--mesalib/src/glsl/list.h21
-rw-r--r--mesalib/src/glsl/loop_unroll.cpp13
-rw-r--r--mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp111
-rw-r--r--mesalib/src/glsl/main.cpp10
-rw-r--r--mesalib/src/glsl/opt_algebraic.cpp49
-rw-r--r--mesalib/src/glsl/opt_cse.cpp9
-rw-r--r--mesalib/src/glsl/s_expression.cpp2
-rw-r--r--mesalib/src/glsl/s_expression.h2
-rw-r--r--mesalib/src/mapi/glapi/SConscript1
-rw-r--r--mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml11
-rw-r--r--mesalib/src/mapi/glapi/gen/Makefile.am3
-rw-r--r--mesalib/src/mapi/glapi/gen/extension_helper.py324
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_API.xml2
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_offsets.py120
-rw-r--r--mesalib/src/mapi/glapi/gen/mesadef.py215
-rw-r--r--mesalib/src/mesa/Android.libmesa_dricore.mk8
-rw-r--r--mesalib/src/mesa/Android.libmesa_st_mesa.mk5
-rw-r--r--mesalib/src/mesa/Makefile.am3
-rwxr-xr-xmesalib/src/mesa/drivers/dri/common/dri_util.c22
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h18
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/mesa.def839
-rw-r--r--mesalib/src/mesa/main/api_validate.c56
-rw-r--r--mesalib/src/mesa/main/api_validate.h6
-rw-r--r--mesalib/src/mesa/main/attrib.c3
-rw-r--r--mesalib/src/mesa/main/context.c11
-rw-r--r--mesalib/src/mesa/main/errors.c172
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/get_hash_params.py5
-rw-r--r--mesalib/src/mesa/main/imports.c19
-rwxr-xr-xmesalib/src/mesa/main/imports.h3
-rw-r--r--mesalib/src/mesa/main/mtypes.h5
-rw-r--r--mesalib/src/mesa/main/shaderapi.c6
-rw-r--r--mesalib/src/mesa/main/sse_minmax.c97
-rw-r--r--mesalib/src/mesa/main/sse_minmax.h30
-rw-r--r--mesalib/src/mesa/main/streaming-load-memcpy.c3
-rw-r--r--mesalib/src/mesa/main/texformat.c3
-rw-r--r--mesalib/src/mesa/main/texstore.c4
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp260
-rw-r--r--mesalib/src/mesa/main/uniforms.c98
-rw-r--r--mesalib/src/mesa/main/uniforms.h4
-rw-r--r--mesalib/src/mesa/main/viewport.c8
-rw-r--r--mesalib/src/mesa/program/prog_execute.c156
-rw-r--r--mesalib/src/mesa/program/prog_instruction.c12
-rw-r--r--mesalib/src/mesa/program/prog_instruction.h12
-rw-r--r--mesalib/src/mesa/program/program_lexer.l14
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_rasterizer.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_viewport.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c30
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawtex.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp19
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c12
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c23
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c14
-rw-r--r--mesalib/src/mesa/x86/common_x86_features.h26
-rw-r--r--mesalib/src/util/Makefile.sources3
-rw-r--r--mesalib/src/util/hash_table.c10
-rw-r--r--mesalib/src/util/macros.h18
-rw-r--r--mesalib/src/util/strtod.cpp (renamed from mesalib/src/glsl/strtod.c)32
-rw-r--r--mesalib/src/util/strtod.h (renamed from mesalib/src/glsl/strtod.h)4
97 files changed, 2224 insertions, 2383 deletions
diff --git a/mesalib/src/gallium/Automake.inc b/mesalib/src/gallium/Automake.inc
index c43f735c3..9b312b113 100644
--- a/mesalib/src/gallium/Automake.inc
+++ b/mesalib/src/gallium/Automake.inc
@@ -58,7 +58,8 @@ GALLIUM_WINSYS_CFLAGS = \
GALLIUM_PIPE_LOADER_WINSYS_LIBS = \
- $(top_builddir)/src/gallium/winsys/sw/null/libws_null.la
+ $(top_builddir)/src/gallium/winsys/sw/null/libws_null.la \
+ $(top_builddir)/src/gallium/winsys/sw/wrapper/libwsw.la
if HAVE_DRISW
GALLIUM_PIPE_LOADER_WINSYS_LIBS += \
diff --git a/mesalib/src/gallium/Makefile.am b/mesalib/src/gallium/Makefile.am
index 21595a1aa..81840b208 100644
--- a/mesalib/src/gallium/Makefile.am
+++ b/mesalib/src/gallium/Makefile.am
@@ -138,14 +138,6 @@ if HAVE_OPENVG
SUBDIRS += state_trackers/vega
endif
-if HAVE_GALLIUM_EGL
-SUBDIRS += state_trackers/egl targets/egl-static
-endif
-
-if HAVE_GALLIUM_GBM
-SUBDIRS += state_trackers/gbm targets/gbm
-endif
-
if HAVE_X11_DRIVER
SUBDIRS += state_trackers/glx/xlib targets/libgl-xlib
endif
@@ -174,11 +166,16 @@ if HAVE_ST_XVMC
SUBDIRS += state_trackers/xvmc targets/xvmc
endif
+if HAVE_ST_NINE
+SUBDIRS += state_trackers/nine targets/d3dadapter9
+endif
+
##
## Don't forget to bundle the remaining (non autotools) state-trackers/targets
##
EXTRA_DIST += \
+ include \
state_trackers/README \
state_trackers/wgl targets/libgl-gdi \
targets/graw-gdi targets/graw-null targets/graw-xlib \
diff --git a/mesalib/src/gallium/auxiliary/Android.mk b/mesalib/src/gallium/auxiliary/Android.mk
index 8046943c1..0bc183170 100644
--- a/mesalib/src/gallium/auxiliary/Android.mk
+++ b/mesalib/src/gallium/auxiliary/Android.mk
@@ -28,7 +28,9 @@ include $(LOCAL_PATH)/Makefile.sources
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(C_SOURCES)
+LOCAL_SRC_FILES := \
+ $(C_SOURCES) \
+ $(VL_STUB_SOURCES)
LOCAL_C_INCLUDES := \
$(GALLIUM_TOP)/auxiliary/util \
diff --git a/mesalib/src/gallium/auxiliary/Makefile.am b/mesalib/src/gallium/auxiliary/Makefile.am
index 4d8ba89cc..4085e510b 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.am
+++ b/mesalib/src/gallium/auxiliary/Makefile.am
@@ -30,8 +30,7 @@ AM_CXXFLAGS += \
$(LLVM_CXXFLAGS)
libgallium_la_SOURCES += \
- $(GALLIVM_SOURCES) \
- $(GALLIVM_CPP_SOURCES)
+ $(GALLIVM_SOURCES)
endif
@@ -46,3 +45,42 @@ indices/u_unfilled_gen.c: $(srcdir)/indices/u_unfilled_gen.py
util/u_format_table.c: $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format_pack.py $(srcdir)/util/u_format_parse.py $(srcdir)/util/u_format.csv
$(AM_V_at)$(MKDIR_P) util
$(AM_V_GEN) $(PYTHON2) $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format.csv > $@
+
+
+noinst_LTLIBRARIES += libgalliumvl_stub.la
+libgalliumvl_stub_la_SOURCES = \
+ $(VL_STUB_SOURCES)
+
+if NEED_GALLIUM_VL
+
+noinst_LTLIBRARIES += libgalliumvl.la
+
+libgalliumvl_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(VL_CFLAGS) \
+ $(LIBDRM_CFLAGS) \
+ $(GALLIUM_PIPE_LOADER_DEFINES) \
+ -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
+
+if HAVE_GALLIUM_STATIC_TARGETS
+libgalliumvl_la_CFLAGS += \
+ -DGALLIUM_STATIC_TARGETS=1
+
+endif # HAVE_GALLIUM_STATIC_TARGETS
+
+libgalliumvl_la_SOURCES = \
+ $(VL_SOURCES)
+
+endif
+
+EXTRA_DIST = \
+ Android.mk SConscript \
+ indices/u_indices.c \
+ indices/u_unfilled_indices.c \
+ indices/u_indices_gen.py \
+ indices/u_unfilled_gen.py \
+ target-helpers \
+ util/u_format.csv \
+ util/u_format_pack.py \
+ util/u_format_parse.py \
+ util/u_format_table.py
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index f6621ef99..862626461 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -1,13 +1,23 @@
C_SOURCES := \
cso_cache/cso_cache.c \
+ cso_cache/cso_cache.h \
cso_cache/cso_context.c \
+ cso_cache/cso_context.h \
cso_cache/cso_hash.c \
+ cso_cache/cso_hash.h \
+ draw/draw_cliptest_tmp.h \
draw/draw_context.c \
+ draw/draw_context.h \
+ draw/draw_decompose_tmp.h \
draw/draw_fs.c \
+ draw/draw_fs.h \
draw/draw_gs.c \
- draw/draw_pipe.c \
+ draw/draw_gs.h \
+ draw/draw_gs_tmp.h \
draw/draw_pipe_aaline.c \
draw/draw_pipe_aapoint.c \
+ draw/draw_pipe.c \
+ draw/draw_pipe.h \
draw/draw_pipe_clip.c \
draw/draw_pipe_cull.c \
draw/draw_pipe_flatshade.c \
@@ -22,142 +32,315 @@ C_SOURCES := \
draw/draw_pipe_wide_line.c \
draw/draw_pipe_wide_point.c \
draw/draw_prim_assembler.c \
+ draw/draw_prim_assembler.h \
+ draw/draw_prim_assembler_tmp.h \
+ draw/draw_private.h \
draw/draw_pt.c \
+ draw/draw_pt_decompose.h \
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.h \
draw/draw_pt_post_vs.c \
draw/draw_pt_so_emit.c \
draw/draw_pt_util.c \
draw/draw_pt_vsplit.c \
+ draw/draw_pt_vsplit_tmp.h \
+ draw/draw_so_emit_tmp.h \
+ draw/draw_split_tmp.h \
+ draw/draw_vbuf.h \
draw/draw_vertex.c \
+ draw/draw_vertex.h \
draw/draw_vs.c \
draw/draw_vs_exec.c \
+ draw/draw_vs.h \
draw/draw_vs_variant.c \
hud/font.c \
+ hud/font.h \
hud/hud_context.c \
+ hud/hud_context.h \
hud/hud_cpu.c \
+ hud/hud_driver_query.c \
hud/hud_fps.c \
- hud/hud_driver_query.c \
+ hud/hud_private.h \
+ indices/u_indices.h \
+ indices/u_indices_priv.h \
indices/u_primconvert.c \
+ indices/u_primconvert.h \
+ os/os_memory_aligned.h \
+ os/os_memory_debug.h \
+ os/os_memory_stdc.h \
+ os/os_memory.h \
os/os_misc.c \
+ os/os_misc.h \
+ os/os_mman.h \
os/os_process.c \
+ os/os_process.h \
+ os/os_thread.h \
os/os_time.c \
+ os/os_time.h \
pipebuffer/pb_buffer_fenced.c \
+ pipebuffer/pb_buffer_fenced.h \
+ pipebuffer/pb_buffer.h \
pipebuffer/pb_buffer_malloc.c \
pipebuffer/pb_bufmgr_alt.c \
pipebuffer/pb_bufmgr_cache.c \
pipebuffer/pb_bufmgr_debug.c \
+ pipebuffer/pb_bufmgr.h \
pipebuffer/pb_bufmgr_mm.c \
pipebuffer/pb_bufmgr_ondemand.c \
pipebuffer/pb_bufmgr_pool.c \
pipebuffer/pb_bufmgr_slab.c \
pipebuffer/pb_validate.c \
+ pipebuffer/pb_validate.h \
+ postprocess/filters.h \
+ postprocess/postprocess.h \
postprocess/pp_celshade.c \
+ postprocess/pp_celshade.h \
postprocess/pp_colors.c \
+ postprocess/pp_colors.h \
+ postprocess/pp_filters.h \
postprocess/pp_init.c \
+ postprocess/pp_mlaa_areamap.h \
postprocess/pp_mlaa.c \
- postprocess/pp_run.c \
+ postprocess/pp_mlaa.h \
+ postprocess/pp_private.h \
postprocess/pp_program.c \
+ postprocess/pp_run.c \
rbug/rbug_connection.c \
+ rbug/rbug_connection.h \
rbug/rbug_context.c \
+ rbug/rbug_context.h \
rbug/rbug_core.c \
+ rbug/rbug_core.h \
rbug/rbug_demarshal.c \
- rbug/rbug_texture.c \
+ rbug/rbug.h \
+ rbug/rbug_internal.h \
+ rbug/rbug_proto.h \
rbug/rbug_shader.c \
+ rbug/rbug_shader.h \
+ rbug/rbug_texture.c \
+ rbug/rbug_texture.h \
rtasm/rtasm_cpu.c \
+ rtasm/rtasm_cpu.h \
rtasm/rtasm_execmem.c \
+ rtasm/rtasm_execmem.h \
rtasm/rtasm_x86sse.c \
+ rtasm/rtasm_x86sse.h \
tgsi/tgsi_build.c \
+ tgsi/tgsi_build.h \
tgsi/tgsi_dump.c \
+ tgsi/tgsi_dump.h \
tgsi/tgsi_exec.c \
+ tgsi/tgsi_exec.h \
tgsi/tgsi_info.c \
+ tgsi/tgsi_info.h \
tgsi/tgsi_iterate.c \
+ tgsi/tgsi_iterate.h \
tgsi/tgsi_lowering.c \
+ tgsi/tgsi_lowering.h \
+ tgsi/tgsi_opcode_tmp.h \
tgsi/tgsi_parse.c \
+ tgsi/tgsi_parse.h \
tgsi/tgsi_sanity.c \
+ tgsi/tgsi_sanity.h \
tgsi/tgsi_scan.c \
+ tgsi/tgsi_scan.h \
tgsi/tgsi_strings.c \
+ tgsi/tgsi_strings.h \
tgsi/tgsi_text.c \
+ tgsi/tgsi_text.h \
tgsi/tgsi_transform.c \
+ tgsi/tgsi_transform.h \
tgsi/tgsi_ureg.c \
+ tgsi/tgsi_ureg.h \
tgsi/tgsi_util.c \
+ tgsi/tgsi_util.h \
translate/translate.c \
+ translate/translate.h \
translate/translate_cache.c \
+ translate/translate_cache.h \
translate/translate_generic.c \
translate/translate_sse.c \
+ util/dbghelp.h \
+ util/u_atomic.h \
+ util/u_bitmask.c \
+ util/u_bitmask.h \
+ util/u_blit.c \
+ util/u_blit.h \
+ util/u_blitter.c \
+ util/u_blitter.h \
+ util/u_box.h \
+ util/u_cache.c \
+ util/u_cache.h \
+ util/u_caps.c \
+ util/u_caps.h \
+ util/u_clear.h \
+ util/u_cpu_detect.c \
+ util/u_cpu_detect.h \
util/u_debug.c \
util/u_debug_describe.c \
+ util/u_debug_describe.h \
util/u_debug_flush.c \
+ util/u_debug_flush.h \
+ util/u_debug.h \
util/u_debug_memory.c \
util/u_debug_refcnt.c \
+ util/u_debug_refcnt.h \
util/u_debug_stack.c \
+ util/u_debug_stack.h \
util/u_debug_symbol.c \
- util/u_dump_defines.c \
- util/u_dump_state.c \
- util/u_bitmask.c \
- util/u_blit.c \
- util/u_blitter.c \
- util/u_cache.c \
- util/u_caps.c \
- util/u_cpu_detect.c \
+ util/u_debug_symbol.h \
+ util/u_dirty_flags.h \
+ util/u_dirty_surfaces.h \
util/u_dl.c \
+ util/u_dl.h \
+ util/u_double_list.h \
util/u_draw.c \
+ util/u_draw.h \
util/u_draw_quad.c \
+ util/u_draw_quad.h \
+ util/u_dual_blend.h \
+ util/u_dump_defines.c \
+ util/u_dump.h \
+ util/u_dump_state.c \
+ util/u_dynarray.h \
+ util/u_fifo.h \
+ util/u_format_bptc.c \
+ util/u_format_bptc.h \
util/u_format.c \
- util/u_format_other.c \
+ util/u_format_etc.c \
+ util/u_format_etc.h \
+ util/u_format.h \
util/u_format_latc.c \
- util/u_format_s3tc.c \
+ util/u_format_latc.h \
+ util/u_format_other.c \
+ util/u_format_other.h \
+ util/u_format_r11g11b10f.h \
+ util/u_format_rgb9e5.h \
util/u_format_rgtc.c \
- util/u_format_etc.c \
- util/u_format_bptc.c \
+ util/u_format_rgtc.h \
+ util/u_format_s3tc.c \
+ util/u_format_s3tc.h \
util/u_format_tests.c \
+ util/u_format_tests.h \
util/u_format_yuv.c \
+ util/u_format_yuv.h \
util/u_format_zs.c \
+ util/u_format_zs.h \
util/u_framebuffer.c \
+ util/u_framebuffer.h \
util/u_gen_mipmap.c \
+ util/u_gen_mipmap.h \
+ util/u_half.h \
util/u_handle_table.c \
+ util/u_handle_table.h \
util/u_hash.c \
+ util/u_hash.h \
util/u_hash_table.c \
+ util/u_hash_table.h \
util/u_helpers.c \
+ util/u_helpers.h \
util/u_index_modify.c \
+ util/u_index_modify.h \
+ util/u_init.h \
+ util/u_inlines.h \
util/u_keymap.c \
+ util/u_keymap.h \
util/u_linear.c \
+ util/u_linear.h \
util/u_linkage.c \
- util/u_network.c \
+ util/u_linkage.h \
util/u_math.c \
+ util/u_math.h \
+ util/u_memory.h \
util/u_mm.c \
+ util/u_mm.h \
+ util/u_network.c \
+ util/u_network.h \
+ util/u_pack_color.h \
+ util/u_pointer.h \
+ util/u_prim.h \
util/u_pstipple.c \
+ util/u_pstipple.h \
+ util/u_range.h \
+ util/u_rect.h \
+ util/u_resource.c \
+ util/u_resource.h \
util/u_ringbuffer.c \
+ util/u_ringbuffer.h \
util/u_sampler.c \
+ util/u_sampler.h \
+ util/u_simple_list.h \
util/u_simple_shaders.c \
+ util/u_simple_shaders.h \
util/u_slab.c \
+ util/u_slab.h \
util/u_snprintf.c \
+ util/u_split_prim.h \
+ util/u_sse.h \
util/u_staging.c \
+ util/u_staging.h \
+ util/u_string.h \
util/u_suballoc.c \
+ util/u_suballoc.h \
util/u_surface.c \
+ util/u_surface.h \
util/u_surfaces.c \
+ util/u_surfaces.h \
+ util/u_tests.c \
+ util/u_tests.h \
util/u_texture.c \
+ util/u_texture.h \
util/u_tile.c \
+ util/u_tile.h \
+ util/u_time.h \
util/u_transfer.c \
- util/u_resource.c \
+ util/u_transfer.h \
util/u_upload_mgr.c \
+ util/u_upload_mgr.h \
util/u_vbuf.c \
- vl/vl_csc.c \
+ util/u_vbuf.h \
+ util/u_video.h
+
+VL_SOURCES := \
vl/vl_compositor.c \
+ vl/vl_compositor.h \
+ vl/vl_csc.c \
+ vl/vl_csc.h \
+ vl/vl_decoder.c \
+ vl/vl_decoder.h \
+ vl/vl_defines.h \
+ vl/vl_deint_filter.c \
+ vl/vl_deint_filter.h \
+ vl/vl_idct.c \
+ vl/vl_idct.h \
vl/vl_matrix_filter.c \
+ vl/vl_matrix_filter.h \
+ vl/vl_mc.c \
+ vl/vl_mc.h \
vl/vl_median_filter.c \
- vl/vl_decoder.c \
- vl/vl_mpeg12_decoder.c \
+ vl/vl_median_filter.h \
vl/vl_mpeg12_bitstream.c \
+ vl/vl_mpeg12_bitstream.h \
+ vl/vl_mpeg12_decoder.c \
+ vl/vl_mpeg12_decoder.h \
+ vl/vl_rbsp.h \
+ vl/vl_types.h \
+ vl/vl_vertex_buffers.c \
+ vl/vl_vertex_buffers.h \
+ vl/vl_video_buffer.c \
+ vl/vl_video_buffer.h \
+ vl/vl_vlc.h \
+ vl/vl_winsys.h \
+ vl/vl_winsys_dri.c \
vl/vl_zscan.c \
- vl/vl_idct.c \
- vl/vl_mc.c \
- vl/vl_vertex_buffers.c \
- vl/vl_video_buffer.c \
- vl/vl_deint_filter.c
+ vl/vl_zscan.h
+
+VL_STUB_SOURCES := \
+ vl/vl_stubs.c
GENERATED_SOURCES := \
indices/u_indices_gen.c \
@@ -165,42 +348,67 @@ GENERATED_SOURCES := \
util/u_format_table.c
GALLIVM_SOURCES := \
- gallivm/lp_bld_arit.c \
- gallivm/lp_bld_arit_overflow.c \
- gallivm/lp_bld_assert.c \
- gallivm/lp_bld_bitarit.c \
- gallivm/lp_bld_const.c \
- gallivm/lp_bld_conv.c \
- gallivm/lp_bld_flow.c \
- gallivm/lp_bld_format_aos.c \
- gallivm/lp_bld_format_aos_array.c \
- gallivm/lp_bld_format_float.c \
- gallivm/lp_bld_format_srgb.c \
- gallivm/lp_bld_format_soa.c \
- gallivm/lp_bld_format_yuv.c \
- gallivm/lp_bld_gather.c \
- gallivm/lp_bld_init.c \
- gallivm/lp_bld_intr.c \
- gallivm/lp_bld_logic.c \
- gallivm/lp_bld_pack.c \
- gallivm/lp_bld_printf.c \
- gallivm/lp_bld_quad.c \
- gallivm/lp_bld_sample.c \
- gallivm/lp_bld_sample_aos.c \
- gallivm/lp_bld_sample_soa.c \
- gallivm/lp_bld_struct.c \
- gallivm/lp_bld_swizzle.c \
- gallivm/lp_bld_tgsi.c \
- gallivm/lp_bld_tgsi_action.c \
- gallivm/lp_bld_tgsi_aos.c \
- gallivm/lp_bld_tgsi_info.c \
- gallivm/lp_bld_tgsi_soa.c \
- gallivm/lp_bld_type.c \
- draw/draw_llvm.c \
- draw/draw_llvm_sample.c \
- draw/draw_vs_llvm.c \
- draw/draw_pt_fetch_shade_pipeline_llvm.c
-
-GALLIVM_CPP_SOURCES := \
+ gallivm/lp_bld_arit.c \
+ gallivm/lp_bld_arit.h \
+ gallivm/lp_bld_arit_overflow.c \
+ gallivm/lp_bld_arit_overflow.h \
+ gallivm/lp_bld_assert.c \
+ gallivm/lp_bld_assert.h \
+ gallivm/lp_bld_bitarit.c \
+ gallivm/lp_bld_bitarit.h \
+ gallivm/lp_bld_const.c \
+ gallivm/lp_bld_const.h \
+ gallivm/lp_bld_conv.c \
+ gallivm/lp_bld_conv.h \
gallivm/lp_bld_debug.cpp \
- gallivm/lp_bld_misc.cpp
+ gallivm/lp_bld_debug.h \
+ gallivm/lp_bld_flow.c \
+ gallivm/lp_bld_flow.h \
+ gallivm/lp_bld_format_aos_array.c \
+ gallivm/lp_bld_format_aos.c \
+ gallivm/lp_bld_format_float.c \
+ gallivm/lp_bld_format.h \
+ gallivm/lp_bld_format_soa.c \
+ gallivm/lp_bld_format_srgb.c \
+ gallivm/lp_bld_format_yuv.c \
+ gallivm/lp_bld_gather.c \
+ gallivm/lp_bld_gather.h \
+ gallivm/lp_bld.h \
+ gallivm/lp_bld_init.c \
+ gallivm/lp_bld_init.h \
+ gallivm/lp_bld_intr.c \
+ gallivm/lp_bld_intr.h \
+ gallivm/lp_bld_limits.h \
+ gallivm/lp_bld_logic.c \
+ gallivm/lp_bld_logic.h \
+ gallivm/lp_bld_misc.cpp \
+ gallivm/lp_bld_misc.h \
+ gallivm/lp_bld_pack.c \
+ gallivm/lp_bld_pack.h \
+ gallivm/lp_bld_printf.c \
+ gallivm/lp_bld_printf.h \
+ gallivm/lp_bld_quad.c \
+ gallivm/lp_bld_quad.h \
+ gallivm/lp_bld_sample_aos.c \
+ gallivm/lp_bld_sample_aos.h \
+ gallivm/lp_bld_sample.c \
+ gallivm/lp_bld_sample.h \
+ gallivm/lp_bld_sample_soa.c \
+ gallivm/lp_bld_struct.c \
+ gallivm/lp_bld_struct.h \
+ gallivm/lp_bld_swizzle.c \
+ gallivm/lp_bld_swizzle.h \
+ gallivm/lp_bld_tgsi_action.c \
+ gallivm/lp_bld_tgsi_action.h \
+ gallivm/lp_bld_tgsi_aos.c \
+ gallivm/lp_bld_tgsi.c \
+ gallivm/lp_bld_tgsi.h \
+ gallivm/lp_bld_tgsi_info.c \
+ gallivm/lp_bld_tgsi_soa.c \
+ gallivm/lp_bld_type.c \
+ gallivm/lp_bld_type.h \
+ draw/draw_llvm.c \
+ draw/draw_llvm.h \
+ draw/draw_llvm_sample.c \
+ draw/draw_pt_fetch_shade_pipeline_llvm.c \
+ draw/draw_vs_llvm.c
diff --git a/mesalib/src/gallium/auxiliary/SConscript b/mesalib/src/gallium/auxiliary/SConscript
index 94041d247..6cb6b8c65 100644
--- a/mesalib/src/gallium/auxiliary/SConscript
+++ b/mesalib/src/gallium/auxiliary/SConscript
@@ -36,13 +36,13 @@ env.Depends('util/u_format_table.c', [
source = env.ParseSourceList('Makefile.sources', [
'C_SOURCES',
+ 'VL_STUB_SOURCES',
'GENERATED_SOURCES'
])
if env['llvm']:
source += env.ParseSourceList('Makefile.sources', [
'GALLIVM_SOURCES',
- 'GALLIVM_CPP_SOURCES'
])
gallium = env.ConvenienceLibrary(
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c
index 18a878118..98678fc9f 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_context.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c
@@ -444,11 +444,9 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
viewport.scale[0] = 0.5f * hud->fb_width;
viewport.scale[1] = 0.5f * hud->fb_height;
viewport.scale[2] = 1.0f;
- viewport.scale[3] = 1.0f;
viewport.translate[0] = 0.5f * hud->fb_width;
viewport.translate[1] = 0.5f * hud->fb_height;
viewport.translate[2] = 0.0f;
- viewport.translate[3] = 0.0f;
cso_set_framebuffer(cso, &fb);
cso_set_sample_mask(cso, ~0);
diff --git a/mesalib/src/gallium/auxiliary/util/u_atomic.h b/mesalib/src/gallium/auxiliary/util/u_atomic.h
index 2f2b42b34..2500bc752 100644
--- a/mesalib/src/gallium/auxiliary/util/u_atomic.h
+++ b/mesalib/src/gallium/auxiliary/util/u_atomic.h
@@ -24,12 +24,12 @@
#define PIPE_ATOMIC_MSVC_INTRINSIC
#elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
#define PIPE_ATOMIC_ASM_MSVC_X86
+#elif defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 401)
+#define PIPE_ATOMIC_GCC_INTRINSIC
#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
#define PIPE_ATOMIC_ASM_GCC_X86
#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86_64))
#define PIPE_ATOMIC_ASM_GCC_X86_64
-#elif defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 401)
-#define PIPE_ATOMIC_GCC_INTRINSIC
#else
#error "Unsupported platform"
#endif
@@ -69,6 +69,18 @@ p_atomic_dec(int32_t *v)
}
static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+ return __sync_add_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+ return __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
{
return __sync_val_compare_and_swap(v, old, _new);
@@ -116,6 +128,18 @@ p_atomic_dec(int32_t *v)
}
static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+ return __sync_add_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+ return __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
{
return __sync_val_compare_and_swap(v, old, _new);
@@ -161,6 +185,18 @@ p_atomic_dec(int32_t *v)
}
static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+ return __sync_add_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+ return __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
{
return __sync_val_compare_and_swap(v, old, _new);
@@ -186,6 +222,8 @@ p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
#define p_atomic_dec_zero(_v) ((boolean) --(*(_v)))
#define p_atomic_inc(_v) ((void) (*(_v))++)
#define p_atomic_dec(_v) ((void) (*(_v))--)
+#define p_atomic_inc_return(_v) ((*(_v))++)
+#define p_atomic_dec_return(_v) ((*(_v))--)
#define p_atomic_cmpxchg(_v, old, _new) (*(_v) == old ? *(_v) = (_new) : *(_v))
#endif
@@ -288,6 +326,12 @@ p_atomic_inc(int32_t *v)
_InterlockedIncrement((long *)v);
}
+static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+ return _InterlockedIncrement((long *)v);
+}
+
static INLINE void
p_atomic_dec(int32_t *v)
{
@@ -295,6 +339,12 @@ p_atomic_dec(int32_t *v)
}
static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+ return _InterlockedDecrement((long *)v);
+}
+
+static INLINE int32_t
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
{
return _InterlockedCompareExchange((long *)v, _new, old);
@@ -329,6 +379,8 @@ p_atomic_dec_zero(int32_t *v)
#define p_atomic_inc(_v) atomic_inc_32((uint32_t *) _v)
#define p_atomic_dec(_v) atomic_dec_32((uint32_t *) _v)
+#define p_atomic_inc_return(_v) atomic_inc_32_nv((uint32_t *) _v)
+#define p_atomic_dec_return(_v) atomic_dec_32_nv((uint32_t *) _v)
#define p_atomic_cmpxchg(_v, _old, _new) \
atomic_cas_32( (uint32_t *) _v, (uint32_t) _old, (uint32_t) _new)
diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c
index 2573bedf5..90408ffdc 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blit.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blit.c
@@ -188,7 +188,7 @@ set_vertex_shader(struct blit_state *ctx)
const uint semantic_indexes[] = { 0, 0 };
ctx->vs = util_make_vertex_passthrough_shader(ctx->pipe, 2,
semantic_names,
- semantic_indexes);
+ semantic_indexes, FALSE);
}
cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
@@ -559,11 +559,9 @@ util_blit_pixels_tex(struct blit_state *ctx,
ctx->viewport.scale[0] = 0.5f * dst->width;
ctx->viewport.scale[1] = 0.5f * dst->height;
ctx->viewport.scale[2] = 0.5f;
- ctx->viewport.scale[3] = 1.0f;
ctx->viewport.translate[0] = 0.5f * dst->width;
ctx->viewport.translate[1] = 0.5f * dst->height;
ctx->viewport.translate[2] = 0.5f;
- ctx->viewport.translate[3] = 0.0f;
cso_set_viewport(ctx->cso, &ctx->viewport);
/* texture */
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index e59fa0481..9d087fe8a 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -319,7 +319,8 @@ static void bind_vs_pos_only(struct blitter_context_priv *ctx)
ctx->vs_pos_only =
util_make_vertex_passthrough_shader_with_so(pipe, 1, semantic_names,
- semantic_indices, &so);
+ semantic_indices, FALSE,
+ &so);
}
pipe->bind_vs_state(pipe, ctx->vs_pos_only);
@@ -335,7 +336,7 @@ static void bind_vs_passthrough(struct blitter_context_priv *ctx)
const uint semantic_indices[] = { 0, 0 };
ctx->vs =
util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
- semantic_indices);
+ semantic_indices, FALSE);
}
pipe->bind_vs_state(pipe, ctx->vs);
@@ -682,11 +683,9 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx,
ctx->viewport.scale[0] = 0.5f * ctx->dst_width;
ctx->viewport.scale[1] = 0.5f * ctx->dst_height;
ctx->viewport.scale[2] = 1.0f;
- ctx->viewport.scale[3] = 1.0f;
ctx->viewport.translate[0] = 0.5f * ctx->dst_width;
ctx->viewport.translate[1] = 0.5f * ctx->dst_height;
ctx->viewport.translate[2] = 0.0f;
- ctx->viewport.translate[3] = 0.0f;
ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, &ctx->viewport);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_box.h b/mesalib/src/gallium/auxiliary/util/u_box.h
index 0b28d0f12..520a3d596 100644
--- a/mesalib/src/gallium/auxiliary/util/u_box.h
+++ b/mesalib/src/gallium/auxiliary/util/u_box.h
@@ -2,6 +2,7 @@
#define UTIL_BOX_INLINES_H
#include "pipe/p_state.h"
+#include "util/u_math.h"
static INLINE
void u_box_1d( unsigned x,
@@ -77,4 +78,121 @@ void u_box_3d( unsigned x,
box->depth = d;
}
+/* Clips @dst to width @w and height @h.
+ * Returns -1 if the resulting box would be empty (then @dst is left unchanged).
+ * 0 if nothing has been reduced.
+ * 1 if width has been reduced.
+ * 2 if height has been reduced.
+ * 3 if both width and height have been reduced.
+ * Aliasing permitted.
+ */
+static INLINE int
+u_box_clip_2d(struct pipe_box *dst,
+ const struct pipe_box *box, int w, int h)
+{
+ unsigned i;
+ int a[2], b[2], dim[2];
+ int *start, *end;
+ int res = 0;
+
+ if (!box->width || !box->height)
+ return -1;
+ dim[0] = w;
+ dim[1] = h;
+ a[0] = box->x;
+ a[1] = box->y;
+ b[0] = box->x + box->width;
+ b[1] = box->y + box->height;
+
+ for (i = 0; i < 2; ++i) {
+ start = (a[i] <= b[i]) ? &a[i] : &b[i];
+ end = (a[i] <= b[i]) ? &b[i] : &a[i];
+
+ if (*end < 0 || *start >= dim[i])
+ return -1;
+ if (*start < 0) {
+ *start = 0;
+ res |= (1 << i);
+ }
+ if (*end > dim[i]) {
+ *end = dim[i];
+ res |= (1 << i);
+ }
+ }
+
+ if (res) {
+ dst->x = a[0];
+ dst->y = a[1];
+ dst->width = b[0] - a[0];
+ dst->height = b[1] - a[1];
+ }
+ return res;
+}
+
+static INLINE int64_t
+u_box_volume_3d(const struct pipe_box *box)
+{
+ return (int64_t)box->width * box->height * box->depth;
+}
+
+/* Aliasing of @dst permitted. */
+static INLINE void
+u_box_union_2d(struct pipe_box *dst,
+ const struct pipe_box *a, const struct pipe_box *b)
+{
+ dst->x = MIN2(a->x, b->x);
+ dst->y = MIN2(a->y, b->y);
+
+ dst->width = MAX2(a->x + a->width, b->x + b->width) - dst->x;
+ dst->height = MAX2(a->y + a->height, b->y + b->height) - dst->y;
+}
+
+/* Aliasing of @dst permitted. */
+static INLINE void
+u_box_union_3d(struct pipe_box *dst,
+ const struct pipe_box *a, const struct pipe_box *b)
+{
+ dst->x = MIN2(a->x, b->x);
+ dst->y = MIN2(a->y, b->y);
+ dst->z = MIN2(a->z, b->z);
+
+ dst->width = MAX2(a->x + a->width, b->x + b->width) - dst->x;
+ dst->height = MAX2(a->y + a->height, b->y + b->height) - dst->y;
+ dst->depth = MAX2(a->z + a->depth, b->z + b->depth) - dst->z;
+}
+
+static INLINE boolean
+u_box_test_intersection_2d(const struct pipe_box *a,
+ const struct pipe_box *b)
+{
+ unsigned i;
+ int a_l[2], a_r[2], b_l[2], b_r[2];
+
+ a_l[0] = MIN2(a->x, a->x + a->width);
+ a_r[0] = MAX2(a->x, a->x + a->width);
+ a_l[1] = MIN2(a->y, a->y + a->height);
+ a_r[1] = MAX2(a->y, a->y + a->height);
+
+ b_l[0] = MIN2(b->x, b->x + b->width);
+ b_r[0] = MAX2(b->x, b->x + b->width);
+ b_l[1] = MIN2(b->y, b->y + b->height);
+ b_r[1] = MAX2(b->y, b->y + b->height);
+
+ for (i = 0; i < 2; ++i) {
+ if (a_l[i] > b_r[i] || a_r[i] < b_l[i])
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static INLINE void
+u_box_minify_2d(struct pipe_box *dst,
+ const struct pipe_box *src, unsigned l)
+{
+ dst->x = src->x >> l;
+ dst->y = src->y >> l;
+ dst->width = MAX2(src->width >> l, 1);
+ dst->height = MAX2(src->height >> l, 1);
+}
+
#endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
index 6ccf04c29..d5138cc05 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
@@ -207,9 +207,36 @@ def get_one_shift(type):
assert False
+def truncate_mantissa(x, bits):
+ '''Truncate an integer so it can be represented exactly with a floating
+ point mantissa'''
+
+ assert isinstance(x, (int, long))
+
+ s = 1
+ if x < 0:
+ s = -1
+ x = -x
+
+ # We can represent integers up to mantissa + 1 bits exactly
+ mask = (1 << (bits + 1)) - 1
+
+ # Slide the mask until the MSB matches
+ shift = 0
+ while (x >> shift) & ~mask:
+ shift += 1
+
+ x &= mask << shift
+ x *= s
+ return x
+
+
def value_to_native(type, value):
'''Get the value of unity for this type.'''
if type.type == FLOAT:
+ if type.size <= 32 \
+ and isinstance(value, (int, long)):
+ return truncate_mantissa(value, 23)
return value
if type.type == FIXED:
return int(value * (1 << (type.size/2)))
@@ -226,9 +253,9 @@ def native_to_constant(type, value):
'''Get the value of unity for this type.'''
if type.type == FLOAT:
if type.size <= 32:
- return "%ff" % value
+ return "%.1ff" % float(value)
else:
- return "%ff" % value
+ return "%.1f" % float(value)
else:
return str(int(value))
@@ -251,8 +278,8 @@ def clamp_expr(src_channel, dst_channel, dst_native_type, value):
dst_max = dst_channel.max()
# Translate the destination range to the src native value
- dst_min_native = value_to_native(src_channel, dst_min)
- dst_max_native = value_to_native(src_channel, dst_max)
+ dst_min_native = native_to_constant(src_channel, value_to_native(src_channel, dst_min))
+ dst_max_native = native_to_constant(src_channel, value_to_native(src_channel, dst_max))
if src_min < dst_min and src_max > dst_max:
return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native)
diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.c b/mesalib/src/gallium/auxiliary/util/u_pstipple.c
index 509f815c5..1e1ec4a98 100644
--- a/mesalib/src/gallium/auxiliary/util/u_pstipple.c
+++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.c
@@ -180,9 +180,7 @@ struct pstip_transform_context {
int maxInput;
uint samplersUsed; /**< bitfield of samplers used */
int freeSampler; /** an available sampler for the pstipple */
- int texTemp; /**< temp registers */
int numImmed;
- boolean firstInstruction;
uint coordOrigin;
};
@@ -243,7 +241,7 @@ free_bit(uint bitfield)
/**
- * TGSI instruction transform callback.
+ * TGSI transform prolog
* Before the first instruction, insert our new code to sample the
* stipple texture (using the fragment coord register) then kill the
* fragment if the stipple texture bit is off.
@@ -256,165 +254,95 @@ free_bit(uint bitfield)
* [...original code...]
*/
static void
-pstip_transform_inst(struct tgsi_transform_context *ctx,
- struct tgsi_full_instruction *inst)
+pstip_transform_prolog(struct tgsi_transform_context *ctx)
{
struct pstip_transform_context *pctx =
(struct pstip_transform_context *) ctx;
+ int wincoordInput;
+ int texTemp;
+
+ /* find free texture sampler */
+ pctx->freeSampler = free_bit(pctx->samplersUsed);
+ if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
+ pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
+
+ if (pctx->wincoordInput < 0)
+ wincoordInput = pctx->maxInput + 1;
+ else
+ wincoordInput = pctx->wincoordInput;
+
+ if (pctx->wincoordInput < 0) {
+ /* declare new position input reg */
+ tgsi_transform_input_decl(ctx, wincoordInput,
+ TGSI_SEMANTIC_POSITION, 1,
+ TGSI_INTERPOLATE_LINEAR);
+ }
- if (pctx->firstInstruction) {
- /* emit our new declarations before the first instruction */
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction newInst;
- uint i;
- int wincoordInput;
-
- /* find free texture sampler */
- pctx->freeSampler = free_bit(pctx->samplersUsed);
- if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
- pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
-
- if (pctx->wincoordInput < 0)
- wincoordInput = pctx->maxInput + 1;
- else
- wincoordInput = pctx->wincoordInput;
-
- /* find one free temp register */
- for (i = 0; i < 32; i++) {
- if ((pctx->tempsUsed & (1 << i)) == 0) {
- /* found a free temp */
- if (pctx->texTemp < 0)
- pctx->texTemp = i;
- else
- break;
- }
- }
- assert(pctx->texTemp >= 0);
-
- if (pctx->wincoordInput < 0) {
- /* declare new position input reg */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_INPUT;
- decl.Declaration.Interpolate = 1;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = TGSI_SEMANTIC_POSITION;
- decl.Semantic.Index = 0;
- decl.Range.First =
- decl.Range.Last = wincoordInput;
- decl.Interp.Interpolate = TGSI_INTERPOLATE_LINEAR;
- ctx->emit_declaration(ctx, &decl);
- }
+ /* declare new sampler */
+ tgsi_transform_sampler_decl(ctx, pctx->freeSampler);
- /* declare new sampler */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_SAMPLER;
- 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.Range.First =
- decl.Range.Last = pctx->texTemp;
- ctx->emit_declaration(ctx, &decl);
-
- /* emit immediate = {1/32, 1/32, 1, 1}
- * The index/position of this immediate will be pctx->numImmed
- */
- {
- static const float value[4] = { 1.0/32, 1.0/32, 1.0, 1.0 };
- struct tgsi_full_immediate immed;
- uint size = 4;
- immed = tgsi_default_full_immediate();
- immed.Immediate.NrTokens = 1 + size; /* one for the token itself */
- immed.u[0].Float = value[0];
- immed.u[1].Float = value[1];
- immed.u[2].Float = value[2];
- immed.u[3].Float = value[3];
- ctx->emit_immediate(ctx, &immed);
- }
-
- pctx->firstInstruction = FALSE;
-
-
- /*
- * Insert new MUL/TEX/KILL_IF instructions at start of program
- * Take gl_FragCoord, divide by 32 (stipple size), sample the
- * texture and kill fragment if needed.
- *
- * We'd like to use non-normalized texcoords to index into a RECT
- * texture, but we can only use REPEAT wrap mode with normalized
- * texcoords. Darn.
- */
-
- /* XXX invert wincoord if origin isn't lower-left... */
-
- /* MUL texTemp, INPUT[wincoord], 1/32; */
- newInst = tgsi_default_full_instruction();
- newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
- newInst.Instruction.NumDstRegs = 1;
- newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
- newInst.Dst[0].Register.Index = pctx->texTemp;
- newInst.Instruction.NumSrcRegs = 2;
- 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.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
- newInst.Dst[0].Register.Index = pctx->texTemp;
- newInst.Instruction.NumSrcRegs = 2;
- 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);
-
- /* KILL_IF -texTemp; # if -texTemp < 0, kill fragment */
- newInst = tgsi_default_full_instruction();
- newInst.Instruction.Opcode = TGSI_OPCODE_KILL_IF;
- newInst.Instruction.NumDstRegs = 0;
- newInst.Instruction.NumSrcRegs = 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);
+ /* Declare temp[0] reg if not already declared.
+ * We can always use temp[0] since this code is before
+ * the rest of the shader.
+ */
+ texTemp = 0;
+ if ((pctx->tempsUsed & (1 << texTemp)) == 0) {
+ tgsi_transform_temp_decl(ctx, texTemp);
}
- /* emit this instruction */
- ctx->emit_instruction(ctx, inst);
+ /* emit immediate = {1/32, 1/32, 1, 1}
+ * The index/position of this immediate will be pctx->numImmed
+ */
+ tgsi_transform_immediate_decl(ctx, 1.0/32.0, 1.0/32.0, 1.0, 1.0);
+
+ /*
+ * Insert new MUL/TEX/KILL_IF instructions at start of program
+ * Take gl_FragCoord, divide by 32 (stipple size), sample the
+ * texture and kill fragment if needed.
+ *
+ * We'd like to use non-normalized texcoords to index into a RECT
+ * texture, but we can only use REPEAT wrap mode with normalized
+ * texcoords. Darn.
+ */
+
+ /* XXX invert wincoord if origin isn't lower-left... */
+
+ /* MUL texTemp, INPUT[wincoord], 1/32; */
+ tgsi_transform_op2_inst(ctx, TGSI_OPCODE_MUL,
+ TGSI_FILE_TEMPORARY, texTemp,
+ TGSI_WRITEMASK_XYZW,
+ TGSI_FILE_INPUT, wincoordInput,
+ TGSI_FILE_IMMEDIATE, pctx->numImmed);
+
+ /* TEX texTemp, texTemp, sampler; */
+ tgsi_transform_tex_2d_inst(ctx,
+ TGSI_FILE_TEMPORARY, texTemp,
+ TGSI_FILE_TEMPORARY, texTemp,
+ pctx->freeSampler);
+
+ /* KILL_IF -texTemp; # if -texTemp < 0, kill fragment */
+ tgsi_transform_kill_inst(ctx,
+ TGSI_FILE_TEMPORARY, texTemp,
+ TGSI_SWIZZLE_W);
}
/**
* Given a fragment shader, return a new fragment shader which
* samples a stipple texture and executes KILL.
+ * \param samplerUnitOut returns the index of the sampler unit which
+ * will be used to sample the stipple texture
*/
-struct pipe_shader_state *
-util_pstipple_create_fragment_shader(struct pipe_context *pipe,
- struct pipe_shader_state *fs,
+struct tgsi_token *
+util_pstipple_create_fragment_shader(const struct tgsi_token *tokens,
unsigned *samplerUnitOut)
{
- struct pipe_shader_state *new_fs;
struct pstip_transform_context transform;
- const uint newLen = tgsi_num_tokens(fs->tokens) + NUM_NEW_TOKENS;
-
- new_fs = MALLOC(sizeof(*new_fs));
- if (!new_fs)
- return NULL;
+ const uint newLen = tgsi_num_tokens(tokens) + NUM_NEW_TOKENS;
+ struct tgsi_token *new_tokens;
- new_fs->tokens = tgsi_alloc_tokens(newLen);
- if (!new_fs->tokens) {
- FREE(new_fs);
+ new_tokens = tgsi_alloc_tokens(newLen);
+ if (!new_tokens) {
return NULL;
}
@@ -423,21 +351,17 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
memset(&transform, 0, sizeof(transform));
transform.wincoordInput = -1;
transform.maxInput = -1;
- transform.texTemp = -1;
- transform.firstInstruction = TRUE;
transform.coordOrigin = TGSI_FS_COORD_ORIGIN_UPPER_LEFT;
- transform.base.transform_instruction = pstip_transform_inst;
+ transform.base.prolog = pstip_transform_prolog;
transform.base.transform_declaration = pstip_transform_decl;
transform.base.transform_immediate = pstip_transform_immed;
- tgsi_scan_shader(fs->tokens, &transform.info);
+ tgsi_scan_shader(tokens, &transform.info);
transform.coordOrigin =
transform.info.properties[TGSI_PROPERTY_FS_COORD_ORIGIN];
- tgsi_transform_shader(fs->tokens,
- (struct tgsi_token *) new_fs->tokens,
- newLen, &transform.base);
+ tgsi_transform_shader(tokens, new_tokens, newLen, &transform.base);
#if 0 /* DEBUG */
tgsi_dump(fs->tokens, 0);
@@ -447,6 +371,6 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
assert(transform.freeSampler < PIPE_MAX_SAMPLERS);
*samplerUnitOut = transform.freeSampler;
- return new_fs;
+ return new_tokens;
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.h b/mesalib/src/gallium/auxiliary/util/u_pstipple.h
index 6fbed80cc..13155e7f5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_pstipple.h
+++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.h
@@ -47,9 +47,8 @@ util_pstipple_create_sampler_view(struct pipe_context *pipe,
extern void *
util_pstipple_create_sampler(struct pipe_context *pipe);
-extern struct pipe_shader_state *
-util_pstipple_create_fragment_shader(struct pipe_context *pipe,
- struct pipe_shader_state *fs,
+struct tgsi_token *
+util_pstipple_create_fragment_shader(const struct tgsi_token *tokens,
unsigned *samplerUnitOut);
diff --git a/mesalib/src/gallium/auxiliary/util/u_rect.h b/mesalib/src/gallium/auxiliary/util/u_rect.h
index dd87f81f3..cf29dff0d 100644
--- a/mesalib/src/gallium/auxiliary/util/u_rect.h
+++ b/mesalib/src/gallium/auxiliary/util/u_rect.h
@@ -30,6 +30,7 @@
#define U_RECT_H
#include "pipe/p_compiler.h"
+#include "util/u_math.h"
#ifdef __cplusplus
extern "C" {
@@ -67,6 +68,12 @@ u_rect_find_intersection(const struct u_rect *a,
}
+static INLINE int
+u_rect_area(const struct u_rect *r)
+{
+ return (r->x1 - r->x0) * (r->y1 - r->y0);
+}
+
static INLINE void
u_rect_possible_intersection(const struct u_rect *a,
struct u_rect *b)
@@ -79,6 +86,17 @@ u_rect_possible_intersection(const struct u_rect *a,
}
}
+/* Set @d to a rectangle that covers both @a and @b.
+ */
+static INLINE void
+u_rect_union(struct u_rect *d, const struct u_rect *a, const struct u_rect *b)
+{
+ d->x0 = MIN2(a->x0, b->x0);
+ d->y0 = MIN2(a->y0, b->y0);
+ d->x1 = MAX2(a->x1, b->x1);
+ d->y1 = MAX2(a->y1, b->y1);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c
index adf4887d5..edb30379b 100644
--- a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -59,11 +59,13 @@ void *
util_make_vertex_passthrough_shader(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
- const uint *semantic_indexes)
+ const uint *semantic_indexes,
+ bool window_space)
{
return util_make_vertex_passthrough_shader_with_so(pipe, num_attribs,
semantic_names,
- semantic_indexes, NULL);
+ semantic_indexes,
+ window_space, NULL);
}
void *
@@ -71,6 +73,7 @@ util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
const uint *semantic_indexes,
+ bool window_space,
const struct pipe_stream_output_info *so)
{
struct ureg_program *ureg;
@@ -80,6 +83,9 @@ util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
if (ureg == NULL)
return NULL;
+ if (window_space)
+ ureg_property(ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, TRUE);
+
for (i = 0; i < num_attribs; i++) {
struct ureg_src src;
struct ureg_dst dst;
@@ -124,6 +130,76 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe)
return pipe->create_vs_state(pipe, &state);
}
+/**
+ * Takes position and color, and outputs position, color, and instance id.
+ */
+void *util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe)
+{
+ static const char text[] =
+ "VERT\n"
+ "DCL IN[0]\n"
+ "DCL IN[1]\n"
+ "DCL SV[0], INSTANCEID\n"
+ "DCL OUT[0], POSITION\n"
+ "DCL OUT[1], GENERIC[0]\n"
+ "DCL OUT[2], GENERIC[1]\n"
+
+ "MOV OUT[0], IN[0]\n"
+ "MOV OUT[1], IN[1]\n"
+ "MOV OUT[2].x, SV[0].xxxx\n"
+ "END\n";
+ struct tgsi_token tokens[1000];
+ struct pipe_shader_state state = {tokens};
+
+ if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+ assert(0);
+ return NULL;
+ }
+ return pipe->create_vs_state(pipe, &state);
+}
+
+/**
+ * Takes position, color, and target layer, and emits vertices on that target
+ * layer, with the specified color.
+ */
+void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe)
+{
+ static const char text[] =
+ "GEOM\n"
+ "PROPERTY GS_INPUT_PRIMITIVE TRIANGLES\n"
+ "PROPERTY GS_OUTPUT_PRIMITIVE TRIANGLE_STRIP\n"
+ "PROPERTY GS_MAX_OUTPUT_VERTICES 3\n"
+ "PROPERTY GS_INVOCATIONS 1\n"
+ "DCL IN[][0], POSITION\n" /* position */
+ "DCL IN[][1], GENERIC[0]\n" /* color */
+ "DCL IN[][2], GENERIC[1]\n" /* vs invocation */
+ "DCL OUT[0], POSITION\n"
+ "DCL OUT[1], GENERIC[0]\n"
+ "DCL OUT[2], LAYER\n"
+ "IMM[0] INT32 {0, 0, 0, 0}\n"
+
+ "MOV OUT[0], IN[0][0]\n"
+ "MOV OUT[1], IN[0][1]\n"
+ "MOV OUT[2].x, IN[0][2].xxxx\n"
+ "EMIT IMM[0].xxxx\n"
+ "MOV OUT[0], IN[1][0]\n"
+ "MOV OUT[1], IN[1][1]\n"
+ "MOV OUT[2].x, IN[1][2].xxxx\n"
+ "EMIT IMM[0].xxxx\n"
+ "MOV OUT[0], IN[2][0]\n"
+ "MOV OUT[1], IN[2][1]\n"
+ "MOV OUT[2].x, IN[2][2].xxxx\n"
+ "EMIT IMM[0].xxxx\n"
+ "END\n";
+ struct tgsi_token tokens[1000];
+ struct pipe_shader_state state = {tokens};
+
+ if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+ assert(0);
+ return NULL;
+ }
+ return pipe->create_gs_state(pipe, &state);
+}
/**
* Make simple fragment texture shader:
diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h
index c1d14aa3b..dd282e02a 100644
--- a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -47,19 +47,27 @@ extern void *
util_make_vertex_passthrough_shader(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
- const uint *semantic_indexes);
+ const uint *semantic_indexes,
+ bool window_space);
extern void *
util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
const uint *semantic_indexes,
+ bool window_space,
const struct pipe_stream_output_info *so);
extern void *
util_make_layered_clear_vertex_shader(struct pipe_context *pipe);
extern void *
+util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe);
+
+extern void *
+util_make_layered_clear_geometry_shader(struct pipe_context *pipe);
+
+extern void *
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
unsigned tex_target,
unsigned interp_mode,
diff --git a/mesalib/src/gallium/auxiliary/util/u_snprintf.c b/mesalib/src/gallium/auxiliary/util/u_snprintf.c
index 7a2bf2a6f..39e9b70d0 100644
--- a/mesalib/src/gallium/auxiliary/util/u_snprintf.c
+++ b/mesalib/src/gallium/auxiliary/util/u_snprintf.c
@@ -176,7 +176,7 @@
#define HAVE_ASPRINTF 1 /* not needed */
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
-#define HAVE_STDINT_H 0
+#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_INTTYPES_H 0
#define HAVE_LOCALE_H 0
diff --git a/mesalib/src/gallium/auxiliary/util/u_tests.c b/mesalib/src/gallium/auxiliary/util/u_tests.c
new file mode 100644
index 000000000..c0f6327b6
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_tests.c
@@ -0,0 +1,268 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Advanced Micro Devices, 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 THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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_tests.h"
+
+#include "util/u_draw_quad.h"
+#include "util/u_format.h"
+#include "util/u_inlines.h"
+#include "util/u_simple_shaders.h"
+#include "util/u_surface.h"
+#include "util/u_tile.h"
+#include "cso_cache/cso_context.h"
+#include <stdio.h>
+
+#define TOLERANCE 0.01
+
+static struct pipe_resource *
+util_create_texture2d(struct pipe_screen *screen, unsigned width,
+ unsigned height, enum pipe_format format)
+{
+ struct pipe_resource templ = {{0}};
+
+ templ.target = PIPE_TEXTURE_2D;
+ templ.width0 = width;
+ templ.height0 = height;
+ templ.depth0 = 1;
+ templ.array_size = 1;
+ templ.format = format;
+ templ.usage = PIPE_USAGE_DEFAULT;
+ templ.bind = PIPE_BIND_SAMPLER_VIEW |
+ (util_format_is_depth_or_stencil(format) ?
+ PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET);
+
+ return screen->resource_create(screen, &templ);
+}
+
+static void
+util_set_framebuffer_cb0(struct cso_context *cso, struct pipe_context *ctx,
+ struct pipe_resource *tex)
+{
+ struct pipe_surface templ = {{0}}, *surf;
+ struct pipe_framebuffer_state fb = {0};
+
+ templ.format = tex->format;
+ surf = ctx->create_surface(ctx, tex, &templ);
+
+ fb.width = tex->width0;
+ fb.height = tex->height0;
+ fb.cbufs[0] = surf;
+ fb.nr_cbufs = 1;
+
+ cso_set_framebuffer(cso, &fb);
+ pipe_surface_reference(&surf, NULL);
+}
+
+static void
+util_set_blend_normal(struct cso_context *cso)
+{
+ struct pipe_blend_state blend = {0};
+
+ blend.rt[0].colormask = PIPE_MASK_RGBA;
+ cso_set_blend(cso, &blend);
+}
+
+static void
+util_set_dsa_disable(struct cso_context *cso)
+{
+ struct pipe_depth_stencil_alpha_state dsa = {{0}};
+
+ cso_set_depth_stencil_alpha(cso, &dsa);
+}
+
+static void
+util_set_rasterizer_normal(struct cso_context *cso)
+{
+ struct pipe_rasterizer_state rs = {0};
+
+ rs.half_pixel_center = 1;
+ rs.bottom_edge_rule = 1;
+ rs.depth_clip = 1;
+
+ cso_set_rasterizer(cso, &rs);
+}
+
+static void
+util_set_max_viewport(struct cso_context *cso, struct pipe_resource *tex)
+{
+ struct pipe_viewport_state viewport;
+
+ viewport.scale[0] = 0.5f * tex->width0;
+ viewport.scale[1] = 0.5f * tex->height0;
+ viewport.scale[2] = 1.0f;
+ viewport.translate[0] = 0.5f * tex->width0;
+ viewport.translate[1] = 0.5f * tex->height0;
+ viewport.translate[2] = 0.0f;
+
+ cso_set_viewport(cso, &viewport);
+}
+
+static void
+util_set_interleaved_vertex_elements(struct cso_context *cso,
+ unsigned num_elements)
+{
+ int i;
+ struct pipe_vertex_element *velem =
+ calloc(1, num_elements * sizeof(struct pipe_vertex_element));
+
+ for (i = 0; i < num_elements; i++) {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ velem[i].src_offset = i * 16;
+ }
+
+ cso_set_vertex_elements(cso, num_elements, velem);
+ free(velem);
+}
+
+static bool
+util_probe_rect_rgba(struct pipe_context *ctx, struct pipe_resource *tex,
+ unsigned offx, unsigned offy, unsigned w, unsigned h,
+ const float *expected)
+{
+ struct pipe_transfer *transfer;
+ void *map;
+ float *pixels = malloc(w * h * 4 * sizeof(float));
+ int x,y,c;
+ bool pass = true;
+
+ map = pipe_transfer_map(ctx, tex, 0, 0, PIPE_TRANSFER_READ,
+ offx, offy, w, h, &transfer);
+ pipe_get_tile_rgba(transfer, map, 0, 0, w, h, pixels);
+ pipe_transfer_unmap(ctx, transfer);
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ float *probe = &pixels[(y*w + x)*4];
+
+ for (c = 0; c < 4; c++)
+ if (fabs(probe[c] - expected[c]) >= TOLERANCE) {
+ printf("Probe color at (%i,%i), ", offx+x, offy+y);
+ printf("Expected: %.3f, %.3f, %.3f, %.3f, ",
+ expected[0], expected[1], expected[2], expected[3]);
+ printf("Got: %.3f, %.3f, %.3f, %.3f\n",
+ probe[0], probe[1], probe[2], probe[2]);
+ pass = false;
+ goto done;
+ }
+ }
+ }
+done:
+
+ free(pixels);
+ return pass;
+}
+
+/**
+ * Test TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION.
+ *
+ * The viewport state is set as usual, but it should have no effect.
+ * Clipping should also be disabled.
+ *
+ * POSITION.xyz should already be multiplied by 1/w and POSITION.w should
+ * contain 1/w. By setting w=0, we can test that POSITION.xyz isn't
+ * multiplied by 1/w (otherwise nothing would be rendered).
+ *
+ * TODO: Whether the value of POSITION.w is correctly interpreted as 1/w
+ * during perspective interpolation is not tested.
+ */
+static void
+tgsi_vs_window_space_position(struct pipe_context *ctx)
+{
+ struct cso_context *cso;
+ struct pipe_resource *cb;
+ void *fs, *vs;
+ bool pass = true;
+
+ static uint vs_attribs[] = {
+ TGSI_SEMANTIC_POSITION,
+ TGSI_SEMANTIC_GENERIC
+ };
+ static uint vs_indices[] = {0, 0};
+ static float vertices[] = {
+ 0, 0, 0, 0, 1, 0, 0, 1,
+ 0, 256, 0, 0, 1, 0, 0, 1,
+ 256, 256, 0, 0, 1, 0, 0, 1,
+ 256, 0, 0, 0, 1, 0, 0, 1,
+ };
+ static float red[] = {1, 0, 0, 1};
+ static float clear_color[] = {0.1, 0.1, 0.1, 0.1};
+
+ if (!ctx->screen->get_param(ctx->screen,
+ PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION)) {
+ printf("Test(%s) = skip\n", __func__);
+ return;
+ }
+
+ cso = cso_create_context(ctx);
+ cb = util_create_texture2d(ctx->screen, 256, 256,
+ PIPE_FORMAT_R8G8B8A8_UNORM);
+
+ /* Set states. */
+ util_set_framebuffer_cb0(cso, ctx, cb);
+ util_set_blend_normal(cso);
+ util_set_dsa_disable(cso);
+ util_set_rasterizer_normal(cso);
+ util_set_max_viewport(cso, cb);
+ util_set_interleaved_vertex_elements(cso, 2);
+
+ /* Fragment shader. */
+ fs = util_make_fragment_passthrough_shader(ctx, TGSI_SEMANTIC_GENERIC,
+ TGSI_INTERPOLATE_LINEAR, TRUE);
+ cso_set_fragment_shader_handle(cso, fs);
+
+ /* Vertex shader. */
+ vs = util_make_vertex_passthrough_shader(ctx, 2, vs_attribs, vs_indices,
+ TRUE);
+ cso_set_vertex_shader_handle(cso, vs);
+
+ /* Clear and draw. */
+ ctx->clear(ctx, PIPE_CLEAR_COLOR0, (void*)clear_color, 0, 0);
+ util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2);
+
+ /* Probe pixels. */
+ pass = pass && util_probe_rect_rgba(ctx, cb, 0, 0,
+ cb->width0, cb->height0, red);
+
+ /* Cleanup. */
+ cso_release_all(cso);
+ cso_destroy_context(cso);
+ ctx->delete_vs_state(ctx, vs);
+ ctx->delete_fs_state(ctx, fs);
+ pipe_resource_reference(&cb, NULL);
+
+ printf("Test(%s) = %s\n", __func__, pass ? "pass" : "fail");
+}
+
+/**
+ * Run all tests. This should be run with a clean context after
+ * context_create.
+ */
+void
+util_run_tests(struct pipe_context *ctx)
+{
+ tgsi_vs_window_space_position(ctx);
+}
diff --git a/mesalib/src/gallium/auxiliary/util/u_tests.h b/mesalib/src/gallium/auxiliary/util/u_tests.h
new file mode 100644
index 000000000..a1439347d
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_tests.h
@@ -0,0 +1,37 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Advanced Micro Devices, 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 THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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_TESTS_H
+#define U_TESTS_H
+
+#include "pipe/p_compiler.h"
+
+struct pipe_context;
+
+void util_run_tests(struct pipe_context *ctx);
+
+#endif
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index 0c55327d6..676fa0d7a 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -59,6 +59,7 @@ LIBGLSL_FILES = \
$(GLSL_SRCDIR)/loop_controls.cpp \
$(GLSL_SRCDIR)/loop_unroll.cpp \
$(GLSL_SRCDIR)/lower_clip_distance.cpp \
+ $(GLSL_SRCDIR)/lower_const_arrays_to_uniforms.cpp \
$(GLSL_SRCDIR)/lower_discard.cpp \
$(GLSL_SRCDIR)/lower_discard_flow.cpp \
$(GLSL_SRCDIR)/lower_if_to_cond_assign.cpp \
@@ -104,8 +105,7 @@ LIBGLSL_FILES = \
$(GLSL_SRCDIR)/opt_swizzle_swizzle.cpp \
$(GLSL_SRCDIR)/opt_tree_grafting.cpp \
$(GLSL_SRCDIR)/opt_vectorize.cpp \
- $(GLSL_SRCDIR)/s_expression.cpp \
- $(GLSL_SRCDIR)/strtod.c
+ $(GLSL_SRCDIR)/s_expression.cpp
# glsl_compiler
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index 83dfafd75..deb8c7a7f 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -644,19 +644,6 @@ class ast_declarator_list;
class ast_struct_specifier : public ast_node {
public:
- /**
- * \brief Make a shallow copy of an ast_struct_specifier.
- *
- * Use only if the objects are allocated from the same context and will not
- * be modified. Zeros the inherited ast_node's fields.
- */
- ast_struct_specifier(const ast_struct_specifier& that):
- ast_node(), name(that.name), declarations(that.declarations),
- is_declaration(that.is_declaration)
- {
- /* empty */
- }
-
ast_struct_specifier(const char *identifier,
ast_declarator_list *declarator_list);
virtual void print(void) const;
@@ -674,22 +661,6 @@ public:
class ast_type_specifier : public ast_node {
public:
- /**
- * \brief Make a shallow copy of an ast_type_specifier, specifying array
- * fields.
- *
- * Use only if the objects are allocated from the same context and will not
- * be modified. Zeros the inherited ast_node's fields.
- */
- ast_type_specifier(const ast_type_specifier *that,
- ast_array_specifier *array_specifier)
- : ast_node(), type_name(that->type_name), structure(that->structure),
- array_specifier(array_specifier),
- default_precision(that->default_precision)
- {
- /* empty */
- }
-
/** Construct a type specifier from a type name */
ast_type_specifier(const char *name)
: type_name(name), structure(NULL), array_specifier(NULL),
diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll
index e66a93591..57c46be84 100644
--- a/mesalib/src/glsl/glsl_lexer.ll
+++ b/mesalib/src/glsl/glsl_lexer.ll
@@ -23,7 +23,7 @@
*/
#include <ctype.h>
#include <limits.h>
-#include "strtod.h"
+#include "util/strtod.h"
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
@@ -450,24 +450,11 @@ layout {
return LITERAL_INTEGER(8);
}
-[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
- yylval->real = glsl_strtof(yytext, NULL);
- return FLOATCONSTANT;
- }
-\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
- yylval->real = glsl_strtof(yytext, NULL);
- return FLOATCONSTANT;
- }
-[0-9]+\.([eE][+-]?[0-9]+)?[fF]? {
- yylval->real = glsl_strtof(yytext, NULL);
- return FLOATCONSTANT;
- }
+[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? |
+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? |
+[0-9]+\.([eE][+-]?[0-9]+)?[fF]? |
[0-9]+[eE][+-]?[0-9]+[fF]? {
- yylval->real = glsl_strtof(yytext, NULL);
- return FLOATCONSTANT;
- }
-[0-9]+[fF] {
- yylval->real = glsl_strtof(yytext, NULL);
+ yylval->real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 79f849465..27e3301e2 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -1350,9 +1350,15 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier,
ast_declarator_list *declarator_list)
{
if (identifier == NULL) {
+ static mtx_t mutex = _MTX_INITIALIZER_NP;
static unsigned anon_count = 1;
- identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count);
- anon_count++;
+ unsigned count;
+
+ mtx_lock(&mutex);
+ count = anon_count++;
+ mtx_unlock(&mutex);
+
+ identifier = ralloc_asprintf(this, "#anon_struct_%04x", count);
}
name = identifier;
this->declarations.push_degenerate_list_at_head(&declarator_list->link);
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index c11d86482..5f9919348 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -29,6 +29,7 @@ extern "C" {
#include "program/hash_table.h"
}
+mtx_t glsl_type::mutex = _MTX_INITIALIZER_NP;
hash_table *glsl_type::array_types = NULL;
hash_table *glsl_type::record_types = NULL;
hash_table *glsl_type::interface_types = NULL;
@@ -53,9 +54,14 @@ glsl_type::glsl_type(GLenum gl_type,
vector_elements(vector_elements), matrix_columns(matrix_columns),
length(0)
{
+ mtx_lock(&glsl_type::mutex);
+
init_ralloc_type_ctx();
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
+
+ mtx_unlock(&glsl_type::mutex);
+
/* Neither dimension is zero or both dimensions are zero.
*/
assert((vector_elements == 0) == (matrix_columns == 0));
@@ -71,9 +77,14 @@ glsl_type::glsl_type(GLenum gl_type, glsl_base_type base_type,
sampler_array(array), sampler_type(type), interface_packing(0),
length(0)
{
+ mtx_lock(&glsl_type::mutex);
+
init_ralloc_type_ctx();
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
+
+ mtx_unlock(&glsl_type::mutex);
+
memset(& fields, 0, sizeof(fields));
if (base_type == GLSL_TYPE_SAMPLER) {
@@ -95,11 +106,14 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
{
unsigned int i;
+ mtx_lock(&glsl_type::mutex);
+
init_ralloc_type_ctx();
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
this->fields.structure = ralloc_array(this->mem_ctx,
glsl_struct_field, length);
+
for (i = 0; i < length; i++) {
this->fields.structure[i].type = fields[i].type;
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
@@ -110,6 +124,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
this->fields.structure[i].sample = fields[i].sample;
this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
}
+
+ mtx_unlock(&glsl_type::mutex);
}
glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
@@ -123,6 +139,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
{
unsigned int i;
+ mtx_lock(&glsl_type::mutex);
+
init_ralloc_type_ctx();
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
@@ -138,6 +156,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
this->fields.structure[i].sample = fields[i].sample;
this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
}
+
+ mtx_unlock(&glsl_type::mutex);
}
@@ -285,6 +305,8 @@ const glsl_type *glsl_type::get_scalar_type() const
void
_mesa_glsl_release_types(void)
{
+ mtx_lock(&glsl_type::mutex);
+
if (glsl_type::array_types != NULL) {
hash_table_dtor(glsl_type::array_types);
glsl_type::array_types = NULL;
@@ -294,6 +316,8 @@ _mesa_glsl_release_types(void)
hash_table_dtor(glsl_type::record_types);
glsl_type::record_types = NULL;
}
+
+ mtx_unlock(&glsl_type::mutex);
}
@@ -302,7 +326,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
sampler_type(0), interface_packing(0),
vector_elements(0), matrix_columns(0),
- name(NULL), length(length)
+ length(length), name(NULL)
{
this->fields.array = array;
/* Inherit the gl type of the base. The GL type is used for
@@ -316,7 +340,10 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
* NUL.
*/
const unsigned name_length = strlen(array->name) + 10 + 3;
+
+ mtx_lock(&glsl_type::mutex);
char *const n = (char *) ralloc_size(this->mem_ctx, name_length);
+ mtx_unlock(&glsl_type::mutex);
if (length == 0)
snprintf(n, name_length, "%s[]", array->name);
@@ -452,12 +479,6 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
const glsl_type *
glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
{
-
- if (array_types == NULL) {
- array_types = hash_table_ctor(64, hash_table_string_hash,
- hash_table_string_compare);
- }
-
/* Generate a name using the base type pointer in the key. This is
* done because the name of the base type may not be unique across
* shaders. For example, two shaders may have different record types
@@ -466,9 +487,19 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
char key[128];
snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
+ mtx_lock(&glsl_type::mutex);
+
+ if (array_types == NULL) {
+ array_types = hash_table_ctor(64, hash_table_string_hash,
+ hash_table_string_compare);
+ }
+
const glsl_type *t = (glsl_type *) hash_table_find(array_types, key);
+
if (t == NULL) {
+ mtx_unlock(&glsl_type::mutex);
t = new glsl_type(base, array_size);
+ mtx_lock(&glsl_type::mutex);
hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key));
}
@@ -477,6 +508,8 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
assert(t->length == array_size);
assert(t->fields.array == base);
+ mtx_unlock(&glsl_type::mutex);
+
return t;
}
@@ -575,13 +608,17 @@ glsl_type::get_record_instance(const glsl_struct_field *fields,
{
const glsl_type key(fields, num_fields, name);
+ mtx_lock(&glsl_type::mutex);
+
if (record_types == NULL) {
record_types = hash_table_ctor(64, record_key_hash, record_key_compare);
}
const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key);
if (t == NULL) {
+ mtx_unlock(&glsl_type::mutex);
t = new glsl_type(fields, num_fields, name);
+ mtx_lock(&glsl_type::mutex);
hash_table_insert(record_types, (void *) t, t);
}
@@ -590,6 +627,8 @@ glsl_type::get_record_instance(const glsl_struct_field *fields,
assert(t->length == num_fields);
assert(strcmp(t->name, name) == 0);
+ mtx_unlock(&glsl_type::mutex);
+
return t;
}
@@ -602,13 +641,17 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
{
const glsl_type key(fields, num_fields, packing, block_name);
+ mtx_lock(&glsl_type::mutex);
+
if (interface_types == NULL) {
interface_types = hash_table_ctor(64, record_key_hash, record_key_compare);
}
const glsl_type *t = (glsl_type *) hash_table_find(interface_types, & key);
if (t == NULL) {
+ mtx_unlock(&glsl_type::mutex);
t = new glsl_type(fields, num_fields, packing, block_name);
+ mtx_lock(&glsl_type::mutex);
hash_table_insert(interface_types, (void *) t, t);
}
@@ -617,6 +660,8 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
assert(t->length == num_fields);
assert(strcmp(t->name, block_name) == 0);
+ mtx_unlock(&glsl_type::mutex);
+
return t;
}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index eeb14c274..474b12914 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -122,16 +122,18 @@ struct glsl_type {
* easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
static void* operator new(size_t size)
{
- if (glsl_type::mem_ctx == NULL) {
- glsl_type::mem_ctx = ralloc_context(NULL);
- assert(glsl_type::mem_ctx != NULL);
- }
+ mtx_lock(&glsl_type::mutex);
+
+ /* mem_ctx should have been created by the static members */
+ assert(glsl_type::mem_ctx != NULL);
void *type;
type = ralloc_size(glsl_type::mem_ctx, size);
assert(type != NULL);
+ mtx_unlock(&glsl_type::mutex);
+
return type;
}
@@ -139,7 +141,9 @@ struct glsl_type {
* ralloc_free in that case. */
static void operator delete(void *type)
{
+ mtx_lock(&glsl_type::mutex);
ralloc_free(type);
+ mtx_unlock(&glsl_type::mutex);
}
/**
@@ -149,18 +153,11 @@ struct glsl_type {
* these will be 0.
*/
/*@{*/
- unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
- unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */
+ uint8_t vector_elements; /**< 1, 2, 3, or 4 vector elements. */
+ uint8_t matrix_columns; /**< 1, 2, 3, or 4 matrix columns. */
/*@}*/
/**
- * Name of the data type
- *
- * Will never be \c NULL.
- */
- const char *name;
-
- /**
* For \c GLSL_TYPE_ARRAY, this is the length of the array. For
* \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
* elements in the structure and the number of values pointed to by
@@ -169,6 +166,13 @@ struct glsl_type {
unsigned length;
/**
+ * Name of the data type
+ *
+ * Will never be \c NULL.
+ */
+ const char *name;
+
+ /**
* Subtype of composite data types.
*/
union {
@@ -618,6 +622,9 @@ struct glsl_type {
bool record_compare(const glsl_type *b) const;
private:
+
+ static mtx_t mutex;
+
/**
* ralloc context for all glsl_type allocations
*
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index 5907854f6..f6aeb6158 100755
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -46,11 +46,6 @@ bool ir_rvalue::is_negative_one() const
return false;
}
-bool ir_rvalue::is_basis() const
-{
- return false;
-}
-
/**
* Modify the swizzle make to move one component to another
*
@@ -1191,49 +1186,6 @@ ir_constant::is_negative_one() const
}
bool
-ir_constant::is_basis() const
-{
- if (!this->type->is_scalar() && !this->type->is_vector())
- return false;
-
- if (this->type->is_boolean())
- return false;
-
- unsigned ones = 0;
- for (unsigned c = 0; c < this->type->vector_elements; c++) {
- switch (this->type->base_type) {
- case GLSL_TYPE_FLOAT:
- if (this->value.f[c] == 1.0)
- ones++;
- else if (this->value.f[c] != 0.0)
- return false;
- break;
- case GLSL_TYPE_INT:
- if (this->value.i[c] == 1)
- ones++;
- else if (this->value.i[c] != 0)
- return false;
- break;
- case GLSL_TYPE_UINT:
- if (int(this->value.u[c]) == 1)
- ones++;
- else if (int(this->value.u[c]) != 0)
- return false;
- break;
- default:
- /* The only other base types are structures, arrays, samplers, and
- * booleans. Samplers cannot be constants, and the others should
- * have been filtered out above.
- */
- assert(!"Should not get here.");
- return false;
- }
- }
-
- return ones == 1;
-}
-
-bool
ir_constant::is_uint16_constant() const
{
if (!type->is_integer())
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index 90c443c3d..a0f48b2af 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -251,8 +251,7 @@ public:
* for vector and scalar types that have all elements set to the value
* zero (or \c false for booleans).
*
- * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one,
- * ir_constant::is_basis
+ * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one
*/
virtual bool is_zero() const;
@@ -264,8 +263,7 @@ public:
* for vector and scalar types that have all elements set to the value
* one (or \c true for booleans).
*
- * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one,
- * ir_constant::is_basis
+ * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one
*/
virtual bool is_one() const;
@@ -278,25 +276,10 @@ public:
* negative one. For boolean types, the result is always \c false.
*
* \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one
- * ir_constant::is_basis
*/
virtual bool is_negative_one() const;
/**
- * Determine if an r-value is a basis vector
- *
- * The base implementation of this function always returns \c false. The
- * \c ir_constant class over-rides this function to return \c true \b only
- * for vector and scalar types that have one element set to the value one,
- * and the other elements set to the value zero. For boolean types, the
- * result is always \c false.
- *
- * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one,
- * is_constant::is_negative_one
- */
- virtual bool is_basis() const;
-
- /**
* Determine if an r-value is an unsigned integer constant which can be
* stored in 16 bits.
*
@@ -359,6 +342,12 @@ enum ir_var_declaration_type {
* re-declared by the shader.
*/
ir_var_declared_implicitly,
+
+ /**
+ * Variable is implicitly generated by the compiler and should not be
+ * visible via the API.
+ */
+ ir_var_hidden,
};
/**
@@ -2257,7 +2246,7 @@ public:
* Determine whether a constant has the same value as another constant
*
* \sa ir_constant::is_zero, ir_constant::is_one,
- * ir_constant::is_negative_one, ir_constant::is_basis
+ * ir_constant::is_negative_one
*/
bool has_value(const ir_constant *) const;
@@ -2270,7 +2259,6 @@ public:
virtual bool is_zero() const;
virtual bool is_one() const;
virtual bool is_negative_one() const;
- virtual bool is_basis() const;
/**
* Return true for constants that could be stored as 16-bit unsigned values.
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index e25857ac5..34e0b4b94 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -114,6 +114,7 @@ bool lower_noise(exec_list *instructions);
bool lower_variable_index_to_cond_assign(exec_list *instructions,
bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
+bool lower_const_arrays_to_uniforms(exec_list *instructions);
bool lower_clip_distance(gl_shader *shader);
void lower_output_reads(exec_list *instructions);
bool lower_packing_builtins(exec_list *instructions, int op_mask);
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index ae00e7934..fd318c046 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -972,7 +972,7 @@ ir_reader::read_texture(s_expression *expr)
op = ir_query_levels;
} else if (MATCH(expr, other_pattern)) {
op = ir_texture::get_opcode(tag->value());
- if (op == -1)
+ if (op == (ir_texture_opcode) -1)
return NULL;
} else {
ir_read_error(NULL, "unexpected texture pattern %s", tag->value());
diff --git a/mesalib/src/glsl/ir_uniform.h b/mesalib/src/glsl/ir_uniform.h
index b9ecf7cdd..21b5d05c1 100644
--- a/mesalib/src/glsl/ir_uniform.h
+++ b/mesalib/src/glsl/ir_uniform.h
@@ -175,6 +175,12 @@ struct gl_uniform_storage {
* arrays this is the first element in the array.
*/
unsigned remap_location;
+
+ /**
+ * This is a compiler-generated uniform that should not be advertised
+ * via the API.
+ */
+ bool hidden;
};
#ifdef __cplusplus
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index f613abc99..a77b5868a 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -585,6 +585,8 @@ private:
this->uniforms[id].driver_storage = NULL;
this->uniforms[id].storage = this->values;
this->uniforms[id].atomic_buffer_index = -1;
+ this->uniforms[id].hidden =
+ current_var->data.how_declared == ir_var_hidden;
if (this->ubo_block_index != -1) {
this->uniforms[id].block_index = this->ubo_block_index;
@@ -806,6 +808,50 @@ link_set_image_access_qualifiers(struct gl_shader_program *prog)
}
}
+/**
+ * Sort the array of uniform storage so that the non-hidden uniforms are first
+ *
+ * This function sorts the list "in place." This is important because some of
+ * the storage accessible from \c uniforms has \c uniforms as its \c ralloc
+ * context. If \c uniforms is freed, some other storage will also be freed.
+ */
+static unsigned
+move_hidden_uniforms_to_end(struct gl_shader_program *prog,
+ struct gl_uniform_storage *uniforms,
+ unsigned num_elements)
+{
+ struct gl_uniform_storage *sorted_uniforms =
+ ralloc_array(prog, struct gl_uniform_storage, num_elements);
+ unsigned hidden_uniforms = 0;
+ unsigned j = 0;
+
+ /* Add the non-hidden uniforms. */
+ for (unsigned i = 0; i < num_elements; i++) {
+ if (!uniforms[i].hidden)
+ sorted_uniforms[j++] = uniforms[i];
+ }
+
+ /* Add and count the hidden uniforms. */
+ for (unsigned i = 0; i < num_elements; i++) {
+ if (uniforms[i].hidden) {
+ sorted_uniforms[j++] = uniforms[i];
+ hidden_uniforms++;
+ }
+ }
+
+ assert(prog->UniformHash != NULL);
+ prog->UniformHash->clear();
+ for (unsigned i = 0; i < num_elements; i++) {
+ if (sorted_uniforms[i].name != NULL)
+ prog->UniformHash->put(i, sorted_uniforms[i].name);
+ }
+
+ memcpy(uniforms, sorted_uniforms, sizeof(uniforms[0]) * num_elements);
+ ralloc_free(sorted_uniforms);
+
+ return hidden_uniforms;
+}
+
void
link_assign_uniform_locations(struct gl_shader_program *prog,
unsigned int boolean_true)
@@ -926,6 +972,9 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
sizeof(prog->_LinkedShaders[i]->SamplerTargets));
}
+ const unsigned hidden_uniforms =
+ move_hidden_uniforms_to_end(prog, uniforms, num_user_uniforms);
+
/* Reserve all the explicit locations of the active uniforms. */
for (unsigned i = 0; i < num_user_uniforms; i++) {
if (uniforms[i].remap_location != UNMAPPED_UNIFORM_LOC) {
@@ -977,6 +1026,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
#endif
prog->NumUserUniformStorage = num_user_uniforms;
+ prog->NumHiddenUniforms = hidden_uniforms;
prog->UniformStorage = uniforms;
link_set_image_access_qualifiers(prog);
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 2d31801d3..de6b1fb9f 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -642,7 +642,7 @@ validate_geometry_shader_emissions(struct gl_context *ctx,
emit_vertex.run(prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->ir);
if (emit_vertex.error()) {
linker_error(prog, "Invalid call %s(%d). Accepted values for the "
- "stream parameter are in the range [0, %d].",
+ "stream parameter are in the range [0, %d].\n",
emit_vertex.error_func(),
emit_vertex.error_stream(),
ctx->Const.MaxVertexStreams - 1);
@@ -676,7 +676,7 @@ validate_geometry_shader_emissions(struct gl_context *ctx,
*/
if (prog->Geom.UsesStreams && prog->Geom.OutputType != GL_POINTS) {
linker_error(prog, "EmitStreamVertex(n) and EndStreamPrimitive(n) "
- "with n>0 requires point output");
+ "with n>0 requires point output\n");
}
}
}
@@ -808,7 +808,7 @@ cross_validate_globals(struct gl_shader_program *prog,
linker_error(prog,
"All redeclarations of gl_FragDepth in all "
"fragment shaders in a single program must have "
- "the same set of qualifiers.");
+ "the same set of qualifiers.\n");
}
if (var->data.used && layout_differs) {
@@ -817,7 +817,7 @@ cross_validate_globals(struct gl_shader_program *prog,
"qualifier in any fragment shader, it must be "
"redeclared with the same layout qualifier in "
"all fragment shaders that have assignments to "
- "gl_FragDepth");
+ "gl_FragDepth\n");
}
}
@@ -948,7 +948,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog)
&sh->UniformBlocks[j]);
if (index == -1) {
- linker_error(prog, "uniform block `%s' has mismatching definitions",
+ linker_error(prog, "uniform block `%s' has mismatching definitions\n",
sh->UniformBlocks[j].Name);
return false;
}
@@ -1635,7 +1635,7 @@ link_intrastage_shaders(void *mem_ctx,
if ((other_sig != NULL) && other_sig->is_defined
&& !other_sig->is_builtin()) {
- linker_error(prog, "function `%s' is multiply defined",
+ linker_error(prog, "function `%s' is multiply defined\n",
f->name);
return NULL;
}
@@ -2086,7 +2086,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
if (attr + slots > max_index) {
linker_error(prog,
"insufficient contiguous locations "
- "available for %s `%s' %d %d %d", string,
+ "available for %s `%s' %d %d %d\n", string,
var->name, used_locations, use_mask, attr);
return false;
}
@@ -2155,7 +2155,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
linker_error(prog,
"insufficient contiguous locations "
- "available for %s `%s'",
+ "available for %s `%s'\n",
string, to_assign[i].var->name);
return false;
}
@@ -2257,7 +2257,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
continue;
if (sh->num_samplers > ctx->Const.Program[i].MaxTextureImageUnits) {
- linker_error(prog, "Too many %s shader texture samplers",
+ linker_error(prog, "Too many %s shader texture samplers\n",
_mesa_shader_stage_to_string(i));
}
@@ -2271,7 +2271,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
_mesa_shader_stage_to_string(i));
} else {
linker_error(prog, "Too many %s shader default uniform block "
- "components",
+ "components\n",
_mesa_shader_stage_to_string(i));
}
}
@@ -2284,7 +2284,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
"this is non-portable out-of-spec behavior\n",
_mesa_shader_stage_to_string(i));
} else {
- linker_error(prog, "Too many %s shader uniform components",
+ linker_error(prog, "Too many %s shader uniform components\n",
_mesa_shader_stage_to_string(i));
}
}
@@ -2302,7 +2302,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
}
if (total_uniform_blocks > ctx->Const.MaxCombinedUniformBlocks) {
- linker_error(prog, "Too many combined uniform blocks (%d/%d)",
+ linker_error(prog, "Too many combined uniform blocks (%d/%d)\n",
prog->NumUniformBlocks,
ctx->Const.MaxCombinedUniformBlocks);
} else {
@@ -2310,7 +2310,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
const unsigned max_uniform_blocks =
ctx->Const.Program[i].MaxUniformBlocks;
if (blocks[i] > max_uniform_blocks) {
- linker_error(prog, "Too many %s uniform blocks (%d/%d)",
+ linker_error(prog, "Too many %s uniform blocks (%d/%d)\n",
_mesa_shader_stage_to_string(i),
blocks[i],
max_uniform_blocks);
@@ -2338,7 +2338,7 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
if (sh) {
if (sh->NumImages > ctx->Const.Program[i].MaxImageUniforms)
- linker_error(prog, "Too many %s shader image uniforms",
+ linker_error(prog, "Too many %s shader image uniforms\n",
_mesa_shader_stage_to_string(i));
total_image_units += sh->NumImages;
@@ -2354,11 +2354,11 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
}
if (total_image_units > ctx->Const.MaxCombinedImageUniforms)
- linker_error(prog, "Too many combined image uniforms");
+ linker_error(prog, "Too many combined image uniforms\n");
if (total_image_units + fragment_outputs >
ctx->Const.MaxCombinedImageUnitsAndFragmentOutputs)
- linker_error(prog, "Too many combined image uniforms and fragment outputs");
+ linker_error(prog, "Too many combined image uniforms and fragment outputs\n");
}
@@ -2382,7 +2382,7 @@ reserve_explicit_locations(struct gl_shader_program *prog,
max_loc + 1);
if (!prog->UniformRemapTable) {
- linker_error(prog, "Out of memory during linking.");
+ linker_error(prog, "Out of memory during linking.\n");
return false;
}
@@ -2411,8 +2411,8 @@ reserve_explicit_locations(struct gl_shader_program *prog,
* or linker error will be generated."
*/
linker_error(prog,
- "location qualifier for uniform %s overlaps"
- "previously used location",
+ "location qualifier for uniform %s overlaps "
+ "previously used location\n",
var->name);
return false;
}
@@ -2447,7 +2447,7 @@ check_explicit_uniform_locations(struct gl_context *ctx,
string_to_uint_map *uniform_map = new string_to_uint_map;
if (!uniform_map) {
- linker_error(prog, "Out of memory during linking.");
+ linker_error(prog, "Out of memory during linking.\n");
return;
}
@@ -2678,6 +2678,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
&ctx->Const.ShaderCompilerOptions[i],
ctx->Const.NativeIntegers))
;
+
+ lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir);
}
/* Check and validate stream emissions in geometry shaders */
@@ -2719,7 +2721,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
*/
if (first == MESA_SHADER_FRAGMENT) {
linker_error(prog, "Transform feedback varyings specified, but "
- "no vertex or geometry shader is present.");
+ "no vertex or geometry shader is present.\n");
goto done;
}
diff --git a/mesalib/src/glsl/list.h b/mesalib/src/glsl/list.h
index b40764cae..bebe17fcf 100644
--- a/mesalib/src/glsl/list.h
+++ b/mesalib/src/glsl/list.h
@@ -529,6 +529,27 @@ exec_node_insert_list_before(struct exec_node *n, struct exec_list *before)
exec_list_make_empty(before);
}
+static inline void
+exec_list_validate(const struct exec_list *list)
+{
+ const struct exec_node *node;
+
+ assert(list->head->prev == (const struct exec_node *) &list->head);
+ assert(list->tail == NULL);
+ assert(list->tail_pred->next == (const struct exec_node *) &list->tail);
+
+ /* We could try to use one of the interators below for this but they all
+ * either require C++ or assume the exec_node is embedded in a structure
+ * which is not the case for this function.
+ */
+ for (node = exec_list_get_head_const(list);
+ !exec_node_is_tail_sentinel(node);
+ node = exec_node_get_next_const(node)) {
+ assert(node->next->prev == node);
+ assert(node->prev->next == node);
+ }
+}
+
#ifdef __cplusplus
inline void exec_list::make_empty()
{
diff --git a/mesalib/src/glsl/loop_unroll.cpp b/mesalib/src/glsl/loop_unroll.cpp
index ce795f6cd..635e1dd99 100644
--- a/mesalib/src/glsl/loop_unroll.cpp
+++ b/mesalib/src/glsl/loop_unroll.cpp
@@ -64,6 +64,7 @@ class loop_unroll_count : public ir_hierarchical_visitor {
public:
int nodes;
bool unsupported_variable_indexing;
+ bool array_indexed_by_induction_var_with_exact_iterations;
/* If there are nested loops, the node count will be inaccurate. */
bool nested_loop;
@@ -74,6 +75,7 @@ public:
nodes = 0;
nested_loop = false;
unsupported_variable_indexing = false;
+ array_indexed_by_induction_var_with_exact_iterations = false;
run(list);
}
@@ -112,6 +114,14 @@ public:
ir_variable *array = ir->array->variable_referenced();
loop_variable *lv = ls->get(ir->array_index->variable_referenced());
if (array && lv && lv->is_induction_var()) {
+ /* If an array is indexed by a loop induction variable, and the
+ * array size is exactly the number of loop iterations, this is
+ * probably a simple for-loop trying to access each element in
+ * turn; the application may expect it to be unrolled.
+ */
+ if (int(array->type->length) == ls->limiting_terminator->iterations)
+ array_indexed_by_induction_var_with_exact_iterations = true;
+
switch (array->data.mode) {
case ir_var_auto:
case ir_var_temporary:
@@ -314,7 +324,8 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
bool loop_too_large =
count.nested_loop || count.nodes * iterations > max_iterations * 5;
- if (loop_too_large && !count.unsupported_variable_indexing)
+ if (loop_too_large && !count.unsupported_variable_indexing &&
+ !count.array_indexed_by_induction_var_with_exact_iterations)
return visit_continue;
/* Note: the limiting terminator contributes 1 to ls->num_loop_jumps.
diff --git a/mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp b/mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp
new file mode 100644
index 000000000..2243f479a
--- /dev/null
+++ b/mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file lower_const_arrays_to_uniforms.cpp
+ *
+ * Lower constant arrays to uniform arrays.
+ *
+ * Some driver backends (such as i965 and nouveau) don't handle constant arrays
+ * gracefully, instead treating them as ordinary writable temporary arrays.
+ * Since arrays can be large, this often means spilling them to scratch memory,
+ * which usually involves a large number of instructions.
+ *
+ * This must be called prior to link_set_uniform_initializers(); we need the
+ * linker to process our new uniform's constant initializer.
+ *
+ * This should be called after optimizations, since those can result in
+ * splitting and removing arrays that are indexed by constant expressions.
+ */
+#include "ir.h"
+#include "ir_visitor.h"
+#include "ir_rvalue_visitor.h"
+#include "glsl_types.h"
+
+namespace {
+class lower_const_array_visitor : public ir_rvalue_visitor {
+public:
+ lower_const_array_visitor(exec_list *insts)
+ {
+ instructions = insts;
+ progress = false;
+ index = 0;
+ }
+
+ bool run()
+ {
+ visit_list_elements(this, instructions);
+ return progress;
+ }
+
+ void handle_rvalue(ir_rvalue **rvalue);
+
+private:
+ exec_list *instructions;
+ bool progress;
+ unsigned index;
+};
+
+void
+lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
+{
+ if (!*rvalue)
+ return;
+
+ ir_dereference_array *dra = (*rvalue)->as_dereference_array();
+ if (!dra)
+ return;
+
+ ir_constant *con = dra->array->as_constant();
+ if (!con || !con->type->is_array())
+ return;
+
+ void *mem_ctx = ralloc_parent(con);
+
+ char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%d", index++);
+
+ ir_variable *uni =
+ new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
+ uni->constant_initializer = con;
+ uni->constant_value = con;
+ uni->data.has_initializer = true;
+ uni->data.how_declared = ir_var_hidden;
+ uni->data.read_only = true;
+ /* Assume the whole thing is accessed. */
+ uni->data.max_array_access = uni->type->length - 1;
+ instructions->push_head(uni);
+
+ ir_dereference_variable *varref = new(mem_ctx) ir_dereference_variable(uni);
+ *rvalue = new(mem_ctx) ir_dereference_array(varref, dra->array_index);
+
+ progress = true;
+}
+
+} /* anonymous namespace */
+
+bool
+lower_const_arrays_to_uniforms(exec_list *instructions)
+{
+ lower_const_array_visitor v(instructions);
+ return v.run();
+}
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index 79e943831..432643707 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -46,6 +46,7 @@
#include "glsl_parser_extras.h"
#include "ir_optimization.h"
#include "program.h"
+#include "program/hash_table.h"
#include "loop_analysis.h"
#include "standalone_scaffolding.h"
@@ -368,6 +369,11 @@ main(int argc, char **argv)
assert(whole_program != NULL);
whole_program->InfoLog = ralloc_strdup(whole_program, "");
+ /* Created just to avoid segmentation faults */
+ whole_program->AttributeBindings = new string_to_uint_map;
+ whole_program->FragDataBindings = new string_to_uint_map;
+ whole_program->FragDataIndexBindings = new string_to_uint_map;
+
for (/* empty */; argc > optind; optind++) {
whole_program->Shaders =
reralloc(whole_program, whole_program->Shaders,
@@ -426,6 +432,10 @@ main(int argc, char **argv)
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++)
ralloc_free(whole_program->_LinkedShaders[i]);
+ delete whole_program->AttributeBindings;
+ delete whole_program->FragDataBindings;
+ delete whole_program->FragDataIndexBindings;
+
ralloc_free(whole_program);
_mesa_glsl_release_types();
_mesa_glsl_release_builtin_functions();
diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp
index 0cdb8ecfc..430f5cb97 100644
--- a/mesalib/src/glsl/opt_algebraic.cpp
+++ b/mesalib/src/glsl/opt_algebraic.cpp
@@ -105,12 +105,6 @@ is_vec_negative_one(ir_constant *ir)
}
static inline bool
-is_vec_basis(ir_constant *ir)
-{
- return (ir == NULL) ? false : ir->is_basis();
-}
-
-static inline bool
is_valid_vec_const(ir_constant *ir)
{
if (ir == NULL)
@@ -537,21 +531,34 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1]))
return ir_constant::zero(mem_ctx, ir->type);
- if (is_vec_basis(op_const[0])) {
- unsigned component = 0;
- for (unsigned c = 0; c < op_const[0]->type->vector_elements; c++) {
- if (op_const[0]->value.f[c] == 1.0)
- component = c;
- }
- return new(mem_ctx) ir_swizzle(ir->operands[1], component, 0, 0, 0, 1);
- }
- if (is_vec_basis(op_const[1])) {
- unsigned component = 0;
- for (unsigned c = 0; c < op_const[1]->type->vector_elements; c++) {
- if (op_const[1]->value.f[c] == 1.0)
- component = c;
- }
- return new(mem_ctx) ir_swizzle(ir->operands[0], component, 0, 0, 0, 1);
+ for (int i = 0; i < 2; i++) {
+ if (!op_const[i])
+ continue;
+
+ unsigned components[4] = { 0 }, count = 0;
+
+ for (unsigned c = 0; c < op_const[i]->type->vector_elements; c++) {
+ if (op_const[i]->value.f[c] == 0.0)
+ continue;
+
+ components[count] = c;
+ count++;
+ }
+
+ /* No channels had zero values; bail. */
+ if (count >= op_const[i]->type->vector_elements)
+ break;
+
+ ir_expression_operation op = count == 1 ?
+ ir_binop_mul : ir_binop_dot;
+
+ /* Swizzle both operands to remove the channels that were zero. */
+ return new(mem_ctx)
+ ir_expression(op, glsl_type::float_type,
+ new(mem_ctx) ir_swizzle(ir->operands[0],
+ components, count),
+ new(mem_ctx) ir_swizzle(ir->operands[1],
+ components, count));
}
break;
diff --git a/mesalib/src/glsl/opt_cse.cpp b/mesalib/src/glsl/opt_cse.cpp
index 9c96835dd..b0b67f496 100644
--- a/mesalib/src/glsl/opt_cse.cpp
+++ b/mesalib/src/glsl/opt_cse.cpp
@@ -194,6 +194,8 @@ is_cse_candidate_visitor::visit(ir_dereference_variable *ir)
if (ir->var->data.read_only) {
return visit_continue;
} else {
+ if (debug)
+ printf("CSE: non-candidate: var %s is not read only\n", ir->var->name);
ok = false;
return visit_stop;
}
@@ -220,8 +222,11 @@ is_cse_candidate(ir_rvalue *ir)
/* Our temporary variable assignment generation isn't ready to handle
* anything bigger than a vector.
*/
- if (!ir->type->is_vector() && !ir->type->is_scalar())
+ if (!ir->type->is_vector() && !ir->type->is_scalar()) {
+ if (debug)
+ printf("CSE: non-candidate: not a vector/scalar\n");
return false;
+ }
/* Only handle expressions and textures currently. We may want to extend
* to variable-index array dereferences at some point.
@@ -231,6 +236,8 @@ is_cse_candidate(ir_rvalue *ir)
case ir_type_texture:
break;
default:
+ if (debug)
+ printf("CSE: non-candidate: not an expression/texture\n");
return false;
}
diff --git a/mesalib/src/glsl/s_expression.cpp b/mesalib/src/glsl/s_expression.cpp
index 1a28e1d52..2928a4db8 100644
--- a/mesalib/src/glsl/s_expression.cpp
+++ b/mesalib/src/glsl/s_expression.cpp
@@ -73,7 +73,7 @@ read_atom(void *ctx, const char *&src, char *&symbol_buffer)
} else {
// Check if the atom is a number.
char *float_end = NULL;
- float f = glsl_strtof(src, &float_end);
+ float f = _mesa_strtof(src, &float_end);
if (float_end != src) {
char *int_end = NULL;
int i = strtol(src, &int_end, 10);
diff --git a/mesalib/src/glsl/s_expression.h b/mesalib/src/glsl/s_expression.h
index 642af19b4..1d4753530 100644
--- a/mesalib/src/glsl/s_expression.h
+++ b/mesalib/src/glsl/s_expression.h
@@ -27,7 +27,7 @@
#define S_EXPRESSION_H
#include "main/core.h" /* for Elements */
-#include "strtod.h"
+#include "util/strtod.h"
#include "list.h"
/* Type-safe downcasting macros (also safe to pass NULL) */
diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript
index bc1c43aa8..97ebfe638 100644
--- a/mesalib/src/mapi/glapi/SConscript
+++ b/mesalib/src/mapi/glapi/SConscript
@@ -16,6 +16,7 @@ if env['platform'] == 'windows':
env.Append(CPPDEFINES = [
'_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
+ 'KHRONOS_DLL_EXPORTS', # declare gl* as __declspec(dllexport) in Khronos headers
])
if env['gles']:
env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS'])
diff --git a/mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml b/mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml
new file mode 100644
index 000000000..bc724357b
--- /dev/null
+++ b/mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_KHR_context_flush_control" number="168">
+ <enum name="CONTEXT_RELEASE_BEHAVIOR" value="0x82FB"/>
+ <enum name="CONTEXT_RELEASE_BEHAVIOR_FLUSH" value="0x82FC"/>
+</category>
+
+</OpenGLAPI>
diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am
index 72e5095ee..7f76f1971 100644
--- a/mesalib/src/mapi/glapi/gen/Makefile.am
+++ b/mesalib/src/mapi/glapi/gen/Makefile.am
@@ -61,12 +61,10 @@ EXTRA_DIST= \
$(MESA_GLAPI_DIR)/glapi_x86-64.S \
$(MESA_GLAPI_DIR)/glapi_sparc.S \
$(COMMON_GLX) \
- extension_helper.py \
gl_apitemp.py \
gl_enums.py \
gl_genexec.py \
gl_gentable.py \
- gl_offsets.py \
gl_procs.py \
gl_SPARC_asm.py \
gl_table.py \
@@ -76,7 +74,6 @@ EXTRA_DIST= \
glX_proto_send.py \
glX_proto_size.py \
glX_server_table.py \
- mesadef.py \
remap_helper.py \
gl_API.dtd
diff --git a/mesalib/src/mapi/glapi/gen/extension_helper.py b/mesalib/src/mapi/glapi/gen/extension_helper.py
deleted file mode 100644
index da633dc61..000000000
--- a/mesalib/src/mapi/glapi/gen/extension_helper.py
+++ /dev/null
@@ -1,324 +0,0 @@
-#!/usr/bin/env python
-
-# (C) Copyright IBM Corporation 2005
-# 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
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, and/or sell copies of the Software, and to permit persons to whom
-# the Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#
-# Authors:
-# Ian Romanick <idr@us.ibm.com>
-
-import gl_XML
-import license
-import sys, getopt, string
-
-vtxfmt = [
- "ArrayElement", \
- "Color3f", \
- "Color3fv", \
- "Color4f", \
- "Color4fv", \
- "EdgeFlag", \
- "EdgeFlagv", \
- "EvalCoord1f", \
- "EvalCoord1fv", \
- "EvalCoord2f", \
- "EvalCoord2fv", \
- "EvalPoint1", \
- "EvalPoint2", \
- "FogCoordfEXT", \
- "FogCoordfvEXT", \
- "Indexf", \
- "Indexfv", \
- "Materialfv", \
- "MultiTexCoord1fARB", \
- "MultiTexCoord1fvARB", \
- "MultiTexCoord2fARB", \
- "MultiTexCoord2fvARB", \
- "MultiTexCoord3fARB", \
- "MultiTexCoord3fvARB", \
- "MultiTexCoord4fARB", \
- "MultiTexCoord4fvARB", \
- "Normal3f", \
- "Normal3fv", \
- "SecondaryColor3fEXT", \
- "SecondaryColor3fvEXT", \
- "TexCoord1f", \
- "TexCoord1fv", \
- "TexCoord2f", \
- "TexCoord2fv", \
- "TexCoord3f", \
- "TexCoord3fv", \
- "TexCoord4f", \
- "TexCoord4fv", \
- "Vertex2f", \
- "Vertex2fv", \
- "Vertex3f", \
- "Vertex3fv", \
- "Vertex4f", \
- "Vertex4fv", \
- "CallList", \
- "CallLists", \
- "Begin", \
- "End", \
- "VertexAttrib1fNV", \
- "VertexAttrib1fvNV", \
- "VertexAttrib2fNV", \
- "VertexAttrib2fvNV", \
- "VertexAttrib3fNV", \
- "VertexAttrib3fvNV", \
- "VertexAttrib4fNV", \
- "VertexAttrib4fvNV", \
- "VertexAttrib1fARB", \
- "VertexAttrib1fvARB", \
- "VertexAttrib2fARB", \
- "VertexAttrib2fvARB", \
- "VertexAttrib3fARB", \
- "VertexAttrib3fvARB", \
- "VertexAttrib4fARB", \
- "VertexAttrib4fvARB", \
- "Rectf", \
- "DrawArrays", \
- "DrawElements", \
- "DrawRangeElements", \
- "EvalMesh1", \
- "EvalMesh2", \
-]
-
-def all_entrypoints_in_abi(f, abi, api):
- for n in f.entry_points:
- [category, num] = api.get_category_for_name( n )
- if category not in abi:
- return 0
-
- return 1
-
-
-def any_entrypoints_in_abi(f, abi, api):
- for n in f.entry_points:
- [category, num] = api.get_category_for_name( n )
- if category in abi:
- return 1
-
- return 0
-
-
-def condition_for_function(f, abi, all_not_in_ABI):
- """Create a C-preprocessor condition for the function.
-
- There are two modes of operation. If all_not_in_ABI is set, a
- condition is only created is all of the entry-point names for f are
- not in the selected ABI. If all_not_in_ABI is not set, a condition
- is created if any entryp-point name is not in the selected ABI.
- """
-
- condition = []
- for n in f.entry_points:
- [category, num] = api.get_category_for_name( n )
- if category not in abi:
- condition.append( 'defined(need_%s)' % (gl_XML.real_category_name( category )) )
- elif all_not_in_ABI:
- return []
-
- return condition
-
-
-class PrintGlExtensionGlue(gl_XML.gl_print_base):
- def __init__(self):
- gl_XML.gl_print_base.__init__(self)
-
- self.name = "extension_helper.py (from Mesa)"
- self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
- return
-
-
- def printRealHeader(self):
- print '#include "utils.h"'
- print '#include "main/dispatch.h"'
- print ''
- return
-
-
- def printBody(self, api):
- abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
-
- category_list = {}
-
- print '#ifndef NULL'
- print '# define NULL 0'
- print '#endif'
- print ''
-
- for f in api.functionIterateAll():
- condition = condition_for_function(f, abi, 0)
- if len(condition):
- print '#if %s' % (string.join(condition, " || "))
- print 'static const char %s_names[] =' % (f.name)
-
- parameter_signature = ''
- for p in f.parameterIterator():
- if p.is_padding:
- continue
-
- # FIXME: This is a *really* ugly hack. :(
-
- tn = p.type_expr.get_base_type_node()
- if p.is_pointer():
- parameter_signature += 'p'
- elif tn.integer:
- parameter_signature += 'i'
- elif tn.size == 4:
- parameter_signature += 'f'
- else:
- parameter_signature += 'd'
-
- print ' "%s\\0" /* Parameter signature */' % (parameter_signature)
-
- for n in f.entry_points:
- print ' "gl%s\\0"' % (n)
-
- [category, num] = api.get_category_for_name( n )
- if category not in abi:
- c = gl_XML.real_category_name(category)
- if not category_list.has_key(c):
- category_list[ c ] = []
-
- category_list[ c ].append( f )
-
- print ' "";'
- print '#endif'
- print ''
-
- keys = category_list.keys()
- keys.sort()
-
- for category in keys:
- print '#if defined(need_%s)' % (category)
- print 'static const struct dri_extension_function %s_functions[] = {' % (category)
-
- for f in category_list[ category ]:
- # A function either has an offset that is
- # assigned by the ABI, or it has a remap
- # index.
- if any_entrypoints_in_abi(f, abi, api):
- index_name = "-1"
- offset = f.offset
- else:
- index_name = "%s_remap_index" % (f.name)
- offset = -1
-
- print ' { %s_names, %s, %d },' % (f.name, index_name, offset)
-
-
- print ' { NULL, 0, 0 }'
- print '};'
- print '#endif'
- print ''
-
- return
-
-
-class PrintInitDispatch(gl_XML.gl_print_base):
- def __init__(self):
- gl_XML.gl_print_base.__init__(self)
-
- self.name = "extension_helper.py (from Mesa)"
- self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
- return
-
-
- def do_function_body(self, api, abi, vtxfmt_only):
- last_condition_string = None
- for f in api.functionIterateByOffset():
- if (f.name in vtxfmt) and not vtxfmt_only:
- continue
-
- if (f.name not in vtxfmt) and vtxfmt_only:
- continue
-
- condition = condition_for_function(f, abi, 1)
- condition_string = string.join(condition, " || ")
-
- if condition_string != last_condition_string:
- if last_condition_string:
- print '#endif /* %s */' % (last_condition_string)
-
- if condition_string:
- print '#if %s' % (condition_string)
-
- if vtxfmt_only:
- print ' disp->%s = vfmt->%s;' % (f.name, f.name)
- else:
- print ' disp->%s = _mesa_%s;' % (f.name, f.name)
-
- last_condition_string = condition_string
-
- if last_condition_string:
- print '#endif /* %s */' % (last_condition_string)
-
-
-
- def printBody(self, api):
- abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
-
- print 'void driver_init_exec_table(struct _glapi_table *disp)'
- print '{'
- self.do_function_body(api, abi, 0)
- print '}'
- print ''
- print 'void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)'
- print '{'
- self.do_function_body(api, abi, 1)
- print '}'
-
- return
-
-
-def show_usage():
- print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
- print " -m output_mode Output mode can be one of 'extensions' or 'exec_init'."
- sys.exit(1)
-
-if __name__ == '__main__':
- file_name = "gl_API.xml"
-
- try:
- (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
- except Exception,e:
- show_usage()
-
- mode = "extensions"
- for (arg,val) in args:
- if arg == "-f":
- file_name = val
- if arg == '-m':
- mode = val
-
-
- api = gl_XML.parse_GL_API( file_name )
-
- if mode == "extensions":
- printer = PrintGlExtensionGlue()
- elif mode == "exec_init":
- printer = PrintInitDispatch()
- else:
- show_usage()
-
- printer.Print( api )
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index 43e5d3555..96146b7a7 100755
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -8379,6 +8379,8 @@
<xi:include href="ARB_texture_barrier.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+<xi:include href="KHR_context_flush_control.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
<!-- Non-ARB extensions sorted by extension number. -->
<category name="GL_EXT_blend_color" number="2">
diff --git a/mesalib/src/mapi/glapi/gen/gl_offsets.py b/mesalib/src/mapi/glapi/gen/gl_offsets.py
deleted file mode 100644
index 897ac18ae..000000000
--- a/mesalib/src/mapi/glapi/gen/gl_offsets.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-
-# (C) Copyright IBM Corporation 2004, 2005
-# 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
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, and/or sell copies of the Software, and to permit persons to whom
-# the Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#
-# Authors:
-# Ian Romanick <idr@us.ibm.com>
-
-import gl_XML
-import license
-import sys, getopt
-
-class PrintGlOffsets(gl_XML.gl_print_base):
- def __init__(self, es=False):
- gl_XML.gl_print_base.__init__(self)
-
- self.es = es
- self.name = "gl_offsets.py (from Mesa)"
- self.header_tag = '_GLAPI_OFFSETS_H_'
- self.license = license.bsd_license_template % ( \
-"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
-(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
- return
-
- def printBody(self, api):
- print '/* this file should not be included directly in mesa */'
- print ''
-
- functions = []
- abi_functions = []
- alias_functions = []
- count = 0
- for f in api.functionIterateByOffset():
- if not f.is_abi():
- functions.append( [f, count] )
- count += 1
- else:
- abi_functions.append( f )
-
- if self.es:
- # remember functions with aliases
- if len(f.entry_points) > 1:
- alias_functions.append(f)
-
- for f in abi_functions:
- print '#define _gloffset_%s %d' % (f.name, f.offset)
- last_static = f.offset
-
- print ''
- print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
- print ''
-
- for [f, index] in functions:
- print '#define _gloffset_%s %d' % (f.name, f.offset)
-
- print '#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset)
-
- print ''
- print '#else'
- print ''
-
- for [f, index] in functions:
- print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)
-
- print ''
- print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
-
- if alias_functions:
- print ''
- print '/* define aliases for compatibility */'
- for f in alias_functions:
- for name in f.entry_points:
- if name != f.name:
- print '#define _gloffset_%s _gloffset_%s' % (name, f.name)
- return
-
-
-def show_usage():
- print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
- print " -c Enable compatibility with OpenGL ES."
- sys.exit(1)
-
-if __name__ == '__main__':
- file_name = "gl_API.xml"
-
- try:
- (args, trail) = getopt.getopt(sys.argv[1:], "f:c")
- except Exception,e:
- show_usage()
-
- es = False
- for (arg,val) in args:
- if arg == "-f":
- file_name = val
- elif arg == "-c":
- es = True
-
- api = gl_XML.parse_GL_API( file_name )
-
- printer = PrintGlOffsets(es)
- printer.Print( api )
diff --git a/mesalib/src/mapi/glapi/gen/mesadef.py b/mesalib/src/mapi/glapi/gen/mesadef.py
deleted file mode 100644
index 77cc4a350..000000000
--- a/mesalib/src/mapi/glapi/gen/mesadef.py
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/usr/bin/env python
-
-
-# Mesa 3-D graphics library
-#
-# Copyright (C) 1999-2001 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, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-# OTHER DEALINGS IN THE SOFTWARE.
-
-
-# Generate the mesa.def file for Windows.
-#
-# Usage:
-# mesadef.py >mesa.def
-# Then copy to src/mesa/drivers/windows/gdi
-#
-# Dependencies:
-# The apispec file must be in the current directory.
-
-
-
-import apiparser
-import string
-
-
-def PrintHead():
- print '; DO NOT EDIT - This file generated automatically by mesadef.py script'
- print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''
- print 'VERSION 6.0'
- print ';'
- print '; Module definition file for Mesa (OPENGL32.DLL)'
- print ';'
- print '; Note: The OpenGL functions use the STDCALL'
- print '; function calling convention. Microsoft\'s'
- print '; OPENGL32 uses this convention and so must the'
- print '; Mesa OPENGL32 so that the Mesa DLL can be used'
- print '; as a drop-in replacement.'
- print ';'
- print '; The linker exports STDCALL entry points with'
- print '; \'decorated\' names; e.g., _glBegin@0, where the'
- print '; trailing number is the number of bytes of '
- print '; parameter data pushed onto the stack. The'
- print '; callee is responsible for popping this data'
- print '; off the stack, usually via a RETF n instruction.'
- print ';'
- print '; However, the Microsoft OPENGL32.DLL does not export'
- print '; the decorated names, even though the calling convention'
- print '; is STDCALL. So, this module definition file is'
- print '; needed to force the Mesa OPENGL32.DLL to export the'
- print '; symbols in the same manner as the Microsoft DLL.'
- print '; Were it not for this problem, this file would not'
- print '; be needed (for the gl* functions) since the entry'
- print '; points are compiled with dllexport declspec.'
- print ';'
- print '; However, this file is still needed to export "internal"'
- print '; Mesa symbols for the benefit of the OSMESA32.DLL.'
- print ';'
- print 'EXPORTS'
- return
-#enddef
-
-
-def PrintTail():
- print ';'
- print '; WGL API'
- print '\twglChoosePixelFormat'
- print '\twglCopyContext'
- print '\twglCreateContext'
- print '\twglCreateLayerContext'
- print '\twglDeleteContext'
- print '\twglDescribeLayerPlane'
- print '\twglDescribePixelFormat'
- print '\twglGetCurrentContext'
- print '\twglGetCurrentDC'
- print '\twglGetExtensionsStringARB'
- print '\twglGetLayerPaletteEntries'
- print '\twglGetPixelFormat'
- print '\twglGetProcAddress'
- print '\twglMakeCurrent'
- print '\twglRealizeLayerPalette'
- print '\twglSetLayerPaletteEntries'
- print '\twglSetPixelFormat'
- print '\twglShareLists'
- print '\twglSwapBuffers'
- print '\twglSwapLayerBuffers'
- print '\twglUseFontBitmapsA'
- print '\twglUseFontBitmapsW'
- print '\twglUseFontOutlinesA'
- print '\twglUseFontOutlinesW'
- print ';'
- print '; Mesa internals - mostly for OSMESA'
- print '\t_ac_CreateContext'
- print '\t_ac_DestroyContext'
- print '\t_ac_InvalidateState'
- print '\t_glapi_get_context'
- print '\t_glapi_get_proc_address'
- print '\t_mesa_buffer_data'
- print '\t_mesa_buffer_map'
- print '\t_mesa_buffer_subdata'
- print '\t_mesa_choose_tex_format'
- print '\t_mesa_compressed_texture_size'
- print '\t_mesa_create_framebuffer'
- print '\t_mesa_create_visual'
- print '\t_mesa_delete_buffer_object'
- print '\t_mesa_delete_texture_object'
- print '\t_mesa_destroy_framebuffer'
- print '\t_mesa_destroy_visual'
- print '\t_mesa_enable_1_3_extensions'
- print '\t_mesa_enable_1_4_extensions'
- print '\t_mesa_enable_1_5_extensions'
- print '\t_mesa_enable_sw_extensions'
- print '\t_mesa_error'
- print '\t_mesa_free_context_data'
- print '\t_mesa_get_current_context'
- print '\t_mesa_init_default_imports'
- print '\t_mesa_initialize_context'
- print '\t_mesa_make_current'
- print '\t_mesa_new_buffer_object'
- print '\t_mesa_new_texture_object'
- print '\t_mesa_problem'
- print '\t_mesa_store_compressed_teximage1d'
- print '\t_mesa_store_compressed_teximage2d'
- print '\t_mesa_store_compressed_teximage3d'
- print '\t_mesa_store_compressed_texsubimage1d'
- print '\t_mesa_store_compressed_texsubimage2d'
- print '\t_mesa_store_compressed_texsubimage3d'
- print '\t_mesa_store_teximage1d'
- print '\t_mesa_store_teximage2d'
- print '\t_mesa_store_teximage3d'
- print '\t_mesa_store_texsubimage1d'
- print '\t_mesa_store_texsubimage2d'
- print '\t_mesa_store_texsubimage3d'
- print '\t_mesa_test_proxy_teximage'
- print '\t_mesa_Viewport'
- print '\t_mesa_meta_CopyColorSubTable'
- print '\t_mesa_meta_CopyColorTable'
- print '\t_mesa_meta_CopyConvolutionFilter1D'
- print '\t_mesa_meta_CopyConvolutionFilter2D'
- print '\t_mesa_meta_CopyTexImage1D'
- print '\t_mesa_meta_CopyTexImage2D'
- print '\t_mesa_meta_CopyTexSubImage1D'
- print '\t_mesa_meta_CopyTexSubImage2D'
- print '\t_mesa_meta_CopyTexSubImage3D'
- print '\t_swrast_Accum'
- print '\t_swrast_alloc_buffers'
- print '\t_swrast_Bitmap'
- print '\t_swrast_CopyPixels'
- print '\t_swrast_DrawPixels'
- print '\t_swrast_GetDeviceDriverReference'
- print '\t_swrast_Clear'
- print '\t_swrast_choose_line'
- print '\t_swrast_choose_triangle'
- print '\t_swrast_CreateContext'
- print '\t_swrast_DestroyContext'
- print '\t_swrast_InvalidateState'
- print '\t_swrast_ReadPixels'
- print '\t_swrast_zbuffer_address'
- print '\t_swsetup_Wakeup'
- print '\t_swsetup_CreateContext'
- print '\t_swsetup_DestroyContext'
- print '\t_swsetup_InvalidateState'
- print '\t_tnl_CreateContext'
- print '\t_tnl_DestroyContext'
- print '\t_tnl_InvalidateState'
- print '\t_tnl_MakeCurrent'
- print '\t_tnl_run_pipeline'
-#enddef
-
-
-records = []
-
-def FindOffset(funcName):
- for (name, alias, offset) in records:
- if name == funcName:
- return offset
- #endif
- #endfor
- return -1
-#enddef
-
-
-def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset):
- if alias == '':
- dispatchName = name
- else:
- dispatchName = alias
- if offset < 0:
- offset = FindOffset(dispatchName)
- if offset >= 0 and string.find(name, "unused") == -1:
- print '\tgl%s' % (name)
- # save this info in case we need to look up an alias later
- records.append((name, dispatchName, offset))
-
-#enddef
-
-
-PrintHead()
-apiparser.ProcessSpecFile("APIspec", EmitEntry)
-PrintTail()
diff --git a/mesalib/src/mesa/Android.libmesa_dricore.mk b/mesalib/src/mesa/Android.libmesa_dricore.mk
index 1e6d94872..2ab593d3c 100644
--- a/mesalib/src/mesa/Android.libmesa_dricore.mk
+++ b/mesalib/src/mesa/Android.libmesa_dricore.mk
@@ -51,10 +51,16 @@ endif # MESA_ENABLE_ASM
ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
LOCAL_SRC_FILES += \
- $(SRCDIR)main/streaming-load-memcpy.c
+ $(SRCDIR)main/streaming-load-memcpy.c \
+ $(SRCDIR)main/sse_minmax.c
LOCAL_CFLAGS := -msse4.1
endif
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+LOCAL_CFLAGS += \
+ -DUSE_SSE41
+endif
+
LOCAL_C_INCLUDES := \
$(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
$(MESA_TOP)/src \
diff --git a/mesalib/src/mesa/Android.libmesa_st_mesa.mk b/mesalib/src/mesa/Android.libmesa_st_mesa.mk
index 8b8d652a3..618d6bfb2 100644
--- a/mesalib/src/mesa/Android.libmesa_st_mesa.mk
+++ b/mesalib/src/mesa/Android.libmesa_st_mesa.mk
@@ -48,6 +48,11 @@ ifeq ($(TARGET_ARCH),x86)
endif # x86
endif # MESA_ENABLE_ASM
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+LOCAL_CFLAGS := \
+ -DUSE_SSE41
+endif
+
LOCAL_C_INCLUDES := \
$(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
$(MESA_TOP)/src/gallium/auxiliary \
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am
index e71bccbbe..932db4fb8 100644
--- a/mesalib/src/mesa/Makefile.am
+++ b/mesalib/src/mesa/Makefile.am
@@ -151,7 +151,8 @@ libmesagallium_la_LIBADD = \
$(ARCH_LIBS)
libmesa_sse41_la_SOURCES = \
- main/streaming-load-memcpy.c
+ main/streaming-load-memcpy.c \
+ main/sse_minmax.c
libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) -msse4.1
pkgconfigdir = $(libdir)/pkgconfig
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index f18fac61e..28923319d 100755
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -380,19 +380,17 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
return NULL;
}
- /* The EGL_KHR_create_context spec says:
+ /* The latest version of EGL_KHR_create_context spec says:
*
- * "Flags are only defined for OpenGL context creation, and specifying
- * a flags value other than zero for other types of contexts,
- * including OpenGL ES contexts, will generate an error."
+ * "If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in
+ * EGL_CONTEXT_FLAGS_KHR, then a <debug context> will be created.
+ * [...] This bit is supported for OpenGL and OpenGL ES contexts.
*
- * The GLX_EXT_create_context_es2_profile specification doesn't say
- * anything specific about this case. However, none of the known flags
- * have any meaning in an ES context, so this seems safe.
+ * None of the other flags have any meaning in an ES context, so this seems safe.
*/
if (mesa_api != API_OPENGL_COMPAT
&& mesa_api != API_OPENGL_CORE
- && flags != 0) {
+ && (flags & ~__DRI_CTX_FLAG_DEBUG)) {
*error = __DRI_CTX_ERROR_BAD_FLAG;
return NULL;
}
@@ -573,6 +571,12 @@ static int driUnbindContext(__DRIcontext *pcp)
if (pcp == NULL)
return GL_FALSE;
+ /*
+ ** Call driUnbindContext before checking for valid drawables
+ ** to handle surfaceless contexts properly.
+ */
+ pcp->driScreenPriv->driver->UnbindContext(pcp);
+
pdp = pcp->driDrawablePriv;
prp = pcp->driReadablePriv;
@@ -580,8 +584,6 @@ static int driUnbindContext(__DRIcontext *pcp)
if (!pdp && !prp)
return GL_TRUE;
- pcp->driScreenPriv->driver->UnbindContext(pcp);
-
assert(pdp);
if (pdp->refcount == 0) {
/* ERROR!!! */
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h b/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h
index b73a6620c..4e5a7217e 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -340,3 +340,21 @@ DRI_CONF_SECTION_BEGIN \
DRI_CONF_OPT_BEGIN(device_id, string, def) \
DRI_CONF_DESC(en,gettext("Define the graphic device to use if possible")) \
DRI_CONF_OPT_END
+
+/**
+ * \brief Gallium-Nine specific configuration options
+ */
+
+#define DRI_CONF_SECTION_NINE \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,gettext("Gallium Nine"))
+
+#define DRI_CONF_NINE_THROTTLE(def) \
+DRI_CONF_OPT_BEGIN(throttle_value, int, def) \
+ DRI_CONF_DESC(en,gettext("Define the throttling value. -1 for no throttling, -2 for default (usually 2), 0 for glfinish behaviour")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_THREADSUBMIT(def) \
+DRI_CONF_OPT_BEGIN_B(thread_submit, def) \
+ DRI_CONF_DESC(en,gettext("Use an additional thread to submit buffers.")) \
+DRI_CONF_OPT_END
diff --git a/mesalib/src/mesa/drivers/windows/gdi/mesa.def b/mesalib/src/mesa/drivers/windows/gdi/mesa.def
index 92736b368..a52207b63 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/mesa.def
+++ b/mesalib/src/mesa/drivers/windows/gdi/mesa.def
@@ -1,6 +1,3 @@
-; DO NOT EDIT - This file generated automatically by mesadef.py script
-;DESCRIPTION 'Mesa (OpenGL work-alike) for Win32'
-VERSION 6.5
;
; Module definition file for Mesa (OPENGL32.DLL)
;
@@ -27,15 +24,23 @@ VERSION 6.5
; points are compiled with dllexport declspec.
;
EXPORTS
- glNewList
- glEndList
- glCallList
- glCallLists
- glDeleteLists
- glGenLists
- glListBase
+ glAccum
+ glAlphaFunc
+ glAreTexturesResident
+ glArrayElement
glBegin
+ glBindTexture
glBitmap
+ glBlendFunc
+ glCallList
+ glCallLists
+ glClear
+ glClearAccum
+ glClearColor
+ glClearDepth
+ glClearIndex
+ glClearStencil
+ glClipPlane
glColor3b
glColor3bv
glColor3d
@@ -68,9 +73,88 @@ EXPORTS
glColor4uiv
glColor4us
glColor4usv
+ glColorMask
+ glColorMaterial
+ glColorPointer
+ glCopyPixels
+ glCopyTexImage1D
+ glCopyTexImage2D
+ glCopyTexSubImage1D
+ glCopyTexSubImage2D
+ glCullFace
+ glDeleteLists
+ glDeleteTextures
+ glDepthFunc
+ glDepthMask
+ glDepthRange
+ glDisable
+ glDisableClientState
+ glDrawArrays
+ glDrawBuffer
+ glDrawElements
+ glDrawPixels
glEdgeFlag
+ glEdgeFlagPointer
glEdgeFlagv
+ glEnable
+ glEnableClientState
glEnd
+ glEndList
+ glEvalCoord1d
+ glEvalCoord1dv
+ glEvalCoord1f
+ glEvalCoord1fv
+ glEvalCoord2d
+ glEvalCoord2dv
+ glEvalCoord2f
+ glEvalCoord2fv
+ glEvalMesh1
+ glEvalMesh2
+ glEvalPoint1
+ glEvalPoint2
+ glFeedbackBuffer
+ glFinish
+ glFlush
+ glFogf
+ glFogfv
+ glFogi
+ glFogiv
+ glFrontFace
+ glFrustum
+ glGenLists
+ glGenTextures
+ glGetBooleanv
+ glGetClipPlane
+ glGetDoublev
+ glGetError
+ glGetFloatv
+ glGetIntegerv
+ glGetLightfv
+ glGetLightiv
+ glGetMapdv
+ glGetMapfv
+ glGetMapiv
+ glGetMaterialfv
+ glGetMaterialiv
+ glGetPixelMapfv
+ glGetPixelMapuiv
+ glGetPixelMapusv
+ glGetPointerv
+ glGetPolygonStipple
+ glGetString
+ glGetTexEnvfv
+ glGetTexEnviv
+ glGetTexGendv
+ glGetTexGenfv
+ glGetTexGeniv
+ glGetTexImage
+ glGetTexLevelParameterfv
+ glGetTexLevelParameteriv
+ glGetTexParameterfv
+ glGetTexParameteriv
+ glHint
+ glIndexMask
+ glIndexPointer
glIndexd
glIndexdv
glIndexf
@@ -79,6 +163,45 @@ EXPORTS
glIndexiv
glIndexs
glIndexsv
+ glIndexub
+ glIndexubv
+ glInitNames
+ glInterleavedArrays
+ glIsEnabled
+ glIsList
+ glIsTexture
+ glLightModelf
+ glLightModelfv
+ glLightModeli
+ glLightModeliv
+ glLightf
+ glLightfv
+ glLighti
+ glLightiv
+ glLineStipple
+ glLineWidth
+ glListBase
+ glLoadIdentity
+ glLoadMatrixd
+ glLoadMatrixf
+ glLoadName
+ glLogicOp
+ glMap1d
+ glMap1f
+ glMap2d
+ glMap2f
+ glMapGrid1d
+ glMapGrid1f
+ glMapGrid2d
+ glMapGrid2f
+ glMaterialf
+ glMaterialfv
+ glMateriali
+ glMaterialiv
+ glMatrixMode
+ glMultMatrixd
+ glMultMatrixf
+ glNewList
glNormal3b
glNormal3bv
glNormal3d
@@ -89,6 +212,30 @@ EXPORTS
glNormal3iv
glNormal3s
glNormal3sv
+ glNormalPointer
+ glOrtho
+ glPassThrough
+ glPixelMapfv
+ glPixelMapuiv
+ glPixelMapusv
+ glPixelStoref
+ glPixelStorei
+ glPixelTransferf
+ glPixelTransferi
+ glPixelZoom
+ glPointSize
+ glPolygonMode
+ glPolygonOffset
+ glPolygonStipple
+ glPopAttrib
+ glPopClientAttrib
+ glPopMatrix
+ glPopName
+ glPrioritizeTextures
+ glPushAttrib
+ glPushClientAttrib
+ glPushMatrix
+ glPushName
glRasterPos2d
glRasterPos2dv
glRasterPos2f
@@ -113,6 +260,8 @@ EXPORTS
glRasterPos4iv
glRasterPos4s
glRasterPos4sv
+ glReadBuffer
+ glReadPixels
glRectd
glRectdv
glRectf
@@ -121,6 +270,17 @@ EXPORTS
glRectiv
glRects
glRectsv
+ glRenderMode
+ glRotated
+ glRotatef
+ glScaled
+ glScalef
+ glScissor
+ glSelectBuffer
+ glShadeModel
+ glStencilFunc
+ glStencilMask
+ glStencilOp
glTexCoord1d
glTexCoord1dv
glTexCoord1f
@@ -153,6 +313,27 @@ EXPORTS
glTexCoord4iv
glTexCoord4s
glTexCoord4sv
+ glTexCoordPointer
+ glTexEnvf
+ glTexEnvfv
+ glTexEnvi
+ glTexEnviv
+ glTexGend
+ glTexGendv
+ glTexGenf
+ glTexGenfv
+ glTexGeni
+ glTexGeniv
+ glTexImage1D
+ glTexImage2D
+ glTexParameterf
+ glTexParameterfv
+ glTexParameteri
+ glTexParameteriv
+ glTexSubImage1D
+ glTexSubImage2D
+ glTranslated
+ glTranslatef
glVertex2d
glVertex2dv
glVertex2f
@@ -177,643 +358,8 @@ EXPORTS
glVertex4iv
glVertex4s
glVertex4sv
- glClipPlane
- glColorMaterial
- glCullFace
- glFogf
- glFogfv
- glFogi
- glFogiv
- glFrontFace
- glHint
- glLightf
- glLightfv
- glLighti
- glLightiv
- glLightModelf
- glLightModelfv
- glLightModeli
- glLightModeliv
- glLineStipple
- glLineWidth
- glMaterialf
- glMaterialfv
- glMateriali
- glMaterialiv
- glPointSize
- glPolygonMode
- glPolygonStipple
- glScissor
- glShadeModel
- glTexParameterf
- glTexParameterfv
- glTexParameteri
- glTexParameteriv
- glTexImage1D
- glTexImage2D
- glTexEnvf
- glTexEnvfv
- glTexEnvi
- glTexEnviv
- glTexGend
- glTexGendv
- glTexGenf
- glTexGenfv
- glTexGeni
- glTexGeniv
- glFeedbackBuffer
- glSelectBuffer
- glRenderMode
- glInitNames
- glLoadName
- glPassThrough
- glPopName
- glPushName
- glDrawBuffer
- glClear
- glClearAccum
- glClearIndex
- glClearColor
- glClearStencil
- glClearDepth
- glStencilMask
- glColorMask
- glDepthMask
- glIndexMask
- glAccum
- glDisable
- glEnable
- glFinish
- glFlush
- glPopAttrib
- glPushAttrib
- glMap1d
- glMap1f
- glMap2d
- glMap2f
- glMapGrid1d
- glMapGrid1f
- glMapGrid2d
- glMapGrid2f
- glEvalCoord1d
- glEvalCoord1dv
- glEvalCoord1f
- glEvalCoord1fv
- glEvalCoord2d
- glEvalCoord2dv
- glEvalCoord2f
- glEvalCoord2fv
- glEvalMesh1
- glEvalPoint1
- glEvalMesh2
- glEvalPoint2
- glAlphaFunc
- glBlendFunc
- glLogicOp
- glStencilFunc
- glStencilOp
- glDepthFunc
- glPixelZoom
- glPixelTransferf
- glPixelTransferi
- glPixelStoref
- glPixelStorei
- glPixelMapfv
- glPixelMapuiv
- glPixelMapusv
- glReadBuffer
- glCopyPixels
- glReadPixels
- glDrawPixels
- glGetBooleanv
- glGetClipPlane
- glGetDoublev
- glGetError
- glGetFloatv
- glGetIntegerv
- glGetLightfv
- glGetLightiv
- glGetMapdv
- glGetMapfv
- glGetMapiv
- glGetMaterialfv
- glGetMaterialiv
- glGetPixelMapfv
- glGetPixelMapuiv
- glGetPixelMapusv
- glGetPolygonStipple
- glGetString
- glGetTexEnvfv
- glGetTexEnviv
- glGetTexGendv
- glGetTexGenfv
- glGetTexGeniv
- glGetTexImage
- glGetTexParameterfv
- glGetTexParameteriv
- glGetTexLevelParameterfv
- glGetTexLevelParameteriv
- glIsEnabled
- glIsList
- glDepthRange
- glFrustum
- glLoadIdentity
- glLoadMatrixf
- glLoadMatrixd
- glMatrixMode
- glMultMatrixf
- glMultMatrixd
- glOrtho
- glPopMatrix
- glPushMatrix
- glRotated
- glRotatef
- glScaled
- glScalef
- glTranslated
- glTranslatef
- glViewport
- glArrayElement
- glColorPointer
- glDisableClientState
- glDrawArrays
- glDrawElements
- glEdgeFlagPointer
- glEnableClientState
- glGetPointerv
- glIndexPointer
- glInterleavedArrays
- glNormalPointer
- glTexCoordPointer
glVertexPointer
- glPolygonOffset
- glCopyTexImage1D
- glCopyTexImage2D
- glCopyTexSubImage1D
- glCopyTexSubImage2D
- glTexSubImage1D
- glTexSubImage2D
- glAreTexturesResident
- glBindTexture
- glDeleteTextures
- glGenTextures
- glIsTexture
- glPrioritizeTextures
- glIndexub
- glIndexubv
- glPopClientAttrib
- glPushClientAttrib
- glBlendColor
- glBlendEquation
- glDrawRangeElements
- glColorTable
- glColorTableParameterfv
- glColorTableParameteriv
- glCopyColorTable
- glGetColorTable
- glGetColorTableParameterfv
- glGetColorTableParameteriv
- glColorSubTable
- glCopyColorSubTable
- glConvolutionFilter1D
- glConvolutionFilter2D
- glConvolutionParameterf
- glConvolutionParameterfv
- glConvolutionParameteri
- glConvolutionParameteriv
- glCopyConvolutionFilter1D
- glCopyConvolutionFilter2D
- glGetConvolutionFilter
- glGetConvolutionParameterfv
- glGetConvolutionParameteriv
- glGetSeparableFilter
- glSeparableFilter2D
- glGetHistogram
- glGetHistogramParameterfv
- glGetHistogramParameteriv
- glGetMinmax
- glGetMinmaxParameterfv
- glGetMinmaxParameteriv
- glHistogram
- glMinmax
- glResetHistogram
- glResetMinmax
- glTexImage3D
- glTexSubImage3D
- glCopyTexSubImage3D
- glActiveTextureARB
- glClientActiveTextureARB
- glMultiTexCoord1dARB
- glMultiTexCoord1dvARB
- glMultiTexCoord1fARB
- glMultiTexCoord1fvARB
- glMultiTexCoord1iARB
- glMultiTexCoord1ivARB
- glMultiTexCoord1sARB
- glMultiTexCoord1svARB
- glMultiTexCoord2dARB
- glMultiTexCoord2dvARB
- glMultiTexCoord2fARB
- glMultiTexCoord2fvARB
- glMultiTexCoord2iARB
- glMultiTexCoord2ivARB
- glMultiTexCoord2sARB
- glMultiTexCoord2svARB
- glMultiTexCoord3dARB
- glMultiTexCoord3dvARB
- glMultiTexCoord3fARB
- glMultiTexCoord3fvARB
- glMultiTexCoord3iARB
- glMultiTexCoord3ivARB
- glMultiTexCoord3sARB
- glMultiTexCoord3svARB
- glMultiTexCoord4dARB
- glMultiTexCoord4dvARB
- glMultiTexCoord4fARB
- glMultiTexCoord4fvARB
- glMultiTexCoord4iARB
- glMultiTexCoord4ivARB
- glMultiTexCoord4sARB
- glMultiTexCoord4svARB
- glLoadTransposeMatrixfARB
- glLoadTransposeMatrixdARB
- glMultTransposeMatrixfARB
- glMultTransposeMatrixdARB
- glSampleCoverageARB
- glCompressedTexImage3DARB
- glCompressedTexImage2DARB
- glCompressedTexImage1DARB
- glCompressedTexSubImage3DARB
- glCompressedTexSubImage2DARB
- glCompressedTexSubImage1DARB
- glGetCompressedTexImageARB
- glActiveTexture
- glClientActiveTexture
- glMultiTexCoord1d
- glMultiTexCoord1dv
- glMultiTexCoord1f
- glMultiTexCoord1fv
- glMultiTexCoord1i
- glMultiTexCoord1iv
- glMultiTexCoord1s
- glMultiTexCoord1sv
- glMultiTexCoord2d
- glMultiTexCoord2dv
- glMultiTexCoord2f
- glMultiTexCoord2fv
- glMultiTexCoord2i
- glMultiTexCoord2iv
- glMultiTexCoord2s
- glMultiTexCoord2sv
- glMultiTexCoord3d
- glMultiTexCoord3dv
- glMultiTexCoord3f
- glMultiTexCoord3fv
- glMultiTexCoord3i
- glMultiTexCoord3iv
- glMultiTexCoord3s
- glMultiTexCoord3sv
- glMultiTexCoord4d
- glMultiTexCoord4dv
- glMultiTexCoord4f
- glMultiTexCoord4fv
- glMultiTexCoord4i
- glMultiTexCoord4iv
- glMultiTexCoord4s
- glMultiTexCoord4sv
- glLoadTransposeMatrixf
- glLoadTransposeMatrixd
- glMultTransposeMatrixf
- glMultTransposeMatrixd
- glSampleCoverage
- glCompressedTexImage3D
- glCompressedTexImage2D
- glCompressedTexImage1D
- glCompressedTexSubImage3D
- glCompressedTexSubImage2D
- glCompressedTexSubImage1D
- glGetCompressedTexImage
- glBlendColorEXT
- glPolygonOffsetEXT
- glTexImage3DEXT
- glTexSubImage3DEXT
- glTexSubImage1DEXT
- glTexSubImage2DEXT
- glCopyTexImage1DEXT
- glCopyTexImage2DEXT
- glCopyTexSubImage1DEXT
- glCopyTexSubImage2DEXT
- glCopyTexSubImage3DEXT
- glAreTexturesResidentEXT
- glBindTextureEXT
- glDeleteTexturesEXT
- glGenTexturesEXT
- glIsTextureEXT
- glPrioritizeTexturesEXT
- glArrayElementEXT
- glColorPointerEXT
- glDrawArraysEXT
- glEdgeFlagPointerEXT
- glGetPointervEXT
- glIndexPointerEXT
- glNormalPointerEXT
- glTexCoordPointerEXT
- glVertexPointerEXT
- glBlendEquationEXT
- glPointParameterfEXT
- glPointParameterfvEXT
- glPointParameterfARB
- glPointParameterfvARB
- glColorTableEXT
- glGetColorTableEXT
- glGetColorTableParameterivEXT
- glGetColorTableParameterfvEXT
- glLockArraysEXT
- glUnlockArraysEXT
- glDrawRangeElementsEXT
- glSecondaryColor3bEXT
- glSecondaryColor3bvEXT
- glSecondaryColor3dEXT
- glSecondaryColor3dvEXT
- glSecondaryColor3fEXT
- glSecondaryColor3fvEXT
- glSecondaryColor3iEXT
- glSecondaryColor3ivEXT
- glSecondaryColor3sEXT
- glSecondaryColor3svEXT
- glSecondaryColor3ubEXT
- glSecondaryColor3ubvEXT
- glSecondaryColor3uiEXT
- glSecondaryColor3uivEXT
- glSecondaryColor3usEXT
- glSecondaryColor3usvEXT
- glSecondaryColorPointerEXT
- glMultiDrawArraysEXT
- glMultiDrawElementsEXT
- glFogCoordfEXT
- glFogCoordfvEXT
- glFogCoorddEXT
- glFogCoorddvEXT
- glFogCoordPointerEXT
- glBlendFuncSeparateEXT
- glWindowPos2dMESA
- glWindowPos2dvMESA
- glWindowPos2fMESA
- glWindowPos2fvMESA
- glWindowPos2iMESA
- glWindowPos2ivMESA
- glWindowPos2sMESA
- glWindowPos2svMESA
- glWindowPos3dMESA
- glWindowPos3dvMESA
- glWindowPos3fMESA
- glWindowPos3fvMESA
- glWindowPos3iMESA
- glWindowPos3ivMESA
- glWindowPos3sMESA
- glWindowPos3svMESA
- glWindowPos4dMESA
- glWindowPos4dvMESA
- glWindowPos4fMESA
- glWindowPos4fvMESA
- glWindowPos4iMESA
- glWindowPos4ivMESA
- glWindowPos4sMESA
- glWindowPos4svMESA
- glWindowPos2dARB
- glWindowPos2fARB
- glWindowPos2iARB
- glWindowPos2sARB
- glWindowPos2dvARB
- glWindowPos2fvARB
- glWindowPos2ivARB
- glWindowPos2svARB
- glWindowPos3dARB
- glWindowPos3fARB
- glWindowPos3iARB
- glWindowPos3sARB
- glWindowPos3dvARB
- glWindowPos3fvARB
- glWindowPos3ivARB
- glWindowPos3svARB
- glAreProgramsResidentNV
- glBindProgramNV
- glDeleteProgramsNV
- glExecuteProgramNV
- glGenProgramsNV
- glGetProgramParameterdvNV
- glGetProgramParameterfvNV
- glGetProgramivNV
- glGetProgramStringNV
- glGetTrackMatrixivNV
- glGetVertexAttribdvNV
- glGetVertexAttribfvNV
- glGetVertexAttribivNV
- glGetVertexAttribPointervNV
- glIsProgramNV
- glLoadProgramNV
- glProgramParameter4dNV
- glProgramParameter4dvNV
- glProgramParameter4fNV
- glProgramParameter4fvNV
- glProgramParameters4dvNV
- glProgramParameters4fvNV
- glRequestResidentProgramsNV
- glTrackMatrixNV
- glVertexAttribPointerNV
- glVertexAttrib1dNV
- glVertexAttrib1dvNV
- glVertexAttrib1fNV
- glVertexAttrib1fvNV
- glVertexAttrib1sNV
- glVertexAttrib1svNV
- glVertexAttrib2dNV
- glVertexAttrib2dvNV
- glVertexAttrib2fNV
- glVertexAttrib2fvNV
- glVertexAttrib2sNV
- glVertexAttrib2svNV
- glVertexAttrib3dNV
- glVertexAttrib3dvNV
- glVertexAttrib3fNV
- glVertexAttrib3fvNV
- glVertexAttrib3sNV
- glVertexAttrib3svNV
- glVertexAttrib4dNV
- glVertexAttrib4dvNV
- glVertexAttrib4fNV
- glVertexAttrib4fvNV
- glVertexAttrib4sNV
- glVertexAttrib4svNV
- glVertexAttrib4ubNV
- glVertexAttrib4ubvNV
- glVertexAttribs1dvNV
- glVertexAttribs1fvNV
- glVertexAttribs1svNV
- glVertexAttribs2dvNV
- glVertexAttribs2fvNV
- glVertexAttribs2svNV
- glVertexAttribs3dvNV
- glVertexAttribs3fvNV
- glVertexAttribs3svNV
- glVertexAttribs4dvNV
- glVertexAttribs4fvNV
- glVertexAttribs4svNV
- glVertexAttribs4ubvNV
- glPointParameteriNV
- glPointParameterivNV
- glFogCoordf
- glFogCoordfv
- glFogCoordd
- glFogCoorddv
- glFogCoordPointer
- glMultiDrawArrays
- glMultiDrawElements
- glPointParameterf
- glPointParameterfv
- glPointParameteri
- glPointParameteriv
- glSecondaryColor3b
- glSecondaryColor3bv
- glSecondaryColor3d
- glSecondaryColor3dv
- glSecondaryColor3f
- glSecondaryColor3fv
- glSecondaryColor3i
- glSecondaryColor3iv
- glSecondaryColor3s
- glSecondaryColor3sv
- glSecondaryColor3ub
- glSecondaryColor3ubv
- glSecondaryColor3ui
- glSecondaryColor3uiv
- glSecondaryColor3us
- glSecondaryColor3usv
- glSecondaryColorPointer
- glWindowPos2d
- glWindowPos2dv
- glWindowPos2f
- glWindowPos2fv
- glWindowPos2i
- glWindowPos2iv
- glWindowPos2s
- glWindowPos2sv
- glWindowPos3d
- glWindowPos3dv
- glWindowPos3f
- glWindowPos3fv
- glWindowPos3i
- glWindowPos3iv
- glWindowPos3s
- glWindowPos3sv
- glVertexAttrib1sARB
- glVertexAttrib1fARB
- glVertexAttrib1dARB
- glVertexAttrib2sARB
- glVertexAttrib2fARB
- glVertexAttrib2dARB
- glVertexAttrib3sARB
- glVertexAttrib3fARB
- glVertexAttrib3dARB
- glVertexAttrib4sARB
- glVertexAttrib4fARB
- glVertexAttrib4dARB
- glVertexAttrib4NubARB
- glVertexAttrib1svARB
- glVertexAttrib1fvARB
- glVertexAttrib1dvARB
- glVertexAttrib2svARB
- glVertexAttrib2fvARB
- glVertexAttrib2dvARB
- glVertexAttrib3svARB
- glVertexAttrib3fvARB
- glVertexAttrib3dvARB
- glVertexAttrib4bvARB
- glVertexAttrib4svARB
- glVertexAttrib4ivARB
- glVertexAttrib4ubvARB
- glVertexAttrib4usvARB
- glVertexAttrib4uivARB
- glVertexAttrib4fvARB
- glVertexAttrib4dvARB
- glVertexAttrib4NbvARB
- glVertexAttrib4NsvARB
- glVertexAttrib4NivARB
- glVertexAttrib4NubvARB
- glVertexAttrib4NusvARB
- glVertexAttrib4NuivARB
- glVertexAttribPointerARB
- glEnableVertexAttribArrayARB
- glDisableVertexAttribArrayARB
- glProgramStringARB
- glBindProgramARB
- glDeleteProgramsARB
- glGenProgramsARB
- glIsProgramARB
- glProgramEnvParameter4dARB
- glProgramEnvParameter4dvARB
- glProgramEnvParameter4fARB
- glProgramEnvParameter4fvARB
- glProgramLocalParameter4dARB
- glProgramLocalParameter4dvARB
- glProgramLocalParameter4fARB
- glProgramLocalParameter4fvARB
- glGetProgramEnvParameterdvARB
- glGetProgramEnvParameterfvARB
- glGetProgramLocalParameterdvARB
- glGetProgramLocalParameterfvARB
- glGetProgramivARB
- glGetProgramStringARB
- glGetVertexAttribdvARB
- glGetVertexAttribfvARB
- glGetVertexAttribivARB
- glGetVertexAttribPointervARB
- glProgramNamedParameter4fNV
- glProgramNamedParameter4dNV
- glProgramNamedParameter4fvNV
- glProgramNamedParameter4dvNV
- glGetProgramNamedParameterfvNV
- glGetProgramNamedParameterdvNV
- glBindBufferARB
- glBufferDataARB
- glBufferSubDataARB
- glDeleteBuffersARB
- glGenBuffersARB
- glGetBufferParameterivARB
- glGetBufferPointervARB
- glGetBufferSubDataARB
- glIsBufferARB
- glMapBufferARB
- glUnmapBufferARB
- glGenQueriesARB
- glDeleteQueriesARB
- glIsQueryARB
- glBeginQueryARB
- glEndQueryARB
- glGetQueryivARB
- glGetQueryObjectivARB
- glGetQueryObjectuivARB
- glBindBuffer
- glBufferData
- glBufferSubData
- glDeleteBuffers
- glGenBuffers
- glGetBufferParameteriv
- glGetBufferPointerv
- glGetBufferSubData
- glIsBuffer
- glMapBuffer
- glUnmapBuffer
- glGenQueries
- glDeleteQueries
- glIsQuery
- glBeginQuery
- glEndQuery
- glGetQueryiv
- glGetQueryObjectiv
- glGetQueryObjectuiv
-;
-; WGL API
+ glViewport
wglChoosePixelFormat
wglCopyContext
wglCreateContext
@@ -837,4 +383,3 @@ EXPORTS
wglUseFontBitmapsW
wglUseFontOutlinesA
wglUseFontOutlinesW
- wglGetExtensionsStringARB
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 9b80600de..bf4fa3ea8 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -55,52 +55,6 @@ index_bytes(GLenum type, GLsizei count)
/**
- * Find the max index in the given element/index buffer
- */
-GLuint
-_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
- const void *indices,
- struct gl_buffer_object *elementBuf)
-{
- const GLubyte *map = NULL;
- GLuint max = 0;
- GLuint i;
-
- if (_mesa_is_bufferobj(elementBuf)) {
- /* elements are in a user-defined buffer object. need to map it */
- map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size,
- GL_MAP_READ_BIT, elementBuf,
- MAP_INTERNAL);
- /* Actual address is the sum of pointers */
- indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
- }
-
- if (type == GL_UNSIGNED_INT) {
- for (i = 0; i < count; i++)
- if (((GLuint *) indices)[i] > max)
- max = ((GLuint *) indices)[i];
- }
- else if (type == GL_UNSIGNED_SHORT) {
- for (i = 0; i < count; i++)
- if (((GLushort *) indices)[i] > max)
- max = ((GLushort *) indices)[i];
- }
- else {
- ASSERT(type == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++)
- if (((GLubyte *) indices)[i] > max)
- max = ((GLubyte *) indices)[i];
- }
-
- if (map) {
- ctx->Driver.UnmapBuffer(ctx, elementBuf, MAP_INTERNAL);
- }
-
- return max;
-}
-
-
-/**
* Check if OK to draw arrays/elements.
*/
static GLboolean
@@ -749,17 +703,17 @@ _mesa_validate_DrawTransformFeedback(struct gl_context *ctx,
return GL_FALSE;
}
- if (!obj->EndedAnytime) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*");
- return GL_FALSE;
- }
-
if (stream >= ctx->Const.MaxVertexStreams) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
return GL_FALSE;
}
+ if (!obj->EndedAnytime) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*");
+ return GL_FALSE;
+ }
+
if (numInstances <= 0) {
if (numInstances < 0)
_mesa_error(ctx, GL_INVALID_VALUE,
diff --git a/mesalib/src/mesa/main/api_validate.h b/mesalib/src/mesa/main/api_validate.h
index 8238df16c..0bb91c675 100644
--- a/mesalib/src/mesa/main/api_validate.h
+++ b/mesalib/src/mesa/main/api_validate.h
@@ -35,12 +35,6 @@ struct gl_context;
struct gl_transform_feedback_object;
-extern GLuint
-_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
- const void *indices,
- struct gl_buffer_object *elementBuf);
-
-
extern bool
_mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode);
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 5345339f6..4684615a8 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -1345,7 +1345,8 @@ _mesa_PopAttrib(void)
if (xform->DepthClamp != ctx->Transform.DepthClamp)
_mesa_set_enable(ctx, GL_DEPTH_CLAMP,
ctx->Transform.DepthClamp);
- _mesa_ClipControl(xform->ClipOrigin, xform->ClipDepthMode);
+ if (ctx->Extensions.ARB_clip_control)
+ _mesa_ClipControl(xform->ClipOrigin, xform->ClipDepthMode);
}
break;
case GL_TEXTURE_BIT:
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 25b9bfc4c..400c158a7 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -719,6 +719,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
/** GL_ARB_gpu_shader5 */
consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET;
consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET;
+
+ /** GL_KHR_context_flush_control */
+ consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
}
@@ -729,6 +732,8 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
static void
check_context_limits(struct gl_context *ctx)
{
+ (void) ctx;
+
/* check that we don't exceed the size of various bitfields */
assert(VARYING_SLOT_MAX <=
(8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten)));
@@ -1622,9 +1627,11 @@ _mesa_make_current( struct gl_context *newCtx,
}
if (curCtx &&
- (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
+ (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
/* make sure this context is valid for flushing */
- curCtx != newCtx)
+ curCtx != newCtx &&
+ curCtx->Const.ContextReleaseBehavior ==
+ GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
_mesa_flush(curCtx);
/* We used to call _glapi_check_multithread() here. Now do it in drivers */
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index 25171f0ee..7d622bb16 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -676,22 +676,41 @@ debug_pop_group(struct gl_debug_state *debug)
/**
- * Return debug state for the context. The debug state will be allocated
- * and initialized upon the first call.
+ * Lock and return debug state for the context. The debug state will be
+ * allocated and initialized upon the first call. When NULL is returned, the
+ * debug state is not locked.
*/
static struct gl_debug_state *
-_mesa_get_debug_state(struct gl_context *ctx)
+_mesa_lock_debug_state(struct gl_context *ctx)
{
+ mtx_lock(&ctx->DebugMutex);
+
if (!ctx->Debug) {
ctx->Debug = debug_create();
if (!ctx->Debug) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
+ GET_CURRENT_CONTEXT(cur);
+ mtx_unlock(&ctx->DebugMutex);
+
+ /*
+ * This function may be called from other threads. When that is the
+ * case, we cannot record this OOM error.
+ */
+ if (ctx == cur)
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
+
+ return NULL;
}
}
return ctx->Debug;
}
+static void
+_mesa_unlock_debug_state(struct gl_context *ctx)
+{
+ mtx_unlock(&ctx->DebugMutex);
+}
+
/**
* Set the integer debug state specified by \p pname. This can be called from
* _mesa_set_enable for example.
@@ -699,7 +718,7 @@ _mesa_get_debug_state(struct gl_context *ctx)
bool
_mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val)
{
- struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
+ struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
if (!debug)
return false;
@@ -716,6 +735,8 @@ _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val)
break;
}
+ _mesa_unlock_debug_state(ctx);
+
return true;
}
@@ -729,9 +750,12 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname)
struct gl_debug_state *debug;
GLint val;
+ mtx_lock(&ctx->DebugMutex);
debug = ctx->Debug;
- if (!debug)
+ if (!debug) {
+ mtx_unlock(&ctx->DebugMutex);
return 0;
+ }
switch (pname) {
case GL_DEBUG_OUTPUT:
@@ -756,6 +780,8 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname)
break;
}
+ mtx_unlock(&ctx->DebugMutex);
+
return val;
}
@@ -769,9 +795,12 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname)
struct gl_debug_state *debug;
void *val;
+ mtx_lock(&ctx->DebugMutex);
debug = ctx->Debug;
- if (!debug)
+ if (!debug) {
+ mtx_unlock(&ctx->DebugMutex);
return NULL;
+ }
switch (pname) {
case GL_DEBUG_CALLBACK_FUNCTION_ARB:
@@ -786,9 +815,49 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname)
break;
}
+ mtx_unlock(&ctx->DebugMutex);
+
return val;
}
+/**
+ * Insert a debug message. The mutex is assumed to be locked, and will be
+ * unlocked by this call.
+ */
+static void
+log_msg_locked_and_unlock(struct gl_context *ctx,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type, GLuint id,
+ enum mesa_debug_severity severity,
+ GLint len, const char *buf)
+{
+ struct gl_debug_state *debug = ctx->Debug;
+
+ if (!debug_is_message_enabled(debug, source, type, id, severity)) {
+ _mesa_unlock_debug_state(ctx);
+ return;
+ }
+
+ if (ctx->Debug->Callback) {
+ GLenum gl_source = debug_source_enums[source];
+ GLenum gl_type = debug_type_enums[type];
+ GLenum gl_severity = debug_severity_enums[severity];
+ GLDEBUGPROC callback = ctx->Debug->Callback;
+ const void *data = ctx->Debug->CallbackData;
+
+ /*
+ * When ctx->Debug->SyncOutput is GL_FALSE, the client is prepared for
+ * unsynchronous calls. When it is GL_TRUE, we will not spawn threads.
+ * In either case, we can call the callback unlocked.
+ */
+ _mesa_unlock_debug_state(ctx);
+ callback(gl_source, gl_type, id, gl_severity, len, buf, data);
+ }
+ else {
+ debug_log_message(ctx->Debug, source, type, id, severity, len, buf);
+ _mesa_unlock_debug_state(ctx);
+ }
+}
/**
* Log a client or driver debug message.
@@ -798,24 +867,12 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source,
enum mesa_debug_type type, GLuint id,
enum mesa_debug_severity severity, GLint len, const char *buf)
{
- struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
+ struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
if (!debug)
return;
- if (!debug_is_message_enabled(debug, source, type, id, severity))
- return;
-
- if (debug->Callback) {
- GLenum gl_type = debug_type_enums[type];
- GLenum gl_severity = debug_severity_enums[severity];
-
- debug->Callback(debug_source_enums[source], gl_type, id, gl_severity,
- len, buf, debug->CallbackData);
- return;
- }
-
- debug_log_message(debug, source, type, id, severity, len, buf);
+ log_msg_locked_and_unlock(ctx, source, type, id, severity, len, buf);
}
@@ -956,7 +1013,7 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
return 0;
}
- debug = _mesa_get_debug_state(ctx);
+ debug = _mesa_lock_debug_state(ctx);
if (!debug)
return 0;
@@ -991,6 +1048,8 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
debug_delete_messages(debug, 1);
}
+ _mesa_unlock_debug_state(ctx);
+
return ret;
}
@@ -1027,7 +1086,7 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
return;
}
- debug = _mesa_get_debug_state(ctx);
+ debug = _mesa_lock_debug_state(ctx);
if (!debug)
return;
@@ -1039,6 +1098,8 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
else {
debug_set_message_enable_all(debug, source, type, severity, enabled);
}
+
+ _mesa_unlock_debug_state(ctx);
}
@@ -1046,10 +1107,11 @@ void GLAPIENTRY
_mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
+ struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
if (debug) {
debug->Callback = callback;
debug->CallbackData = userParam;
+ _mesa_unlock_debug_state(ctx);
}
}
@@ -1059,18 +1121,10 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
const GLchar *message)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
const char *callerstr = "glPushDebugGroup";
+ struct gl_debug_state *debug;
struct gl_debug_message *emptySlot;
- if (!debug)
- return;
-
- if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) {
- _mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr);
- return;
- }
-
switch(source) {
case GL_DEBUG_SOURCE_APPLICATION:
case GL_DEBUG_SOURCE_THIRD_PARTY:
@@ -1086,10 +1140,15 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
if (!validate_length(ctx, callerstr, length))
return; /* GL_INVALID_VALUE */
- log_msg(ctx, gl_enum_to_debug_source(source),
- MESA_DEBUG_TYPE_PUSH_GROUP, id,
- MESA_DEBUG_SEVERITY_NOTIFICATION, length,
- message);
+ debug = _mesa_lock_debug_state(ctx);
+ if (!debug)
+ return;
+
+ if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) {
+ _mesa_unlock_debug_state(ctx);
+ _mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr);
+ return;
+ }
/* pop reuses the message details from push so we store this */
emptySlot = debug_get_group_message(debug);
@@ -1101,6 +1160,12 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
length, message);
debug_push_group(debug);
+
+ log_msg_locked_and_unlock(ctx,
+ gl_enum_to_debug_source(source),
+ MESA_DEBUG_TYPE_PUSH_GROUP, id,
+ MESA_DEBUG_SEVERITY_NOTIFICATION, length,
+ message);
}
@@ -1108,35 +1173,43 @@ void GLAPIENTRY
_mesa_PopDebugGroup(void)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
const char *callerstr = "glPopDebugGroup";
- struct gl_debug_message *gdmessage;
+ struct gl_debug_state *debug;
+ struct gl_debug_message *gdmessage, msg;
+ debug = _mesa_lock_debug_state(ctx);
if (!debug)
return;
if (debug->GroupStackDepth <= 0) {
+ _mesa_unlock_debug_state(ctx);
_mesa_error(ctx, GL_STACK_UNDERFLOW, "%s", callerstr);
return;
}
debug_pop_group(debug);
+ /* make a shallow copy */
gdmessage = debug_get_group_message(debug);
- log_msg(ctx, gdmessage->source,
- gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP),
- gdmessage->id,
- gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
- gdmessage->length, gdmessage->message);
-
- debug_message_clear(gdmessage);
+ msg = *gdmessage;
+ gdmessage->message = NULL;
+ gdmessage->length = 0;
+
+ log_msg_locked_and_unlock(ctx,
+ msg.source,
+ gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP),
+ msg.id,
+ gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
+ msg.length, msg.message);
+
+ debug_message_clear(&msg);
}
void
_mesa_init_errors(struct gl_context *ctx)
{
- /* no-op */
+ mtx_init(&ctx->DebugMutex, mtx_plain);
}
@@ -1148,6 +1221,8 @@ _mesa_free_errors_data(struct gl_context *ctx)
/* set to NULL just in case it is used before context is completely gone. */
ctx->Debug = NULL;
}
+
+ mtx_destroy(&ctx->DebugMutex);
}
@@ -1362,6 +1437,8 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
debug_get_id(&error_msg_id);
do_output = should_output(ctx, error, fmtString);
+
+ mtx_lock(&ctx->DebugMutex);
if (ctx->Debug) {
do_log = debug_is_message_enabled(ctx->Debug,
MESA_DEBUG_SOURCE_API,
@@ -1372,6 +1449,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
else {
do_log = GL_FALSE;
}
+ mtx_unlock(&ctx->DebugMutex);
if (do_output || do_log) {
char s[MAX_DEBUG_MESSAGE_LENGTH], s2[MAX_DEBUG_MESSAGE_LENGTH];
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 15d66a744..0df04c2e6 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -320,6 +320,7 @@ static const struct extension extension_table[] = {
/* KHR extensions */
{ "GL_KHR_debug", o(dummy_true), GL, 2012 },
+ { "GL_KHR_context_flush_control", o(dummy_true), GL | ES2, 2014 },
/* Vendor extensions */
{ "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL, 1999 },
diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py
index aa9f282d8..09a61acc1 100644
--- a/mesalib/src/mesa/main/get_hash_params.py
+++ b/mesalib/src/mesa/main/get_hash_params.py
@@ -318,6 +318,9 @@ descriptor=[
[ "PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_NAME_LENGTH), extra_INTEL_performance_query" ],
[ "PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_DESC_LENGTH), extra_INTEL_performance_query" ],
[ "PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", "CONST(PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS), extra_INTEL_performance_query" ],
+
+# GL_KHR_context_flush_control
+ [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM(Const.ContextReleaseBehavior), NO_EXTRA" ],
]},
# GLES3 is not a typo.
@@ -624,7 +627,7 @@ descriptor=[
# == GL_CURRENT_MATRIX_NV
[ "CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
# == GL_CURRENT_MATRIX_NV
- [ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
+ [ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX_T, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
# == GL_PROGRAM_ERROR_POSITION_NV
[ "PROGRAM_ERROR_POSITION_ARB", "CONTEXT_INT(Program.ErrorPos), extra_ARB_vertex_program_ARB_fragment_program" ],
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index b8c754815..4f5a2d11f 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -499,25 +499,6 @@ _mesa_strdup( const char *s )
}
}
-/** Wrapper around strtof() */
-float
-_mesa_strtof( const char *s, char **end )
-{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \
- !defined(__NetBSD__)
- static locale_t loc = NULL;
- if (!loc) {
- loc = newlocale(LC_CTYPE_MASK, "C", NULL);
- }
- return strtof_l(s, end, loc);
-#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
- return strtof(s, end);
-#else
- return (float)strtod(s, end);
-#endif
-}
-
/** Compute simple checksum/hash for a string */
unsigned int
_mesa_str_checksum(const char *str)
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 725416d06..e984cfbea 100755
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -539,9 +539,6 @@ _mesa_half_is_negative(GLhalfARB h)
extern char *
_mesa_strdup( const char *s );
-extern float
-_mesa_strtof( const char *s, char **end );
-
extern unsigned int
_mesa_str_checksum(const char *str);
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index e1f1f1dde..7389baa1d 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2843,6 +2843,7 @@ struct gl_shader_program
/* post-link info: */
unsigned NumUserUniformStorage;
+ unsigned NumHiddenUniforms;
struct gl_uniform_storage *UniformStorage;
/**
@@ -3680,6 +3681,9 @@ struct gl_constants
GLboolean FakeSWMSAA;
+ /** GL_KHR_context_flush_control */
+ GLenum ContextReleaseBehavior;
+
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
};
@@ -4390,6 +4394,7 @@ struct gl_context
GLuint ErrorDebugCount;
/* GL_ARB_debug_output/GL_KHR_debug */
+ mtx_t DebugMutex;
struct gl_debug_state *Debug;
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 2be9092c1..66578204f 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -565,13 +565,15 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
*params = _mesa_longest_attribute_name_length(shProg);
return;
case GL_ACTIVE_UNIFORMS:
- *params = shProg->NumUserUniformStorage;
+ *params = shProg->NumUserUniformStorage - shProg->NumHiddenUniforms;
return;
case GL_ACTIVE_UNIFORM_MAX_LENGTH: {
unsigned i;
GLint max_len = 0;
+ const unsigned num_uniforms =
+ shProg->NumUserUniformStorage - shProg->NumHiddenUniforms;
- for (i = 0; i < shProg->NumUserUniformStorage; i++) {
+ for (i = 0; i < num_uniforms; i++) {
/* Add one for the terminating NUL character for a non-array, and
* 4 for the "[0]" and the NUL for an array.
*/
diff --git a/mesalib/src/mesa/main/sse_minmax.c b/mesalib/src/mesa/main/sse_minmax.c
new file mode 100644
index 000000000..222ac1454
--- /dev/null
+++ b/mesalib/src/mesa/main/sse_minmax.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2014 Timothy Arceri
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Author:
+ * Timothy Arceri <t_arceri@yahoo.com.au>
+ *
+ */
+
+#ifdef __SSE4_1__
+#include "main/sse_minmax.h"
+#include <smmintrin.h>
+#include <stdint.h>
+
+void
+_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
+ unsigned *max_index, const unsigned count)
+{
+ unsigned max_ui = 0;
+ unsigned min_ui = ~0U;
+ unsigned i = 0;
+ unsigned aligned_count = count;
+
+ /* handle the first few values without SSE until the pointer is aligned */
+ while (((uintptr_t)ui_indices & 15) && aligned_count) {
+ if (*ui_indices > max_ui)
+ max_ui = *ui_indices;
+ if (*ui_indices < min_ui)
+ min_ui = *ui_indices;
+
+ aligned_count--;
+ ui_indices++;
+ }
+
+ /* TODO: The actual threshold for SSE begin useful may be higher than 8.
+ * Some careful microbenchmarks and measurement are required to
+ * find the actual tipping point.
+ */
+ if (aligned_count >= 8) {
+ unsigned max_arr[4] __attribute__ ((aligned (16)));
+ unsigned min_arr[4] __attribute__ ((aligned (16)));
+ unsigned vec_count;
+ __m128i max_ui4 = _mm_setzero_si128();
+ __m128i min_ui4 = _mm_set1_epi32(~0U);
+ __m128i ui_indices4;
+ __m128i *ui_indices_ptr;
+
+ vec_count = aligned_count & ~0x3;
+ ui_indices_ptr = (__m128i *)ui_indices;
+ for (i = 0; i < vec_count / 4; i++) {
+ ui_indices4 = _mm_load_si128(&ui_indices_ptr[i]);
+ max_ui4 = _mm_max_epu32(ui_indices4, max_ui4);
+ min_ui4 = _mm_min_epu32(ui_indices4, min_ui4);
+ }
+
+ _mm_store_si128((__m128i *)max_arr, max_ui4);
+ _mm_store_si128((__m128i *)min_arr, min_ui4);
+
+ for (i = 0; i < 4; i++) {
+ if (max_arr[i] > max_ui)
+ max_ui = max_arr[i];
+ if (min_arr[i] < min_ui)
+ min_ui = min_arr[i];
+ }
+ i = vec_count;
+ }
+
+ for (; i < aligned_count; i++) {
+ if (ui_indices[i] > max_ui)
+ max_ui = ui_indices[i];
+ if (ui_indices[i] < min_ui)
+ min_ui = ui_indices[i];
+ }
+
+ *min_index = min_ui;
+ *max_index = max_ui;
+}
+
+#endif
diff --git a/mesalib/src/mesa/main/sse_minmax.h b/mesalib/src/mesa/main/sse_minmax.h
new file mode 100644
index 000000000..953c4e9eb
--- /dev/null
+++ b/mesalib/src/mesa/main/sse_minmax.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2014 Timothy Arceri
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Author:
+ * Timothy Arceri <t_arceri@yahoo.com.au>
+ *
+ */
+
+void
+_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
+ unsigned *max_index, const unsigned count);
diff --git a/mesalib/src/mesa/main/streaming-load-memcpy.c b/mesalib/src/mesa/main/streaming-load-memcpy.c
index 8427149c5..d7147afdc 100644
--- a/mesalib/src/mesa/main/streaming-load-memcpy.c
+++ b/mesalib/src/mesa/main/streaming-load-memcpy.c
@@ -26,7 +26,6 @@
*
*/
-#ifdef __SSE4_1__
#include "main/macros.h"
#include "main/streaming-load-memcpy.h"
#include <smmintrin.h>
@@ -84,5 +83,3 @@ _mesa_streaming_load_memcpy(void *restrict dst, void *restrict src, size_t len)
memcpy(d, s, len);
}
}
-
-#endif
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 832e66128..ec16af9d2 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -155,12 +155,14 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
case GL_ALPHA4:
case GL_ALPHA8:
RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM);
break;
case GL_ALPHA12:
case GL_ALPHA16:
RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM16);
RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM);
break;
/* Luminance formats */
@@ -224,6 +226,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
case GL_COMPRESSED_ALPHA_ARB:
RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM);
break;
case GL_COMPRESSED_LUMINANCE_ARB:
RETURN_IF_SUPPORTED(MESA_FORMAT_L_UNORM8);
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index f913e42d3..f858cef50 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -1667,8 +1667,10 @@ texstore_rgba_integer(TEXSTORE_PARAMS)
assert(is_array && !normalized);
- if (!is_array)
+ if (!is_array) {
+ free(tmp_row);
return GL_FALSE;
+ }
invert_swizzle(dst2rgba, rgba2dst);
compute_component_mapping(GL_RGBA, baseInternalFormat, base2rgba);
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index fcb14c4e2..32870d0c4 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -176,46 +176,13 @@ validate_uniform_parameters(struct gl_context *ctx,
struct gl_shader_program *shProg,
GLint location, GLsizei count,
unsigned *array_index,
- const char *caller,
- bool negative_one_is_not_valid)
+ const char *caller)
{
- if (!shProg || !shProg->LinkStatus) {
+ if (shProg == NULL) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", caller);
return NULL;
}
- if (location == -1) {
- /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1
- * spec says:
- *
- * "The error INVALID_OPERATION is generated if program has not been
- * linked successfully, or if location is not a valid location for
- * program."
- *
- * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec
- * says:
- *
- * "If the value of location is -1, the Uniform* commands will
- * silently ignore the data passed in, and the current uniform
- * values will not be changed."
- *
- * Allowing -1 for the location parameter of glUniform allows
- * applications to avoid error paths in the case that, for example, some
- * uniform variable is removed by the compiler / linker after
- * optimization. In this case, the new value of the uniform is dropped
- * on the floor. For the case of glGetUniform, there is nothing
- * sensible to do for a location of -1.
- *
- * The negative_one_is_not_valid flag selects between the two behaviors.
- */
- if (negative_one_is_not_valid) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
- caller, location);
- }
-
- return NULL;
- }
-
/* From page 12 (page 26 of the PDF) of the OpenGL 2.1 spec:
*
* "If a negative number is provided where an argument of type sizei or
@@ -226,10 +193,26 @@ validate_uniform_parameters(struct gl_context *ctx,
return NULL;
}
- /* Check that the given location is in bounds of uniform remap table. */
- if (location >= (GLint) shProg->NumUniformRemapTable) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
- caller, location);
+ /* Check that the given location is in bounds of uniform remap table.
+ * Unlinked programs will have NumUniformRemapTable == 0, so we can take
+ * the shProg->LinkStatus check out of the main path.
+ */
+ if (unlikely(location >= (GLint) shProg->NumUniformRemapTable)) {
+ if (!shProg->LinkStatus)
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
+ caller);
+ else
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
+ caller, location);
+
+ return NULL;
+ }
+
+ if (location == -1) {
+ if (!shProg->LinkStatus)
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
+ caller);
+
return NULL;
}
@@ -269,27 +252,30 @@ validate_uniform_parameters(struct gl_context *ctx,
struct gl_uniform_storage *const uni = shProg->UniformRemapTable[location];
- if (uni->array_elements == 0 && count > 1) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(count > 1 for non-array, location=%d)",
- caller, location);
- return NULL;
- }
+ if (uni->array_elements == 0) {
+ if (count > 1) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(count > 1 for non-array, location=%d)",
+ caller, location);
+ return NULL;
+ }
- /* The array index specified by the uniform location is just the uniform
- * location minus the base location of of the uniform.
- */
- *array_index = location - uni->remap_location;
+ assert((location - uni->remap_location) == 0);
+ *array_index = 0;
+ } else {
+ /* The array index specified by the uniform location is just the uniform
+ * location minus the base location of of the uniform.
+ */
+ *array_index = location - uni->remap_location;
- /* If the uniform is an array, check that array_index is in bounds.
- * If not an array, check that array_index is zero.
- * array_index is unsigned so no need to check for less than zero.
- */
- const unsigned limit = MAX2(uni->array_elements, 1);
- if (*array_index >= limit) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
- caller, location);
- return NULL;
+ /* If the uniform is an array, check that array_index is in bounds.
+ * array_index is unsigned so no need to check for less than zero.
+ */
+ if (*array_index >= uni->array_elements) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
+ caller, location);
+ return NULL;
+ }
}
return uni;
}
@@ -308,9 +294,39 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
struct gl_uniform_storage *const uni =
validate_uniform_parameters(ctx, shProg, location, 1,
- &offset, "glGetUniform", true);
- if (uni == NULL)
+ &offset, "glGetUniform");
+ if (uni == NULL) {
+ /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1
+ * spec says:
+ *
+ * "The error INVALID_OPERATION is generated if program has not been
+ * linked successfully, or if location is not a valid location for
+ * program."
+ *
+ * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec
+ * says:
+ *
+ * "If the value of location is -1, the Uniform* commands will
+ * silently ignore the data passed in, and the current uniform
+ * values will not be changed."
+ *
+ * Allowing -1 for the location parameter of glUniform allows
+ * applications to avoid error paths in the case that, for example, some
+ * uniform variable is removed by the compiler / linker after
+ * optimization. In this case, the new value of the uniform is dropped
+ * on the floor. For the case of glGetUniform, there is nothing
+ * sensible to do for a location of -1.
+ *
+ * If the location was -1, validate_unfirom_parameters will return NULL
+ * without raising an error. Raise the error here.
+ */
+ if (location == -1) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniform(location=%d)",
+ location);
+ }
+
return;
+ }
{
unsigned elements = (uni->type->is_sampler())
@@ -342,8 +358,7 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
*/
if (returnType == uni->type->base_type
|| ((returnType == GLSL_TYPE_INT
- || returnType == GLSL_TYPE_UINT
- || returnType == GLSL_TYPE_SAMPLER)
+ || returnType == GLSL_TYPE_UINT)
&&
(uni->type->base_type == GLSL_TYPE_INT
|| uni->type->base_type == GLSL_TYPE_UINT
@@ -583,93 +598,22 @@ _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,
extern "C" void
_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
GLint location, GLsizei count,
- const GLvoid *values, GLenum type)
+ const GLvoid *values,
+ enum glsl_base_type basicType,
+ unsigned src_components)
{
unsigned offset;
- unsigned components;
- unsigned src_components;
- enum glsl_base_type basicType;
struct gl_uniform_storage *const uni =
validate_uniform_parameters(ctx, shProg, location, count,
- &offset, "glUniform", false);
+ &offset, "glUniform");
if (uni == NULL)
return;
/* Verify that the types are compatible.
*/
- switch (type) {
- case GL_FLOAT:
- basicType = GLSL_TYPE_FLOAT;
- src_components = 1;
- break;
- case GL_FLOAT_VEC2:
- basicType = GLSL_TYPE_FLOAT;
- src_components = 2;
- break;
- case GL_FLOAT_VEC3:
- basicType = GLSL_TYPE_FLOAT;
- src_components = 3;
- break;
- case GL_FLOAT_VEC4:
- basicType = GLSL_TYPE_FLOAT;
- src_components = 4;
- break;
- case GL_UNSIGNED_INT:
- basicType = GLSL_TYPE_UINT;
- src_components = 1;
- break;
- case GL_UNSIGNED_INT_VEC2:
- basicType = GLSL_TYPE_UINT;
- src_components = 2;
- break;
- case GL_UNSIGNED_INT_VEC3:
- basicType = GLSL_TYPE_UINT;
- src_components = 3;
- break;
- case GL_UNSIGNED_INT_VEC4:
- basicType = GLSL_TYPE_UINT;
- src_components = 4;
- break;
- case GL_INT:
- basicType = GLSL_TYPE_INT;
- src_components = 1;
- break;
- case GL_INT_VEC2:
- basicType = GLSL_TYPE_INT;
- src_components = 2;
- break;
- case GL_INT_VEC3:
- basicType = GLSL_TYPE_INT;
- src_components = 3;
- break;
- case GL_INT_VEC4:
- basicType = GLSL_TYPE_INT;
- src_components = 4;
- break;
- case GL_BOOL:
- case GL_BOOL_VEC2:
- case GL_BOOL_VEC3:
- case GL_BOOL_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT2x3:
- case GL_FLOAT_MAT2x4:
- case GL_FLOAT_MAT3x2:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT3x4:
- case GL_FLOAT_MAT4x2:
- case GL_FLOAT_MAT4x3:
- case GL_FLOAT_MAT4:
- default:
- _mesa_problem(NULL, "Invalid type in %s", __func__);
- return;
- }
-
- if (uni->type->is_sampler()) {
- components = 1;
- } else {
- components = uni->type->vector_elements;
- }
+ const unsigned components = uni->type->is_sampler()
+ ? 1 : uni->type->vector_elements;
bool match;
switch (uni->type->base_type) {
@@ -690,7 +634,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
return;
}
- if (ctx->_Shader->Flags & GLSL_UNIFORMS) {
+ if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) {
log_uniform(values, basicType, components, 1, count,
false, shProg, location, uni);
}
@@ -713,9 +657,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
* GL_INVALID_VALUE error and ignore the command.
*/
if (uni->type->is_sampler()) {
- int i;
-
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
const unsigned texUnit = ((unsigned *) values)[i];
/* check that the sampler (tex unit index) is legal */
@@ -730,9 +672,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
}
if (uni->type->is_image()) {
- int i;
-
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
const int unit = ((GLint *) values)[i];
/* check that the image unit is legal */
@@ -772,9 +712,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
(const union gl_constant_value *) values;
union gl_constant_value *dst = &uni->storage[components * offset];
const unsigned elems = components * count;
- unsigned i;
- for (i = 0; i < elems; i++) {
+ for (unsigned i = 0; i < elems; i++) {
if (basicType == GLSL_TYPE_FLOAT) {
dst[i].i = src[i].f != 0.0f ? ctx->Const.UniformBooleanTrue : 0;
} else {
@@ -791,19 +730,16 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
* the changes through.
*/
if (uni->type->is_sampler()) {
- int i;
-
bool flushed = false;
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
+ for (int i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_shader *const sh = shProg->_LinkedShaders[i];
- int j;
/* If the shader stage doesn't use the sampler uniform, skip this.
*/
if (sh == NULL || !uni->sampler[i].active)
continue;
- for (j = 0; j < count; j++) {
+ for (int j = 0; j < count; j++) {
sh->SamplerUnits[uni->sampler[i].index + offset + j] =
((unsigned *) values)[j];
}
@@ -845,13 +781,11 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
* uniforms to image units present in the shader data structure.
*/
if (uni->type->is_image()) {
- int i, j;
-
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
+ for (int i = 0; i < MESA_SHADER_STAGES; i++) {
if (uni->image[i].active) {
struct gl_shader *sh = shProg->_LinkedShaders[i];
- for (j = 0; j < count; j++)
+ for (int j = 0; j < count; j++)
sh->ImageUnits[uni->image[i].index + offset + j] =
((GLint *) values)[j];
}
@@ -878,7 +812,7 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
struct gl_uniform_storage *const uni =
validate_uniform_parameters(ctx, shProg, location, count,
- &offset, "glUniformMatrix", false);
+ &offset, "glUniformMatrix");
if (uni == NULL)
return;
@@ -902,17 +836,17 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
}
/* GL_INVALID_VALUE is generated if `transpose' is not GL_FALSE.
- * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml */
- if (ctx->API == API_OPENGLES
- || (ctx->API == API_OPENGLES2 && ctx->Version < 30)) {
- if (transpose) {
+ * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml
+ */
+ if (transpose) {
+ if (ctx->API == API_OPENGLES2 && ctx->Version < 30) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glUniformMatrix(matrix transpose is not GL_FALSE)");
return;
}
}
- if (ctx->_Shader->Flags & GLSL_UNIFORMS) {
+ if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) {
log_uniform(values, GLSL_TYPE_FLOAT, components, vectors, count,
bool(transpose), shProg, location, uni);
}
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index c30710772..d2d70e7f7 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -151,7 +151,7 @@ void GLAPIENTRY
_mesa_Uniform1f(GLint location, GLfloat v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_FLOAT);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_FLOAT, 1);
}
void GLAPIENTRY
@@ -161,7 +161,7 @@ _mesa_Uniform2f(GLint location, GLfloat v0, GLfloat v1)
GLfloat v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 2);
}
void GLAPIENTRY
@@ -172,7 +172,7 @@ _mesa_Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 3);
}
void GLAPIENTRY
@@ -185,14 +185,14 @@ _mesa_Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 4);
}
void GLAPIENTRY
_mesa_Uniform1i(GLint location, GLint v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_INT);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_INT, 1);
}
void GLAPIENTRY
@@ -202,7 +202,7 @@ _mesa_Uniform2i(GLint location, GLint v0, GLint v1)
GLint v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC2);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 2);
}
void GLAPIENTRY
@@ -213,7 +213,7 @@ _mesa_Uniform3i(GLint location, GLint v0, GLint v1, GLint v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC3);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 3);
}
void GLAPIENTRY
@@ -225,63 +225,63 @@ _mesa_Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC4);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 4);
}
void GLAPIENTRY
_mesa_Uniform1fv(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 1);
}
void GLAPIENTRY
_mesa_Uniform2fv(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 2);
}
void GLAPIENTRY
_mesa_Uniform3fv(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 3);
}
void GLAPIENTRY
_mesa_Uniform4fv(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 4);
}
void GLAPIENTRY
_mesa_Uniform1iv(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 1);
}
void GLAPIENTRY
_mesa_Uniform2iv(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC2);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 2);
}
void GLAPIENTRY
_mesa_Uniform3iv(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC3);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 3);
}
void GLAPIENTRY
_mesa_Uniform4iv(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC4);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 4);
}
/** Same as above with direct state access **/
@@ -292,7 +292,7 @@ _mesa_ProgramUniform1f(GLuint program, GLint location, GLfloat v0)
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform1f");
- _mesa_uniform(ctx, shProg, location, 1, &v0, GL_FLOAT);
+ _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_FLOAT, 1);
}
void GLAPIENTRY
@@ -304,7 +304,7 @@ _mesa_ProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1)
v[0] = v0;
v[1] = v1;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2f");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 2);
}
void GLAPIENTRY
@@ -318,7 +318,7 @@ _mesa_ProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1,
v[1] = v1;
v[2] = v2;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3f");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 3);
}
void GLAPIENTRY
@@ -333,7 +333,7 @@ _mesa_ProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1,
v[2] = v2;
v[3] = v3;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4f");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 4);
}
void GLAPIENTRY
@@ -343,7 +343,7 @@ _mesa_ProgramUniform1i(GLuint program, GLint location, GLint v0)
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform1i");
- _mesa_uniform(ctx, shProg, location, 1, &v0, GL_INT);
+ _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_INT, 1);
}
void GLAPIENTRY
@@ -355,7 +355,7 @@ _mesa_ProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1)
v[0] = v0;
v[1] = v1;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2i");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC2);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 2);
}
void GLAPIENTRY
@@ -369,7 +369,7 @@ _mesa_ProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1,
v[1] = v1;
v[2] = v2;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3i");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC3);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 3);
}
void GLAPIENTRY
@@ -384,7 +384,7 @@ _mesa_ProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1,
v[2] = v2;
v[3] = v3;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4i");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC4);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 4);
}
void GLAPIENTRY
@@ -395,7 +395,7 @@ _mesa_ProgramUniform1fv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform1fv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 1);
}
void GLAPIENTRY
@@ -406,7 +406,7 @@ _mesa_ProgramUniform2fv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform2fv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 2);
}
void GLAPIENTRY
@@ -417,7 +417,7 @@ _mesa_ProgramUniform3fv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform3fv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 3);
}
void GLAPIENTRY
@@ -428,7 +428,7 @@ _mesa_ProgramUniform4fv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform4fv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 4);
}
void GLAPIENTRY
@@ -439,7 +439,7 @@ _mesa_ProgramUniform1iv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform1iv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_INT);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 1);
}
void GLAPIENTRY
@@ -450,7 +450,7 @@ _mesa_ProgramUniform2iv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform2iv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC2);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 2);
}
void GLAPIENTRY
@@ -461,7 +461,7 @@ _mesa_ProgramUniform3iv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform3iv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC3);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 3);
}
void GLAPIENTRY
@@ -472,7 +472,7 @@ _mesa_ProgramUniform4iv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform4iv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC4);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 4);
}
@@ -481,7 +481,7 @@ void GLAPIENTRY
_mesa_Uniform1ui(GLint location, GLuint v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_UINT, 1);
}
void GLAPIENTRY
@@ -491,7 +491,7 @@ _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1)
GLuint v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 2);
}
void GLAPIENTRY
@@ -502,7 +502,7 @@ _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 3);
}
void GLAPIENTRY
@@ -514,35 +514,35 @@ _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 4);
}
void GLAPIENTRY
_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 1);
}
void GLAPIENTRY
_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 2);
}
void GLAPIENTRY
_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 3);
}
void GLAPIENTRY
_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 4);
}
@@ -583,7 +583,7 @@ _mesa_ProgramUniform1ui(GLuint program, GLint location, GLuint v0)
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform1ui");
- _mesa_uniform(ctx, shProg, location, 1, &v0, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_UINT, 1);
}
void GLAPIENTRY
@@ -596,7 +596,7 @@ _mesa_ProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1)
v[1] = v1;
shProg = _mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform2ui");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 2);
}
void GLAPIENTRY
@@ -611,7 +611,7 @@ _mesa_ProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1,
v[2] = v2;
shProg = _mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform3ui");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 3);
}
void GLAPIENTRY
@@ -626,7 +626,7 @@ _mesa_ProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1,
v[2] = v2;
v[3] = v3;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4ui");
- _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 4);
}
void GLAPIENTRY
@@ -637,7 +637,7 @@ _mesa_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform1uiv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 1);
}
void GLAPIENTRY
@@ -648,7 +648,7 @@ _mesa_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform2uiv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 2);
}
void GLAPIENTRY
@@ -659,7 +659,7 @@ _mesa_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform3uiv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 3);
}
void GLAPIENTRY
@@ -670,7 +670,7 @@ _mesa_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program,
"glProgramUniform4uiv");
- _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 4);
}
@@ -1208,7 +1208,7 @@ _mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
struct gl_shader_program *shProg;
if (!ctx->Extensions.ARB_uniform_buffer_object) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformName");
return;
}
diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h
index 6575a52f4..0a9ee7de9 100644
--- a/mesalib/src/mesa/main/uniforms.h
+++ b/mesalib/src/mesa/main/uniforms.h
@@ -265,7 +265,9 @@ _mesa_get_uniform_location(struct gl_shader_program *shProg,
void
_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program,
GLint location, GLsizei count,
- const GLvoid *values, GLenum type);
+ const GLvoid *values,
+ enum glsl_base_type basicType,
+ unsigned src_components);
void
_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c
index d6a9e290a..0adce9c78 100644
--- a/mesalib/src/mesa/main/viewport.c
+++ b/mesalib/src/mesa/main/viewport.c
@@ -459,15 +459,14 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
ctx->Transform.ClipDepthMode == depth)
return;
- FLUSH_VERTICES(ctx, 0);
+ /* Affects transform state and the viewport transform */
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_VIEWPORT);
if (ctx->Transform.ClipOrigin != origin) {
ctx->Transform.ClipOrigin = origin;
/* Affects the winding order of the front face. */
ctx->NewState |= _NEW_POLYGON;
- /* Affects the y component of the viewport transform. */
- ctx->NewState |= _NEW_VIEWPORT;
if (ctx->Driver.FrontFace)
ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
@@ -476,9 +475,6 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
if (ctx->Transform.ClipDepthMode != depth) {
ctx->Transform.ClipDepthMode = depth;
- /* Affects the z part of the viewpoint transform. */
- ctx->NewState |= _NEW_VIEWPORT;
-
if (ctx->Driver.DepthRange)
ctx->Driver.DepthRange(ctx);
}
diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c
index fcc9ed518..650c40f2a 100644
--- a/mesalib/src/mesa/program/prog_execute.c
+++ b/mesalib/src/mesa/program/prog_execute.c
@@ -1119,77 +1119,6 @@ _mesa_execute_program(struct gl_context * ctx,
break;
case OPCODE_NOP:
break;
- case OPCODE_PK2H: /* pack two 16-bit floats in one 32-bit float */
- {
- GLfloat a[4];
- GLuint result[4];
- GLhalfNV hx, hy;
- fetch_vector4(&inst->SrcReg[0], machine, a);
- hx = _mesa_float_to_half(a[0]);
- hy = _mesa_float_to_half(a[1]);
- result[0] =
- result[1] =
- result[2] =
- result[3] = hx | (hy << 16);
- store_vector4ui(inst, machine, result);
- }
- break;
- case OPCODE_PK2US: /* pack two GLushorts into one 32-bit float */
- {
- GLfloat a[4];
- GLuint result[4], usx, usy;
- fetch_vector4(&inst->SrcReg[0], machine, a);
- a[0] = CLAMP(a[0], 0.0F, 1.0F);
- a[1] = CLAMP(a[1], 0.0F, 1.0F);
- usx = F_TO_I(a[0] * 65535.0F);
- usy = F_TO_I(a[1] * 65535.0F);
- result[0] =
- result[1] =
- result[2] =
- result[3] = usx | (usy << 16);
- store_vector4ui(inst, machine, result);
- }
- break;
- case OPCODE_PK4B: /* pack four GLbytes into one 32-bit float */
- {
- GLfloat a[4];
- GLuint result[4], ubx, uby, ubz, ubw;
- fetch_vector4(&inst->SrcReg[0], machine, a);
- a[0] = CLAMP(a[0], -128.0F / 127.0F, 1.0F);
- a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F);
- a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F);
- a[3] = CLAMP(a[3], -128.0F / 127.0F, 1.0F);
- ubx = F_TO_I(127.0F * a[0] + 128.0F);
- uby = F_TO_I(127.0F * a[1] + 128.0F);
- ubz = F_TO_I(127.0F * a[2] + 128.0F);
- ubw = F_TO_I(127.0F * a[3] + 128.0F);
- result[0] =
- result[1] =
- result[2] =
- result[3] = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
- store_vector4ui(inst, machine, result);
- }
- break;
- case OPCODE_PK4UB: /* pack four GLubytes into one 32-bit float */
- {
- GLfloat a[4];
- GLuint result[4], ubx, uby, ubz, ubw;
- fetch_vector4(&inst->SrcReg[0], machine, a);
- a[0] = CLAMP(a[0], 0.0F, 1.0F);
- a[1] = CLAMP(a[1], 0.0F, 1.0F);
- a[2] = CLAMP(a[2], 0.0F, 1.0F);
- a[3] = CLAMP(a[3], 0.0F, 1.0F);
- ubx = F_TO_I(255.0F * a[0]);
- uby = F_TO_I(255.0F * a[1]);
- ubz = F_TO_I(255.0F * a[2]);
- ubw = F_TO_I(255.0F * a[3]);
- result[0] =
- result[1] =
- result[2] =
- result[3] = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
- store_vector4ui(inst, machine, result);
- }
- break;
case OPCODE_POW:
{
GLfloat a[4], b[4], result[4];
@@ -1224,20 +1153,6 @@ _mesa_execute_program(struct gl_context * ctx,
pc = machine->CallStack[--machine->StackDepth] - 1;
}
break;
- case OPCODE_RFL: /* reflection vector */
- {
- GLfloat axis[4], dir[4], result[4], tmpX, tmpW;
- fetch_vector4(&inst->SrcReg[0], machine, axis);
- fetch_vector4(&inst->SrcReg[1], machine, dir);
- tmpW = DOT3(axis, axis);
- tmpX = (2.0F * DOT3(axis, dir)) / tmpW;
- result[0] = tmpX * axis[0] - dir[0];
- result[1] = tmpX * axis[1] - dir[1];
- result[2] = tmpX * axis[2] - dir[2];
- /* result[3] is never written! XXX enforce in parser! */
- store_vector4(inst, machine, result);
- }
- break;
case OPCODE_RSQ: /* 1 / sqrt() */
{
GLfloat a[4], result[4];
@@ -1279,12 +1194,6 @@ _mesa_execute_program(struct gl_context * ctx,
}
}
break;
- case OPCODE_SFL: /* set false, operands ignored */
- {
- static const GLfloat result[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
- store_vector4(inst, machine, result);
- }
- break;
case OPCODE_SGE: /* set on greater or equal */
{
GLfloat a[4], b[4], result[4];
@@ -1395,12 +1304,6 @@ _mesa_execute_program(struct gl_context * ctx,
store_vector4(inst, machine, result);
}
break;
- case OPCODE_STR: /* set true, operands ignored */
- {
- static const GLfloat result[4] = { 1.0F, 1.0F, 1.0F, 1.0F };
- store_vector4(inst, machine, result);
- }
- break;
case OPCODE_SUB:
{
GLfloat a[4], b[4], result[4];
@@ -1574,52 +1477,6 @@ _mesa_execute_program(struct gl_context * ctx,
store_vector4(inst, machine, result);
}
break;
- case OPCODE_UP2H: /* unpack two 16-bit floats */
- {
- const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
- GLfloat result[4];
- GLushort hx, hy;
- hx = raw & 0xffff;
- hy = raw >> 16;
- result[0] = result[2] = _mesa_half_to_float(hx);
- result[1] = result[3] = _mesa_half_to_float(hy);
- store_vector4(inst, machine, result);
- }
- break;
- case OPCODE_UP2US: /* unpack two GLushorts */
- {
- const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
- GLfloat result[4];
- GLushort usx, usy;
- usx = raw & 0xffff;
- usy = raw >> 16;
- result[0] = result[2] = usx * (1.0f / 65535.0f);
- result[1] = result[3] = usy * (1.0f / 65535.0f);
- store_vector4(inst, machine, result);
- }
- break;
- case OPCODE_UP4B: /* unpack four GLbytes */
- {
- const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
- GLfloat result[4];
- result[0] = (((raw >> 0) & 0xff) - 128) / 127.0F;
- result[1] = (((raw >> 8) & 0xff) - 128) / 127.0F;
- result[2] = (((raw >> 16) & 0xff) - 128) / 127.0F;
- result[3] = (((raw >> 24) & 0xff) - 128) / 127.0F;
- store_vector4(inst, machine, result);
- }
- break;
- case OPCODE_UP4UB: /* unpack four GLubytes */
- {
- const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
- GLfloat result[4];
- result[0] = ((raw >> 0) & 0xff) / 255.0F;
- result[1] = ((raw >> 8) & 0xff) / 255.0F;
- result[2] = ((raw >> 16) & 0xff) / 255.0F;
- result[3] = ((raw >> 24) & 0xff) / 255.0F;
- store_vector4(inst, machine, result);
- }
- break;
case OPCODE_XPD: /* cross product */
{
GLfloat a[4], b[4], result[4];
@@ -1637,19 +1494,6 @@ _mesa_execute_program(struct gl_context * ctx,
}
}
break;
- case OPCODE_X2D: /* 2-D matrix transform */
- {
- GLfloat a[4], b[4], c[4], result[4];
- fetch_vector4(&inst->SrcReg[0], machine, a);
- fetch_vector4(&inst->SrcReg[1], machine, b);
- fetch_vector4(&inst->SrcReg[2], machine, c);
- result[0] = a[0] + b[0] * c[0] + b[1] * c[1];
- result[1] = a[1] + b[0] * c[2] + b[1] * c[3];
- result[2] = a[2] + b[0] * c[0] + b[1] * c[1];
- result[3] = a[3] + b[0] * c[2] + b[1] * c[3];
- store_vector4(inst, machine, result);
- }
- break;
case OPCODE_END:
return GL_TRUE;
default:
diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c
index e2eadc36c..976024e3c 100644
--- a/mesalib/src/mesa/program/prog_instruction.c
+++ b/mesalib/src/mesa/program/prog_instruction.c
@@ -191,18 +191,12 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
{ OPCODE_NOISE2, "NOISE2", 1, 1 },
{ OPCODE_NOISE3, "NOISE3", 1, 1 },
{ OPCODE_NOISE4, "NOISE4", 1, 1 },
- { OPCODE_PK2H, "PK2H", 1, 1 },
- { OPCODE_PK2US, "PK2US", 1, 1 },
- { OPCODE_PK4B, "PK4B", 1, 1 },
- { OPCODE_PK4UB, "PK4UB", 1, 1 },
{ OPCODE_POW, "POW", 2, 1 },
{ OPCODE_RCP, "RCP", 1, 1 },
{ OPCODE_RET, "RET", 0, 0 },
- { OPCODE_RFL, "RFL", 1, 1 },
{ OPCODE_RSQ, "RSQ", 1, 1 },
{ OPCODE_SCS, "SCS", 1, 1 },
{ OPCODE_SEQ, "SEQ", 2, 1 },
- { OPCODE_SFL, "SFL", 0, 1 },
{ OPCODE_SGE, "SGE", 2, 1 },
{ OPCODE_SGT, "SGT", 2, 1 },
{ OPCODE_SIN, "SIN", 1, 1 },
@@ -210,7 +204,6 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
{ OPCODE_SLT, "SLT", 2, 1 },
{ OPCODE_SNE, "SNE", 2, 1 },
{ OPCODE_SSG, "SSG", 1, 1 },
- { OPCODE_STR, "STR", 0, 1 },
{ OPCODE_SUB, "SUB", 2, 1 },
{ OPCODE_SWZ, "SWZ", 1, 1 },
{ OPCODE_TEX, "TEX", 1, 1 },
@@ -220,11 +213,6 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
{ OPCODE_TXP, "TXP", 1, 1 },
{ OPCODE_TXP_NV, "TXP_NV", 1, 1 },
{ OPCODE_TRUNC, "TRUNC", 1, 1 },
- { OPCODE_UP2H, "UP2H", 1, 1 },
- { OPCODE_UP2US, "UP2US", 1, 1 },
- { OPCODE_UP4B, "UP4B", 1, 1 },
- { OPCODE_UP4UB, "UP4UB", 1, 1 },
- { OPCODE_X2D, "X2D", 3, 1 },
{ OPCODE_XPD, "XPD", 2, 1 }
};
diff --git a/mesalib/src/mesa/program/prog_instruction.h b/mesalib/src/mesa/program/prog_instruction.h
index b9604e50d..de7880499 100644
--- a/mesalib/src/mesa/program/prog_instruction.h
+++ b/mesalib/src/mesa/program/prog_instruction.h
@@ -187,18 +187,12 @@ typedef enum prog_opcode {
OPCODE_NOISE2, /* X */
OPCODE_NOISE3, /* X */
OPCODE_NOISE4, /* X */
- OPCODE_PK2H, /* X */
- OPCODE_PK2US, /* X */
- OPCODE_PK4B, /* X */
- OPCODE_PK4UB, /* X */
OPCODE_POW, /* X X X X */
OPCODE_RCP, /* X X X X X */
OPCODE_RET, /* 2 2 opt */
- OPCODE_RFL, /* X */
OPCODE_RSQ, /* X X X X X */
OPCODE_SCS, /* X X */
OPCODE_SEQ, /* 2 X X */
- OPCODE_SFL, /* 2 X */
OPCODE_SGE, /* X X X X X */
OPCODE_SGT, /* 2 X X */
OPCODE_SIN, /* X 2 X X */
@@ -206,7 +200,6 @@ typedef enum prog_opcode {
OPCODE_SLT, /* X X X X X */
OPCODE_SNE, /* 2 X X */
OPCODE_SSG, /* 2 X */
- OPCODE_STR, /* 2 X */
OPCODE_SUB, /* X X 1.1 X X */
OPCODE_SWZ, /* X X X */
OPCODE_TEX, /* X 3 X X */
@@ -216,11 +209,6 @@ typedef enum prog_opcode {
OPCODE_TXP, /* X X */
OPCODE_TXP_NV, /* 3 X */
OPCODE_TRUNC, /* X */
- OPCODE_UP2H, /* X */
- OPCODE_UP2US, /* X */
- OPCODE_UP4B, /* X */
- OPCODE_UP4UB, /* X */
- OPCODE_X2D, /* X */
OPCODE_XPD, /* X X */
MAX_OPCODE
} gl_inst_opcode;
diff --git a/mesalib/src/mesa/program/program_lexer.l b/mesalib/src/mesa/program/program_lexer.l
index d5dbcf347..2fcd71f22 100644
--- a/mesalib/src/mesa/program/program_lexer.l
+++ b/mesalib/src/mesa/program/program_lexer.l
@@ -28,6 +28,7 @@
#include "program/symbol_table.h"
#include "program/program_parser.h"
#include "program/program_parse.tab.h"
+#include "util/strtod.h"
#define require_ARB_vp (yyextra->mode == ARB_vertex)
#define require_ARB_fp (yyextra->mode == ARB_fragment)
@@ -216,26 +217,19 @@ MIN{sz}{cc}{sat} { return_opcode( 1, BIN_OP, MIN, 3); }
MOV{sz}{cc}{sat} { return_opcode( 1, VECTOR_OP, MOV, 3); }
MUL{sz}{cc}{sat} { return_opcode( 1, BIN_OP, MUL, 3); }
-PK2H { return_opcode(require_NV_fp, VECTOR_OP, PK2H, 4); }
-PK2US { return_opcode(require_NV_fp, VECTOR_OP, PK2US, 5); }
-PK4B { return_opcode(require_NV_fp, VECTOR_OP, PK4B, 4); }
-PK4UB { return_opcode(require_NV_fp, VECTOR_OP, PK4UB, 5); }
POW{szf}{cc}{sat} { return_opcode( 1, BINSC_OP, POW, 3); }
RCP{szf}{cc}{sat} { return_opcode( 1, SCALAR_OP, RCP, 3); }
-RFL{szf}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, RFL, 3); }
RSQ{szf}{cc}{sat} { return_opcode( 1, SCALAR_OP, RSQ, 3); }
SCS{sat} { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); }
SEQ{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SEQ, 3); }
-SFL{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SFL, 3); }
SGE{sz}{cc}{sat} { return_opcode( 1, BIN_OP, SGE, 3); }
SGT{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SGT, 3); }
SIN{szf}{cc}{sat} { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); }
SLE{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SLE, 3); }
SLT{sz}{cc}{sat} { return_opcode( 1, BIN_OP, SLT, 3); }
SNE{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SNE, 3); }
-STR{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, STR, 3); }
SUB{sz}{cc}{sat} { return_opcode( 1, BIN_OP, SUB, 3); }
SWZ{sat} { return_opcode( 1, SWZ, SWZ, 3); }
@@ -244,12 +238,6 @@ TXB{cc}{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); }
TXD{cc}{sat} { return_opcode(require_NV_fp, TXD_OP, TXD, 3); }
TXP{cc}{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); }
-UP2H{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP2H, 4); }
-UP2US{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP2US, 5); }
-UP4B{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP4B, 4); }
-UP4UB{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP4UB, 5); }
-
-X2D{szf}{cc}{sat} { return_opcode(require_NV_fp, TRI_OP, X2D, 3); }
XPD{sat} { return_opcode( 1, BIN_OP, XPD, 3); }
vertex { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); }
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
index 50209788b..606f19a18 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -72,7 +72,7 @@ static void update_raster_state( struct st_context *st )
{
raster->front_ccw = (ctx->Polygon.FrontFace == GL_CCW);
- /* _NEW_VIEWPORT */
+ /* _NEW_TRANSFORM */
if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT) {
raster->front_ccw ^= 1;
}
@@ -246,13 +246,10 @@ static void update_raster_state( struct st_context *st )
raster->half_pixel_center = 1;
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
raster->bottom_edge_rule = 1;
- /* _NEW_VIEWPORT */
+ /* _NEW_TRANSFORM */
if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT)
raster->bottom_edge_rule ^= 1;
- /* _NEW_VIEWPORT */
- raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
-
/* ST_NEW_RASTERIZER */
raster->rasterizer_discard = ctx->RasterDiscard;
@@ -267,6 +264,7 @@ static void update_raster_state( struct st_context *st )
/* _NEW_TRANSFORM */
raster->depth_clip = !ctx->Transform.DepthClamp;
raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
+ raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
cso_set_rasterizer(st->cso_context, raster);
}
@@ -283,8 +281,7 @@ const struct st_tracked_state st_update_rasterizer = {
_NEW_PROGRAM |
_NEW_SCISSOR |
_NEW_FRAG_CLAMP |
- _NEW_TRANSFORM |
- _NEW_VIEWPORT), /* mesa state dependencies*/
+ _NEW_TRANSFORM), /* mesa state dependencies*/
(ST_NEW_VERTEX_PROGRAM |
ST_NEW_RASTERIZER), /* state tracker dependencies */
},
diff --git a/mesalib/src/mesa/state_tracker/st_atom_viewport.c b/mesalib/src/mesa/state_tracker/st_atom_viewport.c
index 5b992084b..efa056e10 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_viewport.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_viewport.c
@@ -70,12 +70,10 @@ update_viewport( struct st_context *st )
st->state.viewport[i].scale[0] = scale[0];
st->state.viewport[i].scale[1] = scale[1] * yScale;
st->state.viewport[i].scale[2] = scale[2];
- st->state.viewport[i].scale[3] = 1.0;
st->state.viewport[i].translate[0] = translate[0];
st->state.viewport[i].translate[1] = translate[1] * yScale + yBias;
st->state.viewport[i].translate[2] = translate[2];
- st->state.viewport[i].translate[3] = 0.0;
}
cso_set_viewport(st->cso_context, &st->state.viewport[0]);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index e3ba5a88f..2107ab167 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -504,11 +504,9 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
vp.scale[0] = 0.5f * width;
vp.scale[1] = height * (invert ? -0.5f : 0.5f);
vp.scale[2] = 0.5f;
- vp.scale[3] = 1.0f;
vp.translate[0] = 0.5f * width;
vp.translate[1] = 0.5f * height;
vp.translate[2] = 0.5f;
- vp.translate[3] = 0.0f;
cso_set_viewport(cso, &vp);
}
@@ -769,7 +767,8 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
const uint semantic_indexes[] = { 0, 0, 0 };
st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3,
semantic_names,
- semantic_indexes);
+ semantic_indexes,
+ FALSE);
}
if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap))
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 2c1414e48..45dea594e 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -88,6 +88,14 @@ st_destroy_clear(struct st_context *st)
cso_delete_vertex_shader(st->cso_context, st->clear.vs);
st->clear.vs = NULL;
}
+ if (st->clear.vs_layered) {
+ cso_delete_vertex_shader(st->cso_context, st->clear.vs_layered);
+ st->clear.vs_layered = NULL;
+ }
+ if (st->clear.gs_layered) {
+ cso_delete_geometry_shader(st->cso_context, st->clear.gs_layered);
+ st->clear.gs_layered = NULL;
+ }
}
@@ -123,10 +131,12 @@ set_vertex_shader(struct st_context *st)
const uint semantic_indexes[] = { 0, 0 };
st->clear.vs = util_make_vertex_passthrough_shader(st->pipe, 2,
semantic_names,
- semantic_indexes);
+ semantic_indexes,
+ FALSE);
}
cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
+ cso_set_geometry_shader_handle(st->cso_context, NULL);
}
@@ -135,18 +145,25 @@ set_vertex_shader_layered(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
- if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID) ||
- !pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) {
- assert(!"Got layered clear, but the VS layer output is unsupported");
+ if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID)) {
+ assert(!"Got layered clear, but VS instancing is unsupported");
set_vertex_shader(st);
return;
}
if (!st->clear.vs_layered) {
- st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe);
+ bool vs_layer =
+ pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT);
+ if (vs_layer) {
+ st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe);
+ } else {
+ st->clear.vs_layered = util_make_layered_clear_helper_vertex_shader(pipe);
+ st->clear.gs_layered = util_make_layered_clear_geometry_shader(pipe);
+ }
}
cso_set_vertex_shader_handle(st->cso_context, st->clear.vs_layered);
+ cso_set_geometry_shader_handle(st->cso_context, st->clear.gs_layered);
}
@@ -323,16 +340,13 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
vp.scale[0] = 0.5f * fb_width;
vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
vp.scale[2] = 0.5f;
- vp.scale[3] = 1.0f;
vp.translate[0] = 0.5f * fb_width;
vp.translate[1] = 0.5f * fb_height;
vp.translate[2] = 0.5f;
- vp.translate[3] = 0.0f;
cso_set_viewport(st->cso_context, &vp);
}
set_fragment_shader(st);
- cso_set_geometry_shader_handle(st->cso_context, NULL);
if (num_layers > 1)
set_vertex_shader_layered(st);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 5ae092b94..939fc2065 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -776,11 +776,9 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
vp.scale[0] = 0.5f * w;
vp.scale[1] = -0.5f * h;
vp.scale[2] = 0.5f;
- vp.scale[3] = 1.0f;
vp.translate[0] = 0.5f * w;
vp.translate[1] = 0.5f * h;
vp.translate[2] = 0.5f;
- vp.translate[3] = 0.0f;
cso_set_viewport(cso, &vp);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
index f997e6b00..d057ff62a 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
@@ -91,7 +91,7 @@ lookup_shader(struct pipe_context *pipe,
util_make_vertex_passthrough_shader(pipe,
num_attribs,
semantic_names,
- semantic_indexes);
+ semantic_indexes, FALSE);
NumCachedShaders++;
return CachedShaders[i].handle;
@@ -258,11 +258,9 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
vp.scale[0] = 0.5f * width;
vp.scale[1] = height * (invert ? -0.5f : 0.5f);
vp.scale[2] = 1.0f;
- vp.scale[3] = 1.0f;
vp.translate[0] = 0.5f * width;
vp.translate[1] = 0.5f * height;
vp.translate[2] = 0.0f;
- vp.translate[3] = 0.0f;
cso_set_viewport(cso, &vp);
}
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 58f14f954..15f9df492 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -181,6 +181,7 @@ struct st_context
void *vs;
void *fs;
void *vs_layered;
+ void *gs_layered;
} clear;
/** used for anything using util_draw_vertex_buffer */
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index aff3ddebe..bdfab8b41 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -241,8 +241,7 @@ void st_init_limits(struct pipe_screen *screen,
if (options->EmitNoLoops)
options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
- else
- options->MaxUnrollIterations = 255; /* SM3 limit */
+
options->LowerClipDistance = true;
}
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index a4e2c8da5..8e91c4b61 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4022,6 +4022,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
newinst = v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], src_regs[2]);
newinst->tex_target = inst->tex_target;
+ newinst->sampler_array_size = inst->sampler_array_size;
}
/* Make modifications to fragment program info. */
@@ -4101,6 +4102,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
newinst = v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], src_regs[2]);
newinst->tex_target = inst->tex_target;
+ newinst->sampler_array_size = inst->sampler_array_size;
}
/* Make modifications to fragment program info. */
@@ -4524,8 +4526,10 @@ compile_tgsi_instruction(struct st_translate *t,
inst->saturate,
clamp_dst_color_output);
- for (i = 0; i < num_src; i++)
+ for (i = 0; i < num_src; i++) {
+ assert(inst->src[i].file != PROGRAM_UNDEFINED);
src[i] = translate_src(t, &inst->src[i]);
+ }
switch(inst->op) {
case TGSI_OPCODE_BGNLOOP:
@@ -4555,6 +4559,7 @@ compile_tgsi_instruction(struct st_translate *t,
case TGSI_OPCODE_TG4:
case TGSI_OPCODE_LODQ:
src[num_src] = t->samplers[inst->sampler.index];
+ assert(src[num_src].File != TGSI_FILE_NULL);
if (inst->sampler.reladdr)
src[num_src] =
ureg_src_indirect(src[num_src], ureg_src(t->address[2]));
@@ -4721,7 +4726,8 @@ emit_wpos(struct st_context *st,
}
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) {
/* the driver supports lower-left origin, need to invert Y */
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
invert = TRUE;
}
else
@@ -4731,7 +4737,8 @@ emit_wpos(struct st_context *st,
/* Fragment shader wants origin in lower-left */
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT))
/* the driver supports lower-left origin */
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT))
/* the driver supports upper-left origin, need to invert Y */
invert = TRUE;
@@ -4744,7 +4751,8 @@ emit_wpos(struct st_context *st,
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
/* the driver supports pixel center integer */
adjY[1] = 1.0f;
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
}
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) {
/* the driver supports pixel center half integer, need to bias X,Y */
@@ -4763,7 +4771,8 @@ emit_wpos(struct st_context *st,
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
/* the driver supports pixel center integer, need to bias X,Y */
adjX = adjY[0] = adjY[1] = 0.5f;
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
}
else
assert(0);
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index df6de737f..606d67891 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -452,7 +452,8 @@ st_framebuffer_create(struct st_context *st,
st_pipe_format_to_mesa_format(srgb_format) != MESA_FORMAT_NONE &&
screen->is_format_supported(screen, srgb_format,
PIPE_TEXTURE_2D, stfbi->visual->samples,
- PIPE_BIND_RENDER_TARGET))
+ (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_RENDER_TARGET)))
mode.sRGBCapable = GL_TRUE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 26a5f51c7..2c9d9a523 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -891,7 +891,8 @@ emit_wpos(struct st_context *st,
}
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) {
/* the driver supports lower-left origin, need to invert Y */
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
invert = TRUE;
}
else
@@ -901,7 +902,8 @@ emit_wpos(struct st_context *st,
/* Fragment shader wants origin in lower-left */
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT))
/* the driver supports lower-left origin */
- ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+ TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT))
/* the driver supports upper-left origin, need to invert Y */
invert = TRUE;
@@ -914,7 +916,8 @@ emit_wpos(struct st_context *st,
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
/* the driver supports pixel center integer */
adjY[1] = 1.0f;
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
}
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) {
/* the driver supports pixel center half integer, need to bias X,Y */
@@ -933,7 +936,8 @@ emit_wpos(struct st_context *st,
else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
/* the driver supports pixel center integer, need to bias X,Y */
adjX = adjY[0] = adjY[1] = 0.5f;
- ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+ TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
}
else
assert(0);
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 926086bf8..737c2694e 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -742,21 +742,25 @@ st_translate_fragment_program(struct st_context *st,
debug_printf("\n");
}
if (write_all == GL_TRUE)
- ureg_property_fs_color0_writes_all_cbufs(ureg, 1);
+ ureg_property(ureg, TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS, 1);
if (stfp->Base.FragDepthLayout != FRAG_DEPTH_LAYOUT_NONE) {
switch (stfp->Base.FragDepthLayout) {
case FRAG_DEPTH_LAYOUT_ANY:
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_ANY);
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+ TGSI_FS_DEPTH_LAYOUT_ANY);
break;
case FRAG_DEPTH_LAYOUT_GREATER:
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_GREATER);
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+ TGSI_FS_DEPTH_LAYOUT_GREATER);
break;
case FRAG_DEPTH_LAYOUT_LESS:
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_LESS);
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+ TGSI_FS_DEPTH_LAYOUT_LESS);
break;
case FRAG_DEPTH_LAYOUT_UNCHANGED:
- ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_UNCHANGED);
+ ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+ TGSI_FS_DEPTH_LAYOUT_UNCHANGED);
break;
default:
assert(0);
@@ -1122,10 +1126,11 @@ st_translate_geometry_program(struct st_context *st,
stgp->tgsi.tokens = NULL;
}
- ureg_property_gs_input_prim(ureg, stgp->Base.InputType);
- ureg_property_gs_output_prim(ureg, stgp->Base.OutputType);
- ureg_property_gs_max_vertices(ureg, stgp->Base.VerticesOut);
- ureg_property_gs_invocations(ureg, stgp->Base.Invocations);
+ ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType);
+ ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType);
+ ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,
+ stgp->Base.VerticesOut);
+ ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations);
if (stgp->glsl_to_tgsi)
st_translate_program(st->ctx,
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 045dbb506..e623b361a 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -36,6 +36,8 @@
#include "main/enums.h"
#include "main/macros.h"
#include "main/transformfeedback.h"
+#include "main/sse_minmax.h"
+#include "x86/common_x86_asm.h"
#include "vbo_context.h"
@@ -119,10 +121,16 @@ vbo_get_minmax_index(struct gl_context *ctx,
}
}
else {
- for (i = 0; i < count; i++) {
- if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
- if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
+#if defined(USE_SSE41)
+ if (cpu_has_sse4_1) {
+ _mesa_uint_array_min_max(ui_indices, &min_ui, &max_ui, count);
}
+ else
+#endif
+ for (i = 0; i < count; i++) {
+ if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
+ if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
+ }
}
*min_index = min_ui;
*max_index = max_ui;
diff --git a/mesalib/src/mesa/x86/common_x86_features.h b/mesalib/src/mesa/x86/common_x86_features.h
index 66f2cf651..65634aa5d 100644
--- a/mesalib/src/mesa/x86/common_x86_features.h
+++ b/mesalib/src/mesa/x86/common_x86_features.h
@@ -59,13 +59,39 @@
#define X86_CPUEXT_3DNOW_EXT (1<<30)
#define X86_CPUEXT_3DNOW (1<<31)
+#ifdef __MMX__
+#define cpu_has_mmx 1
+#else
#define cpu_has_mmx (_mesa_x86_cpu_features & X86_FEATURE_MMX)
+#endif
+
#define cpu_has_mmxext (_mesa_x86_cpu_features & X86_FEATURE_MMXEXT)
+
+#ifdef __SSE__
+#define cpu_has_xmm 1
+#else
#define cpu_has_xmm (_mesa_x86_cpu_features & X86_FEATURE_XMM)
+#endif
+
+#ifdef __SSE2__
+#define cpu_has_xmm2 1
+#else
#define cpu_has_xmm2 (_mesa_x86_cpu_features & X86_FEATURE_XMM2)
+#endif
+
+#ifdef __3dNOW__
+#define cpu_has_3dnow 1
+#else
#define cpu_has_3dnow (_mesa_x86_cpu_features & X86_FEATURE_3DNOW)
+#endif
+
#define cpu_has_3dnowext (_mesa_x86_cpu_features & X86_FEATURE_3DNOWEXT)
+
+#ifdef __SSE4_1__
+#define cpu_has_sse4_1 1
+#else
#define cpu_has_sse4_1 (_mesa_x86_cpu_features & X86_FEATURE_SSE4_1)
+#endif
#endif
diff --git a/mesalib/src/util/Makefile.sources b/mesalib/src/util/Makefile.sources
index 952b79905..9e274241d 100644
--- a/mesalib/src/util/Makefile.sources
+++ b/mesalib/src/util/Makefile.sources
@@ -3,7 +3,8 @@ MESA_UTIL_FILES := \
ralloc.c \
register_allocate.c \
register_allocate.h \
- rgtc.c
+ rgtc.c \
+ strtod.cpp
MESA_UTIL_GENERATED_FILES = \
format_srgb.c
diff --git a/mesalib/src/util/hash_table.c b/mesalib/src/util/hash_table.c
index 1b6726c79..920bdfd33 100644
--- a/mesalib/src/util/hash_table.c
+++ b/mesalib/src/util/hash_table.c
@@ -385,12 +385,12 @@ _mesa_hash_table_random_entry(struct hash_table *ht,
/**
- * Quick FNV-1 hash implementation based on:
+ * Quick FNV-1a hash implementation based on:
* http://www.isthe.com/chongo/tech/comp/fnv/
*
- * FNV-1 is not be the best hash out there -- Jenkins's lookup3 is supposed to
- * be quite good, and it probably beats FNV. But FNV has the advantage that
- * it involves almost no code. For an improvement on both, see Paul
+ * FNV-1a is not be the best hash out there -- Jenkins's lookup3 is supposed
+ * to be quite good, and it probably beats FNV. But FNV has the advantage
+ * that it involves almost no code. For an improvement on both, see Paul
* Hsieh's http://www.azillionmonkeys.com/qed/hash.html
*/
uint32_t
@@ -408,7 +408,7 @@ _mesa_hash_data(const void *data, size_t size)
return hash;
}
-/** FNV-1 string hash implementation */
+/** FNV-1a string hash implementation */
uint32_t
_mesa_hash_string(const char *key)
{
diff --git a/mesalib/src/util/macros.h b/mesalib/src/util/macros.h
index ff37a7d63..5fc672953 100644
--- a/mesalib/src/util/macros.h
+++ b/mesalib/src/util/macros.h
@@ -29,6 +29,10 @@
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#endif
+/* For compatibility with Clang's __has_builtin() */
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
/**
* __builtin_expect macros
@@ -69,6 +73,12 @@ do { \
assert(!str); \
__builtin_unreachable(); \
} while (0)
+#elif _MSC_VER >= 1200
+#define unreachable(str) \
+do { \
+ assert(!str); \
+ __assume(0); \
+} while (0)
#endif
#ifndef unreachable
@@ -79,7 +89,13 @@ do { \
* Assume macro. Useful for expressing our assumptions to the compiler,
* typically for purposes of silencing warnings.
*/
-#ifdef HAVE___BUILTIN_UNREACHABLE
+#if __has_builtin(__builtin_assume)
+#define assume(expr) \
+do { \
+ assert(expr); \
+ __builtin_assume(expr); \
+} while (0)
+#elif defined HAVE___BUILTIN_UNREACHABLE
#define assume(expr) ((expr) ? ((void) 0) \
: (assert(!"assumption failed"), \
__builtin_unreachable()))
diff --git a/mesalib/src/glsl/strtod.c b/mesalib/src/util/strtod.cpp
index 5d4346b5a..2b4dd982a 100644
--- a/mesalib/src/glsl/strtod.c
+++ b/mesalib/src/util/strtod.cpp
@@ -28,7 +28,7 @@
#ifdef _GNU_SOURCE
#include <locale.h>
-#ifdef __APPLE__
+#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
#endif
#endif
@@ -36,21 +36,22 @@
#include "strtod.h"
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+static struct locale_initializer {
+ locale_initializer() { loc = newlocale(LC_CTYPE_MASK, "C", NULL); }
+ locale_t loc;
+} loc_init;
+#endif
/**
* Wrapper around strtod which uses the "C" locale so the decimal
* point is always '.'
*/
double
-glsl_strtod(const char *s, char **end)
+_mesa_strtod(const char *s, char **end)
{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(__HAIKU__) && !defined(__UCLIBC__)
- static locale_t loc = NULL;
- if (!loc) {
- loc = newlocale(LC_CTYPE_MASK, "C", NULL);
- }
- return strtod_l(s, end, loc);
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+ return strtod_l(s, end, loc_init.loc);
#else
return strtod(s, end);
#endif
@@ -62,16 +63,11 @@ glsl_strtod(const char *s, char **end)
* point is always '.'
*/
float
-glsl_strtof(const char *s, char **end)
+_mesa_strtof(const char *s, char **end)
{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(__HAIKU__) && !defined(__UCLIBC__)
- static locale_t loc = NULL;
- if (!loc) {
- loc = newlocale(LC_CTYPE_MASK, "C", NULL);
- }
- return strtof_l(s, end, loc);
-#elif _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+ return strtof_l(s, end, loc_init.loc);
+#elif defined(HAVE_STRTOF)
return strtof(s, end);
#else
return (float) strtod(s, end);
diff --git a/mesalib/src/glsl/strtod.h b/mesalib/src/util/strtod.h
index ad847dbb0..02c25ddb7 100644
--- a/mesalib/src/glsl/strtod.h
+++ b/mesalib/src/util/strtod.h
@@ -32,10 +32,10 @@ extern "C" {
#endif
extern double
-glsl_strtod(const char *s, char **end);
+_mesa_strtod(const char *s, char **end);
extern float
-glsl_strtof(const char *s, char **end);
+_mesa_strtof(const char *s, char **end);
#ifdef __cplusplus