summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-10-22 19:27:34 -0700
committerIan Romanick <ian.d.romanick@intel.com>2009-10-22 19:27:34 -0700
commit21c795b64d14dbd3496903ba5aaab196de2e7a2a (patch)
tree6ab54c3279819342757dae4c3b7fd28d968dd819
parentea92bef2898bc3391407702b0843ebb9d5e083fc (diff)
parent286611d99060c38c4cc12f18fde5448213e2a44b (diff)
Merge branch 'master' into asm-shader-rework-3asm-shader-rework-3
Conflicts: src/mesa/shader/lex.yy.c
-rw-r--r--Makefile22
-rw-r--r--configs/linux-dri4
-rw-r--r--configs/linux-dri-debug2
-rw-r--r--configs/linux-dri-xcb4
-rw-r--r--configure.ac10
-rw-r--r--docs/envvars.html1
-rw-r--r--docs/relnotes-7.6.1.html1
-rw-r--r--docs/shading.html9
-rw-r--r--progs/Makefile24
-rw-r--r--progs/demos/fbo_firecube.c36
-rw-r--r--progs/egl/eglgears.c10
-rw-r--r--progs/egl/egltri.c5
-rw-r--r--progs/egl/peglgears.c10
-rw-r--r--progs/egl/xeglgears.c399
-rw-r--r--progs/tests/arraytexture.c19
-rw-r--r--progs/tests/invert.c2
-rw-r--r--progs/tests/prog_parameter.c4
-rw-r--r--progs/trivial/tri-query.c5
-rw-r--r--progs/xdemos/glsync.c2
-rw-r--r--scons/gallium.py15
-rw-r--r--scons/llvm.py45
-rw-r--r--src/egl/drivers/glx/egl_glx.c903
-rw-r--r--src/egl/main/eglapi.c140
-rw-r--r--src/egl/main/eglapi.h8
-rw-r--r--src/egl/main/eglconfig.c9
-rw-r--r--src/egl/main/eglconfigutil.c7
-rw-r--r--src/egl/main/eglconfigutil.h2
-rw-r--r--src/egl/main/eglcurrent.c2
-rw-r--r--src/egl/main/egldriver.c2
-rw-r--r--src/egl/main/eglmisc.c3
-rw-r--r--src/egl/main/eglmisc.h2
-rw-r--r--src/egl/main/eglsurface.c27
-rw-r--r--src/egl/main/eglsurface.h2
-rw-r--r--src/gallium/auxiliary/util/u_blit.c19
-rw-r--r--src/gallium/auxiliary/util/u_clear.h16
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.c35
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.h2
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.c95
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.h33
-rw-r--r--src/gallium/auxiliary/util/u_keymap.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_gen_fp.c4
-rw-r--r--src/gallium/drivers/i915/i915_debug.c2
-rw-r--r--src/gallium/drivers/i915/i915_fpc_translate.c2
-rw-r--r--src/gallium/drivers/llvmpipe/Makefile1
-rw-r--r--src/gallium/drivers/llvmpipe/SConscript1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_arit.c96
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_arit.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_const.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_conv.c240
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_conv.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_logic.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_pack.c419
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_pack.h95
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_swizzle.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_type.c29
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_type.h4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test.h20
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_conv.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_format.c3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_main.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c14
-rw-r--r--src/gallium/drivers/nouveau/Makefile3
-rw-r--r--src/gallium/drivers/nouveau/nouveau_context.c41
-rw-r--r--src/gallium/drivers/nouveau/nouveau_context.h11
-rw-r--r--src/gallium/drivers/nv04/nv04_context.c28
-rw-r--r--src/gallium/drivers/nv04/nv04_context.h1
-rw-r--r--src/gallium/drivers/nv10/nv10_context.c27
-rw-r--r--src/gallium/drivers/nv10/nv10_context.h1
-rw-r--r--src/gallium/drivers/nv20/nv20_context.c28
-rw-r--r--src/gallium/drivers/nv20/nv20_context.h1
-rw-r--r--src/gallium/drivers/nv30/nv30_context.c30
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h1
-rw-r--r--src/gallium/drivers/nv30/nv30_fragtex.c10
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.c29
-rw-r--r--src/gallium/drivers/nv30/nv30_state_fb.c58
-rw-r--r--src/gallium/drivers/nv40/nv40_context.c30
-rw-r--r--src/gallium/drivers/nv40/nv40_context.h1
-rw-r--r--src/gallium/drivers/nv50/nv50_context.c34
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h9
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c309
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c52
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c26
-rw-r--r--src/gallium/drivers/nv50/nv50_state_validate.c53
-rw-r--r--src/gallium/drivers/nv50/nv50_tex.c177
-rw-r--r--src/gallium/drivers/nv50/nv50_texture.h2
-rw-r--r--src/gallium/drivers/nv50/nv50_vbo.c413
-rw-r--r--src/gallium/drivers/r300/Makefile3
-rw-r--r--src/gallium/drivers/r300/r300_chipset.c3
-rw-r--r--src/gallium/drivers/r300/r300_chipset.h6
-rw-r--r--src/gallium/drivers/r300/r300_clear.c3
-rw-r--r--src/gallium/drivers/r300/r300_clear.h4
-rw-r--r--src/gallium/drivers/r300/r300_context.c114
-rw-r--r--src/gallium/drivers/r300/r300_context.h45
-rw-r--r--src/gallium/drivers/r300/r300_debug.c1
-rw-r--r--src/gallium/drivers/r300/r300_emit.c140
-rw-r--r--src/gallium/drivers/r300/r300_emit.h11
-rw-r--r--src/gallium/drivers/r300/r300_flush.c27
-rw-r--r--src/gallium/drivers/r300/r300_flush.h7
-rw-r--r--src/gallium/drivers/r300/r300_fs.c17
-rw-r--r--src/gallium/drivers/r300/r300_fs.h12
-rw-r--r--src/gallium/drivers/r300/r300_query.c63
-rw-r--r--src/gallium/drivers/r300/r300_query.h4
-rw-r--r--src/gallium/drivers/r300/r300_reg.h36
-rw-r--r--src/gallium/drivers/r300/r300_render.c255
-rw-r--r--src/gallium/drivers/r300/r300_render.h52
-rw-r--r--src/gallium/drivers/r300/r300_screen.c45
-rw-r--r--src/gallium/drivers/r300/r300_screen.h5
-rw-r--r--src/gallium/drivers/r300/r300_shader_inlines.h47
-rw-r--r--src/gallium/drivers/r300/r300_state.c12
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c207
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.h4
-rw-r--r--src/gallium/drivers/r300/r300_state_inlines.h70
-rw-r--r--src/gallium/drivers/r300/r300_state_invariant.c5
-rw-r--r--src/gallium/drivers/r300/r300_state_invariant.h6
-rw-r--r--src/gallium/drivers/r300/r300_surface.c382
-rw-r--r--src/gallium/drivers/r300/r300_surface.h124
-rw-r--r--src/gallium/drivers/r300/r300_texture.c25
-rw-r--r--src/gallium/drivers/r300/r300_texture.h4
-rw-r--r--src/gallium/drivers/r300/r300_vs.c86
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h9
-rw-r--r--src/gallium/drivers/r300/r3xx_fs.c74
-rw-r--r--src/gallium/drivers/r300/r3xx_fs.h32
-rw-r--r--src/gallium/drivers/r300/r5xx_fs.c125
-rw-r--r--src/gallium/drivers/r300/r5xx_fs.h32
-rw-r--r--src/gallium/drivers/trace/tr_drm.c4
-rw-r--r--src/gallium/drivers/trace/tr_screen.c3
-rw-r--r--src/gallium/include/pipe/p_compiler.h6
-rw-r--r--src/gallium/include/pipe/p_context.h3
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c22
-rw-r--r--src/gallium/state_trackers/dri/dri_extensions.c4
-rw-r--r--src/gallium/state_trackers/egl/egl_surface.c23
-rw-r--r--src/gallium/state_trackers/vega/renderer.c16
-rw-r--r--src/gallium/state_trackers/vega/vg_tracker.c24
-rw-r--r--src/gallium/state_trackers/xorg/Makefile3
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.c279
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c167
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c190
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c104
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.h8
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.c37
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.h3
-rw-r--r--src/gallium/state_trackers/xorg/xorg_output.c107
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c162
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.h4
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h9
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.c4
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.h1
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.c33
-rw-r--r--src/glx/x11/glxcmds.c10
-rw-r--r--src/mesa/drivers/common/driverfuncs.c2
-rw-r--r--src/mesa/drivers/common/meta.c6
-rw-r--r--src/mesa/drivers/dri/Makefile.template24
-rw-r--r--src/mesa/drivers/dri/common/drirenderbuffer.h2
-rw-r--r--src/mesa/drivers/dri/fb/Makefile2
-rw-r--r--src/mesa/drivers/dri/ffb/Makefile1
-rw-r--r--src/mesa/drivers/dri/gamma/Makefile1
-rw-r--r--src/mesa/drivers/dri/i810/Makefile1
-rw-r--r--src/mesa/drivers/dri/i915/Makefile1
-rw-r--r--src/mesa/drivers/dri/i915/intel_tris.c8
-rw-r--r--src/mesa/drivers/dri/i965/Makefile1
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h5
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c12
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c19
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h10
-rw-r--r--src/mesa/drivers/dri/intel/intel_syncobj.c2
-rw-r--r--src/mesa/drivers/dri/mach64/Makefile1
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_tex.c1
-rw-r--r--src/mesa/drivers/dri/mga/Makefile1
-rw-r--r--src/mesa/drivers/dri/r128/Makefile1
-rw-r--r--src/mesa/drivers/dri/r200/Makefile1
-rw-r--r--src/mesa/drivers/dri/r300/Makefile12
-rw-r--r--src/mesa/drivers/dri/r300/r300_texstate.c20
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c12
-rw-r--r--src/mesa/drivers/dri/r600/Makefile1
-rw-r--r--src/mesa/drivers/dri/r600/r600_cmdbuf.c18
-rw-r--r--src/mesa/drivers/dri/r600/r600_context.c1
-rw-r--r--src/mesa/drivers/dri/r600/r600_texstate.c12
-rw-r--r--src/mesa/drivers/dri/r600/r700_assembler.c59
-rw-r--r--src/mesa/drivers/dri/r600/r700_assembler.h1
-rw-r--r--src/mesa/drivers/dri/r600/r700_fragprog.c37
-rw-r--r--src/mesa/drivers/dri/radeon/Makefile1
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_bo_legacy.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_fbo.c5
-rw-r--r--src/mesa/drivers/dri/s3v/Makefile36
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_common.h83
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_context.c260
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_context.h443
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_dd.c90
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_dri.h143
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_inithw.c79
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_lock.c62
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_lock.h99
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_macros.h230
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_regs.h367
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_render.c203
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_screen.c99
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_screen.h39
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_span.c219
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_state.c888
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tex.c548
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tex.h28
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_texmem.c582
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_texstate.c300
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tris.c850
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tris.h11
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tritmp.h958
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_vb.c339
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_vb.h39
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_xmesa.c341
-rw-r--r--src/mesa/drivers/dri/s3v/s3virgetri.h383
-rw-r--r--src/mesa/drivers/dri/savage/Makefile1
-rw-r--r--src/mesa/drivers/dri/sis/Makefile1
-rw-r--r--src/mesa/drivers/dri/swrast/Makefile1
-rw-r--r--src/mesa/drivers/dri/tdfx/Makefile2
-rw-r--r--src/mesa/drivers/dri/trident/Makefile26
-rw-r--r--src/mesa/drivers/dri/trident/trident_context.c465
-rw-r--r--src/mesa/drivers/dri/trident/trident_context.h242
-rw-r--r--src/mesa/drivers/dri/trident/trident_dd.c110
-rw-r--r--src/mesa/drivers/dri/trident/trident_dri.h28
-rw-r--r--src/mesa/drivers/dri/trident/trident_lock.h11
-rw-r--r--src/mesa/drivers/dri/trident/trident_state.c548
-rw-r--r--src/mesa/drivers/dri/trident/trident_tris.c1125
-rw-r--r--src/mesa/drivers/dri/trident/trident_vb.c434
-rw-r--r--src/mesa/drivers/dri/unichrome/Makefile1
-rw-r--r--src/mesa/main/context.c39
-rw-r--r--src/mesa/main/context.h8
-rw-r--r--src/mesa/main/dd.h7
-rw-r--r--src/mesa/main/debug.c110
-rw-r--r--src/mesa/main/debug.h6
-rw-r--r--src/mesa/main/imports.c15
-rw-r--r--src/mesa/main/light.c2
-rw-r--r--src/mesa/main/mtypes.h17
-rw-r--r--src/mesa/main/shaders.c24
-rw-r--r--src/mesa/main/texobj.c2
-rw-r--r--src/mesa/main/texstate.c7
-rw-r--r--src/mesa/shader/lex.yy.c1863
-rw-r--r--src/mesa/shader/prog_print.c3
-rw-r--r--src/mesa/shader/program_lexer.l9
-rw-r--r--src/mesa/shader/program_parse.tab.c2301
-rw-r--r--src/mesa/shader/program_parse.tab.h191
-rw-r--r--src/mesa/shader/shader_api.c27
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c16
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c19
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c16
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c3
-rw-r--r--src/mesa/tnl/t_context.h1
-rw-r--r--src/mesa/tnl/t_vb_cliptmp.h103
-rw-r--r--src/mesa/tnl/t_vb_program.c15
-rw-r--r--src/mesa/tnl/t_vb_vertex.c31
-rw-r--r--src/mesa/vbo/vbo_exec_api.c22
-rw-r--r--src/mesa/vbo/vbo_exec_array.c78
254 files changed, 7207 insertions, 16324 deletions
diff --git a/Makefile b/Makefile
index 413a1b4372e..7f073fd516c 100644
--- a/Makefile
+++ b/Makefile
@@ -505,9 +505,11 @@ rm_depend:
touch $$dep ; \
done
-lib_gz:
- rm -f configs/current ; \
- rm -f configs/autoconf ; \
+rm_config:
+ rm -f configs/current
+ rm -f configs/autoconf
+
+lib_gz: rm_config
cd .. ; \
tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
gzip $(LIB_NAME).tar ; \
@@ -525,9 +527,7 @@ glut_gz:
gzip $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.gz $(DIRECTORY)
-lib_bz2:
- rm -f configs/current ; \
- rm -f configs/autoconf ; \
+lib_bz2: rm_config
cd .. ; \
tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
bzip2 $(LIB_NAME).tar ; \
@@ -545,9 +545,7 @@ glut_bz2:
bzip2 $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.bz2 $(DIRECTORY)
-lib_zip:
- rm -f configs/current ; \
- rm -f configs/autoconf ; \
+lib_zip: rm_config
rm -f $(LIB_NAME).zip ; \
cd .. ; \
zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
@@ -576,5 +574,7 @@ md5:
@-md5sum $(GLUT_NAME).tar.bz2
@-md5sum $(GLUT_NAME).zip
-.PHONY: tarballs rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 \
- glut_bz2 lib_zip demo_zip glut_zip md5
+.PHONY: tarballs rm_depend rm_config md5 \
+ lib_gz demo_gz glut_gz \
+ lib_bz2 demo_bz2 glut_bz2 \
+ lib_zip demo_zip glut_zip
diff --git a/configs/linux-dri b/configs/linux-dri
index 0998ba8549d..6c3c0ab9211 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -63,5 +63,5 @@ GALLIUM_WINSYS_DIRS = drm
GALLIUM_WINSYS_DRM_DIRS = intel
GALLIUM_STATE_TRACKERS_DIRS = egl
-DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
- savage sis tdfx trident unichrome ffb swrast
+DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
+ savage sis tdfx unichrome ffb swrast
diff --git a/configs/linux-dri-debug b/configs/linux-dri-debug
index c3a458459d8..0dbf428830a 100644
--- a/configs/linux-dri-debug
+++ b/configs/linux-dri-debug
@@ -11,6 +11,6 @@ ARCH_FLAGS = -DDEBUG
#DRI_DIRS = i915tex i915
#DRI_DIRS = i965
#DRI_DIRS = radeon r200 r300
-#DRI_DIRS = unichrome sis trident
+#DRI_DIRS = unichrome sis
#DRI_DIRS = i810 mga r128 tdfx
diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb
index e9c15a82e42..827fb973308 100644
--- a/configs/linux-dri-xcb
+++ b/configs/linux-dri-xcb
@@ -68,5 +68,5 @@ WINDOW_SYSTEM=dri
# gamma are missing because they have not been converted to use the new
# interface.
-DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
- savage sis tdfx trident unichrome ffb
+DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \
+ savage sis tdfx unichrome ffb
diff --git a/configure.ac b/configure.ac
index 2a67bd62b25..910c0b1a4b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,6 +230,8 @@ else
LIB_EXTENSION='dylib' ;;
cygwin* )
LIB_EXTENSION='dll' ;;
+ aix* )
+ LIB_EXTENSION='a' ;;
* )
LIB_EXTENSION='so' ;;
esac
@@ -766,8 +768,8 @@ if test "$mesa_driver" = dri; then
# default drivers
if test "x$DRI_DIRS" = "xyes"; then
- DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon s3v \
- savage sis tdfx trident unichrome ffb swrast"
+ DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
+ savage sis tdfx unichrome ffb swrast"
fi
DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
@@ -1150,9 +1152,9 @@ yes)
fi
if test "$tracker" = xorg; then
PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
- HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71"
+ HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
HAVE_XEXTPROTO_71="no")
- fi
+ fi
done
GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
;;
diff --git a/docs/envvars.html b/docs/envvars.html
index 6d7a321da9f..b2c0e01ee32 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -28,6 +28,7 @@ Setting this variable automatically sets the MESA_TEX_PROG variable as well.
<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
and disable the GL_EXT_bar extension.
+<li>MESA_GLSL - <a href="shading.html#envvars">shading language options</a>
</ul>
<p>
diff --git a/docs/relnotes-7.6.1.html b/docs/relnotes-7.6.1.html
index 47a906f1f4b..9d28a5b2b5a 100644
--- a/docs/relnotes-7.6.1.html
+++ b/docs/relnotes-7.6.1.html
@@ -44,6 +44,7 @@ tbd
<li>r300: Work around an issue with very large fragment programs on R500.
<li>Fake glXQueryDrawable() didn't return good values (bug 24320)
<li>Fixed AUX buffer breakage (bug 24426).
+<li>Fixed locale-dependent float parsing bug in GLSL compiler (bug 24531)
</ul>
</body>
diff --git a/docs/shading.html b/docs/shading.html
index 77c86be3aa6..bd02335a803 100644
--- a/docs/shading.html
+++ b/docs/shading.html
@@ -39,7 +39,8 @@ Contents
<p>
The <b>MESA_GLSL</b> environment variable can be set to a comma-separated
-list of keywords to control some aspects of the GLSL compiler:
+list of keywords to control some aspects of the GLSL compiler and shader
+execution. These are generally used for debugging.
</p>
<ul>
<li>dump - print GLSL shader code to stdout at link time
@@ -49,6 +50,12 @@ list of keywords to control some aspects of the GLSL compiler:
<li>nopt - disable compiler optimizations
<li>opt - force compiler optimizations
<li>uniform - print message to stdout when glUniform is called
+<li>nopvert - force vertex shaders to be a simple shader that just transforms
+ the vertex position with ftransform() and passes through the color and
+ texcoord[0] attributes.
+<li>nopfrag - force fragment shader to be a simple shader that passes
+ through the color attribute.
+<li>useprog - log glUseProgram calls to stderr
</ul>
<p>
Example: export MESA_GLSL=dump,nopt
diff --git a/progs/Makefile b/progs/Makefile
index c99f4eebcc1..3700707dfb1 100644
--- a/progs/Makefile
+++ b/progs/Makefile
@@ -15,18 +15,22 @@ message:
subdirs:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
- fi \
- done
+ @if test -n "$(SUBDIRS)" ; then \
+ for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE)) || exit 1 ; \
+ fi \
+ done \
+ fi
# Dummy install target
install:
clean:
- -@for dir in $(SUBDIRS) tests ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) clean) ; \
- fi \
- done
+ -@if test -n "$(SUBDIRS)" ; then \
+ for dir in $(SUBDIRS) tests ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE) clean) ; \
+ fi \
+ done \
+ fi
diff --git a/progs/demos/fbo_firecube.c b/progs/demos/fbo_firecube.c
index 4e42924a09e..b3f7e00e5af 100644
--- a/progs/demos/fbo_firecube.c
+++ b/progs/demos/fbo_firecube.c
@@ -938,7 +938,14 @@ reshape(int width, int height)
static void
init_fbotexture()
{
+ static const GLenum depthFormats[] = {
+ GL_DEPTH_COMPONENT,
+ GL_DEPTH_COMPONENT16,
+ GL_DEPTH_COMPONENT32
+ };
+ static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]);
GLint i;
+ GLenum stat;
/* gen framebuffer id, delete it, do some assertions, just for testing */
glGenFramebuffersEXT(1, &MyFB);
@@ -969,18 +976,31 @@ init_fbotexture()
/* make depth renderbuffer */
glGenRenderbuffersEXT(1, &DepthRB);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
- TexWidth, TexHeight);
- CheckError(__LINE__);
+ /* we may have to try several formats */
+ for (i = 0; i < numDepthFormats; i++) {
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i],
+ TexWidth, TexHeight);
+ CheckError(__LINE__);
+
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, DepthRB);
+ CheckError(__LINE__);
+ stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) {
+ break;
+ }
+ }
+
+ if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ fprintf(stderr, "Error: unable to get usable FBO combination!\n");
+ exit(1);
+ }
+
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
- GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
+ GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
CheckError(__LINE__);
printf("Depth renderbuffer size = %d bits\n", i);
- /* attach DepthRB to MyFB */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, DepthRB);
- CheckError(__LINE__);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
/*
diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c
index 0eee9ecf4da..052d0f9e25d 100644
--- a/progs/egl/eglgears.c
+++ b/progs/egl/eglgears.c
@@ -274,10 +274,10 @@ draw(void)
static void
reshape(int width, int height)
{
- glViewport(0, 0, (GLint) width, (GLint) height);
-
GLfloat h = (GLfloat) height / (GLfloat) width;
+ glViewport(0, 0, (GLint) width, (GLint) height);
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
+ GLfloat seconds, fps;
+
while (ct - st < ttr)
{
double tt = current_time();
@@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
- GLfloat seconds = ct - st;
- GLfloat fps = frames / seconds;
+ seconds = ct - st;
+ fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
diff --git a/progs/egl/egltri.c b/progs/egl/egltri.c
index 79f6702007e..9bbc3cddaf1 100644
--- a/progs/egl/egltri.c
+++ b/progs/egl/egltri.c
@@ -127,6 +127,7 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
+ GLfloat seconds, fps;
while (ct - st < ttr)
{
@@ -139,8 +140,8 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
- GLfloat seconds = ct - st;
- GLfloat fps = frames / seconds;
+ seconds = ct - st;
+ fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
diff --git a/progs/egl/peglgears.c b/progs/egl/peglgears.c
index 1ddb691677f..212d1acf692 100644
--- a/progs/egl/peglgears.c
+++ b/progs/egl/peglgears.c
@@ -274,10 +274,10 @@ draw(void)
static void
reshape(int width, int height)
{
- glViewport(0, 0, (GLint) width, (GLint) height);
-
GLfloat h = (GLfloat) height / (GLfloat) width;
+ glViewport(0, 0, (GLint) width, (GLint) height);
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
+ GLfloat seconds, fps;
+
while (ct - st < ttr)
{
double tt = current_time();
@@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
- GLfloat seconds = ct - st;
- GLfloat fps = frames / seconds;
+ seconds = ct - st;
+ fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c
index 72ed0052832..614a6256037 100644
--- a/progs/egl/xeglgears.c
+++ b/progs/egl/xeglgears.c
@@ -95,9 +95,6 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;
-static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
-
-
/*
*
* Draw a gear wheel. You'll probably want to call this function when
@@ -327,122 +324,235 @@ init(void)
}
-/*
- * Create an RGB, double-buffered X window.
- * Return the window and context handles.
- */
-static void
-make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
- const char *name,
- int x, int y, int width, int height,
- Window *winRet,
- EGLContext *ctxRet,
- EGLSurface *surfRet)
-{
- static const EGLint attribs[] = {
- EGL_RED_SIZE, 1,
- EGL_GREEN_SIZE, 1,
- EGL_BLUE_SIZE, 1,
- /*EGL_DOUBLEBUFFER,*/
- EGL_DEPTH_SIZE, 1,
- EGL_NONE
- };
+struct egl_manager {
+ EGLNativeDisplayType xdpy;
+ EGLNativeWindowType xwin;
+ EGLNativePixmapType xpix;
- int scrnum;
- XSetWindowAttributes attr;
- unsigned long mask;
- Window root;
- Window win;
- XVisualInfo *visInfo, visTemplate;
- int num_visuals;
+ EGLDisplay dpy;
+ EGLConfig conf;
EGLContext ctx;
- EGLConfig config;
- EGLint num_configs, vid;
- scrnum = DefaultScreen( x_dpy );
- root = RootWindow( x_dpy, scrnum );
+ EGLSurface win;
+ EGLSurface pix;
+ EGLSurface pbuf;
- if (fullscreen) {
- x = 0; y = 0;
- width = DisplayWidth( x_dpy, scrnum );
- height = DisplayHeight( x_dpy, scrnum );
+ EGLBoolean verbose;
+ EGLint major, minor;
+};
+
+static struct egl_manager *
+egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list,
+ EGLBoolean verbose)
+{
+ struct egl_manager *eman;
+ const char *ver;
+ EGLint num_conf;
+
+ eman = calloc(1, sizeof(*eman));
+ if (!eman)
+ return NULL;
+
+ eman->verbose = verbose;
+ eman->xdpy = xdpy;
+
+ eman->dpy = eglGetDisplay(eman->xdpy);
+ if (eman->dpy == EGL_NO_DISPLAY) {
+ printf("eglGetDisplay() failed\n");
+ free(eman);
+ return NULL;
}
- if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
- printf("Error: couldn't get an EGL visual config\n");
- exit(1);
+ if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) {
+ printf("eglInitialize() failed\n");
+ free(eman);
+ return NULL;
}
- if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
- printf("Error: eglGetConfigAttrib() failed\n");
- exit(1);
+ ver = eglQueryString(eman->dpy, EGL_VERSION);
+ printf("EGL_VERSION = %s\n", ver);
+
+ if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) ||
+ !num_conf) {
+ printf("eglChooseConfig() failed\n");
+ eglTerminate(eman->dpy);
+ free(eman);
+ return NULL;
}
- /* The X window visual must match the EGL config */
- visTemplate.visualid = vid;
- visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
- if (!visInfo) {
- printf("Error: couldn't get X visual\n");
- exit(1);
+ eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL);
+ if (eman->ctx == EGL_NO_CONTEXT) {
+ printf("eglCreateContext() failed\n");
+ eglTerminate(eman->dpy);
+ free(eman);
+ return NULL;
+ }
+
+ return eman;
+}
+
+static EGLBoolean
+egl_manager_create_window(struct egl_manager *eman, const char *name,
+ EGLint w, EGLint h, EGLBoolean need_surface,
+ EGLBoolean fullscreen, const EGLint *attrib_list)
+{
+ XVisualInfo vinfo_template, *vinfo = NULL;
+ EGLint val, num_vinfo;
+ Window root;
+ XSetWindowAttributes attrs;
+ unsigned long mask;
+ EGLint x = 0, y = 0;
+
+ if (!eglGetConfigAttrib(eman->dpy, eman->conf,
+ EGL_NATIVE_VISUAL_ID, &val)) {
+ printf("eglGetConfigAttrib() failed\n");
+ return EGL_FALSE;
+ }
+ if (val) {
+ vinfo_template.visualid = (VisualID) val;
+ vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo);
+ }
+ /* try harder if window surface is not needed */
+ if (!vinfo && !need_surface &&
+ eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) {
+ if (val == 32)
+ val = 24;
+ vinfo_template.depth = val;
+ vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo);
+ }
+
+ if (!vinfo) {
+ printf("XGetVisualInfo() failed\n");
+ return EGL_FALSE;
+ }
+
+ root = DefaultRootWindow(eman->xdpy);
+ if (fullscreen) {
+ x = y = 0;
+ w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy));
+ h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy));
}
/* window attributes */
- attr.background_pixel = 0;
- attr.border_pixel = 0;
- attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
- attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
- attr.override_redirect = fullscreen;
+ attrs.background_pixel = 0;
+ attrs.border_pixel = 0;
+ attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone);
+ attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ attrs.override_redirect = fullscreen;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
- win = XCreateWindow( x_dpy, root, 0, 0, width, height,
- 0, visInfo->depth, InputOutput,
- visInfo->visual, mask, &attr );
+ eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h,
+ 0, vinfo->depth, InputOutput,
+ vinfo->visual, mask, &attrs);
+ XFree(vinfo);
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
- sizehints.width = width;
- sizehints.height = height;
+ sizehints.width = w;
+ sizehints.height = h;
sizehints.flags = USSize | USPosition;
- XSetNormalHints(x_dpy, win, &sizehints);
- XSetStandardProperties(x_dpy, win, name, name,
- None, (char **)NULL, 0, &sizehints);
+ XSetNormalHints(eman->xdpy, eman->xwin, &sizehints);
+ XSetStandardProperties(eman->xdpy, eman->xwin, name, name,
+ None, (char **)NULL, 0, &sizehints);
}
- eglBindAPI(EGL_OPENGL_API);
+ if (need_surface) {
+ eman->win = eglCreateWindowSurface(eman->dpy, eman->conf,
+ eman->xwin, attrib_list);
+ if (eman->win == EGL_NO_SURFACE) {
+ printf("eglCreateWindowSurface() failed\n");
+ XDestroyWindow(eman->xdpy, eman->xwin);
+ eman->xwin = None;
+ return EGL_FALSE;
+ }
+ }
+
+ XMapWindow(eman->xdpy, eman->xwin);
+
+ return EGL_TRUE;
+}
- ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
- if (!ctx) {
- printf("Error: glXCreateContext failed\n");
- exit(1);
+static EGLBoolean
+egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin,
+ EGLBoolean need_surface, const EGLint *attrib_list)
+{
+ XWindowAttributes attrs;
+
+ if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) {
+ printf("XGetWindowAttributes() failed\n");
+ return EGL_FALSE;
+ }
+
+ eman->xpix = XCreatePixmap(eman->xdpy, xwin,
+ attrs.width, attrs.height, attrs.depth);
+
+ if (need_surface) {
+ eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf,
+ eman->xpix, attrib_list);
+ if (eman->pix == EGL_NO_SURFACE) {
+ printf("eglCreatePixmapSurface() failed\n");
+ XFreePixmap(eman->xdpy, eman->xpix);
+ eman->xpix = None;
+ return EGL_FALSE;
+ }
}
- *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
+ return EGL_TRUE;
+}
- XFree(visInfo);
+static EGLBoolean
+egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list)
+{
+ eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list);
+ if (eman->pbuf == EGL_NO_SURFACE) {
+ printf("eglCreatePbufferSurface() failed\n");
+ return EGL_FALSE;
+ }
- *winRet = win;
- *ctxRet = ctx;
+ return EGL_TRUE;
}
+static void
+egl_manager_destroy(struct egl_manager *eman)
+{
+ eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ eglTerminate(eman->dpy);
+
+ if (eman->xwin != None)
+ XDestroyWindow(eman->xdpy, eman->xwin);
+ if (eman->xpix != None)
+ XFreePixmap(eman->xdpy, eman->xpix);
+
+ free(eman);
+}
static void
-event_loop(Display *dpy, Window win,
- EGLDisplay egl_dpy, EGLSurface egl_surf)
+event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
{
+ GC gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL);
+ EGLint orig_w = w, orig_h = h;
+
+ if (surface_type == EGL_PBUFFER_BIT)
+ printf("there will be no screen update if "
+ "eglCopyBuffers() is not implemented\n");
+
while (1) {
- while (XPending(dpy) > 0) {
+ while (XPending(eman->xdpy) > 0) {
XEvent event;
- XNextEvent(dpy, &event);
+ XNextEvent(eman->xdpy, &event);
switch (event.type) {
- case Expose:
+ case Expose:
/* we'll redraw below */
- break;
- case ConfigureNotify:
- reshape(event.xconfigure.width, event.xconfigure.height);
- break;
+ break;
+ case ConfigureNotify:
+ w = event.xconfigure.width;
+ h = event.xconfigure.height;
+ if (surface_type == EGL_WINDOW_BIT)
+ reshape(w, h);
+ break;
case KeyPress:
{
char buffer[10];
@@ -476,6 +586,7 @@ event_loop(Display *dpy, Window win,
static int frames = 0;
static double tRot0 = -1.0, tRate0 = -1.0;
double dt, t = current_time();
+ int x, y;
if (tRot0 < 0.0)
tRot0 = t;
dt = t - tRot0;
@@ -487,7 +598,25 @@ event_loop(Display *dpy, Window win,
angle -= 3600.0;
draw();
- eglSwapBuffers(egl_dpy, egl_surf);
+ switch (surface_type) {
+ case EGL_WINDOW_BIT:
+ eglSwapBuffers(eman->dpy, eman->win);
+ break;
+ case EGL_PBUFFER_BIT:
+ eglWaitClient();
+ if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix))
+ break;
+ /* fall through */
+ case EGL_PIXMAP_BIT:
+ eglWaitClient();
+ for (x = 0; x < w; x += orig_w) {
+ for (y = 0; y < h; y += orig_h) {
+ XCopyArea(eman->xdpy, eman->xpix, eman->xwin, gc,
+ 0, 0, orig_w, orig_h, x, y);
+ }
+ }
+ break;
+ }
frames++;
@@ -503,6 +632,8 @@ event_loop(Display *dpy, Window win,
}
}
}
+
+ XFreeGC(eman->xdpy, gc);
}
@@ -513,6 +644,8 @@ usage(void)
printf(" -display <displayname> set the display to run on\n");
printf(" -fullscreen run in fullscreen mode\n");
printf(" -info display OpenGL renderer info\n");
+ printf(" -pixmap use pixmap surface\n");
+ printf(" -pbuffer use pbuffer surface\n");
}
@@ -521,15 +654,23 @@ main(int argc, char *argv[])
{
const int winWidth = 300, winHeight = 300;
Display *x_dpy;
- Window win;
- EGLSurface egl_surf;
- EGLContext egl_ctx;
- EGLDisplay egl_dpy;
char *dpyName = NULL;
+ struct egl_manager *eman;
+ EGLint attribs[] = {
+ EGL_SURFACE_TYPE, 0, /* filled later */
+ EGL_RED_SIZE, 1,
+ EGL_GREEN_SIZE, 1,
+ EGL_BLUE_SIZE, 1,
+ EGL_DEPTH_SIZE, 1,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+ EGL_NONE
+ };
+ char win_title[] = "xeglgears (window/pixmap/pbuffer)";
+ EGLint surface_type = EGL_WINDOW_BIT;
GLboolean printInfo = GL_FALSE;
- EGLint egl_major, egl_minor;
+ GLboolean fullscreen = GL_FALSE;
+ EGLBoolean ret;
int i;
- const char *s;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0) {
@@ -542,12 +683,21 @@ main(int argc, char *argv[])
else if (strcmp(argv[i], "-fullscreen") == 0) {
fullscreen = GL_TRUE;
}
+ else if (strcmp(argv[i], "-pixmap") == 0) {
+ surface_type = EGL_PIXMAP_BIT;
+ }
+ else if (strcmp(argv[i], "-pbuffer") == 0) {
+ surface_type = EGL_PBUFFER_BIT;
+ }
else {
usage();
return -1;
}
}
+ /* set surface type */
+ attribs[1] = surface_type;
+
x_dpy = XOpenDisplay(dpyName);
if (!x_dpy) {
printf("Error: couldn't open display %s\n",
@@ -555,26 +705,60 @@ main(int argc, char *argv[])
return -1;
}
- egl_dpy = eglGetDisplay(x_dpy);
- if (!egl_dpy) {
- printf("Error: eglGetDisplay() failed\n");
- return -1;
- }
+ eglBindAPI(EGL_OPENGL_API);
- if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
- printf("Error: eglInitialize() failed\n");
+ eman = egl_manager_new(x_dpy, attribs, printInfo);
+ if (!eman) {
+ XCloseDisplay(x_dpy);
return -1;
}
- s = eglQueryString(egl_dpy, EGL_VERSION);
- printf("EGL_VERSION = %s\n", s);
-
- make_x_window(x_dpy, egl_dpy,
- "glxgears", 0, 0, winWidth, winHeight,
- &win, &egl_ctx, &egl_surf);
+ snprintf(win_title, sizeof(win_title), "xeglgears (%s)",
+ (surface_type == EGL_WINDOW_BIT) ? "window" :
+ (surface_type == EGL_PIXMAP_BIT) ? "pixmap" : "pbuffer");
+
+ /* create surface(s) */
+ switch (surface_type) {
+ case EGL_WINDOW_BIT:
+ ret = egl_manager_create_window(eman, win_title, winWidth, winHeight,
+ EGL_TRUE, fullscreen, NULL);
+ if (ret)
+ ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
+ break;
+ case EGL_PIXMAP_BIT:
+ ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
+ EGL_FALSE, fullscreen, NULL) &&
+ egl_manager_create_pixmap(eman, eman->xwin,
+ EGL_TRUE, NULL));
+ if (ret)
+ ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx);
+ break;
+ case EGL_PBUFFER_BIT:
+ {
+ EGLint pbuf_attribs[] = {
+ EGL_WIDTH, winWidth,
+ EGL_HEIGHT, winHeight,
+ EGL_NONE
+ };
+ ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
+ EGL_FALSE, fullscreen, NULL) &&
+ egl_manager_create_pixmap(eman, eman->xwin,
+ EGL_FALSE, NULL) &&
+ egl_manager_create_pbuffer(eman, pbuf_attribs));
+ if (ret)
+ ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx);
+ }
+ break;
+ default:
+ ret = EGL_FALSE;
+ break;
+ }
- XMapWindow(x_dpy, win);
- eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx);
+ if (!ret) {
+ egl_manager_destroy(eman);
+ XCloseDisplay(x_dpy);
+ return -1;
+ }
if (printInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@@ -590,18 +774,13 @@ main(int argc, char *argv[])
*/
reshape(winWidth, winHeight);
- event_loop(x_dpy, win, egl_dpy, egl_surf);
+ event_loop(eman, surface_type, winWidth, winHeight);
glDeleteLists(gear1, 1);
glDeleteLists(gear2, 1);
glDeleteLists(gear3, 1);
- eglDestroyContext(egl_dpy, egl_ctx);
- eglDestroySurface(egl_dpy, egl_surf);
- eglTerminate(egl_dpy);
-
-
- XDestroyWindow(x_dpy, win);
+ egl_manager_destroy(eman);
XCloseDisplay(x_dpy);
return 0;
diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c
index 6c0484df0de..28252a354bf 100644
--- a/progs/tests/arraytexture.c
+++ b/progs/tests/arraytexture.c
@@ -77,10 +77,6 @@ static GLfloat texZ = 0.0;
static GLfloat texZ_dir = 0.01;
static GLint num_layers;
-static PFNGLBINDPROGRAMARBPROC bind_program;
-static PFNGLPROGRAMSTRINGARBPROC program_string;
-static PFNGLGENPROGRAMSARBPROC gen_programs;
-
static void
PrintString(const char *s)
@@ -125,13 +121,13 @@ static void Display(void)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
glColor3f(1,1,1);
glRasterPos3f(-0.9, -0.9, 0.0);
sprintf(str, "Texture Z coordinate = %4.1f", texZ);
PrintString(str);
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 1);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 1);
GL_CHECK_ERROR();
glEnable(GL_TEXTURE_2D_ARRAY_EXT);
GL_CHECK_ERROR();
@@ -159,7 +155,7 @@ static void Display(void)
glDisable(GL_TEXTURE_2D_ARRAY_EXT);
GL_CHECK_ERROR();
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
GL_CHECK_ERROR();
glutSwapBuffers();
@@ -226,8 +222,8 @@ compile_fragment_program(GLuint id, const char *prog)
int err;
err = glGetError();
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, id);
- (*program_string)(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, id);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(prog), (const GLubyte *) prog);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
@@ -264,11 +260,6 @@ static void Init(void)
require_extension("GL_MESA_texture_array");
require_extension("GL_SGIS_generate_mipmap");
- bind_program = glutGetProcAddress("glBindProgramARB");
- program_string = glutGetProcAddress("glProgramStringARB");
- gen_programs = glutGetProcAddress("glGenProgramsARB");
-
-
for (num_layers = 0; textures[num_layers] != NULL; num_layers++)
/* empty */ ;
diff --git a/progs/tests/invert.c b/progs/tests/invert.c
index 63099fbd221..3bc97a460b6 100644
--- a/progs/tests/invert.c
+++ b/progs/tests/invert.c
@@ -128,7 +128,7 @@ static void Init( void )
{
const char * const ver_string = (const char * const)
glGetString( GL_VERSION );
- const float ver = strtof( ver_string, NULL );
+ const float ver = strtod( ver_string, NULL );
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c
index 6dd956c4023..28e3b537acd 100644
--- a/progs/tests/prog_parameter.c
+++ b/progs/tests/prog_parameter.c
@@ -116,7 +116,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param,
for ( i = 0 ; i < (4 * count) ; i++ ) {
- param[i] = (GLfloat) random() / (GLfloat) random();
+ param[i] = (GLfloat) rand() / (GLfloat) rand();
}
/* Try using the "classic" interface.
@@ -153,7 +153,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param,
for ( i = 0 ; i < (4 * count) ; i++ ) {
- param[i] = (GLfloat) random() / (GLfloat) random();
+ param[i] = (GLfloat) rand() / (GLfloat) rand();
}
printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count);
diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c
index 85e39df2dfa..94956a86f33 100644
--- a/progs/trivial/tri-query.c
+++ b/progs/trivial/tri-query.c
@@ -39,6 +39,11 @@ GLenum doubleBuffer;
static void Init(void)
{
+ if (!glutExtensionSupported("GL_ARB_occlusion_query")) {
+ fprintf(stderr, "Sorry, this program requires GL_ARB_occlusion_query\n");
+ exit(1);
+ }
+
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
diff --git a/progs/xdemos/glsync.c b/progs/xdemos/glsync.c
index 34167d339f3..da87306cf2a 100644
--- a/progs/xdemos/glsync.c
+++ b/progs/xdemos/glsync.c
@@ -95,7 +95,7 @@ enum sync_type {
static void usage(char *name)
{
printf("usage: %s [-w <width>] [-h <height>] [-s<sync method>] "
- "[-vc]\n", name);
+ "[-v]\n", name);
printf("\t-s<sync method>:\n");
printf("\t\tn: none\n");
printf("\t\ts: SGI video sync extension\n");
diff --git a/scons/gallium.py b/scons/gallium.py
index 38782ac7266..34877b2f8b3 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -263,7 +263,10 @@ def generate(env):
if msvc and env['toolchain'] != 'winddk':
cppdefines += [
'VC_EXTRALEAN',
+ '_CRT_SECURE_NO_WARNINGS',
'_CRT_SECURE_NO_DEPRECATE',
+ '_SCL_SECURE_NO_WARNINGS',
+ '_SCL_SECURE_NO_DEPRECATE',
]
if debug:
cppdefines += ['_DEBUG']
@@ -343,10 +346,18 @@ def generate(env):
ccflags += [
'-m32',
#'-march=pentium4',
- '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
- '-mstackrealign', # ensure stack is aligned -- do not enabled -msse without it!
#'-mfpmath=sse',
]
+ if platform != 'windows':
+ # XXX: -mstackrealign causes stack corruption on MinGW. Ditto
+ # for -mincoming-stack-boundary=2. Still enable it on other
+ # platforms for now, but we can't rely on it for cross platform
+ # code. We have to use __attribute__((force_align_arg_pointer))
+ # instead.
+ ccflags += [
+ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ '-mstackrealign', # ensure stack is aligned
+ ]
if env['machine'] == 'x86_64':
ccflags += ['-m64']
# See also:
diff --git a/scons/llvm.py b/scons/llvm.py
index d3293bb404f..73e9310f71b 100644
--- a/scons/llvm.py
+++ b/scons/llvm.py
@@ -29,6 +29,7 @@ Tool-specific initialization for LLVM
import os
import os.path
+import sys
import SCons.Errors
import SCons.Util
@@ -39,7 +40,7 @@ def generate(env):
llvm_dir = os.environ['LLVM']
except KeyError:
# Do nothing -- use the system headers/libs
- pass
+ llvm_dir = None
else:
if not os.path.isdir(llvm_dir):
raise SCons.Errors.InternalError, "Specified LLVM directory not found"
@@ -57,7 +58,47 @@ def generate(env):
env.PrependENVPath('PATH', llvm_bin_dir)
- if env.Detect('llvm-config'):
+ if env['msvc']:
+ # XXX: There is no llvm-config on Windows, so assume a standard layout
+ if llvm_dir is not None:
+ env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
+ env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
+ env.Prepend(LIBS = [
+ 'LLVMBitWriter',
+ 'LLVMCore',
+ 'LLVMSupport',
+ 'LLVMSystem',
+ 'LLVMSupport',
+ 'LLVMSystem',
+ 'LLVMCore',
+ 'LLVMCodeGen',
+ 'LLVMSelectionDAG',
+ 'LLVMAsmPrinter',
+ 'LLVMBitReader',
+ 'LLVMBitWriter',
+ 'LLVMTransformUtils',
+ 'LLVMInstrumentation',
+ 'LLVMScalarOpts',
+ 'LLVMipo',
+ 'LLVMHello',
+ 'LLVMLinker',
+ 'LLVMAnalysis',
+ 'LLVMipa',
+ 'LLVMX86CodeGen',
+ 'LLVMX86AsmPrinter',
+ 'LLVMExecutionEngine',
+ 'LLVMInterpreter',
+ 'LLVMJIT',
+ 'LLVMTarget',
+ 'LLVMAsmParser',
+ 'LLVMDebugger',
+ 'LLVMArchive',
+ 'imagehlp',
+ 'psapi',
+ ])
+ env['LLVM_VERSION'] = '2.5'
+ return
+ elif env.Detect('llvm-config'):
version = env.backtick('llvm-config --version').rstrip()
try:
diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index 4685f600e29..96292b0e9e8 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -33,23 +33,12 @@
* Authors: Alan Hourihane <alanh@tungstengraphics.com>
*/
-/*
- * TODO:
- *
- * test eglBind/ReleaseTexImage
- */
-
-
-#include <assert.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "dlfcn.h"
+#include <stdlib.h>
+#include <string.h>
#include <X11/Xlib.h>
-#include <GL/gl.h>
-#include "glxclient.h"
+#include <GL/glx.h>
+#include "eglconfigutil.h"
#include "eglconfig.h"
#include "eglcontext.h"
#include "egldisplay.h"
@@ -58,46 +47,19 @@
#include "egllog.h"
#include "eglsurface.h"
-#include <GL/gl.h>
-
#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-static const EGLint all_apis = (EGL_OPENGL_ES_BIT
- | EGL_OPENGL_ES2_BIT
- | EGL_OPENVG_BIT
- /* | EGL_OPENGL_BIT */); /* can't do */
+#ifndef GLX_VERSION_1_4
+#error "GL/glx.h must be equal to or greater than GLX 1.4"
+#endif
+
+/*
+ * report OpenGL ES bits because apps usually forget to specify
+ * EGL_RENDERABLE_TYPE when choosing configs
+ */
+#define GLX_EGL_APIS (EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)
-struct visual_attribs
-{
- /* X visual attribs */
- int id;
- int klass;
- int depth;
- int redMask, greenMask, blueMask;
- int colormapSize;
- int bitsPerRGB;
-
- /* GL visual attribs */
- int supportsGL;
- int transparentType;
- int transparentRedValue;
- int transparentGreenValue;
- int transparentBlueValue;
- int transparentAlphaValue;
- int transparentIndexValue;
- int bufferSize;
- int level;
- int render_type;
- int doubleBuffer;
- int stereo;
- int auxBuffers;
- int redSize, greenSize, blueSize, alphaSize;
- int depthSize;
- int stencilSize;
- int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
- int numSamples, numMultisample;
- int visualCaveat;
-};
/** subclass of _EGLDriver */
struct GLX_egl_driver
@@ -114,6 +76,21 @@ struct GLX_egl_display
GLXFBConfig *fbconfigs;
int glx_maj, glx_min;
+
+ const char *extensions;
+ EGLBoolean have_1_3;
+ EGLBoolean have_make_current_read;
+ EGLBoolean have_fbconfig;
+ EGLBoolean have_pbuffer;
+
+ /* GLX_SGIX_pbuffer */
+ PFNGLXCREATEGLXPBUFFERSGIXPROC glXCreateGLXPbufferSGIX;
+ PFNGLXDESTROYGLXPBUFFERSGIXPROC glXDestroyGLXPbufferSGIX;
+
+ /* workaround quirks of different GLX implementations */
+ EGLBoolean single_buffered_quirk;
+ EGLBoolean glx_window_quirk;
+
};
@@ -131,7 +108,8 @@ struct GLX_egl_surface
{
_EGLSurface Base; /**< base class */
- GLXDrawable drawable;
+ Drawable drawable;
+ GLXDrawable glx_drawable;
};
@@ -139,6 +117,7 @@ struct GLX_egl_surface
struct GLX_egl_config
{
_EGLConfig Base; /**< base class */
+ EGLBoolean double_buffered;
int index;
};
@@ -173,288 +152,369 @@ GLX_egl_config_index(_EGLConfig *conf)
return ((struct GLX_egl_config *) conf)->index;
}
-static GLboolean
-get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
- struct visual_attribs *attribs)
-{
- const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
- int rgba;
- memset(attribs, 0, sizeof(struct visual_attribs));
+#define MAP_ATTRIB(attr, memb) \
+ { attr, offsetof(__GLcontextModes, memb) }
+
+
+static const struct {
+ int attr;
+ int offset;
+} fbconfig_attributes[] = {
+ /* table 3.1 of GLX 1.4 */
+ MAP_ATTRIB(GLX_FBCONFIG_ID, fbconfigID),
+ MAP_ATTRIB(GLX_BUFFER_SIZE, rgbBits),
+ MAP_ATTRIB(GLX_LEVEL, level),
+ MAP_ATTRIB(GLX_DOUBLEBUFFER, doubleBufferMode),
+ MAP_ATTRIB(GLX_STEREO, stereoMode),
+ MAP_ATTRIB(GLX_AUX_BUFFERS, numAuxBuffers),
+ MAP_ATTRIB(GLX_RED_SIZE, redBits),
+ MAP_ATTRIB(GLX_GREEN_SIZE, greenBits),
+ MAP_ATTRIB(GLX_BLUE_SIZE, blueBits),
+ MAP_ATTRIB(GLX_ALPHA_SIZE, alphaBits),
+ MAP_ATTRIB(GLX_DEPTH_SIZE, depthBits),
+ MAP_ATTRIB(GLX_STENCIL_SIZE, stencilBits),
+ MAP_ATTRIB(GLX_ACCUM_RED_SIZE, accumRedBits),
+ MAP_ATTRIB(GLX_ACCUM_GREEN_SIZE, accumGreenBits),
+ MAP_ATTRIB(GLX_ACCUM_BLUE_SIZE, accumBlueBits),
+ MAP_ATTRIB(GLX_ACCUM_ALPHA_SIZE, accumAlphaBits),
+ MAP_ATTRIB(GLX_SAMPLE_BUFFERS, sampleBuffers),
+ MAP_ATTRIB(GLX_SAMPLES, samples),
+ MAP_ATTRIB(GLX_RENDER_TYPE, renderType),
+ MAP_ATTRIB(GLX_DRAWABLE_TYPE, drawableType),
+ MAP_ATTRIB(GLX_X_RENDERABLE, xRenderable),
+ MAP_ATTRIB(GLX_X_VISUAL_TYPE, visualType),
+ MAP_ATTRIB(GLX_CONFIG_CAVEAT, visualRating),
+ MAP_ATTRIB(GLX_TRANSPARENT_TYPE, transparentPixel),
+ MAP_ATTRIB(GLX_TRANSPARENT_INDEX_VALUE, transparentIndex),
+ MAP_ATTRIB(GLX_TRANSPARENT_RED_VALUE, transparentRed),
+ MAP_ATTRIB(GLX_TRANSPARENT_GREEN_VALUE, transparentGreen),
+ MAP_ATTRIB(GLX_TRANSPARENT_BLUE_VALUE, transparentBlue),
+ MAP_ATTRIB(GLX_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
+ MAP_ATTRIB(GLX_MAX_PBUFFER_WIDTH, maxPbufferWidth),
+ MAP_ATTRIB(GLX_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
+ MAP_ATTRIB(GLX_MAX_PBUFFER_PIXELS, maxPbufferPixels),
+ MAP_ATTRIB(GLX_VISUAL_ID, visualID),
+};
- attribs->id = vInfo->visualid;
-#if defined(__cplusplus) || defined(c_plusplus)
- attribs->klass = vInfo->c_class;
-#else
- attribs->klass = vInfo->class;
-#endif
- attribs->depth = vInfo->depth;
- attribs->redMask = vInfo->red_mask;
- attribs->greenMask = vInfo->green_mask;
- attribs->blueMask = vInfo->blue_mask;
- attribs->colormapSize = vInfo->colormap_size;
- attribs->bitsPerRGB = vInfo->bits_per_rgb;
-
- if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 ||
- !attribs->supportsGL)
- return GL_FALSE;
- glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
- glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
- glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba);
- if (!rgba)
- return GL_FALSE;
- attribs->render_type = GLX_RGBA_BIT;
-
- glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
- if (!attribs->doubleBuffer)
- return GL_FALSE;
-
- glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
- glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
- glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize);
- glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize);
- glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize);
- glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize);
- glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize);
- glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize);
- glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
- glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
- glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
- glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
-
- /* get transparent pixel stuff */
- glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
- if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
- glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
- glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
- glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
- glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
- }
- else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
- glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
- }
-
- /* multisample attribs */
-#ifdef GLX_ARB_multisample
- if (ext && strstr(ext, "GLX_ARB_multisample")) {
- glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample);
- glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples);
- }
-#endif
- else {
- attribs->numSamples = 0;
- attribs->numMultisample = 0;
- }
-#if defined(GLX_EXT_visual_rating)
- if (ext && strstr(ext, "GLX_EXT_visual_rating")) {
- glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat);
- }
- else {
- attribs->visualCaveat = GLX_NONE_EXT;
+static EGLBoolean
+convert_fbconfig(Display *dpy, GLXFBConfig fbconfig,
+ struct GLX_egl_config *GLX_conf)
+{
+ __GLcontextModes mode;
+ int err = 0, attr, val, i;
+
+ memset(&mode, 0, sizeof(mode));
+
+ for (i = 0; i < ARRAY_SIZE(fbconfig_attributes); i++) {
+ int offset = fbconfig_attributes[i].offset;
+ attr = fbconfig_attributes[i].attr;
+ err = glXGetFBConfigAttrib(dpy, fbconfig, attr, &val);
+ if (err) {
+ if (err == GLX_BAD_ATTRIBUTE) {
+ err = 0;
+ continue;
+ }
+ break;
+ }
+ *((int *) ((char *) &mode + offset)) = val;
}
-#else
- attribs->visualCaveat = 0;
-#endif
-
- return GL_TRUE;
-}
+ if (err)
+ return EGL_FALSE;
-#ifdef GLX_VERSION_1_3
+ /* must have rgba bit */
+ if (!(mode.renderType & GLX_RGBA_BIT))
+ return EGL_FALSE;
-static int
-glx_token_to_visual_class(int visual_type)
-{
- switch (visual_type) {
- case GLX_TRUE_COLOR:
- return TrueColor;
- case GLX_DIRECT_COLOR:
- return DirectColor;
- case GLX_PSEUDO_COLOR:
- return PseudoColor;
- case GLX_STATIC_COLOR:
- return StaticColor;
- case GLX_GRAY_SCALE:
- return GrayScale;
- case GLX_STATIC_GRAY:
- return StaticGray;
- case GLX_NONE:
- default:
- return None;
+ /* pixmap and pbuffer surfaces must be single-buffered in EGL */
+ if (mode.doubleBufferMode) {
+ mode.drawableType &= ~(GLX_PIXMAP_BIT | GLX_PBUFFER_BIT);
+ if (!mode.drawableType)
+ return EGL_FALSE;
}
+
+ mode.rgbMode = GL_TRUE;
+ mode.haveAccumBuffer = (mode.accumRedBits +
+ mode.accumGreenBits +
+ mode.accumBlueBits +
+ mode.accumAlphaBits > 0);
+ mode.haveDepthBuffer = (mode.depthBits > 0);
+ mode.haveStencilBuffer = (mode.stencilBits > 0);
+
+ GLX_conf->double_buffered = (mode.doubleBufferMode != 0);
+ return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode,
+ GLX_EGL_APIS, GLX_EGL_APIS);
}
-static int
-get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
- struct visual_attribs *attribs)
-{
- int visual_type;
- int fbconfig_id;
- memset(attribs, 0, sizeof(struct visual_attribs));
+static const struct {
+ int attr;
+ int offset;
+} visual_attributes[] = {
+ /* table 3.7 of GLX 1.4 */
+ /* no GLX_USE_GL */
+ MAP_ATTRIB(GLX_BUFFER_SIZE, rgbBits),
+ MAP_ATTRIB(GLX_LEVEL, level),
+ MAP_ATTRIB(GLX_RGBA, rgbMode),
+ MAP_ATTRIB(GLX_DOUBLEBUFFER, doubleBufferMode),
+ MAP_ATTRIB(GLX_STEREO, stereoMode),
+ MAP_ATTRIB(GLX_AUX_BUFFERS, numAuxBuffers),
+ MAP_ATTRIB(GLX_RED_SIZE, redBits),
+ MAP_ATTRIB(GLX_GREEN_SIZE, greenBits),
+ MAP_ATTRIB(GLX_BLUE_SIZE, blueBits),
+ MAP_ATTRIB(GLX_ALPHA_SIZE, alphaBits),
+ MAP_ATTRIB(GLX_DEPTH_SIZE, depthBits),
+ MAP_ATTRIB(GLX_STENCIL_SIZE, stencilBits),
+ MAP_ATTRIB(GLX_ACCUM_RED_SIZE, accumRedBits),
+ MAP_ATTRIB(GLX_ACCUM_GREEN_SIZE, accumGreenBits),
+ MAP_ATTRIB(GLX_ACCUM_BLUE_SIZE, accumBlueBits),
+ MAP_ATTRIB(GLX_ACCUM_ALPHA_SIZE, accumAlphaBits),
+ MAP_ATTRIB(GLX_SAMPLE_BUFFERS, sampleBuffers),
+ MAP_ATTRIB(GLX_SAMPLES, samples),
+ MAP_ATTRIB(GLX_FBCONFIG_ID, fbconfigID),
+ /* GLX_EXT_visual_rating */
+ MAP_ATTRIB(GLX_VISUAL_CAVEAT_EXT, visualRating),
+};
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &fbconfig_id);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_VISUAL_ID, &attribs->id);
+static int
+get_visual_type(const XVisualInfo *vis)
+{
+ int klass;
-#if 0
- attribs->depth = vInfo->depth;
- attribs->redMask = vInfo->red_mask;
- attribs->greenMask = vInfo->green_mask;
- attribs->blueMask = vInfo->blue_mask;
- attribs->colormapSize = vInfo->colormap_size;
- attribs->bitsPerRGB = vInfo->bits_per_rgb;
+#if defined(__cplusplus) || defined(c_plusplus)
+ klass = vis->c_class;
+#else
+ klass = vis->class;
#endif
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type);
- attribs->klass = glx_token_to_visual_class(visual_type);
+ switch (klass) {
+ case TrueColor:
+ return GLX_TRUE_COLOR;
+ case DirectColor:
+ return GLX_DIRECT_COLOR;
+ case PseudoColor:
+ return GLX_PSEUDO_COLOR;
+ case StaticColor:
+ return GLX_STATIC_COLOR;
+ case GrayScale:
+ return GLX_GRAY_SCALE;
+ case StaticGray:
+ return GLX_STATIC_GRAY;
+ default:
+ return GLX_NONE;
+ }
+}
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type);
- if (!(attribs->render_type & GLX_RGBA_BIT))
- return 0;
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
- if (!attribs->doubleBuffer)
- return 0;
+static EGLBoolean
+convert_visual(Display *dpy, XVisualInfo *vinfo,
+ struct GLX_egl_config *GLX_conf)
+{
+ __GLcontextModes mode;
+ int err, attr, val, i;
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers);
+ /* the visual must support OpenGL */
+ err = glXGetConfig(dpy, vinfo, GLX_USE_GL, &val);
+ if (err || !val)
+ return EGL_FALSE;
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize);
+ memset(&mode, 0, sizeof(mode));
+
+ for (i = 0; i < ARRAY_SIZE(visual_attributes); i++) {
+ int offset = visual_attributes[i].offset;
+ attr = visual_attributes[i].attr;
+ err = glXGetConfig(dpy, vinfo, attr, &val);
+ if (err) {
+ if (err == GLX_BAD_ATTRIBUTE) {
+ err = 0;
+ continue;
+ }
+ break;
+ }
+ *((int *) ((char *) &mode + offset)) = val;
+ }
+ if (err)
+ return EGL_FALSE;
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
+ /* must be RGB mode */
+ if (!mode.rgbMode)
+ return EGL_FALSE;
- /* get transparent pixel stuff */
- glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
- if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
- }
- else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
- }
+ mode.visualID = vinfo->visualid;
+ mode.visualType = get_visual_type(vinfo);
+ mode.redMask = vinfo->red_mask;
+ mode.greenMask = vinfo->green_mask;
+ mode.blueMask = vinfo->blue_mask;
+
+ mode.drawableType = GLX_WINDOW_BIT;
+ /* pixmap surfaces must be single-buffered in EGL */
+ if (!mode.doubleBufferMode)
+ mode.drawableType |= GLX_PIXMAP_BIT;
+
+ mode.renderType = GLX_RGBA_BIT;
+ mode.xRenderable = GL_TRUE;
+ mode.haveAccumBuffer = (mode.accumRedBits +
+ mode.accumGreenBits +
+ mode.accumBlueBits +
+ mode.accumAlphaBits > 0);
+ mode.haveDepthBuffer = (mode.depthBits > 0);
+ mode.haveStencilBuffer = (mode.stencilBits > 0);
+
+ GLX_conf->double_buffered = (mode.doubleBufferMode != 0);
+ return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode,
+ GLX_EGL_APIS, GLX_EGL_APIS);
+}
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples);
- glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat);
+static void
+fix_config(struct GLX_egl_display *GLX_dpy, struct GLX_egl_config *GLX_conf)
+{
+ _EGLConfig *conf = &GLX_conf->Base;
+ EGLint surface_type, r, g, b, a;
+
+ surface_type = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE);
+ if (!GLX_conf->double_buffered && GLX_dpy->single_buffered_quirk) {
+ /* some GLX impls do not like single-buffered window surface */
+ surface_type &= ~EGL_WINDOW_BIT;
+ /* pbuffer bit is usually not set */
+ if (GLX_dpy->have_pbuffer)
+ surface_type |= EGL_PBUFFER_BIT;
+ SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, surface_type);
+ }
- if (attribs->id == 0) {
- attribs->id = fbconfig_id;
- return EGL_PBUFFER_BIT | EGL_PIXMAP_BIT;
+ /* no visual attribs unless window bit is set */
+ if (!(surface_type & EGL_WINDOW_BIT)) {
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, 0);
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
}
- return EGL_WINDOW_BIT;
+ /* make sure buffer size is set correctly */
+ r = GET_CONFIG_ATTRIB(conf, EGL_RED_SIZE);
+ g = GET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE);
+ b = GET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE);
+ a = GET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE);
+ SET_CONFIG_ATTRIB(conf, EGL_BUFFER_SIZE, r + g + b + a);
}
-#endif
static EGLBoolean
-create_configs(_EGLDisplay *disp, struct GLX_egl_display *GLX_dpy)
+create_configs(_EGLDisplay *dpy, struct GLX_egl_display *GLX_dpy,
+ EGLint screen)
{
- XVisualInfo theTemplate;
- int numVisuals;
- long mask;
- int i;
- struct visual_attribs attribs;
+ EGLint num_configs = 0, i;
+ EGLint id = 1;
- GLX_dpy->fbconfigs = NULL;
-
-#ifdef GLX_VERSION_1_3
- /* get list of all fbconfigs on this screen */
- GLX_dpy->fbconfigs = glXGetFBConfigs(GLX_dpy->dpy, DefaultScreen(GLX_dpy->dpy), &numVisuals);
+ if (GLX_dpy->have_fbconfig) {
+ GLX_dpy->fbconfigs = glXGetFBConfigs(GLX_dpy->dpy, screen, &num_configs);
+ }
+ else {
+ XVisualInfo vinfo_template;
+ long mask;
- if (numVisuals == 0) {
- GLX_dpy->fbconfigs = NULL;
- goto xvisual;
+ vinfo_template.screen = screen;
+ mask = VisualScreenMask;
+ GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &vinfo_template,
+ &num_configs);
}
- for (i = 0; i < numVisuals; i++) {
- struct GLX_egl_config *config;
- int bit;
+ if (!num_configs)
+ return EGL_FALSE;
- bit = get_fbconfig_attribs(GLX_dpy->dpy, GLX_dpy->fbconfigs[i], &attribs);
- if (!bit)
+ for (i = 0; i < num_configs; i++) {
+ struct GLX_egl_config *GLX_conf, template;
+ EGLBoolean ok;
+
+ memset(&template, 0, sizeof(template));
+ _eglInitConfig(&template.Base, id);
+ if (GLX_dpy->have_fbconfig)
+ ok = convert_fbconfig(GLX_dpy->dpy, GLX_dpy->fbconfigs[i], &template);
+ else
+ ok = convert_visual(GLX_dpy->dpy, &GLX_dpy->visuals[i], &template);
+ if (!ok)
+ continue;
+
+ fix_config(GLX_dpy, &template);
+ if (!_eglValidateConfig(&template.Base, EGL_FALSE)) {
+ _eglLog(_EGL_DEBUG, "GLX: failed to validate config %d", i);
continue;
+ }
- config = CALLOC_STRUCT(GLX_egl_config);
-
- config->index = i;
- _eglInitConfig(&config->Base, (i+1));
- SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id);
- SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, attribs.greenSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, attribs.blueSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, attribs.alphaSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, attribs.depthSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, attribs.stencilSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, attribs.numSamples);
- SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample);
- SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis);
- SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis);
- SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, bit);
-
- /* XXX possibly other things to init... */
+ GLX_conf = CALLOC_STRUCT(GLX_egl_config);
+ if (GLX_conf) {
+ memcpy(GLX_conf, &template, sizeof(template));
+ GLX_conf->index = i;
- _eglAddConfig(disp, &config->Base);
+ _eglAddConfig(dpy, &GLX_conf->Base);
+ id++;
+ }
}
- goto end;
-#endif
-
-xvisual:
- /* get list of all visuals on this screen */
- theTemplate.screen = DefaultScreen(GLX_dpy->dpy);
- mask = VisualScreenMask;
- GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &theTemplate, &numVisuals);
+ return EGL_TRUE;
+}
- for (i = 0; i < numVisuals; i++) {
- struct GLX_egl_config *config;
- if (!get_visual_attribs(GLX_dpy->dpy, &GLX_dpy->visuals[i], &attribs))
- continue;
+static void
+check_extensions(struct GLX_egl_display *GLX_dpy, EGLint screen)
+{
+ GLX_dpy->extensions =
+ glXQueryExtensionsString(GLX_dpy->dpy, screen);
+ if (GLX_dpy->extensions) {
+ /* glXGetProcAddress is assumed */
+
+ if (strstr(GLX_dpy->extensions, "GLX_SGI_make_current_read")) {
+ /* GLX 1.3 entry points are used */
+ GLX_dpy->have_make_current_read = EGL_TRUE;
+ }
- config = CALLOC_STRUCT(GLX_egl_config);
+ if (strstr(GLX_dpy->extensions, "GLX_SGIX_fbconfig")) {
+ /* GLX 1.3 entry points are used */
+ GLX_dpy->have_fbconfig = EGL_TRUE;
+ }
- config->index = i;
- _eglInitConfig(&config->Base, (i+1));
- SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id);
- SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, attribs.greenSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, attribs.blueSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, attribs.alphaSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, attribs.depthSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, attribs.stencilSize);
- SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, attribs.numSamples);
- SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample);
- SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis);
- SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis);
- SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE,
- (EGL_WINDOW_BIT /*| EGL_PBUFFER_BIT | EGL_PIXMAP_BIT*/));
+ if (strstr(GLX_dpy->extensions, "GLX_SGIX_pbuffer")) {
+ GLX_dpy->glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)
+ glXGetProcAddress((const GLubyte *) "glXCreateGLXPbufferSGIX");
+ GLX_dpy->glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)
+ glXGetProcAddress((const GLubyte *) "glXDestroyGLXPbufferSGIX");
- /* XXX possibly other things to init... */
+ if (GLX_dpy->glXCreateGLXPbufferSGIX &&
+ GLX_dpy->glXDestroyGLXPbufferSGIX &&
+ GLX_dpy->have_fbconfig)
+ GLX_dpy->have_pbuffer = EGL_TRUE;
+ }
+ }
- _eglAddConfig(disp, &config->Base);
+ if (GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3) {
+ GLX_dpy->have_1_3 = EGL_TRUE;
+ GLX_dpy->have_make_current_read = EGL_TRUE;
+ GLX_dpy->have_fbconfig = EGL_TRUE;
+ GLX_dpy->have_pbuffer = EGL_TRUE;
}
+}
-end:
- return EGL_TRUE;
+
+static void
+check_quirks(struct GLX_egl_display *GLX_dpy, EGLint screen)
+{
+ const char *vendor;
+
+ GLX_dpy->single_buffered_quirk = EGL_TRUE;
+ GLX_dpy->glx_window_quirk = EGL_TRUE;
+
+ vendor = glXGetClientString(GLX_dpy->dpy, GLX_VENDOR);
+ if (vendor && strstr(vendor, "NVIDIA")) {
+ vendor = glXQueryServerString(GLX_dpy->dpy, screen, GLX_VENDOR);
+ if (vendor && strstr(vendor, "NVIDIA")) {
+ _eglLog(_EGL_DEBUG, "disable quirks");
+ GLX_dpy->single_buffered_quirk = EGL_FALSE;
+ GLX_dpy->glx_window_quirk = EGL_FALSE;
+ }
+ }
}
+
/**
* Called via eglInitialize(), GLX_drv->API.Initialize().
*/
@@ -478,17 +538,33 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp,
}
}
- disp->DriverData = (void *) GLX_dpy;
- disp->ClientAPIsMask = all_apis;
+ if (!glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min)) {
+ _eglLog(_EGL_WARNING, "GLX: glXQueryVersion failed");
+ if (!disp->NativeDisplay)
+ XCloseDisplay(GLX_dpy->dpy);
+ free(GLX_dpy);
+ return EGL_FALSE;
+ }
- glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min);
+ check_extensions(GLX_dpy, DefaultScreen(GLX_dpy->dpy));
+ check_quirks(GLX_dpy, DefaultScreen(GLX_dpy->dpy));
+
+ create_configs(disp, GLX_dpy, DefaultScreen(GLX_dpy->dpy));
+ if (!disp->NumConfigs) {
+ _eglLog(_EGL_WARNING, "GLX: failed to create any config");
+ if (!disp->NativeDisplay)
+ XCloseDisplay(GLX_dpy->dpy);
+ free(GLX_dpy);
+ return EGL_FALSE;
+ }
+
+ disp->DriverData = (void *) GLX_dpy;
+ disp->ClientAPIsMask = GLX_EGL_APIS;
/* we're supporting EGL 1.4 */
*major = 1;
*minor = 4;
- create_configs(disp, GLX_dpy);
-
return EGL_TRUE;
}
@@ -539,8 +615,7 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return NULL;
}
-#ifdef GLX_VERSION_1_3
- if (GLX_dpy->fbconfigs)
+ if (GLX_dpy->have_fbconfig)
GLX_ctx->context =
glXCreateNewContext(GLX_dpy->dpy,
GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
@@ -548,7 +623,6 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
GLX_ctx_shared ? GLX_ctx_shared->context : NULL,
GL_TRUE);
else
-#endif
GLX_ctx->context =
glXCreateContext(GLX_dpy->dpy,
&GLX_dpy->visuals[GLX_egl_config_index(conf)],
@@ -559,15 +633,6 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return NULL;
}
-#if 1
- /* (maybe?) need to have a direct rendering context */
- if (!glXIsDirect(GLX_dpy->dpy, GLX_ctx->context)) {
- glXDestroyContext(GLX_dpy->dpy, GLX_ctx->context);
- free(GLX_ctx);
- return NULL;
- }
-#endif
-
return &GLX_ctx->Base;
}
@@ -589,17 +654,14 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
if (!_eglMakeCurrent(drv, disp, dsurf, rsurf, ctx))
return EGL_FALSE;
- ddraw = (GLX_dsurf) ? GLX_dsurf->drawable : None;
- rdraw = (GLX_rsurf) ? GLX_rsurf->drawable : None;
+ ddraw = (GLX_dsurf) ? GLX_dsurf->glx_drawable : None;
+ rdraw = (GLX_rsurf) ? GLX_rsurf->glx_drawable : None;
cctx = (GLX_ctx) ? GLX_ctx->context : NULL;
-#ifdef GLX_VERSION_1_3
- if (glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx))
- return EGL_TRUE;
-#endif
-
- if (ddraw == rdraw && glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx))
- return EGL_TRUE;
+ if (GLX_dpy->have_make_current_read)
+ return glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx);
+ else if (ddraw == rdraw)
+ return glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx);
return EGL_FALSE;
}
@@ -642,6 +704,20 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
}
GLX_surf->drawable = window;
+
+ if (GLX_dpy->have_1_3 && !GLX_dpy->glx_window_quirk)
+ GLX_surf->glx_drawable =
+ glXCreateWindow(GLX_dpy->dpy,
+ GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+ GLX_surf->drawable, NULL);
+ else
+ GLX_surf->glx_drawable = GLX_surf->drawable;
+
+ if (!GLX_surf->glx_drawable) {
+ free(GLX_surf);
+ return NULL;
+ }
+
get_drawable_size(GLX_dpy->dpy, window, &width, &height);
GLX_surf->Base.Width = width;
GLX_surf->Base.Height = height;
@@ -649,18 +725,13 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return &GLX_surf->Base;
}
-#ifdef GLX_VERSION_1_3
static _EGLSurface *
GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
NativePixmapType pixmap, const EGLint *attrib_list)
{
struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
struct GLX_egl_surface *GLX_surf;
- int i;
-
- /* GLX must >= 1.3 */
- if (!(GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3))
- return NULL;
+ uint width, height;
GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
if (!GLX_surf) {
@@ -674,25 +745,39 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return NULL;
}
- for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
- switch (attrib_list[i]) {
- /* no attribs at this time */
- default:
- _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface");
- free(GLX_surf);
- return NULL;
+ GLX_surf->drawable = pixmap;
+
+ if (GLX_dpy->have_1_3) {
+ GLX_surf->glx_drawable =
+ glXCreatePixmap(GLX_dpy->dpy,
+ GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+ GLX_surf->drawable, NULL);
+ }
+ else if (GLX_dpy->have_fbconfig) {
+ GLXFBConfig fbconfig = GLX_dpy->fbconfigs[GLX_egl_config_index(conf)];
+ XVisualInfo *vinfo = glXGetVisualFromFBConfig(GLX_dpy->dpy, fbconfig);
+ if (vinfo) {
+ GLX_surf->glx_drawable =
+ glXCreateGLXPixmap(GLX_dpy->dpy, vinfo, GLX_surf->drawable);
+ XFree(vinfo);
}
}
+ else {
+ GLX_surf->glx_drawable =
+ glXCreateGLXPixmap(GLX_dpy->dpy,
+ &GLX_dpy->visuals[GLX_egl_config_index(conf)],
+ GLX_surf->drawable);
+ }
- GLX_surf->drawable =
- glXCreatePixmap(GLX_dpy->dpy,
- GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
- pixmap, NULL);
- if (!GLX_surf->drawable) {
+ if (!GLX_surf->glx_drawable) {
free(GLX_surf);
return NULL;
}
+ get_drawable_size(GLX_dpy->dpy, pixmap, &width, &height);
+ GLX_surf->Base.Width = width;
+ GLX_surf->Base.Height = height;
+
return &GLX_surf->Base;
}
@@ -703,11 +788,7 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
struct GLX_egl_surface *GLX_surf;
int attribs[5];
- int i = 0, j = 0;
-
- /* GLX must >= 1.3 */
- if (!(GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3))
- return NULL;
+ int i;
GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
if (!GLX_surf) {
@@ -721,33 +802,44 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
return NULL;
}
- while(attrib_list[i] != EGL_NONE) {
- switch (attrib_list[i]) {
- case EGL_WIDTH:
- attribs[j++] = GLX_PBUFFER_WIDTH;
- attribs[j++] = attrib_list[i+1];
- break;
- case EGL_HEIGHT:
- attribs[j++] = GLX_PBUFFER_HEIGHT;
- attribs[j++] = attrib_list[i+1];
- break;
+ i = 0;
+ attribs[i] = None;
+
+ GLX_surf->drawable = None;
+
+ if (GLX_dpy->have_1_3) {
+ /* put geometry in attribs */
+ if (GLX_surf->Base.Width) {
+ attribs[i++] = GLX_PBUFFER_WIDTH;
+ attribs[i++] = GLX_surf->Base.Width;
+ }
+ if (GLX_surf->Base.Height) {
+ attribs[i++] = GLX_PBUFFER_HEIGHT;
+ attribs[i++] = GLX_surf->Base.Height;
}
- i++;
+ attribs[i] = None;
+
+ GLX_surf->glx_drawable =
+ glXCreatePbuffer(GLX_dpy->dpy,
+ GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+ attribs);
+ }
+ else if (GLX_dpy->have_pbuffer) {
+ GLX_surf->glx_drawable = GLX_dpy->glXCreateGLXPbufferSGIX(
+ GLX_dpy->dpy,
+ GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
+ GLX_surf->Base.Width,
+ GLX_surf->Base.Height,
+ attribs);
}
- attribs[j++] = 0;
- GLX_surf->drawable =
- glXCreatePbuffer(GLX_dpy->dpy,
- GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
- attribs);
- if (!GLX_surf->drawable) {
+ if (!GLX_surf->glx_drawable) {
free(GLX_surf);
return NULL;
}
return &GLX_surf->Base;
}
-#endif
static EGLBoolean
GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
@@ -755,15 +847,35 @@ GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
if (!_eglIsSurfaceBound(surf)) {
struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
- switch (surf->Type) {
- case EGL_PBUFFER_BIT:
- glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->drawable);
- break;
- case EGL_PIXMAP_BIT:
- glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->drawable);
- break;
- default:
- break;
+
+ if (GLX_dpy->have_1_3) {
+ switch (surf->Type) {
+ case EGL_WINDOW_BIT:
+ if (!GLX_dpy->glx_window_quirk)
+ glXDestroyWindow(GLX_dpy->dpy, GLX_surf->glx_drawable);
+ break;
+ case EGL_PBUFFER_BIT:
+ glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->glx_drawable);
+ break;
+ case EGL_PIXMAP_BIT:
+ glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable);
+ break;
+ default:
+ break;
+ }
+ }
+ else {
+ switch (surf->Type) {
+ case EGL_PBUFFER_BIT:
+ GLX_dpy->glXDestroyGLXPbufferSGIX(GLX_dpy->dpy,
+ GLX_surf->glx_drawable);
+ break;
+ case EGL_PIXMAP_BIT:
+ glXDestroyGLXPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable);
+ break;
+ default:
+ break;
+ }
}
free(surf);
}
@@ -773,44 +885,12 @@ GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
static EGLBoolean
-GLX_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
- EGLint buffer)
-{
- struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
- struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
-
- /* buffer ?? */
- glXBindTexImageEXT(GLX_dpy->dpy, GLX_surf->drawable,
- GLX_FRONT_LEFT_EXT, NULL);
-
- return EGL_TRUE;
-}
-
-
-static EGLBoolean
-GLX_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
- EGLint buffer)
-{
- struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
- struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
-
- /* buffer ?? */
- glXReleaseTexImageEXT(GLX_dpy->dpy, GLX_surf->drawable,
- GLX_FRONT_LEFT_EXT);
-
- return EGL_TRUE;
-}
-
-
-static EGLBoolean
GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
struct GLX_egl_surface *GLX_surf = GLX_egl_surface(draw);
- _eglLog(_EGL_DEBUG, "GLX: EGL SwapBuffers 0x%x",draw);
-
- glXSwapBuffers(GLX_dpy->dpy, GLX_surf->drawable);
+ glXSwapBuffers(GLX_dpy->dpy, GLX_surf->glx_drawable);
return EGL_TRUE;
}
@@ -821,23 +901,24 @@ GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
static _EGLProc
GLX_eglGetProcAddress(const char *procname)
{
- /* This is a bit of a hack to get at the gallium/Mesa state tracker
- * function st_get_proc_address(). This will probably change at
- * some point.
- */
- _EGLProc (*get_proc_addr)(const char *procname);
- _EGLProc proc_addr;
- get_proc_addr = dlsym(NULL, "st_get_proc_address");
- if (get_proc_addr)
- return get_proc_addr(procname);
-
- proc_addr = glXGetProcAddress((const GLubyte *)procname);
- if (proc_addr)
- return proc_addr;
-
- return (_EGLProc)dlsym(NULL, procname);
+ return (_EGLProc) glXGetProcAddress((const GLubyte *) procname);
}
+static EGLBoolean
+GLX_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
+{
+ glXWaitGL();
+ return EGL_TRUE;
+}
+
+static EGLBoolean
+GLX_eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
+{
+ if (engine != EGL_CORE_NATIVE_ENGINE)
+ return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
+ glXWaitX();
+ return EGL_TRUE;
+}
static void
GLX_Unload(_EGLDriver *drv)
@@ -865,15 +946,13 @@ _eglMain(const char *args)
GLX_drv->Base.API.CreateContext = GLX_eglCreateContext;
GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent;
GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface;
-#ifdef GLX_VERSION_1_3
GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface;
GLX_drv->Base.API.CreatePbufferSurface = GLX_eglCreatePbufferSurface;
-#endif
GLX_drv->Base.API.DestroySurface = GLX_eglDestroySurface;
- GLX_drv->Base.API.BindTexImage = GLX_eglBindTexImage;
- GLX_drv->Base.API.ReleaseTexImage = GLX_eglReleaseTexImage;
GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers;
GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress;
+ GLX_drv->Base.API.WaitClient = GLX_eglWaitClient;
+ GLX_drv->Base.API.WaitNative = GLX_eglWaitNative;
GLX_drv->Base.Name = "GLX";
GLX_drv->Base.Unload = GLX_Unload;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index d86ef9ce562..14cc5fa6137 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -9,12 +9,36 @@
* heterogeneous hardware devices in the future.
*
* The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are
- * opaque handles implemented with 32-bit unsigned integers.
- * It's up to the driver function or fallback function to look up the
- * handle and get an object.
- * By using opaque handles, we leave open the possibility of having
- * indirect rendering in the future, like GLX.
+ * opaque handles. Internal objects are linked to a display to
+ * create the handles.
*
+ * For each public API entry point, the opaque handles are looked up
+ * before being dispatched to the drivers. When it fails to look up
+ * a handle, one of
+ *
+ * EGL_BAD_DISPLAY
+ * EGL_BAD_CONFIG
+ * EGL_BAD_CONTEXT
+ * EGL_BAD_SURFACE
+ * EGL_BAD_SCREEN_MESA
+ * EGL_BAD_MODE_MESA
+ *
+ * is generated and the driver function is not called. An
+ * uninitialized EGLDisplay has no driver associated with it. When
+ * such display is detected,
+ *
+ * EGL_NOT_INITIALIZED
+ *
+ * is generated.
+ *
+ * Some of the entry points use current display, context, or surface
+ * implicitly. For such entry points, the implicit objects are also
+ * checked before calling the driver function. Other than the
+ * errors listed above,
+ *
+ * EGL_BAD_CURRENT_SURFACE
+ *
+ * may also be generated.
*
* Notes on naming conventions:
*
@@ -496,15 +520,31 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
EGLBoolean EGLAPIENTRY
eglSwapInterval(EGLDisplay dpy, EGLint interval)
{
+ _EGLContext *ctx = _eglGetCurrentContext();
+ _EGLSurface *surf;
_EGL_DECLARE_DD(dpy);
- return drv->API.SwapInterval(drv, disp, interval);
+
+ if (!ctx || !_eglIsContextLinked(ctx) || ctx->Display != disp)
+ return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
+
+ surf = ctx->DrawSurface;
+ if (!_eglIsSurfaceLinked(surf))
+ return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
+
+ return drv->API.SwapInterval(drv, disp, surf, interval);
}
EGLBoolean EGLAPIENTRY
eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
{
+ _EGLContext *ctx = _eglGetCurrentContext();
_EGL_DECLARE_DD_AND_SURFACE(dpy, surface);
+
+ /* surface must be bound to current context in EGL 1.4 */
+ if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
+ return _eglError(EGL_BAD_SURFACE, __FUNCTION__);
+
return drv->API.SwapBuffers(drv, disp, surf);
}
@@ -518,32 +558,66 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target)
EGLBoolean EGLAPIENTRY
-eglWaitGL(void)
+eglWaitClient(void)
{
- _EGLDisplay *disp = _eglGetCurrentDisplay();
+ _EGLContext *ctx = _eglGetCurrentContext();
+ _EGLDisplay *disp;
_EGLDriver *drv;
- if (!disp)
+ if (!ctx)
return EGL_TRUE;
+ /* let bad current context imply bad current surface */
+ if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
+ return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
- /* a current display is always initialized */
+ /* a valid current context implies an initialized current display */
+ disp = ctx->Display;
drv = disp->Driver;
+ assert(drv);
- return drv->API.WaitGL(drv, disp);
+ return drv->API.WaitClient(drv, disp, ctx);
+}
+
+
+EGLBoolean EGLAPIENTRY
+eglWaitGL(void)
+{
+#ifdef EGL_VERSION_1_2
+ _EGLThreadInfo *t = _eglGetCurrentThread();
+ EGLint api_index = t->CurrentAPIIndex;
+ EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API);
+ EGLBoolean ret;
+
+ if (api_index != es_index && _eglIsCurrentThreadDummy())
+ return _eglError(EGL_BAD_ALLOC, "eglWaitGL");
+
+ t->CurrentAPIIndex = es_index;
+ ret = eglWaitClient();
+ t->CurrentAPIIndex = api_index;
+ return ret;
+#else
+ return eglWaitClient();
+#endif
}
EGLBoolean EGLAPIENTRY
eglWaitNative(EGLint engine)
{
- _EGLDisplay *disp = _eglGetCurrentDisplay();
+ _EGLContext *ctx = _eglGetCurrentContext();
+ _EGLDisplay *disp;
_EGLDriver *drv;
- if (!disp)
+ if (!ctx)
return EGL_TRUE;
+ /* let bad current context imply bad current surface */
+ if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
+ return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
- /* a current display is always initialized */
+ /* a valid current context implies an initialized current display */
+ disp = ctx->Display;
drv = disp->Driver;
+ assert(drv);
return drv->API.WaitNative(drv, disp, engine);
}
@@ -568,8 +642,26 @@ eglGetCurrentContext(void)
EGLSurface EGLAPIENTRY
eglGetCurrentSurface(EGLint readdraw)
{
- _EGLSurface *s = _eglGetCurrentSurface(readdraw);
- return _eglGetSurfaceHandle(s);
+ _EGLContext *ctx = _eglGetCurrentContext();
+ _EGLSurface *surf;
+
+ if (!ctx)
+ return EGL_NO_SURFACE;
+
+ switch (readdraw) {
+ case EGL_DRAW:
+ surf = ctx->DrawSurface;
+ break;
+ case EGL_READ:
+ surf = ctx->ReadSurface;
+ break;
+ default:
+ _eglError(EGL_BAD_PARAMETER, __FUNCTION__);
+ surf = NULL;
+ break;
+ }
+
+ return _eglGetSurfaceHandle(surf);
}
@@ -900,20 +992,4 @@ eglReleaseThread(void)
}
-EGLBoolean
-eglWaitClient(void)
-{
- _EGLDisplay *disp = _eglGetCurrentDisplay();
- _EGLDriver *drv;
-
- if (!disp)
- return EGL_TRUE;
-
- /* a current display is always initialized */
- drv = disp->Driver;
-
- return drv->API.WaitClient(drv, disp);
-}
-
-
#endif /* EGL_VERSION_1_2 */
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 6081e588928..aa0abe3eb6b 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -35,13 +35,13 @@ typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurf
typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint value);
typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
-typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval);
+typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, NativePixmapType target);
/* misc funcs */
typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name);
-typedef EGLBoolean (*WaitGL_t)(_EGLDriver *drv, _EGLDisplay *dpy);
+typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine);
typedef _EGLProc (*GetProcAddress_t)(const char *procname);
@@ -65,7 +65,6 @@ typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy,
#ifdef EGL_VERSION_1_2
-typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy);
typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list);
#endif /* EGL_VERSION_1_2 */
@@ -101,7 +100,7 @@ struct _egl_api
CopyBuffers_t CopyBuffers;
QueryString_t QueryString;
- WaitGL_t WaitGL;
+ WaitClient_t WaitClient;
WaitNative_t WaitNative;
GetProcAddress_t GetProcAddress;
@@ -120,7 +119,6 @@ struct _egl_api
QueryModeStringMESA_t QueryModeStringMESA;
#ifdef EGL_VERSION_1_2
- WaitClient_t WaitClient;
CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer;
#endif
};
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 2c8d1c4055b..31d69a77080 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -82,18 +82,17 @@ _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf)
EGLBoolean
_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
{
- _EGLConfig *conf = NULL;
+ EGLint num_configs = (dpy) ? dpy->NumConfigs : 0;
EGLint i;
- for (i = 0; dpy && i < dpy->NumConfigs; i++) {
- conf = dpy->Configs[i];
+ for (i = 0; i < num_configs; i++) {
+ _EGLConfig *conf = dpy->Configs[i];
if (conf == (_EGLConfig *) config) {
assert(conf->Display == dpy);
break;
}
}
-
- return (conf != NULL);
+ return (i < num_configs);
}
diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c
index a5fcdcd2876..36e94f0d2de 100644
--- a/src/egl/main/eglconfigutil.c
+++ b/src/egl/main/eglconfigutil.c
@@ -102,7 +102,12 @@ _eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m,
SET_CONFIG_ATTRIB(conf, EGL_NATIVE_RENDERABLE, m->xRenderable);
SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, m->visualID);
- SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType);
+
+ if (m->visualType != GLX_NONE)
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType);
+ else
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
+
SET_CONFIG_ATTRIB(conf, EGL_RENDERABLE_TYPE, renderable_type);
SET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS, m->sampleBuffers);
SET_CONFIG_ATTRIB(conf, EGL_SAMPLES, m->samples);
diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h
index ad850798908..8c923ee206a 100644
--- a/src/egl/main/eglconfigutil.h
+++ b/src/egl/main/eglconfigutil.h
@@ -2,7 +2,7 @@
#define EGLCONFIGUTIL_INCLUDED
-#include "GLES/gl.h"
+#include "GL/gl.h"
#include "GL/internal/glcore.h"
#include "eglconfig.h"
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index ca7a0771681..df506151b58 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -16,7 +16,7 @@ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
#ifdef GLX_USE_TLS
-static __thread const _EGLThreadInfo *_egl_TSD;
+static __thread const _EGLThreadInfo *_egl_TSD
__attribute__ ((tls_model("initial-exec")));
static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 0c76c799738..018b06d3bea 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -408,7 +408,7 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
drv->API.CopyBuffers = _eglCopyBuffers;
drv->API.QueryString = _eglQueryString;
- drv->API.WaitGL = _eglWaitGL;
+ drv->API.WaitClient = _eglWaitClient;
drv->API.WaitNative = _eglWaitNative;
#ifdef EGL_MESA_screen_surface
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index b37213faf10..e66913320b2 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -108,11 +108,12 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name)
EGLBoolean
-_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy)
+_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
{
/* just a placeholder */
(void) drv;
(void) dpy;
+ (void) ctx;
return EGL_TRUE;
}
diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h
index a15c839be2b..829d4cde792 100644
--- a/src/egl/main/eglmisc.h
+++ b/src/egl/main/eglmisc.h
@@ -37,7 +37,7 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name);
extern EGLBoolean
-_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy);
+_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
extern EGLBoolean
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index e7a1a8329e1..940a1b760cf 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -15,6 +15,22 @@
#include "eglsurface.h"
+static void
+_eglClampSwapInterval(_EGLSurface *surf, EGLint interval)
+{
+ EGLint bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MAX_SWAP_INTERVAL);
+ if (interval >= bound) {
+ interval = bound;
+ }
+ else {
+ bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MIN_SWAP_INTERVAL);
+ if (interval < bound)
+ interval = bound;
+ }
+ surf->SwapInterval = interval;
+}
+
+
/**
* Do error check on parameters and initialize the given _EGLSurface object.
* \return EGL_TRUE if no errors, EGL_FALSE otherwise.
@@ -194,7 +210,9 @@ _eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type,
surf->TextureTarget = texTarget;
surf->MipmapTexture = mipmapTex;
surf->MipmapLevel = 0;
- surf->SwapInterval = 0;
+ /* the default swap interval is 1 */
+ _eglClampSwapInterval(surf, 1);
+
#ifdef EGL_VERSION_1_2
surf->SwapBehavior = EGL_BUFFER_DESTROYED; /* XXX ok? */
surf->HorizontalResolution = EGL_UNKNOWN; /* set by caller */
@@ -466,11 +484,10 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
EGLBoolean
-_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval)
+_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+ EGLint interval)
{
- _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW);
- if (surf)
- surf->SwapInterval = interval;
+ _eglClampSwapInterval(surf, interval);
return EGL_TRUE;
}
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index f6d44b5922e..b75fa9c3686 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -86,7 +86,7 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint
extern EGLBoolean
-_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval);
+_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
#ifdef EGL_VERSION_1_2
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index fb00c3abe8b..50386425995 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -46,6 +46,7 @@
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "util/u_surface.h"
+#include "util/u_rect.h"
#include "cso_cache/cso_context.h"
@@ -301,7 +302,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
* no overlapping.
* Filter mode should not matter since there's no stretching.
*/
- if (dst->format == src->format &&
+ if (pipe->surface_copy &&
+ dst->format == src->format &&
srcX0 < srcX1 &&
dstX0 < dstX1 &&
srcY0 < srcY1 &&
@@ -365,10 +367,17 @@ util_blit_pixels_writemask(struct blit_state *ctx,
PIPE_BUFFER_USAGE_GPU_WRITE);
/* load temp texture */
- pipe->surface_copy(pipe,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
+ if (pipe->surface_copy) {
+ pipe->surface_copy(pipe,
+ texSurf, 0, 0, /* dest */
+ src, srcLeft, srcTop, /* src */
+ srcW, srcH); /* size */
+ } else {
+ util_surface_copy(pipe, FALSE,
+ texSurf, 0, 0, /* dest */
+ src, srcLeft, srcTop, /* src */
+ srcW, srcH); /* size */
+ }
/* free the surface, update the texture if necessary.
*/
diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h
index 7c16b32cf9f..1e65a035aed 100644
--- a/src/gallium/auxiliary/util/u_clear.h
+++ b/src/gallium/auxiliary/util/u_clear.h
@@ -32,6 +32,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_pack_color.h"
+#include "util/u_rect.h"
/**
@@ -48,13 +49,22 @@ util_clear(struct pipe_context *pipe,
unsigned color;
util_pack_color(rgba, ps->format, &color);
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+ if (pipe->surface_fill) {
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+ } else {
+ util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+ }
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *ps = framebuffer->zsbuf;
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
- util_pack_z_stencil(ps->format, depth, stencil));
+ if (pipe->surface_fill) {
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+ util_pack_z_stencil(ps->format, depth, stencil));
+ } else {
+ util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+ util_pack_z_stencil(ps->format, depth, stencil));
+ }
}
}
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
index ded361ce704..c93e0db23c3 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -131,7 +131,7 @@ win32_sig_handler_sse(EXCEPTION_POINTERS* ep)
#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_DARWIN)
-static sigjmp_buf __lv_powerpc_jmpbuf;
+static jmp_buf __lv_powerpc_jmpbuf;
static volatile sig_atomic_t __lv_powerpc_canjump = 0;
static void
@@ -143,9 +143,11 @@ sigill_handler(int sig)
}
__lv_powerpc_canjump = 0;
- siglongjmp(__lv_powerpc_jmpbuf, 1);
+ longjmp(__lv_powerpc_jmpbuf, 1);
}
+#endif
+#if defined(PIPE_ARCH_PPC)
static void
check_os_altivec_support(void)
{
@@ -166,7 +168,7 @@ check_os_altivec_support(void)
/* no Darwin, do it the brute-force way */
/* this is borrowed from the libmpeg2 library */
signal(SIGILL, sigill_handler);
- if (sigsetjmp(__lv_powerpc_jmpbuf, 1)) {
+ if (setjmp(__lv_powerpc_jmpbuf)) {
signal(SIGILL, SIG_DFL);
} else {
__lv_powerpc_canjump = 1;
@@ -180,9 +182,9 @@ check_os_altivec_support(void)
signal(SIGILL, SIG_DFL);
util_cpu_caps.has_altivec = 1;
}
-#endif
+#endif /* PIPE_OS_DARWIN */
}
-#endif
+#endif /* PIPE_ARCH_PPC */
/* If we're running on a processor that can do SSE, let's see if we
* are allowed to or not. This will catch 2.4.0 or later kernels that
@@ -190,6 +192,7 @@ check_os_altivec_support(void)
* and RedHat patched 2.2 kernels that have broken exception handling
* support for user space apps that do SSE.
*/
+#if defined(PIPE_ARCH_X86) || defined (PIPE_ARCH_X86_64)
static void
check_os_katmai_support(void)
{
@@ -370,6 +373,7 @@ cpuid(uint32_t ax, uint32_t *p)
return ret;
}
+#endif /* X86 or X86_64 */
void
util_cpu_detect(void)
@@ -390,19 +394,26 @@ util_cpu_detect(void)
util_cpu_caps.arch = UTIL_CPU_ARCH_SPARC;
#elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
util_cpu_caps.arch = UTIL_CPU_ARCH_X86;
+ util_cpu_caps.little_endian = 1;
#elif defined(PIPE_ARCH_PPC)
util_cpu_caps.arch = UTIL_CPU_ARCH_POWERPC;
+ util_cpu_caps.little_endian = 0;
#else
util_cpu_caps.arch = UTIL_CPU_ARCH_UNKNOWN;
#endif
/* Count the number of CPUs in system */
-#if !defined(PIPE_OS_WINDOWS) && !defined(PIPE_OS_UNKNOWN) && defined(_SC_NPROCESSORS_ONLN)
+#if defined(PIPE_OS_WINDOWS)
+ {
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ util_cpu_caps.nr_cpus = system_info.dwNumberOfProcessors;
+ }
+#elif defined(PIPE_OS_UNIX) && defined(_SC_NPROCESSORS_ONLN)
util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
if (util_cpu_caps.nr_cpus == -1)
util_cpu_caps.nr_cpus = 1;
-
-#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_OPENBSD)
+#elif defined(PIPE_OS_BSD)
{
int mib[2], ncpu;
int len;
@@ -469,7 +480,6 @@ util_cpu_detect(void)
util_cpu_caps.cacheline = regs2[2] & 0xFF;
}
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_NETBSD) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_OPENBSD)
if (util_cpu_caps.has_sse)
check_os_katmai_support();
@@ -477,13 +487,8 @@ util_cpu_detect(void)
util_cpu_caps.has_sse2 = 0;
util_cpu_caps.has_sse3 = 0;
util_cpu_caps.has_ssse3 = 0;
+ util_cpu_caps.has_sse4_1 = 0;
}
-#else
- util_cpu_caps.has_sse = 0;
- util_cpu_caps.has_sse2 = 0;
- util_cpu_caps.has_sse3 = 0;
- util_cpu_caps.has_ssse3 = 0;
-#endif
}
#endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h
index 7ea0121c07f..4b3dc39c342 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.h
+++ b/src/gallium/auxiliary/util/u_cpu_detect.h
@@ -54,6 +54,8 @@ struct util_cpu_caps {
int x86_cpu_type;
unsigned cacheline;
+ unsigned little_endian:1;
+
unsigned has_tsc:1;
unsigned has_mmx:1;
unsigned has_mmx2:1;
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c
index 8c2a8f454cc..5604e3ac374 100644
--- a/src/gallium/auxiliary/util/u_hash_table.c
+++ b/src/gallium/auxiliary/util/u_hash_table.c
@@ -47,7 +47,7 @@
#include "util/u_hash_table.h"
-struct hash_table
+struct util_hash_table
{
struct cso_hash *cso;
@@ -61,27 +61,27 @@ struct hash_table
};
-struct hash_table_item
+struct util_hash_table_item
{
void *key;
void *value;
};
-static INLINE struct hash_table_item *
-hash_table_item(struct cso_hash_iter iter)
+static INLINE struct util_hash_table_item *
+util_hash_table_item(struct cso_hash_iter iter)
{
- return (struct hash_table_item *)cso_hash_iter_data(iter);
+ return (struct util_hash_table_item *)cso_hash_iter_data(iter);
}
-struct hash_table *
-hash_table_create(unsigned (*hash)(void *key),
- int (*compare)(void *key1, void *key2))
+struct util_hash_table *
+util_hash_table_create(unsigned (*hash)(void *key),
+ int (*compare)(void *key1, void *key2))
{
- struct hash_table *ht;
+ struct util_hash_table *ht;
- ht = MALLOC_STRUCT(hash_table);
+ ht = MALLOC_STRUCT(util_hash_table);
if(!ht)
return NULL;
@@ -99,16 +99,16 @@ hash_table_create(unsigned (*hash)(void *key),
static INLINE struct cso_hash_iter
-hash_table_find_iter(struct hash_table *ht,
- void *key,
- unsigned key_hash)
+util_hash_table_find_iter(struct util_hash_table *ht,
+ void *key,
+ unsigned key_hash)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
iter = cso_hash_find(ht->cso, key_hash);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
if (!ht->compare(item->key, key))
break;
iter = cso_hash_iter_next(iter);
@@ -118,17 +118,17 @@ hash_table_find_iter(struct hash_table *ht,
}
-static INLINE struct hash_table_item *
-hash_table_find_item(struct hash_table *ht,
- void *key,
- unsigned key_hash)
+static INLINE struct util_hash_table_item *
+util_hash_table_find_item(struct util_hash_table *ht,
+ void *key,
+ unsigned key_hash)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
iter = cso_hash_find(ht->cso, key_hash);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
if (!ht->compare(item->key, key))
return item;
iter = cso_hash_iter_next(iter);
@@ -139,12 +139,12 @@ hash_table_find_item(struct hash_table *ht,
enum pipe_error
-hash_table_set(struct hash_table *ht,
- void *key,
- void *value)
+util_hash_table_set(struct util_hash_table *ht,
+ void *key,
+ void *value)
{
unsigned key_hash;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
struct cso_hash_iter iter;
assert(ht);
@@ -153,14 +153,14 @@ hash_table_set(struct hash_table *ht,
key_hash = ht->hash(key);
- item = hash_table_find_item(ht, key, key_hash);
+ item = util_hash_table_find_item(ht, key, key_hash);
if(item) {
/* TODO: key/value destruction? */
item->value = value;
return PIPE_OK;
}
- item = MALLOC_STRUCT(hash_table_item);
+ item = MALLOC_STRUCT(util_hash_table_item);
if(!item)
return PIPE_ERROR_OUT_OF_MEMORY;
@@ -178,11 +178,11 @@ hash_table_set(struct hash_table *ht,
void *
-hash_table_get(struct hash_table *ht,
- void *key)
+util_hash_table_get(struct util_hash_table *ht,
+ void *key)
{
unsigned key_hash;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -190,7 +190,7 @@ hash_table_get(struct hash_table *ht,
key_hash = ht->hash(key);
- item = hash_table_find_item(ht, key, key_hash);
+ item = util_hash_table_find_item(ht, key, key_hash);
if(!item)
return NULL;
@@ -199,12 +199,12 @@ hash_table_get(struct hash_table *ht,
void
-hash_table_remove(struct hash_table *ht,
- void *key)
+util_hash_table_remove(struct util_hash_table *ht,
+ void *key)
{
unsigned key_hash;
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -212,11 +212,11 @@ hash_table_remove(struct hash_table *ht,
key_hash = ht->hash(key);
- iter = hash_table_find_iter(ht, key, key_hash);
+ iter = util_hash_table_find_iter(ht, key, key_hash);
if(cso_hash_iter_is_null(iter))
return;
- item = hash_table_item(iter);
+ item = util_hash_table_item(iter);
assert(item);
FREE(item);
@@ -225,10 +225,10 @@ hash_table_remove(struct hash_table *ht,
void
-hash_table_clear(struct hash_table *ht)
+util_hash_table_clear(struct util_hash_table *ht)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -236,7 +236,7 @@ hash_table_clear(struct hash_table *ht)
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter));
+ item = (struct util_hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter));
FREE(item);
iter = cso_hash_first_node(ht->cso);
}
@@ -244,12 +244,13 @@ hash_table_clear(struct hash_table *ht)
enum pipe_error
-hash_table_foreach(struct hash_table *ht,
- enum pipe_error (*callback)(void *key, void *value, void *data),
- void *data)
+util_hash_table_foreach(struct util_hash_table *ht,
+ enum pipe_error (*callback)
+ (void *key, void *value, void *data),
+ void *data)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
enum pipe_error result;
assert(ht);
@@ -258,7 +259,7 @@ hash_table_foreach(struct hash_table *ht,
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
result = callback(item->key, item->value, data);
if(result != PIPE_OK)
return result;
@@ -270,10 +271,10 @@ hash_table_foreach(struct hash_table *ht,
void
-hash_table_destroy(struct hash_table *ht)
+util_hash_table_destroy(struct util_hash_table *ht)
{
struct cso_hash_iter iter;
- struct hash_table_item *item;
+ struct util_hash_table_item *item;
assert(ht);
if (!ht)
@@ -281,7 +282,7 @@ hash_table_destroy(struct hash_table *ht)
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
- item = (struct hash_table_item *)cso_hash_iter_data(iter);
+ item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
FREE(item);
iter = cso_hash_iter_next(iter);
}
diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h
index feee881582e..258a31aec8a 100644
--- a/src/gallium/auxiliary/util/u_hash_table.h
+++ b/src/gallium/auxiliary/util/u_hash_table.h
@@ -46,7 +46,7 @@ extern "C" {
/**
* Generic purpose hash table.
*/
-struct hash_table;
+struct util_hash_table;
/**
@@ -55,37 +55,38 @@ struct hash_table;
* @param hash hash function
* @param compare should return 0 for two equal keys.
*/
-struct hash_table *
-hash_table_create(unsigned (*hash)(void *key),
- int (*compare)(void *key1, void *key2));
+struct util_hash_table *
+util_hash_table_create(unsigned (*hash)(void *key),
+ int (*compare)(void *key1, void *key2));
enum pipe_error
-hash_table_set(struct hash_table *ht,
- void *key,
- void *value);
+util_hash_table_set(struct util_hash_table *ht,
+ void *key,
+ void *value);
void *
-hash_table_get(struct hash_table *ht,
- void *key);
+util_hash_table_get(struct util_hash_table *ht,
+ void *key);
void
-hash_table_remove(struct hash_table *ht,
- void *key);
+util_hash_table_remove(struct util_hash_table *ht,
+ void *key);
void
-hash_table_clear(struct hash_table *ht);
+util_hash_table_clear(struct util_hash_table *ht);
enum pipe_error
-hash_table_foreach(struct hash_table *ht,
- enum pipe_error (*callback)(void *key, void *value, void *data),
- void *data);
+util_hash_table_foreach(struct util_hash_table *ht,
+ enum pipe_error (*callback)
+ (void *key, void *value, void *data),
+ void *data);
void
-hash_table_destroy(struct hash_table *ht);
+util_hash_table_destroy(struct util_hash_table *ht);
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/util/u_keymap.c b/src/gallium/auxiliary/util/u_keymap.c
index 508a2ee0634..f856395ca92 100644
--- a/src/gallium/auxiliary/util/u_keymap.c
+++ b/src/gallium/auxiliary/util/u_keymap.c
@@ -28,7 +28,7 @@
/**
* Key lookup/associative container.
*
- * Like Jose's u_hash_table, based on CSO cache code for now.
+ * Like Jose's util_hash_table, based on CSO cache code for now.
*
* Author: Brian Paul
*/
diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fp.c b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
index 312621fd534..b6b2f885af5 100644
--- a/src/gallium/drivers/cell/ppu/cell_gen_fp.c
+++ b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
@@ -674,7 +674,7 @@ emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst)
* Emit linear interpolate. See emit_ADD for comments.
*/
static boolean
-emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst)
+emit_LRP(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4], tmp_reg[4];
@@ -1766,7 +1766,7 @@ emit_instruction(struct codegen *gen,
return emit_binop(gen, inst);
case TGSI_OPCODE_MAD:
return emit_MAD(gen, inst);
- case TGSI_OPCODE_LERP:
+ case TGSI_OPCODE_LRP:
return emit_LRP(gen, inst);
case TGSI_OPCODE_DP3:
return emit_DP3(gen, inst);
diff --git a/src/gallium/drivers/i915/i915_debug.c b/src/gallium/drivers/i915/i915_debug.c
index ce92d1af9a7..e6640e587b4 100644
--- a/src/gallium/drivers/i915/i915_debug.c
+++ b/src/gallium/drivers/i915/i915_debug.c
@@ -880,7 +880,7 @@ i915_dump_batchbuffer( struct intel_batchbuffer *batch )
return;
}
- debug_printf( "\n\nBATCH: (%d)\n", bytes / 4);
+ debug_printf( "\n\nBATCH: (%d)\n", (int)bytes / 4);
while (!done &&
stream.offset < bytes)
diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c
index 89504ced276..1fe5cda9563 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -127,7 +127,7 @@ i915_program_error(struct i915_fp_compile *p, const char *msg, ...)
va_start( args, msg );
util_vsnprintf( buffer, sizeof(buffer), msg, args );
va_end( args );
- debug_printf(buffer);
+ debug_printf("%s", buffer);
debug_printf("\n");
p->error = 1;
diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile
index 21aff1967a1..b96ee23a993 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -21,6 +21,7 @@ C_SOURCES = \
lp_bld_interp.c \
lp_bld_intr.c \
lp_bld_logic.c \
+ lp_bld_pack.c \
lp_bld_sample_soa.c \
lp_bld_swizzle.c \
lp_bld_struct.c \
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index 13cd465838a..403e4daa436 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -33,6 +33,7 @@ llvmpipe = env.ConvenienceLibrary(
'lp_bld_format_soa.c',
'lp_bld_interp.c',
'lp_bld_intr.c',
+ 'lp_bld_pack.c',
'lp_bld_sample_soa.c',
'lp_bld_struct.c',
'lp_bld_logic.c',
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
index d27ef0de041..83ca06acf86 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
@@ -54,6 +54,7 @@
#include "lp_bld_const.h"
#include "lp_bld_intr.h"
#include "lp_bld_logic.h"
+#include "lp_bld_pack.h"
#include "lp_bld_debug.h"
#include "lp_bld_arit.h"
@@ -280,45 +281,6 @@ lp_build_sub(struct lp_build_context *bld,
/**
- * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
- */
-static LLVMValueRef
-lp_build_unpack_shuffle(unsigned n, unsigned lo_hi)
-{
- LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
- unsigned i, j;
-
- assert(n <= LP_MAX_VECTOR_LENGTH);
- assert(lo_hi < 2);
-
- for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) {
- elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0);
- elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0);
- }
-
- return LLVMConstVector(elems, n);
-}
-
-
-/**
- * Build constant int vector of width 'n' and value 'c'.
- */
-static LLVMValueRef
-lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c)
-{
- LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
- unsigned i;
-
- assert(n <= LP_MAX_VECTOR_LENGTH);
-
- for(i = 0; i < n; ++i)
- elems[i] = LLVMConstInt(type, c, 0);
-
- return LLVMConstVector(elems, n);
-}
-
-
-/**
* Normalized 8bit multiplication.
*
* - alpha plus one
@@ -361,33 +323,30 @@ lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c)
*/
static LLVMValueRef
lp_build_mul_u8n(LLVMBuilderRef builder,
+ struct lp_type i16_type,
LLVMValueRef a, LLVMValueRef b)
{
- static LLVMValueRef c01 = NULL;
- static LLVMValueRef c08 = NULL;
- static LLVMValueRef c80 = NULL;
+ LLVMValueRef c8;
LLVMValueRef ab;
- if(!c01) c01 = lp_build_const_vec(LLVMInt16Type(), 8, 0x01);
- if(!c08) c08 = lp_build_const_vec(LLVMInt16Type(), 8, 0x08);
- if(!c80) c80 = lp_build_const_vec(LLVMInt16Type(), 8, 0x80);
+ c8 = lp_build_int_const_scalar(i16_type, 8);
#if 0
/* a*b/255 ~= (a*(b + 1)) >> 256 */
- b = LLVMBuildAdd(builder, b, c01, "");
+ b = LLVMBuildAdd(builder, b, lp_build_int_const_scalar(i16_type, 1), "");
ab = LLVMBuildMul(builder, a, b, "");
#else
- /* t/255 ~= (t + (t >> 8) + 0x80) >> 8 */
+ /* ab/255 ~= (ab + (ab >> 8) + 0x80) >> 8 */
ab = LLVMBuildMul(builder, a, b, "");
- ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c08, ""), "");
- ab = LLVMBuildAdd(builder, ab, c80, "");
+ ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c8, ""), "");
+ ab = LLVMBuildAdd(builder, ab, lp_build_int_const_scalar(i16_type, 0x80), "");
#endif
- ab = LLVMBuildLShr(builder, ab, c08, "");
+ ab = LLVMBuildLShr(builder, ab, c8, "");
return ab;
}
@@ -415,39 +374,18 @@ lp_build_mul(struct lp_build_context *bld,
return bld->undef;
if(!type.floating && !type.fixed && type.norm) {
- if(util_cpu_caps.has_sse2 && type.width == 8 && type.length == 16) {
- LLVMTypeRef i16x8 = LLVMVectorType(LLVMInt16Type(), 8);
- LLVMTypeRef i8x16 = LLVMVectorType(LLVMInt8Type(), 16);
- static LLVMValueRef ml = NULL;
- static LLVMValueRef mh = NULL;
- LLVMValueRef al, ah, bl, bh;
- LLVMValueRef abl, abh;
- LLVMValueRef ab;
-
- if(!ml) ml = lp_build_unpack_shuffle(16, 0);
- if(!mh) mh = lp_build_unpack_shuffle(16, 1);
+ if(type.width == 8) {
+ struct lp_type i16_type = lp_wider_type(type);
+ LLVMValueRef al, ah, bl, bh, abl, abh, ab;
- /* PUNPCKLBW, PUNPCKHBW */
- al = LLVMBuildShuffleVector(bld->builder, a, bld->zero, ml, "");
- bl = LLVMBuildShuffleVector(bld->builder, b, bld->zero, ml, "");
- ah = LLVMBuildShuffleVector(bld->builder, a, bld->zero, mh, "");
- bh = LLVMBuildShuffleVector(bld->builder, b, bld->zero, mh, "");
-
- /* NOP */
- al = LLVMBuildBitCast(bld->builder, al, i16x8, "");
- bl = LLVMBuildBitCast(bld->builder, bl, i16x8, "");
- ah = LLVMBuildBitCast(bld->builder, ah, i16x8, "");
- bh = LLVMBuildBitCast(bld->builder, bh, i16x8, "");
+ lp_build_unpack2(bld->builder, type, i16_type, a, &al, &ah);
+ lp_build_unpack2(bld->builder, type, i16_type, b, &bl, &bh);
/* PMULLW, PSRLW, PADDW */
- abl = lp_build_mul_u8n(bld->builder, al, bl);
- abh = lp_build_mul_u8n(bld->builder, ah, bh);
-
- /* PACKUSWB */
- ab = lp_build_intrinsic_binary(bld->builder, "llvm.x86.sse2.packuswb.128" , i16x8, abl, abh);
+ abl = lp_build_mul_u8n(bld->builder, i16_type, al, bl);
+ abh = lp_build_mul_u8n(bld->builder, i16_type, ah, bh);
- /* NOP */
- ab = LLVMBuildBitCast(bld->builder, ab, i8x16, "");
+ ab = lp_build_pack2(bld->builder, i16_type, type, abl, abh);
return ab;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.h b/src/gallium/drivers/llvmpipe/lp_bld_arit.h
index 095a8e1cabe..4e568c055e2 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_arit.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.h
@@ -40,7 +40,7 @@
#include <llvm-c/Core.h>
-struct lp_type type;
+struct lp_type;
struct lp_build_context;
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_const.h b/src/gallium/drivers/llvmpipe/lp_bld_const.h
index ffb302f7366..cb8e1c7b006 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_const.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_const.h
@@ -42,7 +42,7 @@
#include <pipe/p_compiler.h>
-struct lp_type type;
+struct lp_type;
unsigned
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.c b/src/gallium/drivers/llvmpipe/lp_bld_conv.c
index 20c8710214b..99352094379 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_conv.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.c
@@ -69,6 +69,7 @@
#include "lp_bld_const.h"
#include "lp_bld_intr.h"
#include "lp_bld_arit.h"
+#include "lp_bld_pack.h"
#include "lp_bld_conv.h"
@@ -199,241 +200,6 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
/**
- * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
- */
-static LLVMValueRef
-lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
-{
- LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
- unsigned i, j;
-
- assert(n <= LP_MAX_VECTOR_LENGTH);
- assert(lo_hi < 2);
-
- /* TODO: cache results in a static table */
-
- for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) {
- elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0);
- elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0);
- }
-
- return LLVMConstVector(elems, n);
-}
-
-
-/**
- * Build shuffle vectors that match PACKxx instructions.
- */
-static LLVMValueRef
-lp_build_const_pack_shuffle(unsigned n)
-{
- LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
- unsigned i;
-
- assert(n <= LP_MAX_VECTOR_LENGTH);
-
- /* TODO: cache results in a static table */
-
- for(i = 0; i < n; ++i)
- elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0);
-
- return LLVMConstVector(elems, n);
-}
-
-
-/**
- * Expand the bit width.
- *
- * This will only change the number of bits the values are represented, not the
- * values themselves.
- */
-static void
-lp_build_expand(LLVMBuilderRef builder,
- struct lp_type src_type,
- struct lp_type dst_type,
- LLVMValueRef src,
- LLVMValueRef *dst, unsigned num_dsts)
-{
- unsigned num_tmps;
- unsigned i;
-
- /* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
-
- /* We must not loose or gain channels. Only precision */
- assert(src_type.length == dst_type.length * num_dsts);
-
- num_tmps = 1;
- dst[0] = src;
-
- while(src_type.width < dst_type.width) {
- struct lp_type new_type = src_type;
- LLVMTypeRef new_vec_type;
-
- new_type.width *= 2;
- new_type.length /= 2;
- new_vec_type = lp_build_vec_type(new_type);
-
- for(i = num_tmps; i--; ) {
- LLVMValueRef zero;
- LLVMValueRef shuffle_lo;
- LLVMValueRef shuffle_hi;
- LLVMValueRef lo;
- LLVMValueRef hi;
-
- zero = lp_build_zero(src_type);
- shuffle_lo = lp_build_const_unpack_shuffle(src_type.length, 0);
- shuffle_hi = lp_build_const_unpack_shuffle(src_type.length, 1);
-
- /* PUNPCKLBW, PUNPCKHBW */
- lo = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_lo, "");
- hi = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_hi, "");
-
- dst[2*i + 0] = LLVMBuildBitCast(builder, lo, new_vec_type, "");
- dst[2*i + 1] = LLVMBuildBitCast(builder, hi, new_vec_type, "");
- }
-
- src_type = new_type;
-
- num_tmps *= 2;
- }
-
- assert(num_tmps == num_dsts);
-}
-
-
-/**
- * Non-interleaved pack.
- *
- * This will move values as
- *
- * lo = __ l0 __ l1 __ l2 __.. __ ln
- * hi = __ h0 __ h1 __ h2 __.. __ hn
- * res = l0 l1 l2 .. ln h0 h1 h2 .. hn
- *
- * TODO: handle saturation consistently.
- */
-static LLVMValueRef
-lp_build_pack2(LLVMBuilderRef builder,
- struct lp_type src_type,
- struct lp_type dst_type,
- boolean clamped,
- LLVMValueRef lo,
- LLVMValueRef hi)
-{
- LLVMTypeRef src_vec_type = lp_build_vec_type(src_type);
- LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type);
- LLVMValueRef shuffle;
- LLVMValueRef res;
-
- /* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
-
- /* We must not loose or gain channels. Only precision */
- assert(src_type.length * 2 == dst_type.length);
-
- assert(!src_type.floating);
- assert(!dst_type.floating);
-
- if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) {
- /* All X86 non-interleaved pack instructions all take signed inputs and
- * saturate them, so saturate beforehand. */
- if(!src_type.sign && !clamped) {
- struct lp_build_context bld;
- unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width;
- LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1);
- lp_build_context_init(&bld, builder, src_type);
- lo = lp_build_min(&bld, lo, dst_max);
- hi = lp_build_min(&bld, hi, dst_max);
- }
-
- switch(src_type.width) {
- case 32:
- if(dst_type.sign || !util_cpu_caps.has_sse4_1)
- res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi);
- else
- /* PACKUSDW is the only instrinsic with a consistent signature */
- return lp_build_intrinsic_binary(builder, "llvm.x86.sse41.packusdw", dst_vec_type, lo, hi);
- break;
-
- case 16:
- if(dst_type.sign)
- res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi);
- else
- res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi);
- break;
-
- default:
- assert(0);
- return LLVMGetUndef(dst_vec_type);
- break;
- }
-
- res = LLVMBuildBitCast(builder, res, dst_vec_type, "");
- return res;
- }
-
- lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
- hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");
-
- shuffle = lp_build_const_pack_shuffle(dst_type.length);
-
- res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, "");
-
- return res;
-}
-
-
-/**
- * Truncate the bit width.
- *
- * TODO: Handle saturation consistently.
- */
-static LLVMValueRef
-lp_build_pack(LLVMBuilderRef builder,
- struct lp_type src_type,
- struct lp_type dst_type,
- boolean clamped,
- const LLVMValueRef *src, unsigned num_srcs)
-{
- LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
- unsigned i;
-
- /* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
-
- /* We must not loose or gain channels. Only precision */
- assert(src_type.length * num_srcs == dst_type.length);
-
- for(i = 0; i < num_srcs; ++i)
- tmp[i] = src[i];
-
- while(src_type.width > dst_type.width) {
- struct lp_type new_type = src_type;
-
- new_type.width /= 2;
- new_type.length *= 2;
-
- /* Take in consideration the sign changes only in the last step */
- if(new_type.width == dst_type.width)
- new_type.sign = dst_type.sign;
-
- num_srcs /= 2;
-
- for(i = 0; i < num_srcs; ++i)
- tmp[i] = lp_build_pack2(builder, src_type, new_type, clamped,
- tmp[2*i + 0], tmp[2*i + 1]);
-
- src_type = new_type;
- }
-
- assert(num_srcs == 1);
-
- return tmp[0];
-}
-
-
-/**
* Generic type conversion.
*
* TODO: Take a precision argument, or even better, add a new precision member
@@ -572,7 +338,7 @@ lp_build_conv(LLVMBuilderRef builder,
if(tmp_type.width < dst_type.width) {
assert(num_tmps == 1);
- lp_build_expand(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts);
+ lp_build_unpack(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts);
tmp_type.width = dst_type.width;
tmp_type.length = dst_type.length;
num_tmps = num_dsts;
@@ -692,7 +458,7 @@ lp_build_conv_mask(LLVMBuilderRef builder,
}
else if(src_type.width < dst_type.width) {
assert(num_srcs == 1);
- lp_build_expand(builder, src_type, dst_type, src[0], dst, num_dsts);
+ lp_build_unpack(builder, src_type, dst_type, src[0], dst, num_dsts);
}
else {
assert(num_srcs == num_dsts);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.h b/src/gallium/drivers/llvmpipe/lp_bld_conv.h
index ca378804d2a..948e68fae4f 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_conv.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.h
@@ -40,7 +40,7 @@
#include <llvm-c/Core.h>
-struct lp_type type;
+struct lp_type;
LLVMValueRef
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logic.h b/src/gallium/drivers/llvmpipe/lp_bld_logic.h
index a4ee7723b5f..d67500ef707 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_logic.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_logic.h
@@ -42,7 +42,7 @@
#include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */
-struct lp_type type;
+struct lp_type;
struct lp_build_context;
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.c b/src/gallium/drivers/llvmpipe/lp_bld_pack.c
new file mode 100644
index 00000000000..fe82fda0392
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_bld_pack.c
@@ -0,0 +1,419 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/**
+ * @file
+ * Helper functions for packing/unpacking.
+ *
+ * Pack/unpacking is necessary for conversion between types of different
+ * bit width.
+ *
+ * They are also commonly used when an computation needs higher
+ * precision for the intermediate values. For example, if one needs the
+ * function:
+ *
+ * c = compute(a, b);
+ *
+ * to use more precision for intermediate results then one should implement it
+ * as:
+ *
+ * LLVMValueRef
+ * compute(LLVMBuilderRef builder struct lp_type type, LLVMValueRef a, LLVMValueRef b)
+ * {
+ * struct lp_type wide_type = lp_wider_type(type);
+ * LLVMValueRef al, ah, bl, bh, cl, ch, c;
+ *
+ * lp_build_unpack2(builder, type, wide_type, a, &al, &ah);
+ * lp_build_unpack2(builder, type, wide_type, b, &bl, &bh);
+ *
+ * cl = compute_half(al, bl);
+ * ch = compute_half(ah, bh);
+ *
+ * c = lp_build_pack2(bld->builder, wide_type, type, cl, ch);
+ *
+ * return c;
+ * }
+ *
+ * where compute_half() would do the computation for half the elements with
+ * twice the precision.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "util/u_debug.h"
+#include "util/u_math.h"
+#include "util/u_cpu_detect.h"
+
+#include "lp_bld_type.h"
+#include "lp_bld_const.h"
+#include "lp_bld_intr.h"
+#include "lp_bld_arit.h"
+#include "lp_bld_pack.h"
+
+
+/**
+ * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
+ */
+static LLVMValueRef
+lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
+{
+ LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
+ unsigned i, j;
+
+ assert(n <= LP_MAX_VECTOR_LENGTH);
+ assert(lo_hi < 2);
+
+ /* TODO: cache results in a static table */
+
+ for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) {
+ elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0);
+ elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0);
+ }
+
+ return LLVMConstVector(elems, n);
+}
+
+
+/**
+ * Build shuffle vectors that match PACKxx instructions.
+ */
+static LLVMValueRef
+lp_build_const_pack_shuffle(unsigned n)
+{
+ LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
+ unsigned i;
+
+ assert(n <= LP_MAX_VECTOR_LENGTH);
+
+ /* TODO: cache results in a static table */
+
+ for(i = 0; i < n; ++i)
+ elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0);
+
+ return LLVMConstVector(elems, n);
+}
+
+
+/**
+ * Interleave vector elements.
+ *
+ * Matches the PUNPCKLxx and PUNPCKHxx SSE instructions.
+ */
+LLVMValueRef
+lp_build_interleave2(LLVMBuilderRef builder,
+ struct lp_type type,
+ LLVMValueRef a,
+ LLVMValueRef b,
+ unsigned lo_hi)
+{
+ LLVMValueRef shuffle;
+
+ shuffle = lp_build_const_unpack_shuffle(type.length, lo_hi);
+
+ return LLVMBuildShuffleVector(builder, a, b, shuffle, "");
+}
+
+
+/**
+ * Double the bit width.
+ *
+ * This will only change the number of bits the values are represented, not the
+ * values themselves.
+ */
+void
+lp_build_unpack2(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef src,
+ LLVMValueRef *dst_lo,
+ LLVMValueRef *dst_hi)
+{
+ LLVMValueRef msb;
+ LLVMTypeRef dst_vec_type;
+
+ assert(!src_type.floating);
+ assert(!dst_type.floating);
+ assert(dst_type.sign == src_type.sign);
+ assert(dst_type.width == src_type.width * 2);
+ assert(dst_type.length * 2 == src_type.length);
+
+ if(src_type.sign) {
+ /* Replicate the sign bit in the most significant bits */
+ msb = LLVMBuildAShr(builder, src, lp_build_int_const_scalar(src_type, src_type.width - 1), "");
+ }
+ else
+ /* Most significant bits always zero */
+ msb = lp_build_zero(src_type);
+
+ /* Interleave bits */
+ if(util_cpu_caps.little_endian) {
+ *dst_lo = lp_build_interleave2(builder, src_type, src, msb, 0);
+ *dst_hi = lp_build_interleave2(builder, src_type, src, msb, 1);
+ }
+ else {
+ *dst_lo = lp_build_interleave2(builder, src_type, msb, src, 0);
+ *dst_hi = lp_build_interleave2(builder, src_type, msb, src, 1);
+ }
+
+ /* Cast the result into the new type (twice as wide) */
+
+ dst_vec_type = lp_build_vec_type(dst_type);
+
+ *dst_lo = LLVMBuildBitCast(builder, *dst_lo, dst_vec_type, "");
+ *dst_hi = LLVMBuildBitCast(builder, *dst_hi, dst_vec_type, "");
+}
+
+
+/**
+ * Expand the bit width.
+ *
+ * This will only change the number of bits the values are represented, not the
+ * values themselves.
+ */
+void
+lp_build_unpack(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef src,
+ LLVMValueRef *dst, unsigned num_dsts)
+{
+ unsigned num_tmps;
+ unsigned i;
+
+ /* Register width must remain constant */
+ assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+
+ /* We must not loose or gain channels. Only precision */
+ assert(src_type.length == dst_type.length * num_dsts);
+
+ num_tmps = 1;
+ dst[0] = src;
+
+ while(src_type.width < dst_type.width) {
+ struct lp_type tmp_type = src_type;
+
+ tmp_type.width *= 2;
+ tmp_type.length /= 2;
+
+ for(i = num_tmps; i--; ) {
+ lp_build_unpack2(builder, src_type, tmp_type, dst[i], &dst[2*i + 0], &dst[2*i + 1]);
+ }
+
+ src_type = tmp_type;
+
+ num_tmps *= 2;
+ }
+
+ assert(num_tmps == num_dsts);
+}
+
+
+/**
+ * Non-interleaved pack.
+ *
+ * This will move values as
+ *
+ * lo = __ l0 __ l1 __ l2 __.. __ ln
+ * hi = __ h0 __ h1 __ h2 __.. __ hn
+ * res = l0 l1 l2 .. ln h0 h1 h2 .. hn
+ *
+ * This will only change the number of bits the values are represented, not the
+ * values themselves.
+ *
+ * It is assumed the values are already clamped into the destination type range.
+ * Values outside that range will produce undefined results. Use
+ * lp_build_packs2 instead.
+ */
+LLVMValueRef
+lp_build_pack2(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef lo,
+ LLVMValueRef hi)
+{
+ LLVMTypeRef src_vec_type = lp_build_vec_type(src_type);
+ LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type);
+ LLVMValueRef shuffle;
+ LLVMValueRef res;
+
+ dst_vec_type = lp_build_vec_type(dst_type);
+
+ assert(!src_type.floating);
+ assert(!dst_type.floating);
+ assert(src_type.width == dst_type.width * 2);
+ assert(src_type.length * 2 == dst_type.length);
+
+ if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) {
+ switch(src_type.width) {
+ case 32:
+ if(dst_type.sign) {
+ res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi);
+ }
+ else {
+ if (util_cpu_caps.has_sse4_1) {
+ /* PACKUSDW is the only instrinsic with a consistent signature */
+ return lp_build_intrinsic_binary(builder, "llvm.x86.sse41.packusdw", dst_vec_type, lo, hi);
+ }
+ else {
+ assert(0);
+ return LLVMGetUndef(dst_vec_type);
+ }
+ }
+ break;
+
+ case 16:
+ if(dst_type.sign)
+ res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi);
+ else
+ res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi);
+ break;
+
+ default:
+ assert(0);
+ return LLVMGetUndef(dst_vec_type);
+ break;
+ }
+
+ res = LLVMBuildBitCast(builder, res, dst_vec_type, "");
+ return res;
+ }
+
+ lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
+ hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");
+
+ shuffle = lp_build_const_pack_shuffle(dst_type.length);
+
+ res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, "");
+
+ return res;
+}
+
+
+
+/**
+ * Non-interleaved pack and saturate.
+ *
+ * Same as lp_build_pack2 but will saturate values so that they fit into the
+ * destination type.
+ */
+LLVMValueRef
+lp_build_packs2(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef lo,
+ LLVMValueRef hi)
+{
+ boolean clamp;
+
+ assert(!src_type.floating);
+ assert(!dst_type.floating);
+ assert(src_type.sign == dst_type.sign);
+ assert(src_type.width == dst_type.width * 2);
+ assert(src_type.length * 2 == dst_type.length);
+
+ clamp = TRUE;
+
+ /* All X86 SSE non-interleaved pack instructions take signed inputs and
+ * saturate them, so no need to clamp for those cases. */
+ if(util_cpu_caps.has_sse2 &&
+ src_type.width * src_type.length == 128 &&
+ src_type.sign)
+ clamp = FALSE;
+
+ if(clamp) {
+ struct lp_build_context bld;
+ unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width;
+ LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1);
+ lp_build_context_init(&bld, builder, src_type);
+ lo = lp_build_min(&bld, lo, dst_max);
+ hi = lp_build_min(&bld, hi, dst_max);
+ /* FIXME: What about lower bound? */
+ }
+
+ return lp_build_pack2(builder, src_type, dst_type, lo, hi);
+}
+
+
+/**
+ * Truncate the bit width.
+ *
+ * TODO: Handle saturation consistently.
+ */
+LLVMValueRef
+lp_build_pack(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ boolean clamped,
+ const LLVMValueRef *src, unsigned num_srcs)
+{
+ LLVMValueRef (*pack2)(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef lo,
+ LLVMValueRef hi);
+ LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
+ unsigned i;
+
+
+ /* Register width must remain constant */
+ assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+
+ /* We must not loose or gain channels. Only precision */
+ assert(src_type.length * num_srcs == dst_type.length);
+
+ if(clamped)
+ pack2 = &lp_build_pack2;
+ else
+ pack2 = &lp_build_packs2;
+
+ for(i = 0; i < num_srcs; ++i)
+ tmp[i] = src[i];
+
+ while(src_type.width > dst_type.width) {
+ struct lp_type tmp_type = src_type;
+
+ tmp_type.width /= 2;
+ tmp_type.length *= 2;
+
+ /* Take in consideration the sign changes only in the last step */
+ if(tmp_type.width == dst_type.width)
+ tmp_type.sign = dst_type.sign;
+
+ num_srcs /= 2;
+
+ for(i = 0; i < num_srcs; ++i)
+ tmp[i] = pack2(builder, src_type, tmp_type, tmp[2*i + 0], tmp[2*i + 1]);
+
+ src_type = tmp_type;
+ }
+
+ assert(num_srcs == 1);
+
+ return tmp[0];
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.h b/src/gallium/drivers/llvmpipe/lp_bld_pack.h
new file mode 100644
index 00000000000..fb2a34984a4
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_bld_pack.h
@@ -0,0 +1,95 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Helper functions for packing/unpacking conversions.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef LP_BLD_PACK_H
+#define LP_BLD_PACK_H
+
+
+#include <llvm-c/Core.h>
+
+
+struct lp_type;
+
+
+LLVMValueRef
+lp_build_interleave2(LLVMBuilderRef builder,
+ struct lp_type type,
+ LLVMValueRef a,
+ LLVMValueRef b,
+ unsigned lo_hi);
+
+
+void
+lp_build_unpack2(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef src,
+ LLVMValueRef *dst_lo,
+ LLVMValueRef *dst_hi);
+
+
+void
+lp_build_unpack(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef src,
+ LLVMValueRef *dst, unsigned num_dsts);
+
+
+LLVMValueRef
+lp_build_packs2(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef lo,
+ LLVMValueRef hi);
+
+
+LLVMValueRef
+lp_build_pack2(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ LLVMValueRef lo,
+ LLVMValueRef hi);
+
+
+LLVMValueRef
+lp_build_pack(LLVMBuilderRef builder,
+ struct lp_type src_type,
+ struct lp_type dst_type,
+ boolean clamped,
+ const LLVMValueRef *src, unsigned num_srcs);
+
+
+#endif /* !LP_BLD_PACK_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h
index 1f6da804488..b9472127a63 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h
@@ -40,7 +40,7 @@
#include <llvm-c/Core.h>
-struct lp_type type;
+struct lp_type;
struct lp_build_context;
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_type.c b/src/gallium/drivers/llvmpipe/lp_bld_type.c
index 606243d6c5a..1320a267214 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_type.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_type.c
@@ -160,12 +160,31 @@ lp_build_int_vec_type(struct lp_type type)
struct lp_type
lp_int_type(struct lp_type type)
{
- struct lp_type int_type;
+ struct lp_type res_type;
- memset(&int_type, 0, sizeof int_type);
- int_type.width = type.width;
- int_type.length = type.length;
- return int_type;
+ memset(&res_type, 0, sizeof res_type);
+ res_type.width = type.width;
+ res_type.length = type.length;
+
+ return res_type;
+}
+
+
+/**
+ * Return the type with twice the bit width (hence half the number of elements).
+ */
+struct lp_type
+lp_wider_type(struct lp_type type)
+{
+ struct lp_type res_type;
+
+ memcpy(&res_type, &type, sizeof res_type);
+ res_type.width *= 2;
+ res_type.length /= 2;
+
+ assert(res_type.length);
+
+ return res_type;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_type.h b/src/gallium/drivers/llvmpipe/lp_bld_type.h
index ee5ca3483c1..46c298fa206 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_type.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_type.h
@@ -166,6 +166,10 @@ struct lp_type
lp_int_type(struct lp_type type);
+struct lp_type
+lp_wider_type(struct lp_type type);
+
+
void
lp_build_context_init(struct lp_build_context *bld,
LLVMBuilderRef builder,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 60107214df5..c43b3da4508 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -115,6 +115,7 @@ struct setup_context {
/**
* Execute fragment shader for the four fragments in the quad.
*/
+ALIGN_STACK
static void
shade_quads(struct llvmpipe_context *llvmpipe,
struct quad_header *quads[],
@@ -277,11 +278,13 @@ clip_emit_quad( struct setup_context *setup, struct quad_header *quad )
* until we codegenerate single-quad variants of the fragment pipeline
* we need this hack. */
const unsigned nr_quads = TILE_VECTOR_HEIGHT*TILE_VECTOR_WIDTH/QUAD_SIZE;
- struct quad_header quads[nr_quads];
- struct quad_header *quad_ptrs[nr_quads];
+ struct quad_header quads[4];
+ struct quad_header *quad_ptrs[4];
int x0 = block_x(quad->input.x0);
unsigned i;
+ assert(nr_quads == 4);
+
for(i = 0; i < nr_quads; ++i) {
int x = x0 + 2*i;
if(x == quad->input.x0)
diff --git a/src/gallium/drivers/llvmpipe/lp_test.h b/src/gallium/drivers/llvmpipe/lp_test.h
index a88e110c663..39d80726e65 100644
--- a/src/gallium/drivers/llvmpipe/lp_test.h
+++ b/src/gallium/drivers/llvmpipe/lp_test.h
@@ -56,6 +56,9 @@
#include "lp_bld_type.h"
+#define LP_TEST_NUM_SAMPLES 32
+
+
void
write_tsv_header(FILE *fp);
@@ -68,17 +71,28 @@ boolean
test_all(unsigned verbose, FILE *fp);
+#if defined(PIPE_CC_MSVC)
+
+unsigned __int64 __rdtsc();
+#pragma intrinsic(__rdtsc)
+#define rdtsc() __rdtsc()
+
+#elif defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
+
static INLINE uint64_t
rdtsc(void)
{
-#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
uint32_t hi, lo;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
return ((uint64_t)lo) | (((uint64_t)hi) << 32);
+}
+
#else
- return 0;
+
+#define rdtsc() 0
+
#endif
-}
+
float
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 94b661dcba4..e3af81cffb0 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -477,8 +477,8 @@ test_one(unsigned verbose,
char *error = NULL;
blend_test_ptr_t blend_test_ptr;
boolean success;
- const unsigned n = 32;
- int64_t cycles[n];
+ const unsigned n = LP_TEST_NUM_SAMPLES;
+ int64_t cycles[LP_TEST_NUM_SAMPLES];
double cycles_avg = 0.0;
unsigned i, j;
diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c
index 9dcf58e5dcd..ac2a6d05e32 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_conv.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c
@@ -156,8 +156,8 @@ test_one(unsigned verbose,
char *error = NULL;
conv_test_ptr_t conv_test_ptr;
boolean success;
- const unsigned n = 32;
- int64_t cycles[n];
+ const unsigned n = LP_TEST_NUM_SAMPLES;
+ int64_t cycles[LP_TEST_NUM_SAMPLES];
double cycles_avg = 0.0;
unsigned num_srcs;
unsigned num_dsts;
diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index ab80c0143f9..5dc8297fe90 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_format.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -35,6 +35,7 @@
#include <llvm-c/Target.h>
#include <llvm-c/Transforms/Scalar.h>
+#include "util/u_cpu_detect.h"
#include "util/u_format.h"
#include "lp_bld_format.h"
@@ -263,6 +264,8 @@ int main(int argc, char **argv)
LLVMInitializeNativeTarget();
#endif
+ util_cpu_detect();
+
for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i)
if(!test_format(&test_cases[i]))
ret = 1;
diff --git a/src/gallium/drivers/llvmpipe/lp_test_main.c b/src/gallium/drivers/llvmpipe/lp_test_main.c
index f07fa256f16..d4767ff52ba 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_main.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_main.c
@@ -34,6 +34,8 @@
*/
+#include "util/u_cpu_detect.h"
+
#include "lp_bld_const.h"
#include "lp_test.h"
@@ -370,6 +372,8 @@ int main(int argc, char **argv)
LLVMInitializeNativeTarget();
#endif
+ util_cpu_detect();
+
if(fp) {
/* Warm up the caches */
test_some(0, NULL, 100);
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 08f0950d475..a00f2495dfc 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -66,16 +66,24 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
pf_get_block(lpt->base.format, &lpt->base.block);
for (level = 0; level <= pt->last_level; level++) {
+ unsigned nblocksx, nblocksy;
+
pt->width[level] = width;
pt->height[level] = height;
pt->depth[level] = depth;
pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
- lpt->stride[level] = align(pt->nblocksx[level]*pt->block.size, 16);
+ pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
+
+ /* Allocate storage for whole quads. This is particularly important
+ * for depth surfaces, which are currently stored in a swizzled format. */
+ nblocksx = pf_get_nblocksx(&pt->block, align(width, 2));
+ nblocksy = pf_get_nblocksy(&pt->block, align(height, 2));
+
+ lpt->stride[level] = align(nblocksx*pt->block.size, 16);
lpt->level_offset[level] = buffer_size;
- buffer_size += (pt->nblocksy[level] *
+ buffer_size += (nblocksy *
((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
lpt->stride[level]);
diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile
index dbe8a6e7bf5..0cb66041d50 100644
--- a/src/gallium/drivers/nouveau/Makefile
+++ b/src/gallium/drivers/nouveau/Makefile
@@ -3,6 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nouveau
-C_SOURCES = nouveau_screen.c
+C_SOURCES = nouveau_screen.c \
+ nouveau_context.c
include ../../Makefile.template
diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c
new file mode 100644
index 00000000000..23443869e68
--- /dev/null
+++ b/src/gallium/drivers/nouveau/nouveau_context.c
@@ -0,0 +1,41 @@
+#include <pipe/p_defines.h>
+#include <pipe/p_context.h>
+
+#include "nouveau/nouveau_screen.h"
+#include "nouveau/nouveau_context.h"
+
+#include "nouveau/nouveau_bo.h"
+
+static unsigned int
+nouveau_reference_flags(struct nouveau_bo *bo)
+{
+ uint32_t bo_flags;
+ int flags = 0;
+
+ bo_flags = nouveau_bo_pending(bo);
+ if (bo_flags & NOUVEAU_BO_RD)
+ flags |= PIPE_REFERENCED_FOR_READ;
+ if (bo_flags & NOUVEAU_BO_WR)
+ flags |= PIPE_REFERENCED_FOR_WRITE;
+
+ return flags;
+}
+
+unsigned int
+nouveau_is_texture_referenced(struct pipe_context *pipe,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level)
+{
+ struct nouveau_miptree *mt = nouveau_miptree(pt);
+
+ return nouveau_reference_flags(mt->bo);
+}
+
+unsigned int
+nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
+{
+ struct nouveau_bo *bo = nouveau_bo(pb);
+
+ return nouveau_reference_flags(bo);
+}
+
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
new file mode 100644
index 00000000000..6a28d40da7b
--- /dev/null
+++ b/src/gallium/drivers/nouveau/nouveau_context.h
@@ -0,0 +1,11 @@
+#ifndef __NOUVEAU_CONTEXT_H__
+#define __NOUVEAU_CONTEXT_H__
+
+unsigned int
+nouveau_is_texture_referenced(struct pipe_context *, struct pipe_texture *,
+ unsigned face, unsigned level);
+
+unsigned int
+nouveau_is_buffer_referenced(struct pipe_context *, struct pipe_buffer *);
+
+#endif
diff --git a/src/gallium/drivers/nv04/nv04_context.c b/src/gallium/drivers/nv04/nv04_context.c
index 17166c9f51d..10d984ace9b 100644
--- a/src/gallium/drivers/nv04/nv04_context.c
+++ b/src/gallium/drivers/nv04/nv04_context.c
@@ -64,30 +64,6 @@ nv04_init_hwctx(struct nv04_context *nv04)
return TRUE;
}
-static unsigned int
-nv04_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv04_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-
struct pipe_context *
nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@@ -113,8 +89,8 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv04->pipe.clear = nv04_clear;
nv04->pipe.flush = nv04_flush;
- nv04->pipe.is_texture_referenced = nv04_is_texture_referenced;
- nv04->pipe.is_buffer_referenced = nv04_is_buffer_referenced;
+ nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+ nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv04_init_surface_functions(nv04);
nv04_init_state_functions(nv04);
diff --git a/src/gallium/drivers/nv04/nv04_context.h b/src/gallium/drivers/nv04/nv04_context.h
index 2842b2c90db..55326c787a8 100644
--- a/src/gallium/drivers/nv04/nv04_context.h
+++ b/src/gallium/drivers/nv04/nv04_context.h
@@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv04_screen *ctx = nv04->screen
diff --git a/src/gallium/drivers/nv10/nv10_context.c b/src/gallium/drivers/nv10/nv10_context.c
index a127b134ecd..933176fc32a 100644
--- a/src/gallium/drivers/nv10/nv10_context.c
+++ b/src/gallium/drivers/nv10/nv10_context.c
@@ -257,29 +257,6 @@ nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
-static unsigned int
-nv10_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv10_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
struct pipe_context *
nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@@ -305,8 +282,8 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv10->pipe.clear = nv10_clear;
nv10->pipe.flush = nv10_flush;
- nv10->pipe.is_texture_referenced = nv10_is_texture_referenced;
- nv10->pipe.is_buffer_referenced = nv10_is_buffer_referenced;
+ nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+ nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv10_init_surface_functions(nv10);
nv10_init_state_functions(nv10);
diff --git a/src/gallium/drivers/nv10/nv10_context.h b/src/gallium/drivers/nv10/nv10_context.h
index f1e003c9537..36a6aa7a74e 100644
--- a/src/gallium/drivers/nv10/nv10_context.h
+++ b/src/gallium/drivers/nv10/nv10_context.h
@@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv10_screen *ctx = nv10->screen
diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c
index b32d0d83ba0..9a48739661b 100644
--- a/src/gallium/drivers/nv20/nv20_context.c
+++ b/src/gallium/drivers/nv20/nv20_context.c
@@ -380,30 +380,6 @@ nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
-
-static unsigned int
-nv20_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv20_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
struct pipe_context *
nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@@ -429,8 +405,8 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv20->pipe.clear = nv20_clear;
nv20->pipe.flush = nv20_flush;
- nv20->pipe.is_texture_referenced = nv20_is_texture_referenced;
- nv20->pipe.is_buffer_referenced = nv20_is_buffer_referenced;
+ nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+ nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv20_init_surface_functions(nv20);
nv20_init_state_functions(nv20);
diff --git a/src/gallium/drivers/nv20/nv20_context.h b/src/gallium/drivers/nv20/nv20_context.h
index fc932f1f90e..a4eaa956608 100644
--- a/src/gallium/drivers/nv20/nv20_context.h
+++ b/src/gallium/drivers/nv20/nv20_context.h
@@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv20_screen *ctx = nv20->screen
diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
index f827bdc78b1..d8300fd69f6 100644
--- a/src/gallium/drivers/nv30/nv30_context.c
+++ b/src/gallium/drivers/nv30/nv30_context.c
@@ -10,7 +10,7 @@ nv30_flush(struct pipe_context *pipe, unsigned flags,
struct pipe_fence_handle **fence)
{
struct nv30_context *nv30 = nv30_context(pipe);
-
+
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
BEGIN_RING(rankine, 0x1fd8, 1);
OUT_RING (2);
@@ -31,29 +31,6 @@ nv30_destroy(struct pipe_context *pipe)
FREE(nv30);
}
-static unsigned int
-nv30_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv30_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
struct pipe_context *
nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@@ -78,8 +55,8 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv30->pipe.clear = nv30_clear;
nv30->pipe.flush = nv30_flush;
- nv30->pipe.is_texture_referenced = nv30_is_texture_referenced;
- nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced;
+ nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+ nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv30_init_query_functions(nv30);
nv30_init_surface_functions(nv30);
@@ -95,4 +72,3 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
return &nv30->pipe;
}
-
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index 4229c0a0e14..8d49366dfcb 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv30_screen *ctx = nv30->screen
diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
index 822e1d8defe..f5f17d40714 100644
--- a/src/gallium/drivers/nv30/nv30_fragtex.c
+++ b/src/gallium/drivers/nv30/nv30_fragtex.c
@@ -30,7 +30,7 @@ nv30_texture_formats[] = {
_(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X),
_(A8L8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y),
// _(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X),
-// _(Z24S8_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X),
+ _(Z24S8_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X),
_(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W),
_(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W),
_(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W),
@@ -69,13 +69,13 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
tf = nv30_fragtex_format(pt->format);
if (!tf)
- assert(0);
+ return NULL;
txf = tf->format;
txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0);
- txf |= log2i(pt->width[0]) << 20;
- txf |= log2i(pt->height[0]) << 24;
- txf |= log2i(pt->depth[0]) << 28;
+ txf |= log2i(pt->width[0]) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT;
+ txf |= log2i(pt->height[0]) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT;
+ txf |= log2i(pt->depth[0]) << NV34TCL_TX_FORMAT_BASE_SIZE_W_SHIFT;
txf |= NV34TCL_TX_FORMAT_NO_BORDER | 0x10000;
switch (pt->target) {
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index 41af38450b5..bb40e1803d1 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -10,6 +10,22 @@
#define NV34TCL_CHIPSET_3X_MASK 0x00000010
#define NV35TCL_CHIPSET_3X_MASK 0x000001e0
+/* FIXME: It seems I should not include directly ../../winsys/drm/nouveau/drm/nouveau_drm_api.h
+ * to get the pointer to the context front buffer, so I copied nouveau_winsys here.
+ * nv30_screen_surface_format_supported() can then use it to enforce creating fbo
+ * with same number of bits everywhere.
+ */
+struct nouveau_winsys {
+ struct pipe_winsys base;
+
+ struct pipe_screen *pscreen;
+
+ unsigned nr_pctx;
+ struct pipe_context **pctx;
+
+ struct pipe_surface *front;
+};
+
static int
nv30_screen_get_param(struct pipe_screen *pscreen, int param)
{
@@ -83,21 +99,18 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
enum pipe_texture_target target,
unsigned tex_usage, unsigned geom_flags)
{
+ struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
+
if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- return TRUE;
- default:
- break;
- }
+ return (format == front->format);
} else
if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
switch (format) {
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
+ return (front->format == PIPE_FORMAT_A8R8G8B8_UNORM);
case PIPE_FORMAT_Z16_UNORM:
- return TRUE;
+ return (front->format == PIPE_FORMAT_R5G6B5_UNORM);
default:
break;
}
diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c
index 2729dcec7cc..f90681b0f97 100644
--- a/src/gallium/drivers/nv30/nv30_state_fb.c
+++ b/src/gallium/drivers/nv30/nv30_state_fb.c
@@ -8,15 +8,15 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
struct nouveau_channel *chan = nv30->screen->base.channel;
struct nouveau_grobj *rankine = nv30->screen->rankine;
struct nv04_surface *rt[2], *zeta = NULL;
- uint32_t rt_enable, rt_format;
- int i, colour_format = 0, zeta_format = 0;
+ uint32_t rt_enable = 0, rt_format = 0;
+ int i, colour_format = 0, zeta_format = 0, depth_only = 0;
struct nouveau_stateobj *so = so_new(64, 10);
unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
unsigned w = fb->width;
unsigned h = fb->height;
struct nv30_miptree *nv30mt;
+ int colour_bits = 32, zeta_bits = 32;
- rt_enable = 0;
for (i = 0; i < fb->nr_cbufs; i++) {
if (colour_format) {
assert(colour_format == fb->cbufs[i]->format);
@@ -35,17 +35,35 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
zeta = (struct nv04_surface *)fb->zsbuf;
}
- if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
- assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
- for (i = 1; i < fb->nr_cbufs; i++)
- assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
+ if (rt_enable & (NV34TCL_RT_ENABLE_COLOR0|NV34TCL_RT_ENABLE_COLOR1)) {
+ /* Render to at least a colour buffer */
+ if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
+ for (i = 1; i < fb->nr_cbufs; i++)
+ assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
- rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
- (log2i(rt[0]->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
- (log2i(rt[0]->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
+ rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
+ (log2i(rt[0]->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
+ (log2i(rt[0]->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
+ }
+ else
+ rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
+ } else if (fb->zsbuf) {
+ depth_only = 1;
+
+ /* Render to depth buffer only */
+ if (!(zeta->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
+
+ rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
+ (log2i(zeta->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
+ (log2i(zeta->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
+ }
+ else
+ rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
+ } else {
+ return FALSE;
}
- else
- rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
switch (colour_format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -54,6 +72,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
break;
case PIPE_FORMAT_R5G6B5_UNORM:
rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
+ colour_bits = 16;
break;
default:
assert(0);
@@ -62,6 +81,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
switch (zeta_format) {
case PIPE_FORMAT_Z16_UNORM:
rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
+ zeta_bits = 16;
break;
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
@@ -72,21 +92,27 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
assert(0);
}
- if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
- uint32_t pitch = rt[0]->pitch;
+ if (colour_bits != zeta_bits) {
+ return FALSE;
+ }
+
+ if (depth_only || (rt_enable & NV34TCL_RT_ENABLE_COLOR0)) {
+ struct nv04_surface *rt0 = (depth_only ? zeta : rt[0]);
+ uint32_t pitch = rt0->pitch;
+
if (zeta) {
pitch |= (zeta->pitch << 16);
} else {
pitch |= (pitch << 16);
}
- nv30mt = (struct nv30_miptree *)rt[0]->base.texture;
+ nv30mt = (struct nv30_miptree *) rt0->base.texture;
so_method(so, rankine, NV34TCL_DMA_COLOR0, 1);
so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
chan->vram->handle, chan->gart->handle);
so_method(so, rankine, NV34TCL_COLOR0_PITCH, 2);
so_data (so, pitch);
- so_reloc (so, nouveau_bo(nv30mt->buffer), rt[0]->base.offset,
+ so_reloc (so, nouveau_bo(nv30mt->buffer), rt0->base.offset,
rt_flags | NOUVEAU_BO_LOW, 0, 0);
}
diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
index 8eba6a43ef9..7f008274a4e 100644
--- a/src/gallium/drivers/nv40/nv40_context.c
+++ b/src/gallium/drivers/nv40/nv40_context.c
@@ -10,7 +10,7 @@ nv40_flush(struct pipe_context *pipe, unsigned flags,
struct pipe_fence_handle **fence)
{
struct nv40_context *nv40 = nv40_context(pipe);
-
+
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
BEGIN_RING(curie, 0x1fd8, 1);
OUT_RING (2);
@@ -31,29 +31,6 @@ nv40_destroy(struct pipe_context *pipe)
FREE(nv40);
}
-static unsigned int
-nv40_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv40_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
struct pipe_context *
nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@@ -78,8 +55,8 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv40->pipe.clear = nv40_clear;
nv40->pipe.flush = nv40_flush;
- nv40->pipe.is_texture_referenced = nv40_is_texture_referenced;
- nv40->pipe.is_buffer_referenced = nv40_is_buffer_referenced;
+ nv40->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+ nv40->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv40_init_query_functions(nv40);
nv40_init_surface_functions(nv40);
@@ -95,4 +72,3 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
return &nv40->pipe;
}
-
diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
index 97bc83292d4..a3d594167aa 100644
--- a/src/gallium/drivers/nv40/nv40_context.h
+++ b/src/gallium/drivers/nv40/nv40_context.h
@@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv40_screen *ctx = nv40->screen
diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c
index fca078b174a..219e7a78623 100644
--- a/src/gallium/drivers/nv50/nv50_context.c
+++ b/src/gallium/drivers/nv50/nv50_context.c
@@ -33,13 +33,6 @@ nv50_flush(struct pipe_context *pipe, unsigned flags,
{
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_channel *chan = nv50->screen->base.channel;
- struct nouveau_grobj *eng2d = nv50->screen->eng2d;
-
- /* We need this in the ddx for reliable composite, not sure what we're
- * actually flushing. We generate all our own flushes with flags = 0. */
- WAIT_RING(chan, 2);
- BEGIN_RING(chan, eng2d, 0x0110, 1);
- OUT_RING (chan, 0);
if (flags & PIPE_FLUSH_FRAME)
FIRE_RING(chan);
@@ -60,29 +53,6 @@ nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
-static unsigned int
-nv50_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv50_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
struct pipe_context *
nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@@ -108,8 +78,8 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv50->pipe.flush = nv50_flush;
- nv50->pipe.is_texture_referenced = nv50_is_texture_referenced;
- nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced;
+ nv50->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+ nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
screen->base.channel->user_private = nv50;
screen->base.channel->flush_notify = nv50_state_flush_notify;
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index 4608854d711..33667e8765c 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -14,6 +14,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_stateobj.h"
+#include "nouveau/nouveau_context.h"
#include "nv50_screen.h"
#include "nv50_program.h"
@@ -120,6 +121,7 @@ struct nv50_state {
struct nouveau_stateobj *vtxfmt;
struct nouveau_stateobj *vtxbuf;
struct nouveau_stateobj *vtxattr;
+ unsigned vtxelt_nr;
};
struct nv50_context {
@@ -152,6 +154,8 @@ struct nv50_context {
unsigned sampler_nr;
struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS];
unsigned miptree_nr;
+
+ uint16_t vbo_fifo;
};
static INLINE struct nv50_context *
@@ -198,6 +202,11 @@ extern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program
extern boolean nv50_state_validate(struct nv50_context *nv50);
extern void nv50_state_flush_notify(struct nouveau_channel *chan);
+extern void nv50_so_init_sifc(struct nv50_context *nv50,
+ struct nouveau_stateobj *so,
+ struct nouveau_bo *bo, unsigned reloc,
+ unsigned size);
+
/* nv50_tex.c */
extern void nv50_tex_validate(struct nv50_context *);
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 576d075318f..c7145bb9beb 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -32,6 +32,7 @@
#include "nv50_context.h"
#define NV50_SU_MAX_TEMP 64
+#define NV50_SU_MAX_ADDR 7
//#define NV50_PROGRAM_DUMP
/* ARL - gallium craps itself on progs/vp/arl.txt
@@ -79,7 +80,8 @@ struct nv50_reg {
P_ATTR,
P_RESULT,
P_CONST,
- P_IMMD
+ P_IMMD,
+ P_ADDR
} type;
int index;
@@ -99,6 +101,7 @@ struct nv50_pc {
/* hw resources */
struct nv50_reg *r_temp[NV50_SU_MAX_TEMP];
+ struct nv50_reg r_addr[NV50_SU_MAX_ADDR];
/* tgsi resources */
struct nv50_reg *temp;
@@ -112,6 +115,8 @@ struct nv50_pc {
struct nv50_reg *immd;
float *immd_buf;
int immd_nr;
+ struct nv50_reg **addr;
+ int addr_nr;
struct nv50_reg *temp_temp[16];
unsigned temp_temp_nr;
@@ -159,6 +164,17 @@ popcnt4(uint32_t val)
}
static void
+terminate_mbb(struct nv50_pc *pc)
+{
+ int i;
+
+ /* remove records of temporary address register values */
+ for (i = 0; i < NV50_SU_MAX_ADDR; ++i)
+ if (pc->r_addr[i].index < 0)
+ pc->r_addr[i].rhw = -1;
+}
+
+static void
alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg)
{
int i = 0;
@@ -454,9 +470,68 @@ set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e)
e->inst[1] |= (val >> 6) << 2;
}
+static void
+emit_set_addr(struct nv50_pc *pc, struct nv50_reg *dst, unsigned val)
+{
+ struct nv50_program_exec *e = exec(pc);
+
+ assert(val <= 0xffff);
+ e->inst[0] = 0xd0000000 | ((val & 0xffff) << 9);
+ e->inst[1] = 0x20000000;
+ e->inst[0] |= dst->hw << 2;
+ set_long(pc, e);
+
+ emit(pc, e);
+}
+
+static struct nv50_reg *
+alloc_addr(struct nv50_pc *pc, struct nv50_reg *ref)
+{
+ int i;
+ struct nv50_reg *a = NULL;
+
+ if (!ref) {
+ for (i = 0; i < NV50_SU_MAX_ADDR; ++i) {
+ if (pc->r_addr[i].index >= 0)
+ continue;
+ if (pc->r_addr[i].rhw >= 0 &&
+ pc->r_addr[i].acc == pc->insn_cur)
+ continue;
+
+ pc->r_addr[i].rhw = -1;
+ pc->r_addr[i].index = i;
+ return &pc->r_addr[i];
+ }
+ assert(0);
+ return NULL;
+ }
+
+ for (i = NV50_SU_MAX_ADDR - 1; i >= 0; --i) {
+ if (pc->r_addr[i].index >= 0) /* occupied for TGSI */
+ continue;
+ if (pc->r_addr[i].rhw < 0) { /* unused */
+ a = &pc->r_addr[i];
+ continue;
+ }
+ if (!a && pc->r_addr[i].acc != pc->insn_cur)
+ a = &pc->r_addr[i];
+
+ if (ref->hw - pc->r_addr[i].rhw < 128) {
+ /* alloc'd & suitable */
+ pc->r_addr[i].acc = pc->insn_cur;
+ return &pc->r_addr[i];
+ }
+ }
+ assert(a);
+ emit_set_addr(pc, a, ref->hw * 4);
+
+ a->rhw = ref->hw % 128;
+ a->acc = pc->insn_cur;
+ return a;
+}
#define INTERP_LINEAR 0
-#define INTERP_FLAT 1
+#define INTERP_FLAT 1
#define INTERP_PERSPECTIVE 2
#define INTERP_CENTROID 4
@@ -488,6 +563,16 @@ emit_interp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *iv,
emit(pc, e);
}
+static INLINE void
+set_addr(struct nv50_program_exec *e, struct nv50_reg *a)
+{
+ assert(!(e->inst[0] & 0x0c000000));
+ assert(!(e->inst[1] & 0x00000004));
+
+ e->inst[0] |= (a->hw & 3) << 26;
+ e->inst[1] |= (a->hw >> 2) << 2;
+}
+
static void
set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s,
struct nv50_program_exec *e)
@@ -498,6 +583,14 @@ set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s,
e->param.shift = s;
e->param.mask = m << (s % 32);
+ if (src->hw > 127)
+ set_addr(e, alloc_addr(pc, src));
+ else
+ if (src->acc < 0) {
+ assert(src->type == P_CONST);
+ set_addr(e, pc->addr[src->index]);
+ }
+
e->inst[1] |= (((src->type == P_IMMD) ? 0 : 1) << 22);
}
@@ -506,11 +599,13 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
{
struct nv50_program_exec *e = exec(pc);
- e->inst[0] |= 0x10000000;
+ e->inst[0] = 0x10000000;
+ if (!pc->allow32)
+ set_long(pc, e);
set_dst(pc, dst, e);
- if (pc->allow32 && dst->type != P_RESULT && src->type == P_IMMD) {
+ if (!is_long(e) && src->type == P_IMMD) {
set_immd(pc, src, e);
/*XXX: 32-bit, but steals part of "half" reg space - need to
* catch and handle this case if/when we do half-regs
@@ -630,7 +725,7 @@ set_src_1(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e)
}
alloc_reg(pc, src);
- e->inst[0] |= (src->hw << 16);
+ e->inst[0] |= ((src->hw & 127) << 16);
}
static void
@@ -658,7 +753,7 @@ set_src_2(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e)
}
alloc_reg(pc, src);
- e->inst[1] |= (src->hw << 14);
+ e->inst[1] |= ((src->hw & 127) << 14);
}
static void
@@ -721,6 +816,22 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst,
}
static void
+emit_arl(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src,
+ uint8_t s)
+{
+ struct nv50_program_exec *e = exec(pc);
+
+ set_long(pc, e);
+ e->inst[1] |= 0xc0000000;
+
+ e->inst[0] |= dst->hw << 2;
+ e->inst[0] |= s << 16; /* shift left */
+ set_src_0_restricted(pc, src, e);
+
+ emit(pc, e);
+}
+
+static void
emit_minmax(struct nv50_pc *pc, unsigned sub, struct nv50_reg *dst,
struct nv50_reg *src0, struct nv50_reg *src1)
{
@@ -837,7 +948,7 @@ emit_precossin(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
#define CVTOP_SAT 0x08
#define CVTOP_ABS 0x10
-/* 0x04 == 32 bit */
+/* 0x04 == 32 bit dst */
/* 0x40 == dst is float */
/* 0x80 == src is float */
#define CVT_F32_F32 0xc4
@@ -858,7 +969,7 @@ emit_cvt(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src,
set_long(pc, e);
e->inst[0] |= 0xa0000000;
- e->inst[1] |= 0x00004000;
+ e->inst[1] |= 0x00004000; /* 32 bit src */
e->inst[1] |= (cvn << 16);
e->inst[1] |= (fmt << 24);
set_src_0(pc, src, e);
@@ -1037,20 +1148,10 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
FREE(one);
}
-static void
+static INLINE void
emit_neg(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
{
- struct nv50_program_exec *e = exec(pc);
-
- set_long(pc, e);
- e->inst[0] |= 0xa0000000; /* delta */
- e->inst[1] |= (7 << 29); /* delta */
- e->inst[1] |= 0x04000000; /* negate arg0? probably not */
- e->inst[1] |= (1 << 14); /* src .f32 */
- set_dst(pc, dst, e);
- set_src_0(pc, src, e);
-
- emit(pc, e);
+ emit_cvt(pc, dst, src, -1, CVTOP_RN, CVT_F32_F32 | CVT_NEG);
}
static void
@@ -1058,22 +1159,18 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src)
{
struct nv50_program_exec *e;
const int r_pred = 1;
+ unsigned cvn = CVT_F32_F32;
- /* Sets predicate reg ? */
- e = exec(pc);
- e->inst[0] = 0xa00001fd;
- e->inst[1] = 0xc4014788;
- set_src_0(pc, src, e);
- set_pred_wr(pc, 1, r_pred, e);
if (src->neg)
- e->inst[1] |= 0x20000000;
- emit(pc, e);
+ cvn |= CVT_NEG;
+ /* write predicate reg */
+ emit_cvt(pc, NULL, src, r_pred, CVTOP_RN, cvn);
- /* This is probably KILP */
+ /* conditional discard */
e = exec(pc);
- e->inst[0] = 0x000001fe;
+ e->inst[0] = 0x00000002;
set_long(pc, e);
- set_pred(pc, 1 /* LT? */, r_pred, e);
+ set_pred(pc, 0x1 /* LT */, r_pred, e);
emit(pc, e);
}
@@ -1219,6 +1316,43 @@ emit_nop(struct nv50_pc *pc)
}
static void
+emit_ddx(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
+{
+ struct nv50_program_exec *e = exec(pc);
+
+ assert(src->type == P_TEMP);
+
+ e->inst[0] = 0xc0140000;
+ e->inst[1] = 0x89800000;
+ set_long(pc, e);
+ set_dst(pc, dst, e);
+ set_src_0(pc, src, e);
+ set_src_2(pc, src, e);
+
+ emit(pc, e);
+}
+
+static void
+emit_ddy(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
+{
+ struct nv50_program_exec *e = exec(pc);
+
+ assert(src->type == P_TEMP);
+
+ if (!src->neg) /* ! double negation */
+ emit_neg(pc, src, src);
+
+ e->inst[0] = 0xc0150000;
+ e->inst[1] = 0x8a400000;
+ set_long(pc, e);
+ set_dst(pc, dst, e);
+ set_src_0(pc, src, e);
+ set_src_2(pc, src, e);
+
+ emit(pc, e);
+}
+
+static void
convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e)
{
unsigned q = 0, m = ~0;
@@ -1266,10 +1400,14 @@ convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e)
e->inst[1] |= q;
}
+/* Some operations support an optional negation flag. */
static boolean
negate_supported(const struct tgsi_full_instruction *insn, int i)
{
+ int s;
+
switch (insn->Instruction.Opcode) {
+ case TGSI_OPCODE_DDY:
case TGSI_OPCODE_DP3:
case TGSI_OPCODE_DP4:
case TGSI_OPCODE_MUL:
@@ -1277,12 +1415,29 @@ negate_supported(const struct tgsi_full_instruction *insn, int i)
case TGSI_OPCODE_ADD:
case TGSI_OPCODE_SUB:
case TGSI_OPCODE_MAD:
- return TRUE;
+ break;
case TGSI_OPCODE_POW:
- return (i == 1) ? TRUE : FALSE;
+ if (i == 1)
+ break;
+ return FALSE;
default:
return FALSE;
}
+
+ /* Watch out for possible multiple uses of an nv50_reg, we
+ * can't use nv50_reg::neg in these cases.
+ */
+ for (s = 0; s < insn->Instruction.NumSrcRegs; ++s) {
+ if (s == i)
+ continue;
+ if ((insn->FullSrcRegisters[s].SrcRegister.Index ==
+ insn->FullSrcRegisters[i].SrcRegister.Index) &&
+ (insn->FullSrcRegisters[s].SrcRegister.File ==
+ insn->FullSrcRegisters[i].SrcRegister.File))
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Return a read mask for source registers deduced from opcode & write mask. */
@@ -1357,6 +1512,16 @@ tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst)
return &pc->temp[dst->DstRegister.Index * 4 + c];
case TGSI_FILE_OUTPUT:
return &pc->result[dst->DstRegister.Index * 4 + c];
+ case TGSI_FILE_ADDRESS:
+ {
+ struct nv50_reg *r = pc->addr[dst->DstRegister.Index * 4 + c];
+ if (!r) {
+ r = alloc_addr(pc, NULL);
+ pc->addr[dst->DstRegister.Index * 4 + c] = r;
+ }
+ assert(r);
+ return r;
+ }
case TGSI_FILE_NULL:
return NULL;
default:
@@ -1372,7 +1537,10 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src,
{
struct nv50_reg *r = NULL;
struct nv50_reg *temp;
- unsigned sgn, c;
+ unsigned sgn, c, swz;
+
+ if (src->SrcRegister.File != TGSI_FILE_CONSTANT)
+ assert(!src->SrcRegister.Indirect);
sgn = tgsi_util_get_full_src_register_sign_mode(src, chan);
@@ -1390,13 +1558,29 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src,
r = &pc->temp[src->SrcRegister.Index * 4 + c];
break;
case TGSI_FILE_CONSTANT:
- r = &pc->param[src->SrcRegister.Index * 4 + c];
+ if (!src->SrcRegister.Indirect) {
+ r = &pc->param[src->SrcRegister.Index * 4 + c];
+ break;
+ }
+ /* Indicate indirection by setting r->acc < 0 and
+ * use the index field to select the address reg.
+ */
+ r = MALLOC_STRUCT(nv50_reg);
+ swz = tgsi_util_get_src_register_swizzle(
+ &src->SrcRegisterInd, 0);
+ ctor_reg(r, P_CONST,
+ src->SrcRegisterInd.Index * 4 + swz, c);
+ r->acc = -1;
break;
case TGSI_FILE_IMMEDIATE:
r = &pc->immd[src->SrcRegister.Index * 4 + c];
break;
case TGSI_FILE_SAMPLER:
break;
+ case TGSI_FILE_ADDRESS:
+ r = pc->addr[src->SrcRegister.Index * 4 + c];
+ assert(r);
+ break;
default:
assert(0);
break;
@@ -1632,8 +1816,15 @@ nv50_program_tx_insn(struct nv50_pc *pc,
emit_add(pc, dst[c], src[0][c], src[1][c]);
}
break;
+ case TGSI_OPCODE_ARL:
+ assert(src[0][0]);
+ temp = temp_temp(pc);
+ emit_cvt(pc, temp, src[0][0], -1, CVTOP_FLOOR, CVT_S32_F32);
+ emit_arl(pc, dst[0], temp, 4);
+ break;
case TGSI_OPCODE_BGNLOOP:
pc->loop_pos[pc->loop_lvl++] = pc->p->exec_size;
+ terminate_mbb(pc);
break;
case TGSI_OPCODE_BRK:
emit_branch(pc, -1, 0, NULL);
@@ -1648,6 +1839,18 @@ nv50_program_tx_insn(struct nv50_pc *pc,
CVTOP_CEIL, CVT_F32_F32 | CVT_RI);
}
break;
+ case TGSI_OPCODE_CMP:
+ pc->allow32 = FALSE;
+ for (c = 0; c < 4; c++) {
+ if (!(mask & (1 << c)))
+ continue;
+ emit_cvt(pc, NULL, src[0][c], 1, CVTOP_RN, CVT_F32_F32);
+ emit_mov(pc, dst[c], src[1][c]);
+ set_pred(pc, 0x1, 1, pc->p->exec_tail); /* @SF */
+ emit_mov(pc, dst[c], src[2][c]);
+ set_pred(pc, 0x6, 1, pc->p->exec_tail); /* @NSF */
+ }
+ break;
case TGSI_OPCODE_COS:
if (mask & 8) {
emit_precossin(pc, temp, src[0][3]);
@@ -1660,6 +1863,20 @@ nv50_program_tx_insn(struct nv50_pc *pc,
emit_precossin(pc, temp, src[0][0]);
emit_flop(pc, 5, brdc, temp);
break;
+ case TGSI_OPCODE_DDX:
+ for (c = 0; c < 4; c++) {
+ if (!(mask & (1 << c)))
+ continue;
+ emit_ddx(pc, dst[c], src[0][c]);
+ }
+ break;
+ case TGSI_OPCODE_DDY:
+ for (c = 0; c < 4; c++) {
+ if (!(mask & (1 << c)))
+ continue;
+ emit_ddy(pc, dst[c], src[0][c]);
+ }
+ break;
case TGSI_OPCODE_DP3:
emit_mul(pc, temp, src[0][0], src[1][0]);
emit_mad(pc, temp, src[0][1], src[1][1], temp);
@@ -1691,6 +1908,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
emit_branch(pc, -1, 0, NULL);
pc->if_insn[--pc->if_lvl]->param.index = pc->p->exec_size;
pc->if_insn[pc->if_lvl++] = pc->p->exec_tail;
+ terminate_mbb(pc);
break;
case TGSI_OPCODE_ENDIF:
pc->if_insn[--pc->if_lvl]->param.index = pc->p->exec_size;
@@ -1703,6 +1921,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
pc->br_join[pc->if_lvl]->param.index = pc->p->exec_size;
pc->br_join[pc->if_lvl] = NULL;
}
+ terminate_mbb(pc);
/* emit a NOP as join point, we could set it on the next
* one, but would have to make sure it is long and !immd
*/
@@ -1713,6 +1932,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
emit_branch(pc, -1, 0, NULL);
pc->p->exec_tail->param.index = pc->loop_pos[--pc->loop_lvl];
pc->br_loop[pc->loop_lvl]->param.index = pc->p->exec_size;
+ terminate_mbb(pc);
break;
case TGSI_OPCODE_EX2:
emit_preex2(pc, temp, src[0][0]);
@@ -1740,6 +1960,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
set_pred_wr(pc, 1, 0, pc->if_cond);
emit_branch(pc, 0, 2, &pc->br_join[pc->if_lvl]);
pc->if_insn[pc->if_lvl++] = pc->p->exec_tail;
+ terminate_mbb(pc);
break;
case TGSI_OPCODE_KIL:
emit_kil(pc, src[0][0]);
@@ -1914,8 +2135,12 @@ nv50_program_tx_insn(struct nv50_pc *pc,
for (c = 0; c < 4; c++) {
if (!src[i][c])
continue;
+ src[i][c]->neg = 0;
if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD)
FREE(src[i][c]);
+ else
+ if (src[i][c]->acc < 0 && src[i][c]->type == P_CONST)
+ FREE(src[i][c]); /* indirect constant */
}
}
@@ -2259,8 +2484,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
pc->interp_mode[i] = mode;
}
break;
+ case TGSI_FILE_ADDRESS:
case TGSI_FILE_CONSTANT:
- break;
case TGSI_FILE_SAMPLER:
break;
default:
@@ -2454,6 +2679,8 @@ ctor_nv50_pc(struct nv50_pc *pc, struct nv50_program *p)
pc->attr_nr = p->info.file_max[TGSI_FILE_INPUT] + 1;
pc->result_nr = p->info.file_max[TGSI_FILE_OUTPUT] + 1;
pc->param_nr = p->info.file_max[TGSI_FILE_CONSTANT] + 1;
+ pc->addr_nr = p->info.file_max[TGSI_FILE_ADDRESS] + 1;
+ assert(pc->addr_nr <= 2);
p->cfg.high_temp = 4;
@@ -2522,6 +2749,14 @@ ctor_nv50_pc(struct nv50_pc *pc, struct nv50_program *p)
ctor_reg(&pc->param[rid], P_CONST, i, rid);
}
+ if (pc->addr_nr) {
+ pc->addr = CALLOC(pc->addr_nr * 4, sizeof(struct nv50_reg *));
+ if (!pc->addr)
+ return FALSE;
+ }
+ for (i = 0; i < NV50_SU_MAX_ADDR; ++i)
+ ctor_reg(&pc->r_addr[i], P_ADDR, -1, i + 1);
+
return TRUE;
}
@@ -2701,7 +2936,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
p->immd_nr, NV50_CB_PMISC);
}
- assert(p->param_nr <= 128);
+ assert(p->param_nr <= 512);
if (p->param_nr) {
unsigned cb;
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index dd7baecba7c..63dce0f4c22 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -218,7 +218,16 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
tesla_class = NV54TCL;
break;
case 0xa0:
- tesla_class = NVA0TCL;
+ switch (chipset) {
+ case 0xa0:
+ case 0xaa:
+ case 0xac:
+ tesla_class = NVA0TCL;
+ break;
+ default:
+ tesla_class = 0x8597;
+ break;
+ }
break;
default:
NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset);
@@ -226,12 +235,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
return NULL;
}
- if (tesla_class == 0) {
- NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
- nv50_screen_destroy(pscreen);
- return NULL;
- }
-
ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class,
&screen->tesla);
if (ret) {
@@ -301,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
so_data (so, 8);
/* constant buffers for immediates and VP/FP parameters */
- ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
+ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (32 * 4) * 4,
&screen->constbuf_misc[0]);
if (ret) {
nv50_screen_destroy(pscreen);
@@ -309,7 +312,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
}
for (i = 0; i < 2; i++) {
- ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
+ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (128 * 4) * 4,
&screen->constbuf_parm[i]);
if (ret) {
nv50_screen_destroy(pscreen);
@@ -318,8 +321,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
}
if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) ||
- nouveau_resource_init(&screen->parm_heap[0], 0, 128) ||
- nouveau_resource_init(&screen->parm_heap[1], 0, 128))
+ nouveau_resource_init(&screen->parm_heap[0], 0, 512) ||
+ nouveau_resource_init(&screen->parm_heap[1], 0, 512))
{
NOUVEAU_ERR("Error initialising constant buffers.\n");
nv50_screen_destroy(pscreen);
@@ -340,7 +343,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
- so_data (so, (NV50_CB_PMISC << 16) | 0x00000800);
+ so_data (so, (NV50_CB_PMISC << 16) | 0x00000200);
so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
so_data (so, 0x00000001 | (NV50_CB_PMISC << 12));
so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
@@ -364,48 +367,31 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
so_data (so, 0x00000131 | (NV50_CB_PFP << 12));
- /* Texture sampler/image unit setup - we abuse the constant buffer
- * upload mechanism for the moment to upload data to the tex config
- * blocks. At some point we *may* want to go the NVIDIA way of doing
- * things?
- */
- ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic);
+ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 64*8*4, &screen->tic);
if (ret) {
nv50_screen_destroy(pscreen);
return NULL;
}
- so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
- so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
- so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
- so_data (so, (NV50_CB_TIC << 16) | 0x0800);
so_method(so, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3);
so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
- so_data (so, 0x00000800);
+ so_data (so, 0x000007ff);
- ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc);
+ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 64*8*4, &screen->tsc);
if (ret) {
nv50_screen_destroy(pscreen);
return NULL;
}
- so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
- so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
- so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
- so_data (so, (NV50_CB_TSC << 16) | 0x0800);
so_method(so, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3);
so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
- so_data (so, 0x00000800);
+ so_data (so, 0x00000000);
/* Vertex array limits - max them out */
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index 81fa3e34c59..ffaa5e29d1c 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -146,6 +146,7 @@ nv50_sampler_state_create(struct pipe_context *pipe,
(wrap_mode(cso->wrap_r) << 6));
switch (cso->mag_img_filter) {
+ case PIPE_TEX_FILTER_ANISO:
case PIPE_TEX_FILTER_LINEAR:
tsc[1] |= NV50TSC_1_1_MAGF_LINEAR;
break;
@@ -156,6 +157,7 @@ nv50_sampler_state_create(struct pipe_context *pipe,
}
switch (cso->min_img_filter) {
+ case PIPE_TEX_FILTER_ANISO:
case PIPE_TEX_FILTER_LINEAR:
tsc[1] |= NV50TSC_1_1_MINF_LINEAR;
break;
@@ -183,21 +185,15 @@ nv50_sampler_state_create(struct pipe_context *pipe,
else
if (cso->max_anisotropy >= 12.0)
tsc[0] |= (6 << 20);
- else
- if (cso->max_anisotropy >= 10.0)
- tsc[0] |= (5 << 20);
- else
- if (cso->max_anisotropy >= 8.0)
- tsc[0] |= (4 << 20);
- else
- if (cso->max_anisotropy >= 6.0)
- tsc[0] |= (3 << 20);
- else
- if (cso->max_anisotropy >= 4.0)
- tsc[0] |= (2 << 20);
- else
- if (cso->max_anisotropy >= 2.0)
- tsc[0] |= (1 << 20);
+ else {
+ tsc[0] |= (int)(cso->max_anisotropy * 0.5f) << 20;
+
+ if (cso->max_anisotropy >= 4.0)
+ tsc[1] |= NV50TSC_1_1_UNKN_ANISO_35;
+ else
+ if (cso->max_anisotropy >= 2.0)
+ tsc[1] |= NV50TSC_1_1_UNKN_ANISO_15;
+ }
if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
tsc[0] |= (1 << 8);
diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c
index fd276203710..012911f41bd 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -222,6 +222,9 @@ nv50_state_flush_notify(struct nouveau_channel *chan)
{
struct nv50_context *nv50 = chan->user_private;
+ if (nv50->state.tic_upload && !(nv50->dirty & NV50_NEW_TEXTURE))
+ so_emit(chan, nv50->state.tic_upload);
+
so_emit_reloc_markers(chan, nv50->state.fb);
so_emit_reloc_markers(chan, nv50->state.vertprog);
so_emit_reloc_markers(chan, nv50->state.fragprog);
@@ -233,6 +236,7 @@ boolean
nv50_state_validate(struct nv50_context *nv50)
{
struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct nouveau_grobj *eng2d = nv50->screen->eng2d;
struct nouveau_stateobj *so;
unsigned i;
@@ -354,18 +358,25 @@ scissor_uptodate:
viewport_uptodate:
if (nv50->dirty & NV50_NEW_SAMPLER) {
- int i;
+ unsigned i;
+
+ so = so_new(nv50->sampler_nr * 9 + 23 + 4, 2);
+
+ nv50_so_init_sifc(nv50, so, nv50->screen->tsc, NOUVEAU_BO_VRAM,
+ nv50->sampler_nr * 8 * 4);
- so = so_new(nv50->sampler_nr * 9 + 2, 0);
- so_method(so, tesla, NV50TCL_CB_ADDR, 1);
- so_data (so, NV50_CB_TSC);
for (i = 0; i < nv50->sampler_nr; i++) {
if (!nv50->sampler[i])
continue;
-
- so_method(so, tesla, NV50TCL_CB_DATA(0) | (2<<29), 8);
+ so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8);
so_datap (so, nv50->sampler[i]->tsc, 8);
}
+
+ so_method(so, tesla, 0x1440, 1); /* sync SIFC */
+ so_data (so, 0);
+ so_method(so, tesla, 0x1334, 1); /* flush TSC */
+ so_data (so, 0);
+
so_ref(so, &nv50->state.tsc_upload);
so_ref(NULL, &so);
}
@@ -383,3 +394,33 @@ viewport_uptodate:
return TRUE;
}
+void nv50_so_init_sifc(struct nv50_context *nv50,
+ struct nouveau_stateobj *so,
+ struct nouveau_bo *bo, unsigned reloc, unsigned size)
+{
+ struct nouveau_grobj *eng2d = nv50->screen->eng2d;
+
+ so_method(so, eng2d, NV50_2D_DST_FORMAT, 2);
+ so_data (so, NV50_2D_DST_FORMAT_R8_UNORM);
+ so_data (so, 1);
+ so_method(so, eng2d, NV50_2D_DST_PITCH, 5);
+ so_data (so, 262144);
+ so_data (so, 65536);
+ so_data (so, 1);
+ so_reloc (so, bo, 0, reloc | NOUVEAU_BO_WR | NOUVEAU_BO_HIGH, 0, 0);
+ so_reloc (so, bo, 0, reloc | NOUVEAU_BO_WR | NOUVEAU_BO_LOW, 0, 0);
+ so_method(so, eng2d, NV50_2D_SIFC_UNK0800, 2);
+ so_data (so, 0);
+ so_data (so, NV50_2D_SIFC_FORMAT_R8_UNORM);
+ so_method(so, eng2d, NV50_2D_SIFC_WIDTH, 10);
+ so_data (so, size);
+ so_data (so, 1);
+ so_data (so, 0);
+ so_data (so, 1);
+ so_data (so, 0);
+ so_data (so, 1);
+ so_data (so, 0);
+ so_data (so, 0);
+ so_data (so, 0);
+ so_data (so, 0);
+}
diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c
index 72d33150af1..e12a6ad648b 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -25,106 +25,60 @@
#include "nouveau/nouveau_stateobj.h"
+#define _(pf, tt, r, g, b, a, tf) \
+{ \
+ PIPE_FORMAT_##pf, \
+ NV50TIC_0_0_MAPR_##r | NV50TIC_0_0_TYPER_##tt | \
+ NV50TIC_0_0_MAPG_##g | NV50TIC_0_0_TYPEG_##tt | \
+ NV50TIC_0_0_MAPB_##b | NV50TIC_0_0_TYPEB_##tt | \
+ NV50TIC_0_0_MAPA_##a | NV50TIC_0_0_TYPEA_##tt | \
+ NV50TIC_0_0_FMT_##tf \
+}
+
+struct nv50_texture_format {
+ enum pipe_format pf;
+ uint32_t hw;
+};
+
+#define NV50_TEX_FORMAT_LIST_SIZE \
+ (sizeof(nv50_tex_format_list) / sizeof(struct nv50_texture_format))
+
+static const struct nv50_texture_format nv50_tex_format_list[] =
+{
+ _(A8R8G8B8_UNORM, UNORM, C2, C1, C0, C3, 8_8_8_8),
+ _(X8R8G8B8_UNORM, UNORM, C2, C1, C0, ONE, 8_8_8_8),
+ _(A1R5G5B5_UNORM, UNORM, C2, C1, C0, C3, 1_5_5_5),
+ _(A4R4G4B4_UNORM, UNORM, C2, C1, C0, C3, 4_4_4_4),
+
+ _(R5G6B5_UNORM, UNORM, C2, C1, C0, ONE, 5_6_5),
+
+ _(L8_UNORM, UNORM, C0, C0, C0, ONE, 8),
+ _(A8_UNORM, UNORM, ZERO, ZERO, ZERO, C0, 8),
+ _(I8_UNORM, UNORM, C0, C0, C0, C0, 8),
+
+ _(A8L8_UNORM, UNORM, C0, C0, C0, C1, 8_8),
+
+ _(DXT1_RGB, UNORM, C0, C1, C2, ONE, DXT1),
+ _(DXT1_RGBA, UNORM, C0, C1, C2, C3, DXT1),
+ _(DXT3_RGBA, UNORM, C0, C1, C2, C3, DXT3),
+ _(DXT5_RGBA, UNORM, C0, C1, C2, C3, DXT5)
+};
+
+#undef _
+
static int
nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
struct nv50_miptree *mt, int unit)
{
- switch (mt->base.base.format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_8_8_8_8);
- break;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_8_8_8_8);
- break;
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_1_5_5_5);
- break;
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_4_4_4_4);
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_5_6_5);
- break;
- case PIPE_FORMAT_L8_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_8);
- break;
- case PIPE_FORMAT_A8_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_8);
- break;
- case PIPE_FORMAT_I8_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_8);
- break;
- case PIPE_FORMAT_A8L8_UNORM:
- so_data(so, NV50TIC_0_0_MAPA_C1 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_8_8);
- break;
- case PIPE_FORMAT_DXT1_RGB:
- so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_DXT1);
- break;
- case PIPE_FORMAT_DXT1_RGBA:
- so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_DXT1);
- break;
- case PIPE_FORMAT_DXT3_RGBA:
- so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_DXT3);
- break;
- case PIPE_FORMAT_DXT5_RGBA:
- so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
- NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
- NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
- NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
- NV50TIC_0_0_FMT_DXT5);
- break;
- default:
- return 1;
- }
+ unsigned i;
+ for (i = 0; i < NV50_TEX_FORMAT_LIST_SIZE; i++)
+ if (nv50_tex_format_list[i].pf == mt->base.base.format)
+ break;
+ if (i == NV50_TEX_FORMAT_LIST_SIZE)
+ return 1;
+
+ so_data (so, nv50_tex_format_list[i].hw);
so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
NOUVEAU_BO_RD, 0, 0);
if (nv50->sampler[unit]->normalized)
@@ -144,23 +98,24 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
void
nv50_tex_validate(struct nv50_context *nv50)
{
+ struct nouveau_grobj *eng2d = nv50->screen->eng2d;
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nouveau_stateobj *so;
- int unit, push;
+ unsigned i, unit, push;
+
+ push = MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2 + 23 + 6;
+ so = so_new(nv50->miptree_nr * 9 + push, nv50->miptree_nr + 2);
- push = nv50->miptree_nr * 9 + 2;
- push += MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2;
+ nv50_so_init_sifc(nv50, so, nv50->screen->tic, NOUVEAU_BO_VRAM,
+ nv50->miptree_nr * 8 * 4);
- so = so_new(push, nv50->miptree_nr * 2);
- so_method(so, tesla, NV50TCL_CB_ADDR, 1);
- so_data (so, NV50_CB_TIC);
- for (unit = 0; unit < nv50->miptree_nr; unit++) {
+ for (i = 0, unit = 0; unit < nv50->miptree_nr; ++unit) {
struct nv50_miptree *mt = nv50->miptree[unit];
if (!mt)
continue;
- so_method(so, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
+ so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8);
if (nv50_tex_construct(nv50, so, mt, unit)) {
NOUVEAU_ERR("failed tex validate\n");
so_ref(NULL, &so);
@@ -168,17 +123,25 @@ nv50_tex_validate(struct nv50_context *nv50)
}
so_method(so, tesla, NV50TCL_SET_SAMPLER_TEX, 1);
- so_data (so, (unit << NV50TCL_SET_SAMPLER_TEX_TIC_SHIFT) |
- (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) |
- NV50TCL_SET_SAMPLER_TEX_VALID);
+ so_data (so, (i++ << NV50TCL_SET_SAMPLER_TEX_TIC_SHIFT) |
+ (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) |
+ NV50TCL_SET_SAMPLER_TEX_VALID);
}
for (; unit < nv50->state.miptree_nr; unit++) {
so_method(so, tesla, NV50TCL_SET_SAMPLER_TEX, 1);
so_data (so,
- (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | 0);
+ (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | 0);
}
+ /* not sure if the following really do what I think: */
+ so_method(so, tesla, 0x1440, 1); /* sync SIFC */
+ so_data (so, 0);
+ so_method(so, tesla, 0x1330, 1); /* flush TIC */
+ so_data (so, 0);
+ so_method(so, tesla, 0x1338, 1); /* flush texture caches */
+ so_data (so, 0x20);
+
so_ref(so, &nv50->state.tic_upload);
so_ref(NULL, &so);
nv50->state.miptree_nr = nv50->miptree_nr;
diff --git a/src/gallium/drivers/nv50/nv50_texture.h b/src/gallium/drivers/nv50/nv50_texture.h
index 207fb039f70..13f74c11c6b 100644
--- a/src/gallium/drivers/nv50/nv50_texture.h
+++ b/src/gallium/drivers/nv50/nv50_texture.h
@@ -133,6 +133,8 @@
#define NV50TSC_1_1_MIPF_NEAREST 0x00000080
#define NV50TSC_1_1_MIPF_LINEAR 0x000000c0
#define NV50TSC_1_1_LOD_BIAS_MASK 0x01fff000
+#define NV50TSC_1_1_UNKN_ANISO_15 0x10000000
+#define NV50TSC_1_1_UNKN_ANISO_35 0x18000000
#define NV50TSC_1_2_MIN_LOD_MASK 0x00000f00
#define NV50TSC_1_2_MAX_LOD_MASK 0x00f00000
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c
index eeed148c7b9..db54380241f 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -26,6 +26,18 @@
#include "nv50_context.h"
+static boolean
+nv50_push_elements_u08(struct nv50_context *, uint8_t *, unsigned);
+
+static boolean
+nv50_push_elements_u16(struct nv50_context *, uint16_t *, unsigned);
+
+static boolean
+nv50_push_elements_u32(struct nv50_context *, uint32_t *, unsigned);
+
+static boolean
+nv50_push_arrays(struct nv50_context *, unsigned, unsigned);
+
static INLINE unsigned
nv50_prim(unsigned mode)
{
@@ -132,6 +144,7 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_channel *chan = nv50->screen->tesla->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
+ boolean ret;
nv50_state_validate(nv50);
@@ -139,24 +152,25 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
OUT_RING (chan, 0);
BEGIN_RING(chan, tesla, 0x142c, 1);
OUT_RING (chan, 0);
- BEGIN_RING(chan, tesla, 0x1440, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, tesla, 0x1334, 1);
- OUT_RING (chan, 0);
BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1);
OUT_RING (chan, nv50_prim(mode));
- BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2);
- OUT_RING (chan, start);
- OUT_RING (chan, count);
+
+ if (nv50->vbo_fifo)
+ ret = nv50_push_arrays(nv50, start, count);
+ else {
+ BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2);
+ OUT_RING (chan, start);
+ OUT_RING (chan, count);
+ ret = TRUE;
+ }
BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);
OUT_RING (chan, 0);
- pipe->flush(pipe, 0, NULL);
- return TRUE;
+ return ret;
}
-static INLINE void
+static INLINE boolean
nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
unsigned start, unsigned count)
{
@@ -165,6 +179,9 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
map += start;
+ if (nv50->vbo_fifo)
+ return nv50_push_elements_u08(nv50, map, count);
+
if (count & 1) {
BEGIN_RING(chan, tesla, 0x15e8, 1);
OUT_RING (chan, map[0]);
@@ -183,9 +200,10 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
count -= nr;
map += nr;
}
+ return TRUE;
}
-static INLINE void
+static INLINE boolean
nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
unsigned start, unsigned count)
{
@@ -194,6 +212,9 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
map += start;
+ if (nv50->vbo_fifo)
+ return nv50_push_elements_u16(nv50, map, count);
+
if (count & 1) {
BEGIN_RING(chan, tesla, 0x15e8, 1);
OUT_RING (chan, map[0]);
@@ -212,9 +233,10 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
count -= nr;
map += nr;
}
+ return TRUE;
}
-static INLINE void
+static INLINE boolean
nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map,
unsigned start, unsigned count)
{
@@ -223,6 +245,9 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map,
map += start;
+ if (nv50->vbo_fifo)
+ return nv50_push_elements_u32(nv50, map, count);
+
while (count) {
unsigned nr = count > 2047 ? 2047 : count;
@@ -232,6 +257,7 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map,
count -= nr;
map += nr;
}
+ return TRUE;
}
boolean
@@ -244,6 +270,7 @@ nv50_draw_elements(struct pipe_context *pipe,
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct pipe_screen *pscreen = pipe->screen;
void *map;
+ boolean ret;
map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
@@ -258,23 +285,25 @@ nv50_draw_elements(struct pipe_context *pipe,
OUT_RING (chan, nv50_prim(mode));
switch (indexSize) {
case 1:
- nv50_draw_elements_inline_u08(nv50, map, start, count);
+ ret = nv50_draw_elements_inline_u08(nv50, map, start, count);
break;
case 2:
- nv50_draw_elements_inline_u16(nv50, map, start, count);
+ ret = nv50_draw_elements_inline_u16(nv50, map, start, count);
break;
case 4:
- nv50_draw_elements_inline_u32(nv50, map, start, count);
+ ret = nv50_draw_elements_inline_u32(nv50, map, start, count);
break;
default:
assert(0);
+ ret = FALSE;
+ break;
}
BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);
OUT_RING (chan, 0);
pipe_buffer_unmap(pscreen, indexBuffer);
- pipe->flush(pipe, 0, NULL);
- return TRUE;
+
+ return ret;
}
static INLINE boolean
@@ -341,17 +370,24 @@ nv50_vbo_validate(struct nv50_context *nv50)
{
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nouveau_stateobj *vtxbuf, *vtxfmt, *vtxattr;
- unsigned i;
+ unsigned i, n_ve;
/* don't validate if Gallium took away our buffers */
if (nv50->vtxbuf_nr == 0)
return;
+ nv50->vbo_fifo = 0;
+
+ for (i = 0; i < nv50->vtxbuf_nr; ++i)
+ if (nv50->vtxbuf[i].stride &&
+ !(nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX))
+ nv50->vbo_fifo = 0xffff;
+
+ n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr);
vtxattr = NULL;
- vtxbuf = so_new(nv50->vtxelt_nr * 7, nv50->vtxelt_nr * 4);
- vtxfmt = so_new(nv50->vtxelt_nr + 1, 0);
- so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0),
- nv50->vtxelt_nr);
+ vtxbuf = so_new(n_ve * 7, nv50->vtxelt_nr * 4);
+ vtxfmt = so_new(n_ve + 1, 0);
+ so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve);
for (i = 0; i < nv50->vtxelt_nr; i++) {
struct pipe_vertex_element *ve = &nv50->vtxelt[i];
@@ -367,10 +403,19 @@ nv50_vbo_validate(struct nv50_context *nv50)
so_method(vtxbuf, tesla,
NV50TCL_VERTEX_ARRAY_FORMAT(i), 1);
so_data (vtxbuf, 0);
+
+ nv50->vbo_fifo &= ~(1 << i);
continue;
}
so_data(vtxfmt, hw | i);
+ if (nv50->vbo_fifo) {
+ so_method(vtxbuf, tesla,
+ NV50TCL_VERTEX_ARRAY_FORMAT(i), 1);
+ so_data (vtxbuf, 0);
+ continue;
+ }
+
so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 3);
so_data (vtxbuf, 0x20000000 | vb->stride);
so_reloc (vtxbuf, bo, vb->buffer_offset +
@@ -389,6 +434,13 @@ nv50_vbo_validate(struct nv50_context *nv50)
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
NOUVEAU_BO_LOW, 0, 0);
}
+ for (; i < n_ve; ++i) {
+ so_data (vtxfmt, 0x7e080010);
+
+ so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1);
+ so_data (vtxbuf, 0);
+ }
+ nv50->state.vtxelt_nr = nv50->vtxelt_nr;
so_ref (vtxfmt, &nv50->state.vtxfmt);
so_ref (vtxbuf, &nv50->state.vtxbuf);
@@ -398,3 +450,320 @@ nv50_vbo_validate(struct nv50_context *nv50)
so_ref (NULL, &vtxattr);
}
+typedef void (*pfn_push)(struct nouveau_channel *, void *);
+
+struct nv50_vbo_emitctx
+{
+ pfn_push push[16];
+ void *map[16];
+ unsigned stride[16];
+ unsigned nr_ve;
+ unsigned vtx_dwords;
+ unsigned vtx_max;
+};
+
+static INLINE void
+emit_vtx_next(struct nouveau_channel *chan, struct nv50_vbo_emitctx *emit)
+{
+ unsigned i;
+
+ for (i = 0; i < emit->nr_ve; ++i) {
+ emit->push[i](chan, emit->map[i]);
+ emit->map[i] += emit->stride[i];
+ }
+}
+
+static INLINE void
+emit_vtx(struct nouveau_channel *chan, struct nv50_vbo_emitctx *emit,
+ uint32_t vi)
+{
+ unsigned i;
+
+ for (i = 0; i < emit->nr_ve; ++i)
+ emit->push[i](chan, emit->map[i] + emit->stride[i] * vi);
+}
+
+static INLINE boolean
+nv50_map_vbufs(struct nv50_context *nv50)
+{
+ int i;
+
+ for (i = 0; i < nv50->vtxbuf_nr; ++i) {
+ struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i];
+ unsigned size, delta;
+
+ if (nouveau_bo(vb->buffer)->map)
+ continue;
+
+ size = vb->stride * (vb->max_index + 1);
+ delta = vb->buffer_offset;
+
+ if (!size)
+ size = vb->buffer->size - vb->buffer_offset;
+
+ if (nouveau_bo_map_range(nouveau_bo(vb->buffer),
+ delta, size, NOUVEAU_BO_RD))
+ break;
+ }
+
+ if (i == nv50->vtxbuf_nr)
+ return TRUE;
+ for (; i >= 0; --i)
+ nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer));
+ return FALSE;
+}
+
+static INLINE void
+nv50_unmap_vbufs(struct nv50_context *nv50)
+{
+ unsigned i;
+
+ for (i = 0; i < nv50->vtxbuf_nr; ++i)
+ if (nouveau_bo(nv50->vtxbuf[i].buffer)->map)
+ nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer));
+}
+
+static void
+emit_b32_1(struct nouveau_channel *chan, void *data)
+{
+ uint32_t *v = data;
+
+ OUT_RING(chan, v[0]);
+}
+
+static void
+emit_b32_2(struct nouveau_channel *chan, void *data)
+{
+ uint32_t *v = data;
+
+ OUT_RING(chan, v[0]);
+ OUT_RING(chan, v[1]);
+}
+
+static void
+emit_b32_3(struct nouveau_channel *chan, void *data)
+{
+ uint32_t *v = data;
+
+ OUT_RING(chan, v[0]);
+ OUT_RING(chan, v[1]);
+ OUT_RING(chan, v[2]);
+}
+
+static void
+emit_b32_4(struct nouveau_channel *chan, void *data)
+{
+ uint32_t *v = data;
+
+ OUT_RING(chan, v[0]);
+ OUT_RING(chan, v[1]);
+ OUT_RING(chan, v[2]);
+ OUT_RING(chan, v[3]);
+}
+
+static void
+emit_b16_1(struct nouveau_channel *chan, void *data)
+{
+ uint16_t *v = data;
+
+ OUT_RING(chan, v[0]);
+}
+
+static void
+emit_b16_3(struct nouveau_channel *chan, void *data)
+{
+ uint16_t *v = data;
+
+ OUT_RING(chan, (v[1] << 16) | v[0]);
+ OUT_RING(chan, v[2]);
+}
+
+static void
+emit_b08_1(struct nouveau_channel *chan, void *data)
+{
+ uint8_t *v = data;
+
+ OUT_RING(chan, v[0]);
+}
+
+static void
+emit_b08_3(struct nouveau_channel *chan, void *data)
+{
+ uint8_t *v = data;
+
+ OUT_RING(chan, (v[2] << 16) | (v[1] << 8) | v[0]);
+}
+
+static boolean
+emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
+ unsigned start)
+{
+ unsigned i;
+
+ if (nv50_map_vbufs(nv50) == FALSE)
+ return FALSE;
+
+ emit->nr_ve = 0;
+ emit->vtx_dwords = 0;
+
+ for (i = 0; i < nv50->vtxelt_nr; ++i) {
+ struct pipe_vertex_element *ve;
+ struct pipe_vertex_buffer *vb;
+ unsigned n, type, size;
+
+ ve = &nv50->vtxelt[i];
+ vb = &nv50->vtxbuf[ve->vertex_buffer_index];
+ if (!(nv50->vbo_fifo & (1 << i)))
+ continue;
+ n = emit->nr_ve++;
+
+ emit->stride[n] = vb->stride;
+ emit->map[n] = nouveau_bo(vb->buffer)->map +
+ (start * vb->stride + ve->src_offset);
+
+ type = pf_type(ve->src_format);
+ size = pf_size_x(ve->src_format) << pf_exp2(ve->src_format);
+
+ assert(ve->nr_components > 0 && ve->nr_components <= 4);
+
+ /* It shouldn't be necessary to push the implicit 1s
+ * for case 3 and size 8 cases 1, 2, 3.
+ */
+ switch (size) {
+ default:
+ NOUVEAU_ERR("unsupported vtxelt size: %u\n", size);
+ return FALSE;
+ case 32:
+ switch (ve->nr_components) {
+ case 1: emit->push[n] = emit_b32_1; break;
+ case 2: emit->push[n] = emit_b32_2; break;
+ case 3: emit->push[n] = emit_b32_3; break;
+ case 4: emit->push[n] = emit_b32_4; break;
+ }
+ emit->vtx_dwords += ve->nr_components;
+ break;
+ case 16:
+ switch (ve->nr_components) {
+ case 1: emit->push[n] = emit_b16_1; break;
+ case 2: emit->push[n] = emit_b32_1; break;
+ case 3: emit->push[n] = emit_b16_3; break;
+ case 4: emit->push[n] = emit_b32_2; break;
+ }
+ emit->vtx_dwords += (ve->nr_components + 1) >> 1;
+ break;
+ case 8:
+ switch (ve->nr_components) {
+ case 1: emit->push[n] = emit_b08_1; break;
+ case 2: emit->push[n] = emit_b16_1; break;
+ case 3: emit->push[n] = emit_b08_3; break;
+ case 4: emit->push[n] = emit_b32_1; break;
+ }
+ emit->vtx_dwords += 1;
+ break;
+ }
+ }
+
+ emit->vtx_max = 512 / emit->vtx_dwords;
+
+ return TRUE;
+}
+
+static boolean
+nv50_push_arrays(struct nv50_context *nv50, unsigned start, unsigned count)
+{
+ struct nouveau_channel *chan = nv50->screen->base.channel;
+ struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct nv50_vbo_emitctx emit;
+
+ if (emit_prepare(nv50, &emit, start) == FALSE)
+ return FALSE;
+
+ while (count) {
+ unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+ dw = nr * emit.vtx_dwords;
+
+ BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+ for (i = 0; i < nr; ++i)
+ emit_vtx_next(chan, &emit);
+
+ count -= nr;
+ }
+ nv50_unmap_vbufs(nv50);
+
+ return TRUE;
+}
+
+static boolean
+nv50_push_elements_u32(struct nv50_context *nv50, uint32_t *map, unsigned count)
+{
+ struct nouveau_channel *chan = nv50->screen->base.channel;
+ struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct nv50_vbo_emitctx emit;
+
+ if (emit_prepare(nv50, &emit, 0) == FALSE)
+ return FALSE;
+
+ while (count) {
+ unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+ dw = nr * emit.vtx_dwords;
+
+ BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+ for (i = 0; i < nr; ++i)
+ emit_vtx(chan, &emit, *map++);
+
+ count -= nr;
+ }
+ nv50_unmap_vbufs(nv50);
+
+ return TRUE;
+}
+
+static boolean
+nv50_push_elements_u16(struct nv50_context *nv50, uint16_t *map, unsigned count)
+{
+ struct nouveau_channel *chan = nv50->screen->base.channel;
+ struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct nv50_vbo_emitctx emit;
+
+ if (emit_prepare(nv50, &emit, 0) == FALSE)
+ return FALSE;
+
+ while (count) {
+ unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+ dw = nr * emit.vtx_dwords;
+
+ BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+ for (i = 0; i < nr; ++i)
+ emit_vtx(chan, &emit, *map++);
+
+ count -= nr;
+ }
+ nv50_unmap_vbufs(nv50);
+
+ return TRUE;
+}
+
+static boolean
+nv50_push_elements_u08(struct nv50_context *nv50, uint8_t *map, unsigned count)
+{
+ struct nouveau_channel *chan = nv50->screen->base.channel;
+ struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct nv50_vbo_emitctx emit;
+
+ if (emit_prepare(nv50, &emit, 0) == FALSE)
+ return FALSE;
+
+ while (count) {
+ unsigned i, dw, nr = MIN2(count, emit.vtx_max);
+ dw = nr * emit.vtx_dwords;
+
+ BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw);
+ for (i = 0; i < nr; ++i)
+ emit_vtx(chan, &emit, *map++);
+
+ count -= nr;
+ }
+ nv50_unmap_vbufs(nv50);
+
+ return TRUE;
+}
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index 69e4724790a..f73d80de882 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -4,8 +4,6 @@ include $(TOP)/configs/current
LIBNAME = r300
C_SOURCES = \
- r3xx_fs.c \
- r5xx_fs.c \
r300_chipset.c \
r300_clear.c \
r300_context.c \
@@ -20,7 +18,6 @@ C_SOURCES = \
r300_state_derived.c \
r300_state_invariant.c \
r300_vs.c \
- r300_surface.c \
r300_texture.c \
r300_tgsi_to_rc.c
diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c
index d138866d33c..51fdb82ff34 100644
--- a/src/gallium/drivers/r300/r300_chipset.c
+++ b/src/gallium/drivers/r300/r300_chipset.c
@@ -21,6 +21,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "r300_chipset.h"
+
#include "util/u_debug.h"
/* r300_chipset: A file all to itself for deducing the various properties of
@@ -31,7 +32,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
{
/* Reasonable defaults */
caps->num_vert_fpus = 4;
- caps->has_tcl = getenv("RADEON_NO_TCL") ? FALSE : TRUE;
+ caps->has_tcl = debug_get_bool_option("RADEON_NO_TCL", FALSE) ? FALSE : TRUE;
caps->is_r500 = FALSE;
caps->high_second_pipe = FALSE;
diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h
index 322d4a57e41..0633a8b8a72 100644
--- a/src/gallium/drivers/r300/r300_chipset.h
+++ b/src/gallium/drivers/r300/r300_chipset.h
@@ -33,9 +33,11 @@ struct r300_capabilities {
/* Chipset family */
int family;
/* The number of vertex floating-point units */
- int num_vert_fpus;
+ unsigned num_vert_fpus;
/* The number of fragment pipes */
- int num_frag_pipes;
+ unsigned num_frag_pipes;
+ /* The number of z pipes */
+ unsigned num_z_pipes;
/* Whether or not TCL is physically present */
boolean has_tcl;
/* Whether or not this is an RV515 or newer; R500s have many differences
diff --git a/src/gallium/drivers/r300/r300_clear.c b/src/gallium/drivers/r300/r300_clear.c
index 8b9cb819ae6..02d6d504fc0 100644
--- a/src/gallium/drivers/r300/r300_clear.c
+++ b/src/gallium/drivers/r300/r300_clear.c
@@ -21,6 +21,9 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "r300_clear.h"
+#include "r300_context.h"
+
+#include "util/u_clear.h"
/* Clears currently bound buffers. */
void r300_clear(struct pipe_context* pipe,
diff --git a/src/gallium/drivers/r300/r300_clear.h b/src/gallium/drivers/r300/r300_clear.h
index cd5900565e8..b8fcdf273c7 100644
--- a/src/gallium/drivers/r300/r300_clear.h
+++ b/src/gallium/drivers/r300/r300_clear.h
@@ -23,9 +23,7 @@
#ifndef R300_CLEAR_H
#define R300_CLEAR_H
-#include "util/u_clear.h"
-
-#include "r300_context.h"
+struct pipe_context;
void r300_clear(struct pipe_context* pipe,
unsigned buffers,
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 9cc455135db..c34fbb11235 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -20,90 +20,52 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "r300_context.h"
+#include "draw/draw_context.h"
-#include "r300_flush.h"
-#include "r300_state_invariant.h"
+#include "pipe/p_inlines.h"
-static boolean r300_draw_range_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
- unsigned indexSize,
- unsigned minIndex,
- unsigned maxIndex,
- unsigned mode,
- unsigned start,
- unsigned count)
-{
- struct r300_context* r300 = r300_context(pipe);
- int i;
-
- for (i = 0; i < r300->vertex_buffer_count; i++) {
- void* buf = pipe_buffer_map(pipe->screen,
- r300->vertex_buffers[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(r300->draw, i, buf);
- }
-
- if (indexBuffer) {
- void* indices = pipe_buffer_map(pipe->screen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer_range(r300->draw, indexSize,
- minIndex, maxIndex, indices);
- } else {
- draw_set_mapped_element_buffer(r300->draw, 0, NULL);
- }
+#include "tgsi/tgsi_scan.h"
- draw_set_mapped_constant_buffer(r300->draw,
- r300->shader_constants[PIPE_SHADER_VERTEX].constants,
- r300->shader_constants[PIPE_SHADER_VERTEX].count *
- (sizeof(float) * 4));
+#include "util/u_hash_table.h"
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
- draw_arrays(r300->draw, mode, start, count);
-
- for (i = 0; i < r300->vertex_buffer_count; i++) {
- pipe_buffer_unmap(pipe->screen, r300->vertex_buffers[i].buffer);
- draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
- }
-
- if (indexBuffer) {
- pipe_buffer_unmap(pipe->screen, indexBuffer);
- draw_set_mapped_element_buffer_range(r300->draw, 0, start,
- start + count - 1, NULL);
- }
-
- return TRUE;
-}
+#include "r300_clear.h"
+#include "r300_context.h"
+#include "r300_flush.h"
+#include "r300_query.h"
+#include "r300_render.h"
+#include "r300_screen.h"
+#include "r300_state_derived.h"
+#include "r300_state_invariant.h"
+#include "r300_winsys.h"
-static boolean r300_draw_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
- unsigned indexSize, unsigned mode,
- unsigned start, unsigned count)
+static enum pipe_error r300_clear_hash_table(void* key, void* value,
+ void* data)
{
- return r300_draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0,
- mode, start, count);
+ FREE(key);
+ FREE(value);
+ return PIPE_OK;
}
-static boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
- unsigned start, unsigned count)
+static void r300_destroy_context(struct pipe_context* context)
{
- return r300_draw_elements(pipe, NULL, 0, mode, start, count);
-}
-
-static void r300_destroy_context(struct pipe_context* context) {
struct r300_context* r300 = r300_context(context);
struct r300_query* query, * temp;
+ util_hash_table_foreach(r300->shader_hash_table, r300_clear_hash_table,
+ NULL);
+ util_hash_table_destroy(r300->shader_hash_table);
+
draw_destroy(r300->draw);
/* Free the OQ BO. */
context->screen->buffer_destroy(r300->oqbo);
/* If there are any queries pending or not destroyed, remove them now. */
- if (r300->query_list) {
- foreach_s(query, temp, r300->query_list) {
- remove_from_list(query);
- FREE(query);
- }
+ foreach_s(query, temp, &r300->query_list) {
+ remove_from_list(query);
+ FREE(query);
}
FREE(r300->blend_color_state);
@@ -136,6 +98,13 @@ r300_is_buffer_referenced( struct pipe_context *pipe,
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
+static void r300_flush_cb(void *data)
+{
+ struct r300_context* const cs_context_copy = data;
+
+ cs_context_copy->context.flush(&cs_context_copy->context, 0, NULL);
+}
+
struct pipe_context* r300_create_context(struct pipe_screen* screen,
struct r300_winsys* r300_winsys)
{
@@ -147,7 +116,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->winsys = r300_winsys;
r300->context.winsys = (struct pipe_winsys*)r300_winsys;
- r300->context.screen = r300_screen(screen);
+ r300->context.screen = screen;
r300_init_debug(r300);
@@ -157,11 +126,14 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->context.draw_arrays = r300_draw_arrays;
r300->context.draw_elements = r300_draw_elements;
- r300->context.draw_range_elements = r300_draw_range_elements;
+ r300->context.draw_range_elements = r300_swtcl_draw_range_elements;
r300->context.is_texture_referenced = r300_is_texture_referenced;
r300->context.is_buffer_referenced = r300_is_buffer_referenced;
+ r300->shader_hash_table = util_hash_table_create(r300_shader_key_hash,
+ r300_shader_key_compare);
+
r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);
r300->rs_block = CALLOC_STRUCT(r300_rs_block);
r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
@@ -185,13 +157,15 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300_init_query_functions(r300);
- r300_init_surface_functions(r300);
+ /* r300_init_surface_functions(r300); */
r300_init_state_functions(r300);
r300_emit_invariant_state(r300);
+
+ r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300);
r300->dirty_state = R300_NEW_KITCHEN_SINK;
r300->dirty_hw++;
-
+ make_empty_list(&r300->query_list);
return &r300->context;
}
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 086633f732d..30b80fa9db8 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -23,21 +23,10 @@
#ifndef R300_CONTEXT_H
#define R300_CONTEXT_H
-#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
#include "pipe/p_context.h"
-#include "tgsi/tgsi_scan.h"
-
-#include "util/u_memory.h"
-#include "util/u_simple_list.h"
-
-#include "r300_clear.h"
-#include "r300_query.h"
-#include "r300_screen.h"
-#include "r300_winsys.h"
-
struct r300_fragment_shader;
struct r300_vertex_shader;
@@ -62,7 +51,6 @@ struct r300_dsa_state {
uint32_t z_buffer_control; /* R300_ZB_CNTL: 0x4f00 */
uint32_t z_stencil_control; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */
uint32_t stencil_ref_mask; /* R300_ZB_STENCILREFMASK: 0x4f08 */
- uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */
uint32_t stencil_ref_bf; /* R500_ZB_STENCILREFMASK_BF: 0x4fd4 */
};
@@ -124,6 +112,10 @@ struct r300_viewport_state {
uint32_t vte_control; /* R300_VAP_VTE_CNTL: 0x20b0 */
};
+struct r300_ztop_state {
+ uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */
+};
+
#define R300_NEW_BLEND 0x00000001
#define R300_NEW_BLEND_COLOR 0x00000002
#define R300_NEW_CLIP 0x00000004
@@ -141,7 +133,8 @@ struct r300_viewport_state {
#define R300_NEW_VERTEX_FORMAT 0x04000000
#define R300_NEW_VERTEX_SHADER 0x08000000
#define R300_NEW_VIEWPORT 0x10000000
-#define R300_NEW_KITCHEN_SINK 0x1fffffff
+#define R300_NEW_QUERY 0x20000000
+#define R300_NEW_KITCHEN_SINK 0x3fffffff
/* The next several objects are not pure Radeon state; they inherit from
* various Gallium classes. */
@@ -172,6 +165,10 @@ struct r300_query {
unsigned int count;
/* The offset of this query into the query buffer, in bytes. */
unsigned offset;
+ /* if we've flushed the query */
+ boolean flushed;
+ /* if begin has been emitted */
+ boolean begin_emitted;
/* Linked list members. */
struct r300_query* prev;
struct r300_query* next;
@@ -237,7 +234,14 @@ struct r300_context {
/* Occlusion query buffer. */
struct pipe_buffer* oqbo;
/* Query list. */
- struct r300_query* query_list;
+ struct r300_query *query_current;
+ struct r300_query query_list;
+
+ /* Shader hash table. Used to store vertex formatting information, which
+ * depends on the combination of both currently loaded shaders. */
+ struct util_hash_table* shader_hash_table;
+ /* Vertex formatting information. */
+ struct r300_vertex_format* vertex_info;
/* Various CSO state objects. */
/* Blend state. */
@@ -269,12 +273,16 @@ struct r300_context {
/* Vertex buffers for Gallium. */
struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
int vertex_buffer_count;
- /* Vertex information. */
- struct r300_vertex_format vertex_info;
+ /* Vertex elements for Gallium. */
+ struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS];
+ int vertex_element_count;
/* Vertex shader. */
struct r300_vertex_shader* vs;
/* Viewport state. */
struct r300_viewport_state* viewport_state;
+ /* ZTOP state. */
+ struct r300_ztop_state ztop_state;
+
/* Bitmask of dirty state objects. */
uint32_t dirty_state;
/* Flag indicating whether or not the HW is dirty. */
@@ -312,9 +320,8 @@ void r300_init_surface_functions(struct r300_context* r300);
#define DBG_VP 0x0000004
#define DBG_CS 0x0000008
#define DBG_DRAW 0x0000010
-#define DBG_SURF 0x0000020
-#define DBG_TEX 0x0000040
-#define DBG_FALL 0x0000080
+#define DBG_TEX 0x0000020
+#define DBG_FALL 0x0000040
/*@}*/
static INLINE boolean DBG_ON(struct r300_context * ctx, unsigned flags)
diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c
index bfd4ab018a5..421253ca722 100644
--- a/src/gallium/drivers/r300/r300_debug.c
+++ b/src/gallium/drivers/r300/r300_debug.c
@@ -37,7 +37,6 @@ static struct debug_option debug_options[] = {
{ "vp", DBG_VP, "Vertex program handling" },
{ "cs", DBG_CS, "Command submissions" },
{ "draw", DBG_DRAW, "Draw and emit" },
- { "surf", DBG_SURF, "Surface drawing" },
{ "tex", DBG_TEX, "Textures" },
{ "fall", DBG_FALL, "Fallbacks" },
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 570b4c5ef7f..258c38fefdc 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -22,10 +22,15 @@
/* r300_emit: Functions for emitting state. */
-#include "r300_emit.h"
+#include "util/u_math.h"
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_emit.h"
#include "r300_fs.h"
+#include "r300_screen.h"
#include "r300_state_derived.h"
+#include "r300_state_inlines.h"
#include "r300_vs.h"
void r300_emit_blend_state(struct r300_context* r300,
@@ -106,7 +111,7 @@ void r300_emit_dsa_state(struct r300_context* r300,
OUT_CS(dsa->z_buffer_control);
OUT_CS(dsa->z_stencil_control);
OUT_CS(dsa->stencil_ref_mask);
- OUT_CS_REG(R300_ZB_ZTOP, dsa->z_buffer_top);
+ OUT_CS_REG(R300_ZB_ZTOP, r300->ztop_state.z_buffer_top);
if (r300screen->caps->is_r500) {
/* OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf); */
}
@@ -320,31 +325,37 @@ void r300_emit_fb_state(struct r300_context* r300,
END_CS;
}
-void r300_emit_query_begin(struct r300_context* r300,
- struct r300_query* query)
+static void r300_emit_query_start(struct r300_context *r300)
{
+ struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps;
+ struct r300_query *query = r300->query_current;
CS_LOCALS(r300);
+ if (!query)
+ return;
+
/* XXX This will almost certainly not return good results
* for overlapping queries. */
- BEGIN_CS(2);
+ BEGIN_CS(4);
+ if (caps->family == CHIP_FAMILY_RV530) {
+ OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
+ } else {
+ OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL);
+ }
OUT_CS_REG(R300_ZB_ZPASS_DATA, 0);
END_CS;
+ query->begin_emitted = TRUE;
}
-void r300_emit_query_end(struct r300_context* r300,
- struct r300_query* query)
+
+static void r300_emit_query_finish(struct r300_context *r300,
+ struct r300_query *query)
{
struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
CS_LOCALS(r300);
- if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo,
- 0, RADEON_GEM_DOMAIN_GTT)) {
- debug_printf("r300: There wasn't room for the OQ buffer!?"
- " Oh noes!\n");
- }
-
assert(caps->num_frag_pipes);
+
BEGIN_CS(6 * caps->num_frag_pipes + 2);
/* I'm not so sure I like this switch, but it's hard to be elegant
* when there's so many special cases...
@@ -381,7 +392,7 @@ void r300_emit_query_end(struct r300_context* r300,
OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 0),
0, RADEON_GEM_DOMAIN_GTT, 0);
- break;
+ break;
default:
debug_printf("r300: Implementation error: Chipset reports %d"
" pixel pipes!\n", caps->num_frag_pipes);
@@ -391,7 +402,55 @@ void r300_emit_query_end(struct r300_context* r300,
/* And, finally, reset it to normal... */
OUT_CS_REG(R300_SU_REG_DEST, 0xF);
END_CS;
+}
+static void rv530_emit_query_single(struct r300_context *r300,
+ struct r300_query *query)
+{
+ CS_LOCALS(r300);
+
+ BEGIN_CS(8);
+ OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_0);
+ OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+ OUT_CS_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
+ OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
+ END_CS;
+}
+
+static void rv530_emit_query_double(struct r300_context *r300,
+ struct r300_query *query)
+{
+ CS_LOCALS(r300);
+
+ BEGIN_CS(14);
+ OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_0);
+ OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+ OUT_CS_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
+ OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_1);
+ OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+ OUT_CS_RELOC(r300->oqbo, query->offset + sizeof(uint32_t), 0, RADEON_GEM_DOMAIN_GTT, 0);
+ OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
+ END_CS;
+}
+
+void r300_emit_query_end(struct r300_context* r300)
+{
+ struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps;
+ struct r300_query *query = r300->query_current;
+
+ if (!query)
+ return;
+
+ if (query->begin_emitted == FALSE)
+ return;
+
+ if (caps->family == CHIP_FAMILY_RV530) {
+ if (caps->num_z_pipes == 2)
+ rv530_emit_query_double(r300, query);
+ else
+ rv530_emit_query_single(r300, query);
+ } else
+ r300_emit_query_finish(r300, query);
}
void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
@@ -475,7 +534,8 @@ void r300_emit_texture(struct r300_context* r300,
CS_LOCALS(r300);
BEGIN_CS(16);
- OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
+ OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0 |
+ (offset << 28));
OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
@@ -494,7 +554,7 @@ void r300_emit_vertex_buffer(struct r300_context* r300)
DBG(r300, DBG_DRAW, "r300: Preparing vertex buffer %p for render, "
"vertex size %d\n", r300->vbo,
- r300->vertex_info.vinfo.size);
+ r300->vertex_info->vinfo.size);
/* Set the pointer to our vertex buffer. The emitted values are this:
* PACKET3 [3D_LOAD_VBPNTR]
* COUNT [1]
@@ -505,8 +565,8 @@ void r300_emit_vertex_buffer(struct r300_context* r300)
BEGIN_CS(7);
OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3);
OUT_CS(1);
- OUT_CS(r300->vertex_info.vinfo.size |
- (r300->vertex_info.vinfo.size << 8));
+ OUT_CS(r300->vertex_info->vinfo.size |
+ (r300->vertex_info->vinfo.size << 8));
OUT_CS(r300->vbo_offset);
OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
END_CS;
@@ -518,30 +578,30 @@ void r300_emit_vertex_format_state(struct r300_context* r300)
CS_LOCALS(r300);
BEGIN_CS(26);
- OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info.vinfo.size);
+ OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info->vinfo.size);
OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2);
- OUT_CS(r300->vertex_info.vinfo.hwfmt[0]);
- OUT_CS(r300->vertex_info.vinfo.hwfmt[1]);
+ OUT_CS(r300->vertex_info->vinfo.hwfmt[0]);
+ OUT_CS(r300->vertex_info->vinfo.hwfmt[1]);
OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
- OUT_CS(r300->vertex_info.vinfo.hwfmt[2]);
- OUT_CS(r300->vertex_info.vinfo.hwfmt[3]);
+ OUT_CS(r300->vertex_info->vinfo.hwfmt[2]);
+ OUT_CS(r300->vertex_info->vinfo.hwfmt[3]);
/* for (i = 0; i < 4; i++) {
* debug_printf("hwfmt%d: 0x%08x\n", i,
- * r300->vertex_info.vinfo.hwfmt[i]);
+ * r300->vertex_info->vinfo.hwfmt[i]);
* } */
OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8);
for (i = 0; i < 8; i++) {
- OUT_CS(r300->vertex_info.vap_prog_stream_cntl[i]);
+ OUT_CS(r300->vertex_info->vap_prog_stream_cntl[i]);
/* debug_printf("prog_stream_cntl%d: 0x%08x\n", i,
- * r300->vertex_info.vap_prog_stream_cntl[i]); */
+ * r300->vertex_info->vap_prog_stream_cntl[i]); */
}
OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, 8);
for (i = 0; i < 8; i++) {
- OUT_CS(r300->vertex_info.vap_prog_stream_cntl_ext[i]);
+ OUT_CS(r300->vertex_info->vap_prog_stream_cntl_ext[i]);
/* debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i,
- * r300->vertex_info.vap_prog_stream_cntl_ext[i]); */
+ * r300->vertex_info->vap_prog_stream_cntl_ext[i]); */
}
END_CS;
}
@@ -658,6 +718,9 @@ void r300_emit_dirty_state(struct r300_context* r300)
r300_update_derived_state(r300);
+ /* Clean out BOs. */
+ r300->winsys->reset_bos(r300->winsys);
+
/* XXX check size */
validate:
/* Color buffers... */
@@ -683,7 +746,8 @@ validate:
/* ...textures... */
for (i = 0; i < r300->texture_count; i++) {
tex = r300->textures[i];
- assert(tex && tex->buffer && "texture is marked, but NULL!");
+ if (!tex)
+ continue;
if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
r300->context.flush(&r300->context, 0, NULL);
@@ -717,6 +781,11 @@ validate:
goto validate;
}
+ if (r300->dirty_state & R300_NEW_QUERY) {
+ r300_emit_query_start(r300);
+ r300->dirty_state &= ~R300_NEW_QUERY;
+ }
+
if (r300->dirty_state & R300_NEW_BLEND) {
r300_emit_blend_state(r300, r300->blend_state);
r300->dirty_state &= ~R300_NEW_BLEND;
@@ -770,12 +839,13 @@ validate:
if (r300->dirty_state &
(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) {
for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
- if (r300->dirty_state &
- ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
- r300_emit_texture(r300,
- r300->sampler_states[i],
- r300->textures[i],
- i);
+ if (r300->dirty_state &
+ ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
+ if (r300->textures[i])
+ r300_emit_texture(r300,
+ r300->sampler_states[i],
+ r300->textures[i],
+ i);
r300->dirty_state &=
~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i));
dirty_tex++;
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index c4002b8e5d0..02ac5bebbd9 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -23,13 +23,6 @@
#ifndef R300_EMIT_H
#define R300_EMIT_H
-#include "util/u_math.h"
-
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_screen.h"
-#include "r300_state_inlines.h"
-
struct rX00_fragment_program_code;
struct r300_vertex_program_code;
@@ -58,8 +51,8 @@ void r300_emit_fb_state(struct r300_context* r300,
void r300_emit_query_begin(struct r300_context* r300,
struct r300_query* query);
-void r300_emit_query_end(struct r300_context* r300,
- struct r300_query* query);
+
+void r300_emit_query_end(struct r300_context* r300);
void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs);
diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c
index 0dff1c6f4fb..14a08241fc4 100644
--- a/src/gallium/drivers/r300/r300_flush.c
+++ b/src/gallium/drivers/r300/r300_flush.c
@@ -20,29 +20,48 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
+
+#include "util/u_simple_list.h"
+
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_emit.h"
#include "r300_flush.h"
+#include "r300_state_invariant.h"
static void r300_flush(struct pipe_context* pipe,
unsigned flags,
struct pipe_fence_handle** fence)
{
- struct r300_context* r300 = r300_context(pipe);
- CS_LOCALS(r300);
+ struct r300_context *r300 = r300_context(pipe);
+ struct r300_query *query;
+ CS_LOCALS(r300);
/* We probably need to flush Draw, but we may have been called from
- * within Draw. This feels kludgy, but it might be the best thing. */
- if (!r300->draw->flushing) {
+ * within Draw. This feels kludgy, but it might be the best thing.
+ *
+ * Of course, the best thing is to kill Draw with fire. :3 */
+ if (r300->draw && !r300->draw->flushing) {
draw_flush(r300->draw);
}
+ r300_emit_query_end(r300);
+
if (r300->dirty_hw) {
FLUSH_CS;
r300_emit_invariant_state(r300);
r300->dirty_state = R300_NEW_KITCHEN_SINK;
r300->dirty_hw = 0;
}
+ /* reset flushed query */
+ foreach(query, &r300->query_list) {
+ query->flushed = TRUE;
+ }
}
+
void r300_init_flush_functions(struct r300_context* r300)
{
r300->context.flush = r300_flush;
diff --git a/src/gallium/drivers/r300/r300_flush.h b/src/gallium/drivers/r300/r300_flush.h
index 9a83d89daab..0e9e6106bb7 100644
--- a/src/gallium/drivers/r300/r300_flush.h
+++ b/src/gallium/drivers/r300/r300_flush.h
@@ -23,13 +23,6 @@
#ifndef R300_FLUSH_H
#define R300_FLUSH_H
-#include "draw/draw_private.h"
-
-#include "pipe/p_context.h"
-
-#include "r300_context.h"
-#include "r300_cs.h"
-
void r300_init_flush_functions(struct r300_context* r300);
#endif /* R300_FLUSH_H */
diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
index 546ad545a53..29ddc84c411 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -21,10 +21,14 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "r300_fs.h"
+#include "tgsi/tgsi_dump.h"
+#include "r300_context.h"
+#include "r300_screen.h"
+#include "r300_fs.h"
#include "r300_tgsi_to_rc.h"
+#include "radeon_code.h"
#include "radeon_compiler.h"
static void find_output_registers(struct r300_fragment_program_compiler * compiler,
@@ -126,14 +130,9 @@ void r300_translate_fragment_shader(struct r300_context* r300,
/* Invoke the compiler */
r3xx_compile_fragment_program(&compiler);
if (compiler.Base.Error) {
- /* Todo: Fallback to software rendering gracefully? */
- fprintf(stderr, "r300 FP: Compiler error: %s\n", compiler.Base.ErrorMsg);
-
- if (compiler.is_r500) {
- memcpy(compiler.code, &r5xx_passthrough_fragment_shader, sizeof(r5xx_passthrough_fragment_shader));
- } else {
- memcpy(compiler.code, &r3xx_passthrough_fragment_shader, sizeof(r3xx_passthrough_fragment_shader));
- }
+ /* XXX failover maybe? */
+ DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n",
+ compiler.Base.ErrorMsg);
}
/* And, finally... */
diff --git a/src/gallium/drivers/r300/r300_fs.h b/src/gallium/drivers/r300/r300_fs.h
index 967e9f697e9..e831c30301b 100644
--- a/src/gallium/drivers/r300/r300_fs.h
+++ b/src/gallium/drivers/r300/r300_fs.h
@@ -24,11 +24,9 @@
#ifndef R300_FS_H
#define R300_FS_H
-#include "tgsi/tgsi_dump.h"
+#include "pipe/p_state.h"
-#include "r300_context.h"
-#include "r3xx_fs.h"
-#include "r5xx_fs.h"
+#include "tgsi/tgsi_scan.h"
#include "radeon_code.h"
@@ -48,4 +46,10 @@ struct r300_fragment_shader {
void r300_translate_fragment_shader(struct r300_context* r300,
struct r300_fragment_shader* fs);
+static inline boolean r300_fragment_shader_writes_depth(struct r300_fragment_shader *fs)
+{
+ if (!fs)
+ return FALSE;
+ return (fs->code.writes_depth) ? TRUE : FALSE;
+}
#endif /* R300_FS_H */
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index 2880d34877f..007f11efae6 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -20,17 +20,23 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "r300_query.h"
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
+#include "r300_context.h"
+#include "r300_screen.h"
+#include "r300_cs.h"
#include "r300_emit.h"
+#include "r300_query.h"
+#include "r300_reg.h"
-static struct pipe_query* r300_create_query(struct pipe_context* pipe,
+static struct pipe_query *r300_create_query(struct pipe_context *pipe,
unsigned query_type)
{
- struct r300_context* r300 = r300_context(pipe);
- struct r300_screen* r300screen = r300_screen(r300->context.screen);
- unsigned query_size = r300screen->caps->num_frag_pipes * 4;
- struct r300_query* q, * qptr;
+ struct r300_context *r300 = r300_context(pipe);
+ struct r300_screen *r300screen = r300_screen(r300->context.screen);
+ unsigned query_size;
+ struct r300_query *q, *qptr;
q = CALLOC_STRUCT(r300_query);
@@ -39,13 +45,16 @@ static struct pipe_query* r300_create_query(struct pipe_context* pipe,
q->active = FALSE;
- if (!r300->query_list) {
- r300->query_list = q;
- } else if (!is_empty_list(r300->query_list)) {
- qptr = last_elem(r300->query_list);
+ if (r300screen->caps->family == CHIP_FAMILY_RV530)
+ query_size = r300screen->caps->num_z_pipes * sizeof(uint32_t);
+ else
+ query_size = r300screen->caps->num_frag_pipes * sizeof(uint32_t);
+
+ if (!is_empty_list(&r300->query_list)) {
+ qptr = last_elem(&r300->query_list);
q->offset = qptr->offset + query_size;
- insert_at_tail(r300->query_list, q);
}
+ insert_at_tail(&r300->query_list, q);
/* XXX */
if (q->offset >= 4096) {
@@ -71,24 +80,26 @@ static void r300_begin_query(struct pipe_context* pipe,
struct r300_context* r300 = r300_context(pipe);
struct r300_query* q = (struct r300_query*)query;
+ assert(r300->query_current == NULL);
+
map = pipe->screen->buffer_map(pipe->screen, r300->oqbo,
PIPE_BUFFER_USAGE_CPU_WRITE);
map += q->offset / 4;
- *map = ~0;
+ *map = ~0U;
pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
- r300_emit_dirty_state(r300);
- r300_emit_query_begin(r300, q);
+ q->flushed = FALSE;
+ r300->query_current = q;
+ r300->dirty_state |= R300_NEW_QUERY;
}
static void r300_end_query(struct pipe_context* pipe,
- struct pipe_query* query)
+ struct pipe_query* query)
{
struct r300_context* r300 = r300_context(pipe);
- struct r300_query* q = (struct r300_query*)query;
- r300_emit_dirty_state(r300);
- r300_emit_query_end(r300, q);
+ r300_emit_query_end(r300);
+ r300->query_current = NULL;
}
static boolean r300_get_query_result(struct pipe_context* pipe,
@@ -98,28 +109,30 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
{
struct r300_context* r300 = r300_context(pipe);
struct r300_screen* r300screen = r300_screen(r300->context.screen);
- struct r300_query* q = (struct r300_query*)query;
+ struct r300_query *q = (struct r300_query*)query;
unsigned flags = PIPE_BUFFER_USAGE_CPU_READ;
uint32_t* map;
- uint32_t temp;
+ uint32_t temp = 0;
unsigned i;
- if (wait) {
+ if (q->flushed == FALSE)
pipe->flush(pipe, 0, NULL);
- } else {
+ if (!wait) {
flags |= PIPE_BUFFER_USAGE_DONTBLOCK;
}
map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, flags);
+ if (!map)
+ return FALSE;
map += q->offset / 4;
for (i = 0; i < r300screen->caps->num_frag_pipes; i++) {
- if (*map == ~0) {
+ if (*map == ~0U) {
/* Looks like our results aren't ready yet. */
if (wait) {
debug_printf("r300: Despite waiting, OQ results haven't"
" come in yet.\n");
}
- temp = ~0;
+ temp = ~0U;
break;
}
temp += *map;
@@ -127,7 +140,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
}
pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
- if (temp == ~0) {
+ if (temp == ~0U) {
/* Our results haven't been written yet... */
return FALSE;
}
diff --git a/src/gallium/drivers/r300/r300_query.h b/src/gallium/drivers/r300/r300_query.h
index 4f50e8f8440..48876da3123 100644
--- a/src/gallium/drivers/r300/r300_query.h
+++ b/src/gallium/drivers/r300/r300_query.h
@@ -23,10 +23,6 @@
#ifndef R300_QUERY_H
#define R300_QUERY_H
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_reg.h"
-
struct r300_context;
static INLINE struct r300_query* r300_query(struct pipe_query* q)
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
index 3abff5db622..e920b2a5e77 100644
--- a/src/gallium/drivers/r300/r300_reg.h
+++ b/src/gallium/drivers/r300/r300_reg.h
@@ -348,6 +348,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_WRITE_ENA_W 8
# define R300_SWIZZLE1_SHIFT 16
+# define R300_VAP_SWIZZLE_X001 \
+ ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+ (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+ (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+ (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \
+ (0xf << R300_WRITE_ENA_SHIFT))
+
+# define R300_VAP_SWIZZLE_XY01 \
+ ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+ (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+ (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+ (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \
+ (0xf << R300_WRITE_ENA_SHIFT))
+
+# define R300_VAP_SWIZZLE_XYZ1 \
+ ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+ (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+ (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+ (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \
+ (0xf << R300_WRITE_ENA_SHIFT))
+
# define R300_VAP_SWIZZLE_XYZW \
((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
(R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
@@ -1172,6 +1193,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* SU Depth Offset value */
#define R300_SU_DEPTH_OFFSET 0x42c4
+#define R300_SU_REG_DEST 0x42c8
+# define R300_RASTER_PIPE_SELECT_0 (1 << 0)
+# define R300_RASTER_PIPE_SELECT_1 (1 << 1)
+# define R300_RASTER_PIPE_SELECT_2 (1 << 2)
+# define R300_RASTER_PIPE_SELECT_3 (1 << 3)
+# define R300_RASTER_PIPE_SELECT_ALL 0xf
+
/* BEGIN: Rasterization / Interpolators - many guesses */
@@ -2095,6 +2123,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R500_FG_ALPHA_VALUE 0x4be0
# define R500_FG_ALPHA_VALUE_MASK 0x0000ffff
+#define RV530_FG_ZBREG_DEST 0x4be8
+# define RV530_FG_ZBREG_DEST_PIPE_SELECT_0 (1 << 0)
+# define RV530_FG_ZBREG_DEST_PIPE_SELECT_1 (1 << 1)
+# define RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL (3 << 0)
/* gap */
/* Fragment program parameters in 7.16 floating point */
@@ -3313,10 +3345,6 @@ enum {
#define R200_3D_DRAW_IMMD_2 0xC0003500
-/* XXX Oh look, stuff not brought over from docs yet */
-
-#define R300_SU_REG_DEST 0x42C8
-
#endif /* _R300_REG_H */
/* *INDENT-ON* */
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index ca44e0f6615..6e2bcc62dac 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -20,19 +20,214 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "draw/draw_pipe.h"
+#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
+
+#include "pipe/p_inlines.h"
+
#include "util/u_memory.h"
#include "r300_cs.h"
#include "r300_context.h"
#include "r300_emit.h"
#include "r300_reg.h"
+#include "r300_render.h"
#include "r300_state_derived.h"
/* r300_render: Vertex and index buffer primitive emission. */
#define R300_MAX_VBO_SIZE (1024 * 1024)
+static uint32_t r300_translate_primitive(unsigned prim)
+{
+ switch (prim) {
+ case PIPE_PRIM_POINTS:
+ return R300_VAP_VF_CNTL__PRIM_POINTS;
+ case PIPE_PRIM_LINES:
+ return R300_VAP_VF_CNTL__PRIM_LINES;
+ case PIPE_PRIM_LINE_LOOP:
+ return R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
+ case PIPE_PRIM_LINE_STRIP:
+ return R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
+ case PIPE_PRIM_TRIANGLES:
+ return R300_VAP_VF_CNTL__PRIM_TRIANGLES;
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ return R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
+ case PIPE_PRIM_TRIANGLE_FAN:
+ return R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
+ case PIPE_PRIM_QUADS:
+ return R300_VAP_VF_CNTL__PRIM_QUADS;
+ case PIPE_PRIM_QUAD_STRIP:
+ return R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
+ case PIPE_PRIM_POLYGON:
+ return R300_VAP_VF_CNTL__PRIM_POLYGON;
+ default:
+ return 0;
+ }
+}
+
+/* This is the fast-path drawing & emission for HW TCL. */
+boolean r300_draw_range_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize,
+ unsigned minIndex,
+ unsigned maxIndex,
+ unsigned mode,
+ unsigned start,
+ unsigned count)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ CS_LOCALS(r300);
+ uint32_t prim = r300_translate_primitive(mode);
+ struct pipe_vertex_buffer* aos = r300->vertex_buffers;
+ unsigned aos_count = r300->vertex_buffer_count;
+ short* indices;
+ unsigned packet_size;
+ unsigned i;
+ bool invalid = FALSE;
+
+validate:
+ for (i = 0; i < aos_count; i++) {
+ if (!r300->winsys->add_buffer(r300->winsys, aos[i].buffer,
+ RADEON_GEM_DOMAIN_GTT, 0)) {
+ pipe->flush(pipe, 0, NULL);
+ goto validate;
+ }
+ }
+ if (!r300->winsys->validate(r300->winsys)) {
+ pipe->flush(pipe, 0, NULL);
+ if (invalid) {
+ /* Well, hell. */
+ debug_printf("r300: Stuck in validation loop, gonna quit now.");
+ exit(1);
+ }
+ invalid = TRUE;
+ goto validate;
+ }
+
+ r300_emit_dirty_state(r300);
+
+ packet_size = (aos_count >> 1) * 3 + (aos_count & 1) * 2;
+
+ BEGIN_CS(3 + packet_size + (aos_count * 2));
+ OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size);
+ OUT_CS(aos_count);
+ for (i = 0; i < aos_count - 1; i += 2) {
+ OUT_CS(aos[i].stride |
+ (aos[i].stride << 8) |
+ (aos[i + 1].stride << 16) |
+ (aos[i + 1].stride << 24));
+ OUT_CS(aos[i].buffer_offset + start * 4 * aos[i].stride);
+ OUT_CS(aos[i + 1].buffer_offset + start * 4 * aos[i + 1].stride);
+ }
+ if (aos_count & 1) {
+ OUT_CS(aos[i].stride | (aos[i].stride << 8));
+ OUT_CS(aos[i].buffer_offset + start * 4 * aos[i].stride);
+ }
+ for (i = 0; i < aos_count; i++) {
+ OUT_CS_RELOC(aos[i].buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
+ }
+ END_CS;
+
+ if (indexBuffer) {
+ indices = (short*)pipe_buffer_map(pipe->screen, indexBuffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+
+ /* Set the starting point. */
+ indices += start;
+
+ BEGIN_CS(2 + (count+1)/2);
+ OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count + 1)/2);
+ OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | prim);
+ for (i = 0; i < count - 1; i += 2) {
+ OUT_CS(indices[i + 1] << 16 | indices[i]);
+ }
+ if (count % 2) {
+ OUT_CS(indices[count - 1]);
+ }
+ END_CS;
+ } else {
+ BEGIN_CS(2);
+ OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
+ OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) |
+ prim);
+ END_CS;
+ }
+
+ return TRUE;
+}
+
+/* Simple helpers for context setup. Should probably be moved to util. */
+boolean r300_draw_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize, unsigned mode,
+ unsigned start, unsigned count)
+{
+ return pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0,
+ mode, start, count);
+}
+
+boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
+ unsigned start, unsigned count)
+{
+ return pipe->draw_elements(pipe, NULL, 0, mode, start, count);
+}
+
+/****************************************************************************
+ * The rest of this file is for SW TCL rendering only. Please be polite and *
+ * keep these functions separated so that they are easier to locate. ~C. *
+ ***************************************************************************/
+
+/* Draw-based drawing for SW TCL chipsets. */
+boolean r300_swtcl_draw_range_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize,
+ unsigned minIndex,
+ unsigned maxIndex,
+ unsigned mode,
+ unsigned start,
+ unsigned count)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ int i;
+
+ for (i = 0; i < r300->vertex_buffer_count; i++) {
+ void* buf = pipe_buffer_map(pipe->screen,
+ r300->vertex_buffers[i].buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_vertex_buffer(r300->draw, i, buf);
+ }
+
+ if (indexBuffer) {
+ void* indices = pipe_buffer_map(pipe->screen, indexBuffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_element_buffer_range(r300->draw, indexSize,
+ minIndex, maxIndex, indices);
+ } else {
+ draw_set_mapped_element_buffer(r300->draw, 0, NULL);
+ }
+
+ draw_set_mapped_constant_buffer(r300->draw,
+ r300->shader_constants[PIPE_SHADER_VERTEX].constants,
+ r300->shader_constants[PIPE_SHADER_VERTEX].count *
+ (sizeof(float) * 4));
+
+ draw_arrays(r300->draw, mode, start, count);
+
+ for (i = 0; i < r300->vertex_buffer_count; i++) {
+ pipe_buffer_unmap(pipe->screen, r300->vertex_buffers[i].buffer);
+ draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
+ }
+
+ if (indexBuffer) {
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
+ draw_set_mapped_element_buffer_range(r300->draw, 0, start,
+ start + count - 1, NULL);
+ }
+
+ return TRUE;
+}
+
+/* Object for rendering using Draw. */
struct r300_render {
/* Parent class */
struct vbuf_render base;
@@ -67,7 +262,7 @@ r300_render_get_vertex_info(struct vbuf_render* render)
r300_update_derived_state(r300);
- return &r300->vertex_info.vinfo;
+ return &r300->vertex_info->vinfo;
}
static boolean r300_render_allocate_vertices(struct vbuf_render* render,
@@ -127,7 +322,6 @@ static void r300_render_unmap_vertices(struct vbuf_render* render,
static void r300_render_release_vertices(struct vbuf_render* render)
{
struct r300_render* r300render = r300_render(render);
- struct r300_context* r300 = r300render->r300;
r300render->vbo_offset += r300render->vbo_max_used;
r300render->vbo_max_used = 0;
@@ -137,56 +331,13 @@ static boolean r300_render_set_primitive(struct vbuf_render* render,
unsigned prim)
{
struct r300_render* r300render = r300_render(render);
- r300render->prim = prim;
- switch (prim) {
- case PIPE_PRIM_POINTS:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POINTS;
- break;
- case PIPE_PRIM_LINES:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINES;
- break;
- case PIPE_PRIM_LINE_LOOP:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
- break;
- case PIPE_PRIM_LINE_STRIP:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
- break;
- case PIPE_PRIM_TRIANGLES:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLES;
- break;
- case PIPE_PRIM_TRIANGLE_STRIP:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
- break;
- case PIPE_PRIM_TRIANGLE_FAN:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
- break;
- case PIPE_PRIM_QUADS:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUADS;
- break;
- case PIPE_PRIM_QUAD_STRIP:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
- break;
- case PIPE_PRIM_POLYGON:
- r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POLYGON;
- break;
- default:
- return FALSE;
- break;
- }
+ r300render->prim = prim;
+ r300render->hwprim = r300_translate_primitive(prim);
return TRUE;
}
-static void r300_prepare_render(struct r300_render* render, unsigned count)
-{
- struct r300_context* r300 = render->r300;
-
- CS_LOCALS(r300);
-
- r300_emit_dirty_state(r300);
-}
-
static void r300_render_draw_arrays(struct vbuf_render* render,
unsigned start,
unsigned count)
@@ -196,7 +347,7 @@ static void r300_render_draw_arrays(struct vbuf_render* render,
CS_LOCALS(r300);
- r300_prepare_render(r300render, count);
+ r300_emit_dirty_state(r300);
DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count);
@@ -213,15 +364,11 @@ static void r300_render_draw(struct vbuf_render* render,
{
struct r300_render* r300render = r300_render(render);
struct r300_context* r300 = r300render->r300;
- struct pipe_screen* screen = r300->context.screen;
- struct pipe_buffer* index_buffer;
- void* index_map;
int i;
- uint32_t index;
CS_LOCALS(r300);
- r300_prepare_render(r300render, count);
+ r300_emit_dirty_state(r300);
BEGIN_CS(2 + (count+1)/2);
OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2);
diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h
new file mode 100644
index 00000000000..3d8f47ba75f
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_render.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_RENDER_H
+#define R300_RENDER_H
+
+boolean r300_draw_range_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize,
+ unsigned minIndex,
+ unsigned maxIndex,
+ unsigned mode,
+ unsigned start,
+ unsigned count);
+
+boolean r300_draw_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize, unsigned mode,
+ unsigned start, unsigned count);
+
+boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
+ unsigned start, unsigned count);
+
+boolean r300_swtcl_draw_range_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize,
+ unsigned minIndex,
+ unsigned maxIndex,
+ unsigned mode,
+ unsigned start,
+ unsigned count);
+
+#endif /* R300_RENDER_H */
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 7d154576e04..1d9f91d0f73 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -20,7 +20,14 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_simple_screen.h"
+
+#include "r300_context.h"
#include "r300_screen.h"
+#include "r300_texture.h"
+#include "r300_winsys.h"
/* Return the identifier behind whom the brave coders responsible for this
* amalgamation of code, sweat, and duct tape, routinely obscure their names.
@@ -73,13 +80,10 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
struct r300_screen* r300screen = r300_screen(pscreen);
switch (param) {
- /* XXX cases marked "IN THEORY" are possible on the hardware,
- * but haven't been implemented yet. */
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
/* XXX I'm told this goes up to 16 */
return 8;
case PIPE_CAP_NPOT_TEXTURES:
- /* IN THEORY */
return 0;
case PIPE_CAP_TWO_SIDED_STENCIL:
if (r300screen->caps->is_r500) {
@@ -88,16 +92,26 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
return 0;
}
case PIPE_CAP_GLSL:
- if (r300screen->caps->is_r500) {
- return 1;
- } else {
- return 0;
- }
+ /* I'll be frank. This is a lie.
+ *
+ * We don't truly support GLSL on any of this driver's chipsets.
+ * To be fair, no chipset supports the full GLSL specification
+ * to the best of our knowledge, but some of the less esoteric
+ * features are still missing here.
+ *
+ * Rather than cripple ourselves intentionally, I'm going to set
+ * this flag, and as Gallium's interface continues to change, I
+ * hope that this single monolithic GLSL enable can slowly get
+ * split down into many different pieces and the state tracker
+ * will handle fallbacks transparently, like it should.
+ *
+ * ~ C.
+ */
+ return 1;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 1;
case PIPE_CAP_POINT_SPRITE:
- /* IN THEORY */
- return 0;
+ return 1;
case PIPE_CAP_MAX_RENDER_TARGETS:
return 4;
case PIPE_CAP_OCCLUSION_QUERY:
@@ -138,10 +152,8 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
return 1;
case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
- /* XXX guessing (what a terrible guess) */
- return 2;
+ return 0;
case PIPE_CAP_TGSI_CONT_SUPPORTED:
- /* XXX */
return 0;
case PIPE_CAP_BLEND_EQUATION_SEPARATE:
return 1;
@@ -222,6 +234,7 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
/* Z buffer or texture */
case PIPE_FORMAT_Z16_UNORM:
+ case PIPE_FORMAT_Z24X8_UNORM:
/* Z buffer with stencil or texture */
case PIPE_FORMAT_Z24S8_UNORM:
retval = usage &
@@ -231,7 +244,7 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
/* Definitely unsupported formats. */
/* Non-usable Z buffer/stencil formats. */
- case PIPE_FORMAT_Z24X8_UNORM:
+ case PIPE_FORMAT_Z32_UNORM:
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
debug_printf("r300: Note: Got unsupported format: %s in %s\n",
@@ -241,7 +254,6 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
/* XXX These don't even exist
case PIPE_FORMAT_A32R32G32B32:
case PIPE_FORMAT_A16R16G16B16: */
- /* XXX Insert YUV422 packed VYUY and YVYU here */
/* XXX What the deuce is UV88? (r3xx accel page 14)
debug_printf("r300: Warning: Got unimplemented format: %s in %s\n",
pf_name(format), __FUNCTION__);
@@ -310,7 +322,7 @@ r300_get_tex_transfer(struct pipe_screen *screen,
{
struct r300_texture *tex = (struct r300_texture *)texture;
struct r300_transfer *trans;
- unsigned offset; /* in bytes */
+ unsigned offset = 0; /* in bytes */
/* XXX Add support for these things */
if (texture->target == PIPE_TEXTURE_CUBE) {
@@ -395,6 +407,7 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)
caps->pci_id = r300_winsys->pci_id;
caps->num_frag_pipes = r300_winsys->gb_pipes;
+ caps->num_z_pipes = r300_winsys->z_pipes;
r300_parse_chipset(caps);
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 2a0e41fbc3b..41df31f670f 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -23,14 +23,9 @@
#ifndef R300_SCREEN_H
#define R300_SCREEN_H
-#include "pipe/p_inlines.h"
#include "pipe/p_screen.h"
-#include "util/u_memory.h"
-#include "util/u_simple_screen.h"
#include "r300_chipset.h"
-#include "r300_texture.h"
-#include "r300_winsys.h"
struct r300_screen {
/* Parent class */
diff --git a/src/gallium/drivers/r300/r300_shader_inlines.h b/src/gallium/drivers/r300/r300_shader_inlines.h
deleted file mode 100644
index a04f45b03e2..00000000000
--- a/src/gallium/drivers/r300/r300_shader_inlines.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#ifndef R300_SHADER_INLINES_H
-#define R300_SHADER_INLINES_H
-
-/* TGSI constants. TGSI is like XML: If it can't solve your problems, you're
- * not using enough of it. */
-static const struct tgsi_full_src_register r300_constant_zero = {
- .SrcRegister.Extended = TRUE,
- .SrcRegister.File = TGSI_FILE_NULL,
- .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO,
-};
-
-static const struct tgsi_full_src_register r300_constant_one = {
- .SrcRegister.Extended = TRUE,
- .SrcRegister.File = TGSI_FILE_NULL,
- .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ONE,
- .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ONE,
- .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ONE,
- .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ONE,
-};
-
-#endif /* R300_SHADER_INLINES_H */
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 3cef285dee8..a3e1bc621a5 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -20,8 +20,10 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "util/u_debug.h"
+#include "draw/draw_context.h"
+
#include "util/u_math.h"
+#include "util/u_memory.h"
#include "util/u_pack_color.h"
#include "tgsi/tgsi_parse.h"
@@ -31,6 +33,7 @@
#include "r300_context.h"
#include "r300_reg.h"
+#include "r300_screen.h"
#include "r300_state_inlines.h"
#include "r300_fs.h"
#include "r300_vs.h"
@@ -247,9 +250,6 @@ static void*
R300_FG_ALPHA_FUNC_ENABLE;
dsa->alpha_reference = CLAMP(state->alpha.ref_value * 1023.0f,
0, 1023);
- } else {
- /* XXX need to fix this to be dynamically set
- dsa->z_buffer_top = R300_ZTOP_ENABLE; */
}
return (void*)dsa;
@@ -332,7 +332,7 @@ static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
{
struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
rc_constants_destroy(&fs->code.constants);
- FREE(fs->state.tokens);
+ FREE((void*)fs->state.tokens);
FREE(shader);
}
@@ -700,7 +700,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
rc_constants_destroy(&vs->code.constants);
draw_delete_vertex_shader(r300->draw, vs->draw);
- FREE(vs->state.tokens);
+ FREE((void*)vs->state.tokens);
FREE(shader);
} else {
draw_delete_vertex_shader(r300->draw,
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index 02b7ab91076..7d000e9e2da 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -20,15 +20,47 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "r300_state_derived.h"
+#include "draw/draw_context.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "r300_context.h"
#include "r300_fs.h"
+#include "r300_screen.h"
+#include "r300_state_derived.h"
#include "r300_state_inlines.h"
#include "r300_vs.h"
/* r300_state_derived: Various bits of state which are dependent upon
* currently bound CSO data. */
+struct r300_shader_key {
+ struct r300_vertex_shader* vs;
+ struct r300_fragment_shader* fs;
+};
+
+struct r300_shader_derived_value {
+ struct r300_vertex_format* vformat;
+ struct r300_rs_block* rs_block;
+};
+
+unsigned r300_shader_key_hash(void* key) {
+ struct r300_shader_key* shader_key = (struct r300_shader_key*)key;
+ unsigned vs = (unsigned)shader_key->vs;
+ unsigned fs = (unsigned)shader_key->fs;
+
+ return (vs << 16) | (fs & 0xffff);
+}
+
+int r300_shader_key_compare(void* key1, void* key2) {
+ struct r300_shader_key* shader_key1 = (struct r300_shader_key*)key1;
+ struct r300_shader_key* shader_key2 = (struct r300_shader_key*)key2;
+
+ return (shader_key1->vs == shader_key2->vs) &&
+ (shader_key1->fs == shader_key2->fs);
+}
+
/* Set up the vs_tab and routes. */
static void r300_vs_tab_routes(struct r300_context* r300,
struct r300_vertex_format* vformat)
@@ -192,8 +224,9 @@ static void r300_vertex_psc(struct r300_context* r300,
struct r300_screen* r300screen = r300_screen(r300->context.screen);
struct vertex_info* vinfo = &vformat->vinfo;
int* tab = vformat->vs_tab;
- uint32_t temp;
- int i, attrib_count;
+ uint16_t type, swizzle;
+ enum pipe_format format;
+ unsigned i, attrib_count;
/* Vertex shaders have no semantics on their inputs,
* so PSC should just route stuff based on their info,
@@ -214,64 +247,43 @@ static void r300_vertex_psc(struct r300_context* r300,
}
for (i = 0; i < attrib_count; i++) {
- /* Make sure we have a proper destination for our attribute */
+ /* Make sure we have a proper destination for our attribute. */
assert(tab[i] != -1);
- /* Add the attribute to the PSC table. */
- temp = r300screen->caps->has_tcl ?
- R300_DATA_TYPE_FLOAT_4 :
- translate_vertex_data_type(vinfo->attrib[i].emit);
- temp |= tab[i] << R300_DST_VEC_LOC_SHIFT;
+ format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
+ /* Obtain the type of data in this attribute. */
+ type = r300_translate_vertex_data_type(format) |
+ tab[i] << R300_DST_VEC_LOC_SHIFT;
+
+ /* Obtain the swizzle for this attribute. Note that the default
+ * swizzle in the hardware is not XYZW! */
+ swizzle = r300_translate_vertex_data_swizzle(format);
+
+ /* Add the attribute to the PSC table. */
if (i & 1) {
- vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
- vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16;
+ vformat->vap_prog_stream_cntl[i >> 1] |= type << 16;
- vformat->vap_prog_stream_cntl_ext[i >> 1] |=
- (R300_VAP_SWIZZLE_XYZW << 16);
+ vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
} else {
- vformat->vap_prog_stream_cntl[i >> 1] &= 0xffff0000;
- vformat->vap_prog_stream_cntl[i >> 1] |= temp << 0;
+ vformat->vap_prog_stream_cntl[i >> 1] |= type << 0;
- vformat->vap_prog_stream_cntl_ext[i >> 1] |=
- (R300_VAP_SWIZZLE_XYZW << 0);
+ vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 0;
}
}
/* Set the last vector in the PSC. */
- i--;
+ if (i) {
+ i -= 1;
+ }
vformat->vap_prog_stream_cntl[i >> 1] |=
(R300_LAST_VEC << (i & 1 ? 16 : 0));
}
-/* Update the vertex format. */
-static void r300_update_vertex_format(struct r300_context* r300)
-{
- struct r300_vertex_format vformat;
- int i;
-
- memset(&vformat, 0, sizeof(struct r300_vertex_format));
- for (i = 0; i < 16; i++) {
- vformat.vs_tab[i] = -1;
- vformat.fs_tab[i] = -1;
- }
-
- r300_vs_tab_routes(r300, &vformat);
-
- r300_vertex_psc(r300, &vformat);
-
- if (memcmp(&r300->vertex_info, &vformat,
- sizeof(struct r300_vertex_format))) {
- memcpy(&r300->vertex_info, &vformat,
- sizeof(struct r300_vertex_format));
- r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
- }
-}
-
/* Set up the mappings from GB to US, for RS block. */
-static void r300_update_fs_tab(struct r300_context* r300)
+static void r300_update_fs_tab(struct r300_context* r300,
+ struct r300_vertex_format* vformat)
{
- struct r300_vertex_format* vformat = &r300->vertex_info;
struct tgsi_shader_info* info = &r300->fs->info;
int i, cols = 0, texs = 0, cols_emitted = 0;
int* tab = vformat->fs_tab;
@@ -333,18 +345,15 @@ static void r300_update_fs_tab(struct r300_context* r300)
/* Set up the RS block. This is the part of the chipset that actually does
* the rasterization of vertices into fragments. This is also the part of the
* chipset that locks up if any part of it is even slightly wrong. */
-static void r300_update_rs_block(struct r300_context* r300)
+static void r300_update_rs_block(struct r300_context* r300,
+ struct r300_rs_block* rs)
{
- struct r300_rs_block* rs = r300->rs_block;
struct tgsi_shader_info* info = &r300->fs->info;
- int* tab = r300->vertex_info.fs_tab;
int col_count = 0, fp_offset = 0, i, tex_count = 0;
int rs_tex_comp = 0;
- memset(rs, 0, sizeof(struct r300_rs_block));
if (r300_screen(r300->context.screen)->caps->is_r500) {
for (i = 0; i < info->num_inputs; i++) {
- assert(tab[i] != -1);
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
rs->ip[col_count] |=
@@ -385,7 +394,6 @@ static void r300_update_rs_block(struct r300_context* r300)
}
} else {
for (i = 0; i < info->num_inputs; i++) {
- assert(tab[i] != -1);
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
rs->ip[col_count] |=
@@ -444,15 +452,104 @@ static void r300_update_rs_block(struct r300_context* r300)
rs->inst_count = MAX2(MAX2(col_count - 1, tex_count - 1), 0);
}
+/* Update the vertex format. */
+static void r300_update_derived_shader_state(struct r300_context* r300)
+{
+ struct r300_shader_key* key;
+ struct r300_vertex_format* vformat;
+ struct r300_rs_block* rs_block;
+ struct r300_shader_derived_value* value;
+ int i;
+
+ /*
+ key = CALLOC_STRUCT(r300_shader_key);
+ key->vs = r300->vs;
+ key->fs = r300->fs;
+
+ value = (struct r300_shader_derived_value*)
+ util_hash_table_get(r300->shader_hash_table, (void*)key);
+ if (value) {
+ //vformat = value->vformat;
+ rs_block = value->rs_block;
+
+ FREE(key);
+ } else {
+ rs_block = CALLOC_STRUCT(r300_rs_block);
+ value = CALLOC_STRUCT(r300_shader_derived_value);
+
+ r300_update_rs_block(r300, rs_block);
+
+ //value->vformat = vformat;
+ value->rs_block = rs_block;
+ util_hash_table_set(r300->shader_hash_table,
+ (void*)key, (void*)value);
+ } */
+
+ /* XXX This will be refactored ASAP. */
+ vformat = CALLOC_STRUCT(r300_vertex_format);
+ rs_block = CALLOC_STRUCT(r300_rs_block);
+
+ for (i = 0; i < 16; i++) {
+ vformat->vs_tab[i] = -1;
+ vformat->fs_tab[i] = -1;
+ }
+
+ r300_vs_tab_routes(r300, vformat);
+ r300_vertex_psc(r300, vformat);
+ r300_update_fs_tab(r300, vformat);
+
+ r300_update_rs_block(r300, rs_block);
+
+ FREE(r300->vertex_info);
+ FREE(r300->rs_block);
+
+ r300->vertex_info = vformat;
+ r300->rs_block = rs_block;
+ r300->dirty_state |= (R300_NEW_VERTEX_FORMAT | R300_NEW_RS_BLOCK);
+}
+
+static void r300_update_ztop(struct r300_context* r300)
+{
+ r300->ztop_state.z_buffer_top = R300_ZTOP_ENABLE;
+
+ /* This is important enough that I felt it warranted a comment.
+ *
+ * According to the docs, these are the conditions where ZTOP must be
+ * disabled:
+ * 1) Alpha testing enabled
+ * 2) Texture kill instructions in fragment shader
+ * 3) Chroma key culling enabled
+ * 4) W-buffering enabled
+ *
+ * The docs claim that for the first three cases, if no ZS writes happen,
+ * then ZTOP can be used.
+ *
+ * Additionally, the following conditions require disabled ZTOP:
+ * ~) Depth writes in fragment shader
+ * ~) Outstanding occlusion queries
+ *
+ * ~C.
+ */
+ if (r300->dsa_state->alpha_function) {
+ r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300->fs->info.uses_kill) {
+ r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300_fragment_shader_writes_depth(r300->fs)) {
+ r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300->query_current) {
+ r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
+ }
+}
+
void r300_update_derived_state(struct r300_context* r300)
{
if (r300->dirty_state &
- (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) {
- r300_update_vertex_format(r300);
+ (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) {
+ r300_update_derived_shader_state(r300);
}
- if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) {
- r300_update_fs_tab(r300);
- r300_update_rs_block(r300);
+ if (r300->dirty_state &
+ (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) {
+ r300_update_ztop(r300);
}
}
diff --git a/src/gallium/drivers/r300/r300_state_derived.h b/src/gallium/drivers/r300/r300_state_derived.h
index 71a4a47b003..05ad535e2de 100644
--- a/src/gallium/drivers/r300/r300_state_derived.h
+++ b/src/gallium/drivers/r300/r300_state_derived.h
@@ -25,6 +25,10 @@
struct r300_context;
+unsigned r300_shader_key_hash(void* key);
+
+int r300_shader_key_compare(void* key1, void* key2);
+
void r300_update_derived_state(struct r300_context* r300);
#endif /* R300_STATE_DERIVED_H */
diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h
index d7b57e1b227..ec11a41253f 100644
--- a/src/gallium/drivers/r300/r300_state_inlines.h
+++ b/src/gallium/drivers/r300/r300_state_inlines.h
@@ -24,6 +24,8 @@
#ifndef R300_STATE_INLINES_H
#define R300_STATE_INLINES_H
+#include "draw/draw_vertex.h"
+
#include "pipe/p_format.h"
#include "r300_reg.h"
@@ -51,6 +53,7 @@ static INLINE uint32_t r300_translate_blend_function(int blend_func)
return R300_COMB_FCN_MAX;
default:
debug_printf("r300: Unknown blend function %d\n", blend_func);
+ assert(0);
break;
}
return 0;
@@ -98,6 +101,7 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact)
case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */
default:
debug_printf("r300: Unknown blend factor %d\n", blend_fact);
+ assert(0);
break;
}
return 0;
@@ -127,6 +131,7 @@ static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func)
default:
debug_printf("r300: Unknown depth/stencil function %d\n",
zs_func);
+ assert(0);
break;
}
return 0;
@@ -153,6 +158,7 @@ static INLINE uint32_t r300_translate_stencil_op(int s_op)
return R300_ZS_INVERT;
default:
debug_printf("r300: Unknown stencil op %d", s_op);
+ assert(0);
break;
}
return 0;
@@ -179,6 +185,7 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func)
return R300_FG_ALPHA_FUNC_ALWAYS;
default:
debug_printf("r300: Unknown alpha function %d", alpha_func);
+ assert(0);
break;
}
return 0;
@@ -207,6 +214,7 @@ static INLINE uint32_t r300_translate_wrap(int wrap)
return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
default:
debug_printf("r300: Unknown texture wrap %d", wrap);
+ assert(0);
return 0;
}
}
@@ -226,6 +234,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
break;
default:
debug_printf("r300: Unknown texture filter %d\n", min);
+ assert(0);
break;
}
switch (mag) {
@@ -240,6 +249,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
break;
default:
debug_printf("r300: Unknown texture filter %d\n", mag);
+ assert(0);
break;
}
switch (mip) {
@@ -254,6 +264,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
break;
default:
debug_printf("r300: Unknown texture filter %d\n", mip);
+ assert(0);
break;
}
@@ -277,6 +288,8 @@ static INLINE uint32_t r300_anisotropy(float max_aniso)
/* Buffer formats. */
+/* Colorbuffer formats. This is the unswizzled format of the RB3D block's
+ * output. For the swizzling of the targets, check the shader's format. */
static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
{
switch (format) {
@@ -311,17 +324,21 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
debug_printf("r300: Implementation error: "
"Got unsupported color format %s in %s\n",
pf_name(format), __FUNCTION__);
+ assert(0);
break;
}
return 0;
}
+/* Depthbuffer and stencilbuffer. Thankfully, we only support two flavors. */
static INLINE uint32_t r300_translate_zsformat(enum pipe_format format)
{
switch (format) {
/* 16-bit depth, no stencil */
case PIPE_FORMAT_Z16_UNORM:
return R300_DEPTHFORMAT_16BIT_INT_Z;
+ /* 24-bit depth, ignored stencil */
+ case PIPE_FORMAT_Z24X8_UNORM:
/* 24-bit depth, 8-bit stencil */
case PIPE_FORMAT_Z24S8_UNORM:
return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
@@ -329,18 +346,22 @@ static INLINE uint32_t r300_translate_zsformat(enum pipe_format format)
debug_printf("r300: Implementation error: "
"Got unsupported ZS format %s in %s\n",
pf_name(format), __FUNCTION__);
+ assert(0);
break;
}
return 0;
}
-/* Translate pipe_format into US_OUT_FMT.
+/* Shader output formats. This is essentially the swizzle from the shader
+ * to the RB3D block.
+ *
* Note that formats are stored from C3 to C0. */
static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format)
{
switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_X8R8G8B8_UNORM:
+ /* XXX */
case PIPE_FORMAT_Z24S8_UNORM:
return R300_US_OUT_FMT_C4_8 |
R300_C0_SEL_B | R300_C1_SEL_G |
@@ -354,6 +375,7 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format)
debug_printf("r300: Implementation error: "
"Got unsupported output format %s in %s\n",
pf_name(format), __FUNCTION__);
+ assert(0);
return R300_US_OUT_FMT_UNUSED;
}
return 0;
@@ -380,31 +402,57 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count)
return 0;
}
-static INLINE uint32_t translate_vertex_data_type(int type) {
- switch (type) {
- case EMIT_1F:
- case EMIT_1F_PSIZE:
+/* Translate pipe_formats into PSC vertex types. */
+static INLINE uint16_t
+r300_translate_vertex_data_type(enum pipe_format format) {
+ switch (format) {
+ case PIPE_FORMAT_R32_FLOAT:
return R300_DATA_TYPE_FLOAT_1;
break;
- case EMIT_2F:
+ case PIPE_FORMAT_R32G32_FLOAT:
return R300_DATA_TYPE_FLOAT_2;
break;
- case EMIT_3F:
+ case PIPE_FORMAT_R32G32B32_FLOAT:
return R300_DATA_TYPE_FLOAT_3;
break;
- case EMIT_4F:
+ case PIPE_FORMAT_R32G32B32A32_FLOAT:
return R300_DATA_TYPE_FLOAT_4;
break;
- case EMIT_4UB:
- return R300_DATA_TYPE_BYTE;
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ return R300_DATA_TYPE_BYTE |
+ R300_NORMALIZE;
break;
default:
debug_printf("r300: Implementation error: "
- "Bad vertex data type!\n");
+ "Bad vertex data format %s!\n", pf_name(format));
assert(0);
break;
}
+ return 0;
+}
+static INLINE uint16_t
+r300_translate_vertex_data_swizzle(enum pipe_format format) {
+ switch (format) {
+ case PIPE_FORMAT_R32_FLOAT:
+ return R300_VAP_SWIZZLE_X001;
+ break;
+ case PIPE_FORMAT_R32G32_FLOAT:
+ return R300_VAP_SWIZZLE_XY01;
+ break;
+ case PIPE_FORMAT_R32G32B32_FLOAT:
+ return R300_VAP_SWIZZLE_XYZ1;
+ break;
+ case PIPE_FORMAT_R32G32B32A32_FLOAT:
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ return R300_VAP_SWIZZLE_XYZW;
+ break;
+ default:
+ debug_printf("r300: Implementation error: "
+ "Bad vertex data format %s!\n", pf_name(format));
+ assert(0);
+ break;
+ }
return 0;
}
diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c
index 3865730d635..4865f160581 100644
--- a/src/gallium/drivers/r300/r300_state_invariant.c
+++ b/src/gallium/drivers/r300/r300_state_invariant.c
@@ -21,9 +21,12 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_reg.h"
+#include "r300_screen.h"
#include "r300_state_invariant.h"
-
struct pipe_viewport_state r300_viewport_identity = {
.scale = {1.0, 1.0, 1.0, 1.0},
.translate = {0.0, 0.0, 0.0, 0.0},
diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h
index 5bea6779fe5..05cff0d6dfe 100644
--- a/src/gallium/drivers/r300/r300_state_invariant.h
+++ b/src/gallium/drivers/r300/r300_state_invariant.h
@@ -23,11 +23,7 @@
#ifndef R300_STATE_INVARIANT_H
#define R300_STATE_INVARIANT_H
-#include "r300_chipset.h"
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_reg.h"
-#include "r300_state_inlines.h"
+struct r300_context;
void r300_emit_invariant_state(struct r300_context* r300);
diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
deleted file mode 100644
index d72e734ff0c..00000000000
--- a/src/gallium/drivers/r300/r300_surface.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#include "r300_surface.h"
-
-static void r300_surface_setup(struct r300_context* r300,
- struct r300_texture* dest,
- unsigned x, unsigned y,
- unsigned w, unsigned h)
-{
- struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
- unsigned pixpitch = r300_texture_get_stride(dest, 0) / dest->tex.block.size;
- CS_LOCALS(r300);
-
- r300_emit_blend_state(r300, &blend_clear_state);
- r300_emit_blend_color_state(r300, &blend_color_clear_state);
- r300_emit_dsa_state(r300, &dsa_clear_state);
- r300_emit_rs_state(r300, &rs_clear_state);
-
- BEGIN_CS(26);
-
- /* Viewport setup */
- OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6);
- OUT_CS_32F((float)w);
- OUT_CS_32F((float)x);
- OUT_CS_32F((float)h);
- OUT_CS_32F((float)y);
- OUT_CS_32F(1.0);
- OUT_CS_32F(0.0);
-
- OUT_CS_REG(R300_VAP_VTE_CNTL, R300_VPORT_X_SCALE_ENA |
- R300_VPORT_X_OFFSET_ENA |
- R300_VPORT_Y_SCALE_ENA |
- R300_VPORT_Y_OFFSET_ENA |
- R300_VTX_XY_FMT | R300_VTX_Z_FMT);
-
- /* Pixel scissors. */
- OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2);
- if (caps->is_r500) {
- OUT_CS((x << R300_SCISSORS_X_SHIFT) | (y << R300_SCISSORS_Y_SHIFT));
- OUT_CS(((w - 1) << R300_SCISSORS_X_SHIFT) | ((h - 1) << R300_SCISSORS_Y_SHIFT));
- } else {
- /* Non-R500 chipsets have an offset of 1440 in their scissors. */
- OUT_CS(((x + 1440) << R300_SCISSORS_X_SHIFT) |
- ((y + 1440) << R300_SCISSORS_Y_SHIFT));
- OUT_CS((((w - 1) + 1440) << R300_SCISSORS_X_SHIFT) |
- (((h - 1) + 1440) << R300_SCISSORS_Y_SHIFT));
- }
-
- /* Flush colorbuffer and blend caches. */
- OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
- R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D |
- R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL);
- OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
- R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
- R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
-
- /* Setup colorbuffer. */
- OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1);
- OUT_CS_RELOC(dest->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
- OUT_CS_REG_SEQ(R300_RB3D_COLORPITCH0, 1);
- OUT_CS_RELOC(dest->buffer, pixpitch |
- r300_translate_colorformat(dest->tex.format), 0,
- RADEON_GEM_DOMAIN_VRAM, 0);
- OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0xf);
-
- END_CS;
-}
-
-/* Provides pipe_context's "surface_fill". Commonly used for clearing
- * buffers. */
-static void r300_surface_fill(struct pipe_context* pipe,
- struct pipe_surface* dest,
- unsigned x, unsigned y,
- unsigned w, unsigned h,
- unsigned color)
-{
- int i;
- float r, g, b, a, depth;
- struct r300_context* r300 = r300_context(pipe);
- struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
- struct r300_texture* tex = (struct r300_texture*)dest->texture;
- unsigned pixpitch = r300_texture_get_stride(tex, 0) / tex->tex.block.size;
- boolean invalid = FALSE;
- CS_LOCALS(r300);
-
- a = (float)((color >> 24) & 0xff) / 255.0f;
- r = (float)((color >> 16) & 0xff) / 255.0f;
- g = (float)((color >> 8) & 0xff) / 255.0f;
- b = (float)((color >> 0) & 0xff) / 255.0f;
- DBG(r300, DBG_SURF, "r300: Filling surface %p at (%d,%d),"
- " dimensions %dx%d (pixel pitch %d), color 0x%x\n",
- dest, x, y, w, h, pixpitch, color);
-
- /* Fallback? */
- if (!pipe->screen->is_format_supported(pipe->screen, dest->format,
- PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
-fallback:
- DBG(r300, DBG_SURF | DBG_FALL,
- "r300: Falling back on surface clear...\n");
- util_surface_fill(pipe, dest, x, y, w, h, color);
- return;
- }
-
- /* Make sure our target BO is okay. */
-validate:
- if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
- 0, RADEON_GEM_DOMAIN_VRAM)) {
- r300->context.flush(&r300->context, 0, NULL);
- goto validate;
- }
- if (!r300->winsys->validate(r300->winsys)) {
- r300->context.flush(&r300->context, 0, NULL);
- if (invalid) {
- DBG(r300, DBG_SURF | DBG_FALL, "r300: Stuck in validation loop.");
- goto fallback;
- }
- invalid = TRUE;
- goto validate;
- }
-
- r300_surface_setup(r300, tex, x, y, w, h);
-
- /* Vertex shader setup */
- if (caps->has_tcl) {
- r300_emit_vertex_program_code(r300, &r300_passthrough_vertex_shader, 0);
- } else {
- BEGIN_CS(4);
- OUT_CS_REG(R300_VAP_CNTL_STATUS,
-#ifdef PIPE_ARCH_BIG_ENDIAN
- R300_VC_32BIT_SWAP |
-#endif
- R300_VAP_TCL_BYPASS);
- OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) |
- R300_PVS_NUM_CNTLRS(5) |
- R300_PVS_NUM_FPUS(caps->num_vert_fpus) |
- R300_PVS_VF_MAX_VTX_NUM(12));
- END_CS;
- }
-
- /* Fragment shader setup */
- if (caps->is_r500) {
- r500_emit_fragment_program_code(r300, &r5xx_passthrough_fragment_shader, 0);
- r300_emit_rs_block_state(r300, &r5xx_rs_block_clear_state);
- } else {
- r300_emit_fragment_program_code(r300, &r3xx_passthrough_fragment_shader, 0);
- r300_emit_rs_block_state(r300, &r3xx_rs_block_clear_state);
- }
-
- BEGIN_CS(26);
-
- /* VAP stream control, mapping from input memory to PVS/RS memory */
- if (caps->has_tcl) {
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
- (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) |
- ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) |
- R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
- } else {
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
- (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) |
- ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) |
- R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
- }
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0,
- (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) |
- (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT));
-
- /* VAP format controls */
- OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0,
- R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT |
- R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT);
- OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x0);
-
- /* Disable textures */
- OUT_CS_REG(R300_TX_ENABLE, 0x0);
-
- /* The size of the point we're about to draw, in sixths of pixels */
- OUT_CS_REG(R300_GA_POINT_SIZE,
- ((h * 6) & R300_POINTSIZE_Y_MASK) |
- ((w * 6) << R300_POINTSIZE_X_SHIFT));
-
- /* Vertex size. */
- OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
-
- /* Packet3 with our point vertex */
- OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8);
- OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING |
- (1 << R300_PRIM_NUM_VERTICES_SHIFT));
- /* Position */
- OUT_CS_32F(0.5);
- OUT_CS_32F(0.5);
- OUT_CS_32F(1.0);
- OUT_CS_32F(1.0);
- /* Color */
- OUT_CS_32F(r);
- OUT_CS_32F(g);
- OUT_CS_32F(b);
- OUT_CS_32F(a);
-
- OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
-
- END_CS;
-
- r300->dirty_hw++;
-}
-
-static void r300_surface_copy(struct pipe_context* pipe,
- struct pipe_surface* dest,
- unsigned destx, unsigned desty,
- struct pipe_surface* src,
- unsigned srcx, unsigned srcy,
- unsigned w, unsigned h)
-{
- struct r300_context* r300 = r300_context(pipe);
- struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
- struct r300_texture* srctex = (struct r300_texture*)src->texture;
- struct r300_texture* desttex = (struct r300_texture*)dest->texture;
- unsigned pixpitch = r300_texture_get_stride(srctex, 0) / srctex->tex.block.size;
- boolean invalid = FALSE;
- float fsrcx = srcx, fsrcy = srcy, fdestx = destx, fdesty = desty;
- CS_LOCALS(r300);
-
- DBG(r300, DBG_SURF, "r300: Copying surface %p at (%d,%d) to %p at (%d, %d),"
- " dimensions %dx%d (pixel pitch %d)\n",
- src, srcx, srcy, dest, destx, desty, w, h, pixpitch);
-
- if ((srctex->buffer == desttex->buffer) &&
- ((destx < srcx + w) || (srcx < destx + w)) &&
- ((desty < srcy + h) || (srcy < desty + h))) {
- goto fallback;
- }
-
- if (!pipe->screen->is_format_supported(pipe->screen, src->format,
- PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
- !pipe->screen->is_format_supported(pipe->screen, dest->format,
- PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
-fallback:
- DBG(r300, DBG_SURF | DBG_FALL, "r300: Falling back on surface_copy\n");
- util_surface_copy(pipe, FALSE, dest, destx, desty, src,
- srcx, srcy, w, h);
- return;
- }
-
- /* Add our target BOs to the list. */
-validate:
- if (!r300->winsys->add_buffer(r300->winsys, srctex->buffer,
- RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
- r300->context.flush(&r300->context, 0, NULL);
- goto validate;
- }
- if (!r300->winsys->add_buffer(r300->winsys, desttex->buffer,
- 0, RADEON_GEM_DOMAIN_VRAM)) {
- r300->context.flush(&r300->context, 0, NULL);
- goto validate;
- }
- if (!r300->winsys->validate(r300->winsys)) {
- r300->context.flush(&r300->context, 0, NULL);
- if (invalid) {
- DBG(r300, DBG_SURF | DBG_FALL, "r300: Stuck in validation loop.");
- goto fallback;
- }
- invalid = TRUE;
- goto validate;
- }
-
- r300_surface_setup(r300, desttex, destx, desty, w, h);
-
- /* Setup the texture. */
- r300_emit_texture(r300, &r300_sampler_copy_state, srctex, 0);
-
- /* Flush and enable. */
- r300_flush_textures(r300);
-
- /* Vertex shader setup */
- if (caps->has_tcl) {
- r300_emit_vertex_program_code(r300, &r300_passthrough_vertex_shader, 0);
- } else {
- BEGIN_CS(4);
- OUT_CS_REG(R300_VAP_CNTL_STATUS,
-#ifdef PIPE_ARCH_BIG_ENDIAN
- R300_VC_32BIT_SWAP |
-#endif
- R300_VAP_TCL_BYPASS);
- OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) |
- R300_PVS_NUM_CNTLRS(5) |
- R300_PVS_NUM_FPUS(caps->num_vert_fpus) |
- R300_PVS_VF_MAX_VTX_NUM(12));
- END_CS;
- }
-
- /* Fragment shader setup */
- if (caps->is_r500) {
- r500_emit_fragment_program_code(r300, &r5xx_texture_fragment_shader, 0);
- r300_emit_rs_block_state(r300, &r5xx_rs_block_copy_state);
- } else {
- r300_emit_fragment_program_code(r300, &r3xx_texture_fragment_shader, 0);
- r300_emit_rs_block_state(r300, &r3xx_rs_block_copy_state);
- }
-
- BEGIN_CS(30);
- /* VAP stream control, mapping from input memory to PVS/RS memory */
- if (caps->has_tcl) {
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
- (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) |
- ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) |
- R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT));
- } else {
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
- (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) |
- ((R300_LAST_VEC | (6 << R300_DST_VEC_LOC_SHIFT) |
- R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT));
- }
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0,
- (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) |
- (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT));
-
- /* VAP format controls */
- OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0,
- R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT);
- /* Two components of texture 0 */
- OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2);
-
- /* Vertex size. */
- OUT_CS_REG(R300_VAP_VTX_SIZE, 0x4);
-
- /* Packet3 with our texcoords */
- OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 16);
- OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING |
- (4 << R300_PRIM_NUM_VERTICES_SHIFT));
- /* (x , y ) */
- OUT_CS_32F(fdestx / dest->width);
- OUT_CS_32F(fdesty / dest->height);
- OUT_CS_32F(fsrcx / src->width);
- OUT_CS_32F(fsrcy / src->height);
- /* (x , y + h) */
- OUT_CS_32F(fdestx / dest->width);
- OUT_CS_32F((fdesty + h) / dest->height);
- OUT_CS_32F(fsrcx / src->width);
- OUT_CS_32F((fsrcy + h) / src->height);
- /* (x + w, y + h) */
- OUT_CS_32F((fdestx + w) / dest->width);
- OUT_CS_32F((fdesty + h) / dest->height);
- OUT_CS_32F((fsrcx + w) / src->width);
- OUT_CS_32F((fsrcy + h) / src->height);
- /* (x + w, y ) */
- OUT_CS_32F((fdestx + w) / dest->width);
- OUT_CS_32F(fdesty / dest->height);
- OUT_CS_32F((fsrcx + w) / src->width);
- OUT_CS_32F(fsrcy / src->height);
-
- OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
-
- END_CS;
-
- r300->dirty_hw++;
-}
-
-void r300_init_surface_functions(struct r300_context* r300)
-{
- r300->context.surface_fill = r300_surface_fill;
- r300->context.surface_copy = r300_surface_copy;
-}
diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h
deleted file mode 100644
index f9e98b2ec9c..00000000000
--- a/src/gallium/drivers/r300/r300_surface.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#ifndef R300_SURFACE_H
-#define R300_SURFACE_H
-
-#include "pipe/p_context.h"
-#include "pipe/p_screen.h"
-
-#include "util/u_rect.h"
-
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_emit.h"
-#include "r300_fs.h"
-#include "r300_vs.h"
-#include "r300_state_inlines.h"
-
-static struct r300_blend_state blend_clear_state = {
- .blend_control = 0x0,
- .alpha_blend_control = 0x0,
- .rop = 0x0,
- .dither = 0x0,
-};
-
-static struct r300_blend_color_state blend_color_clear_state = {
- .blend_color = 0x0,
- .blend_color_red_alpha = 0x0,
- .blend_color_green_blue = 0x0,
-};
-
-static struct r300_dsa_state dsa_clear_state = {
- .alpha_function = 0x0,
- .alpha_reference = 0x0,
- .z_buffer_control = 0x0,
- .z_stencil_control = 0x0,
- .stencil_ref_mask = R300_STENCILWRITEMASK_MASK,
- .z_buffer_top = R300_ZTOP_ENABLE,
- .stencil_ref_bf = 0x0,
-};
-
-static struct r300_rs_state rs_clear_state = {
- .point_minmax = 0x36000006,
- .line_control = 0x00030006,
- .depth_scale_front = 0x0,
- .depth_offset_front = 0x0,
- .depth_scale_back = 0x0,
- .depth_offset_back = 0x0,
- .polygon_offset_enable = 0x0,
- .cull_mode = 0x0,
- .line_stipple_config = 0x3BAAAAAB,
- .line_stipple_value = 0x0,
- .color_control = R300_SHADE_MODEL_FLAT,
-};
-
-static struct r300_rs_block r3xx_rs_block_clear_state = {
- .ip[0] = R500_RS_SEL_S(R300_RS_SEL_C0) |
- R500_RS_SEL_T(R300_RS_SEL_C0) |
- R500_RS_SEL_R(R300_RS_SEL_C0) |
- R500_RS_SEL_Q(R300_RS_SEL_K1),
- .inst[0] = R300_RS_INST_COL_CN_WRITE,
- .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN,
- .inst_count = 0,
-};
-
-static struct r300_rs_block r5xx_rs_block_clear_state = {
- .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) |
- R500_RS_SEL_T(R500_RS_IP_PTR_K0) |
- R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
- R500_RS_SEL_Q(R500_RS_IP_PTR_K1),
- .inst[0] = R500_RS_INST_COL_CN_WRITE,
- .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN,
- .inst_count = 0,
-};
-
-/* The following state is used for surface_copy only. */
-
-static struct r300_rs_block r3xx_rs_block_copy_state = {
- .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) |
- R500_RS_SEL_T(R300_RS_SEL_K0) |
- R500_RS_SEL_R(R300_RS_SEL_K0) |
- R500_RS_SEL_Q(R300_RS_SEL_K1),
- .inst[0] = R300_RS_INST_COL_CN_WRITE,
- .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN,
- .inst_count = R300_RS_TX_OFFSET(0),
-};
-
-static struct r300_rs_block r5xx_rs_block_copy_state = {
- .ip[0] = R500_RS_SEL_S(0) |
- R500_RS_SEL_T(1) |
- R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
- R500_RS_SEL_Q(R500_RS_IP_PTR_K1),
- .inst[0] = R500_RS_INST_TEX_CN_WRITE,
- .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN,
- .inst_count = R300_RS_TX_OFFSET(0),
-};
-
-static struct r300_sampler_state r300_sampler_copy_state = {
- .filter0 = R300_TX_WRAP_S(R300_TX_CLAMP) |
- R300_TX_WRAP_T(R300_TX_CLAMP) |
- R300_TX_MAG_FILTER_NEAREST |
- R300_TX_MIN_FILTER_NEAREST,
-};
-
-#endif /* R300_SURFACE_H */
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 7ea4c33fa9a..3c8ff24e17d 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -20,6 +20,12 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#include "pipe/p_screen.h"
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "r300_context.h"
#include "r300_texture.h"
static void r300_setup_texture_state(struct r300_texture* tex)
@@ -36,16 +42,16 @@ static void r300_setup_texture_state(struct r300_texture* tex)
/* XXX */
state->format1 = r300_translate_texformat(pt->format);
if (pt->target == PIPE_TEXTURE_CUBE) {
- state->format1 |= R300_TX_FORMAT_CUBIC_MAP;
+ state->format1 |= R300_TX_FORMAT_CUBIC_MAP;
}
if (pt->target == PIPE_TEXTURE_3D) {
- state->format1 |= R300_TX_FORMAT_3D;
+ state->format1 |= R300_TX_FORMAT_3D;
}
state->format2 = (r300_texture_get_stride(tex, 0) / pt->block.size) - 1;
- /* Assume (somewhat foolishly) that oversized textures will
- * not be permitted by the state tracker. */
+ /* Don't worry about accidentally setting this bit on non-r500;
+ * the kernel should catch it. */
if (pt->width[0] > 2048) {
state->format2 |= R500_TXWIDTH_BIT11;
}
@@ -67,7 +73,8 @@ unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level)
return tex->stride_override;
if (level > tex->tex.last_level) {
- debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__, level, tex->tex.last_level);
+ debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__,
+ level, tex->tex.last_level);
return 0;
}
@@ -90,11 +97,6 @@ static void r300_setup_miptree(struct r300_texture* tex)
base->nblocksx[i] = pf_get_nblocksx(&base->block, base->width[i]);
base->nblocksy[i] = pf_get_nblocksy(&base->block, base->height[i]);
- /* Radeons enjoy things in multiples of 64.
- *
- * XXX
- * POT, uncompressed, unmippmapped textures can be aligned to 32,
- * instead of 64. */
stride = r300_texture_get_stride(tex, i);
size = stride * base->nblocksy[i] * base->depth[i];
@@ -189,9 +191,7 @@ static struct pipe_texture*
{
struct r300_texture* tex;
- /* XXX we should start doing mips now... */
if (base->target != PIPE_TEXTURE_2D ||
- base->last_level != 0 ||
base->depth[0] != 1) {
return NULL;
}
@@ -207,7 +207,6 @@ static struct pipe_texture*
tex->stride_override = *stride;
- /* XXX */
r300_setup_texture_state(tex);
pipe_buffer_reference(&tex->buffer, buffer);
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 992dad77ab4..55d1a0ac5cf 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -23,11 +23,8 @@
#ifndef R300_TEXTURE_H
#define R300_TEXTURE_H
-#include "pipe/p_screen.h"
#include "pipe/p_video_state.h"
-#include "util/u_math.h"
-#include "r300_context.h"
#include "r300_reg.h"
struct r300_texture;
@@ -83,6 +80,7 @@ static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
R300_TX_FORMAT_YUV_TO_RGB;
/* W24_FP */
case PIPE_FORMAT_Z24S8_UNORM:
+ case PIPE_FORMAT_Z24X8_UNORM:
return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
default:
debug_printf("r300: Implementation error: "
diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c
index 8460cfaf518..eca85879a7f 100644
--- a/src/gallium/drivers/r300/r300_vs.c
+++ b/src/gallium/drivers/r300/r300_vs.c
@@ -146,89 +146,3 @@ void r300_translate_vertex_shader(struct r300_context* r300,
rc_destroy(&compiler.Base);
vs->translated = TRUE;
}
-
-
-/* XXX get these to r300_reg */
-#define R300_PVS_DST_OPCODE(x) ((x) << 0)
-# define R300_VE_DOT_PRODUCT 1
-# define R300_VE_MULTIPLY 2
-# define R300_VE_ADD 3
-# define R300_VE_MAXIMUM 7
-# define R300_VE_SET_LESS_THAN 10
-#define R300_PVS_DST_MATH_INST (1 << 6)
-# define R300_ME_RECIP_DX 6
-#define R300_PVS_DST_MACRO_INST (1 << 7)
-# define R300_PVS_MACRO_OP_2CLK_MADD 0
-#define R300_PVS_DST_REG_TYPE(x) ((x) << 8)
-# define R300_PVS_DST_REG_TEMPORARY 0
-# define R300_PVS_DST_REG_A0 1
-# define R300_PVS_DST_REG_OUT 2
-# define R300_PVS_DST_REG_OUT_REPL_X 3
-# define R300_PVS_DST_REG_ALT_TEMPORARY 4
-# define R300_PVS_DST_REG_INPUT 5
-#define R300_PVS_DST_OFFSET(x) ((x) << 13)
-#define R300_PVS_DST_WE(x) ((x) << 20)
-#define R300_PVS_DST_WE_XYZW (0xf << 20)
-
-#define R300_PVS_SRC_REG_TYPE(x) ((x) << 0)
-# define R300_PVS_SRC_REG_TEMPORARY 0
-# define R300_PVS_SRC_REG_INPUT 1
-# define R300_PVS_SRC_REG_CONSTANT 2
-# define R300_PVS_SRC_REG_ALT_TEMPORARY 3
-#define R300_PVS_SRC_OFFSET(x) ((x) << 5)
-#define R300_PVS_SRC_SWIZZLE(x) ((x) << 13)
-# define R300_PVS_SRC_SELECT_X 0
-# define R300_PVS_SRC_SELECT_Y 1
-# define R300_PVS_SRC_SELECT_Z 2
-# define R300_PVS_SRC_SELECT_W 3
-# define R300_PVS_SRC_SELECT_FORCE_0 4
-# define R300_PVS_SRC_SELECT_FORCE_1 5
-# define R300_PVS_SRC_SWIZZLE_XYZW \
- ((R300_PVS_SRC_SELECT_X | (R300_PVS_SRC_SELECT_Y << 3) | \
- (R300_PVS_SRC_SELECT_Z << 6) | (R300_PVS_SRC_SELECT_W << 9)) << 13)
-# define R300_PVS_SRC_SWIZZLE_ZERO \
- ((R300_PVS_SRC_SELECT_FORCE_0 | (R300_PVS_SRC_SELECT_FORCE_0 << 3) | \
- (R300_PVS_SRC_SELECT_FORCE_0 << 6) | \
- (R300_PVS_SRC_SELECT_FORCE_0 << 9)) << 13)
-# define R300_PVS_SRC_SWIZZLE_ONE \
- ((R300_PVS_SRC_SELECT_FORCE_1 | (R300_PVS_SRC_SELECT_FORCE_1 << 3) | \
- (R300_PVS_SRC_SELECT_FORCE_1 << 6) | \
- (R300_PVS_SRC_SELECT_FORCE_1 << 9)) << 13)
-#define R300_PVS_MODIFIER_X (1 << 25)
-#define R300_PVS_MODIFIER_Y (1 << 26)
-#define R300_PVS_MODIFIER_Z (1 << 27)
-#define R300_PVS_MODIFIER_W (1 << 28)
-#define R300_PVS_NEGATE_XYZW \
- (R300_PVS_MODIFIER_X | R300_PVS_MODIFIER_Y | \
- R300_PVS_MODIFIER_Z | R300_PVS_MODIFIER_W)
-
-struct r300_vertex_program_code r300_passthrough_vertex_shader = {
- .length = 8, /* two instructions */
-
- /* MOV out[0], in[0] */
- .body.d[0] = R300_PVS_DST_OPCODE(R300_VE_ADD) |
- R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) |
- R300_PVS_DST_OFFSET(0) | R300_PVS_DST_WE_XYZW,
- .body.d[1] = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) |
- R300_PVS_SRC_OFFSET(0) | R300_PVS_SRC_SWIZZLE_XYZW,
- .body.d[2] = R300_PVS_SRC_SWIZZLE_ZERO,
- .body.d[3] = 0x0,
-
- /* MOV out[1], in[1] */
- .body.d[4] = R300_PVS_DST_OPCODE(R300_VE_ADD) |
- R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) |
- R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW,
- .body.d[5] = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) |
- R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW,
- .body.d[6] = R300_PVS_SRC_SWIZZLE_ZERO,
- .body.d[7] = 0x0,
-
- .inputs[0] = 0,
- .inputs[1] = 1,
- .outputs[0] = 0,
- .outputs[1] = 1,
-
- .InputsRead = 3,
- .OutputsWritten = 3
-};
-
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index f18ad75a47d..864a6146b22 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -48,6 +48,9 @@ struct r300_winsys {
/* GB pipe count */
uint32_t gb_pipes;
+ /* Z pipe count (rv530 only) */
+ uint32_t z_pipes;
+
/* GART size. */
uint32_t gart_size;
@@ -92,6 +95,12 @@ struct r300_winsys {
/* Flush the CS. */
void (*flush_cs)(struct r300_winsys* winsys);
+
+ /* winsys flush - callback from winsys when flush required */
+ void (*set_flush_cb)(struct r300_winsys *winsys,
+ void (*flush_cb)(void *), void *data);
+
+ void (*reset_bos)(struct r300_winsys *winsys);
};
struct pipe_context* r300_create_context(struct pipe_screen* screen,
diff --git a/src/gallium/drivers/r300/r3xx_fs.c b/src/gallium/drivers/r300/r3xx_fs.c
deleted file mode 100644
index c1c1194d58e..00000000000
--- a/src/gallium/drivers/r300/r3xx_fs.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#include "r3xx_fs.h"
-
-#include "r300_reg.h"
-
-struct rX00_fragment_program_code r3xx_passthrough_fragment_shader = {
- .code.r300.alu.length = 1,
- .code.r300.tex.length = 0,
-
- .code.r300.config = 0,
- .code.r300.pixsize = 0,
- .code.r300.code_offset = 0,
- .code.r300.code_addr[3] = R300_RGBA_OUT,
-
- .code.r300.alu.inst[0].rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
- R300_ALU_OUTC_CMP,
- .code.r300.alu.inst[0].rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
- R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
- .code.r300.alu.inst[0].alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
- R300_ALU_OUTA_CMP,
- .code.r300.alu.inst[0].alpha_addr = R300_ALPHA_ADDR0(0) |
- R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
-};
-
-struct rX00_fragment_program_code r3xx_texture_fragment_shader = {
- .code.r300.alu.length = 1,
- .code.r300.tex.length = 1,
-
- .code.r300.config = R300_PFS_CNTL_FIRST_NODE_HAS_TEX,
- .code.r300.pixsize = 0,
- .code.r300.code_offset = 0,
- .code.r300.code_addr[3] = R300_RGBA_OUT,
-
- .code.r300.tex.inst[0] = R300_TEX_OP_LD << R300_TEX_INST_SHIFT,
-
- .code.r300.alu.inst[0].rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
- R300_ALU_OUTC_CMP,
- .code.r300.alu.inst[0].rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
- R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
- .code.r300.alu.inst[0].alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
- R300_ALU_OUTA_CMP,
- .code.r300.alu.inst[0].alpha_addr = R300_ALPHA_ADDR0(0) |
- R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
-};
diff --git a/src/gallium/drivers/r300/r3xx_fs.h b/src/gallium/drivers/r300/r3xx_fs.h
deleted file mode 100644
index 51cd245724d..00000000000
--- a/src/gallium/drivers/r300/r3xx_fs.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#ifndef R3XX_FS_H
-#define R3XX_FS_H
-
-#include "radeon_code.h"
-
-struct rX00_fragment_program_code r3xx_passthrough_fragment_shader;
-struct rX00_fragment_program_code r3xx_texture_fragment_shader;
-
-#endif /* R3XX_FS_H */
diff --git a/src/gallium/drivers/r300/r5xx_fs.c b/src/gallium/drivers/r300/r5xx_fs.c
deleted file mode 100644
index f072deab0d9..00000000000
--- a/src/gallium/drivers/r300/r5xx_fs.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#include "r5xx_fs.h"
-
-#include "r300_reg.h"
-
-/* XXX this all should find its way back to r300_reg */
-/* Swizzle tools */
-#define R500_SWIZZLE_ZERO 4
-#define R500_SWIZZLE_HALF 5
-#define R500_SWIZZLE_ONE 6
-#define R500_SWIZ_RGB_ZERO ((4 << 0) | (4 << 3) | (4 << 6))
-#define R500_SWIZ_RGB_ONE ((6 << 0) | (6 << 3) | (6 << 6))
-#define R500_SWIZ_RGB_RGB ((0 << 0) | (1 << 3) | (2 << 6))
-#define R500_SWIZ_MOD_NEG 1
-#define R500_SWIZ_MOD_ABS 2
-#define R500_SWIZ_MOD_NEG_ABS 3
-/* Swizzles for inst2 */
-#define R500_SWIZ_TEX_STRQ(x) ((x) << 8)
-#define R500_SWIZ_TEX_RGBA(x) ((x) << 24)
-/* Swizzles for inst3 */
-#define R500_SWIZ_RGB_A(x) ((x) << 2)
-#define R500_SWIZ_RGB_B(x) ((x) << 15)
-/* Swizzles for inst4 */
-#define R500_SWIZ_ALPHA_A(x) ((x) << 14)
-#define R500_SWIZ_ALPHA_B(x) ((x) << 21)
-/* Swizzle for inst5 */
-#define R500_SWIZ_RGBA_C(x) ((x) << 14)
-#define R500_SWIZ_ALPHA_C(x) ((x) << 27)
-/* Writemasks */
-#define R500_TEX_WMASK(x) ((x) << 11)
-#define R500_ALU_WMASK(x) ((x) << 11)
-#define R500_ALU_OMASK(x) ((x) << 15)
-#define R500_W_OMASK (1 << 31)
-
-struct rX00_fragment_program_code r5xx_passthrough_fragment_shader = {
- .code.r500.max_temp_idx = 0,
- .code.r500.inst_end = 0,
-
- .code.r500.inst[0].inst0 = R500_INST_TYPE_OUT |
- R500_INST_TEX_SEM_WAIT | R500_INST_LAST |
- R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
- R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
- .code.r500.inst[0].inst1 =
- R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
- R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST,
- .code.r500.inst[0].inst2 =
- R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
- R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST,
- .code.r500.inst[0].inst3 =
- R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R |
- R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B |
- R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R |
- R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B,
- .code.r500.inst[0].inst4 =
- R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A,
- .code.r500.inst[0].inst5 =
- R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 |
- R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 |
- R500_ALU_RGBA_A_SWIZ_0,
-};
-
-struct rX00_fragment_program_code r5xx_texture_fragment_shader = {
- .code.r500.max_temp_idx = 0,
- .code.r500.inst_end = 1,
-
- .code.r500.inst[0].inst0 = R500_INST_TYPE_TEX |
- R500_INST_TEX_SEM_WAIT |
- R500_INST_RGB_WMASK_RGB | R500_INST_ALPHA_WMASK |
- R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
- .code.r500.inst[0].inst1 = R500_TEX_ID(0) | R500_TEX_INST_LD |
- R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED,
- .code.r500.inst[0].inst2 = R500_TEX_SRC_ADDR(0) |
- R500_TEX_SRC_S_SWIZ_R | R500_TEX_SRC_T_SWIZ_G |
- R500_TEX_SRC_R_SWIZ_B | R500_TEX_SRC_Q_SWIZ_A |
- R500_TEX_DST_ADDR(0) |
- R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G |
- R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A,
- .code.r500.inst[0].inst3 = 0x0,
- .code.r500.inst[0].inst4 = 0x0,
- .code.r500.inst[0].inst5 = 0x0,
-
- .code.r500.inst[1].inst0 = R500_INST_TYPE_OUT |
- R500_INST_TEX_SEM_WAIT | R500_INST_LAST |
- R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
- R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
- .code.r500.inst[1].inst1 =
- R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
- R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST,
- .code.r500.inst[1].inst2 =
- R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
- R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST,
- .code.r500.inst[1].inst3 =
- R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R |
- R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B |
- R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R |
- R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B,
- .code.r500.inst[1].inst4 =
- R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A,
- .code.r500.inst[1].inst5 =
- R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 |
- R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 |
- R500_ALU_RGBA_A_SWIZ_0,
-};
diff --git a/src/gallium/drivers/r300/r5xx_fs.h b/src/gallium/drivers/r300/r5xx_fs.h
deleted file mode 100644
index a4addde32b2..00000000000
--- a/src/gallium/drivers/r300/r5xx_fs.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#ifndef R5XX_FS_H
-#define R5XX_FS_H
-
-#include "radeon_code.h"
-
-struct rX00_fragment_program_code r5xx_passthrough_fragment_shader;
-struct rX00_fragment_program_code r5xx_texture_fragment_shader;
-
-#endif /* R5XX_FS_H */
diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c
index 781ca5d3bc0..48d1c4051cc 100644
--- a/src/gallium/drivers/trace/tr_drm.c
+++ b/src/gallium/drivers/trace/tr_drm.c
@@ -150,7 +150,9 @@ trace_drm_destroy(struct drm_api *_api)
{
struct trace_drm_api *tr_api = trace_drm_api(_api);
struct drm_api *api = tr_api->api;
- api->destroy(api);
+
+ if (api->destroy)
+ api->destroy(api);
free(tr_api);
}
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index ab605c7fc87..7da9bd3866b 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -366,7 +366,8 @@ trace_screen_get_tex_transfer(struct pipe_screen *_screen,
trace_dump_call_end();
- result = trace_transfer_create(tr_tex, result);
+ if (result)
+ result = trace_transfer_create(tr_tex, result);
return result;
}
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
index c13cffceb0a..c36286f9bee 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -167,11 +167,17 @@ typedef unsigned char boolean;
#define ALIGN16_ASSIGN(NAME) NAME##___aligned
#define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
#define ALIGN8_ATTRIB __attribute__(( aligned( 8 ) ))
+#if __GNUC__ > 4 || (__GNUC__ == 4 &&__GNUC_MINOR__>1)
+#define ALIGN_STACK __attribute__((force_align_arg_pointer))
+#else
+#define ALIGN_STACK
+#endif
#else
#define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
#define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
#define ALIGN16_ATTRIB
#define ALIGN8_ATTRIB
+#define ALIGN_STACK
#endif
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 39620a71980..5569001e601 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -189,6 +189,9 @@ struct pipe_context {
/**
* Surface functions
+ *
+ * The pipe driver is allowed to set these functions to NULL, and in that
+ * case, they will not be available.
*/
/*@{*/
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index c67cc8dacb6..5625ff53cfd 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -45,6 +45,7 @@
#include "state_tracker/st_cb_fbo.h"
#include "util/u_memory.h"
+#include "util/u_rect.h"
static struct pipe_surface *
dri_surface_from_handle(struct drm_api *api,
@@ -541,12 +542,21 @@ dri1_swap_copy(struct dri_context *ctx,
cur = dPriv->pClipRects;
for (i = 0; i < dPriv->numClipRects; ++i) {
- if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox))
- pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
- src,
- (int)clip.x1 - dPriv->x,
- (int)clip.y1 - dPriv->y,
- clip.x2 - clip.x1, clip.y2 - clip.y1);
+ if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
+ if (pipe->surface_copy) {
+ pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
+ src,
+ (int)clip.x1 - dPriv->x,
+ (int)clip.y1 - dPriv->y,
+ clip.x2 - clip.x1, clip.y2 - clip.y1);
+ } else {
+ util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
+ src,
+ (int)clip.x1 - dPriv->x,
+ (int)clip.y1 - dPriv->y,
+ clip.x2 - clip.x1, clip.y2 - clip.y1);
+ }
+ }
}
}
diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c
index f39a305531e..800d462e322 100644
--- a/src/gallium/state_trackers/dri/dri_extensions.c
+++ b/src/gallium/state_trackers/dri/dri_extensions.c
@@ -37,6 +37,7 @@
#define need_GL_ARB_multisample
#define need_GL_ARB_occlusion_query
#define need_GL_ARB_point_parameters
+#define need_GL_ARB_provoking_vertex
#define need_GL_ARB_shader_objects
#define need_GL_ARB_texture_compression
#define need_GL_ARB_vertex_array_object
@@ -52,6 +53,7 @@
#define need_GL_EXT_fog_coord
#define need_GL_EXT_framebuffer_object
#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_provoking_vertex
#define need_GL_EXT_secondary_color
#define need_GL_APPLE_vertex_array_object
#define need_GL_NV_vertex_program
@@ -69,6 +71,7 @@ const struct dri_extension card_extensions[] = {
{"GL_ARB_multitexture", NULL},
{"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions},
{"GL_ARB_pixel_buffer_object", NULL},
+ {"GL_ARB_provoking_vertex", GL_ARB_provoking_vertex_functions},
{"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
{"GL_ARB_shading_language_100", GL_VERSION_2_0_functions },
{"GL_ARB_shading_language_120", GL_VERSION_2_1_functions },
@@ -97,6 +100,7 @@ const struct dri_extension card_extensions[] = {
{"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
{"GL_EXT_packed_depth_stencil", NULL},
{"GL_EXT_pixel_buffer_object", NULL},
+ {"GL_EXT_provoking_vertex", GL_EXT_provoking_vertex_functions},
{"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
{"GL_EXT_stencil_wrap", NULL},
{"GL_EXT_texture_edge_clamp", NULL},
diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c
index 7911a8834e0..71c013756d3 100644
--- a/src/gallium/state_trackers/egl/egl_surface.c
+++ b/src/gallium/state_trackers/egl/egl_surface.c
@@ -12,6 +12,8 @@
#include "state_tracker/drm_api.h"
+#include "util/u_rect.h"
+
/*
* Util functions
*/
@@ -360,12 +362,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
st_notify_swapbuffers(surf->stfb);
if (ctx && surf->screen) {
- ctx->pipe->surface_copy(ctx->pipe,
- surf->screen->surface,
- 0, 0,
- back_surf,
- 0, 0,
- surf->w, surf->h);
+ if (ctx->pipe->surface_copy) {
+ ctx->pipe->surface_copy(ctx->pipe,
+ surf->screen->surface,
+ 0, 0,
+ back_surf,
+ 0, 0,
+ surf->w, surf->h);
+ } else {
+ util_surface_copy(ctx->pipe, FALSE,
+ surf->screen->surface,
+ 0, 0,
+ back_surf,
+ 0, 0,
+ surf->w, surf->h);
+ }
ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
#ifdef DRM_MODE_FEATURE_DIRTYFB
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index f7c5f2f0cdf..396c88aa3d2 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -37,6 +37,7 @@
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
#include "util/u_memory.h"
+#include "util/u_rect.h"
#include "cso_cache/cso_context.h"
@@ -457,10 +458,17 @@ void renderer_copy_surface(struct renderer *ctx,
PIPE_BUFFER_USAGE_GPU_WRITE);
/* load temp texture */
- pipe->surface_copy(pipe,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
+ if (pipe->surface_copy) {
+ pipe->surface_copy(pipe,
+ texSurf, 0, 0, /* dest */
+ src, srcLeft, srcTop, /* src */
+ srcW, srcH); /* size */
+ } else {
+ util_surface_copy(pipe, FALSE,
+ texSurf, 0, 0, /* dest */
+ src, srcLeft, srcTop, /* src */
+ srcW, srcH); /* size */
+ }
/* free the surface, update the texture if necessary.*/
screen->tex_surface_destroy(texSurf);
diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c
index 56cc60aebe1..c4da01e52cc 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.c
+++ b/src/gallium/state_trackers/vega/vg_tracker.c
@@ -235,13 +235,23 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
old_texture,
0, 0, 0,
PIPE_BUFFER_USAGE_GPU_READ);
- pipe->surface_copy(pipe,
- surface,
- 0, 0,
- old_surface,
- 0, 0,
- MIN2(old_surface->width, width),
- MIN2(old_surface->height, height));
+ if (pipe->surface_copy) {
+ pipe->surface_copy(pipe,
+ surface,
+ 0, 0,
+ old_surface,
+ 0, 0,
+ MIN2(old_surface->width, width),
+ MIN2(old_surface->height, height));
+ } else {
+ util_surface_copy(pipe, FALSE,
+ surface,
+ 0, 0,
+ old_surface,
+ 0, 0,
+ MIN2(old_surface->width, width),
+ MIN2(old_surface->height, height));
+ }
if (surface)
pipe_surface_reference(&surface, NULL);
if (old_surface)
diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile
index 030bac5fff2..22c107370e8 100644
--- a/src/gallium/state_trackers/xorg/Makefile
+++ b/src/gallium/state_trackers/xorg/Makefile
@@ -5,7 +5,8 @@ LIBNAME = xorgtracker
LIBRARY_INCLUDES = \
-DHAVE_CONFIG_H \
- -DHAVE_XEXTPROTO_71=1 \
+ $(shell pkg-config xextproto --atleast-version=7.0.99.1 \
+ && echo "-DHAVE_XEXTPROTO_71") \
$(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/auxiliary \
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
index 6871625605f..e039bb12b6d 100644
--- a/src/gallium/state_trackers/xorg/xorg_composite.c
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -9,37 +9,47 @@
#include "pipe/p_inlines.h"
+/*XXX also in Xrender.h but the including it here breaks compilition */
+#define XFixedToDouble(f) (((double) (f)) / 65536.)
+
struct xorg_composite_blend {
- int op:8;
+ int op : 8;
- unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */
- unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */
+ unsigned alpha_dst : 4;
+ unsigned alpha_src : 4;
- unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
- unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
+ unsigned rgb_src : 8; /**< PIPE_BLENDFACTOR_x */
+ unsigned rgb_dst : 8; /**< PIPE_BLENDFACTOR_x */
};
#define BLEND_OP_OVER 3
static const struct xorg_composite_blend xorg_blends[] = {
{ PictOpClear,
- PIPE_BLENDFACTOR_CONST_COLOR, PIPE_BLENDFACTOR_CONST_ALPHA,
- PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO },
-
+ 0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO},
{ PictOpSrc,
- PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE,
- PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO },
-
+ 0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO},
{ PictOpDst,
- PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO,
- PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE },
-
+ 0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE},
{ PictOpOver,
- PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE,
- PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
-
+ 0, 1, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
{ PictOpOverReverse,
- PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE,
- PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
+ 1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE},
+ { PictOpIn,
+ 1, 0, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ZERO},
+ { PictOpInReverse,
+ 0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_SRC_ALPHA},
+ { PictOpOut,
+ 1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ZERO},
+ { PictOpOutReverse,
+ 0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+ { PictOpAtop,
+ 1, 1, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+ { PictOpAtopReverse,
+ 1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_SRC_ALPHA},
+ { PictOpXor,
+ 1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+ { PictOpAdd,
+ 0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE},
};
@@ -58,40 +68,48 @@ pixel_to_float4(Pixel pixel, float *color)
color[3] = ((float)a) / 255.;
}
-struct acceleration_info {
- int op : 16;
- int with_mask : 1;
- int component_alpha : 1;
-};
-static const struct acceleration_info accelerated_ops[] = {
- {PictOpClear, 1, 0},
- {PictOpSrc, 1, 0},
- {PictOpDst, 1, 0},
- {PictOpOver, 1, 0},
- {PictOpOverReverse, 1, 0},
- {PictOpIn, 1, 0},
- {PictOpInReverse, 1, 0},
- {PictOpOut, 1, 0},
- {PictOpOutReverse, 1, 0},
- {PictOpAtop, 1, 0},
- {PictOpAtopReverse, 1, 0},
- {PictOpXor, 1, 0},
- {PictOpAdd, 1, 0},
- {PictOpSaturate, 1, 0},
-};
-
-static struct xorg_composite_blend
-blend_for_op(int op)
+static boolean
+blend_for_op(struct xorg_composite_blend *blend,
+ int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
{
const int num_blends =
sizeof(xorg_blends)/sizeof(struct xorg_composite_blend);
int i;
+ boolean supported = FALSE;
+
+ /* our default in case something goes wrong */
+ *blend = xorg_blends[BLEND_OP_OVER];
for (i = 0; i < num_blends; ++i) {
- if (xorg_blends[i].op == op)
- return xorg_blends[i];
+ if (xorg_blends[i].op == op) {
+ *blend = xorg_blends[i];
+ supported = TRUE;
+ }
}
- return xorg_blends[BLEND_OP_OVER];
+
+ /* If there's no dst alpha channel, adjust the blend op so that we'll treat
+ * it as always 1. */
+ if (pDstPicture &&
+ PICT_FORMAT_A(pDstPicture->format) == 0 && blend->alpha_dst) {
+ if (blend->rgb_src == PIPE_BLENDFACTOR_DST_ALPHA)
+ blend->rgb_src = PIPE_BLENDFACTOR_ONE;
+ else if (blend->rgb_src == PIPE_BLENDFACTOR_INV_DST_ALPHA)
+ blend->rgb_src = PIPE_BLENDFACTOR_ZERO;
+ }
+
+ /* If the source alpha is being used, then we should only be in a case where
+ * the source blend factor is 0, and the source blend value is the mask
+ * channels multiplied by the source picture's alpha. */
+ if (pMaskPicture && pMaskPicture->componentAlpha &&
+ PICT_FORMAT_RGB(pMaskPicture->format) && blend->alpha_src) {
+ if (blend->rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) {
+ blend->rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR;
+ } else if (blend->rgb_dst == PIPE_BLENDFACTOR_INV_SRC_ALPHA) {
+ blend->rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR;
+ }
+ }
+ return supported;
}
static INLINE int
@@ -112,6 +130,43 @@ render_repeat_to_gallium(int mode)
return PIPE_TEX_WRAP_REPEAT;
}
+static INLINE boolean
+render_filter_to_gallium(int xrender_filter, int *out_filter)
+{
+
+ switch (xrender_filter) {
+ case PictFilterNearest:
+ *out_filter = PIPE_TEX_FILTER_NEAREST;
+ break;
+ case PictFilterBilinear:
+ *out_filter = PIPE_TEX_FILTER_LINEAR;
+ break;
+ case PictFilterFast:
+ *out_filter = PIPE_TEX_FILTER_NEAREST;
+ break;
+ case PictFilterGood:
+ *out_filter = PIPE_TEX_FILTER_LINEAR;
+ break;
+ case PictFilterBest:
+ *out_filter = PIPE_TEX_FILTER_LINEAR;
+ break;
+ default:
+ debug_printf("Unkown xrender filter");
+ *out_filter = PIPE_TEX_FILTER_NEAREST;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static boolean is_filter_accelerated(PicturePtr pic)
+{
+ int filter;
+ if (pic && !render_filter_to_gallium(pic->filter, &filter))
+ return FALSE;
+ return TRUE;
+}
+
boolean xorg_composite_accelerated(int op,
PicturePtr pSrcPicture,
PicturePtr pMaskPicture,
@@ -120,51 +175,53 @@ boolean xorg_composite_accelerated(int op,
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- unsigned i;
- unsigned accel_ops_count =
- sizeof(accelerated_ops)/sizeof(struct acceleration_info);
+ struct xorg_composite_blend blend;
+
+ if (!is_filter_accelerated(pSrcPicture) ||
+ !is_filter_accelerated(pMaskPicture)) {
+ XORG_FALLBACK("Unsupported Xrender filter");
+ }
if (pSrcPicture->pSourcePict) {
if (pSrcPicture->pSourcePict->type != SourcePictTypeSolidFill)
- XORG_FALLBACK("gradients not enabled (haven't been well tested)");
+ XORG_FALLBACK("Gradients not enabled (haven't been well tested)");
}
- for (i = 0; i < accel_ops_count; ++i) {
- if (op == accelerated_ops[i].op) {
- /* Check for unsupported component alpha */
- if ((pSrcPicture->componentAlpha &&
- !accelerated_ops[i].component_alpha) ||
- (pMaskPicture &&
- (!accelerated_ops[i].with_mask ||
- (pMaskPicture->componentAlpha &&
- !accelerated_ops[i].component_alpha))))
- XORG_FALLBACK("component alpha unsupported");
- return TRUE;
+ if (blend_for_op(&blend, op,
+ pSrcPicture, pMaskPicture, pDstPicture)) {
+ /* Check for component alpha */
+ if (pMaskPicture && pMaskPicture->componentAlpha &&
+ PICT_FORMAT_RGB(pMaskPicture->format)) {
+ if (blend.alpha_src && blend.rgb_src != PIPE_BLENDFACTOR_ZERO) {
+ XORG_FALLBACK("Component alpha not supported with source "
+ "alpha and source value blending. (op=%d)",
+ op);
+ }
}
+ return TRUE;
}
- XORG_FALLBACK("unsupported operation");
+ XORG_FALLBACK("Unsupported composition operation = %d", op);
}
static void
bind_blend_state(struct exa_context *exa, int op,
- PicturePtr pSrcPicture, PicturePtr pMaskPicture)
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
{
struct xorg_composite_blend blend_opt;
struct pipe_blend_state blend;
- blend_opt = blend_for_op(op);
+ blend_for_op(&blend_opt, op, pSrcPicture, pMaskPicture, pDstPicture);
memset(&blend, 0, sizeof(struct pipe_blend_state));
blend.blend_enable = 1;
- blend.colormask |= PIPE_MASK_R;
- blend.colormask |= PIPE_MASK_G;
- blend.colormask |= PIPE_MASK_B;
- blend.colormask |= PIPE_MASK_A;
+ blend.colormask |= PIPE_MASK_RGBA;
- blend.rgb_src_factor = blend_opt.rgb_src_factor;
- blend.alpha_src_factor = blend_opt.alpha_src_factor;
- blend.rgb_dst_factor = blend_opt.rgb_dst_factor;
- blend.alpha_dst_factor = blend_opt.alpha_dst_factor;
+ blend.rgb_src_factor = blend_opt.rgb_src;
+ blend.alpha_src_factor = blend_opt.rgb_src;
+ blend.rgb_dst_factor = blend_opt.rgb_dst;
+ blend.alpha_dst_factor = blend_opt.rgb_dst;
cso_set_blend(exa->renderer->cso, &blend);
}
@@ -200,6 +257,8 @@ bind_shaders(struct exa_context *exa, int op,
if (pMaskPicture) {
vs_traits |= VS_MASK;
fs_traits |= FS_MASK;
+ if (pMaskPicture->componentAlpha)
+ fs_traits |= FS_COMPONENT_ALPHA;
}
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
@@ -207,7 +266,6 @@ bind_shaders(struct exa_context *exa, int op,
cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs);
}
-
static void
bind_samplers(struct exa_context *exa, int op,
PicturePtr pSrcPicture, PicturePtr pMaskPicture,
@@ -233,10 +291,15 @@ bind_samplers(struct exa_context *exa, int op,
if (pSrcPicture && pSrc) {
unsigned src_wrap = render_repeat_to_gallium(
pSrcPicture->repeatType);
+ int filter;
+
+ render_filter_to_gallium(pSrcPicture->filter, &filter);
+
src_sampler.wrap_s = src_wrap;
src_sampler.wrap_t = src_wrap;
- src_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
- src_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
+ src_sampler.min_img_filter = filter;
+ src_sampler.mag_img_filter = filter;
+ src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
src_sampler.normalized_coords = 1;
samplers[0] = &src_sampler;
exa->bound_textures[0] = pSrc->tex;
@@ -246,10 +309,15 @@ bind_samplers(struct exa_context *exa, int op,
if (pMaskPicture && pMask) {
unsigned mask_wrap = render_repeat_to_gallium(
pMaskPicture->repeatType);
+ int filter;
+
+ render_filter_to_gallium(pMaskPicture->filter, &filter);
+
mask_sampler.wrap_s = mask_wrap;
mask_sampler.wrap_t = mask_wrap;
- mask_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
- mask_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
+ mask_sampler.min_img_filter = filter;
+ mask_sampler.mag_img_filter = filter;
+ src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
mask_sampler.normalized_coords = 1;
samplers[1] = &mask_sampler;
exa->bound_textures[1] = pMask->tex;
@@ -297,6 +365,44 @@ setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst)
setup_fs_constant_buffer(exa);
}
+static INLINE boolean matrix_from_pict_transform(PictTransform *trans, float *matrix)
+{
+ if (!trans)
+ return FALSE;
+
+ matrix[0] = XFixedToDouble(trans->matrix[0][0]);
+ matrix[1] = XFixedToDouble(trans->matrix[0][1]);
+ matrix[2] = XFixedToDouble(trans->matrix[0][2]);
+
+ matrix[3] = XFixedToDouble(trans->matrix[1][0]);
+ matrix[4] = XFixedToDouble(trans->matrix[1][1]);
+ matrix[5] = XFixedToDouble(trans->matrix[1][2]);
+
+ matrix[6] = XFixedToDouble(trans->matrix[2][0]);
+ matrix[7] = XFixedToDouble(trans->matrix[2][1]);
+ matrix[8] = XFixedToDouble(trans->matrix[2][2]);
+
+ return TRUE;
+}
+
+static void
+setup_transforms(struct exa_context *exa,
+ PicturePtr pSrcPicture, PicturePtr pMaskPicture)
+{
+ PictTransform *src_t = NULL;
+ PictTransform *mask_t = NULL;
+
+ if (pSrcPicture)
+ src_t = pSrcPicture->transform;
+ if (pMaskPicture)
+ mask_t = pMaskPicture->transform;
+
+ exa->transform.has_src =
+ matrix_from_pict_transform(src_t, exa->transform.src);
+ exa->transform.has_mask =
+ matrix_from_pict_transform(mask_t, exa->transform.mask);
+}
+
boolean xorg_composite_bind_state(struct exa_context *exa,
int op,
PicturePtr pSrcPicture,
@@ -308,13 +414,15 @@ boolean xorg_composite_bind_state(struct exa_context *exa,
{
renderer_bind_framebuffer(exa->renderer, pDst);
renderer_bind_viewport(exa->renderer, pDst);
- bind_blend_state(exa, op, pSrcPicture, pMaskPicture);
+ bind_blend_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture);
renderer_bind_rasterizer(exa->renderer);
bind_shaders(exa, op, pSrcPicture, pMaskPicture);
bind_samplers(exa, op, pSrcPicture, pMaskPicture,
pDstPicture, pSrc, pMask, pDst);
setup_constant_buffers(exa, pDst);
+ setup_transforms(exa, pSrcPicture, pMaskPicture);
+
return TRUE;
}
@@ -329,10 +437,19 @@ void xorg_composite(struct exa_context *exa,
exa->solid_color);
} else {
int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY};
+ float *src_matrix = NULL;
+ float *mask_matrix = NULL;
+
+ if (exa->transform.has_src)
+ src_matrix = exa->transform.src;
+ if (exa->transform.has_mask)
+ mask_matrix = exa->transform.mask;
+
renderer_draw_textures(exa->renderer,
pos, width, height,
exa->bound_textures,
- exa->num_bound_samplers);
+ exa->num_bound_samplers,
+ src_matrix, mask_matrix);
}
}
@@ -346,8 +463,6 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
pixel_to_float4(fg, exa->solid_color);
exa->has_solid_color = TRUE;
- exa->solid_color[3] = 1.f;
-
#if 0
debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n",
(fg >> 24) & 0xff, (fg >> 16) & 0xff,
@@ -362,7 +477,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
renderer_bind_framebuffer(exa->renderer, pixmap);
renderer_bind_viewport(exa->renderer, pixmap);
renderer_bind_rasterizer(exa->renderer);
- bind_blend_state(exa, PictOpSrc, NULL, NULL);
+ bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL);
setup_constant_buffers(exa, pixmap);
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 95973586da8..85b9162d4cf 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -43,10 +43,10 @@
#include "xf86Modes.h"
#ifdef HAVE_XEXTPROTO_71
-#include "X11/extensions/dpmsconst.h"
+#include <X11/extensions/dpmsconst.h>
#else
#define DPMS_SERVER
-#include "X11/extensions/dpmsconst.h"
+#include <X11/extensions/dpms.h>
#endif
#include "pipe/p_inlines.h"
@@ -64,8 +64,6 @@ struct crtc_private
static void
crtc_dpms(xf86CrtcPtr crtc, int mode)
{
- //ScrnInfoPtr pScrn = crtc->scrn;
-
switch (mode) {
case DPMSModeOn:
case DPMSModeStandby:
@@ -77,44 +75,29 @@ crtc_dpms(xf86CrtcPtr crtc, int mode)
}
static Bool
-crtc_lock(xf86CrtcPtr crtc)
-{
- return FALSE;
-}
-
-static void
-crtc_unlock(xf86CrtcPtr crtc)
-{
-}
-
-static void
-crtc_prepare(xf86CrtcPtr crtc)
-{
-}
-
-static void
-crtc_commit(xf86CrtcPtr crtc)
-{
-}
-
-static Bool
-crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
- DisplayModePtr adjusted_mode)
-{
- return TRUE;
-}
-
-static void
-crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
- DisplayModePtr adjusted_mode, int x, int y)
+crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, int x, int y)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
modesettingPtr ms = modesettingPTR(crtc->scrn);
- xf86OutputPtr output = config->output[config->compat_output];
- drmModeConnectorPtr drm_connector = output->driver_private;
+ xf86OutputPtr output = NULL;
+ drmModeConnectorPtr drm_connector;
struct crtc_private *crtcp = crtc->driver_private;
drmModeCrtcPtr drm_crtc = crtcp->drm_crtc;
drmModeModeInfo drm_mode;
+ int i, ret;
+
+ for (i = 0; i < config->num_output; output = NULL, i++) {
+ output = config->output[i];
+
+ if (output->crtc == crtc)
+ break;
+ }
+
+ if (!output)
+ return FALSE;
+
+ drm_connector = output->driver_private;
drm_mode.clock = mode->Clock;
drm_mode.hdisplay = mode->HDisplay;
@@ -133,17 +116,19 @@ crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
xf86SetModeDefaultName(mode);
strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN);
- drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
- &drm_connector->connector_id, 1, &drm_mode);
-}
+ ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
+ &drm_connector->connector_id, 1, &drm_mode);
-#if 0
-static void
-crtc_load_lut(xf86CrtcPtr crtc)
-{
- //ScrnInfoPtr pScrn = crtc->scrn;
+ if (ret)
+ return FALSE;
+
+ crtc->x = x;
+ crtc->y = y;
+ crtc->mode = *mode;
+ crtc->rotation = rotation;
+
+ return TRUE;
}
-#endif
static void
crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue,
@@ -154,37 +139,37 @@ crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue,
static void *
crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
{
- //ScrnInfoPtr pScrn = crtc->scrn;
-
return NULL;
}
static PixmapPtr
crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
{
- //ScrnInfoPtr pScrn = crtc->scrn;
-
return NULL;
}
static void
crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
{
- //ScrnInfoPtr pScrn = crtc->scrn;
}
+/*
+ * Cursor functions
+ */
+
static void
-crtc_destroy(xf86CrtcPtr crtc)
+crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
{
- struct crtc_private *crtcp = crtc->driver_private;
+}
- if (crtcp->cursor_tex)
- pipe_texture_reference(&crtcp->cursor_tex, NULL);
+static void
+crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
- drmModeFreeCrtc(crtcp->drm_crtc);
- xfree(crtcp);
+ drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y);
}
-
static void
crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
{
@@ -230,15 +215,6 @@ crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
}
static void
-crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
-{
- modesettingPtr ms = modesettingPTR(crtc->scrn);
- struct crtc_private *crtcp = crtc->driver_private;
-
- drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y);
-}
-
-static void
crtc_show_cursor(xf86CrtcPtr crtc)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
@@ -258,29 +234,6 @@ crtc_hide_cursor(xf86CrtcPtr crtc)
drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0);
}
-static const xf86CrtcFuncsRec crtc_funcs = {
- .dpms = crtc_dpms,
- .save = NULL,
- .restore = NULL,
- .lock = crtc_lock,
- .unlock = crtc_unlock,
- .mode_fixup = crtc_mode_fixup,
- .prepare = crtc_prepare,
- .mode_set = crtc_mode_set,
- .commit = crtc_commit,
- .gamma_set = crtc_gamma_set,
- .shadow_create = crtc_shadow_create,
- .shadow_allocate = crtc_shadow_allocate,
- .shadow_destroy = crtc_shadow_destroy,
- .set_cursor_position = crtc_set_cursor_position,
- .show_cursor = crtc_show_cursor,
- .hide_cursor = crtc_hide_cursor,
- .load_cursor_image = NULL, /* lets convert to argb only */
- .set_cursor_colors = NULL, /* using argb only */
- .load_cursor_argb = crtc_load_cursor_argb,
- .destroy = crtc_destroy,
-};
-
void
crtc_cursor_destroy(xf86CrtcPtr crtc)
{
@@ -291,6 +244,40 @@ crtc_cursor_destroy(xf86CrtcPtr crtc)
}
}
+/*
+ * Misc functions
+ */
+
+static void
+crtc_destroy(xf86CrtcPtr crtc)
+{
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ if (crtcp->cursor_tex)
+ pipe_texture_reference(&crtcp->cursor_tex, NULL);
+
+ drmModeFreeCrtc(crtcp->drm_crtc);
+ xfree(crtcp);
+}
+
+static const xf86CrtcFuncsRec crtc_funcs = {
+ .dpms = crtc_dpms,
+ .set_mode_major = crtc_set_mode_major,
+
+ .set_cursor_colors = crtc_set_cursor_colors,
+ .set_cursor_position = crtc_set_cursor_position,
+ .show_cursor = crtc_show_cursor,
+ .hide_cursor = crtc_hide_cursor,
+ .load_cursor_argb = crtc_load_cursor_argb,
+
+ .shadow_create = crtc_shadow_create,
+ .shadow_allocate = crtc_shadow_allocate,
+ .shadow_destroy = crtc_shadow_destroy,
+
+ .gamma_set = crtc_gamma_set,
+ .destroy = crtc_destroy,
+};
+
void
crtc_init(ScrnInfoPtr pScrn)
{
@@ -309,6 +296,7 @@ crtc_init(ScrnInfoPtr pScrn)
for (c = 0; c < res->count_crtcs; c++) {
drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]);
+
if (!drm_crtc)
continue;
@@ -325,7 +313,6 @@ crtc_init(ScrnInfoPtr pScrn)
crtcp->drm_crtc = drm_crtc;
crtc->driver_private = crtcp;
-
}
out:
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index ab6c3d75580..847647c1e4d 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -144,20 +144,22 @@ static Bool
CreateFrontBuffer(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
- ScreenPtr pScreen = pScrn->pScreen;
- PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
unsigned handle, stride;
+ struct pipe_texture *tex;
ms->noEvict = TRUE;
- xorg_exa_set_displayed_usage(rootPixmap);
- pScreen->ModifyPixmapHeader(rootPixmap,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->depth, pScrn->bitsPerPixel,
- pScrn->displayWidth * pScrn->bitsPerPixel / 8,
- NULL);
- ms->noEvict = FALSE;
- handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride);
+ tex = xorg_exa_create_root_texture(pScrn, pScrn->virtualX, pScrn->virtualY,
+ pScrn->depth, pScrn->bitsPerPixel);
+
+ if (!tex)
+ return FALSE;
+
+ if (!ms->api->local_handle_from_texture(ms->api, ms->screen,
+ tex,
+ &stride,
+ &handle))
+ return FALSE;
drmModeAddFB(ms->fd,
pScrn->virtualX,
@@ -166,12 +168,39 @@ CreateFrontBuffer(ScrnInfoPtr pScrn)
pScrn->bitsPerPixel,
stride,
handle,
- &ms->fb_id);
+ &ms->fb_id);
pScrn->frameX0 = 0;
pScrn->frameY0 = 0;
AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ pipe_texture_reference(&ms->root_texture, tex);
+ pipe_texture_reference(&tex, NULL);
+ return TRUE;
+}
+
+static Bool
+BindTextureToRoot(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ ScreenPtr pScreen = pScrn->pScreen;
+ struct pipe_texture *check;
+ PixmapPtr rootPixmap;
+
+ rootPixmap = pScreen->GetScreenPixmap(pScreen);
+
+ xorg_exa_set_displayed_usage(rootPixmap);
+ xorg_exa_set_shared_usage(rootPixmap);
+ xorg_exa_set_texture(rootPixmap, ms->root_texture);
+ if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
+ FatalError("Couldn't adjust screen pixmap\n");
+
+ check = xorg_exa_get_texture(rootPixmap);
+ if (ms->root_texture != check)
+ FatalError("Created new root texture\n");
+
+ pipe_texture_reference(&check, NULL);
+
return TRUE;
}
@@ -179,10 +208,9 @@ static Bool
crtc_resize(ScrnInfoPtr pScrn, int width, int height)
{
modesettingPtr ms = modesettingPTR(pScrn);
- //ScreenPtr pScreen = pScrn->pScreen;
- //PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
- //Bool fbAccessDisabled;
- //CARD8 *fbstart;
+ unsigned handle, stride;
+ PixmapPtr rootPixmap;
+ ScreenPtr pScreen = pScrn->pScreen;
if (width == pScrn->virtualX && height == pScrn->virtualY)
return TRUE;
@@ -192,13 +220,40 @@ crtc_resize(ScrnInfoPtr pScrn, int width, int height)
pScrn->virtualX = width;
pScrn->virtualY = height;
+ /*
+ * Remove the old framebuffer & texture.
+ */
+ drmModeRmFB(ms->fd, ms->fb_id);
+ pipe_texture_reference(&ms->root_texture, NULL);
+
+
+ rootPixmap = pScreen->GetScreenPixmap(pScreen);
+ if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height, -1, -1, -1, NULL))
+ return FALSE;
+
+ /* takes one ref */
+ ms->root_texture = xorg_exa_get_texture(rootPixmap);
+
+ if (!ms->api->local_handle_from_texture(ms->api, ms->screen,
+ ms->root_texture,
+ &stride,
+ &handle))
+ FatalError("Could not get handle and stride from texture\n");
+
+ drmModeAddFB(ms->fd,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ pScrn->depth,
+ pScrn->bitsPerPixel,
+ stride,
+ handle,
+ &ms->fb_id);
+
/* HW dependent - FIXME */
pScrn->displayWidth = pScrn->virtualX;
- drmModeRmFB(ms->fd, ms->fb_id);
-
/* now create new frontbuffer */
- return CreateFrontBuffer(pScrn);
+ return CreateFrontBuffer(pScrn) && BindTextureToRoot(pScrn);
}
static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
@@ -206,6 +261,37 @@ static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
};
static Bool
+InitDRM(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ /* deal with server regeneration */
+ if (ms->fd < 0) {
+ char *BusID;
+
+ BusID = xalloc(64);
+ sprintf(BusID, "PCI:%d:%d:%d",
+ ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
+ ms->PciInfo->dev, ms->PciInfo->func
+ );
+
+ ms->fd = drmOpen(NULL, BusID);
+
+ if (ms->fd < 0)
+ return FALSE;
+ }
+
+ if (!ms->api) {
+ ms->api = drm_api_create();
+
+ if (!ms->api)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static Bool
PreInit(ScrnInfoPtr pScrn, int flags)
{
xf86CrtcConfigPtr xf86_config;
@@ -213,7 +299,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
rgb defaultWeight = { 0, 0, 0 };
EntityInfoPtr pEnt;
EntPtr msEnt = NULL;
- char *BusID;
int max_width, max_height;
if (pScrn->numEntities != 1)
@@ -262,16 +347,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
}
}
- BusID = xalloc(64);
- sprintf(BusID, "PCI:%d:%d:%d",
- ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
- ms->PciInfo->dev, ms->PciInfo->func
- );
-
- ms->api = drm_api_create();
- ms->fd = drmOpen(NULL, BusID);
-
- if (ms->fd < 0)
+ ms->fd = -1;
+ ms->api = NULL;
+ if (!InitDRM(pScrn))
return FALSE;
pScrn->monitor = pScrn->confScreen->monitor;
@@ -429,7 +507,6 @@ CreateScreenResources(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
PixmapPtr rootPixmap;
Bool ret;
- unsigned handle, stride;
ms->noEvict = TRUE;
@@ -437,29 +514,14 @@ CreateScreenResources(ScreenPtr pScreen)
ret = pScreen->CreateScreenResources(pScreen);
pScreen->CreateScreenResources = CreateScreenResources;
- rootPixmap = pScreen->GetScreenPixmap(pScreen);
-
- xorg_exa_set_displayed_usage(rootPixmap);
- xorg_exa_set_shared_usage(rootPixmap);
- if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
- FatalError("Couldn't adjust screen pixmap\n");
+ BindTextureToRoot(pScrn);
ms->noEvict = FALSE;
- handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride);
-
- drmModeAddFB(ms->fd,
- pScrn->virtualX,
- pScrn->virtualY,
- pScrn->depth,
- pScrn->bitsPerPixel,
- stride,
- handle,
- &ms->fb_id);
-
AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
#ifdef DRM_MODE_FEATURE_DIRTYFB
+ rootPixmap = pScreen->GetScreenPixmap(pScreen);
ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
pScreen, rootPixmap);
@@ -472,6 +534,8 @@ CreateScreenResources(ScreenPtr pScreen)
"Failed to create screen damage record\n");
return FALSE;
}
+#else
+ (void)rootPixmap;
#endif
return ret;
@@ -484,21 +548,8 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
modesettingPtr ms = modesettingPTR(pScrn);
VisualPtr visual;
- /* deal with server regeneration */
- if (ms->fd < 0) {
- char *BusID;
-
- BusID = xalloc(64);
- sprintf(BusID, "PCI:%d:%d:%d",
- ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
- ms->PciInfo->dev, ms->PciInfo->func
- );
-
- ms->fd = drmOpen(NULL, BusID);
-
- if (ms->fd < 0)
- return FALSE;
- }
+ if (!InitDRM(pScrn))
+ return FALSE;
if (!ms->screen) {
ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL);
@@ -610,8 +661,8 @@ AdjustFrame(int scrnIndex, int x, int y, int flags)
xf86CrtcPtr crtc = output->crtc;
if (crtc && crtc->enabled) {
- crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x,
- y);
+ crtc->funcs->set_mode_major(crtc, pScrn->currentMode,
+ RR_Rotate_0, x, y);
crtc->x = output->initial_x + x;
crtc->y = output->initial_y + y;
}
@@ -684,8 +735,11 @@ EnterVT(int scrnIndex, int flags)
SaveHWState(pScrn);
}
- if (!flags) /* signals startup as we'll do this in CreateScreenResources */
- CreateFrontBuffer(pScrn);
+ if (!CreateFrontBuffer(pScrn))
+ return FALSE;
+
+ if (!flags && !BindTextureToRoot(pScrn))
+ return FALSE;
if (!xf86SetDesiredModes(pScrn))
return FALSE;
@@ -725,10 +779,12 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen)
}
#endif
+ pipe_texture_reference(&ms->root_texture, NULL);
+
if (ms->exa)
xorg_exa_close(pScrn);
- if (ms->api->destroy)
+ if (ms->api && ms->api->destroy)
ms->api->destroy(ms->api);
ms->api = NULL;
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index af76d6690f5..b83d97bdb62 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -47,7 +47,7 @@
#define DEBUG_PRINT 0
#define DEBUG_SOLID 0
-#define DISABLE_ACCEL 0
+#define ACCEL_ENABLED TRUE
/*
* Helper functions
@@ -92,6 +92,8 @@ xorg_exa_common_done(struct exa_context *exa)
{
exa->copy.src = NULL;
exa->copy.dst = NULL;
+ exa->transform.has_src = FALSE;
+ exa->transform.has_mask = FALSE;
exa->has_solid_color = FALSE;
exa->num_bound_samplers = 0;
}
@@ -103,12 +105,21 @@ xorg_exa_common_done(struct exa_context *exa)
static void
ExaWaitMarker(ScreenPtr pScreen, int marker)
{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_context *exa = ms->exa;
+
+#if 0
+ xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
+#else
+ xorg_exa_finish(exa);
+#endif
}
static int
ExaMarkSync(ScreenPtr pScreen)
{
- return 1;
+ return 1;
}
static Bool
@@ -256,11 +267,6 @@ ExaDone(PixmapPtr pPixmap)
if (!priv)
return;
-#if 1
- xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
-#else
- xorg_exa_finish(exa);
-#endif
xorg_exa_common_done(exa);
}
@@ -307,11 +313,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
fg = 0xffff0000;
#endif
-#if DISABLE_ACCEL
- return FALSE;
-#else
- return xorg_solid_bind_state(exa, priv, fg);
-#endif
+ return ACCEL_ENABLED && xorg_solid_bind_state(exa, priv, fg);
}
static void
@@ -409,11 +411,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
exa->copy.src = src_priv;
exa->copy.dst = priv;
-#if DISABLE_ACCEL
- return FALSE;
-#else
- return TRUE;
-#endif
+ return ACCEL_ENABLED;
}
static void
@@ -448,7 +446,8 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
struct exa_pixmap_priv *priv;
#if DEBUG_PRINT
- debug_printf("ExaPrepareComposite\n");
+ debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n",
+ op, pSrcPicture, pMaskPicture, pDstPicture);
#endif
if (!exa->pipe)
XORG_FALLBACK("accle not enabled");
@@ -484,16 +483,12 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
XORG_FALLBACK("pMask format: %s", pf_name(priv->tex->format));
}
-#if DISABLE_ACCEL
- (void) exa;
- return FALSE;
-#else
- return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
+ return ACCEL_ENABLED &&
+ xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
pDstPicture,
pSrc ? exaGetPixmapDriverPrivate(pSrc) : NULL,
pMask ? exaGetPixmapDriverPrivate(pMask) : NULL,
exaGetPixmapDriverPrivate(pDst));
-#endif
}
static void
@@ -526,10 +521,7 @@ ExaCheckComposite(int op,
debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
op, pSrcPicture, pMaskPicture, pDstPicture, accelerated);
#endif
-#if DISABLE_ACCEL
- accelerated = FALSE;
-#endif
- return accelerated;
+ return ACCEL_ENABLED && accelerated;
}
static void *
@@ -693,9 +685,15 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
dst_surf = exa->scrn->get_tex_surface(
exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
- exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width[0]),
- min(height, texture->height[0]));
+ if (exa->pipe->surface_copy) {
+ exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
+ 0, 0, min(width, texture->width[0]),
+ min(height, texture->height[0]));
+ } else {
+ util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
+ 0, 0, min(width, texture->width[0]),
+ min(height, texture->height[0]));
+ }
exa->scrn->tex_surface_destroy(dst_surf);
exa->scrn->tex_surface_destroy(src_surf);
}
@@ -717,6 +715,50 @@ xorg_exa_get_texture(PixmapPtr pPixmap)
return tex;
}
+Bool
+xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex)
+{
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+
+ int mask = PIPE_TEXTURE_USAGE_PRIMARY | PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+
+ if (!priv)
+ return FALSE;
+
+ if (pPixmap->drawable.width != tex->width[0] ||
+ pPixmap->drawable.height != tex->height[0])
+ return FALSE;
+
+ pipe_texture_reference(&priv->tex, tex);
+ priv->tex_flags = tex->tex_usage & mask;
+
+ return TRUE;
+}
+
+struct pipe_texture *
+xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
+ int width, int height,
+ int depth, int bitsPerPixel)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_context *exa = ms->exa;
+ struct pipe_texture template;
+
+ memset(&template, 0, sizeof(template));
+ template.target = PIPE_TEXTURE_2D;
+ exa_get_pipe_format(depth, &template.format, &bitsPerPixel);
+ pf_get_block(template.format, &template.block);
+ template.width[0] = width;
+ template.height[0] = height;
+ template.depth[0] = 1;
+ template.last_level = 0;
+ template.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ template.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
+ template.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+
+ return exa->scrn->texture_create(exa->scrn, &template);
+}
+
void
xorg_exa_close(ScrnInfoPtr pScrn)
{
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h
index 292f964cec6..45f88d94048 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.h
+++ b/src/gallium/state_trackers/xorg/xorg_exa.h
@@ -24,6 +24,14 @@ struct exa_context
float solid_color[4];
boolean has_solid_color;
+ /* float[9] projective matrix bound to pictures */
+ struct {
+ float src[9];
+ float mask[9];
+ boolean has_src;
+ boolean has_mask;
+ } transform;
+
struct {
struct exa_pixmap_priv *src;
struct exa_pixmap_priv *dst;
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
index 8c9b674b4b6..041f4f96dc8 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
@@ -50,36 +50,20 @@ struct xorg_shaders {
struct cso_hash *fs_hash;
};
-static const char over_op[] =
- "SUB TEMP[3], CONST[0].wwww, TEMP[1].wwww\n"
- "MAD TEMP[3], TEMP[0], TEMP[3], TEMP[0]\n";
-
-
-static INLINE void
-create_preamble(struct ureg_program *ureg)
-{
-}
-
-
static INLINE void
src_in_mask(struct ureg_program *ureg,
struct ureg_dst dst,
struct ureg_src src,
- struct ureg_src mask)
+ struct ureg_src mask,
+ boolean component_alpha)
{
-#if 0
- /* MUL dst, src, mask.a */
- ureg_MUL(ureg, dst, src,
- ureg_scalar(mask, TGSI_SWIZZLE_W));
-#else
- /* MOV dst, src */
- /* MUL dst.a, src.a, mask.a */
- ureg_MOV(ureg, dst, src);
- ureg_MUL(ureg,
- ureg_writemask(dst, TGSI_WRITEMASK_W),
- ureg_scalar(src, TGSI_SWIZZLE_W),
- ureg_scalar(mask, TGSI_SWIZZLE_W));
-#endif
+ if (component_alpha) {
+ ureg_MUL(ureg, dst, src, mask);
+ }
+ else {
+ ureg_MUL(ureg, dst, src,
+ ureg_scalar(mask, TGSI_SWIZZLE_W));
+ }
}
static struct ureg_src
@@ -305,6 +289,7 @@ create_fs(struct pipe_context *pipe,
boolean is_solid = fs_traits & FS_SOLID_FILL;
boolean is_lingrad = fs_traits & FS_LINGRAD_FILL;
boolean is_radgrad = fs_traits & FS_RADGRAD_FILL;
+ boolean is_comp_alpha = fs_traits & FS_COMPONENT_ALPHA;
ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
if (ureg == NULL)
@@ -401,7 +386,7 @@ create_fs(struct pipe_context *pipe,
ureg_TEX(ureg, mask,
TGSI_TEXTURE_2D, mask_pos, mask_sampler);
/* src IN mask */
- src_in_mask(ureg, out, ureg_src(src), ureg_src(mask));
+ src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), is_comp_alpha);
ureg_release_temporary(ureg, mask);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
index 33c272070b8..c290d44e8fc 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
@@ -23,7 +23,8 @@ enum xorg_fs_traits {
FS_RADGRAD_FILL = 1 << 4,
FS_FILL = (FS_SOLID_FILL |
FS_LINGRAD_FILL |
- FS_RADGRAD_FILL)
+ FS_RADGRAD_FILL),
+ FS_COMPONENT_ALPHA = 1 << 5
};
struct xorg_shader {
diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c
index 26f45f8d645..bfeddc5e114 100644
--- a/src/gallium/state_trackers/xorg/xorg_output.c
+++ b/src/gallium/state_trackers/xorg/xorg_output.c
@@ -56,66 +56,29 @@
static char *connector_enum_list[] = {
"Unknown",
"VGA",
- "DVI-I",
- "DVI-D",
- "DVI-A",
+ "DVI",
+ "DVI",
+ "DVI",
"Composite",
"SVIDEO",
"LVDS",
- "Component",
- "9-pin DIN",
- "DisplayPort",
- "HDMI Type A",
- "HDMI Type B",
+ "CTV",
+ "DIN",
+ "DP",
+ "HDMI",
+ "HDMI",
};
static void
-dpms(xf86OutputPtr output, int mode)
-{
-}
-
-static void
-save(xf86OutputPtr output)
-{
-}
-
-static void
-restore(xf86OutputPtr output)
-{
-}
-
-static int
-mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
-{
- return MODE_OK;
-}
-
-static Bool
-mode_fixup(xf86OutputPtr output, DisplayModePtr mode,
- DisplayModePtr adjusted_mode)
-{
- return TRUE;
-}
-
-static void
-prepare(xf86OutputPtr output)
-{
- dpms(output, DPMSModeOff);
-}
-
-static void
-mode_set(xf86OutputPtr output, DisplayModePtr mode,
- DisplayModePtr adjusted_mode)
+create_resources(xf86OutputPtr output)
{
+#ifdef RANDR_12_INTERFACE
+#endif /* RANDR_12_INTERFACE */
}
static void
-commit(xf86OutputPtr output)
+dpms(xf86OutputPtr output, int mode)
{
- dpms(output, DPMSModeOn);
-
- if (output->scrn->pScreen != NULL)
- xf86_reload_cursors(output->scrn->pScreen);
}
static xf86OutputStatus
@@ -171,17 +134,10 @@ get_modes(xf86OutputPtr output)
return modes;
}
-static void
-destroy(xf86OutputPtr output)
-{
- drmModeFreeConnector(output->driver_private);
-}
-
-static void
-create_resources(xf86OutputPtr output)
+static int
+mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
{
-#ifdef RANDR_12_INTERFACE
-#endif /* RANDR_12_INTERFACE */
+ return MODE_OK;
}
#ifdef RANDR_12_INTERFACE
@@ -200,36 +156,26 @@ get_property(xf86OutputPtr output, Atom property)
}
#endif /* RANDR_13_INTERFACE */
-#ifdef RANDR_GET_CRTC_INTERFACE
-static xf86CrtcPtr
-get_crtc(xf86OutputPtr output)
+static void
+destroy(xf86OutputPtr output)
{
- return NULL;
+ drmModeFreeConnector(output->driver_private);
}
-#endif
static const xf86OutputFuncsRec output_funcs = {
.create_resources = create_resources,
- .dpms = dpms,
- .save = save,
- .restore = restore,
- .mode_valid = mode_valid,
- .mode_fixup = mode_fixup,
- .prepare = prepare,
- .mode_set = mode_set,
- .commit = commit,
- .detect = detect,
- .get_modes = get_modes,
#ifdef RANDR_12_INTERFACE
.set_property = set_property,
#endif
#ifdef RANDR_13_INTERFACE
.get_property = get_property,
#endif
+ .dpms = dpms,
+ .detect = detect,
+
+ .get_modes = get_modes,
+ .mode_valid = mode_valid,
.destroy = destroy,
-#ifdef RANDR_GET_CRTC_INTERFACE
- .get_crtc = get_crtc,
-#endif
};
void
@@ -240,7 +186,7 @@ output_init(ScrnInfoPtr pScrn)
drmModeResPtr res;
drmModeConnectorPtr drm_connector = NULL;
drmModeEncoderPtr drm_encoder = NULL;
- char *name;
+ char name[32];
int c, v, p;
res = drmModeGetResources(ms->fd);
@@ -273,7 +219,10 @@ output_init(ScrnInfoPtr pScrn)
(void)v;
#endif
- name = connector_enum_list[drm_connector->connector_type];
+ snprintf(name, 32, "%s%d",
+ connector_enum_list[drm_connector->connector_type],
+ drm_connector->connector_type_id);
+
output = xf86OutputCreate(pScrn, &output_funcs, name);
if (!output)
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 1eecf7d2b97..393f3fac3ed 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -7,14 +7,43 @@
#include "util/u_draw_quad.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_rect.h"
#include "pipe/p_inlines.h"
+#include <math.h>
+
enum AxisOrientation {
Y0_BOTTOM,
Y0_TOP
};
+#define floatsEqual(x, y) (fabs(x - y) <= 0.00001f * MIN2(fabs(x), fabs(y)))
+#define floatIsZero(x) (floatsEqual((x) + 1, 1))
+
+static INLINE boolean is_affine(float *matrix)
+{
+ return floatIsZero(matrix[2]) && floatIsZero(matrix[5])
+ && floatsEqual(matrix[8], 1);
+}
+static INLINE void map_point(float *mat, float x, float y,
+ float *out_x, float *out_y)
+{
+ if (!mat) {
+ *out_x = x;
+ *out_y = y;
+ return;
+ }
+
+ *out_x = mat[0]*x + mat[3]*y + mat[6];
+ *out_y = mat[1]*x + mat[4]*y + mat[7];
+ if (!is_affine(mat)) {
+ float w = 1/(mat[2]*x + mat[5]*y + mat[8]);
+ *out_x *= w;
+ *out_y *= w;
+ }
+}
+
static void
renderer_init_state(struct xorg_renderer *r)
{
@@ -59,23 +88,38 @@ static struct pipe_buffer *
setup_vertex_data1(struct xorg_renderer *r,
int srcX, int srcY, int dstX, int dstY,
int width, int height,
- struct pipe_texture *src)
+ struct pipe_texture *src, float *src_matrix)
{
- float s0, t0, s1, t1;
+ float s0, t0, s1, t1, stmp, ttmp;
s0 = srcX / src->width[0];
s1 = srcX + width / src->width[0];
t0 = srcY / src->height[0];
t1 = srcY + height / src->height[0];
- /* 1st vertex */
- setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0);
- /* 2nd vertex */
- setup_vertex1(r->vertices2[1], dstX + width, dstY, s1, t0);
- /* 3rd vertex */
- setup_vertex1(r->vertices2[2], dstX + width, dstY + height, s1, t1);
- /* 4th vertex */
- setup_vertex1(r->vertices2[3], dstX, dstY + height, s0, t1);
+ if (src_matrix) {
+ /* 1st vertex */
+ map_point(src_matrix, s0, t0, &stmp, &ttmp);
+ setup_vertex1(r->vertices2[0], dstX, dstY, stmp, ttmp);
+ /* 2nd vertex */
+ map_point(src_matrix, s1, t0, &stmp, &ttmp);
+ setup_vertex1(r->vertices2[1], dstX + width, dstY, stmp, ttmp);
+ /* 3rd vertex */
+ map_point(src_matrix, s1, t1, &stmp, &ttmp);
+ setup_vertex1(r->vertices2[2], dstX + width, dstY + height, stmp, ttmp);
+ /* 4th vertex */
+ map_point(src_matrix, s0, t1, &stmp, &ttmp);
+ setup_vertex1(r->vertices2[3], dstX, dstY + height, stmp, ttmp);
+ } else {
+ /* 1st vertex */
+ setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0);
+ /* 2nd vertex */
+ setup_vertex1(r->vertices2[1], dstX + width, dstY, s1, t0);
+ /* 3rd vertex */
+ setup_vertex1(r->vertices2[2], dstX + width, dstY + height, s1, t1);
+ /* 4th vertex */
+ setup_vertex1(r->vertices2[3], dstX, dstY + height, s0, t1);
+ }
return pipe_user_buffer_create(r->pipe->screen,
r->vertices2,
@@ -127,9 +171,11 @@ setup_vertex_data2(struct xorg_renderer *r,
int srcX, int srcY, int maskX, int maskY,
int dstX, int dstY, int width, int height,
struct pipe_texture *src,
- struct pipe_texture *mask)
+ struct pipe_texture *mask,
+ float *src_matrix, float *mask_matrix)
{
float st0[4], st1[4];
+ float pt0[2], pt1[2];
st0[0] = srcX / src->width[0];
st0[1] = srcY / src->height[0];
@@ -141,18 +187,49 @@ setup_vertex_data2(struct xorg_renderer *r,
st1[2] = maskX + width / mask->width[0];
st1[3] = maskY + height / mask->height[0];
- /* 1st vertex */
- setup_vertex2(r->vertices3[0], dstX, dstY,
- st0[0], st0[1], st1[0], st1[1]);
- /* 2nd vertex */
- setup_vertex2(r->vertices3[1], dstX + width, dstY,
- st0[2], st0[1], st1[2], st1[1]);
- /* 3rd vertex */
- setup_vertex2(r->vertices3[2], dstX + width, dstY + height,
- st0[2], st0[3], st1[2], st1[3]);
- /* 4th vertex */
- setup_vertex2(r->vertices3[3], dstX, dstY + height,
- st0[0], st0[3], st1[0], st1[3]);
+ if (src_matrix || mask_matrix) {
+ /* 1st vertex */
+ map_point(src_matrix, st0[0], st0[1],
+ pt0 + 0, pt0 + 1);
+ map_point(mask_matrix, st1[0], st1[1],
+ pt1 + 0, pt1 + 1);
+ setup_vertex2(r->vertices3[0], dstX, dstY,
+ pt0[0], pt0[1], pt1[0], pt1[1]);
+ /* 2nd vertex */
+ map_point(src_matrix, st0[2], st0[1],
+ pt0 + 0, pt0 + 1);
+ map_point(mask_matrix, st1[2], st1[1],
+ pt1 + 0, pt1 + 1);
+ setup_vertex2(r->vertices3[1], dstX + width, dstY,
+ pt0[0], pt0[1], pt1[0], pt1[1]);
+ /* 3rd vertex */
+ map_point(src_matrix, st0[2], st0[3],
+ pt0 + 0, pt0 + 1);
+ map_point(mask_matrix, st1[2], st1[3],
+ pt1 + 0, pt1 + 1);
+ setup_vertex2(r->vertices3[2], dstX + width, dstY + height,
+ pt0[0], pt0[1], pt1[0], pt1[1]);
+ /* 4th vertex */
+ map_point(src_matrix, st0[0], st0[3],
+ pt0 + 0, pt0 + 1);
+ map_point(mask_matrix, st1[0], st1[3],
+ pt1 + 0, pt1 + 1);
+ setup_vertex2(r->vertices3[3], dstX, dstY + height,
+ pt0[0], pt0[1], pt1[0], pt1[1]);
+ } else {
+ /* 1st vertex */
+ setup_vertex2(r->vertices3[0], dstX, dstY,
+ st0[0], st0[1], st1[0], st1[1]);
+ /* 2nd vertex */
+ setup_vertex2(r->vertices3[1], dstX + width, dstY,
+ st0[2], st0[1], st1[2], st1[1]);
+ /* 3rd vertex */
+ setup_vertex2(r->vertices3[2], dstX + width, dstY + height,
+ st0[2], st0[3], st1[2], st1[3]);
+ /* 4th vertex */
+ setup_vertex2(r->vertices3[3], dstX, dstY + height,
+ st0[0], st0[3], st1[0], st1[3]);
+ }
return pipe_user_buffer_create(r->pipe->screen,
r->vertices3,
@@ -206,13 +283,15 @@ void renderer_destroy(struct xorg_renderer *r)
if (fsbuf && fsbuf->buffer)
pipe_buffer_reference(&fsbuf->buffer, NULL);
+ if (r->shaders) {
+ xorg_shaders_destroy(r->shaders);
+ r->shaders = NULL;
+ }
+
if (r->cso) {
cso_release_all(r->cso);
cso_destroy_context(r->cso);
- }
-
- if (r->shaders) {
- xorg_shaders_destroy(r->shaders);
+ r->cso = NULL;
}
}
@@ -586,11 +665,19 @@ create_sampler_texture(struct xorg_renderer *r,
screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
struct pipe_surface *ps_tex = screen->get_tex_surface(
screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE );
- pipe->surface_copy(pipe,
- ps_tex, /* dest */
- 0, 0, /* destx/y */
- ps_read,
- 0, 0, src->width[0], src->height[0]);
+ if (pipe->surface_copy) {
+ pipe->surface_copy(pipe,
+ ps_tex, /* dest */
+ 0, 0, /* destx/y */
+ ps_read,
+ 0, 0, src->width[0], src->height[0]);
+ } else {
+ util_surface_copy(pipe, FALSE,
+ ps_tex, /* dest */
+ 0, 0, /* destx/y */
+ ps_read,
+ 0, 0, src->width[0], src->height[0]);
+ }
pipe_surface_reference(&ps_read, NULL);
pipe_surface_reference(&ps_tex, NULL);
}
@@ -681,6 +768,9 @@ void renderer_draw_solid_rect(struct xorg_renderer *r,
struct pipe_context *pipe = r->pipe;
struct pipe_buffer *buf = 0;
+ /*
+ debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
+ x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
/* 1st vertex */
setup_vertex0(r->vertices2[0], x0, y0, color);
/* 2nd vertex */
@@ -709,7 +799,8 @@ void renderer_draw_textures(struct xorg_renderer *r,
int *pos,
int width, int height,
struct pipe_texture **textures,
- int num_textures)
+ int num_textures,
+ float *src_matrix, float *mask_matrix)
{
struct pipe_context *pipe = r->pipe;
struct pipe_buffer *buf = 0;
@@ -720,7 +811,7 @@ void renderer_draw_textures(struct xorg_renderer *r,
pos[0], pos[1], /* src */
pos[4], pos[5], /* dst */
width, height,
- textures[0]);
+ textures[0], src_matrix);
break;
case 2:
buf = setup_vertex_data2(r,
@@ -728,7 +819,8 @@ void renderer_draw_textures(struct xorg_renderer *r,
pos[2], pos[3], /* mask */
pos[4], pos[5], /* dst */
width, height,
- textures[0], textures[1]);
+ textures[0], textures[1],
+ src_matrix, mask_matrix);
break;
default:
debug_assert(!"Unsupported number of textures");
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h
index b6296d5fd6b..3e37c9aa930 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.h
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.h
@@ -47,7 +47,9 @@ void renderer_draw_textures(struct xorg_renderer *r,
int *pos,
int width, int height,
struct pipe_texture **textures,
- int num_textures);
+ int num_textures,
+ float *src_matrix,
+ float *mask_matrix);
#endif
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index 24e1a4928ee..6130cf6621f 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -92,6 +92,7 @@ typedef struct _modesettingRec
struct pipe_context *ctx;
boolean d_depth_bits_last;
boolean ds_depth_bits_last;
+ struct pipe_texture *root_texture;
/* exa */
struct exa_context *exa;
@@ -121,6 +122,14 @@ xorg_exa_set_displayed_usage(PixmapPtr pPixmap);
int
xorg_exa_set_shared_usage(PixmapPtr pPixmap);
+Bool
+xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex);
+
+struct pipe_texture *
+xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
+ int width, int height,
+ int depth, int bpp);
+
void *
xorg_exa_init(ScrnInfoPtr pScrn);
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
index caab33de1cc..69f14e54f26 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
@@ -38,7 +38,7 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
{
struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB);
- if (getenv("RADEON_SOFTPIPE")) {
+ if (debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) {
return softpipe_create_screen((struct pipe_winsys*)winsys);
} else {
struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys);
@@ -51,7 +51,7 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
struct pipe_context* radeon_create_context(struct drm_api* api,
struct pipe_screen* screen)
{
- if (getenv("RADEON_SOFTPIPE")) {
+ if (debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) {
return radeon_create_softpipe(screen->winsys);
} else {
return r300_create_context(screen,
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
index 88a5c82b284..9a789ec1a45 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
@@ -37,6 +37,7 @@
#include "pipe/p_screen.h"
#include "trace/tr_drm.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "state_tracker/drm_api.h"
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
index d2d84f1a8f0..7ea5d1fb4e7 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
@@ -22,6 +22,17 @@
#include "radeon_r300.h"
+static void radeon_r300_set_flush_cb(struct r300_winsys *winsys,
+ void (*flush_cb)(void *),
+ void *data)
+{
+ struct radeon_winsys_priv* priv =
+ (struct radeon_winsys_priv*)winsys->radeon_winsys;
+
+ radeon_cs_space_set_flush(priv->cs, flush_cb,
+ data);
+}
+
static boolean radeon_r300_add_buffer(struct r300_winsys* winsys,
struct pipe_buffer* pbuffer,
uint32_t rd,
@@ -95,6 +106,13 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
}
}
+static void radeon_r300_reset_bos(struct r300_winsys *winsys)
+{
+ struct radeon_winsys_priv* priv =
+ (struct radeon_winsys_priv*)winsys->radeon_winsys;
+ radeon_cs_space_reset_bos(priv->cs);
+}
+
static void radeon_r300_end_cs(struct r300_winsys* winsys,
const char* file,
const char* function,
@@ -119,9 +137,6 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys)
radeon_cs_print(priv->cs, stderr);
}
- /* Clean out BOs. */
- radeon_cs_space_reset_bos(priv->cs);
-
/* Reset CS.
* Someday, when we care about performance, we should really find a way
* to rotate between two or three CS objects so that the GPU can be
@@ -149,6 +164,16 @@ static void do_ioctls(struct r300_winsys* winsys, int fd)
}
winsys->gb_pipes = target;
+ /* get Z pipes */
+ info.request = RADEON_INFO_NUM_Z_PIPES;
+ retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+ if (retval) {
+ fprintf(stderr, "%s: Failed to get GB pipe count, "
+ "error number %d\n", __FUNCTION__, retval);
+ exit(1);
+ }
+ winsys->z_pipes = target;
+
/* Then, get PCI ID */
info.request = RADEON_INFO_DEVICE_ID;
retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
@@ -203,6 +228,8 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys)
winsys->write_cs_reloc = radeon_r300_write_cs_reloc;
winsys->end_cs = radeon_r300_end_cs;
winsys->flush_cs = radeon_r300_flush_cs;
+ winsys->reset_bos = radeon_r300_reset_bos;
+ winsys->set_flush_cb = radeon_r300_set_flush_cb;
memcpy(winsys, old_winsys, sizeof(struct radeon_winsys));
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index cd4aede74e4..c63116bab77 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -540,6 +540,16 @@ DestroyContext(Display * dpy, GLXContext gc)
imported = gc->imported;
gc->xid = None;
+ if (gc->currentDpy) {
+ /* This context is bound to some thread. According to the man page,
+ * we should not actually delete the context until it's unbound.
+ * Note that we set gc->xid = None above. In MakeContextCurrent()
+ * we check for that and delete the context there.
+ */
+ __glXUnlock();
+ return;
+ }
+
#ifdef GLX_DIRECT_RENDERING
/* Destroy the direct rendering context */
if (gc->driContext) {
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index a9bfe905680..ad457645962 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -125,7 +125,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->UnmapTexture = NULL;
driver->TextureMemCpy = _mesa_memcpy;
driver->IsTextureResident = NULL;
- driver->PrioritizeTexture = NULL;
driver->ActiveTexture = NULL;
driver->UpdateTexturePalette = NULL;
@@ -183,7 +182,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->TexGen = NULL;
driver->TexEnv = NULL;
driver->TexParameter = NULL;
- driver->TextureMatrix = NULL;
driver->Viewport = NULL;
/* vertex arrays */
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 21458a7c737..b38f22e130e 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1346,8 +1346,6 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers)
/* create vertex array buffer */
_mesa_GenBuffersARB(1, &clear->VBO);
_mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
- NULL, GL_DYNAMIC_DRAW_ARB);
/* setup vertex arrays */
_mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
@@ -1423,7 +1421,8 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers)
}
/* upload new vertex data */
- _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
+ _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
+ GL_DYNAMIC_DRAW_ARB);
}
/* draw quad */
@@ -2118,7 +2117,6 @@ _mesa_meta_check_generate_mipmap_fallback(GLcontext *ctx, GLenum target,
_mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- printf("Can't render\n");
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
index 18dbeba24a8..1ce9315530c 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -60,18 +60,36 @@ SHARED_INCLUDES = \
##### TARGETS #####
-default: symlinks depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
+default: symlinks subdirs depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
-$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
+$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) Makefile \
+ $(TOP)/src/mesa/drivers/dri/Makefile.template
$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
+ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) \
+ $(DRI_LIB_DEPS)
$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
$(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)
+# If the Makefile defined SUBDIRS, run make in each
+.PHONY: subdirs
+subdirs:
+ @if test -n "$(SUBDIRS)" ; then \
+ for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE)) || exit 1; \
+ fi \
+ done \
+ fi
+
+
+.PHONY: symlinks
+symlinks:
+
+
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
@ echo "running $(MKDEP)"
@ rm -f depend
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.h b/src/mesa/drivers/dri/common/drirenderbuffer.h
index cf55286b30f..5ae28cb53a0 100644
--- a/src/mesa/drivers/dri/common/drirenderbuffer.h
+++ b/src/mesa/drivers/dri/common/drirenderbuffer.h
@@ -56,7 +56,7 @@ typedef struct {
* A handy flag to know if this is the back color buffer.
*
* \note
- * This is currently only used by s3v and tdfx.
+ * This is currently only used by tdfx.
*/
GLboolean backBuffer;
} driRenderbuffer;
diff --git a/src/mesa/drivers/dri/fb/Makefile b/src/mesa/drivers/dri/fb/Makefile
index 309f50b95f8..cf9b3a85563 100644
--- a/src/mesa/drivers/dri/fb/Makefile
+++ b/src/mesa/drivers/dri/fb/Makefile
@@ -25,5 +25,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
-
diff --git a/src/mesa/drivers/dri/ffb/Makefile b/src/mesa/drivers/dri/ffb/Makefile
index cb73238c030..e9da8f9066e 100644
--- a/src/mesa/drivers/dri/ffb/Makefile
+++ b/src/mesa/drivers/dri/ffb/Makefile
@@ -33,4 +33,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/gamma/Makefile b/src/mesa/drivers/dri/gamma/Makefile
index 250d3ac0891..09df1578fc7 100644
--- a/src/mesa/drivers/dri/gamma/Makefile
+++ b/src/mesa/drivers/dri/gamma/Makefile
@@ -32,4 +32,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/i810/Makefile b/src/mesa/drivers/dri/i810/Makefile
index a7825b49b44..3874faee518 100644
--- a/src/mesa/drivers/dri/i810/Makefile
+++ b/src/mesa/drivers/dri/i810/Makefile
@@ -29,4 +29,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile
index 393312e7328..37f15aa7671 100644
--- a/src/mesa/drivers/dri/i915/Makefile
+++ b/src/mesa/drivers/dri/i915/Makefile
@@ -72,4 +72,3 @@ intel_decode.o: ../intel/intel_decode.c
intel_tex_layout.o: ../intel/intel_tex_layout.c
-symlinks:
diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c
index 0641e6df9d7..c3cbba8404d 100644
--- a/src/mesa/drivers/dri/i915/intel_tris.c
+++ b/src/mesa/drivers/dri/i915/intel_tris.c
@@ -1196,12 +1196,16 @@ getFallbackString(GLuint bit)
+/**
+ * Enable/disable a fallback flag.
+ * \param bit one of INTEL_FALLBACK_x flags.
+ */
void
-intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode)
+intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode)
{
GLcontext *ctx = &intel->ctx;
TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint oldfallback = intel->Fallback;
+ const GLbitfield oldfallback = intel->Fallback;
if (mode) {
intel->Fallback |= bit;
diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile
index 57dcc915869..7a55333e896 100644
--- a/src/mesa/drivers/dri/i965/Makefile
+++ b/src/mesa/drivers/dri/i965/Makefile
@@ -100,6 +100,5 @@ DRI_LIB_DEPS += -ldrm_intel
include ../Makefile.template
-symlinks:
intel_decode.o: ../intel/intel_decode.c
intel_tex_layout.o: ../intel/intel_tex_layout.c
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index fa3e32c7ff1..01b6a4a168c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -115,7 +115,9 @@
* Handles blending and (presumably) depth and stencil testing.
*/
-#define BRW_FALLBACK_TEXTURE 0x1
+
+#define BRW_FALLBACK_DRAW (INTEL_FALLBACK_DRIVER << 0)
+
#define BRW_MAX_CURBE (32*16)
struct brw_context;
@@ -454,7 +456,6 @@ struct brw_context
GLuint primitive;
GLboolean emit_state_always;
- GLboolean tmp_fallback;
GLboolean no_batch_wrap;
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 765ae5a2fe5..375afadcbea 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -375,9 +375,10 @@ static void brw_prepare_vertices(struct brw_context *brw)
* isn't an issue at this point.
*/
if (brw->vb.nr_enabled >= BRW_VEP_MAX) {
- intel->Fallback = 1;
+ FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE);
return;
}
+ FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE);
for (i = 0; i < brw->vb.nr_enabled; i++) {
struct brw_vertex_element *input = brw->vb.enabled[i];
@@ -427,9 +428,10 @@ static void brw_prepare_vertices(struct brw_context *brw)
/* Position array not properly enabled:
*/
if (input->glarray->StrideB == 0) {
- intel->Fallback = 1;
+ FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE);
return;
}
+ FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE);
interleave = input->glarray->StrideB;
ptr = input->glarray->Ptr;
@@ -539,12 +541,12 @@ static void brw_emit_vertices(struct brw_context *brw)
if (input->stride) {
OUT_RELOC(input->bo,
I915_GEM_DOMAIN_VERTEX, 0,
- input->offset + input->stride * input->count);
+ input->offset + input->stride * input->count - 1);
} else {
assert(input->count == 1);
OUT_RELOC(input->bo,
I915_GEM_DOMAIN_VERTEX, 0,
- input->offset + input->element_size);
+ input->offset + input->element_size - 1);
}
} else
OUT_BATCH(input->stride ? input->count : 0);
@@ -726,7 +728,7 @@ static void brw_emit_index_buffer(struct brw_context *brw)
brw->ib.offset);
OUT_RELOC(brw->ib.bo,
I915_GEM_DOMAIN_VERTEX, 0,
- brw->ib.offset + brw->ib.size);
+ brw->ib.offset + brw->ib.size - 1);
OUT_BATCH( 0 );
ADVANCE_BATCH();
}
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index 9a619fbd5cf..d4899aab7fa 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -157,7 +157,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
#define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
#define OUT_RELOC(buf, read_domains, write_domain, delta) do { \
- assert((unsigned) (delta) <= buf->size); \
+ assert((unsigned) (delta) < buf->size); \
intel_batchbuffer_emit_reloc(intel->batch, buf, \
read_domains, write_domain, delta); \
} while (0)
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 934f7aa1873..15f4bc6f69d 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -830,7 +830,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
_vbo_DestroyContext(&intel->ctx);
_swrast_DestroyContext(&intel->ctx);
- intel->Fallback = 0; /* don't call _swrast_Flush later */
+ intel->Fallback = 0x0; /* don't call _swrast_Flush later */
intel_batchbuffer_free(intel->batch);
intel->batch = NULL;
@@ -935,10 +935,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
__DRIdrawablePrivate * driReadPriv)
{
__DRIscreenPrivate *psp = driDrawPriv->driScreenPriv;
+ struct intel_context *intel;
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if (driContextPriv)
+ intel = (struct intel_context *) driContextPriv->driverPrivate;
+ else
+ intel = NULL;
+
+ /* According to the glXMakeCurrent() man page: "Pending commands to
+ * the previous context, if any, are flushed before it is released."
+ * But only flush if we're actually changing contexts.
+ */
+ if (intel_context(curCtx) && intel_context(curCtx) != intel) {
+ _mesa_flush(curCtx);
+ }
if (driContextPriv) {
- struct intel_context *intel =
- (struct intel_context *) driContextPriv->driverPrivate;
struct intel_framebuffer *intel_fb =
(struct intel_framebuffer *) driDrawPriv->driverPrivate;
GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index b104096912c..2778cc0136d 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -61,6 +61,10 @@ typedef void (*intel_line_func) (struct intel_context *, intelVertex *,
intelVertex *);
typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
+/**
+ * Bits for intel->Fallback field
+ */
+/*@{*/
#define INTEL_FALLBACK_DRAW_BUFFER 0x1
#define INTEL_FALLBACK_READ_BUFFER 0x2
#define INTEL_FALLBACK_DEPTH_BUFFER 0x4
@@ -68,8 +72,10 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
#define INTEL_FALLBACK_USER 0x10
#define INTEL_FALLBACK_RENDERMODE 0x20
#define INTEL_FALLBACK_TEXTURE 0x40
+#define INTEL_FALLBACK_DRIVER 0x1000 /**< first for drivers */
+/*@}*/
-extern void intelFallback(struct intel_context *intel, GLuint bit,
+extern void intelFallback(struct intel_context *intel, GLbitfield bit,
GLboolean mode);
#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
@@ -171,7 +177,7 @@ struct intel_context
struct dri_metaops meta;
GLint refcount;
- GLuint Fallback;
+ GLbitfield Fallback; /**< mask of INTEL_FALLBACK_x bits */
GLuint NewGLState;
dri_bufmgr *bufmgr;
diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c
index 1286fe929bc..0d7889d3c25 100644
--- a/src/mesa/drivers/dri/intel/intel_syncobj.c
+++ b/src/mesa/drivers/dri/intel/intel_syncobj.c
@@ -114,7 +114,7 @@ static void intel_check_sync(GLcontext *ctx, struct gl_sync_object *s)
{
struct intel_sync_object *sync = (struct intel_sync_object *)s;
- if (sync->bo && drm_intel_bo_busy(sync->bo)) {
+ if (sync->bo && !drm_intel_bo_busy(sync->bo)) {
drm_intel_bo_unreference(sync->bo);
sync->bo = NULL;
s->StatusFlag = 1;
diff --git a/src/mesa/drivers/dri/mach64/Makefile b/src/mesa/drivers/dri/mach64/Makefile
index 7246d51f5d7..a8f463e9fd0 100644
--- a/src/mesa/drivers/dri/mach64/Makefile
+++ b/src/mesa/drivers/dri/mach64/Makefile
@@ -30,4 +30,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/mach64/mach64_tex.c b/src/mesa/drivers/dri/mach64/mach64_tex.c
index 225d23179e1..5a22c93bd2b 100644
--- a/src/mesa/drivers/dri/mach64/mach64_tex.c
+++ b/src/mesa/drivers/dri/mach64/mach64_tex.c
@@ -567,7 +567,6 @@ void mach64InitTextureFuncs( struct dd_function_table *functions )
functions->UpdateTexturePalette = NULL;
functions->ActiveTexture = NULL;
- functions->PrioritizeTexture = NULL;
driInitTextureFormats();
}
diff --git a/src/mesa/drivers/dri/mga/Makefile b/src/mesa/drivers/dri/mga/Makefile
index a871064c629..0cc329fb22d 100644
--- a/src/mesa/drivers/dri/mga/Makefile
+++ b/src/mesa/drivers/dri/mga/Makefile
@@ -31,4 +31,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/r128/Makefile b/src/mesa/drivers/dri/r128/Makefile
index 796dfbc5167..52c5a38a705 100644
--- a/src/mesa/drivers/dri/r128/Makefile
+++ b/src/mesa/drivers/dri/r128/Makefile
@@ -29,4 +29,3 @@ ASM_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile
index fbce70c37bc..776f1e3f3f7 100644
--- a/src/mesa/drivers/dri/r200/Makefile
+++ b/src/mesa/drivers/dri/r200/Makefile
@@ -66,4 +66,3 @@ include ../Makefile.template
#INCLUDES += -I../radeon/server
-symlinks:
diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile
index c64f940623f..cb0f715fa07 100644
--- a/src/mesa/drivers/dri/r300/Makefile
+++ b/src/mesa/drivers/dri/r300/Makefile
@@ -69,16 +69,12 @@ DRIVER_DEFINES = -DRADEON_R300
DRI_LIB_DEPS += $(RADEON_LDFLAGS)
-PIPE_DRIVERS = compiler/libr300compiler.a
+SUBDIRS = compiler
-##### TARGETS #####
+EXTRA_MODULES = compiler/libr300compiler.a
-include ../Makefile.template
-symlinks:
+##### TARGETS #####
-# Mark the archive phony so that we always check for recompilation
-.PHONY : compiler/libr300compiler.a
+include ../Makefile.template
-compiler/libr300compiler.a:
- cd compiler && $(MAKE)
diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c
index f030451b282..65cabccdc1e 100644
--- a/src/mesa/drivers/dri/r300/r300_texstate.c
+++ b/src/mesa/drivers/dri/r300/r300_texstate.c
@@ -225,10 +225,10 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
if (t->image_override && t->bo)
return;
- t->pp_txsize = (((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
- | ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)
- | ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT)
- | ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT));
+ t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT)))
+ | ((R300_TX_HEIGHTMASK_MASK & ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)))
+ | ((R300_TX_DEPTHMASK_MASK & ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT)))
+ | ((R300_TX_MAX_MIP_LEVEL_MASK & ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT))));
t->tile_bits = 0;
@@ -248,8 +248,12 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
if (firstImage->Width > 2048)
t->pp_txpitch |= R500_TXWIDTH_BIT11;
+ else
+ t->pp_txpitch &= ~R500_TXWIDTH_BIT11;
if (firstImage->Height > 2048)
t->pp_txpitch |= R500_TXHEIGHT_BIT11;
+ else
+ t->pp_txpitch &= ~R500_TXHEIGHT_BIT11;
}
}
@@ -479,16 +483,20 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
break;
}
pitch_val--;
- t->pp_txsize = ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT) |
- ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT);
+ t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT)))
+ | ((R300_TX_HEIGHTMASK_MASK & ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT))));
t->pp_txsize |= R300_TX_SIZE_TXPITCH_EN;
t->pp_txpitch |= pitch_val;
if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
if (rb->base.Width > 2048)
t->pp_txpitch |= R500_TXWIDTH_BIT11;
+ else
+ t->pp_txpitch &= ~R500_TXWIDTH_BIT11;
if (rb->base.Height > 2048)
t->pp_txpitch |= R500_TXHEIGHT_BIT11;
+ else
+ t->pp_txpitch &= ~R500_TXHEIGHT_BIT11;
}
t->validated = GL_TRUE;
_mesa_unlock_texture(radeon->glCtx, texObj);
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index 43629d643bc..c2f96af2c12 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -62,12 +62,6 @@ static int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_progra
}
}
- if (vp->code.constants.Count * 4 > VSF_MAX_FRAGMENT_LENGTH) {
- /* Should have checked this earlier... */
- fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__);
- _mesa_exit(-1);
- }
-
for(i = 0; i < vp->code.constants.Count; ++i) {
const float * src = 0;
const struct rc_constant * constant = &vp->code.constants.Constants[i];
@@ -281,6 +275,11 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
}
r3xx_compile_vertex_program(&compiler);
+
+ if (vp->code.constants.Count > ctx->Const.VertexProgram.MaxParameters) {
+ rc_error(&compiler.Base, "Program exceeds constant buffer size limit\n");
+ }
+
vp->error = compiler.Base.Error;
vp->Base->Base.InputsRead = vp->code.InputsRead;
@@ -334,7 +333,6 @@ struct r300_vertex_program * r300SelectAndTranslateVertexShader(GLcontext *ctx)
#define bump_vpu_count(ptr, new_count) do { \
drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr)); \
int _nc=(new_count)/4; \
- assert(_nc < 256); \
if(_nc>_p->vpu.count)_p->vpu.count=_nc; \
} while(0)
diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile
index 7d5a7b1ab6f..9b7c42042e6 100644
--- a/src/mesa/drivers/dri/r600/Makefile
+++ b/src/mesa/drivers/dri/r600/Makefile
@@ -76,4 +76,3 @@ DRI_LIB_DEPS += $(RADEON_LDFLAGS)
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/r600/r600_cmdbuf.c b/src/mesa/drivers/dri/r600/r600_cmdbuf.c
index 3cfe03a45f7..d27a3245a39 100644
--- a/src/mesa/drivers/dri/r600/r600_cmdbuf.c
+++ b/src/mesa/drivers/dri/r600/r600_cmdbuf.c
@@ -254,7 +254,7 @@ static int r600_cs_process_relocs(struct radeon_cs *cs,
relocs = (struct r600_cs_reloc_legacy *)cs->relocs;
restart:
for (i = 0; i < cs->crelocs; i++) {
- uint32_t soffset, eoffset, asicoffset;
+ uint32_t soffset, eoffset;
r = radeon_bo_legacy_validate(relocs[i].base.bo,
&soffset, &eoffset);
@@ -262,24 +262,12 @@ restart:
goto restart;
}
if (r) {
- fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
+ fprintf(stderr, "invalid bo(%p) [0x%08X, 0x%08X]\n",
relocs[i].base.bo, soffset, eoffset);
return r;
}
- asicoffset = soffset;
for (j = 0; j < relocs[i].cindices; j++) {
- if (asicoffset >= eoffset) {
- /* radeon_bo_debug(relocs[i].base.bo, 12); */
- fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
- relocs[i].base.bo, soffset, eoffset);
- fprintf(stderr, "above end: %p 0x%08X 0x%08X\n",
- relocs[i].base.bo,
- cs->packets[relocs[i].indices[j]],
- eoffset);
- exit(0);
- return -EINVAL;
- }
/* pkt3 nop header in ib chunk */
cs->packets[relocs[i].reloc_indices[j]] = 0xC0001000;
/* reloc index in ib chunk */
@@ -287,7 +275,7 @@ restart:
}
/* asic offset in reloc chunk */ /* see alex drm r600_nomm_relocate */
- reloc_chunk[offset_dw] = asicoffset;
+ reloc_chunk[offset_dw] = soffset;
reloc_chunk[offset_dw + 3] = 0;
offset_dw += 4;
diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c
index 969144ba123..ba0d450cbb2 100644
--- a/src/mesa/drivers/dri/r600/r600_context.c
+++ b/src/mesa/drivers/dri/r600/r600_context.c
@@ -131,6 +131,7 @@ const struct dri_extension card_extensions[] = {
{"GL_EXT_texture_lod_bias", NULL},
{"GL_EXT_texture_mirror_clamp", NULL},
{"GL_EXT_texture_rectangle", NULL},
+ {"GL_EXT_vertex_array_bgra", NULL},
{"GL_EXT_texture_sRGB", NULL},
{"GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions},
{"GL_ATI_texture_env_combine3", NULL},
diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c
index 7d7e77d355b..ba1371bf95a 100644
--- a/src/mesa/drivers/dri/r600/r600_texstate.c
+++ b/src/mesa/drivers/dri/r600/r600_texstate.c
@@ -764,7 +764,9 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
struct gl_texture_object *tObj =
_mesa_lookup_texture(rmesa->radeon.glCtx, texname);
radeonTexObjPtr t = radeon_tex_obj(tObj);
- uint32_t pitch_val, size;
+ int firstlevel = t->mt ? t->mt->firstLevel : 0;
+ const struct gl_texture_image *firstImage;
+ uint32_t pitch_val, size, row_align, bpp;
if (!tObj)
return;
@@ -774,7 +776,13 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
if (!offset)
return;
- size = pitch;//h * w * (depth / 8);
+ bpp = depth / 8;
+ if (bpp == 3)
+ bpp = 4;
+
+ firstImage = t->base.Image[0][firstlevel];
+ row_align = rmesa->radeon.texture_row_align - 1;
+ size = ((firstImage->Width * bpp + row_align) & ~row_align) * firstImage->Height;
if (t->bo) {
radeon_bo_unref(t->bo);
t->bo = NULL;
diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c
index ed597c027b5..917318c02ab 100644
--- a/src/mesa/drivers/dri/r600/r700_assembler.c
+++ b/src/mesa/drivers/dri/r600/r700_assembler.c
@@ -355,6 +355,7 @@ unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm)
return 2;
case SQ_OP2_INST_MOV:
+ case SQ_OP2_INST_MOVA_FLOOR:
case SQ_OP2_INST_FRACT:
case SQ_OP2_INST_FLOOR:
case SQ_OP2_INST_EXP_IEEE:
@@ -1307,8 +1308,10 @@ GLboolean tex_src(r700_AssemblerBase *pAsm)
case PROGRAM_INPUT:
switch (pILInst->SrcReg[0].Index)
{
+ case FRAG_ATTRIB_WPOS:
case FRAG_ATTRIB_COL0:
case FRAG_ATTRIB_COL1:
+ case FRAG_ATTRIB_FOGC:
case FRAG_ATTRIB_TEX0:
case FRAG_ATTRIB_TEX1:
case FRAG_ATTRIB_TEX2:
@@ -1321,7 +1324,16 @@ GLboolean tex_src(r700_AssemblerBase *pAsm)
pAsm->S[0].src.reg =
pAsm->uiFP_AttributeMap[pILInst->SrcReg[0].Index];
pAsm->S[0].src.rtype = SRC_REG_INPUT;
- break;
+ break;
+ case FRAG_ATTRIB_FACE:
+ fprintf(stderr, "FRAG_ATTRIB_FACE unsupported\n");
+ break;
+ case FRAG_ATTRIB_PNTC:
+ fprintf(stderr, "FRAG_ATTRIB_PNTC unsupported\n");
+ break;
+ case FRAG_ATTRIB_VAR0:
+ fprintf(stderr, "FRAG_ATTRIB_VAR0 unsupported\n");
+ break;
}
break;
}
@@ -2180,7 +2192,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm)
}
//other bits
- alu_instruction_ptr->m_Word0.f.index_mode = SQ_INDEX_LOOP;
+ alu_instruction_ptr->m_Word0.f.index_mode = SQ_INDEX_AR_X;
if( (is_single_scalar_operation == GL_TRUE)
|| (GL_TRUE == bSplitInst) )
@@ -2514,6 +2526,35 @@ GLboolean assemble_ADD(r700_AssemblerBase *pAsm)
return GL_TRUE;
}
+GLboolean assemble_ARL(r700_AssemblerBase *pAsm)
+{ /* TODO: ar values dont' persist between clauses */
+ if( GL_FALSE == checkop1(pAsm) )
+ {
+ return GL_FALSE;
+ }
+
+ pAsm->D.dst.opcode = SQ_OP2_INST_MOVA_FLOOR;
+ setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE);
+ pAsm->D.dst.rtype = DST_REG_TEMPORARY;
+ pAsm->D.dst.reg = 0;
+ pAsm->D.dst.writex = 0;
+ pAsm->D.dst.writey = 0;
+ pAsm->D.dst.writez = 0;
+ pAsm->D.dst.writew = 0;
+
+ if( GL_FALSE == assemble_src(pAsm, 0, -1) )
+ {
+ return GL_FALSE;
+ }
+
+ if( GL_FALSE == next_ins(pAsm) )
+ {
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
GLboolean assemble_BAD(char *opcode_str)
{
radeon_error("Not yet implemented instruction (%s)\n", opcode_str);
@@ -3928,8 +3969,7 @@ GLboolean AssembleInstr(GLuint uiNumberInsts,
break;
case OPCODE_ARL:
- radeon_error("Not yet implemented instruction OPCODE_ARL \n");
- //if ( GL_FALSE == assemble_BAD("ARL") )
+ if ( GL_FALSE == assemble_ARL(pR700AsmCode) )
return GL_FALSE;
break;
case OPCODE_ARR:
@@ -4274,6 +4314,7 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode,
GLbitfield OutputsWritten)
{
unsigned int unBit;
+ GLuint export_count = 0;
if(pR700AsmCode->depth_export_register_number >= 0)
{
@@ -4295,6 +4336,7 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode,
{
return GL_FALSE;
}
+ export_count++;
}
unBit = 1 << FRAG_RESULT_DEPTH;
if(OutputsWritten & unBit)
@@ -4308,8 +4350,15 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode,
{
return GL_FALSE;
}
+ export_count++;
}
-
+ /* Need to export something, otherwise we'll hang
+ * results are undefined anyway */
+ if(export_count == 0)
+ {
+ Process_Export(pR700AsmCode, SQ_EXPORT_PIXEL, 0, 1, 0, GL_FALSE);
+ }
+
if(pR700AsmCode->cf_last_export_ptr != NULL)
{
pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst = SQ_CF_INST_EXPORT_DONE;
diff --git a/src/mesa/drivers/dri/r600/r700_assembler.h b/src/mesa/drivers/dri/r600/r700_assembler.h
index 0d4283e4bad..8cbca066e95 100644
--- a/src/mesa/drivers/dri/r600/r700_assembler.h
+++ b/src/mesa/drivers/dri/r600/r700_assembler.h
@@ -470,6 +470,7 @@ GLboolean next_ins(r700_AssemblerBase *pAsm);
GLboolean assemble_math_function(r700_AssemblerBase* pAsm, BITS opcode);
GLboolean assemble_ABS(r700_AssemblerBase *pAsm);
GLboolean assemble_ADD(r700_AssemblerBase *pAsm);
+GLboolean assemble_ARL(r700_AssemblerBase *pAsm);
GLboolean assemble_BAD(char *opcode_str);
GLboolean assemble_CMP(r700_AssemblerBase *pAsm);
GLboolean assemble_COS(r700_AssemblerBase *pAsm);
diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c
index 62a1ea1a22a..0f549ead9cc 100644
--- a/src/mesa/drivers/dri/r600/r700_fragprog.c
+++ b/src/mesa/drivers/dri/r600/r700_fragprog.c
@@ -135,15 +135,19 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
{
GLuint i, j;
GLint * puiTEMPwrites;
+ GLint * puiTEMPreads;
struct prog_instruction * pILInst;
InstDeps *pInstDeps;
struct prog_instruction * texcoord_DepInst;
GLint nDepInstID;
puiTEMPwrites = (GLint*) MALLOC(sizeof(GLuint)*mesa_fp->Base.NumTemporaries);
+ puiTEMPreads = (GLint*) MALLOC(sizeof(GLuint)*mesa_fp->Base.NumTemporaries);
+
for(i=0; i<mesa_fp->Base.NumTemporaries; i++)
{
puiTEMPwrites[i] = -1;
+ puiTEMPreads[i] = -1;
}
pInstDeps = (InstDeps*)MALLOC(sizeof(InstDeps)*mesa_fp->Base.NumInstructions);
@@ -167,6 +171,11 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
{
//Set dep.
pInstDeps[i].nSrcDeps[j] = puiTEMPwrites[pILInst->SrcReg[j].Index];
+ //Set first read
+ if(puiTEMPreads[pILInst->SrcReg[j].Index] < 0 )
+ {
+ puiTEMPreads[pILInst->SrcReg[j].Index] = i;
+ }
}
else
{
@@ -177,8 +186,6 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
fp->r700AsmCode.pInstDeps = pInstDeps;
- FREE(puiTEMPwrites);
-
//Find dep for tex inst
for(i=0; i<mesa_fp->Base.NumInstructions; i++)
{
@@ -203,9 +210,25 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp,
{ //... other deps?
}
}
+ // make sure that we dont overwrite src used earlier
+ nDepInstID = puiTEMPreads[pILInst->DstReg.Index];
+ if(nDepInstID < i)
+ {
+ pInstDeps[i].nDstDep = puiTEMPreads[pILInst->DstReg.Index];
+ texcoord_DepInst = &(mesa_fp->Base.Instructions[nDepInstID]);
+ if(GL_TRUE == IsAlu(texcoord_DepInst->Opcode) )
+ {
+ pInstDeps[nDepInstID].nDstDep = i;
+ }
+
+ }
+
}
}
+ FREE(puiTEMPwrites);
+ FREE(puiTEMPreads);
+
return GL_TRUE;
}
@@ -251,7 +274,15 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
number_of_colors_exported--;
}
- fp->r700Shader.exportMode = number_of_colors_exported << 1 | z_enabled;
+ /* illegal to set this to 0 */
+ if(number_of_colors_exported || z_enabled)
+ {
+ fp->r700Shader.exportMode = number_of_colors_exported << 1 | z_enabled;
+ }
+ else
+ {
+ fp->r700Shader.exportMode = (1 << 1);
+ }
fp->translated = GL_TRUE;
diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile
index b1efc72872f..ae2e695bfcc 100644
--- a/src/mesa/drivers/dri/radeon/Makefile
+++ b/src/mesa/drivers/dri/radeon/Makefile
@@ -55,4 +55,3 @@ X86_SOURCES =
include ../Makefile.template
-symlinks:
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
index 3e7547d2f9d..ce60a2f7eae 100644
--- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
@@ -710,6 +710,10 @@ int radeon_bo_legacy_validate(struct radeon_bo *bo,
bo, bo->size, bo_legacy->map_count);
return -EINVAL;
}
+ if(bo->size == 0) {
+ fprintf(stderr, "bo(%p) has size 0.\n", bo);
+ return -EINVAL;
+ }
if (bo_legacy->static_bo || bo_legacy->validated) {
*soffset = bo_legacy->offset;
*eoffset = bo_legacy->offset + bo->size;
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 7ac53ec0ca3..0ae906a6cea 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -445,7 +445,6 @@ restart:
goto restart;
}
- rrb->pitch = texImage->Width * rrb->cpp;
rrb->base.InternalFormat = rrb->base._ActualFormat;
rrb->base.Width = texImage->Width;
rrb->base.Height = texImage->Height;
@@ -555,8 +554,10 @@ radeon_render_texture(GLcontext * ctx,
imageOffset += offsets[att->Zoffset];
}
- /* store that offset in the region */
+ /* store that offset in the region, along with the correct pitch for
+ * the image we are rendering to */
rrb->draw_offset = imageOffset;
+ rrb->pitch = radeon_image->mt->levels[att->TextureLevel].rowstride;
/* update drawing region, etc */
radeon_draw_buffer(ctx, fb);
diff --git a/src/mesa/drivers/dri/s3v/Makefile b/src/mesa/drivers/dri/s3v/Makefile
deleted file mode 100644
index 9bd79731548..00000000000
--- a/src/mesa/drivers/dri/s3v/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# src/mesa/drivers/dri/s3v/Makefile
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = s3v_dri.so
-
-# Doesn't exist yet.
-#MINIGLX_SOURCES = server/savage_dri.c
-
-DRIVER_SOURCES = \
- s3v_context.c \
- s3v_dd.c \
- s3v_inithw.c \
- s3v_lock.c \
- s3v_render.c \
- s3v_screen.c \
- s3v_span.c \
- s3v_state.c \
- s3v_tex.c \
- s3v_texmem.c \
- s3v_texstate.c \
- s3v_tris.c \
- s3v_vb.c \
- s3v_xmesa.c
-
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-
-include ../Makefile.template
-
-symlinks:
diff --git a/src/mesa/drivers/dri/s3v/s3v_common.h b/src/mesa/drivers/dri/s3v/s3v_common.h
deleted file mode 100644
index b66cdf1df08..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_common.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-/* WARNING: If you change any of these defines, make sure to change
- * the kernel include file as well (s3v_drm.h)
- */
-
-#ifndef _XF86DRI_S3V_H_
-#define _XF86DRI_S3V_H_
-
-#ifndef _S3V_DEFINES_
-#define _S3V_DEFINES_
-#define S3V_USE_BATCH 1
-
-/* #define S3V_BUF_4K 1 */
-
-#ifdef S3V_BUF_4K
-#define S3V_DMA_BUF_ORDER 12
-#define S3V_DMA_BUF_NR 256
-#else
-#define S3V_DMA_BUF_ORDER 16 /* -much- better */
-#define S3V_DMA_BUF_NR 16
-#endif
-/* on s3virge you can only choose between *
- * 4k (2^12) and 64k (2^16) dma bufs */
-#define S3V_DMA_BUF_SZ (1<<S3V_DMA_BUF_ORDER)
-
-#define S3V_NR_SAREA_CLIPRECTS 8
-
-/* Each region is a minimum of 16k (64*64@4bpp)
- * and there are at most 40 of them.
- */
-#define S3V_NR_TEX_REGIONS 64 /* was 40 */
-#define S3V_LOG_TEX_GRANULARITY 16 /* was 4 */
-/* 40 * (2 ^ 4) = 640k, that's all we have for tex on 4mb gfx card */
-/* FIXME: will it work with card with less than 4mb? */
-/* FIXME: we should set this at run time */
-
-#endif /* _S3V_DEFINES */
-
-/*
- * WARNING: If you change any of these defines, make sure to change
- * the kernel include file as well (gamma_drm.h)
- */
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_S3V_INIT_DMA 0x00
-#define DRM_S3V_CLEANUP_DMA 0x01
-
-typedef struct _drmS3VInit {
- enum {
- S3V_INIT_DMA = 0x01,
- S3V_CLEANUP_DMA = 0x02
- } func;
-
- unsigned int pcimode; /* bool: 1=pci 0=agp */
-
- unsigned int mmio_offset;
- unsigned int buffers_offset;
- unsigned int sarea_priv_offset;
-
- unsigned int front_offset;
- unsigned int front_width;
- unsigned int front_height;
- unsigned int front_pitch;
-
- unsigned int back_offset;
- unsigned int back_width;
- unsigned int back_height;
- unsigned int back_pitch;
-
- unsigned int depth_offset;
- unsigned int depth_width;
- unsigned int depth_height;
- unsigned int depth_pitch;
-
- unsigned int texture_offset;
-} drmS3VInit;
-
-#endif
diff --git a/src/mesa/drivers/dri/s3v/s3v_context.c b/src/mesa/drivers/dri/s3v/s3v_context.c
deleted file mode 100644
index 0a3bf7258d1..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_context.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "vbo/vbo.h"
-
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-
-#include "main/context.h"
-#include "main/simple_list.h"
-#include "main/matrix.h"
-#include "main/extensions.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-#include "main/simple_list.h"
-#include "main/mm.h"
-
-#include "drivers/common/driverfuncs.h"
-#include "s3v_vb.h"
-#include "s3v_tris.h"
-
-#if 0
-extern const struct tnl_pipeline_stage _s3v_render_stage;
-
-static const struct tnl_pipeline_stage *s3v_pipeline[] = {
- &_tnl_vertex_transform_stage,
- &_tnl_normal_transform_stage,
- &_tnl_lighting_stage,
- &_tnl_fog_coordinate_stage,
- &_tnl_texgen_stage,
- &_tnl_texture_transform_stage,
- /* REMOVE: point attenuation stage */
-#if 1
- &_s3v_render_stage, /* ADD: unclipped rastersetup-to-dma */
-#endif
- &_tnl_render_stage,
- 0,
-};
-#endif
-
-GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
- __DRIcontextPrivate *driContextPriv,
- void *sharedContextPrivate)
-{
- GLcontext *ctx, *shareCtx;
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
- s3vContextPtr vmesa;
- s3vScreenPtr s3vScrn;
- S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) +
- sizeof(drm_sarea_t));
- struct dd_function_table functions;
-
- DEBUG_WHERE(("*** s3vCreateContext ***\n"));
-
- vmesa = (s3vContextPtr) CALLOC( sizeof(*vmesa) );
- if ( !vmesa ) return GL_FALSE;
-
- /* Allocate the Mesa context */
- if (sharedContextPrivate)
- shareCtx = ((s3vContextPtr) sharedContextPrivate)->glCtx;
- else
- shareCtx = NULL;
-
- _mesa_init_driver_functions(&functions);
-
- vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions,
- (void *)vmesa);
- if (!vmesa->glCtx) {
- FREE(vmesa);
- return GL_FALSE;
- }
-
- vmesa->driContext = driContextPriv;
- vmesa->driScreen = sPriv;
- vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
-
- vmesa->hHWContext = driContextPriv->hHWContext;
- vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
- vmesa->driFd = sPriv->fd;
- vmesa->sarea = saPriv;
-
- s3vScrn = vmesa->s3vScreen = (s3vScreenPtr)(sPriv->private);
-
- ctx = vmesa->glCtx;
-
- ctx->Const.MaxTextureLevels = 11; /* it is (11-1) -> 1024 * 1024 FIXME */
-
- ctx->Const.MaxTextureUnits = 1; /* FIXME: or 2 ? */
-
- /* No wide points.
- */
- ctx->Const.MinPointSize = 1.0;
- ctx->Const.MinPointSizeAA = 1.0;
- ctx->Const.MaxPointSize = 1.0;
- ctx->Const.MaxPointSizeAA = 1.0;
-
- /* No wide lines.
- */
- ctx->Const.MinLineWidth = 1.0;
- ctx->Const.MinLineWidthAA = 1.0;
- ctx->Const.MaxLineWidth = 1.0;
- ctx->Const.MaxLineWidthAA = 1.0;
- ctx->Const.LineWidthGranularity = 1.0;
-
- ctx->Const.MaxDrawBuffers = 1;
-
- vmesa->texHeap = mmInit( 0, vmesa->s3vScreen->textureSize );
- DEBUG(("vmesa->s3vScreen->textureSize = 0x%x\n",
- vmesa->s3vScreen->textureSize));
-
- /* NOTE */
- /* mmInit(offset, size); */
-
- /* allocates a structure like this:
-
- struct mem_block_t {
- struct mem_block_t *next;
- struct mem_block_t *heap;
- int ofs,size;
- int align;
- int free:1;
- int reserved:1;
- };
-
- */
-
- make_empty_list(&vmesa->TexObjList);
- make_empty_list(&vmesa->SwappedOut);
-
- vmesa->CurrentTexObj[0] = 0;
- vmesa->CurrentTexObj[1] = 0; /* FIXME */
-
- vmesa->RenderIndex = ~0;
-
- /* Initialize the software rasterizer and helper modules.
- */
- _swrast_CreateContext( ctx );
- _vbo_CreateContext( ctx );
- _tnl_CreateContext( ctx );
- _swsetup_CreateContext( ctx );
-
- /* Install the customized pipeline:
- */
-#if 0
- _tnl_destroy_pipeline( ctx );
- _tnl_install_pipeline( ctx, s3v_pipeline );
-#endif
- /* Configure swrast to match hardware characteristics:
- */
-#if 0
- _swrast_allow_pixel_fog( ctx, GL_FALSE );
- _swrast_allow_vertex_fog( ctx, GL_TRUE );
-#endif
- vmesa->_3d_mode = 0;
-
- /* 3D lines / gouraud tris */
- vmesa->CMD = ( AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
- | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
- | Z_LESS | TEX_WRAP_ON | TEX_MODULATE | LINEAR
- | TEX_COL_ARGB1555 | CMD_3D );
-
- vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
- vmesa->alpha_cmd = vmesa->_alpha[0];
- vmesa->_tri[0] = DO_GOURAUD_TRI;
- vmesa->_tri[1] = DO_TEX_LIT_TRI;
- vmesa->prim_cmd = vmesa->_tri[0];
-
- /* printf("first vmesa->CMD = 0x%x\n", vmesa->CMD); */
-
- vmesa->TexOffset = vmesa->s3vScreen->texOffset;
-
- s3vInitVB( ctx );
- s3vInitExtensions( ctx );
- s3vInitDriverFuncs( ctx );
- s3vInitStateFuncs( ctx );
- s3vInitSpanFuncs( ctx );
- s3vInitTextureFuncs( ctx );
- s3vInitTriFuncs( ctx );
- s3vInitState( vmesa );
-
- driContextPriv->driverPrivate = (void *)vmesa;
-
- /* HACK */
- vmesa->bufSize = S3V_DMA_BUF_SZ;
-
- DEBUG(("vmesa->bufSize = %i\n", vmesa->bufSize));
- DEBUG(("vmesa->bufCount = %i\n", vmesa->bufCount));
-
-
- /* dma init */
- DEBUG_BUFS(("GET_FIRST_DMA\n"));
-
- vmesa->_bufNum = 0;
-
- GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
- 1, &(vmesa->bufIndex[0]), &(vmesa->bufSize),
- &vmesa->_buf[0], &vmesa->bufCount, s3vScrn);
-
- GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
- 1, &(vmesa->bufIndex[1]), &(vmesa->bufSize),
- &vmesa->_buf[1], &vmesa->bufCount, s3vScrn);
-
- vmesa->buf = vmesa->_buf[vmesa->_bufNum];
-
-/*
- vmesa->CMD = (AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
- | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
- | DO_GOURAUD_TRI | CMD_3D);
-
- vmesa->TexOffset = vmesa->s3vScreen->texOffset;
-*/
-
-/* ... but we should support only 15 bit in virge (out of 8/15/24)... */
-
- DEBUG(("glVisual->depthBits = %i\n", glVisual->depthBits));
-
- switch (glVisual->depthBits) {
- case 8:
- break;
-
- case 15:
- case 16:
- vmesa->depth_scale = 1.0f / 0xffff;
- break;
- case 24:
- vmesa->depth_scale = 1.0f / 0xffffff;
- break;
- default:
- break;
- }
-
- vmesa->cull_zero = 0.0f;
-
- vmesa->DepthSize = glVisual->depthBits;
- vmesa->Flags = S3V_FRONT_BUFFER;
- vmesa->Flags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
- vmesa->Flags |= (vmesa->DepthSize > 0 ? S3V_DEPTH_BUFFER : 0);
-
- vmesa->EnabledFlags = S3V_FRONT_BUFFER;
- vmesa->EnabledFlags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
-
-
- if (vmesa->Flags & S3V_BACK_BUFFER) {
- vmesa->readOffset = vmesa->drawOffset = vmesa->s3vScreen->backOffset;
- } else {
- vmesa->readOffset = vmesa->drawOffset = 0;
- }
-
- s3vInitHW( vmesa );
-
- driContextPriv->driverPrivate = (void *)vmesa;
-
- return GL_TRUE;
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_context.h b/src/mesa/drivers/dri/s3v/s3v_context.h
deleted file mode 100644
index 671ba90d781..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_context.h
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_CONTEXT_H_
-#define _S3V_CONTEXT_H_
-
-#include "dri_util.h"
-
-#include "s3v_dri.h"
-#include "s3v_regs.h"
-#include "s3v_macros.h"
-#include "s3v_screen.h"
-#include "main/colormac.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "drm.h"
-#include "main/mm.h"
-#include "drirenderbuffer.h"
-
-/* Flags for context */
-#define S3V_FRONT_BUFFER 0x00000001
-#define S3V_BACK_BUFFER 0x00000002
-#define S3V_DEPTH_BUFFER 0x00000004
-
- /* FIXME: check */
-#define S3V_MAX_TEXTURE_SIZE 2048
-
-/* These are the minimum requirements and should probably be increased */
-#define MAX_MODELVIEW_STACK 16
-#define MAX_PROJECTION_STACK 2
-#define MAX_TEXTURE_STACK 2
-
-extern void s3vDDUpdateHWState(GLcontext *ctx);
-extern s3vScreenPtr s3vCreateScreen(__DRIscreenPrivate *sPriv);
-extern void s3vDestroyScreen(__DRIscreenPrivate *sPriv);
-extern GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
- __DRIcontextPrivate *driContextPriv,
- void *sharedContextPrivate);
-
-#define S3V_UPLOAD_ALL 0xffffffff
-/* #define S3V_UPLOAD_CLIPRECTS 0x00000002 */
-#define S3V_UPLOAD_ALPHA 0x00000004
-#define S3V_UPLOAD_BLEND 0x00000008
-#define S3V_UPLOAD_DEPTH 0x00000010
-#define S3V_UPLOAD_VIEWPORT 0x00000020
-#define S3V_UPLOAD_SHADE 0x00000040
-#define S3V_UPLOAD_CLIP 0x00000080
-#define S3V_UPLOAD_MASKS 0x00000100
-#define S3V_UPLOAD_WINDOW 0x00000200 /* defunct */
-#define S3V_UPLOAD_GEOMETRY 0x00000400
-#define S3V_UPLOAD_POLYGON 0x00000800
-#define S3V_UPLOAD_DITHER 0x00001000
-#define S3V_UPLOAD_LOGICOP 0x00002000
-#define S3V_UPLOAD_FOG 0x00004000
-#define S3V_UPLOAD_LIGHT 0x00008000
-#define S3V_UPLOAD_CONTEXT 0x00010000
-#define S3V_UPLOAD_TEX0 0x00020000
-#define S3V_UPLOAD_STIPPLE 0x00040000
-#define S3V_UPLOAD_TRANSFORM 0x00080000
-#define S3V_UPLOAD_LINEMODE 0x00100000
-#define S3V_UPLOAD_POINTMODE 0x00200000
-#define S3V_UPLOAD_TRIMODE 0x00400000
-
-#define S3V_NEW_CLIP 0x00000001
-#define S3V_NEW_WINDOW 0x00000002
-#define S3V_NEW_CONTEXT 0x00000004
-#define S3V_NEW_TEXTURE 0x00000008 /* defunct */
-#define S3V_NEW_ALPHA 0x00000010
-#define S3V_NEW_DEPTH 0x00000020
-#define S3V_NEW_MASKS 0x00000040
-#define S3V_NEW_POLYGON 0x00000080
-#define S3V_NEW_CULL 0x00000100
-#define S3V_NEW_LOGICOP 0x00000200
-#define S3V_NEW_FOG 0x00000400
-#define S3V_NEW_LIGHT 0x00000800
-#define S3V_NEW_STIPPLE 0x00001000
-#define S3V_NEW_ALL 0xffffffff
-
-#define S3V_FALLBACK_TRI 0x00000001
-#define S3V_FALLBACK_TEXTURE 0x00000002
-
-struct s3v_context;
-typedef struct s3v_context s3vContextRec;
-typedef struct s3v_context *s3vContextPtr;
-typedef struct s3v_texture_object_t *s3vTextureObjectPtr;
-
-#define VALID_S3V_TEXTURE_OBJECT(tobj) (tobj)
-
-#define S3V_TEX_MAXLEVELS 12
-
-/* For shared texture space managment, these texture objects may also
- * be used as proxies for regions of texture memory containing other
- * client's textures. Such proxy textures (not to be confused with GL
- * proxy textures) are subject to the same LRU aging we use for our
- * own private textures, and thus we have a mechanism where we can
- * fairly decide between kicking out our own textures and those of
- * other clients.
- *
- * Non-local texture objects have a valid MemBlock to describe the
- * region managed by the other client, and can be identified by
- * 't->globj == 0'
- */
-struct s3v_texture_object_t {
- struct s3v_texture_object_t *next, *prev;
-
- GLuint age;
- struct gl_texture_object *globj;
-
- int Pitch;
- int Height;
- int WidthLog2;
- int texelBytes;
- int totalSize;
- int bound;
-
- struct mem_block *MemBlock;
- GLuint BufAddr;
-
- GLuint min_level;
- GLuint max_level;
- GLuint dirty_images;
-
- GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
-
- struct {
- const struct gl_texture_image *image;
- int offset; /* into BufAddr */
- int height;
- int internalFormat;
- } image[S3V_TEX_MAXLEVELS];
-
- GLuint TextureCMD;
-
- GLuint TextureColorMode;
- GLuint TextureFilterMode;
- GLuint TextureBorderColor;
- GLuint TextureWrap;
- GLuint TextureMipSize;
-
- GLuint TextureBaseAddr[S3V_TEX_MAXLEVELS];
- GLuint TextureFormat;
- GLuint TextureReadMode;
-};
-
-#define S3V_NO_PALETTE 0x0
-#define S3V_USE_PALETTE 0x1
-#define S3V_UPDATE_PALETTE 0x2
-#define S3V_FALLBACK_PALETTE 0x4
-
-void s3vUpdateTextureState( GLcontext *ctx );
-
-void s3vDestroyTexObj( s3vContextPtr vmesa, s3vTextureObjectPtr t);
-void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t );
-
-void s3vResetGlobalLRU( s3vContextPtr vmesa );
-void s3vTexturesGone( s3vContextPtr vmesa,
- GLuint start, GLuint end,
- GLuint in_use );
-
-void s3vEmitHwState( s3vContextPtr vmesa );
-void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
-void s3vInitExtensions( GLcontext *ctx );
-void s3vInitDriverFuncs( GLcontext *ctx );
-void s3vSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
-void s3vInitState( s3vContextPtr vmesa );
-void s3vInitHW( s3vContextPtr vmesa );
-void s3vInitStateFuncs( GLcontext *ctx );
-void s3vInitTextureFuncs( GLcontext *ctx );
-void s3vInitTriFuncs( GLcontext *ctx );
-
-void s3vUpdateWindow( GLcontext *ctx );
-void s3vUpdateViewportOffset( GLcontext *ctx );
-
-void s3vPrintLocalLRU( s3vContextPtr vmesa );
-void s3vPrintGlobalLRU( s3vContextPtr vmesa );
-
-extern void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode );
-#define FALLBACK( imesa, bit, mode ) s3vFallback( imesa, bit, mode )
-
-/* Use the templated vertex formats. Only one of these is used in s3v.
- */
-#define TAG(x) s3v##x
-#include "tnl_dd/t_dd_vertex.h"
-#undef TAG
-
-typedef void (*s3v_quad_func)( s3vContextPtr,
- const s3vVertex *,
- const s3vVertex *,
- const s3vVertex *,
- const s3vVertex * );
-typedef void (*s3v_tri_func)( s3vContextPtr,
- const s3vVertex *,
- const s3vVertex *,
- const s3vVertex * );
-typedef void (*s3v_line_func)( s3vContextPtr,
- const s3vVertex *,
- const s3vVertex * );
-typedef void (*s3v_point_func)( s3vContextPtr,
- const s3vVertex * );
-
-
-/* static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end); */
-typedef void (*emit_func)( GLcontext *, GLuint, GLuint);
-
-struct s3v_context {
- GLcontext *glCtx; /* Mesa context */
-
- __DRIcontextPrivate *driContext;
- __DRIscreenPrivate *driScreen;
- __DRIdrawablePrivate *driDrawable;
-
- GLuint new_gl_state;
- GLuint new_state;
- GLuint dirty;
-
- S3VSAREAPtr sarea;
-
- /* Temporaries for translating away float colors
- */
- struct gl_client_array UbyteColor;
- struct gl_client_array UbyteSecondaryColor;
-
- /* Mirrors of some DRI state
- */
-
- drm_context_t hHWContext;
- drmLock *driHwLock;
- int driFd;
-
- GLuint numClipRects; /* Cliprects for the draw buffer */
- drm_clip_rect_t *pClipRects;
-
- GLuint* buf; /* FIXME */
- GLuint* _buf[2];
- int _bufNum;
- int bufIndex[2];
- int bufSize;
- int bufCount;
-
- s3vScreenPtr s3vScreen; /* Screen private DRI data */
-
- int drawOffset;
- int readOffset;
-
- s3v_point_func draw_point;
- s3v_line_func draw_line;
- s3v_tri_func draw_tri;
- s3v_quad_func draw_quad;
-
- GLuint Fallback;
- GLuint RenderIndex;
- GLuint SetupNewInputs;
- GLuint SetupIndex;
-
- GLuint vertex_format;
- GLuint vertex_size;
- GLuint vertex_stride_shift;
- char *verts;
-
- GLfloat hw_viewport[16];
- GLuint hw_primitive;
- GLenum render_primitive;
-
- GLfloat depth_scale;
-
- s3vTextureObjectPtr CurrentTexObj[2];
- struct s3v_texture_object_t TexObjList;
- struct s3v_texture_object_t SwappedOut;
- GLenum TexEnvImageFmt[2];
-
- struct mem_block *texHeap;
-
- int lastSwap;
- int texAge;
- int ctxAge;
- int dirtyAge;
- int lastStamp;
-
- /* max was here: don't touch */
-
- unsigned int S3V_REG[S3V_REGS_NUM];
-
- GLuint texMode;
- GLuint alphaMode;
- GLuint lightMode;
-
- GLuint SrcBase;
- GLuint DestBase;
- GLuint DestBlit;
- GLuint ScissorLR;
- GLuint ScissorTB;
- GLuint ScissorWH; /* SubScissorWH */ /* RectWH */
- GLuint FrontStride;
- GLuint BackStride;
- GLuint SrcStride;
- GLuint DestStride;
- GLuint SrcXY;
- GLuint DestXY;
-
- GLuint ClearColor;
- GLuint Color;
- GLuint DitherMode;
- GLuint ClearDepth;
-
- GLuint TextureBorderColor;
- GLuint TexOffset;
- GLuint TexStride;
-
- GLuint CMD;
- GLuint prim_cmd;
- GLuint _tri[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */
- GLuint alpha_cmd; /* actual alpha cmd */
- GLuint _alpha[2];
- GLuint _alpha_tex; /* tex alpha type */
- /* (3d_mode) 0 = 3d line/gourad tri; 1 = 3d tex tri */
- GLuint _3d_mode;
-
- GLfloat backface_sign;
- GLfloat cull_zero;
-
- int restore_primitive;
-
-/* *** 2check *** */
-
- GLuint FogMode;
- GLuint AreaStippleMode;
- GLuint LBReadFormat;
- GLuint LBWriteFormat;
- GLuint LineMode;
- GLuint PointMode;
- GLuint TriangleMode;
- GLuint AntialiasMode;
- GLfloat ViewportScaleX;
- GLfloat ViewportScaleY;
- GLfloat ViewportScaleZ;
- GLfloat ViewportOffsetX;
- GLfloat ViewportOffsetY;
- GLfloat ViewportOffsetZ;
- int MatrixMode;
- int DepthMode;
- int TransformMode;
- int LBReadMode;
- int FBReadMode;
- int FBWindowBase;
- int LBWindowBase;
- int ColorDDAMode;
- int GeometryMode;
- int AlphaTestMode;
- int AlphaBlendMode;
- int AB_FBReadMode;
- int AB_FBReadMode_Save;
- int DeltaMode;
- int ColorMaterialMode;
- int FBHardwareWriteMask;
- int MaterialMode;
- int NormalizeMode;
- int LightingMode;
- int Light0Mode;
- int Light1Mode;
- int Light2Mode;
- int Light3Mode;
- int Light4Mode;
- int Light5Mode;
- int Light6Mode;
- int Light7Mode;
- int Light8Mode;
- int Light9Mode;
- int Light10Mode;
- int Light11Mode;
- int Light12Mode;
- int Light13Mode;
- int Light14Mode;
- int Light15Mode;
- int LogicalOpMode;
- int ScissorMode;
- int ScissorMaxXY;
- int ScissorMinXY;
- int Window; /* GID part probably should be in draw priv */
- int WindowOrigin;
- int x, y, w, h; /* Probably should be in drawable priv */
- int FrameCount; /* Probably should be in drawable priv */
- int NotClipped; /* Probably should be in drawable priv */
- int WindowChanged; /* Probably should be in drawabl... */
- int Flags;
- int EnabledFlags;
- int DepthSize;
- int Begin;
- GLenum ErrorValue;
- int Texture1DEnabled;
- int Texture2DEnabled;
-
- float ModelView[16];
- float Proj[16];
- float ModelViewProj[16];
- float Texture[16];
-
- float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
- int ModelViewCount;
- float ProjStack[(MAX_PROJECTION_STACK-1)*16];
- int ProjCount;
- float TextureStack[(MAX_TEXTURE_STACK-1)*16];
- int TextureCount;
-};
-
-#define S3VIRGEPACKCOLOR555( r, g, b, a ) \
- ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define S3VIRGEPACKCOLOR565( r, g, b ) \
- ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define S3VIRGEPACKCOLOR888( r, g, b ) \
- (((r) << 16) | ((g) << 8) | (b))
-
-#define S3VIRGEPACKCOLOR8888( r, g, b, a ) \
- (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-
-#define S3VIRGEPACKCOLOR4444( r, g, b, a ) \
- ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-static INLINE GLuint s3vPackColor( GLuint cpp,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
-{
- unsigned int ret;
- DEBUG(("cpp = %i, r=0x%x, g=0x%x, b=0x%x, a=0x%x\n", cpp, r, g, b, a));
-
- switch ( cpp ) {
- case 2:
- ret = S3VIRGEPACKCOLOR555( r, g, b, a );
- DEBUG(("ret = 0x%x\n", ret));
- return ret;
- case 4:
- return PACK_COLOR_8888( a, r, g, b );
- default:
- return 0;
- }
-}
-
-#define S3V_CONTEXT(ctx) ((s3vContextPtr)(ctx->DriverCtx))
-
-#endif /* _S3V_CONTEXT_H_ */
diff --git a/src/mesa/drivers/dri/s3v/s3v_dd.c b/src/mesa/drivers/dri/s3v/s3v_dd.c
deleted file mode 100644
index e340116f5e1..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_dd.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_lock.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-
-#include "main/context.h"
-#include "main/framebuffer.h"
-#include "swrast/swrast.h"
-
-#define S3V_DATE "20020207"
-
-
-/* Return the width and height of the current color buffer.
- */
-static void s3vDDGetBufferSize( GLframebuffer *buffer,
- GLuint *width, GLuint *height )
-{
- GET_CURRENT_CONTEXT(ctx);
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-/* S3VHW_LOCK( vmesa ); */
- *width = vmesa->driDrawable->w;
- *height = vmesa->driDrawable->h;
-/* S3VHW_UNLOCK( vmesa ); */
-}
-
-
-/* Return various strings for glGetString().
- */
-static const GLubyte *s3vDDGetString( GLcontext *ctx, GLenum name )
-{
- static char buffer[128];
-
- switch ( name ) {
- case GL_VENDOR:
- return (GLubyte *)"Max Lingua (ladybug)";
-
- case GL_RENDERER:
- sprintf( buffer, "Mesa DRI S3 Virge " S3V_DATE );
-
- /* Append any CPU-specific information.
- */
-#ifdef USE_X86_ASM
- if ( _mesa_x86_cpu_features ) {
- strncat( buffer, " x86", 4 );
-
-}
-#ifdef USE_MMX_ASM
- if ( cpu_has_mmx ) {
- strncat( buffer, "/MMX", 4 );
- }
-#endif
-#ifdef USE_3DNOW_ASM
- if ( cpu_has_3dnow ) {
- strncat( buffer, "/3DNow!", 7 );
- }
-#endif
-#ifdef USE_SSE_ASM
- if ( cpu_has_xmm ) {
- strncat( buffer, "/SSE", 4 );
- }
-#endif
-#endif
- return (GLubyte *)buffer;
-
- default:
- return NULL;
- }
-}
-
-/* Enable the extensions supported by this driver.
- */
-void s3vInitExtensions( GLcontext *ctx )
-{
- /* None... */
-}
-
-/* Initialize the driver's misc functions.
- */
-void s3vInitDriverFuncs( GLcontext *ctx )
-{
- ctx->Driver.GetBufferSize = s3vDDGetBufferSize;
- ctx->Driver.GetString = s3vDDGetString;
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_dri.h b/src/mesa/drivers/dri/s3v/s3v_dri.h
deleted file mode 100644
index 339c579f7f7..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_dri.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_DRI
-#define _S3V_DRI
-
-#include "s3v_common.h"
-
-#define S3V_MAX_DRAWABLES (S3V_DMA_BUF_NR/2) /* 32 */ /* 256 */ /* FIXME */
-
-typedef struct
-{
- int deviceID;
- int width;
- int height;
- int mem;
- int cpp;
- int bitsPerPixel;
-
- int fbOffset;
- int fbStride;
-
- int logTextureGranularity;
- int textureOffset;
-
- drm_handle_t regs;
- drmSize regsSize;
-
- unsigned int sarea_priv_offset;
-/*
- drmAddress regsMap;
-
- drmSize textureSize;
- drm_handle_t textures;
-*/
-
-#if 0
- drm_handle_t agp_buffers;
- drmSize agp_buf_size;
-#endif
-
-/*
- drmBufMapPtr drmBufs;
- int irq;
- unsigned int sarea_priv_offset;
-*/
-
-/* FIXME: cleanup ! */
-
- drmSize registerSize; /* == S3V_MMIO_REGSIZE */
- drm_handle_t registerHandle;
-
- drmSize pciSize;
- drm_handle_t pciMemHandle;
-
- drmSize frontSize; /* == videoRambytes */
-/* drm_handle_t frontHandle; */
- unsigned long frontOffset; /* == fbOffset */
- int frontPitch;
-/* unsigned char *front; */
-
- unsigned int bufferSize; /* size of depth/back buffer */
-
- drmSize backSize;
-/* drm_handle_t backHandle; */
- unsigned long backOffset;
- int backPitch;
-/* unsigned char *back; */
-
- drmSize depthSize;
-/* drm_handle_t depthHandle; */
- unsigned long depthOffset;
- int depthPitch;
-/* unsigned char *depth; */
-
- drmSize texSize;
-/* drm_handle_t texHandle; */
- unsigned long texOffset;
- int texPitch;
-/* unsigned char *tex; */
-
- drmSize dmaBufSize; /* Size of buffers (in bytes) */
- drm_handle_t dmaBufHandle; /* Handle from drmAddMap */
- unsigned long dmaBufOffset; /* Offset/Start */
- int dmaBufPitch; /* Pitch */
- unsigned char *dmaBuf; /* Map */
- int bufNumBufs; /* Number of buffers */
- drmBufMapPtr buffers; /* Buffer map */
-
-} S3VDRIRec, *S3VDRIPtr;
-
-/* WARNING: Do not change the SAREA structure without changing the kernel
- * as well */
-
-typedef struct {
- unsigned char next, prev; /* indices to form a circular LRU */
- unsigned char in_use; /* owned by a client, or free? */
- int age; /* tracked by clients to update local LRU's */
-} S3VTexRegionRec, *S3VTexRegionPtr;
-
-typedef struct {
- unsigned int nbox;
- drm_clip_rect_t boxes[S3V_NR_SAREA_CLIPRECTS];
-
- /* Maintain an LRU of contiguous regions of texture space. If
- * you think you own a region of texture memory, and it has an
- * age different to the one you set, then you are mistaken and
- * it has been stolen by another client. If global texAge
- * hasn't changed, there is no need to walk the list.
- *
- * These regions can be used as a proxy for the fine-grained
- * texture information of other clients - by maintaining them
- * in the same lru which is used to age their own textures,
- * clients have an approximate lru for the whole of global
- * texture space, and can make informed decisions as to which
- * areas to kick out. There is no need to choose whether to
- * kick out your own texture or someone else's - simply eject
- * them all in LRU order.
- */
- S3VTexRegionRec texList[S3V_NR_TEX_REGIONS+1]; /* Last elt is sentinal */
-
- int texAge; /* last time texture was uploaded */
-
- int last_enqueue; /* last time a buffer was enqueued */
- int last_dispatch; /* age of the most recently dispatched buffer */
- int last_quiescent; /* */
-
- int ctxOwner; /* last context to upload state */
-} S3VSAREARec, *S3VSAREAPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} S3VConfigPrivRec, *S3VConfigPrivPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} S3VDRIContextRec, *S3VDRIContextPtr;
-
-
-#endif
diff --git a/src/mesa/drivers/dri/s3v/s3v_inithw.c b/src/mesa/drivers/dri/s3v/s3v_inithw.c
deleted file mode 100644
index bdc9effb799..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_inithw.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include <sys/ioctl.h>
-
-#include "s3v_context.h"
-
-void s3vInitHW( s3vContextPtr vmesa )
-{
- int i;
- static short _reset = 1;
-
- DEBUG(("vmesa->driDrawable = %p\n", vmesa->driDrawable));
- DEBUG(("stride = %i\n",
- vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp));
- DEBUG(("frontOffset = 0x%x\n", vmesa->s3vScreen->frontOffset));
- DEBUG(("backOffset = 0x%x\n", vmesa->s3vScreen->backOffset));
- DEBUG(("depthOffset = 0x%x\n", vmesa->s3vScreen->depthOffset));
- DEBUG(("textureOffset = 0x%x\n", vmesa->s3vScreen->texOffset));
-
-/* if (_reset) { */
-/* ioctl(vmesa->driFd, 0x4a); */
- ioctl(vmesa->driFd, 0x41); /* reset */
- _reset = 0;
-/* ioctl(vmesa->driFd, 0x4c); */
-/* } */
-
- /* FIXME */
- switch (vmesa->s3vScreen->cpp) {
- case 2:
- break;
- case 4:
- break;
- }
-
- /* FIXME for stencil, gid, etc */
- switch (vmesa->DepthSize) {
- case 15:
- case 16:
- break;
- case 24:
- break;
- case 32:
- break;
- }
-
- vmesa->FogMode = 1;
- vmesa->ClearDepth = 0xffff;
- vmesa->x = 0;
- vmesa->y = 0;
- vmesa->w = 0;
- vmesa->h = 0;
- vmesa->FrameCount = 0;
- vmesa->MatrixMode = GL_MODELVIEW;
- vmesa->ModelViewCount = 0;
- vmesa->ProjCount = 0;
- vmesa->TextureCount = 0;
-
-
- /* FIXME: do we need the following? */
-
- for (i = 0; i < 16; i++)
- if (i % 5 == 0)
- vmesa->ModelView[i] =
- vmesa->Proj[i] =
- vmesa->ModelViewProj[i] =
- vmesa->Texture[i] = 1.0;
- else
- vmesa->ModelView[i] =
- vmesa->Proj[i] =
- vmesa->ModelViewProj[i] =
- vmesa->Texture[i] = 0.0;
-
- vmesa->LBWindowBase = vmesa->driScreen->fbWidth *
- (vmesa->driScreen->fbHeight - 1);
- vmesa->FBWindowBase = vmesa->driScreen->fbWidth *
- (vmesa->driScreen->fbHeight - 1);
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_lock.c b/src/mesa/drivers/dri/s3v/s3v_lock.c
deleted file mode 100644
index 52bb87ecec9..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_lock.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-
-#if DEBUG_LOCKING
-char *prevLockFile = NULL;
-int prevLockLine = 0;
-#endif
-
-
-/* Update the hardware state. This is called if another context has
- * grabbed the hardware lock, which includes the X server. This
- * function also updates the driver's window state after the X server
- * moves, resizes or restacks a window -- the change will be reflected
- * in the drawable position and clip rects. Since the X server grabs
- * the hardware lock when it changes the window state, this routine will
- * automatically be called after such a change.
- */
-void s3vGetLock( s3vContextPtr vmesa, GLuint flags )
-{
- __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-/* __DRIscreenPrivate *sPriv = vmesa->driScreen; */
-
- printf("s3vGetLock <- ***\n");
-
- drmGetLock( vmesa->driFd, vmesa->hHWContext, flags );
-
- /* The window might have moved, so we might need to get new clip
- * rects.
- *
- * NOTE: This releases and regrabs the hw lock to allow the X server
- * to respond to the DRI protocol request for new drawable info.
- * Since the hardware state depends on having the latest drawable
- * clip rects, all state checking must be done _after_ this call.
- */
- /* DRI_VALIDATE_DRAWABLE_INFO( vmesa->display, sPriv, dPriv ); */
-
- if ( vmesa->lastStamp != dPriv->lastStamp ) {
- vmesa->lastStamp = dPriv->lastStamp;
- vmesa->new_state |= S3V_NEW_WINDOW | S3V_NEW_CLIP;
- }
-
- vmesa->numClipRects = dPriv->numClipRects;
- vmesa->pClipRects = dPriv->pClipRects;
-
-#if 0
- vmesa->dirty = ~0;
-
- if ( sarea->ctxOwner != vmesa->hHWContext ) {
- sarea->ctxOwner = vmesa->hHWContext;
- vmesa->dirty = S3V_UPLOAD_ALL;
- }
-
- for ( i = 0 ; i < vmesa->lastTexHeap ; i++ ) {
- if ( sarea->texAge[i] != vmesa->lastTexAge[i] ) {
- s3vAgeTextures( vmesa, i );
- }
- }
-#endif
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_lock.h b/src/mesa/drivers/dri/s3v/s3v_lock.h
deleted file mode 100644
index c39d24a38ac..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_lock.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef __S3V_LOCK_H__
-#define __S3V_LOCK_H__
-
-#include <sys/ioctl.h>
-
-extern void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
-
-/* Turn DEBUG_LOCKING on to find locking conflicts.
- */
-#define DEBUG_LOCKING 0
-
-#if DEBUG_LOCKING
-extern char *prevLockFile;
-extern int prevLockLine;
-
-#define DEBUG_LOCK() \
- do { \
- prevLockFile = (__FILE__); \
- prevLockLine = (__LINE__); \
- } while (0)
-
-#define DEBUG_RESET() \
- do { \
- prevLockFile = 0; \
- prevLockLine = 0; \
- } while (0)
-
-#define DEBUG_CHECK_LOCK() \
- do { \
- if ( prevLockFile ) { \
- fprintf( stderr, \
- "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
- prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
- exit(1); \
- } \
- } while (0)
-
-#else
-
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()
-
-#endif
-
-/*
- * !!! We may want to separate locks from locks with validation. This
- * could be used to improve performance for those things commands that
- * do not do any drawing !!!
- */
-
-/* Lock the hardware and validate our state.
- */
-#define LOCK_HARDWARE( vmesa ) \
- do { \
- char __ret = 0; \
- DEBUG_CHECK_LOCK(); \
- DRM_CAS( vmesa->driHwLock, vmesa->hHWContext, \
- (DRM_LOCK_HELD | vmesa->hHWContext), __ret ); \
- if ( __ret ) \
- s3vGetLock( vmesa, 0 ); \
- DEBUG_LOCK(); \
- } while (0)
-
-/* Unlock the hardware.
- */
-#define UNLOCK_HARDWARE( vmesa ) \
- do { \
- DRM_UNLOCK( vmesa->driFd, \
- vmesa->driHwLock, \
- vmesa->hHWContext ); \
- DEBUG_RESET(); \
- } while (0)
-
-#define S3VHW_LOCK( vmesa ) \
- DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); \
- DRM_SPINLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \
- vmesa->driScreen->drawLockID); \
- /* VALIDATE_DRAWABLE_INFO_NO_LOCK(vmesa); */
-
-#define S3VHW_UNLOCK( vmesa ) \
- DRM_SPINUNLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \
- vmesa->driScreen->drawLockID); \
- /* VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(vmesa); */
-
-#define S3V_SIMPLE_LOCK( vmesa ) \
- ioctl(vmesa->driFd, 0x4a)
-
-#define S3V_SIMPLE_FLUSH_LOCK( vmesa ) \
- ioctl(vmesa->driFd, 0x4b)
-
-#define S3V_SIMPLE_UNLOCK( vmesa ) \
- ioctl(vmesa->driFd, 0x4c)
-
-#endif /* __S3V_LOCK_H__ */
diff --git a/src/mesa/drivers/dri/s3v/s3v_macros.h b/src/mesa/drivers/dri/s3v/s3v_macros.h
deleted file mode 100644
index 7e9b4529df4..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_macros.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_MACROS_H_
-#define _S3V_MACROS_H_
-
-/**************/
-/* DRI macros */
-/**************/
-
-#define GENERIC_DEBUG 0
-#define FLOW_DEBUG 0
-#define DMABUFS_DEBUG 0
-
-/* Note: The argument to DEBUG*() _must_ be enclosed in parenthesis */
-
-#if (GENERIC_DEBUG || FLOW_DEBUG || DMABUFS_DEBUG)
-#include <stdio.h>
-#endif
-
-#undef DEBUG
-#if GENERIC_DEBUG
-#define DEBUG(str) printf str
-#else
-#define DEBUG(str)
-#endif
-
-#if FLOW_DEBUG
-#define DEBUG_WHERE(str) printf str
-#else
-#define DEBUG_WHERE(str)
-#endif
-
-#if DMABUFS_DEBUG
-#define DEBUG_BUFS(str) printf str
-#else
-#define DEBUG_BUFS(str)
-#endif
-
-
-#if 0
-#define S3V_DMA_SEND_FLAGS DRM_DMA_PRIORITY
-#define S3V_DMA_SEND_FLAGS DRM_DMA_BLOCK
-#else
-#define S3V_DMA_SEND_FLAGS 0
-#endif
-
-#if 0
-#define S3V_DMA_GET_FLAGS \
- (DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
-#else
-#define S3V_DMA_GET_FLAGS DRM_DMA_WAIT
-#endif
-
-
-#define DMAOUT_CHECK(reg,len) \
-do { \
- DEBUG(("DMAOUT_CHECK: reg = 0x%x\n", S3V_##reg##_REG)); \
- DEBUG_BUFS(("DMAOUT_CHECK (was): ")); \
- DEBUG_BUFS(("vmesa->bufCount=%i of vmesa->bufSize=%i\n", \
- vmesa->bufCount, vmesa->bufSize)); \
- /* FIXME: > or >= */ \
- if (vmesa->bufCount+(len+1) >= vmesa->bufSize) \
- DMAFLUSH(); \
-\
- vmesa->bufCount += (len+1); \
- DEBUG_BUFS(("DMAOUT_CHECK (is): vmesa->bufCount=%i len=%i, reg=%x\n", \
- vmesa->bufCount, len, S3V_##reg##_REG)); \
- DMAOUT( ((len & 0xffff) | ((S3V_##reg##_REG & 0xfffc) << 14)) ); \
-} while (0)
-
-#define DMAOUT(val) \
-do { \
- *(vmesa->buf++)=val; \
- DEBUG_BUFS(("DMAOUT: val=0x%x\n", (unsigned int)val)); \
-} while(0)
-
-#define DMAFINISH() \
-do { \
- /* NOTE: it does nothing - it just prints some summary infos */ \
- DEBUG(("DMAFINISH: vmesa->bufCount=%i\n", vmesa->bufCount)); \
- DEBUG(("buf: index=%i; addr=%p\n", vmesa->bufIndex[vmesa->_bufNum], \
- vmesa->s3vScreen->bufs->list[vmesa->bufIndex[vmesa->_bufNum]].address)); \
-} while(0)
-
-#define DMAFLUSH() \
-do { \
- if (vmesa->bufCount) { \
- SEND_DMA(vmesa->driFd, vmesa->hHWContext, 1, \
- &vmesa->bufIndex[vmesa->_bufNum], &vmesa->bufCount); \
-/*
- GET_DMA(vmesa->driFd, vmesa->hHWContext, 1, \
- &vmesa->bufIndex, &vmesa->bufSize); \
-*/ \
- vmesa->_bufNum = !(vmesa->_bufNum); \
- vmesa->buf = vmesa->_buf[vmesa->_bufNum]; \
-/*
- vmesa->buf = \
- vmesa->s3vScreen->bufs->list[vmesa->bufIndex].address; \
-*/ \
- vmesa->bufCount = 0; \
- } \
-} while (0)
-
-#define CMDCHANGE() \
-do { \
- DMAOUT_CHECK(3DTRI_CMDSET, 1); /* FIXME: TRI/LINE */ \
- DMAOUT(vmesa->CMD); \
- DMAFINISH(); \
-} while (0)
-
-#ifdef DONT_SEND_DMA
-#define GET_DMA(fd, hHWCtx, n, idx, size)
-#define SEND_DMA(fd, hHWCtx,n, idx, cnt)
-#else
-#define GET_DMA(fd, hHWCtx, n, idx, size) \
-do { \
- drmDMAReq dma; \
- int retcode, i; \
-\
- DEBUG(("GET_DMA: ")); \
- DEBUG(("req_count=%i; req_list[#0]=%i; req_size[#0]=%i\n", \
- n, (idx)[n-1], (size)[n-1])); \
-\
- dma.context = (hHWCtx); \
- dma.send_count = 0; \
- dma.send_list = NULL; \
- dma.send_sizes = NULL; \
- dma.flags = S3V_DMA_GET_FLAGS; \
- dma.request_count = (n); \
- dma.request_size = S3V_DMA_BUF_SZ; \
- dma.request_list = (idx); \
- dma.request_sizes = (size); \
-\
- do { \
- if ((retcode = drmDMA((fd), &dma))) { \
- DEBUG_BUFS(("drmDMA (get) returned %d\n", retcode)); \
- } \
-} while (!(dma).granted_count); \
-\
- for (i = 0; i < (n); i++) { \
- DEBUG(("Got buffer %i (index #%i)\n", (idx)[i], i)); \
- DEBUG(("of %i bytes (%i words) size\n", \
- (size)[i], (size)[i] >>2)); \
- /* Convert from bytes to words */ \
- (size)[i] >>= 2; \
- } \
-} while (0)
-
-#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \
-do { \
- drmDMAReq dma; \
- int retcode, i; \
-\
- DEBUG(("SEND_DMA: ")); \
- DEBUG(("send_count=%i; send_list[#0]=%i; send_sizes[#0]=%i\n", \
- n, (idx)[n-1], (cnt)[n-1])); \
-\
- for (i = 0; i < (n); i++) { \
- /* Convert from words to bytes */ \
- (cnt)[i] <<= 2; \
- } \
-\
- dma.context = (hHWCtx); \
- dma.send_count = (n); \
- dma.send_list = (idx); \
- dma.send_sizes = (cnt); \
- dma.flags = S3V_DMA_SEND_FLAGS; \
- dma.request_count = 0; \
- dma.request_size = 0; \
- dma.request_list = NULL; \
- dma.request_sizes = NULL; \
-\
- if ((retcode = drmDMA((fd), &dma))) { \
- DEBUG_BUFS(("drmDMA (send) returned %d\n", retcode)); \
- } \
-\
- for (i = 0; i < (n); i++) { \
- DEBUG(("Sent buffer %i (index #%i)\n", (idx)[i], i)); \
- DEBUG(("of %i bytes (%i words) size\n", \
- (cnt)[i], (cnt)[i] >>2)); \
- (cnt)[i] = 0; \
- } \
-} while (0)
-#endif /* DONT_SEND_DMA */
-
-#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, vPriv) \
-do { \
- int i; \
- DEBUG_BUFS(("GET_FIRST_DMA\n")); \
- DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, *idx, *size)); \
- DEBUG_BUFS(("going to GET_DMA\n")); \
- GET_DMA(fd, hHWCtx, n, idx, size); \
- DEBUG_BUFS(("coming from GET_DMA\n")); \
- DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, (idx)[0], (size)[0])); \
- for (i = 0; i < (n); i++) { \
- DEBUG_BUFS(("buf #%i @%p\n", \
- i, (vPriv)->bufs->list[(idx)[i]].address)); \
- (buf)[i] = (vPriv)->bufs->list[(idx)[i]].address; \
- (cnt)[i] = 0; \
- } \
- DEBUG(("GOING HOME\n")); \
-} while (0)
-
-/**************************/
-/* generic, global macros */
-/**************************/
-
-#define CALC_LOG2(l2,s) \
-do { \
- int __s = s; \
- l2 = 0; \
- while (__s > 1) { ++l2; __s >>= 1; } \
-} while (0)
-
-#define PrimType_Null 0x00000000
-#define PrimType_Points 0x10000000
-#define PrimType_Lines 0x20000000
-#define PrimType_LineLoop 0x30000000
-#define PrimType_LineStrip 0x40000000
-#define PrimType_Triangles 0x50000000
-#define PrimType_TriangleStrip 0x60000000
-#define PrimType_TriangleFan 0x70000000
-#define PrimType_Quads 0x80000000
-#define PrimType_QuadStrip 0x90000000
-#define PrimType_Polygon 0xa0000000
-#define PrimType_Mask 0xf0000000
-
-#endif /* _S3V_MACROS_H_ */
diff --git a/src/mesa/drivers/dri/s3v/s3v_regs.h b/src/mesa/drivers/dri/s3v/s3v_regs.h
deleted file mode 100644
index 26a7c54af5c..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_regs.h
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#ifndef _S3V_REG_H
-#define _S3V_REG_H
-
-#define S3V_REGS_NUM 256
-
-/************
- * DMA REGS *
- ************/
-
-#define S3V_DMA_ID 0
-#define S3V_DMA_REG 0x8590
-#define S3V_DMA_WRITEP_ID 1
-#define S3V_DMA_WRITEP_REG 0x8594
-#define S3V_DMA_READP_ID 2
-#define S3V_DMA_READP_REG 0x8598
-#define S3V_DMA_ENABLE_ID 3
-#define S3V_DMA_ENABLE_REG 0x859C
-#define S3V_DMA_UPDATE_ID 4
-#define S3V_DMA_UPDATE_REG 0x10000
-
-/***************
- * STATUS REGS *
- ***************/
-
-#define S3V_STAT_ID 10
-#define S3V_STAT_REG 0x8504
-#define S3V_STAT_VSYNC_ID 11
-#define S3V_STAT_VSYNC_REG 0x8505
-#define S3V_STAT_3D_DONE_ID 12
-#define S3V_STAT_3D_DONE_REG 0x8506
-#define S3V_STAT_FIFO_OVER_ID 13
-#define S3V_STAT_FIFO_OVER_REG 0x8508
-#define S3V_STAT_FIFO_EMPTY_ID 14
-#define S3V_STAT_FIFO_EMPTY_REG 0x850C
-#define S3V_STAT_HDMA_DONE_ID 15
-#define S3V_STAT_HDMA_DONE_REG 0x8514
-#define S3V_STAT_CDMA_DONE_ID 16
-#define S3V_STAT_CDMA_DONE_REG 0x8524
-#define S3V_STAT_3D_FIFO_EMPTY_ID 17
-#define S3V_STAT_3D_FIFO_EMPTY_REG 0x8544
-#define S3V_STAT_LPB_ID 18
-#define S3V_STAT_LPB_REG 0x8584
-#define S3V_STAT_3D_BUSY_ID 19
-#define S3V_STAT_3D_BUSY_REG 0x8704
-
-/***********
- * 2D REGS *
- ***********/
-
-#define S3V_BITBLT_ID 30
-#define S3V_BITBLT_REG 0xA400
-#define S3V_BITBLT_SRC_BASE_ID 31
-#define S3V_BITBLT_SRC_BASE_REG 0xA4D4
-#define S3V_BITBLT_DEST_BASE_ID 32
-#define S3V_BITBLT_DEST_BASE_REG 0xA4D8
-#define S3V_BITBLT_CLIP_L_R_ID 33
-#define S3V_BITBLT_CLIP_L_R_REG 0xA4DC
-#define S3V_BITBLT_CLIP_T_B_ID 34
-#define S3V_BITBLT_CLIP_T_B_REG 0xA4E0
-#define S3V_BITBLT_DEST_SRC_STRIDE_ID 35
-#define S3V_BITBLT_DEST_SRC_STRIDE_REG 0xA4E4
-#define S3V_BITBLT_MONO_PAT0_ID 36
-#define S3V_BITBLT_MONO_PAT0_REG 0xA4E8
-#define S3V_BITBLT_MONO_PAT1_ID 37
-#define S3V_BITBLT_MONO_PAT1_REG 0xA4EC
-#define S3V_BITBLT_PAT_BG_COLOR_ID 38
-#define S3V_BITBLT_PAT_BG_COLOR_REG 0xA4F0
-#define S3V_BITBLT_PAT_FG_COLOR_ID 39
-#define S3V_BITBLT_PAT_FG_COLOR_REG 0xA4F4
-#define S3V_BITBLT_CMDSET_ID 40
-#define S3V_BITBLT_CMDSET_REG 0xA500
-#define S3V_BITBLT_WIDTH_HEIGHT_ID 41
-#define S3V_BITBLT_WIDTH_HEIGHT_REG 0xA504
-#define S3V_BITBLT_SRC_X_Y_ID 42
-#define S3V_BITBLT_SRC_X_Y_REG 0xA508
-#define S3V_BITBLT_DEST_X_Y_ID 43
-#define S3V_BITBLT_DEST_X_Y_REG 0xA50C
-#define S3V_2DLINE_ID 44
-#define S3V_2DLINE_REG 0xA800
-#define S3V_2DPOLY_ID 45
-#define S3V_2DPOLY_REG 0xAC00
-
-/***************
- * 3DLINE REGS *
- ***************/
-/* base regs */
-#define S3V_3DLINE_ID 50
-#define S3V_3DLINE_REG 0xB000
-#define S3V_3DLINE_Z_BASE_ID 51
-#define S3V_3DLINE_Z_BASE_REG 0xB0D4
-#define S3V_3DLINE_SRC_BASE_ID 52 /* it is the same reg */
-#define S3V_3DLINE_SRC_BASE_REG 0xB0D4
-#define S3V_3DLINE_DEST_BASE_ID 53
-#define S3V_3DLINE_DEST_BASE_REG 0xB0D8
-#define S3V_3DLINE_CLIP_L_R_ID 54
-#define S3V_3DLINE_CLIP_L_R_REG 0xB0DC
-#define S3V_3DLINE_CLIP_T_B_ID 55
-#define S3V_3DLINE_CLIP_T_B_REG 0xB0E0
-#define S3V_3DLINE_DEST_SRC_STRIDE_ID 56
-#define S3V_3DLINE_DEST_SRC_STRIDE_REG 0xB0E4
-#define S3V_3DLINE_Z_STRIDE_ID 57
-#define S3V_3DLINE_Z_STRIDE_REG 0xB0E8
-#define S3V_3DLINE_TEX_BASE_ID 58
-#define S3V_3DLINE_TEX_BASE_REG 0xB0EC
-#define S3V_3DLINE_TEX_B_COLOR_ID 59
-#define S3V_3DLINE_TEX_B_COLOR_REG 0xB0F0
-#define S3V_3DLINE_FOG_COLOR_ID 60
-#define S3V_3DLINE_FOG_COLOR_REG 0xB0F4
-#define S3V_3DLINE_COLOR0_ID 61
-#define S3V_3DLINE_COLOR0_REG 0xB0F8
-#define S3V_3DLINE_COLOR1_ID 62
-#define S3V_3DLINE_COLOR1_REG 0xB0FC
-#define S3V_3DLINE_CMDSET_ID 63
-#define S3V_3DLINE_CMDSET_REG 0xB100 /* special */
-/* tex regs */
-/* FIXME: shouldn't it be a 1D tex for lines? */
-#define S3V_3DLINE_BASEV_ID 64
-#define S3V_3DLINE_BASEV_REG 0xB104
-#define S3V_3DLINE_BASEU_ID 65
-#define S3V_3DLINE_BASEU_REG 0xB108
-#define S3V_3DLINE_WXD_ID 66
-#define S3V_3DLINE_WXD_REG 0xB10C
-#define S3V_3DLINE_WYD_ID 67
-#define S3V_3DLINE_WYD_REG 0xB110
-#define S3V_3DLINE_WSTART_ID 68
-#define S3V_3DLINE_WSTART_REG 0xB114
-#define S3V_3DLINE_DXD_ID 69
-#define S3V_3DLINE_DXD_REG 0xB118
-#define S3V_3DLINE_VXD_ID 70
-#define S3V_3DLINE_VXD_REG 0xB11C
-#define S3V_3DLINE_UXD_ID 71
-#define S3V_3DLINE_UXD_REG 0xB120
-#define S3V_3DLINE_DYD_ID 72
-#define S3V_3DLINE_DYD_REG 0xB124
-#define S3V_3DLINE_VYD_ID 73
-#define S3V_3DLINE_VYD_REG 0xB128
-#define S3V_3DLINE_UYD_ID 74
-#define S3V_3DLINE_UYD_REG 0xB12C
-#define S3V_3DLINE_DSTART_ID 75
-#define S3V_3DLINE_DSTART_REG 0xB130
-#define S3V_3DLINE_VSTART_ID 76
-#define S3V_3DLINE_VSTART_REG 0xB134
-#define S3V_3DLINE_USTART_ID 77
-#define S3V_3DLINE_USTART_REG 0xB138
-/* gourad regs */
-#define S3V_3DLINE_GBD_ID 78
-#define S3V_3DLINE_GBD_REG 0xB144
-#define S3V_3DLINE_ARD_ID 79
-#define S3V_3DLINE_ARD_REG 0xB148
-#define S3V_3DLINE_GS_BS_ID 80
-#define S3V_3DLINE_GS_BS_REG 0xB14C
-#define S3V_3DLINE_AS_RS_ID 81
-#define S3V_3DLINE_AS_RS_REG 0xB150
-/* vertex regs */
-#define S3V_3DLINE_DZ_ID 82
-#define S3V_3DLINE_DZ_REG 0xB158
-#define S3V_3DLINE_ZSTART_ID 83
-#define S3V_3DLINE_ZSTART_REG 0xB15C
-#define S3V_3DLINE_XEND0_END1_ID 84
-#define S3V_3DLINE_XEND0_END1_REG 0xB16C
-#define S3V_3DLINE_DX_ID 85
-#define S3V_3DLINE_DX_REG 0xB170
-#define S3V_3DLINE_XSTART_ID 86
-#define S3V_3DLINE_XSTART_REG 0xB174
-#define S3V_3DLINE_YSTART_ID 87
-#define S3V_3DLINE_YSTART_REG 0xB178
-#define S3V_3DLINE_YCNT_ID 88
-#define S3V_3DLINE_YCNT_REG 0xB17C
-
-/**************
- * 3DTRI REGS *
- **************/
-/* base regs */
-#define S3V_3DTRI_ID 100
-#define S3V_3DTRI_REG 0xB400
-#define S3V_3DTRI_Z_BASE_ID 101
-#define S3V_3DTRI_Z_BASE_REG 0xB4D4
-#define S3V_3DTRI_SRC_BASE_ID 102 /* it is the same reg */
-#define S3V_3DTRI_SRC_BASE_REG 0xB4D4
-#define S3V_3DTRI_DEST_BASE_ID 103
-#define S3V_3DTRI_DEST_BASE_REG 0xB4D8
-#define S3V_3DTRI_CLIP_L_R_ID 104
-#define S3V_3DTRI_CLIP_L_R_REG 0xB4DC
-#define S3V_3DTRI_CLIP_T_B_ID 105
-#define S3V_3DTRI_CLIP_T_B_REG 0xB4E0
-#define S3V_3DTRI_DEST_SRC_STRIDE_ID 106
-#define S3V_3DTRI_DEST_SRC_STRIDE_REG 0xB4E4
-#define S3V_3DTRI_Z_STRIDE_ID 107
-#define S3V_3DTRI_Z_STRIDE_REG 0xB4E8
-#define S3V_3DTRI_TEX_BASE_ID 108
-#define S3V_3DTRI_TEX_BASE_REG 0xB4EC
-#define S3V_3DTRI_TEX_B_COLOR_ID 109
-#define S3V_3DTRI_TEX_B_COLOR_REG 0xB4F0
-#define S3V_3DTRI_FOG_COLOR_ID 110
-#define S3V_3DTRI_FOG_COLOR_REG 0xB4F4
-#define S3V_3DTRI_COLOR0_ID 111
-#define S3V_3DTRI_COLOR0_REG 0xB4F8
-#define S3V_3DTRI_COLOR1_ID 112
-#define S3V_3DTRI_COLOR1_REG 0xB4FC
-#define S3V_3DTRI_CMDSET_ID 113 /* special */
-#define S3V_3DTRI_CMDSET_REG 0xB500
-/* tex regs */
-#define S3V_3DTRI_BASEV_ID 114
-#define S3V_3DTRI_BASEV_REG 0xB504
-#define S3V_3DTRI_BASEU_ID 115
-#define S3V_3DTRI_BASEU_REG 0xB508
-#define S3V_3DTRI_WXD_ID 116
-#define S3V_3DTRI_WXD_REG 0xB50C
-#define S3V_3DTRI_WYD_ID 117
-#define S3V_3DTRI_WYD_REG 0xB510
-#define S3V_3DTRI_WSTART_ID 118
-#define S3V_3DTRI_WSTART_REG 0xB514
-#define S3V_3DTRI_DXD_ID 119
-#define S3V_3DTRI_DXD_REG 0xB518
-#define S3V_3DTRI_VXD_ID 120
-#define S3V_3DTRI_VXD_REG 0xB51C
-#define S3V_3DTRI_UXD_ID 121
-#define S3V_3DTRI_UXD_REG 0xB520
-#define S3V_3DTRI_DYD_ID 122
-#define S3V_3DTRI_DYD_REG 0xB524
-#define S3V_3DTRI_VYD_ID 123
-#define S3V_3DTRI_VYD_REG 0xB528
-#define S3V_3DTRI_UYD_ID 124
-#define S3V_3DTRI_UYD_REG 0xB52C
-#define S3V_3DTRI_DSTART_ID 125
-#define S3V_3DTRI_DSTART_REG 0xB530
-#define S3V_3DTRI_VSTART_ID 126
-#define S3V_3DTRI_VSTART_REG 0xB534
-#define S3V_3DTRI_USTART_ID 127
-#define S3V_3DTRI_USTART_REG 0xB538
-/* gourad regs */
-#define S3V_3DTRI_GBX_ID 128
-#define S3V_3DTRI_GBX_REG 0xB53C
-#define S3V_3DTRI_ARX_ID 129
-#define S3V_3DTRI_ARX_REG 0xB540
-#define S3V_3DTRI_GBY_ID 130
-#define S3V_3DTRI_GBY_REG 0xB544
-#define S3V_3DTRI_ARY_ID 131
-#define S3V_3DTRI_ARY_REG 0xB548
-#define S3V_3DTRI_GS_BS_ID 132
-#define S3V_3DTRI_GS_BS_REG 0xB54C
-#define S3V_3DTRI_AS_RS_ID 133
-#define S3V_3DTRI_AS_RS_REG 0xB550
-/* vertex regs */
-#define S3V_3DTRI_ZXD_ID 134
-#define S3V_3DTRI_ZXD_REG 0xB554
-#define S3V_3DTRI_ZYD_ID 135
-#define S3V_3DTRI_ZYD_REG 0xB558
-#define S3V_3DTRI_ZSTART_ID 136
-#define S3V_3DTRI_ZSTART_REG 0xB55C
-#define S3V_3DTRI_TXDELTA12_ID 137
-#define S3V_3DTRI_TXDELTA12_REG 0xB560
-#define S3V_3DTRI_TXEND12_ID 138
-#define S3V_3DTRI_TXEND12_REG 0xB564
-#define S3V_3DTRI_TXDELTA01_ID 139
-#define S3V_3DTRI_TXDELTA01_REG 0xB568
-#define S3V_3DTRI_TXEND01_ID 140
-#define S3V_3DTRI_TXEND01_REG 0xB56C
-#define S3V_3DTRI_TXDELTA02_ID 141
-#define S3V_3DTRI_TXDELTA02_REG 0xB570
-#define S3V_3DTRI_TXSTART02_ID 142
-#define S3V_3DTRI_TXSTART02_REG 0xB574
-#define S3V_3DTRI_TYS_ID 143
-#define S3V_3DTRI_TYS_REG 0xB578
-#define S3V_3DTRI_TY01_Y12_ID 144
-#define S3V_3DTRI_TY01_Y12_REG 0xB57C
-
-/* COMMANDS (to 0xB100 [lines] or 0xB500 [tris]) */
-
-/* Auto execute */
-#define AUTO_EXEC_MASK 0x00000001
-#define AUTO_EXEC_OFF (0x0)
-#define AUTO_EXEC_ON (0x1)
-/* HW clipping */
-#define HW_CLIP_MASK 0x00000002
-#define HW_CLIP_OFF (0x0 << 1)
-#define HW_CLIP_ON (0x1 << 1)
-/* Destination color */
-#define DEST_COL_MASK 0x0000001c
-#define DEST_COL_PAL (0x0 << 2) /* 8 bpp - palettized */
-#define DEST_COL_1555 (0x1 << 2) /* 16 bpp - ZRGB */
-#define DEST_COL_888 (0x2 << 2) /* 24 bpp - RGB */
-/* Texture color */
-#define TEX_COL_MASK 0x000000e0
-#define TEX_COL_ARGB8888 (0x0 << 5) /* 32 bpp - ARGB */
-#define TEX_COL_ARGB4444 (0x1 << 5) /* 16 bpp - ARGB */
-#define TEX_COL_ARGB1555 (0x2 << 5) /* 16 bpp - ARGB */
-#define TEX_COL_ALPHA4 (0x3 << 5) /* 8 bpp - ALPHA4 */
-#define TEX_COL_BLEND4_LOW (0x4 << 5) /* 4 bpp - BLEND4 low nibble */
-#define TEX_COL_BLEND4_HIGH (0x5 << 5) /* 4 bpp - BLEND4 high nibble */
-#define TEX_COL_PAL (0x6 << 5) /* 8 bpp - palettized */
-#define TEX_COL_YUV (0x7 << 5) /* 16 bpp - YUV */
-/* Mipmap level */
-#define MIP_MASK 0x00000f00
-#define MIPMAP_LEVEL(s) (s << 8) /* 8 -> 11 bits */
-/* Texture filtering */
-#define TEX_FILTER_MASK 0x00007000
-#define MIP_NEAREST (0x0 << 12)
-#define LINEAR_MIP_NEAREST (0x1 << 12)
-#define MIP_LINEAR (0x2 << 12)
-#define LINEAR_MIP_LINEAR (0x3 << 12)
-#define NEAREST (0x4 << 12)
-#define FAST_BILINEAR (0x5 << 12)
-#define LINEAR (0x6 << 12)
-/* Texture blending */
-#define TEX_BLEND_MAKS 0x00018000
-#define TEX_REFLECT (0x0 << 15)
-#define TEX_MODULATE (0x1 << 15)
-#define TEX_DECAL (0x2 << 15)
-/* Fog */
-#define FOG_MASK 0x00020000
-#define FOG_OFF (0x0 << 17)
-#define FOG_ON (0x1 << 17)
-/* Alpha blending */
-#define ALPHA_BLEND_MASK 0x000c0000
-#define ALPHA_OFF (0x0 << 18) | (0x0 << 19)
-#define ALPHA_TEX (0x2 << 18)
-#define ALPHA_SRC (0x3 << 18)
-/* Depth compare mode */
-#define Z_MODE_MASK 0x00700000
-#define Z_NEVER (0x0 << 20)
-#define Z_GREATER (0x1 << 20)
-#define Z_EQUAL (0x2 << 20)
-#define Z_GEQUAL (0x3 << 20)
-#define Z_LESS (0x4 << 20)
-#define Z_NOTEQUAL (0x5 << 20)
-#define Z_LEQUAL (0x6 << 20)
-#define Z_ALWAYS (0x7 << 20)
-/* Depth update */
-#define Z_UPDATE_MASK 0x00800000
-#define Z_UPDATE_OFF (0x0 << 23) /* disable z update */
-#define Z_UPDATE_ON (0x1 << 23)
-/* Depth buffering mode */
-#define Z_BUFFER_MASK 0x03000000
-#define Z_BUFFER (0x0 << 24) | (0x0 << 25)
-#define Z_MUX_BUF (0x1 << 24) | (0x0 << 25)
-#define Z_MUX_DRAW (0x2 << 24)
-#define Z_OFF (0x3 << 24) /* no z buffering */
-/* Texture wrapping */
-#define TEX_WRAP_MASK 0x04000000
-#define TEX_WRAP_OFF (0x0 << 26)
-#define TEX_WRAP_ON (0x1 << 26)
-/* 3d command */
-#define DO_MASK 0x78000000
-#define DO_GOURAUD_TRI (0x0 << 27)
-#define DO_TEX_LIT_TRI_OLD (0x1 << 27)
-#define DO_TEX_UNLIT_TRI_OLD (0x2 << 27)
-#define DO_TEX_LIT_TRI (0x5 << 27)
-#define DO_TEX_UNLIT_TRI (0x6 << 27)
-#define DO_3D_LINE (0x8 << 27)
-#define DO_NOP (0xf << 27) /* turn on autoexec */
-/* status */
-#define CMD_MASK 0x80000000
-#define CMD_2D (0x0 << 31) /* execute a 2d cmd */
-#define CMD_3D (0x1 << 31) /* execute a 3d cmd */
-
-/* global masks */
-#define TEX_MASK ( TEX_COL_MASK | TEX_WRAP_MASK | MIP_MASK \
- | TEX_FILTER_MASK | TEX_BLEND_MAKS \
- | TEX_WRAP_MASK )
-#define Z_MASK ( Z_MODE_MASK | Z_UPDATE_MASK | Z_BUFFER_MASK )
-
-#endif /* _S3V_REG_H */
diff --git a/src/mesa/drivers/dri/s3v/s3v_render.c b/src/mesa/drivers/dri/s3v/s3v_render.c
deleted file mode 100644
index 5023f3c4641..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_render.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-
-#include "tnl/t_context.h"
-
-#include "s3v_context.h"
-#include "s3v_tris.h"
-#include "s3v_vb.h"
-
-
-#define HAVE_POINTS 0
-#define HAVE_LINES 0
-#define HAVE_LINE_STRIPS 0
-#define HAVE_TRIANGLES 0
-#define HAVE_TRI_STRIPS 0
-#define HAVE_TRI_STRIP_1 0
-#define HAVE_TRI_FANS 0
-#define HAVE_QUADS 0
-#define HAVE_QUAD_STRIPS 0
-#define HAVE_POLYGONS 0
-
-#define HAVE_ELTS 0
-
-#if 0
-static void VERT_FALLBACK( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
- int _flags;
-
- DEBUG(("VERT_FALLBACK: flags & PRIM_MODE_MASK = %i\n",
- flags & PRIM_MODE_MASK));
- DEBUG(("VERT_FALLBACK: flags=%i PRIM_MODE_MASK=%i\n",
- flags, PRIM_MODE_MASK));
-#if 0
- tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
-#endif
- tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
-
- _flags = flags & PRIM_MODE_MASK;
-
- tnl->Driver.Render.PrimTabVerts[_flags]( ctx, start, count, flags );
- S3V_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS;
-}
-#endif
-
-static const GLuint hw_prim[GL_POLYGON+1] = {
- PrimType_Points,
- PrimType_Lines,
- PrimType_LineLoop,
- PrimType_LineStrip,
- PrimType_Triangles,
- PrimType_TriangleStrip,
- PrimType_TriangleFan,
- PrimType_Quads,
- PrimType_QuadStrip,
- PrimType_Polygon
-};
-
-static INLINE void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim )
-{
- __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
-
- int _hw_prim = hw_prim[prim];
-
- DEBUG(("s3vStartPrimitive (new #%i) ", prim));
-
- if (_hw_prim != vmesa->restore_primitive) {
-
- if (prim == 4) { /* TRI */
- DEBUG(("switching to tri\n"));
- vmesa->prim_cmd = vmesa->_tri[vmesa->_3d_mode];
- vmesa->alpha_cmd = vmesa->_alpha[vmesa->_3d_mode];
- DMAOUT_CHECK(3DTRI_Z_BASE, 12);
- } else if (prim == 1) { /* LINE */
- DEBUG(("switching to line\n"));
- vmesa->prim_cmd = DO_3D_LINE;
- vmesa->alpha_cmd = vmesa->_alpha[0];
- DMAOUT_CHECK(3DLINE_Z_BASE, 12);
- } else {
- DEBUG(("Never mind the bollocks!\n"));
- }
-
- DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8);
- DMAOUT(vmesa->DestBase);
- /* DMAOUT(vmesa->ScissorLR); */
- /* DMAOUT(vmesa->ScissorTB); */
- DMAOUT( (0 << 16) | (dPriv->w-1) );
- DMAOUT( (0 << 16) | (dPriv->h-1) );
- DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride );
- DMAOUT(vmesa->SrcStride);
- DMAOUT(vmesa->TexOffset);
- DMAOUT(vmesa->TextureBorderColor);
- DMAOUT(0); /* FOG */
- DMAOUT(0);
- DMAOUT(0);
- DMAOUT(vmesa->CMD | vmesa->prim_cmd | vmesa->alpha_cmd);
- DMAFINISH();
- }
-
- vmesa->restore_primitive = _hw_prim;
-}
-
-static INLINE void s3vEndPrimitive( s3vContextPtr vmesa )
-{
-/* GLcontext *ctx = vmesa->glCtx; */
- DEBUG(("s3vEndPrimitive\n"));
-}
-
-#define LOCAL_VARS s3vContextPtr vmesa = S3V_CONTEXT(ctx)
-#define INIT( prim ) s3vStartPrimitive( vmesa, prim )
-#define FINISH s3vEndPrimitive( vmesa )
-#define NEW_PRIMITIVE() (void) vmesa
-#define NEW_BUFFER() (void) vmesa
-#define FIRE_VERTICES() (void) vmesa
-#define GET_CURRENT_VB_MAX_VERTS() \
- (vmesa->bufSize - vmesa->bufCount) / 2
-#define GET_SUBSEQUENT_VB_MAX_VERTS() \
- S3V_DMA_BUF_SZ / 2
-/* XXX */
-#define ALLOC_VERTS(nr) NULL
-#define EMIT_VERTS(ctx, start, count, buf) NULL
-#define FLUSH() s3vEndPrimitive( vmesa )
-
-#define TAG(x) s3v_##x
-
-#include "tnl_dd/t_dd_dmatmp.h"
-
-/**********************************************************************/
-/* Render pipeline stage */
-/**********************************************************************/
-
-
-static GLboolean s3v_run_render( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLuint i;
- tnl_render_func *tab;
-
- DEBUG(("s3v_run_render\n"));
-
- /* FIXME: hw clip */
- if (VB->ClipOrMask || vmesa->RenderIndex != 0) {
- DEBUG(("*** CLIPPED in render ***\n"));
-#if 1
- return GL_TRUE; /* don't handle clipping here */
-#endif
- }
-
-
- /* We don't do elts */
- if (VB->Elts)
- return GL_TRUE;
-
- tab = TAG(render_tab_verts);
-
- tnl->Driver.Render.Start( ctx );
-
- for (i = 0 ; i < VB->PrimitiveCount ; i++ )
- {
- GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
- GLuint start = VB->Primitive[i].start;
- GLuint length = VB->Primitive[i].count;
-
- DEBUG(("s3v_run_render (loop=%i) (lenght=%i)\n", i, length));
-
- if (length) {
- tnl->Driver.Render.BuildVertices( ctx, start,
- start+length, ~0 /*stage->inputs*/); /* XXX */
- tnl->Driver.Render.PrimTabVerts[prim & PRIM_MODE_MASK]
- ( ctx, start, start + length, prim );
- vmesa->SetupNewInputs = VERT_BIT_POS;
- }
- }
-
- tnl->Driver.Render.Finish( ctx );
-
- return GL_FALSE; /* finished the pipe */
-}
-
-
-
-const struct tnl_pipeline_stage _s3v_render_stage =
-{
- "s3v render",
- NULL,
- NULL,
- NULL,
- NULL,
- s3v_run_render /* run */
-};
diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.c b/src/mesa/drivers/dri/s3v/s3v_screen.c
deleted file mode 100644
index f1810597e6f..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_screen.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_vb.h"
-#include "s3v_dri.h"
-
-s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv )
-{
- s3vScreenPtr s3vScreen;
- S3VDRIPtr vDRIPriv = (S3VDRIPtr)sPriv->pDevPriv;
-
-/* int i; */
-
- DEBUG(("s3vCreateScreen\n"));
- DEBUG(("sPriv->pDevPriv at %p\n", sPriv->pDevPriv));
- DEBUG(("size = %i\n", sizeof(*vDRIPriv)));
-
- if (sPriv->devPrivSize != sizeof(S3VDRIRec)) {
- fprintf(stderr,"\nERROR! sizeof(S3VDRIRec) does not match passed size from device driver\n");
- return GL_FALSE;
- }
-
- /* Allocate the private area */
- s3vScreen = (s3vScreenPtr) CALLOC( sizeof(*s3vScreen) );
- if ( !s3vScreen ) return NULL;
-
- s3vScreen->regionCount = 4; /* Magic number. Can we fix this? */
-
- s3vScreen->regions = _mesa_malloc(s3vScreen->regionCount *
- sizeof(s3vRegion));
- DEBUG(("sPriv->fd = %i\nvDRIPriv->dmaBufHandle = %x\n",
- sPriv->fd, vDRIPriv->dmaBufHandle));
-
- DEBUG(("vDRIPriv->dmaBufSize=%i\nvDRIPriv->dmaBuf=%p\n",
- vDRIPriv->dmaBufSize, vDRIPriv->dmaBuf));
-
-
- /* Get the list of dma buffers */
- s3vScreen->bufs = drmMapBufs(sPriv->fd);
-
- if (!s3vScreen->bufs) {
- DEBUG(("Helter/skelter with drmMapBufs\n"));
- return GL_FALSE;
- }
-
- s3vScreen->textureSize = vDRIPriv->texSize;
- s3vScreen->logTextureGranularity = vDRIPriv->logTextureGranularity;
- s3vScreen->cpp = vDRIPriv->cpp;
- s3vScreen->frontOffset = vDRIPriv->frontOffset;
- s3vScreen->frontPitch = vDRIPriv->frontPitch;
- s3vScreen->backOffset = vDRIPriv->backOffset;
- s3vScreen->backPitch = vDRIPriv->frontPitch; /* FIXME: check */
- s3vScreen->depthOffset = vDRIPriv->depthOffset;
- s3vScreen->depthPitch = vDRIPriv->frontPitch;
- s3vScreen->texOffset = vDRIPriv->texOffset;
-
- s3vScreen->driScreen = sPriv;
-
- DEBUG(("vDRIPriv->width =%i; vDRIPriv->deviceID =%x\n", vDRIPriv->width,
- vDRIPriv->deviceID));
- DEBUG(("vDRIPriv->mem =%i\n", vDRIPriv->mem));
- DEBUG(("vDRIPriv->fbOffset =%i\n", vDRIPriv->fbOffset));
- DEBUG((" ps3vDRI->fbStride =%i\n", vDRIPriv->fbStride));
- DEBUG(("s3vScreen->cpp = %i\n", s3vScreen->cpp));
- DEBUG(("s3vScreen->backOffset = %x\n", s3vScreen->backOffset));
- DEBUG(("s3vScreen->depthOffset = %x\n", s3vScreen->depthOffset));
- DEBUG(("s3vScreen->texOffset = %x\n", s3vScreen->texOffset));
- DEBUG(("I will return from s3vCreateScreen now\n"));
-
- DEBUG(("s3vScreen->bufs = 0x%x\n", s3vScreen->bufs));
- return s3vScreen;
-}
-
-/* Destroy the device specific screen private data struct.
- */
-void s3vDestroyScreen( __DRIscreenPrivate *sPriv )
-{
- s3vScreenPtr s3vScreen = (s3vScreenPtr)sPriv->private;
-
- DEBUG(("s3vDestroyScreen\n"));
-
- /* First, unmap the dma buffers */
-/*
- drmUnmapBufs( s3vScreen->bufs );
-*/
- /* Next, unmap all the regions */
-/* while (s3vScreen->regionCount > 0) {
-
- (void)drmUnmap(s3vScreen->regions[s3vScreen->regionCount].map,
- s3vScreen->regions[s3vScreen->regionCount].size);
- s3vScreen->regionCount--;
-
- }
- FREE(s3vScreen->regions); */
- if (s3vScreen)
- FREE(s3vScreen);
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.h b/src/mesa/drivers/dri/s3v/s3v_screen.h
deleted file mode 100644
index c49bc8587da..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_screen.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "main/mtypes.h"
-
-typedef struct _s3vRegion {
- drm_handle_t handle;
- drmSize size;
- drmAddress map;
-} s3vRegion, *s3vRegionPtr;
-
-typedef struct {
-
- int regionCount; /* Count of register regions */
- s3vRegion *regions; /* Vector of mapped region info */
-
- drmBufMapPtr bufs; /* Map of DMA buffers */
-
- __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
-
- int cpp;
- int frontPitch;
- int frontOffset;
-
- int backPitch;
- int backOffset;
- int backX;
- int backY;
-
- int depthOffset;
- int depthPitch;
-
- int texOffset;
- int textureOffset;
- int textureSize;
- int logTextureGranularity;
-} s3vScreenRec, *s3vScreenPtr;
-
diff --git a/src/mesa/drivers/dri/s3v/s3v_span.c b/src/mesa/drivers/dri/s3v/s3v_span.c
deleted file mode 100644
index f9f7c0d1eee..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_span.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_lock.h"
-
-#include "swrast/swrast.h"
-
-#define _SPANLOCK 1
-#define DBG 0
-
-#define LOCAL_VARS \
- s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
- __DRIscreenPrivate *sPriv = vmesa->driScreen; \
- __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
- driRenderbuffer *drb = (driRenderbuffer *) rb; \
- GLuint cpp = drb->cpp; \
- GLuint pitch = ( (drb->backBuffer) ? \
- ((dPriv->w+31)&~31) * cpp \
- : sPriv->fbWidth * cpp); \
- GLuint height = dPriv->h; \
- char *buf = (char *)(sPriv->pFB + drb->offset \
- + (drb->backBuffer ? 0 : dPriv->x * cpp + dPriv->y * pitch));\
- GLuint p; \
- (void) p
-
-/* FIXME! Depth/Stencil read/writes don't work ! */
-#define LOCAL_DEPTH_VARS \
- __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
- __DRIscreenPrivate *sPriv = vmesa->driScreen; \
- driRenderbuffer *drb = (driRenderbuffer *) rb; \
- GLuint pitch = drb->pitch; \
- GLuint height = dPriv->h; \
- char *buf = (char *)(sPriv->pFB + drb->offset); \
- (void) pitch
-
-#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-
-#define Y_FLIP( _y ) (height - _y - 1)
-
-#if _SPANLOCK /* OK, we lock */
-
-#define HW_LOCK() \
- s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
- (void) vmesa; \
- DMAFLUSH(); \
- S3V_SIMPLE_FLUSH_LOCK(vmesa);
-#define HW_UNLOCK() S3V_SIMPLE_UNLOCK(vmesa);
-
-#else /* plz, don't lock */
-
-#define HW_LOCK() \
- s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
- (void) vmesa; \
- DMAFLUSH();
-#define HW_UNLOCK()
-
-#endif
-
-
-/* ================================================================
- * Color buffer
- */
-
-/* 16 bit, RGB565 color spanline and pixel functions
- */
-#define INIT_MONO_PIXEL(p, color) \
- p = S3VIRGEPACKCOLOR555( color[0], color[1], color[2], color[3] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
-do { \
- *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 7) | \
- (((int)g & 0xf8) << 2) | \
- (((int)b & 0xf8) >> 3)); \
- DEBUG(("buf=0x%x drawOffset=0x%x dPriv->x=%i drb->cpp=%i dPriv->y=%i pitch=%i\n", \
- sPriv->pFB, vmesa->drawOffset, dPriv->x, drb->cpp, dPriv->y, pitch)); \
- DEBUG(("dPriv->w = %i\n", dPriv->w)); \
-} while(0)
-
-#define WRITE_PIXEL( _x, _y, p ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y ) \
- do { \
- GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
- rgba[0] = (p >> 7) & 0xf8; \
- rgba[1] = (p >> 2) & 0xf8; \
- rgba[2] = (p << 3) & 0xf8; \
- rgba[3] = 0xff; /*
- if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
- if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
- if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; */ \
- } while (0)
-
-#define TAG(x) s3v##x##_RGB555
-#include "spantmp.h"
-
-
-/* 32 bit, ARGB8888 color spanline and pixel functions
- */
-
-#undef INIT_MONO_PIXEL
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
- (g << 8) | \
- (r << 16) | \
- (a << 24) )
-
-#define WRITE_PIXEL( _x, _y, p ) \
- *(GLuint *)(buf + _x*4 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y ) \
-do { \
- GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \
- rgba[0] = (p >> 16) & 0xff; \
- rgba[1] = (p >> 8) & 0xff; \
- rgba[2] = (p >> 0) & 0xff; \
- rgba[3] = (p >> 24) & 0xff; \
-} while (0)
-
-#define TAG(x) s3v##x##_ARGB8888
-#include "spantmp.h"
-
-
-/* 16 bit depthbuffer functions.
- */
-#define VALUE_TYPE GLushort
-
-#define WRITE_DEPTH( _x, _y, d ) \
- *(GLushort *)(buf + _x*2 + _y*dPriv->w*2) = d
-
-#define READ_DEPTH( d, _x, _y ) \
- d = *(GLushort *)(buf + _x*2 + _y*dPriv->w*2);
-
-#define TAG(x) s3v##x##_z16
-#include "depthtmp.h"
-
-
-
-
-/* 32 bit depthbuffer functions.
- */
-#if 0
-#define VALUE_TYPE GLuint
-
-#define WRITE_DEPTH( _x, _y, d ) \
- *(GLuint *)(buf + _x*4 + _y*pitch) = d;
-
-#define READ_DEPTH( d, _x, _y ) \
- d = *(GLuint *)(buf + _x*4 + _y*pitch);
-
-#define TAG(x) s3v##x##_32
-#include "depthtmp.h"
-#endif
-
-
-/* 24/8 bit interleaved depth/stencil functions
- */
-#if 0
-#define VALUE_TYPE GLuint
-
-#define WRITE_DEPTH( _x, _y, d ) { \
- GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
- tmp &= 0xff; \
- tmp |= (d) & 0xffffff00; \
- *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
-}
-
-#define READ_DEPTH( d, _x, _y ) \
- d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff
-
-
-#define TAG(x) s3v##x##_24_8
-#include "depthtmp.h"
-
-#define WRITE_STENCIL( _x, _y, d ) { \
- GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
- tmp &= 0xffffff00; \
- tmp |= d & 0xff; \
- *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
-}
-
-#define READ_STENCIL( d, _x, _y ) \
- d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff
-
-#define TAG(x) s3v##x##_24_8
-#include "stenciltmp.h"
-
-#endif
-
-
-/**
- * Plug in the Get/Put routines for the given driRenderbuffer.
- */
-void
-s3vSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
-{
- if (drb->Base.InternalFormat == GL_RGBA) {
- if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
- s3vInitPointers_RGB555(&drb->Base);
- }
- else {
- s3vInitPointers_ARGB8888(&drb->Base);
- }
- }
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
- s3vInitDepthPointers_z16(&drb->Base);
- }
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
- /* not done yet */
- }
- else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
- /* not done yet */
- }
-}
diff --git a/src/mesa/drivers/dri/s3v/s3v_state.c b/src/mesa/drivers/dri/s3v/s3v_state.c
deleted file mode 100644
index 561f42c705f..00000000000
--- a/src/mesa/drivers/dri/s3v/s3v_state.c
+++ /dev/null
@@ -1,888 +0,0 @@
-/*
- * Author: Max Lingua <sunmax@libero.it>
- */
-
-#include "s3v_context.h"
-#include "s3v_macros.h"
-#include "s3v_dri.h"
-#include "main/macros.h"
-#include "main/colormac.h"
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "vbo/vbo.h"
-#include "tnl/tnl.h"
-
-/* #define DEBUG(str) printf str */
-#define ENABLELIGHTING 0
-
-
-/* =============================================================
- * Alpha blending
- */
-
-static void s3vUpdateAlphaMode( GLcontext *ctx )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- uint32_t cmd = vmesa->CMD;
- cmd &= ~ALPHA_BLEND_MASK;
-
- if ( ctx->Color.BlendEnabled ) {
- DEBUG(("ctx->Color.AlphaEnabled = 1"));
- vmesa->_alpha[0] = ALPHA_SRC;
- vmesa->_alpha[1] = vmesa->_alpha_tex; /* FIXME: not all tex modes
- support alpha */
- } else {
- DEBUG(("ctx->Color.AlphaEnabled = 0"));
- vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
- }
-#if 1
- if ((cmd & DO_MASK) & DO_3D_LINE) { /* we are drawing 3d lines */
- /* which don't support tex */
- cmd |= vmesa->_alpha[0];
- } else {
- cmd |= vmesa->_alpha[vmesa->_3d_mode];
- }
-
- vmesa->CMD = cmd; /* FIXME: enough? */
-#else
- vmesa->restore_primitive = -1;
-#endif
-
-}
-
-static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
- DEBUG(("s3vDDAlphaFunc\n"));
-
- vmesa->new_state |= S3V_NEW_ALPHA;
-}
-
-static void s3vDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
- DEBUG(("s3vDDBlendFunc\n"));
-
- vmesa->new_state |= S3V_NEW_ALPHA;
-}
-
-/* ================================================================
- * Buffer clear
- */
-
-static void s3vDDClear( GLcontext *ctx, GLbitfield mask )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- unsigned int _stride;
- GLint cx = ctx->DrawBuffer->_Xmin;
- GLint cy = ctx->DrawBuffer->_Ymin;
- GLint cw = ctx->DrawBuffer->_Xmax - cx;
- GLint ch = ctx->DrawBuffer->_Ymax - cy;
-
- /* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */
-
- vmesa->restore_primitive = -1;
-
- /* Update and emit any new state. We need to do this here to catch
- * changes to the masks.
- * FIXME: Just update the masks?
- */
-
- if ( vmesa->new_state )
- s3vDDUpdateHWState( ctx );
-
-/* s3vUpdateMasks( ctx ); */
-/* s3vUpdateClipping( ctx ); */
-/* s3vEmitHwState( vmesa ); */
-
-
-#if 1 /* soft (0)/hw (1)*/
-
- DEBUG(("*** s3vDDClear ***\n"));
-
- DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
- DMAOUT(vmesa->SrcBase);
- DMAOUT(vmesa->DestBlit);
- DMAOUT( vmesa->ScissorLR );
- DMAOUT( vmesa->ScissorTB );
- DMAOUT( (vmesa->SrcStride << 16) | vmesa->SrcStride ); /* FIXME: unify */
- DMAOUT( (~(0)) ); /* masks */
- DMAOUT( (~(0)) );
- DMAOUT(0);
- DMAOUT(vmesa->ClearColor);
- DMAOUT(0);
- DMAOUT(0);
- /* FIXME */
- DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); /* black magic to me */
- DMAOUT(vmesa->ScissorWH);
- DMAOUT(vmesa->SrcXY);
- DMAOUT(vmesa->DestXY);
- DMAFINISH();
-
- if (mask & BUFFER_BIT_DEPTH) { /* depth */
- DEBUG(("BUFFER_BIT_DEPTH\n"));
-
- _stride = ((cw+31)&~31) * 2; /* XXX cw or Buffer->Width??? */
-
- DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
- DMAOUT(0);
- DMAOUT(vmesa->s3vScreen->depthOffset);
- DMAOUT( (0 << 16) | cw );
- DMAOUT( (0 << 16) | ch );
- DMAOUT( (vmesa->SrcStride << 16) | vmesa->DestStride );
- DMAOUT( (~(0)) ); /* masks */
- DMAOUT( (~(0)) );
- DMAOUT(0);
- DMAOUT(vmesa->ClearDepth); /* 0x7FFF */
- /* FIXME */
- DMAOUT(0);
- DMAOUT(0);
- DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));
- DMAOUT( ((cw-1) << 16) | (ch-1) );
- DMAOUT(0);
- DMAOUT( (0 << 16) | 0 );
- DMAFINISH();
-
- DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth));
- mask &= ~BUFFER_BIT_DEPTH;
- }
-
- if (!vmesa->NotClipped) {
- DEBUG(("vmesa->NotClipped\n")); /* yes */
- }
-
- if (!(vmesa->EnabledFlags & S3V_BACK_BUFFER)) {
- DEBUG(("!S3V_BACK_BUFFER -> flush\n"));
- DMAFLUSH();
- }
-/*
- if ( mask )
- DEBUG(("still masked ;3(\n")); */ /* yes */
-#else
- _swrast_Clear( ctx, mask );
-#endif
-}
-
-/* =============================================================
- * Depth testing
- */
-
-static void s3vUpdateZMode( GLcontext *ctx )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- uint32_t cmd = vmesa->CMD;
-
- DEBUG(("Depth.Test = %i\n", ctx->Depth.Test));
- DEBUG(("CMD was = 0x%x ", cmd));
-
-/* printf("depth --- CMD was = 0x%x \n", cmd); */
-
- cmd &= ~Z_MASK; /* 0xfc0fffff; */
- /* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */
-
- if (!ctx->Depth.Test)
- cmd |= Z_OFF;
-
- if ( ctx->Depth.Mask )
- cmd |= Z_UPDATE_ON;
-
- switch ( ctx->Depth.Func ) {
- case GL_NEVER:
- cmd |= Z_NEVER;
- break;
- case GL_ALWAYS:
- cmd |= Z_ALWAYS;
- break;
- case GL_LESS:
- cmd |= Z_LESS;
- break;
- case GL_LEQUAL:
- cmd |= Z_LEQUAL;
- break;
- case GL_EQUAL:
- cmd |= Z_EQUAL;
- break;
- case GL_GEQUAL:
- cmd |= Z_GEQUAL;
- break;
- case GL_GREATER:
- cmd |= Z_GREATER;
- break;
- case GL_NOTEQUAL:
- cmd |= Z_NOTEQUAL;
- break;
- }
-
- DEBUG(("CMD is 0x%x\n", cmd));
-
- vmesa->dirty |= S3V_UPLOAD_DEPTH;
- vmesa->CMD = cmd;
-}
-
-static void s3vDDDepthFunc( GLcontext *ctx, GLenum func )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-/* FLUSH_BATCH( vmesa ); */
- DEBUG(("s3vDDDepthFunc\n"));
- vmesa->new_state |= S3V_NEW_DEPTH;
-}
-
-static void s3vDDDepthMask( GLcontext *ctx, GLboolean flag )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
- /* FLUSH_BATCH( vmesa ); */
- DEBUG(("s3vDDDepthMask\n"));
- vmesa->new_state |= S3V_NEW_DEPTH;
-}
-
-static void s3vDDClearDepth( GLcontext *ctx, GLclampd d )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
- switch ( vmesa->DepthSize ) {
- case 15:
- case 16:
- vmesa->ClearDepth = d * 0x0000ffff; /* 65536 */
- DEBUG(("GLclampd d = %f\n", d));
- DEBUG(("ctx->Depth.Clear = %f\n", ctx->Depth.Clear));
- DEBUG(("(They should be the same)\n"));
- break;
- case 24:
- vmesa->ClearDepth = d * 0x00ffffff;
- break;
- case 32:
- vmesa->ClearDepth = d * 0xffffffff;
- break;
- }
-}
-
-static void s3vDDFinish( GLcontext *ctx )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- DMAFLUSH();
-}
-
-static void s3vDDFlush( GLcontext *ctx )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- DMAFLUSH();
-}
-
-/* =============================================================
- * Fog
- */
-
-static void s3vUpdateFogAttrib( GLcontext *ctx )
-{
-/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
-
- if (ctx->Fog.Enabled) {
- } else {
- }
-
- switch (ctx->Fog.Mode) {
- case GL_LINEAR:
- break;
- case GL_EXP:
- break;
- case GL_EXP2:
- break;
- }
-}
-
-static void s3vDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
-{
- s3vContextPtr vmesa = S3V_CONTEXT(ctx);
- vmesa->new_state |= S3V_NEW_FOG;
-}
-
-/* =============================================================
- * Lines
- */
-static void s3vDDLineWidth( GLcontext *ctx, GLfloat width )
-{
- /* FIXME: on virge you only have one size of 3d lines *
- * if we wanted more, we should start using tris instead *
- * but virge has problem with some tris when all of the *
- * vertices stay on a line */
-}
-
-/* =============================================================
- * Points