Compare commits

..

641 Commits

Author SHA1 Message Date
Chih-Wei Huang
f189dfe9e9 mesa: fix compiling issues with gcc 4.4.x
Gcc 4.4 requires a class with virtual functions has to
define the virtual destructor.
2010-12-29 17:35:47 +08:00
Chia-I Wu
d1ccafa5b7 android: Enable OpenGL ES 2.0. 2010-12-29 16:56:47 +08:00
Chia-I Wu
f7a0636329 i965: Add support for GL_FIXED. 2010-12-11 21:47:18 +08:00
Chih-Wei Huang
6269411b81 android: enable support of i965c 2010-12-09 20:01:35 -05:00
Chia-I Wu
88721c8555 android: Add Android.mk's. 2010-12-09 20:01:35 -05:00
Chia-I Wu
4128957d30 android: Add pre-generated files. 2010-12-09 20:01:35 -05:00
Chia-I Wu
07a8209c3f android: Add __DRI_IMAGE_FORMAT_RGBA8888_REV. 2010-12-09 20:01:35 -05:00
Chia-I Wu
b0a79b3512 android: Add DRM-based gralloc. 2010-12-09 20:01:35 -05:00
Chia-I Wu
121fc671f4 android: Add new classic EGL driver for Android. 2010-12-09 20:01:35 -05:00
Chia-I Wu
8148db591a android: Add android backend for st/egl. 2010-12-09 20:01:35 -05:00
Chia-I Wu
0d4dcb2584 android: Add Android EGL extensions. 2010-12-09 20:01:35 -05:00
Chia-I Wu
1337551451 android: Add _EGL_PLATFORM_ANDROID. 2010-12-09 20:01:35 -05:00
Chia-I Wu
6719d59a85 android: Enable extensions required by ES1 for i915c. 2010-12-09 20:01:35 -05:00
Chia-I Wu
3fe7753b70 android: Fix depth/stencil with i915c. 2010-12-09 20:01:34 -05:00
Chia-I Wu
017c563cff android: Fix GL_OES_EGL_image with SurfaceFlinger. 2010-12-09 20:01:34 -05:00
Chia-I Wu
bf21df37c6 android: Use __mmap2 in winsys/svga. 2010-12-09 20:01:34 -05:00
Chia-I Wu
17935c0191 android: Fix build with bionic. 2010-12-09 20:01:34 -05:00
Chia-I Wu
7aceb74db7 i915c: Add GL_OES_draw_texture support. 2010-12-09 20:01:34 -05:00
Chia-I Wu
88e9712a68 tnl: Add support for GL_FIXED. 2010-12-09 20:01:34 -05:00
Chia-I Wu
2e9e27c0f7 i915: Free with FREE. 2010-12-09 19:39:22 -05:00
Chia-I Wu
455a7585de targets/egl-gdi: Optional support for DRM screen. 2010-12-09 19:39:22 -05:00
Chia-I Wu
25ed79d830 Revert "egl: Drop broken _EGL_PLATFORM_NO_OS code"
This reverts commit 021a68b7e8.
2010-12-09 19:39:22 -05:00
Chia-I Wu
0c0eda393a mesa: Fix glTexCoordPointer with type GL_FIXED.
GL_FIXED is also a legal type for glTexCoordPointer.
2010-12-09 19:37:56 +08:00
Chia-I Wu
2d270ac090 mesa: Fix GL_FIXED arrays.
It is broken since 433e5e6def.
2010-12-09 19:25:05 +08:00
Eric Anholt
05e534e6c4 i965: Drop push-mode reladdr constant loading and always use constant_map.
This eases the gen6 implementation, which can only handle up to 32
registers of constants, while likely not penalizing real apps using
reladdr since all of those I've seen also end up hitting the pull
constant buffer.  On gen6, the constant map means that simple NV VPs
fit under the 32-reg limit and now succeed.  Fixes around 10 testcases.
2010-12-08 22:26:18 -08:00
Alex Deucher
fd543e1f95 radeon: bump mip tree levels to 15
I forgot to bump this when I bumped the tex levels.
2010-12-09 00:16:02 -05:00
Brian Paul
09a5e028a6 mesa: simplify target checking for TexImage functions 2010-12-08 21:38:35 -07:00
Brian Paul
7404fa3f07 mesa: revamp error checking for compressed texture images
Simplify some code, remove unneeded checks, etc.
2010-12-08 21:38:35 -07:00
Chad Versace
f0f2ec4d8a glsl: In ast_to_hir, check sampler array indexing
Raise error if a sampler array is indexed with a non-constant expression.

From section 4.1.7 of the GLSL 1.30 spec:
  "Samplers aggregated into arrays within a shader (using square
  brackets [ ]) can only be indexed with integral constant
  expressions [...]."
2010-12-08 18:53:53 -08:00
Eric Anholt
d547ab150a i965: Drop KIL_NV from the ff/ARB_fp path since it was only used for GLSL. 2010-12-08 11:14:52 -08:00
Eric Anholt
dba6fde08c i965: Use the new pixel mask location for gen6 ARB_fp KIL instructions.
Fixes:
fp-kil
fp-generic/kil-swizzle.
2010-12-08 11:14:35 -08:00
Eric Anholt
39eaacff14 i965: Set the render target index in gen6 fixed-function/ARB_fp path.
Fixes:
fbo-drawbuffers2-blend
fbo-drawbuffers2-colormask
2010-12-08 10:51:04 -08:00
Eric Anholt
4b4dc778b6 i965: Set up the per-render-target blend state on gen6.
This will let us get EXT_draw_buffers2 blending and colormasking working.
2010-12-08 10:50:57 -08:00
Eric Anholt
0d3b8a5cc2 i965: Set up the color masking for the first drawbuffer on gen6.
Fixes glean/maskedClear
2010-12-08 09:53:16 -08:00
Chia-I Wu
d2028ba339 mesa: Do not advertise GL_OES_texture_3D.
GL_OES_texture_3D has a GLSL counterpart.  Since it is not implemented,
GL_OES_texture_3D should not be advertised.
2010-12-08 22:35:40 +08:00
Chia-I Wu
98ee6739d9 vbo: Fix GLES2 glVertexAttrib.
Attribute 0 has no special meaning in GLES2.  Add VertexAttrib4f_nopos
for that purpose and make _es_VertexAttrib* call the new function.

Rename _vbo_* to _es_* to avoid confusion.  These functions are only
used by GLES, and now some of them (_es_VertexAttrib*) even behave
differently than vbo_VertexAttrib*.
2010-12-08 22:19:19 +08:00
Chia-I Wu
9f0d7dd259 vbo: Drop second ATTR macro.
There is no need to have a special version of ATTR for
!FEATURE_beginend, since 81ccb3e2ce.
2010-12-08 22:18:37 +08:00
Brian Paul
7da704ee72 configure: use llvm-config --cppflags instead of --cflags 2010-12-08 06:45:00 -07:00
Brian Paul
c64447f47d mesa: make _mesa_test_proxy_teximage() easier to read 2010-12-07 21:37:20 -07:00
Brian Paul
4ff70b7a8f mesa: consolidate glCompressedTexImage1/2/3D() functions 2010-12-07 21:37:20 -07:00
Brian Paul
1c23b860ce mesa: consolidate glCopyTexSubImage1/2/3D() functions 2010-12-07 21:37:20 -07:00
Brian Paul
11f386fb50 mesa: consolidate glCopyTexImage1/2D() code 2010-12-07 21:37:19 -07:00
Brian Paul
45124e043d mesa: consolidate the glTexSubImage1/2/3D() functions 2010-12-07 21:37:19 -07:00
Brian Paul
35f620d55c mesa: simplify proxy texture code in texture_error_check() 2010-12-07 21:37:19 -07:00
Marek Olšák
c4f9e55d61 r300/compiler: remove at least unused immediates if externals cannot be removed 2010-12-08 04:39:51 +01:00
Marek Olšák
2ff9d4474b r300/compiler: make lowering passes possibly use up to two less temps
CMP may now use two less temps, other non-native instructions may end up
using one less temp, except for SIN/COS/SCS, which I am leaving unchanged
for now.

This may reduce register pressure inside loops, because the register
allocator doesn't do a very good job there.
2010-12-08 04:39:51 +01:00
Marek Olšák
93f2df0760 r300/compiler: handle DPH and XPD in rc_compute_sources_for_writemask
This bug can only be triggered if you put deadcode before native rewrite.
2010-12-08 04:39:50 +01:00
Marek Olšák
95080fb50f r300/compiler: do not print pair/tex/presub program stats for vertex shaders 2010-12-08 04:39:50 +01:00
Marek Olšák
8fac29d49e r300/compiler: cleanup rc_run_compiler 2010-12-08 04:39:50 +01:00
Marek Olšák
2592a8f506 r300/compiler: add a function to query program stats (alu, tex, temps..) 2010-12-08 04:39:50 +01:00
Marek Olšák
431b4c0c84 r300/compiler: don't terminate regalloc if we surpass max temps limit
The same check is already in a later pass (translate_vertex_program).
2010-12-08 04:39:50 +01:00
Eric Anholt
2f07a744f1 i965: Don't try to store gen6 (float) blend constant color in bytes.
Fixes glean/blendFunc
2010-12-07 19:33:47 -08:00
Ian Romanick
002cd2c8d4 linker: Fix regressions caused by previous commit
That's what I get for not running piglit before pushing.

Don't try to patch types of unsized arrays when linking fails.

Don't try to patch types of unsized arrays that are shared between
shader stages.
2010-12-07 19:00:44 -08:00
Ian Romanick
6f53921c4b linker: Ensure that unsized arrays have a size after linking
Fixes piglit test case glsl-vec-array (bugzilla #31908).

NOTE: This bug does not affect 7.9, but I think this patch is a
candiate for the 7.9 branch anyway.
2010-12-07 18:32:16 -08:00
Eric Anholt
b2167a6c01 i965: Fix flipped value of the not-embedded-in-if on gen6.
Fixes:
glean/glsl1-! (not) operator (1, fail)
glean/glsl1-! (not) operator (1, pass)
2010-12-07 17:46:47 -08:00
Ian Romanick
b0fc5103cb glsl: Inherrit type of declared variable from initializer
Types of declared variables and their initializer must match excatly
except for unsized arrays.  Previously the type inherritance for
unsized arrays happened implicitly in the emitted assignment.
However, this assignment is never emitted for uniforms.  Now that type
is explicitly copied unconditionally.

Fixes piglit test array-compare-04.vert (bugzilla #32035) and
glsl-array-uniform-length (bugzilla #31985).

NOTE: This is a candidate for the 7.9 branch.
2010-12-07 16:36:44 -08:00
Eric Anholt
7ca7e9b626 i965: Work around gen6 ignoring source modifiers on math instructions.
With the change of extended math from having the arguments moved into
mrfs and handed off through message passing to being directly hooked
up to the EU, it looks like the piece for doing source modifiers
(negate and abs) was left out.

Fixes:
fog-modes
glean/fp1-ARB_fog_exp test
glean/fp1-ARB_fog_exp2 test
glean/fp1-Computed fog exp test
glean/fp1-Computed fog exp2 test
ext_fog_coord-modes
2010-12-07 15:11:27 -08:00
Eric Anholt
2d7dfb8446 i965: Add disabled debug code for dumping out the WM constant payload.
This can significantly ease thinking about the asm.
2010-12-07 15:11:27 -08:00
Ian Romanick
6848e27e14 i965: Correctly emit constants for aggregate types (array, matrix, struct)
Previously the code only handled scalars and vectors.  This new code
is modeled somewhat after similar code in ir_to_mesa.

Reviewed-by: Eric Anholt <eric@anholt.net>
2010-12-07 15:03:14 -08:00
Jerome Glisse
b7617346dc r600g: fix userspace fence against lastest kernel
R6XX GPU doesn't like to have two partial flush writting
back to memory in row without a prior flush of the pipeline.
Add PS_PARTIAL_FLUSH to flush all work between the CP and
the ES, GS, VS, PS shaders.

Thanks a lot to Alban Browaeys (prahal on irc) for investigating
this issue.

Signed-off-by: Alban Browaeys <prahal@yahoo.com>
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-07 17:54:56 -05:00
Jerome Glisse
69251fc4cd r600g: remove dead code
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-07 16:14:18 -05:00
Eric Anholt
fa0d5a2c5b i965: Always hand the absolute value to RSQ.
gen6 builtin RSQ apparently clamps negative values to 0 instead of
returning the RSQ of the absolute value like ARB_fragment_program
desires and pre-gen6 apparently does.

Fixes:
glean/fp1-RSQ test 2 (reciprocal square root of negative value)
glean/vp1-RSQ test 2 (reciprocal square root of negative value)
2010-12-07 13:13:27 -08:00
Ian Romanick
6d36be508f glsl: Ensure that equality comparisons don't return a NULL IR tree
This fixes bugzilla #32035 and piglit test case array-compare-01 and
array-compare-02.

NOTE: This is a candidate for the 7.9 branch.
2010-12-07 12:50:38 -08:00
Eric Anholt
72845d206e i965: Handle saturates on gen6 math instructions.
We get saturate as an argument to brw_math() instead of as compile
state, since that's how the pre-gen6 send instructions work.  Fixes
fp-ex2-sat.
2010-12-07 12:21:08 -08:00
Eric Anholt
ed492e9544 i965: Fix comment about gen6_wm_constants.
This is the push constant buffer, not the pull constants.
2010-12-07 12:21:08 -08:00
Kenneth Graunke
bd74101aeb Refresh autogenerated glcpp parser. 2010-12-07 10:52:59 -08:00
Kenneth Graunke
800eed6765 glcpp: Don't emit SPACE tokens in conditional_tokens production.
Fixes glslparsertest defined-01.vert.

Reported-by: José Fonseca <jfonseca@vmware.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2010-12-07 10:52:36 -08:00
Marek Olšák
d8b861987d r300g: also revalidate the SWTCL vertex buffer after its reallocation 2010-12-07 19:26:28 +01:00
Zhenyu Wang
27609a8267 i965: upload WM state for _NEW_POLYGON on sandybridge
Be sure polygon stipple mode is updated. This fixes 'gamma' demo.
2010-12-07 17:05:02 +08:00
Vinson Lee
6ee415cc6d r200: Silence uninitialized variable warning.
Fixes this GCC warning.
r200_maos_arrays.c: In function 'r200EmitArrays':
r200_maos_arrays.c:113: warning: 'emitsize' may be used uninitialized in this function
2010-12-07 00:58:54 -08:00
Xiang, Haihao
5ff6ed2b97 i965: set minimum/maximum Point Width on Sandybridge
It is used for point width on vertex. This fixes mesa demo spriteblast and pointblast.
2010-12-07 16:43:24 +08:00
Vinson Lee
dda3ccba8c mesa: Clean up header file inclusion in viewport.h. 2010-12-07 00:37:48 -08:00
Vinson Lee
dbd3f72662 mesa: Clean up header file inclusion in varray.h. 2010-12-07 00:33:36 -08:00
Vinson Lee
2aa36f78dc mesa: Clean up header file inclusion in transformfeedback.h. 2010-12-07 00:28:57 -08:00
Vinson Lee
8cc3d411ed mesa: Clean up header file inclusion in texrender.h. 2010-12-07 00:19:06 -08:00
Marek Olšák
4953ba6a71 r300g: validate buffers only if any of bound buffers is changed
This prevents needless buffer validation (CS space checking).
2010-12-07 08:46:18 +01:00
Marek Olšák
78068a5fbf r300g: cache packet dwords of 3D_LOAD_VBPNTR in a command buffer if possible
It's not always possible to preprocess the content of 3D_LOAD_VBPNTR
in a command buffer, because the offset to all vertex buffers (which
the packet depends on) is derived from the "start" parameter of draw_arrays
and the "indexBias" parameter of draw_elements, but we can at least lazily
make a command buffer for the case when offset == 0, which should occur
most of the time.
2010-12-07 06:42:05 +01:00
Marek Olšák
857d107bfe u_blitter: use util_is_format_compatible in the assert 2010-12-07 06:22:38 +01:00
Brian Paul
d0b2b8da7d mesa: consolidate glTexImage1/2/3D() code
Something similar could be done for glCopyTex[Sub]Image() and the
compressed texture image functions as well.
2010-12-06 17:10:05 -07:00
Brian Paul
6dca66b620 mesa: set gl_texture_object::_Complete=FALSE in incomplete() 2010-12-06 17:10:05 -07:00
Brian Paul
ecb7cc3319 mesa: test for cube map completeness in glGenerateMipmap()
The texture is not cube complete if the base level images aren't of
the same size and format.

NOTE: This is a candidate for the 7.9 branch.
2010-12-06 17:10:05 -07:00
Kenneth Graunke
c17c790387 glsl: Properly add functions during lazy built-in prototype importing.
The original lazy built-in importing patch did not add the newly created
function to the symbol table, nor actually emit it into the IR stream.

Adding it to the symbol table is non-trivial since importing occurs when
generating some ir_call in a nested scope.  A new add_global_function
method, backed by new symbol_table code in the previous patch, handles
this.

Fixes bug #32030.
2010-12-06 13:43:22 -08:00
Kenneth Graunke
a8f52647b0 symbol_table: Add support for adding a symbol at top-level/global scope. 2010-12-06 13:43:22 -08:00
Kenneth Graunke
6fae1e4c4d glsl: Factor out code which emits a new function into the IR stream.
A future commit will use the newly created function in a second place.
2010-12-06 13:43:22 -08:00
Jakob Bornecrantz
d72cb9c94d st/mesa: Unbind all constant buffers 2010-12-06 22:10:49 +01:00
Jerome Glisse
e0d554ab78 r600g: remove useless flush map
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-06 15:50:50 -05:00
Jerome Glisse
afc56b1861 r600g: avoid useless shader rebuild at draw call
Avoid rebuilding constant shader state at each draw call,
factor out spi update that might change at each draw call.
Best would be to update spi only when revealent states
change (likely only flat shading & sprite point).

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-06 15:50:50 -05:00
Jerome Glisse
fa86fc564a r600g: build fetch shader from vertex elements
Vertex elements change are less frequent than draw call, those to
avoid rebuilding fetch shader to often build the fetch shader along
vertex elements. This also allow to move vertex buffer setup out
of draw path and make update to it less frequent.

Shader update can still be improved to only update SPI regs (based
on some rasterizer state like flat shading or point sprite ...).

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-06 15:50:50 -05:00
José Fonseca
a9fa0f3a2f mesa: Bump the number of bits in the register index.
More than 1023 temporaries were being used for a Cinebench shader before
doing temporary optimization, causing the index value to wrap around to
-1024.
2010-12-06 20:03:51 +00:00
Brian Paul
cae2bb76c1 st/mesa: fix mipmap generation bug
In st_finalize_texture() we were looking at the st_texture_object::
lastLevel field instead of the pipe_resource::last_level field to
determine which resource to store the mipmap in.

Then, in st_generate_mipmap() we need to call st_finalize_texture() to
make sure the destination resource is properly allocated.

These changes fix the broken piglit fbo-generatemipmap-formats test.
2010-12-06 11:01:21 -07:00
Brian Paul
c1095f0b0c mesa/llvm: use llvm-config --cppflags
Use --cppflags instead of --cflags so that we get the -I and -D flags
we want, but not compiler options like -O3.

A similar change should probably be made for autoconf.
2010-12-06 10:11:00 -07:00
Brian Paul
4fc62a074c gallium/util: minor formatting fixes 2010-12-06 09:46:45 -07:00
Brian Paul
b89a731ff2 mesa: add error margin to clip mask debug/check code
When X or Y or Z is close to W the outcome of the floating point clip
test comparision may be different between the C and x86 asm paths.
That's OK; don't report an error.

See fd.o bug 32093
2010-12-06 09:46:01 -07:00
Eric Anholt
4538ce915b i965: Remove INTEL_DEBUG=glsl_force now that there's no brw_wm_glsl.c 2010-12-06 00:14:23 -08:00
Eric Anholt
5ba517baa2 i965: Nuke brw_wm_glsl.c.
It was only used for gen6 fragment programs (not GLSL shaders) at this
point, and it was clearly unsuited to the task -- missing opcodes,
corrupted texturing, and assertion failures hit various applications
of all sorts.  It was easier to patch up the non-glsl for remaining
gen6 changes than to make brw_wm_glsl.c complete.

Bug #30530
2010-12-06 00:14:23 -08:00
Eric Anholt
245662f308 i965: Add support for the instruction compression bits on gen6.
Since the 8-wide first-quarter and 16-wide first-half have the same
bit encoding, we now need to track "do you want instruction
compression" in the compile state.
2010-12-06 00:14:23 -08:00
Eric Anholt
3f8bcb0d99 i965: Align gen6 push constant size to dispatch width.
The FS backend is fine with register level granularity.  But for the
brw_wm_emit.c backend, it expects pairs of regs to be used for the
constants, because the whole world is pairs of regs.  If an odd number
got used, we went looking for interpolation in the wrong place.
2010-12-06 00:14:23 -08:00
Eric Anholt
237aa33c67 i965: Make the sampler's implied move on gen6 be a raw move.
We were accidentally doing a float-to-uint conversion.
2010-12-06 00:14:23 -08:00
Eric Anholt
5340dd8cca i965: Fix up gen6 samplers for their usage by brw_wm_emit.c
We were trying to do the implied move even when we'd already manually
moved the real header in place.
2010-12-06 00:14:22 -08:00
Eric Anholt
ad29e79850 i965: Fix gen6 interpolation setup for 16-wide.
In the SF and brw_fs.cpp fixes to set up interpolation sanely on gen6,
the setup for 16-wide interpolation was left behind.  This brings
relative sanity to that path too.
2010-12-06 00:14:22 -08:00
Eric Anholt
ae0df25ab4 i965: Don't smash a group of coordinates doing gen6 16-wide sampler headers. 2010-12-06 00:14:22 -08:00
Eric Anholt
d1ead22d1b i965: Fix up 16-wide gen6 FB writes after various refactoring. 2010-12-06 00:14:22 -08:00
Eric Anholt
ad35528944 i965: Provide delta_xy reg to gen6 non-GLSL path PINTERP.
Fixes many assertion failures in that path.
2010-12-06 00:14:22 -08:00
Eric Anholt
16f8c82389 i965: Move payload reg setup to compile, not lookup time.
Payload reg setup on gen6 depends more on the dispatch width as well
as the uses_depth, computes_depth, and other flags.  That's something
we want to decide at compile time, not at cache lookup.  As a bonus,
the fragment shader program cache lookup should be cheaper now that
there's less to compute for the hash key.
2010-12-06 00:14:22 -08:00
Chia-I Wu
8f2a974cf2 mapi: Rewrite mapi_abi.py to get rid of preprocessor magic.
The preprocessor magic in mapi was nothing but obfuscation.  Rewrite
mapi_abi.py to generate real C code.

This commit removes the hack added in
43121f2086.
2010-12-06 15:40:37 +08:00
Chia-I Wu
5ae4b6693a egl: _eglFilterArray should not allocate.
Otherwise, when it is called from within a driver, the caller cannot
free the returned data (on Windows).
2010-12-06 15:40:37 +08:00
Zhenyu Wang
2b1469340b i965: Fix GS state uploading on Sandybridge
Need to check the required primitive type for GS on Sandybridge,
and when GS is disabled, the new state has to be issued too, instead
of only updating URB state with no GS entry, that caused hang on Sandybridge.

This fixes hang issue during conformance suite testing.
2010-12-06 15:20:48 +08:00
Xiang, Haihao
08be8d6450 i965: fix for flat shading on Sandybridge
use constant interpolation instead of linear interpolation for
attributes COL0,COL1 if GL_FLAT is used. This fixes mesa demo bounce.
2010-12-06 09:42:28 +08:00
Henri Verbeet
4409435614 r600g: Cleanup fetch shader resources in r600_pipe_shader_destroy(). 2010-12-05 18:44:44 +01:00
Henri Verbeet
308cfb80f5 r600g: Cleanup block bo references in r600_context_fini(). 2010-12-05 18:44:44 +01:00
Marek Olšák
c0c929cdac st/mesa: initialize key in st_vp_varient
This fixes endless vertex shader recompilations in find_translated_vp
if the shader contains an edge flag output.

NOTE: This is a candidate for the 7.9 branch.

Signed-off-by Brian Paul <brianp@vmware.com>
2010-12-05 17:38:19 +01:00
Xavier Chantry
ccacabe86c gallium/trace: check bind_vertex_sampler_states and set_vertex_sampler_views
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Reviewed-by: Jakob Bornecrantz <wallbraker at gmail.com>
Signed-off-by: Patrice Mandin <patmandin@gmail.com>
2010-12-05 12:12:25 +01:00
Xavier Chantry
e3256ccb04 init ps->context with util_surfaces_get and do_get
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Reviewed-by: Jakob Bornecrantz <wallbraker at gmail.com>
Signed-off-by: Patrice Mandin <patmandin@gmail.com>
2010-12-05 12:09:38 +01:00
Xavier Chantry
af5345d937 nvfx: fixes after array textures merge
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Patrice Mandin <patmandin@gmail.com>
2010-12-05 12:08:00 +01:00
Marek Olšák
66d45567b4 r300g: optimize looping over atoms
This also removes DBG_STATS (the stats can be obtained with valgrind instead).
2010-12-05 05:52:25 +01:00
Marek Olšák
6947e52548 r300g: cleanup winsys 2010-12-05 05:47:10 +01:00
Dave Airlie
c1365606c5 r300g: try and use all of vertex constant space
Finished up by Marek Olšák.

We can set the constant space to use a different area per-call to the shader,
we can avoid flushing the PVS as often as we do by spreading out the constants
across the whole constant space.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
2010-12-05 05:47:03 +01:00
Marek Olšák
1774273bde r300g: do not use the index parameter in set_constant_buffer
It appears to be a constant buffer index (in case there are more constant
buffers explicitly used by a shader), i.e. something that Gallium currently
does not use. We treated it incorrectly as the offset to a constant buffer.
2010-12-05 05:46:56 +01:00
Vinson Lee
e72651dc5d gallium/noop: Add prototype for noop_init_state_functions.
Silences this GCC warning.
noop_state.c:247: warning: no previous prototype for
'noop_init_state_functions'
2010-12-04 17:30:08 -08:00
Eric Anholt
afb80c5315 i965: Fix compile warning about missing opcodes. 2010-12-04 16:27:57 -08:00
Eric Anholt
8f23039f00 i965: Update gen6 SF state on fragment program change too.
SF state depends on what inputs there are to the fragment program, not
just the outputs of the VS.
2010-12-04 16:26:55 -08:00
Eric Anholt
65570d0482 i965: Update gen6 WM state on compiled program change, not just FP change. 2010-12-04 16:26:55 -08:00
Eric Anholt
4ac2f09e20 intel: Add an env var override to execute for a different GPU revision.
Sometimes I'm on the train and want to just read what's generated
under INTEL_DEBUG=vs,wm for some code on another generation.  Or, for
the next gen enablement we'll want to dump aub files before we have
the actual hardware.  This will let us do that.
2010-12-04 16:26:55 -08:00
Chia-I Wu
859106f196 st/vega: Fix pipe blend state for various blend modes.
rgb_src_factor and rgb_dst_factor should be PIPE_BLENDFACTOR_ONE for
VG_BLEND_SRC_IN and VG_BLEND_DST_IN respectively.  VG_BLEND_SRC_OVER can
be supported only when the fb has no alpha channel.  VG_BLEND_DST_OVER
and VG_BLEND_ADDITIVE have to be supported with a shader.

Note that Porter-Duff blending rules assume premultiplied alpha.
2010-12-04 23:46:38 +08:00
Chia-I Wu
0ee73edecc st/vega: Add blend shaders for all blend modes. 2010-12-04 23:41:35 +08:00
Chia-I Wu
5d24411140 st/vega: Fix VG_BLEND_MULTIPLY.
TEMP[1].w will be needed for OUT.w just below.  Use TEMP[0] to store the
intermediate value.
2010-12-04 23:41:30 +08:00
Vinson Lee
09fba30fde mesa: Clean up header file inclusion in texobj.h. 2010-12-04 01:29:50 -08:00
Vinson Lee
f657ac951d mesa: Clean up header file inclusion in texgetimage.h. 2010-12-04 01:20:28 -08:00
Vinson Lee
0ed245bd57 mesa: Clean up header file inclusion in texformat.h. 2010-12-04 01:11:33 -08:00
Vinson Lee
f8a9f5458b mesa: Clean up header file inclusion in texenvprogram.h. 2010-12-04 01:03:52 -08:00
Vinson Lee
f618f4549a mesa: Clean up header file inclusion in texcompress_s3tc.h. 2010-12-04 01:00:21 -08:00
Vinson Lee
8aa4cd0e50 st/vega: Silence uninitialized variable warning.
Fixes this GCC warning.
api_filters.c: In function 'execute_filter':
api_filters.c:184: warning: 'tex_wrap' may be used uninitialized in this function
2010-12-04 00:53:44 -08:00
Vinson Lee
3132591a4d mesa: Clean up header file inclusion in texcompress.h. 2010-12-04 00:52:14 -08:00
Chia-I Wu
e87a0cd260 st/vega: Blending should use premultiplied alpha.
Convert color values to and back from premultiplied form for blending.
Finally the rendering result of the blend demo looks much closer to that
of the reference implementation.
2010-12-04 15:44:40 +08:00
Chia-I Wu
e8ff3931f8 st/vega: Add support for per-channel alpha.
Drawing an image in VG_DRAW_IMAGE_STENCIL mode produces per-channel
alpha for use in blending.  Add a new shader stage to produce and save
it in TEMP[1].

For other modes that do not need per-channel alpha, the stage does

  MOV TEMP[1], TEMP[0].wwww
2010-12-04 13:20:38 +08:00
Chia-I Wu
a19eaaa6c1 st/vega: Move masking after blending.
Masking should happen after blending.  The shader is not entirely
correct, but leave it as is for now.
2010-12-04 13:20:38 +08:00
Chia-I Wu
3b4c888653 st/vega: Refactor blend shaders.
Add a helper function, blend_generic, that supports all blend modes and
per-channel alpha.  Make other blend generators a wrapper to it.

Both the old and new code expects premultiplied colors, yet the input is
non-premultiplied.  Per-channel alpha is also not used for stencil
image.  They still need to be fixed.
2010-12-04 13:20:32 +08:00
Chia-I Wu
a09baf1668 st/vega: Add some comments to pipeline shaders. 2010-12-04 13:19:29 +08:00
Brian Paul
6c33e820d5 st/mesa: new comment about updating state vars 2010-12-03 17:07:16 -07:00
Brian Paul
64244dfd39 mesa: update comments, remove dead code 2010-12-03 16:45:44 -07:00
Brian Paul
6f851e6642 mesa: remove unneeded cast 2010-12-03 16:40:36 -07:00
Brian Paul
503983b09e mesa: make glGet*(GL_NONE) generate GL_INVALID_ENUM
In find_value() check if we've hit the 0th/invalid entry before checking
if the pname matches.

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31987

NOTE: This is a candidate for the 7.9 branch.
2010-12-03 16:04:26 -07:00
Brian Paul
40ee69b4f3 swrast: restructure some glReadPixels() code 2010-12-03 15:26:31 -07:00
Brian Paul
5fc2548fae swrast: accept GL_RG in glReadPixels()
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=32088
2010-12-03 15:26:31 -07:00
Kenneth Graunke
b7acf538af ir_print_visitor: Print out constant structure values.
In the form (constant type ((field1 value) (field2 value) ...))
2010-12-03 13:59:21 -08:00
Brian Paul
8d6a0dc7f3 swrast: fix indentation 2010-12-03 14:49:19 -07:00
Brian Paul
75746e3779 swrast: allow GL_RG format in glDrawPixels()
Restructure the switch statement to avoid having to add additional
color formats in the future.

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=32086
2010-12-03 14:48:03 -07:00
Brian Paul
b87369e863 mesa: consolidate some compiler -D flags
-D__STDC_CONSTANT_MACROS and -D__STDC_LIMIT_MACROS are only needed for
LLVM build.
2010-12-03 13:52:59 -07:00
Marek Olšák
9f7f093090 r300g: one more r500_index_bias_supported leftover 2010-12-03 20:59:55 +01:00
Marek Olšák
536d527020 r300g: add capability bit index_bias_supported
.. instead of calling r500_index_bias_supported(..) every draw call.
2010-12-03 20:34:56 +01:00
Jerome Glisse
edda44e0dc r600g: more indentation fix + warning silencing + dead code removal
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-03 13:06:53 -05:00
Jerome Glisse
119f00659c r600g: indentation fix
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-03 12:56:51 -05:00
Jerome Glisse
0b841b0349 r600g: update polygon offset only when rasterizer or zbuffer change
Aim is to build as little state as possible in draw functions.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-03 12:45:19 -05:00
Brian Paul
dbf996f308 llvmpipe: fix broken stencil writemask
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=32070
2010-12-03 09:44:30 -07:00
Fabian Bieler
cd431a12bf r600g: set address of pop instructions to next instruction 2010-12-03 11:35:44 -05:00
Jerome Glisse
833f3a488a r600g: dump raw shader output for debugging
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-12-03 11:35:36 -05:00
Brian Paul
6d13ec7dc0 mesa: return GL_FRAMEBUFFER_DEFAULT as FBO attachment type
If querying the default/window-system FBO's attachment type, return
GL_FRAMEBUFFER_DEFAULT (per the GL_ARB_framebuffer_object spec).

See http://bugs.freedesktop.org/show_bug.cgi?id=31947

NOTE: This is a candidate for the 7.9 branch.
2010-12-03 08:32:29 -07:00
Brian Paul
20cf1851d8 mesa: fix GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME query
Return 0 instead of generating an error.

See http://bugs.freedesktop.org/show_bug.cgi?id=30993

Note that piglit fbo-getframebufferattachmentparameter-01 still does
not pass.  But Mesa behaves the same as the NVIDIA driver in this case.
Perhaps the test is incorrect.

NOTE: This is a candidate for the 7.9 branch.
2010-12-03 08:24:51 -07:00
Brian Paul
14746b1d4f gallivm: fix null builder pointers 2010-12-03 07:38:02 -07:00
Chia-I Wu
5be631ce83 st/vega: Add a missing break. 2010-12-03 14:55:29 +08:00
Chia-I Wu
a84a1e344f st/vega: Move vertex transformation to shader.
It was done in path-to-polygon conversion.  That meant that the
results were invalidated when the transformation was modified, and CPU
had to recreate the vertex buffer with new vertices.  It could be a
performance hit for apps that animate.
2010-12-03 14:23:04 +08:00
Chia-I Wu
29bea39fde st/vega: Set pipe_resource::array_size to 1. 2010-12-03 14:22:32 +08:00
Chia-I Wu
9028f24b8a st/egl: Set pipe_resource::array_size to 1. 2010-12-03 14:22:32 +08:00
Marek Olšák
a60a5b850b r300g: do not remove unused constants if we are not near the limit 2010-12-03 06:32:10 +01:00
Marek Olšák
b088b255ec r300g: fix pointer arithmetic with void* in transfer_inline_write 2010-12-03 06:08:50 +01:00
Marek Olšák
d531f9c2f5 mesa, st/mesa: fix gl_FragCoord with FBOs in Gallium
gl_FragCoord.y needs to be flipped upside down if a FBO is bound.

This fixes:
- piglit/fbo-fragcoord
- https://bugs.freedesktop.org/show_bug.cgi?id=29420

Here I add a new program state STATE_FB_WPOS_Y_TRANSFORM, which is set based
on whether a FBO is bound. The state contains a pair of transformations.
It can be either (XY=identity, ZW=transformY) if a FBO is bound,
or (XY=transformY, ZW=identity) otherwise, where identity = (1, 0),
transformY = (-1, height-1).

A classic driver (or st/mesa) may, based on some other state, choose whether
to use XY or ZW, thus negate the conditional "if (is a FBO bound) ...".
The reason for this is that a Gallium driver is allowed to only support WPOS
relative to either the lower left or the upper left corner, so we must flip
the Y axis accordingly again. (the "invert" parameter in emit_wpos_inversion)

NOTE: This is a candidate for the 7.9 branch.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-12-03 05:56:40 +01:00
Marek Olšák
6a46fce14f r300g: implement simple transfer_inline_write for buffers
r600g might need something like that as well. This speeds up constant buffer
upload a bit.
2010-12-03 05:44:47 +01:00
Marek Olšák
3ba8843307 r300g: use internal BO handle for add_buffer and write_reloc
Small perf improvement in ipers.

radeon_drm_get_cs_handle is exactly what this commit tries to avoid
in every write_reloc.
2010-12-03 04:40:22 +01:00
Brian Paul
6299f241e9 gallivm/llvmpipe: remove lp_build_context::builder
The field was redundant.  Use the gallivm->builder value instead.
2010-12-02 18:11:16 -07:00
Brian Paul
36b09b5ded mesa: replace more MAX_WIDTH stack allocations with heap allocations 2010-12-02 18:07:03 -07:00
Marek Olšák
0c9a63db09 r300g: fix build 2010-12-03 00:54:41 +01:00
nobled
39c436a1a2 r300g: Drop unnecessary cast 2010-12-03 00:50:58 +01:00
nobled
7ed65f462a r300g: Abort if draw_create() fails
The other drivers need to be updated to do this, too.
2010-12-03 00:50:58 +01:00
nobled
d5bf231806 r300g: Abort if atom allocations fail 2010-12-03 00:50:58 +01:00
Ben Skeggs
a25cea19f2 nv50: silence some unknown get_param warnings
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2010-12-03 08:23:44 +10:00
Brian Paul
77ea102735 st/mesa: avoid large stack allocations in readpixels code 2010-12-02 14:29:07 -07:00
Brian Paul
aa28efe60d swrast: avoid large stack allocations in tex combine code 2010-12-02 14:29:07 -07:00
Brian Paul
25662f878e swrast: avoid large stack allocations in blend code 2010-12-02 14:29:07 -07:00
Brian Paul
2addcb7b50 mesa: replace large/MAX_WIDTH stack allocations with heap allocations 2010-12-02 14:29:01 -07:00
Brian Paul
896a08bde6 mesa: replace large/MAX_WIDTH stack allocations with heap allocations 2010-12-02 14:26:55 -07:00
Alex Deucher
fae7cb8ed8 r600g: bump texture/cb limits appropriately for evergreen 2010-12-02 16:11:08 -05:00
Alex Deucher
a3dc947057 r600c: bump texture limits to hw limits 2010-12-02 16:11:07 -05:00
Zack Rusin
e737b9294a gallium/util: add states relevant to geometry shaders 2010-12-02 15:50:15 -05:00
José Fonseca
64da9a1a04 mesa: Temporary hack to prevent stack overflow on windows
e.g. st_readpixels is trying to alloca() an huge ammount of memory from
the stack.
2010-12-02 20:30:59 +00:00
José Fonseca
63df5a464e wgl: Fix visual's buffer_mask configuration. 2010-12-02 20:21:39 +00:00
José Fonseca
43121f2086 mapi: Hack to avoid vgCreateFont being generated as vgCreateFontA.
Right fix is probably stop C-preprocessor abuse and stick 100% with
scripted code generation.
2010-12-02 19:39:55 +00:00
Eric Anholt
43491adc44 mesa: Add getters for ARB_copy_buffer's attachment points.
Fixes more complaints by oglconform.
2010-12-02 10:28:55 -08:00
Eric Anholt
7cba339375 mesa: Add getters for the rest of the supported draw buffers.
MAX_DRAW_BUFFERS is 8, so allow all 8 GL_DRAW_BUFFER# to be retrieved.
Fixes complaints by oglconform.
2010-12-02 10:28:52 -08:00
Eric Anholt
b381eff141 glsl: Fix flipped return of has_value() for array constants.
Fixes glsl-array-uniform.
2010-12-02 10:28:51 -08:00
José Fonseca
e3659329e0 WIN32_THREADS -> WIN32
Fixes nasty bug where some parts of the code didn't define WIN32_THREADS
and were using the integer mutex implementation, causing even confusion
to the debuggers.

And there is little interest of other thread implemenation on Win32
besides Win32 threads.
2010-12-02 17:35:03 +00:00
Brian Paul
af4f75c8fe softpipe: increase max texture size to 16K 2010-12-02 10:10:05 -07:00
Brian Paul
4b08f35487 mesa: raise max texture sizes to 16K
This allows 16K x 16K 2D textures, for example, but we don't want to
allow that for 3D textures.  The new gl_constants::MaxTextureMBytes
field is used to prevent allocating too large of texture image.
This allows a 16K x 32 x 32 3D texture, for example, but prevents 16K^3.
Drivers can override this limit.  The default is currently 1GB.

Apps should use the proxy texture mechanism to determine the actual
max texture size.
2010-12-02 10:09:03 -07:00
Marek Olšák
23390e2f5c r300/compiler: disable the swizzle lowering pass in vertex shaders
It was a no-op because all swizzles are native there.
2010-12-02 17:48:08 +01:00
José Fonseca
14e2dc9c66 wgl: Unreference the current framebuffer after the make_current call.
To prevent a dangling pointer dereference.
2010-12-02 16:28:36 +00:00
José Fonseca
63c05c96e7 util: Don't try to use imagehlp on mingw. 2010-12-02 15:14:58 +00:00
José Fonseca
50a52ba67e util: __builtin_frame_address() doesn't work on mingw. 2010-12-02 15:14:58 +00:00
José Fonseca
744ef8721b util: Plug leaks in util_destroy_gen_mipmap. 2010-12-02 15:14:58 +00:00
José Fonseca
e5ffa9aa47 wgl: Fix double free. Remove dead code. 2010-12-02 15:14:58 +00:00
Marek Olšák
f3021c688f r300g: fix up cubemap texture offset computation
Broken since 4c70014626.
2010-12-02 14:44:28 +01:00
José Fonseca
431c478df9 util: C++ safe. 2010-12-02 12:26:55 +00:00
José Fonseca
27ba2eb33b retrace: Some fixes. 2010-12-02 12:17:07 +00:00
Chia-I Wu
cb2791213a st/vega: polygon_array requires a deep free.
A polygon array is an array of pointers to polygons.  The polygons
should be freed with the array.
2010-12-02 17:54:23 +08:00
Chia-I Wu
b950d6fa5d st/vega: Destroy the pipe context with vg_context. 2010-12-02 17:27:38 +08:00
Chad Versace
7528f143df glsl: Fix linker bug in cross_validate_globals()
Cause linking to fail if a global has mismatching invariant qualifiers.

See https://bugs.freedesktop.org/show_bug.cgi?id=30261
2010-12-01 20:40:07 -08:00
Roland Scheidegger
4c70014626 gallium: support for array textures and related changes
resources have a array_size parameter now.
get_tex_surface and tex_surface_destroy have been renamed to create_surface
and surface_destroy and moved to context, similar to sampler views (and
create_surface now uses a template just like create_sampler_view). Surfaces
now really should only be used for rendering. In particular they shouldn't be
used as some kind of 2d abstraction for sharing a texture. offset/layout fields
don't make sense any longer and have been removed, width/height should go too.
surfaces and sampler views now specify a layer range (for texture resources),
layer is either array slice, depth slice or cube face.
pipe_subresource is gone array slices (or cube faces) are now treated the same
as depth slices in transfers etc. (that is, they use the z coord of the
respective functions).

Squashed commit of the following:

commit a45bd509014743d21a532194d7b658a1aeb00cb7
Merge: 1aeca28 32e1e59
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Dec 2 04:32:06 2010 +0100

    Merge remote branch 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/drivers/i915/i915_resource_texture.c
    	src/gallium/drivers/i915/i915_state_emit.c
    	src/gallium/drivers/i915/i915_surface.c

commit 1aeca287a827f29206078fa1204715a477072c08
Merge: 912f042 6f7c8c3
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Dec 2 00:37:11 2010 +0100

    Merge remote branch 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/state_trackers/vega/api_filters.c
    	src/gallium/state_trackers/vega/api_images.c
    	src/gallium/state_trackers/vega/mask.c
    	src/gallium/state_trackers/vega/paint.c
    	src/gallium/state_trackers/vega/renderer.c
    	src/gallium/state_trackers/vega/st_inlines.h
    	src/gallium/state_trackers/vega/vg_context.c
    	src/gallium/state_trackers/vega/vg_manager.c

commit 912f042e1d439de17b36be9a740358c876fcd144
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Dec 1 03:01:55 2010 +0100

    gallium: even more compile fixes after merge

commit 6fc95a58866d2a291def333608ba9c10c3f07e82
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Dec 1 00:22:26 2010 +0100

    gallium: some fixes after merge

commit a8d5ffaeb5397ffaa12fb422e4e7efdf0494c3e2
Merge: f7a202f 2da02e7
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Tue Nov 30 23:41:26 2010 +0100

    Merge remote branch 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/drivers/i915/i915_state_emit.c
    	src/gallium/state_trackers/vega/api_images.c
    	src/gallium/state_trackers/vega/vg_context.c

commit f7a202fde2aea2ec78ef58830f945a5e214e56ab
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Nov 24 19:19:32 2010 +0100

    gallium: even more fixes/cleanups after merge

commit 6895a7f969ed7f9fa8ceb788810df8dbcf04c4c9
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Nov 24 03:07:36 2010 +0100

    gallium: more compile fixes after merge

commit af0501a5103b9756bc4d79167bd81051ad6e8670
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Tue Nov 23 19:24:45 2010 +0100

    gallium: lots of compile fixes after merge

commit 0332003c2feb60f2a20e9a40368180c4ecd33e6b
Merge: 26c6346 b6b91fa
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Tue Nov 23 17:02:26 2010 +0100

    Merge remote branch 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/auxiliary/gallivm/lp_bld_sample.c
    	src/gallium/auxiliary/util/u_blit.c
    	src/gallium/auxiliary/util/u_blitter.c
    	src/gallium/auxiliary/util/u_inlines.h
    	src/gallium/auxiliary/util/u_surface.c
    	src/gallium/auxiliary/util/u_surfaces.c
    	src/gallium/docs/source/context.rst
    	src/gallium/drivers/llvmpipe/lp_rast.c
    	src/gallium/drivers/nv50/nv50_state_validate.c
    	src/gallium/drivers/nvfx/nv04_surface_2d.c
    	src/gallium/drivers/nvfx/nv04_surface_2d.h
    	src/gallium/drivers/nvfx/nvfx_buffer.c
    	src/gallium/drivers/nvfx/nvfx_miptree.c
    	src/gallium/drivers/nvfx/nvfx_resource.c
    	src/gallium/drivers/nvfx/nvfx_resource.h
    	src/gallium/drivers/nvfx/nvfx_state_fb.c
    	src/gallium/drivers/nvfx/nvfx_surface.c
    	src/gallium/drivers/nvfx/nvfx_transfer.c
    	src/gallium/drivers/r300/r300_state_derived.c
    	src/gallium/drivers/r300/r300_texture.c
    	src/gallium/drivers/r600/r600_blit.c
    	src/gallium/drivers/r600/r600_buffer.c
    	src/gallium/drivers/r600/r600_context.h
    	src/gallium/drivers/r600/r600_screen.c
    	src/gallium/drivers/r600/r600_screen.h
    	src/gallium/drivers/r600/r600_state.c
    	src/gallium/drivers/r600/r600_texture.c
    	src/gallium/include/pipe/p_defines.h
    	src/gallium/state_trackers/egl/common/egl_g3d_api.c
    	src/gallium/state_trackers/glx/xlib/xm_st.c
    	src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c
    	src/gallium/targets/libgl-gdi/libgl_gdi.c
    	src/gallium/tests/graw/tri.c
    	src/mesa/state_tracker/st_cb_blit.c
    	src/mesa/state_tracker/st_cb_readpixels.c

commit 26c6346b385929fba94775f33838d0cceaaf1127
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Mon Aug 2 19:37:21 2010 +0200

    fix more merge breakage

commit b30d87c6025eefe7f6979ffa8e369bbe755d5c1d
Merge: 9461bf3 1f1928d
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Mon Aug 2 19:15:38 2010 +0200

    Merge remote branch 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/drivers/llvmpipe/lp_rast.c
    	src/gallium/drivers/llvmpipe/lp_rast_priv.h
    	src/gallium/drivers/r300/r300_blit.c
    	src/gallium/drivers/r300/r300_screen_buffer.c
    	src/gallium/drivers/r300/r300_state_derived.c
    	src/gallium/drivers/r300/r300_texture.c
    	src/gallium/drivers/r300/r300_texture.h
    	src/gallium/drivers/r300/r300_transfer.c
    	src/gallium/drivers/r600/r600_screen.c
    	src/gallium/drivers/r600/r600_state.c
    	src/gallium/drivers/r600/r600_texture.c
    	src/gallium/drivers/r600/r600_texture.h
    	src/gallium/state_trackers/dri/common/dri1_helper.c
    	src/gallium/state_trackers/dri/sw/drisw.c
    	src/gallium/state_trackers/xorg/xorg_exa.c

commit 9461bf3cfb647d2301364ae29fc3084fff52862a
Merge: 17492d7 0eaccb3
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Jul 15 20:13:45 2010 +0200

    Merge commit 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/auxiliary/util/u_blitter.c
    	src/gallium/drivers/llvmpipe/lp_rast.c
    	src/gallium/drivers/llvmpipe/lp_surface.c
    	src/gallium/drivers/r300/r300_render.c
    	src/gallium/drivers/r300/r300_state.c
    	src/gallium/drivers/r300/r300_texture.c
    	src/gallium/drivers/r300/r300_transfer.c
    	src/gallium/tests/trivial/quad-tex.c

commit 17492d705e7b7f607b71db045c3bf344cb6842b3
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Fri Jun 18 10:58:08 2010 +0100

    gallium: rename element_offset/width fields in views to first/last_element

    This is much more consistent with the other fields used there
    (first/last level, first/last layer).
    Actually thinking about removing the ugly union/structs again and
    rename first/last_layer to something even more generic which could also
    be used for buffers (like first/last_member) without inducing headaches.

commit 1b717a289299f942de834dcccafbab91361e20ab
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Jun 17 14:46:09 2010 +0100

    gallium: remove PIPE_SURFACE_LAYOUT_LINEAR definition

    This was only used by the layout field of pipe_surface, but this
    driver internal stuff is gone so there's no need for this driver independent
    layout definition neither.

commit 10cb644b31b3ef47e6c7b55e514ad24bb891fac4
Merge: 5691db9 c85971d
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Jun 17 12:20:41 2010 +0100

    Merge commit 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/docs/source/glossary.rst
    	src/gallium/tests/graw/fs-test.c
    	src/gallium/tests/graw/gs-test.c

commit 5691db960ca3d525ce7d6c32d9c7a28f5e907f3b
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Jun 17 11:29:03 2010 +0100

    st/wgl: fix interface changes bugs

commit 2303ec32143d363b46e59e4b7c91b0ebd34a16b2
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Jun 16 19:42:32 2010 +0100

    gallium: adapt code to interface changes...

commit dcae4f586f0d0885b72674a355e5d56d47afe77d
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Jun 16 19:42:05 2010 +0100

    gallium: separate depth0 and array_size in the resource itself.

    These fields are still mutually exclusive (since no 3d array textures exist)
    but it ultimately seemed to error-prone to adapt all code accept the new
    meaning of depth0 (drivers stick that into hardware regs, calculate mipmap
    sizes etc.). And it isn't really cleaner anyway.
    So, array textures will have depth0 of 1, but instead use array_size,
    3D textures will continue to use depth0 (and have array_size of 1). Cube
    maps also will use array_size to indicate their 6 faces, but since all drivers
    should just be fine by inferring this themselves from the fact it's a cube map
    as they always used to nothing should break.

commit 621737a638d187d208712250fc19a91978fdea6b
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Jun 16 17:47:38 2010 +0100

    gallium: adapt code to interface changes

    There are still usages of pipe_surface where pipe_resource should be used,
    which should eventually be fixed.

commit 2d17f5efe166b2c3d51957c76294165ab30b8ae2
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Wed Jun 16 17:46:14 2010 +0100

    gallium: more interface changes

    In particular to enable usage of buffers in views, and ability to use a
    different pipe_format in pipe_surface.
    Get rid of layout and offset parameter in pipe_surface - the former was
    not used in any (public) code anyway, and the latter should either be computed
    on-demand or driver can use subclass of pipe_surface.
    Also make create_surface() use a template to be more consistent with
    other functions.

commit 71f885ee16aa5cf2742c44bfaf0dc5b8734b9901
Merge: 3232d11 8ad410d
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Mon Jun 14 14:19:51 2010 +0100

    Merge commit 'origin/master' into gallium-array-textures

    Conflicts:
    	src/gallium/auxiliary/util/u_box.h
    	src/gallium/drivers/nv50/nv50_surface.c
    	src/gallium/drivers/nvfx/nvfx_surface.c
    	src/gallium/drivers/r300/r300_blit.c
    	src/gallium/drivers/r300/r300_texture.c
    	src/gallium/drivers/r300/r300_transfer.c
    	src/gallium/drivers/r600/r600_blit.c
    	src/gallium/drivers/r600/r600_screen.h
    	src/gallium/include/pipe/p_state.h

commit 3232d11fe3ebf7686286013c357b404714853984
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Mon Jun 14 11:40:04 2010 +0100

    mesa/st: adapt to interface changes

    still need to fix pipe_surface sharing
    (as that is now per-context).
    Also broken is depth0 handling - half the code assumes
    this is also used for array textures (and hence by extension
    of that cube maps would have depth 6), half the code does not...

commit f433b7f7f552720e5eade0b4078db94590ee85e1
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Mon Jun 14 11:35:52 2010 +0100

    gallium: fix a couple of bugs in interface chnage fixes

commit 818366b28ea18f514dc791646248ce6f08d9bbcf
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:42:11 2010 +0200

    targets: adapt to interface changes

    Yes even that needs adjustments...

commit 66c511ab1682c9918e0200902039247793acb41e
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:41:13 2010 +0200

    tests: adapt to interface changes

    Everything needs to be fixed :-(.

commit 6b494635d9dbdaa7605bc87b1ebf682b138c5808
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:39:50 2010 +0200

    st: adapt non-rendering state trackers to interface changes

    might not be quite right in all places, but they really don't want
    to use pipe_surface.

commit 00c4289a35d86e4fe85919ec32aa9f5ffe69d16d
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:38:48 2010 +0200

    winsys: adapt to interface changes

commit 39d858554dc9ed5dbc795626fec3ef9deae552a0
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:26:54 2010 +0200

    st/python: adapt to interface changes

    don't think that will work, sorry.

commit 6e9336bc49b32139cec4e683857d0958000e15e3
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:26:07 2010 +0200

    st/vega: adapt to interface changes

commit e07f2ae9aaf8842757d5d50865f76f8276245e11
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:25:56 2010 +0200

    st/xorg: adapt to interface changes

commit 05531c10a74a4358103e30d3b38a5eceb25c947f
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:24:53 2010 +0200

    nv50: adapt to interface changes

commit 97704f388d7042121c6d496ba8c003afa3ea2bf3
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:24:45 2010 +0200

    nvfx: adapt to interface changes

commit a8a9c93d703af6e8f5c12e1cea9ec665add1abe0
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:24:01 2010 +0200

    i965g: adapt to interface changes

commit 0dde209589872d20cc34ed0b237e3ed7ae0e2de3
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:22:38 2010 +0200

    i915g: adapt to interface changes

commit 5cac9beede69d12f5807ee1a247a4c864652799e
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:20:58 2010 +0200

    svga: adapt to interface changes

    resource_copy_region still looking fishy.
    Was not very suited to unified zslice/face approach...

commit 08b5a6af4b963a3e4c75fc336bf6c0772dce5150
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:20:01 2010 +0200

    rbug: adapt to interface changes

    Not sure if that won't need changes elsewhere?

commit c9fd24b1f586bcef2e0a6e76b68e40fca3408964
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:19:31 2010 +0200

    trace: adapt to interface changes

commit ed84e010afc5635a1a47390b32247a266f65b8d1
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:19:21 2010 +0200

    failover: adapt to interface changes

commit a1d4b4a293da933276908e3393435ec4b43cf201
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:19:12 2010 +0200

    identity: adapt to interface changes

commit a8dd73e2c56c7d95ffcf174408f38f4f35fd2f4c
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:18:55 2010 +0200

    softpipe: adapt to interface changes

commit a886085893e461e8473978e8206ec2312b7077ff
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:18:44 2010 +0200

    llvmpipe: adapt to interface changes

commit 70523f6d567d8b7cfda682157556370fd3c43460
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:18:14 2010 +0200

    r600g: adapt to interface changes

commit 3f4bc72bd80994865eb9f6b8dfd11e2b97060d19
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:18:05 2010 +0200

    r300g: adapt to interface changes

commit 5d353b55ee14db0ac0515b5a3cf9389430832c19
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:17:37 2010 +0200

    cell: adapt to interface changes

    not even compile tested

commit cf5d03601322c2dcb12d7a9c2f1745e2b2a35eb4
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:14:59 2010 +0200

    util: adapt to interface changes

    amazing how much code changes just due to some subtle interface changes?

commit dc98d713c6937c0e177fc2caf23020402cc7ea7b
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Sat Jun 12 02:12:40 2010 +0200

    gallium: more interface fail, docs

    this also changes flush_frontbuffer to use a pipe_resource instead of
    a pipe_surface - pipe_surface is not meant to be (or at least no longer)
    an abstraction for standalone 2d images which get passed around.
    (This has also implications for the non-rendering state-trackers.)

commit 08436d27ddd59857c22827c609b692aa0c407b7b
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Jun 10 17:42:52 2010 +0200

    gallium: fix array texture interface changes bugs, docs

commit 4a4d927609b62b4d7fb9dffa35158afe282f277b
Author: Roland Scheidegger <sroland@vmware.com>
Date:   Thu Jun 3 22:02:44 2010 +0200

    gallium: interface changes for array textures and related cleanups

    This patch introduces array textures to gallium (note they are not immediately
    usable without the associated changes to the shader side).
    Also, this abandons pipe_subresource in favor of using level and layer
    parameters since the distinction between several faces (which was part of
    pipe_subresource for cube textures) and several z slices (which were not part
    of pipe_subresource but instead part of pipe_box where appropriate for 3d
    textures) is gone at the resource level.
    Textures, be it array, cube, or 3d, now use a "unified" set of parameters,
    there is no distinction between array members, cube faces, or 3d zslices.
    This is unlike d3d10, whose subresource index includes layer information for
    array textures, but which considers all z slices of a 3d texture to be part
    of the same subresource.
    In contrast to d3d10, OpenGL though reuses old 2d and 3d function entry points
    for 1d and 2d array textures, respectively, which also implies that for instance
    it is possible to specify all layers of a 2d array texture at once (note that
    this is not possible for cube maps, which use the 2d entry points, although
    it is possible for cube map arrays, which aren't supported yet in gallium).
    This should possibly make drivers a bit simpler, and also get rid of mutually
    exclusive parameters in some functions (as z and face were exclusive), one
    potential downside would be that 3d array textures could not easily be supported
    without reverting this, but those are nowhere to be seen.

    Also along with adjusting to new parameters, rename get_tex_surface /
    tex_surface_destroy to create_surface / surface_destroy and move them from
    screen to context, which reflects much better what those do (they are analogous
    to create_sampler_view / sampler_view_destroy).

    PIPE_CAP_ARRAY_TEXTURES is used to indicate if a driver supports all of this
    functionality (that is, both sampling from array texture as well as use a range
    of layers as a render target, with selecting the layer from the geometry shader).
2010-12-02 04:33:43 +01:00
Xiang, Haihao
32e1e59146 i965: add support for polygon mode on Sandybridge.
This fixes some mesa demos such as fslight/engine in wireframe mode.
2010-12-02 09:54:35 +08:00
Jakob Bornecrantz
de3ff5af49 i915g: Make sure that new vbo gets updated
Malloc likes to reuse old address as soon as possible this would cause the
new vbo buffer to get the same address as the old. So make sure we set it to
NULL when we allocate a new one. This fixes ipers which will fill up a couple
of VBO buffers per frame.

Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:14 +01:00
Jakob Bornecrantz
442e567aa0 i915g: Improve debug printing for textures
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:14 +01:00
Chris Wilson
f6476822a0 i915g: Fix closure of full batch buffers
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
[danvet: incorporate comments by Dr_Jakob]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:14 +01:00
Daniel Vetter
600454084b i915g: track TODO items
Just as a reminder for all things currently broken with i915g.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:14 +01:00
Daniel Vetter
0246b2bf27 i915g: assert(depth_surface->offset == 0)
Shouldn't happen and not supported, anyway.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:14 +01:00
Daniel Vetter
1a47a25d2c i915g: enable x-tiling for render targets
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
8af684e37e i915g: switch rendering to mipmapped textures to (x,y) offsets
Byte offsets simply don't work with tiled render targets when using
tiling bits. Luckily we can cox the hw into doing the right thing
with the DRAWING_RECT command by disabling the drawing rect offset
for the depth buffer.

Minor fixes by Jakob Bornecrantz.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
9493fe85d1 i915g: enable X-tiling for textures
Tiling is rather fragile in general and results in pure blackness when
unlucky.  Hence add a new option to disable tiling.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
32345610cc i915g: don't pot-align stride for tiled buffers
libdrm will do this for us, if it's required (i.e. if tiling is
possible).

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
6ae6e0c6fe i915g: postpone mipmap/face offset calculation
libdrm-intel can refuse to tile buffers for various reasons. For
potentially tiled buffers the stride is therefore only known after
the iws->buffer_create_tiled call. Unconditionally rounding up to whatever
tiling requires wastes space, so rework the code to not use tex->stride
in the layout code.

Luckily only the mimap/face offset calculation uses it which can easily
be solved by storing an (x, y) coordinate pair. Furthermore this will
be usefull later for properly supporting rendering into the different
levels of tiled mipmap textures.

v2: switch to nblocks(x|y): More in line with gallium and better
suited for rendering into mipmap textures.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
f34fd58ec9 i915g: implement unfenced relocs for textures using tiling bits
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
a95e694eaf i915g: implement unfenced color&depth buffer using tiling bits
v2: Clarify tiling bit calculation as suggested by Chris Wilson.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
2ff0879a63 i915g: return tiling in iws->buffer_from_handle
This is needed to properly implement tiling flags. And the gem
implemention fo buffer_from_handle already calls get_tiling, so
it's for free.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
135b083461 i915g: prepare winsys/batchbuffer for execbuf2
Wire up a fenced parameter, switch all relocations to _FENCED

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
1c60840338 i915g: switch to tiled allocations, kill set_fence
This way relaxed fencing is handled by libdrm. And buffers _can't_
ever change their tiling.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:13 +01:00
Daniel Vetter
4a666488c4 i915g: add winsys function to create tiled buffers
Different kernels have different restrictions for tiled buffers.
Hence use the libdrm abstraction to calculate the necessary
stride and height alignment requirements.

Not yet used.

v2: Incorporate review comments from Jakob Bornecrantz

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:12 +01:00
Daniel Vetter
c62f5c7e7b i915g: drop alignment parameter from iws->buffer_create
It's unnecessary. The kernel gem ignores it totally and we can't
run on the old userspace fake bo manager due to lack of dri2.

Also drop the redundant name string from the sw winsys as suggested
by Jakob Bornecrantz

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-12-02 01:34:12 +01:00
Eric Anholt
b4f585665c glsl: Mark the array access for whole-array comparisons.
By not doing so, the uniform contents of
glsl-uniform-non-uniform-array-compare.shader_test was getting thrown
out since nobody was recorded as dereferencing the array.
2010-12-01 16:14:34 -08:00
Eric Anholt
f361f8a8a9 i965: Add support for loops in the VS.
This follows the changes done for the FS alongside the EU emit code.
2010-12-01 16:14:34 -08:00
Eric Anholt
251d15d888 i965: Enable IF statements in the VS.
While the actual IF instructions were fixed by Zhenyu, we were still
flattening them to conditional moves.
2010-12-01 16:14:34 -08:00
Eric Anholt
843a6a308e i965: Add support for gen6 CONTINUE instruction emit.
At this point, piglit tests for fragment shader loops are working.
2010-12-01 16:14:34 -08:00
Eric Anholt
00e5a743e2 i965: Add support for gen6 BREAK ISA emit.
There are now two targets: the hop-to-end-of-block target, and the
target for where to resume execution for active channels.
2010-12-01 16:14:33 -08:00
Eric Anholt
4890e0f09c i965: Add support for gen6 DO/WHILE ISA emit.
There's no more DO since there's no more mask stack, and WHILE has
been shuffled like IF was.
2010-12-01 16:14:31 -08:00
Eric Anholt
a9f62881a3 i965: Dump the WHILE jump distance on gen6. 2010-12-01 15:22:59 -08:00
Marek Olšák
fcf6b353bf r300g: disable ARB_texture_swizzle if S3TC is enabled on r3xx-only
r3xx cannot swizzle compressed textures. r4xx+ is unaffected.

NOTE: This is a candidate for the 7.9 branch.
2010-12-01 22:54:05 +01:00
Marek Olšák
6478a4de14 r300g: fix texture swizzling with compressed textures on r400-r500
This fixes all S3TC piglit/texwrap tests.

NOTE: This is a candidate for the 7.9 branch.
2010-12-01 22:29:09 +01:00
Ian Romanick
c92550be64 i915: Correctly generate unconditional KIL instructions
Fixes piglit test glsl-fs-discard-03.

NOTE: This is a candidate for the 7.9 branch.
2010-12-01 12:01:13 -08:00
Ian Romanick
b6dbc06742 i915: Request that POW instructions be lowered 2010-12-01 12:01:13 -08:00
Ian Romanick
c4285be9a5 glsl: Lower ir_binop_pow to a sequence of EXP2 and LOG2 2010-12-01 12:01:13 -08:00
Ian Romanick
da61afa738 glsl: Use M_LOG2E constant instead of calling log2 2010-12-01 12:01:12 -08:00
Kenneth Graunke
d2d7a273c5 glsl: Add comments to lower_jumps (from the commit message).
This is essentially Luca's commit message, but placed at the top of the
file.
2010-12-01 11:52:43 -08:00
Kenneth Graunke
1802cb9baf glsl: Remove "discard" support from lower_jumps.
The new lower_discard and opt_discard_simplification passes should
handle all the necessary transformations, so lower_jumps doesn't need to
support it.

Also, lower_jumps incorrectly handled conditional discards - it would
unconditionally truncate all code after the discard.  Rather than fixing
the bug, simply remove the code.

NOTE: This is a candidate for the 7.9 branch.
2010-12-01 11:52:43 -08:00
Kenneth Graunke
940df10100 glsl: Add a lowering pass to move discards out of if-statements.
This should allow lower_if_to_cond_assign to work in the presence of
discards, fixing bug #31690 and likely #31983.

NOTE: This is a candidate for the 7.9 branch.
2010-12-01 11:52:43 -08:00
Kenneth Graunke
9a1d063c6d glsl: Add an optimization pass to simplify discards.
NOTE: This is a candidate for the 7.9 branch.
2010-12-01 11:52:43 -08:00
Marek Olšák
ead2ea89f4 ir_to_mesa: Add support for conditional discards.
NOTE: This is a candidate for the 7.9 branch.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2010-12-01 11:52:36 -08:00
Alex Deucher
2ca9256911 r600c: fix some opcodes on evergreen
There were a few places where we were using the wrong opcodes
on evergreen.  arl still needs to be fixed on evergreen; see
r600g for reference.

NOTE: This is a candidate for the 7.9 branch.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
2010-12-01 13:26:02 -05:00
Marek Olšák
e6d798948e r300/compiler: implement and lower OPCODE_CLAMP
Needed for st/vega.
2010-12-01 18:29:50 +01:00
José Fonseca
6f7c8c3cbf vega: Remove extraneous ; 2010-12-01 12:31:21 +00:00
José Fonseca
792caebced scons: Move MSVS_VERSION option to common module. 2010-12-01 12:23:12 +00:00
José Fonseca
2aa3203660 svga: Silence debug printf. 2010-12-01 12:23:12 +00:00
Chia-I Wu
0dadc0b808 st/vega: Avoid unnecessary constant bufer upload.
Remember the last uploaded data and avoid re-uploading.
2010-12-01 18:36:27 +08:00
Chia-I Wu
d7a6901cac st/vega: Initialize pipe states with renderer.
Initialize vertex elements, rasterizer, stencil ref, and vertex shader
with renderer_create.  Remove RASTERIZER_DIRTY and VS_DIRTY flags.
2010-12-01 18:07:00 +08:00
Chia-I Wu
c91c386012 st/vega: Create drawing surface mask as needed.
As the blend texture, a drawing surface mask is used when masking is
enabled.  It should be created as needed.

s/alpha_mask/surface_mask/ to follow OpenVG 1.1 naming.
2010-12-01 18:03:06 +08:00
Chia-I Wu
04f342b417 st/vega: Delay blend texture creation until needed.
It is used for more advanced blending or mask update.  It might not be
ever needed for some applications.
2010-12-01 17:46:34 +08:00
Chia-I Wu
f8e0dd246b st/vega: Remove st_inlines.h.
Per b0427bedde.
2010-12-01 17:00:22 +08:00
Chia-I Wu
2bb788ccc6 st/vega: Simplify radial gradient.
Eight less instructions with comments.
2010-12-01 16:46:01 +08:00
Chia-I Wu
d7aa03b4fe st/vega: Fix degenerate paints.
Fix the case that the two points of a linear gradient coincide, or the
case that the radius of a radial gradient is equal to or less than 0.
2010-12-01 16:46:01 +08:00
Zhenyu Wang
c530fd3f8a i965: also using align1 mode for math2 on sandybridge
Like Eric's workaround patch of commit 490c23ee6b.
This forces to align1 mode for math2 too.
2010-12-01 15:04:18 +08:00
Chia-I Wu
06e7a55028 st/vega: Fix negated logic in image_draw.
A typo from last commit.
2010-12-01 11:39:33 +08:00
Chia-I Wu
b06de80843 st/vega: Fix paint coordinates transformations.
Depending on whether vgDrawPath(mode), vgDrawImage, or vgDrawGlyph[s] is
called, different paint-to-user and user-to-surface matrices should be
used to derive the sample points for the paint.

This fixes "paint" demo.
2010-12-01 11:31:00 +08:00
Chia-I Wu
ca8bc9c05b st/vega: Bump version to 1.1. 2010-12-01 11:23:53 +08:00
Chia-I Wu
e360f91f15 st/vega: Add color transformation support.
Per OpenVG 1.1.  A new shader stage is added.  It uses the first two
constants of the fragment shader for color transformation parameters.
2010-12-01 11:23:52 +08:00
Chia-I Wu
213e288e78 st/vega: More flexible shader selection.
Divide bits of VegaShaderType into 6 groups: paint, image, mask, fill,
premultiply, and bw.  Each group represents a stage.  At most one shader
from each group will be selected when constructing the final fragment
shader.
2010-12-01 11:23:52 +08:00
Chia-I Wu
30cab4b6cb st/vega: Revive mask layer support. 2010-12-01 11:23:52 +08:00
Chia-I Wu
5d64a06a63 st/vega: Add primitive text support.
Optional features such as auth-hinting are not implemented.  There is no
anti-aliasing, and no effort is done to keep the glyph origin integral.
So the text quality is poor.
2010-12-01 11:23:52 +08:00
Chia-I Wu
34f466d4e6 st/vega: Make image_draw take a matrix. 2010-12-01 11:23:52 +08:00
Chia-I Wu
165cb19abc st/vega: Make path_render and path_stroke take a matrix. 2010-12-01 11:23:51 +08:00
Chia-I Wu
d873f1f5b6 st/vega: Fix image sampler views for alpha-only formats.
For alpha-only VG formats, R = G = B = 1.0.
2010-12-01 11:23:51 +08:00
Chia-I Wu
56f02cedfa st/vega: Update to latest headers. 2010-12-01 11:23:51 +08:00
Chia-I Wu
20ce148c30 st/vega: Get rid of renderer_copy_texture. 2010-12-01 11:23:51 +08:00
Chia-I Wu
33ca973e7a st/vega: vg_copy_texture and vg_copy_surface should share code. 2010-12-01 11:23:51 +08:00
Chia-I Wu
4690cdfe07 st/vega: Clean up renderer fields and functions. 2010-12-01 11:23:50 +08:00
Chia-I Wu
ace4539e88 st/vega: Clean up vg_context fields and functions. 2010-12-01 11:23:50 +08:00
Chia-I Wu
635fe3e192 st/vega: vg_manager should care about only the color buffer.
Move depth/stencil buffer, blend texture view, and alpha mask view
creation to vg_context.c.
2010-12-01 11:23:50 +08:00
Chia-I Wu
ee0f1ab923 st/vega: Make shader_bind call into the renderer.
With this commit, the pipe states are entirely managed by the renderer.
The rest of the code interfaces with the renderer instead of
manipulating the states directly.
2010-12-01 11:23:50 +08:00
Chia-I Wu
b730f0fc52 st/vega: Move g3d states to renderer.
Let vg_context focus on OpenVG states and renderer focus on gallium
states.
2010-12-01 11:23:50 +08:00
Chia-I Wu
96c6637a13 st/vega: Use st_framebuffer for fb width/height.
This allows us to eventually make g3d states opaque.
2010-12-01 11:23:50 +08:00
Chia-I Wu
438359597c st/vega: Delay fb state update to vg_validate_state.
vg_manager_validate_framebuffer should mark the fb dirty and have
vg_validate_state call cso_set_framebuffer.  Rename VIEWPORT_DIRTY to
FRAMEBUFFER_DIRTY.
2010-12-01 11:23:49 +08:00
Chia-I Wu
3b71cb6ad6 st/vega: Add POLYGON_STENCIL and POLYGON_FILL renderer state.
The states are designated for polygon filling.  Polygon filling is a
two-pass process utilizing the stencil buffer.  polygon_fill and
polygon_array_fill functions are updated to make use of the state.
2010-12-01 11:23:49 +08:00
Chia-I Wu
b23f732075 st/vega: Use the renderer for vgMask.
vgMask renders to the alpha mask with special fragment shaders.  The
operation can be supported by switching the renderer to FILTER state.
2010-12-01 11:23:49 +08:00
Chia-I Wu
e5968a5355 st/vega: Add FILTER renderer state for image filtering.
The state is designated to perform image filtering.  execute_filter is
updated to make use of the state.
2010-12-01 11:23:49 +08:00
Chia-I Wu
6b241f532a st/vega: Add CLEAR renderer state for vgClear.
This state provides the ability to clear rectangles of the framebuffer
to the specified color, honoring scissoring.  vegaClear is updated to
make use of the state.
2010-12-01 11:23:49 +08:00
Chia-I Wu
54cb382ea5 st/vega: Add SCISSOR renderer state.
The state can be used to set rectangles of the depth buffer to 0.0f.
update_clip_state is changed to use the state for scissor update.
2010-12-01 11:23:49 +08:00
Chia-I Wu
e31a04ea3b st/vega: Add DRAWTEX renderer state.
This state provides glDrawTex-like function.  It can be used for
vgSetPixels.

Rather than modifying every user of the renderer, this commit instead
modifies renderer_copy_surface to use DRAWTEX or COPY state internally
depending on whether the destination is the framebuffer.
2010-12-01 11:23:48 +08:00
Chia-I Wu
59309337e4 st/vega: Overhaul renderer with renderer states.
Renderer states are high-level states to perform specific tasks.  The
renderer is initially in INIT state.  In that state, the renderer is
used for OpenVG pipeline.

This commit adds a new COPY state to the renderer.  The state is used
for copying between two pipe resources using textured drawing.  It can
be used for vgCopyImage, for example.

Rather than modifying every user of the renderer, this commit instead
modifies renderer_copy_texture to use the COPY state internally.
2010-12-01 11:23:48 +08:00
Chia-I Wu
709e57ae4f llvmpipe: Fix build errors on x86.
The errors were introduced by
efc82aef35.
2010-12-01 11:23:48 +08:00
Kristian Høgsberg
7db49853f0 docs: Fix MESA_drm_image typo 2010-11-30 21:14:50 -05:00
Brian Paul
efc82aef35 gallivm/llvmpipe: squash merge of the llvm-context branch
This branch defines a gallivm_state structure which contains the
LLVMBuilderRef, LLVMContextRef, etc.  All data structures built with
this object can be periodically freed during a "garbage collection"
operation.

The gallivm_state object has to be passed to most of the builder
functions where LLVMBuilderRef used to be used.

Conflicts:
	src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
	src/gallium/drivers/llvmpipe/lp_state_setup.c
2010-11-30 16:35:12 -07:00
Marek Olšák
1f1375d4d8 r300g: fix texture border color once again
I made the texwrap test be more thorough and realized that this driver code
had not been quite right. This commit fixes the border color for depth
textures, compressed textures, and 16-bits-per-channel textures
with up to 2 channels (R16, RG16).

NOTE: This is a candidate for the 7.9 branch.
2010-11-30 23:31:16 +01:00
Kenneth Graunke
2da02e75b1 glsl/linker: Free any IR discarded by optimization passes.
Previously, IR for a linked shader was allocated directly out of the
gl_shader object - meaning all of it lived as long as the shader.

Now, IR is allocated out of a temporary context, and any -live- IR is
reparented/stolen to (effectively) the gl_shader.  Any remaining IR can
be freed.

NOTE: This is a candidate for the 7.9 branch.
2010-11-30 13:48:28 -08:00
Kenneth Graunke
ff994eeff8 glsl: Remove anti-built-in hacks from the print visitor.
Now that we only import built-in signatures that are actually used,
printing them is reasonable.
2010-11-30 13:48:28 -08:00
Kenneth Graunke
f5692f452f glsl: Lazily import built-in function prototypes.
This makes a very simple 1.30 shader go from 196k of memory to 9k.

NOTE: This -may- be a candidate for the 7.9 branch, as the benefit is
substantial.  However, it's not a simple change, so it may be wiser to
wait for 7.10.
2010-11-30 13:48:28 -08:00
Kenneth Graunke
01a25bb64e glsl: Refactor out cloning of function prototypes.
This allows us to reuse some code and will be useful later.
2010-11-30 13:48:28 -08:00
Aras Pranckevicius
4ce084c707 glsl: fix matrix type check in ir_algebraic
Fixes glsl-mat-mul-1.
2010-11-30 13:32:00 -08:00
Eric Anholt
d56c97413e glsl: Quiet unreachable no-return-from-function warning. 2010-11-30 13:29:28 -08:00
Zack Rusin
b22d65e9fc scons: add alias for identity 2010-11-30 16:13:11 -05:00
Eric Anholt
ff79633d9f glsl: Fix structure and array comparisions.
We were trying to emit a single ir_expression to compare the whole
thing.  The backends (ir_to_mesa.cpp and brw_fs.cpp so far) expected
ir_binop_any_nequal or ir_binop_all_equal to apply to at most a vector
(with matrices broken down by the lowering pass).  Break them down to
a bunch of ORed or ANDed any_nequals/all_equals.

Fixes:
glsl-array-compare
glsl-array-compare-02
glsl-fs-struct-equal
glsl-fs-struct-notequal
Bug #31909
2010-11-30 11:42:42 -08:00
Eric Anholt
6b937465d4 glsl: Add a helper constructor for expressions that works out result type.
This doesn't cover all expressions or all operand types, but it will
complain if you overreach and it allows for much greater slack on the
programmer's part.
2010-11-30 11:23:24 -08:00
Keith Whitwell
68a4f63247 llvmpipe: shortcircuit some calls to set_scene_state 2010-11-30 12:01:29 +00:00
Keith Whitwell
d9169364d4 llvmpipe: remove misleading debug string 2010-11-30 12:01:29 +00:00
Keith Whitwell
2d31f048ce llvmpipe: raise dirty flag on transfers to bound constbuf
Need this to trigger the scene to update its shadow of the constant
state.
2010-11-30 12:01:29 +00:00
José Fonseca
31aeac5bf9 wgl: More complete WGL_ARB_pbuffer support. 2010-11-30 10:49:08 +00:00
José Fonseca
c4a43873c5 wgl: Stub WGL_ARB_pbuffer support.
See http://www.opengl.org/registry/specs/ARB/wgl_pbuffer.txt
2010-11-30 10:47:49 +00:00
José Fonseca
af6407a500 scons: Alias for svga 2010-11-30 10:47:26 +00:00
José Fonseca
7bbf675b88 svga: Use consistent hexadecimal representation on debug output. 2010-11-30 10:45:31 +00:00
Marek Olšák
80f24c1575 util: rename u_mempool -> u_slab 2010-11-30 10:12:26 +01:00
Zack Rusin
5572805423 gallivm: fix storing of the addr register
we store into the index specified by the register index, not an
indirect register.
2010-11-30 02:01:43 -05:00
Eric Anholt
001eee52d4 glsl: Make the symbol table's add_variable just use the variable's name. 2010-11-29 17:08:27 -08:00
Eric Anholt
e8f5ebf313 glsl: Make the symbol table's add_function just use the function's name. 2010-11-29 17:08:27 -08:00
Eric Anholt
2927b6c212 i965: Fix type of gl_FragData[] dereference for FB write.
Fixes glsl-fs-fragdata-1, and hopefully Eve Online where I noticed
this bug in the generated shader.  Bug #31952.
2010-11-29 17:08:26 -08:00
Adam Jackson
1ccef926be drivers/x11: unifdef XFree86Server
This code was for the old GLcore build of the software rasteriser.  The
X server switched to a DRI driver for software indirect GLX long ago.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-11-29 17:37:54 -05:00
Marek Olšák
e5aa69f6a6 st/mesa: fix texture border color for RED and RG base formats
The spec says the border color should be consistent with the internal
format.

Signed-off-by: Brian Paul <brianp@vmware.com>
2010-11-29 17:26:40 +01:00
pontus lidman
b1097607db mesa: check for posix_memalign() errors
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-11-29 09:20:41 -07:00
Dave Airlie
a7cb673aa1 r600g: it looks like r600 can handle dword offsets in the indices.
Tested with piglit + ut2004 still seems to render okay (and it
definitely does this)
2010-11-29 11:38:24 +10:00
Marek Olšák
5d4d8b6205 u_blitter: interpolate clear color using a GENERIC varying instead of COLOR
There are also some u_simple_shaders changes.

On r300, the TGSI_SEMANTIC_COLOR varying is a fixed-point number clamped
to the range [0,1] and limited to 12 bits of precision. Therefore we can't
use it for passing through a clear color in order to clear high precision
texture formats.

This also makes u_blitter use only one vertex shader instead of two.
2010-11-28 17:45:39 +01:00
Henri Verbeet
c6ea4c0e8a r600g: Fix the PIPE_FORMAT_A8_UNORM color swap for Evergreen as well. 2010-11-27 17:40:47 +01:00
Henri Verbeet
7a4599c6f5 r600g: Fix the PIPE_FORMAT_L8A8_UNORM color swaps. 2010-11-27 17:40:47 +01:00
Mathias Fröhlich
c3602ff5ed st/mesa: Set PIPE_TRANSFER_DISCARD for GL_MAP_INVALIDATE_RANGE/BUFFFER_BIT
Signed-off-by: Brian Paul <brianp@vmware.com>

Note: this is a candidate for the 7.9 branch.
2010-11-26 14:03:42 -07:00
Brian Paul
97ae4dad1c st/mesa: fix mapping of zero-sized buffer objects
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31934
2010-11-26 13:48:49 -07:00
Thomas Hellstrom
5822484510 xorg/vmwgfx: Don't clip video to viewport
Since the viewport is not updated on RandR12 mode switches anymore,
clipping to viewport may incorrectly clip away the video.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-26 10:28:01 +01:00
Thomas Hellstrom
28ee7561f9 xorg/vmwgfx: Flush even if we don't autopaint the color key
This may help paint the colorkey before overlay updates in some
situations where the app paints the color key (mainly xine).

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-26 10:27:54 +01:00
Marek Olšák
e6e6fcd3a6 r300/compiler: move util functions to radeon_compiler_util
The compiler seriously needs a cleanup as far as the arrangement of functions
is concerned. It's hard to know whether some function was implemented or not
because there are so many places to search in and it can be anywhere and
named anyhow.
2010-11-26 02:23:13 +01:00
Marek Olšák
ea2f56b490 r300/compiler: add a function for swizzling a mask 2010-11-26 02:23:13 +01:00
Marek Olšák
7c29446232 r300/compiler: remove duplicate function rc_mask_to_swz 2010-11-26 02:23:13 +01:00
Marek Olšák
ae3e58d973 r300/compiler: fix rc_rewrite_depth_out for it to work with any instruction
It looks like the function was originally written for ARB_fragment_program.

NOTE: This is a candidate for the 7.9 branch.
2010-11-26 02:22:59 +01:00
Marek Olšák
2c1de07ddf u_blitter: use PIPE_TRANSFER_DISCARD to prevent cpu/gpu stall
But the driver must be smart here and follow PIPE_TRANSFER_DISCARD,
as it should.
2010-11-25 20:25:53 +01:00
Xavier Chantry
c14a261eb9 nvfx: reset nvfx->hw_zeta
If nvfx_framebuffer prepare and validate were called successively with
fb->zsbuf not NULL and then NULL, nvfx->hw_zeta would contain garbage and
this would cause failures in nvfx_framebuffer_relocate/OUT_RELOC(hw_zeta).

This was triggered by piglit/texwrap 2D GL_DEPTH_COMPONENT24 and caused
first a 'write to user buffer!!' error in libdrm and then worse things.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-25 17:04:29 +01:00
Xavier Chantry
049065cdfa nvfx: fb->nr_cbufs <= 1 on nv30
7e1bf94631 changed
PIPE_CAP_MAX_RENDER_TARGETS to 1 on nv30.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-25 17:04:02 +01:00
Kenneth Graunke
1eb7a81f2e glsl: Add a virtual as_discard() method.
NOTE: This is candidate for the 7.9 branch.
2010-11-25 03:26:55 -08:00
Kenneth Graunke
a82592de92 glsl: Use do_common_optimization in the standalone compiler.
NOTE: This is a candidate for the 7.9 branch.
2010-11-25 01:21:05 -08:00
Kenneth Graunke
e8a24c65bc glsl: Don't inline function prototypes.
Currently, the standalone compiler tries to do function inlining before
linking shaders (including linking against the built-in functions).
This resulted in the built-in function _prototypes_ being inlined rather
than the actual function definition.

This is only known to fix a bug in the standalone compiler; most
programs should be unaffected.  Still, it seems like a good idea.

NOTE: This is a candidate for the 7.9 branch.
2010-11-25 01:19:53 -08:00
Vinson Lee
2cc79acc1a r300/compiler: Move declaration before code.
Fixes this GCC warning with linux-x86 build.
radeon_pair_regalloc.c: In function ‘compute_live_intervals’:
radeon_pair_regalloc.c:222: warning: ISO C90 forbids mixed declarations and code
2010-11-24 23:03:26 -08:00
Vinson Lee
995de71550 r300/compiler: Move declaration before code.
Fixes this GCC warning with linux-x86 build.
radeon_pair_regalloc.c: In function ‘compute_live_intervals’:
radeon_pair_regalloc.c:221: warning: ISO C90 forbids mixed declarations and code
2010-11-24 23:00:03 -08:00
Chia-I Wu
ba1128db45 st/vega: Fix a typo in EXTENDED_BLENDER_OVER_FUNC.
The typo was introduced by commit
231d5457b2.
2010-11-25 13:34:24 +08:00
Chia-I Wu
c9fb8c3bcf st/vega: No flipping in vg_prepare_blend_surface.
The blend sampler view is addressed with unnormalized coordinates in the
fragment shader.  It should have the same orientation as the surface
does.
2010-11-25 13:33:59 +08:00
Chia-I Wu
37ec090ac9 st/vega: Masks and surfaces should share orientation.
The alpha mask is addressed with unnormalized coordinates in the
fragment shader.  It should have the same orientation as the surface
does.

This fixes "mask" OpenVG demo.
2010-11-25 13:33:59 +08:00
Chia-I Wu
9ea4936a36 st/vega: Fix a crash with empty paths. 2010-11-25 13:32:03 +08:00
Chia-I Wu
3965051dff auxiliary: util_blit_pixels_tex should restore the viewport.
Viewport state should be saved/restored.
2010-11-25 13:32:03 +08:00
Dave Airlie
3b5a3fd8d1 r300g/r600g: bump cache manager timeouts to 1s
On lightsmark on my r500 this drop the bufmgr allocations of the sysprof.
2010-11-25 09:18:19 +10:00
Kenneth Graunke
1197393faa mesa: Fix glGet of ES2's GL_MAX_*_VECTORS properties.
Previously, the get table listed all three as having custom locations,
yet find_custom_value did not have cases to handle them.

MAX_VARYING_VECTORS does not need a custom location since MaxVaryings is
already stored as float[4] (or vec4).  MaxUniformComponents is stored as
the number of floats, however, so a custom implementation that divides
by 4 is necessary.

Fixes bugs.freedesktop.org #31495.
2010-11-24 14:09:32 -08:00
Peter Clifton
ee88727df8 meta: Mask Stencil.Clear against stencilMax in _mesa_meta_Clear
This fixes incorrect behaviour when the stencil clear value exceeds
the size of the stencil buffer, for example, when set with:

glClearStencil (~1); /* Set a bit pattern of 111...11111110 */
glClear (GL_STENCIL_BUFFER_BIT);

The clear value needs to be masked by the value 2^m - 1, where m is the
number of bits in the stencil buffer. Previously, we passed the value
masked with 0x7fffffff to _mesa_StencilFuncSeparate which then clamps,
NOT masks the value to the range 0 to 2^m - 1.

The result would be clearing the stencil buffer to 0xff, rather than 0xfe.

Signed-off-by: Peter Clifton <pcjc2@cam.ac.uk>
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-11-24 12:14:54 -07:00
Brian Paul
03a4f97a68 x11: remove test_proxy_teximage() function
This was really just for testing purposes.
2010-11-24 12:11:23 -07:00
Brian Paul
74c324fdba mesa: added _mesa_format_image_size64() 2010-11-24 12:11:23 -07:00
Brian Paul
7bfbd88d2c mesa: add assertion and update comment in _mesa_format_image_size() 2010-11-24 12:11:23 -07:00
Kristian Høgsberg
a889f9ee5c i965: Don't write mrf assignment for pointsize output
https://bugs.freedesktop.org/show_bug.cgi?id=31894
2010-11-24 11:27:43 -05:00
Thomas Hellstrom
f20a219e9e gallium/targets/xorg-vmwgfx: Xv fixes
Make sure regions are properly updated and that the colorkey painting is
flushed before we update the HW overlay.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-24 15:23:10 +01:00
Thomas Hellstrom
0b1c0460a0 st/xorg: Add a function to flush pending rendering and damage
This is needed to properly sync with host side rendering. For example,
make sure we flush colorkey painting before updating the overlay.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-24 15:23:10 +01:00
Chia-I Wu
1f4c55128b egl_dri2: Fix one context, multiple surfaces.
When a context was made current to another surface, the old code did
this

  dri2_dpy->core->bindContext(cctx, ddraw, rdraw);
  dri2_dpy->core->unbindContext(old_cctx);

and there will be no current context due to the second line.

unbindContext should be called only when bindContext is not.  This fixes
a regression since d19afc57.  Thanks to Neil Roberts for noticing the
issue and creating a test case.
2010-11-24 14:06:30 +08:00
Ian Romanick
78a340fd48 i915: Disallow alpha, red, RG, and sRGB as render targets
Fixes bugzilla #31832

NOTE: This is a candidate for the 7.9 branch.
2010-11-23 18:42:04 -08:00
Brian Paul
903ead0b26 glsl: start restoring some geometry shader code 2010-11-23 17:23:42 -07:00
Brian Paul
6162773ea4 glsl: better handling of linker failures
Upon link error, exit translation loop, free program instructions.
Check for null pointers in calling code.
2010-11-23 17:18:48 -07:00
Brian Paul
2900e56f9d mesa: use gl_shader_type enum 2010-11-23 17:00:08 -07:00
Brian Paul
c628fd743e mesa: replace #defines with new gl_shader_type enum 2010-11-23 15:52:43 -07:00
Brian Paul
512f840702 mesa: _mesa_valid_register_index() to validate register indexes 2010-11-23 15:52:43 -07:00
Brian Paul
b8dacaf174 mesa: rename, make _mesa_register_file_name() non-static
Plus remove unused parameter.
2010-11-23 15:52:42 -07:00
Brian Paul
caf974c525 glsl: use gl_register_file in a few places 2010-11-23 15:52:42 -07:00
Brian Paul
50fd99d172 glsl: fix off by one in register index assertion 2010-11-23 15:52:42 -07:00
Alex Deucher
ed8b5fb24e gallium/egl: fix r300 vs r600 loading
Should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=31841
2010-11-23 15:18:31 -05:00
Eric Anholt
df24450bac i965: Use the new embedded compare in SEL on gen6 for VS MIN and MAX opcodes.
Cuts the extra CMP instruction that used to precede SEL.
2010-11-23 09:23:30 -08:00
Eric Anholt
8a7cf99457 i965: Don't upload line smooth params unless we're line smoothing. 2010-11-23 09:23:30 -08:00
Eric Anholt
008fd3779b i965: Don't upload line stipple pattern unless we're stippling. 2010-11-23 09:23:30 -08:00
Eric Anholt
e29e3c32d9 i965: Don't upload polygon stipple unless required. 2010-11-23 09:23:30 -08:00
Eric Anholt
7720bfffa3 i965: Move gen4 blend constant color to the gen4 blending file. 2010-11-23 09:23:29 -08:00
Tilman Sauerbeck
3688301c59 r600g: Removed duplicated call to tgsi_split_literal_constant().
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
2010-11-23 09:20:54 +01:00
Tom Stellard
4265c2f819 r300/compiler: Don't allow presubtract sources to be remapped twice
https://bugs.freedesktop.org/show_bug.cgi?id=31193

NOTE: This is a candidate for the 7.9 branch.
2010-11-23 00:02:03 -08:00
Mathias Fröhlich
07e0424a17 r600g: Only compare active vertex elements
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
2010-11-23 08:39:43 +01:00
Vinson Lee
f44d96e1af mesa: Clean up header file inclusion in syncobj.h. 2010-11-22 21:51:49 -08:00
Vinson Lee
37195b7f70 llvmpipe: Remove unnecessary headers. 2010-11-22 21:39:14 -08:00
Xiang, Haihao
93102b4cd8 mesa: fix regression from b4bb668020
Pending commands to the previous context aren't flushed since commit b4bb668

Reported-by: Oleksiy Krivoshey <oleksiyk@gmail.com>
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
2010-11-23 08:59:44 +08:00
Alex Deucher
cb7a36b651 r600c: fix VC flush on cedar and palm 2010-11-22 19:27:58 -05:00
Alex Deucher
0e4c5f63b9 r600g: add support for ontario APUs
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
2010-11-22 18:01:26 -05:00
Alex Deucher
072f2cbf29 r600c: add Ontario Fusion APU support
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
2010-11-22 18:01:25 -05:00
Mathias Fröhlich
8d1ad3b21c r300g: Avoid returning values in a static array, fixing a potential race
(Marek: added the initializion of "vec" in the default statement)

NOTE: This is a candidate for the 7.9 branch.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
2010-11-22 23:56:41 +01:00
Alex Deucher
271b7b5914 r600g: fix some winsys functions to deal properly with evergreen
Are these functions actually used anywhere?
2010-11-22 17:39:54 -05:00
Alex Deucher
bf9c80976f r600g: fix additional EVENT_WRITE packet
Add explicit EVENT_TYPE field
2010-11-22 17:39:16 -05:00
Marek Olšák
e7c74a7dfa st/mesa: set MaxUniformComponents
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-11-22 21:44:35 +01:00
Brian Paul
6a0255122a swrast: init alpha value to 1.0 in opt_sample_rgb_2d() 2010-11-22 09:04:13 -07:00
Marek Olšák
9aa089eac0 gallium: add PIPE_SHADER_CAP_SUBROUTINES
This fixes piglit/glsl-vs-main-return and glsl-fs-main-return for the drivers
which don't support RET (i915g, r300g, r600g, svga).

ir_to_mesa does not currently generate subroutines, but it's a matter of time
till it's added. It would then break all the drivers which don't implement
them, so this CAP makes sense.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
2010-11-22 12:41:22 +01:00
Keith Whitwell
b2ddb93ff3 Merge branch 'lp-offset-twoside' 2010-11-22 10:36:01 +00:00
Dave Airlie
d5aadf0d80 r600g: pick correct color swap for A8 fbos.
This fixes fdo bug 31810.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2010-11-22 16:05:44 +10:00
Tom Stellard
1b6ed80972 r300/compiler: Add a more efficient version of rc_find_free_temporary() 2010-11-21 18:48:31 -08:00
Tom Stellard
8833f53e65 r300/compiler: Enable rename_reg pass for r500 cards
In addition, the rename_reg pass has been rewritten to use
rc_get_readers().
2010-11-21 18:48:31 -08:00
Tom Stellard
bbe49bc585 r300/compiler: Use presubtract operations as much as possible
Previously, presubtract operations where only being used by instructions
with less than three source source registers.
2010-11-21 18:48:31 -08:00
Tom Stellard
ddceededf8 r300/compiler: Convert RGB to alpha in the scheduler 2010-11-21 18:48:31 -08:00
Tom Stellard
681f56af80 r300/compiler: Track readers through branches in rc_get_readers() 2010-11-21 18:48:31 -08:00
Tom Stellard
255860113f r300/compiler: Handle BREAK and CONTINUE in rc_get_readers() 2010-11-21 18:48:31 -08:00
Tom Stellard
96f9580160 r300/compiler: Add rc_get_readers() 2010-11-21 18:48:31 -08:00
Tom Stellard
23f577dbd4 r300/compiler: Ignore alpha dest register when replicating the result
When the result of the alpha instruction is being replicated to the RGB
destination register, we do not need to use alpha's destination register.
This fixes an invalid "Too many hardware temporaries used" error in
the case where a transcendent operation writes to a temporary register
greater than max_temp_regs.

NOTE: This is a candidate for the 7.9 branch.
2010-11-21 18:48:31 -08:00
Tom Stellard
d668659003 r300/compiler: Use zero as the register index for unused sources
This fixes an invalid "Too many hardware temporaries used" error in the
case where a source reads from a temporary register with an index greater
than max_temp_regs and then the source is marked as unused before the
register allocation pass.

NOTE: This is a candidate for the 7.9 branch.
2010-11-21 18:48:31 -08:00
Tom Stellard
3e5f9789d6 r300/compiler: Fix instruction scheduling within IF blocks
Reads of registers that where not written to within the same block were
not being tracked.  So in a situations like this:
0: IF
1: ADD t0, t1, t2
2: MOV t2, t1

Instruction 2 didn't know that instruction 1 read from t2, so
in some cases instruction 2 was being scheduled before instruction 1.

NOTE: This is a candidate for the 7.9 branch.
2010-11-21 18:48:31 -08:00
Tom Stellard
e2301b45c2 r300/compiler: Fix register allocator's handling of loops
NOTE: This is a candidate for the 7.9 branch.
2010-11-21 18:48:31 -08:00
Tom Stellard
412803b5cd r300/compiler: Make sure presubtract sources use supported swizzles
NOTE: This is a candidate for the 7.9 branch.
2010-11-21 18:48:31 -08:00
Vinson Lee
9d08902457 r600: Remove unnecessary header. 2010-11-21 15:03:27 -08:00
Marek Olšák
2892c8bdbc docs: add GL 4.1 status 2010-11-21 23:03:58 +01:00
Marek Olšák
e40a58b7f8 st/mesa: enable ARB_explicit_attrib_location and EXT_separate_shader_objects
Gallium drivers pass all piglit tests for the two (there are 12 tests
for separate_shader_objects and 5 tests for explicit_attrib_location),
and I was told the extensions don't need any driver-specific code.

I made them dependent on PIPE_CAP_GLSL.

Signed-off-by: Brian Paul <brianp@vmware.com>
2010-11-21 19:33:45 +01:00
Brian Paul
5e3733fadf mesa: fix get_texture_dimensions() for texture array targets
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31779
2010-11-21 10:05:51 -07:00
Brian Paul
0ec0f1025d docs: update some GL 3.0 status 2010-11-21 09:40:28 -07:00
Brian Paul
5ed51e950f mesa: hook up GL 3.x entrypoints
Fix up some details in the xml files and regenerate dispatch files.
2010-11-21 09:20:44 -07:00
Brian Paul
81c347ef79 glapi: rename GL3.xml to GL3x.xml as it covers all GL 3.x versions 2010-11-21 09:20:43 -07:00
Brian Paul
197b1d7898 mesa: fix error msg typo 2010-11-21 09:20:43 -07:00
Daniel Vetter
c8fca58d9d i915g: kill idws->pool
The drm winsys only ever handles one gem memory manager. Rip out
the unnecessary complication.

Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-11-21 16:41:19 +01:00
Daniel Vetter
e182618853 i915g: kill buf->map_gtt
Not using the gtt is considered harmful for performance. And for
partial uploads there's always drm_intel_bo_subdata.

Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-11-21 16:41:19 +01:00
Daniel Vetter
d54d67499c i915g: kill RGBA/X formats
It's intel, so always little endian!

Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-11-21 16:41:19 +01:00
Daniel Vetter
8624fe7a49 i915g: add pineview pci ids
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-11-21 16:41:19 +01:00
Daniel Vetter
aba728eb25 i915g: s/hw_tiled/tiling
More in line with other intel drivers.

Change to use enum by Jakob Bornecrantz.

Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-11-21 16:41:18 +01:00
Daniel Vetter
f77a2690b4 i915g: rip out ->sw_tiled
It looks like this was meant to facilitate unfenced access to textures/
color/renderbuffers. It's totally incomplete and fundamentally broken
on a few levels:
- broken: The kernel needs to about every tiled bo to fix up bit17
  swizzling on swap-in.
- unflexible: fenced/unfenced relocs from execbuffer2 do the same, much
  simpler.
- unneeded: with relaxed fencing tiled gem bos are as memory-efficient
  as this trick.

Hence kill it.

Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
2010-11-21 16:41:18 +01:00
Joakim Sindholt
bf10055cff r300g: silence guard band cap errors
Somebody should find out what these are. It can be found on Windows
getting a D3DCAPS9 from IDirect3D9::GetCaps() and reading the
GuardBand* values.
2010-11-21 15:45:20 +01:00
Chia-I Wu
b8f6cb3809 st/vega: Fix vgReadPixels with a subrectangle.
Fix a crash when the subrectangle is not inside the fb.  Fix wrong
pipe transfer when sx > 0 or sy + height != fb->height.

This fixes "readpixels" demo.
2010-11-21 19:32:22 +08:00
Chia-I Wu
e8bbaff22e st/vega: Set wrap_r for mask and blend samplers.
These two samplers use non-normalized texture coordinates.  wrap_r
cannot be PIPE_TEX_WRAP_REPEAT (the default).

This fixes

  sp_tex_sample.c:1790:get_linear_unorm_wrap: Assertion `0' failed

assertion failure.
2010-11-21 19:32:10 +08:00
Chia-I Wu
daa265e53c st/vega: vegaLookupSingle should validate the state.
Fix "lookup" demo crash.
2010-11-21 19:26:33 +08:00
Chia-I Wu
f90524a01b tgsi: Add STENCIL to text parser.
Fix OpenVG "filter" demo

  Program received signal SIGSEGV, Segmentation fault.
  0xb7153dc9 in str_match_no_case (pcur=0xbfffe564, str=0x0) at
  tgsi/tgsi_text.c:86
  86         while (*str != '\0' && *str == uprcase( *cur )) {
2010-11-21 19:26:29 +08:00
Vinson Lee
8bea7776a3 mesa: Clean up header file inclusion in stencil.h. 2010-11-20 22:44:33 -08:00
Vinson Lee
9732a93f40 mesa: Clean up header file inclusion in shared.h. 2010-11-20 22:30:27 -08:00
Vinson Lee
20f041952c mesa: Clean up header file inclusion in shaderapi.h. 2010-11-20 22:17:28 -08:00
Vinson Lee
baa0471597 mesa: Clean up header file inclusion in scissor.h. 2010-11-20 22:01:30 -08:00
Vinson Lee
27e96655c7 mesa: Clean up header file inclusion in renderbuffer.h. 2010-11-20 21:32:07 -08:00
Vinson Lee
b6215d18b5 mesa: Clean up header file inclusion in readpix.h. 2010-11-20 21:23:35 -08:00
Vinson Lee
bab188d22f mesa: Clean up header file inclusion in rastpos.h. 2010-11-20 21:14:06 -08:00
Vinson Lee
9b66305b8d mesa: Clean up header file inclusion in polygon.h. 2010-11-20 21:06:09 -08:00
Vinson Lee
f5cbe04b69 intel: Remove unnecessary header. 2010-11-20 20:13:50 -08:00
Vinson Lee
84f5229119 r600: Remove unnecesary header. 2010-11-20 19:04:30 -08:00
Vinson Lee
b59f3dd8ca swrast: Remove unnecessary header. 2010-11-20 19:00:18 -08:00
Vinson Lee
1310806872 st/mesa: Remove unnecessary headers. 2010-11-20 18:48:09 -08:00
Chia-I Wu
bb045d339b scons: Define IN_DRI_DRIVER.
The define is required for DRI drivers.  It is not needed for
libgl-xlib, but the overhead it introduces should be minor.
2010-11-20 17:47:11 -08:00
Xavier Chantry
7e1bf94631 nvfx: only expose one rt on nv30
We do not know how to use more, GL_ARB_draw_buffers is not exposed on blob.
2010-11-20 23:29:12 +01:00
Owen W. Taylor
c63a86e1e5 r600g: Fix location for clip plane registers
The stride between the different clip plane registers was incorrect.

https://bugs.freedesktop.org/show_bug.cgi?id=31788

agd5f: fix evergreen as well.
2010-11-20 12:18:56 -05:00
Marek Olšák
ffb732d8bd r300g: fix rendering with no vertex elements
Fixes glsl-vs-point-size, although I meant to fix glsl-novertexdata.
Since swrast fails glsl-novertexdata too, I guess it's a core issue.
2010-11-20 16:20:48 +01:00
Eric Anholt
b6b91fa029 i965: Remove duplicate MRF writes in the FS backend.
This is quite common for multitexture sampling, and not only cuts down
on the second and later set of MOVs, but typically also allows
compute-to-MRF on the first set.

No statistically siginficant performance difference in nexuiz (n=3),
but it reduces instruction count in one of its shaders and seems like
a good idea.
2010-11-19 20:05:56 -08:00
Eric Anholt
47b1aac1cf i965: Improve compute-to-mrf.
We were skipping it if the instruction producing the value we were
going to compute-to-mrf used its result reg as a source reg.  This
meant that the typical "write interpolated color to fragment color" or
"texture from interpolated texcoord" shader didn't compute-to-MRF.
Just don't check for the interference cases until after we've checked
if this is the instruction we wanted to compute-to-MRF.

Improves nexuiz high-settings performance on my laptop 0.48% +- 0.08%
(n=3).
2010-11-19 19:54:11 -08:00
Eric Anholt
ac89a90401 ir_to_mesa: Detect and emit MOV_SATs for saturate constructs.
The goal here is to avoid regressing performance on ir_to_mesa drivers
for fixed function fragment shaders requiring saturates.
2010-11-19 19:09:32 -08:00
Eric Anholt
19631fab35 i965: Recognize saturates and turn them into a saturated mov.
On pre-gen6, this turns 4 instructions into 1.  We could still do
better by folding the saturate into the instruction generating the
value if nobody else uses it, but that should be a separate pass.
2010-11-19 19:09:31 -08:00
Eric Anholt
02939d643f glsl: Add a helper function for determining if an rvalue could be a saturate.
Hardware pretty commonly has saturate modifiers on instructions, and
this can be used in codegen to produce those, without everyone else
needing to understand clamping other than min and max.
2010-11-19 19:09:18 -08:00
Eric Anholt
602ae2441a i965: Fold constants into the second arg of BRW_SEL as well.
This hits a common case with min/max operations.
2010-11-19 17:42:07 -08:00
Eric Anholt
f9b420d3bd i965: Remove extra \n at the end of every instruction in INTEL_DEBUG=wm. 2010-11-19 17:42:07 -08:00
Eric Anholt
5944cda6ed i965: Just use memset() to clear most members in FS constructors.
This should make it a lot harder to forget to zero things.
2010-11-19 17:42:07 -08:00
Eric Anholt
61126278a3 i965: Fix compute_to_mrf to not move a MRF write up into another live range.
Fixes glsl-fs-copy-propagation-texcoords-1.
2010-11-19 17:42:06 -08:00
Eric Anholt
6b1d7dd781 mesa: Include C++ files in the makedepend of DRI drivers. 2010-11-19 17:42:06 -08:00
Vinson Lee
a172368ef1 glsl: Fix type of label 'default' in switch statement. 2010-11-19 17:28:22 -08:00
Vinson Lee
7aebe181f3 glsl: Add lower_vector.cpp to SConscript. 2010-11-19 17:23:07 -08:00
Ian Romanick
bb756bb0a6 glsl: Fix matrix constructors with vector parameters
When the semantics of write masks in assignments were changed, this
code was not correctly updated.

Fixes piglit test glsl-mat-from-vec-ctor-01.
2010-11-19 17:17:25 -08:00
Kenneth Graunke
63684a9ae7 glsl: Combine many instruction lowering passes into one.
This should save on the overhead of tree-walking and provide a
convenient place to add more instruction lowering in the future.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-11-19 15:56:28 -08:00
Kenneth Graunke
b943fb94bf glsl: Simplify a type check by using type->is_integer(). 2010-11-19 15:06:58 -08:00
Ian Romanick
11d6f1c698 glsl: Add ir_quadop_vector expression
The vector operator collects 2, 3, or 4 scalar components into a
vector.  Doing this has several advantages.  First, it will make
ud-chain tracking for components of vectors much easier.  Second, a
later optimization pass could collect scalars into vectors to allow
generation of SWZ instructions (or similar as operands to other
instructions on R200 and i915).  It also enables an easy way to
generate IR for SWZ instructions in the ARB_vertex_program assembler.
2010-11-19 15:00:26 -08:00
Ian Romanick
13f57d42b6 glsl: Add unary ir_expression constructor 2010-11-19 15:00:25 -08:00
Ian Romanick
8e498050dc glsl: Add ir_rvalue::is_negative_one predicate 2010-11-19 15:00:25 -08:00
Ian Romanick
fc92e87b97 glsl: Eliminate assumptions about size of ir_expression::operands
This may grow in the near future.
2010-11-19 15:00:25 -08:00
Ian Romanick
f2616e56de glsl: Add ir_unop_sin_reduced and ir_unop_cos_reduced
The operate just like ir_unop_sin and ir_unop_cos except that they
expect their inputs to be limited to the range [-pi, pi].  Several
GPUs require this limited range for their sine and cosine
instructions, so having these as operations (along with a to-be-written
lowering pass) helps this architectures.

These new operations also matche the semantics of the
GL_ARB_fragment_program SCS instruction.  Having these as operations
helps in generating GLSL IR directly from assembly fragment programs.
2010-11-19 15:00:25 -08:00
Alex Deucher
04ffbe1ac6 r600g: use full range of VS resources for vertex samplers
Now that we have fetch shaders, the full range of VS resources
can be used for sampling.
2010-11-19 15:51:24 -05:00
Alex Deucher
4afd068385 r600g: use meaningful defines for chiprev
Makes the code much clearer.
2010-11-19 15:32:02 -05:00
Alex Deucher
52c66120d8 r600g: translate ARR instruction for evergreen
evergreen variant of:
9f7ec103e2
2010-11-19 15:20:59 -05:00
Jerome Glisse
f609b2ab03 r600g: add fetch shader capabilities
Use fetch shader instead of having fetch instruction in the vertex
shader. Allow to restrict shader update to a smaller part when
vertex buffer input layout changes.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-11-19 13:40:55 -05:00
Alex Deucher
3e76ed4e25 r600g: All EVENT_WRITE packets need the EVENT_INDEX field
6xx-evergreen
2010-11-19 13:35:53 -05:00
Viktor Novotný
af17d89966 dri/nouveau: Clean up magic numbers in get_rt_format
Signed-off-by: Viktor Novotný <noviktor@seznam.cz>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-19 19:04:50 +01:00
Jerome Glisse
fab804bdfe r600g: fix occlusion query on evergreen (avoid lockup)
Occlusion query on evergreen need the event index field to be
set otherwise we endup locking up the GPU.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-11-19 11:53:01 -05:00
Keith Whitwell
546c5ffa11 llvmpipe: twoside for specular color also 2010-11-19 16:17:36 +00:00
Keith Whitwell
081ce2680e llvmpipe: fix up twoside after recent changes
Fix my slot/attr confusion.
2010-11-19 16:16:30 +00:00
Hui Qi Tay
d4b5cf6c05 llvmpipe: fix such that offset/twoside function only does in-place modification 2010-11-19 15:12:19 +00:00
Ian Romanick
c05ccc1ebd ir_to_mesa: Generate smarter code for some conditional moves
Condiation moves with a condition of (a < 0), (a > 0), (a <= 0), or (a
>= 0) can be generated with "a" directly as an operand of the CMP
instruction.  This doesn't help much now, but it will help with
assembly shaders that use the CMP instruction.
2010-11-18 18:19:45 -08:00
Ian Romanick
ad87f2ddc7 glsl: Make is_zero and is_one virtual methods of ir_rvalue
This eliminates the need in some cames to validate that an rvalue is
an ir_constant before checking to see if it's 0 or 1.
2010-11-18 18:19:45 -08:00
Brian Paul
83e93b6008 mesa: pass gl_format to _mesa_init_teximage_fields()
This should prevent the field going unset in the future.  See bug
http://bugs.freedesktop.org/show_bug.cgi?id=31544 for background.

Also remove unneeded calls to clear_teximage_fields().

Finally, call _mesa_set_fetch_functions() from the
_mesa_init_teximage_fields() function so callers have one less
thing to worry about.
2010-11-18 16:15:38 -07:00
José Fonseca
3dcc3153b0 scons: Use inline wrap helpers more consistently. 2010-11-18 13:02:36 +00:00
Dave Airlie
185d862cd8 gallium/noop: report GL 2.1
this should at least make app use the same paths as they would for a real
driver.
2010-11-18 18:11:27 +10:00
Vinson Lee
855c66bde7 glsl: Fix 'control reaches end of non-void function' warning.
Fix this GCC warning.
ir.cpp: In static member function
'static unsigned int ir_expression::get_num_operands(ir_expression_operation)':
ir.cpp:199: warning: control reaches end of non-void function
2010-11-17 22:43:52 -08:00
Chia-I Wu
ca9f99d9c5 mesa: Clean up core.h.
Remove version.h and context.h from core.h.
2010-11-18 11:56:01 +08:00
Chia-I Wu
997a2547d1 st/glx: Replace MESA_VERSION_STRING by xmesa_get_name.
xmesa_get_name returns the name of the st_api, which is the same as
MESA_VERSION_STRING.
2010-11-18 11:56:01 +08:00
Chia-I Wu
db1689c236 st/wgl: Use st_context_iface::share for DrvShareLists. 2010-11-18 11:56:01 +08:00
Chia-I Wu
4f38dcd974 gallium: Add st_context_iface::share to st_api.
It will be used to implement wglShareLists.  Fill st_context_iface::copy
for glXCopyContext as well.
2010-11-18 11:56:00 +08:00
Chia-I Wu
28105471af gallium: Add st_api::name.
It is the name of the rendering API.  This field is informative.
2010-11-18 11:56:00 +08:00
Chia-I Wu
cc5c908d7d st/vega: Do not wait NULL fences. 2010-11-18 11:56:00 +08:00
Eric Anholt
50b4508319 i965: Eliminate dead code more aggressively.
If an instruction writes reg but nothing later uses it, then we don't
need to bother doing it.  Before, we were just killing code that was
never read after it was ever written.

This removes many interpolation instructions for attributes with only
a few comopnents used.  Improves nexuiz high-settings performance .46%
+/- .12% (n=3) on my Ironlake.
2010-11-18 11:16:14 +08:00
Brian Paul
48af60b465 mesa: upgrade to glext.h version 66
The type of the num/count parameter to glProgramParameters4[df]vNV()
changed so some API dispatch code needed updates too.
2010-11-17 20:04:45 -07:00
Alex Deucher
a23f25eba1 r600g: fix buffer alignment
This should fix the remaining buffer alignment issues in r600g.
2010-11-17 21:33:40 -05:00
Eric Anholt
da35388044 i965: Fail on loops on gen6 for now until we write the EU emit code for it. 2010-11-18 09:18:47 +08:00
Eric Anholt
3c8db58a17 i965: Add dumping of the sampler default color. 2010-11-18 09:18:47 +08:00
Eric Anholt
95addca019 i965: Add state dumping for sampler state. 2010-11-18 09:18:47 +08:00
Eric Anholt
03ff02d08b mesa: Don't spam the console in a debug build unless some spam is requested.
It's annoying to use test suites under a Mesa debug build because
pretty output is cluttered with stderr's continuous reports that
you're still using the debug driver.
2010-11-18 09:18:47 +08:00
Eric Anholt
d512cbf58f i965: Shut up spurious gcc warning about GLSL_TYPE enums. 2010-11-18 09:18:47 +08:00
Jakob Bornecrantz
e89e8a4347 gallium: Remove redundant sw and debug target helpers 2010-11-17 23:49:09 +00:00
Jakob Bornecrantz
b46340c740 graw: Use inline debug helper instead of non-inline version 2010-11-17 23:49:09 +00:00
Jakob Bornecrantz
c30656d8c2 libgl-xlib: Use inline debug helper instead of non-inline version 2010-11-17 23:49:08 +00:00
Chad Versace
7819435f2e glsl: Improve usage message for glsl_compiler
The new usage message lists possible command line options. (Newcomers to Mesa
currently have to trawl through the source to find the command line options,
and we should save them from that trouble.)

Example Output
--------------
usage: ./glsl_compiler [options] <file.vert | file.geom | file.frag>

Possible options are:
    --glsl-es
    --dump-ast
    --dump-hir
    --dump-lir
    --link
2010-11-17 15:44:41 -08:00
Kenneth Graunke
007f488150 glsl: Refactor get_num_operands.
This adds sentinel values to the ir_expression_operation enum type:
ir_last_unop, ir_last_binop, and ir_last_opcode.  They are set to the
previous one so they don't trigger "unhandled case in switch statement"
warnings, but should never be handled directly.

This allows us to remove the huge array of 1s and 2s in
ir_expression::get_num_operands().
2010-11-17 15:44:41 -08:00
Jerome Glisse
7ffd4e976f r600g: code cleanup (indent, trailing space, empty line ...)
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-11-17 17:22:08 -05:00
Kenneth Graunke
9935fe705d glsl: Remove the ir_binop_cross opcode. 2010-11-17 13:59:17 -08:00
Kenneth Graunke
af1cba2260 Refresh autogenerated file builtin_function.cpp. 2010-11-17 13:37:16 -08:00
Kenneth Graunke
671ccf593e glsl: Reimplement the "cross" built-in without ir_binop_cross.
We are not aware of any GPU that actually implements the cross product
as a single instruction.  Hence, there's no need for it to be an opcode.
Future commits will remove it entirely.
2010-11-17 13:20:30 -08:00
Kenneth Graunke
302fe4049c Regenerate glcpp parser. 2010-11-17 12:53:07 -08:00
Kenneth Graunke
d719bf8fb4 glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.
This is really supposed to be defined only if the driver supports highp
in the fragment shader - but all of our current ES2 implementations do.
So, just define it.  In the future, we'll need to add a flag to
gl_context and only define the macro if the flag is set.

"Fixes" freedesktop.org bug #31673.
2010-11-17 12:50:35 -08:00
Robert Hooker
778917069c egl_dri2: Add missing intel chip ids.
Signed-off-by: Robert Hooker <robert.hooker@canonical.com>
2010-11-17 12:10:53 -08:00
Chad Versace
df883eb157 glsl: Fix Doxygen tag \file in recently renamed files 2010-11-17 12:07:24 -08:00
Chad Versace
b4cdba687c glsl: Fix erroneous cast in ast_jump_statement::hir()
Return values were erroneously cast from (ir_rvalue*) to (ir_expression*).

NOTE: This is a candidate for the 7.9 branch.
2010-11-17 11:59:32 -08:00
Kenneth Graunke
e16c9d5d03 glsl: Fix constant expression handling for <, >, <=, >= on vectors.
ir_binop_less, ir_binop_greater, ir_binop_lequal, and ir_binop_gequal
are defined to work on vectors as well as scalars, as long as the two
operands have the same type.

This is evident from both ir_validate.cpp and our use of these opcodes
in the GLSL lessThan, greaterThan, lessThanEqual, greaterThanEqual
built-in functions.

Found by code inspection.  Not known to fix any bugs.  Presumably, our
tests for the built-in comparison functions must pass because C.E.
handling is done on the ir_call of "greaterThan" rather than the inlined
opcode.  The C.E. handling of the built-in function calls is correct.

NOTE: This is a candidate for the 7.9 branch.
2010-11-17 11:58:56 -08:00
Marek Olšák
fb7ae06f59 r300g: print FS inputs uninitialized due to hardware limits to stderr 2010-11-17 19:01:12 +01:00
Alex Deucher
75e52556a8 r600c/evergreen: texture align is group_bytes just like 6xx/7xx
Default group bytes to 512 on evergreen.  Don't query
tiling config yet for evergreen, the current info returned is not
adequate for evergreen (no way to get bank info).
2010-11-17 11:30:52 -05:00
Brian Paul
1d39df42c4 mesa: minor clean-ups in context code 2010-11-16 20:12:34 -07:00
Brian Paul
85288ad722 mesa: reorder texture_error_check() params
To better match other functions.
2010-11-16 20:12:34 -07:00
Brian Paul
3c59febf05 mesa: 80-column wrapping 2010-11-16 20:12:34 -07:00
Brian Paul
76114d23d1 mesa: whitespace cleanups 2010-11-16 20:12:34 -07:00
Brian Paul
78527154bd mesa: fix error messages and minor reindenting 2010-11-16 20:12:34 -07:00
Kenneth Graunke
bee901a1cf Refresh autogenerated glcpp parser. 2010-11-16 16:22:13 -08:00
Kenneth Graunke
3fb83038a0 glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version >= 1.30.
Per section 4.5.4 of the GLSL 1.30 specification.
2010-11-16 16:22:12 -08:00
Henri Verbeet
6bbe637c13 r600g: Synchronize supported color formats between Evergreen and r600/r700. 2010-11-17 00:41:42 +01:00
Henri Verbeet
7d0f45563d r600g: Swizzle vertex data only once.
Vertex data swizzles are already done in the vertex shader. Doing them twice
breaks BGRA vertex arrays for example.
2010-11-17 00:41:42 +01:00
Marek Olšák
b6e2c32626 r300g: remove the hack with OPCODE_RET
RET was interpreted as END, which was wrong. Instead, if a shader contains RET
in the main function, it will fail to compile with an error message
from now on.

The hack is from early days.
2010-11-16 22:39:27 +01:00
Ian Romanick
2d2d6a80c1 glsl: Simplify generation of swizzle for vector constructors 2010-11-16 12:11:02 -08:00
Ian Romanick
38e55153af glsl: Refactor is_vec_{zero,one} to be methods of ir_constant
These predicates will be used in other places soon.
2010-11-16 12:11:02 -08:00
José Fonseca
4f84a3aa32 libgl-gdi: Allow to pick softpipe/llvmpipe on runtime. 2010-11-16 18:56:39 +00:00
Vinson Lee
063c6b8f74 mesa: Add definitions for inverse hyperbolic function on MSVC. 2010-11-15 22:00:32 -08:00
Vinson Lee
1935bdca44 glsl: Add ir_constant_expression.cpp to SConscript.
This was accidentally removed in commit 32aaf89823.

Fixes SCons builds.
2010-11-15 20:56:11 -08:00
Brian Paul
9b4b70e7e2 glsl: remove opt_constant_expression.cpp from SConscript
And alphabetize the opt_* files.
2010-11-15 18:59:45 -07:00
Brian Paul
c1928c7f10 mesa: add more work-arounds for acoshf(), asinhf(), atahf() 2010-11-15 18:50:58 -07:00
Brian Paul
88f482a839 glsl: fix assorted MSVC warnings 2010-11-15 18:48:43 -07:00
Brian Paul
20c2debce8 st/mesa: fix glDrawPixels(depth/stencil) bugs
When drawing GL_DEPTH_COMPONENT the usual fragment pipeline steps apply
so don't override the depth state.

When drawing GL_STENCIL_INDEX (or GL_DEPTH_STENCIL) the fragment pipeline
does not apply (only the stencil and Z writemasks apply) so disable writes
to the color buffers.

Fixes some regressions from commit ef8bb7ada9
2010-11-15 18:40:32 -07:00
Kenneth Graunke
32aaf89823 glsl: Rename various ir_* files to lower_* and opt_*.
This helps distinguish between lowering passes, optimization passes, and
other compiler code.
2010-11-15 16:34:20 -08:00
Kenneth Graunke
46b80d6469 glsl: Remove unused and out of date Makefile.am.
This was from when glsl2 lived in a separate repository and used
automake.
2010-11-15 14:47:15 -08:00
Kenneth Graunke
3108095198 glsl: Add constant expression handling for asinh, acosh, and atanh. 2010-11-15 14:08:58 -08:00
Kenneth Graunke
91181c7dd4 glsl: Refresh autogenerated file builtin_function.cpp. 2010-11-15 14:02:52 -08:00
Kenneth Graunke
db9b8c062f glsl: Implement the asinh, acosh, and atanh built-in functions. 2010-11-15 14:02:52 -08:00
Kenneth Graunke
096d36872f generate_builtins.py: Fix inconsistent use of tabs and spaces warning. 2010-11-15 14:02:52 -08:00
Kenneth Graunke
0d082c0e06 glsl: Refresh autogenerated lexer and parser files.
For the last three commits.
2010-11-15 13:33:58 -08:00
Kenneth Graunke
7279feeb19 glsl: Add support for the 'u' and 'U' unsigned integer suffixes. 2010-11-15 13:33:58 -08:00
Kenneth Graunke
2b6c1a0b7c glsl: Add new keywords and reserved words for GLSL 1.30. 2010-11-15 13:33:58 -08:00
Kenneth Graunke
285036fbb0 glsl: Rework reserved word/keyword handling in the lexer.
This consolidates the TOKEN_OR_IDENTIFIER and RESERVED_WORD macros into
a single KEYWORD macro.

The old TOKEN_OR_IDENTIFIER macros handled the case of a word going from
an identifier to a keyword; the RESERVED_WORD macro handled a word going
from a reserved word to a language keyword.  However, neither could
properly handle samplerBuffer (for example), which is an identifier in
1.10 and 1.20, a reserved word in 1.30, and a keyword in 1.40 and on.

Furthermore, the existing macros didn't properly handle reserved words
in GLSL ES 1.00.  The best they could do was return a token (rather than
an identifier), resulting in an obtuse parser error, rather than a
user-friendly "you used a reserved word" error message.
2010-11-15 13:33:57 -08:00
Kenneth Graunke
5dc74e9c77 glsl: Convert glsl_type::base_type from #define'd constants to an enum.
This is nice because printing type->base_type in GDB will now give you a
readable name instead of a number.
2010-11-15 13:33:57 -08:00
Kenneth Graunke
ee36f14fa5 glsl: Remove GLSL_TYPE_FUNCTION define.
Functions are not first class objects in GLSL, so there is never a value
of function type.  No code actually used this except for one function
which asserted it shouldn't occur.  One comment mentioned it, but was
incorrect.  So we may as well remove it entirely.
2010-11-15 13:33:57 -08:00
Henri Verbeet
62fe9c4efc r600g: Add PIPE_FORMAT_L8A8_UNORM for Evergreen as well. 2010-11-15 22:20:12 +01:00
Henri Verbeet
228d0d1153 r600: Evergreen has two extra frac_bits for the sampler LOD state.
Note: this is a candidate for the 7.9 branch.
2010-11-15 22:20:12 +01:00
Henri Verbeet
aa3113ae20 r600g: Evergreen has two extra frac_bits for the sampler LOD state.
The (piglit) mipmap_limits test shows the issue very clearly.
2010-11-15 22:20:12 +01:00
Henri Verbeet
da8c877733 r600g: Cleanup the fenced_bo list in r600_context_fini(). 2010-11-15 22:20:12 +01:00
Jerome Glisse
5da246944a gallium/noop: no operation gallium driver
This driver is a fake swdri driver that perform no operations
beside allocation gallium structure and buffer for upper layer
usage.

It's purpose is to help profiling core mesa/gallium without
having pipe driver overhead hidding hot spot of core code.

scons file are likely inadequate i am unfamiliar with this
build system.

To use it simply rename is to swrast_dri.so and properly set
LIBGL_DRIVERS_PATH env variable.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-11-15 14:56:40 -05:00
Hui Qi Tay
e3f106b5fe llvmpipe: clean up polygon offset function in lp setup code 2010-11-15 17:21:35 +00:00
Francisco Jerez
88850b3e4f dri/nouveau: Kill a bunch of ternary operators. 2010-11-15 17:42:08 +01:00
Francisco Jerez
aceb5b3277 dri/nouveau: Fix typo. 2010-11-15 17:42:08 +01:00
Viktor Novotný
8c94c7138e dri/nouveau: Remove nouveau_class.h, finishing switch to rules-ng-ng headers
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-15 17:42:07 +01:00
Viktor Novotný
69f54d2a7e dri/nouveau nv20: Use rules-ng-ng headers
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-15 17:42:07 +01:00
Viktor Novotný
f4efc256fd dri/nouveau: nv10: Use rules-ng-ng headers
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-15 17:42:07 +01:00
Viktor Novotný
8983855012 dri/nouveau: nv04: Use rules-ng-ng headers
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-15 17:42:06 +01:00
Viktor Novotný
dfc2bf818b dri/nouveau: Import headers from rules-ng-ng
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-15 17:42:06 +01:00
Brian Paul
3e910faed5 evergreen: set gl_texture_image::TexFormat field in evergreenSetTexBuffer()
See https://bugs.freedesktop.org/show_bug.cgi?id=31544

Note: this is a candidate for the 7.9 branch.
2010-11-15 09:31:33 -07:00
Brian Paul
f2f1c61950 r300: set gl_texture_image::TexFormat field in r300SetTexBuffer2()
See https://bugs.freedesktop.org/show_bug.cgi?id=31544

Note: this is a candidate for the 7.9 branch
2010-11-15 09:31:27 -07:00
Brian Paul
401f1efd3a r200: set gl_texture_image::TexFormat field in r200SetTexBuffer2()
See https://bugs.freedesktop.org/show_bug.cgi?id=31544

Note: this is a candidate for the 7.9 branch.
2010-11-15 09:31:21 -07:00
Brian Paul
0ef3b298e6 r600: set gl_texture_image::TexFormat field in r600SetTexBuffer2()
See https://bugs.freedesktop.org/show_bug.cgi?id=31544

Note: this is a candidate for the 7.9 branch.
2010-11-15 09:18:47 -07:00
Brian Paul
86abc1f104 radeon: set gl_texture_image::TexFormat field in radeonSetTexBuffer2()
See https://bugs.freedesktop.org/show_bug.cgi?id=31544

Note: this is a candidate for the 7.9 branch
2010-11-15 09:18:40 -07:00
Julien Cristau
e86b4c9194 Makefile: don't include the same files twice in the tarball
src/mesa/drivers/dri/*/*/*.[chS] is a superset of
src/mesa/drivers/dri/*/server/*.[ch] and
src/mesa/drivers/dri/common/xmlpool/*.[ch].
include/GL/internal/glcore.h is already in MAIN_FILES, no need for it in
DRI_FILES too.  src/glx/Makefile was listed twice.

Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-11-15 08:46:22 -07:00
Daniel Lichtenberger
ef0720758e radeon: fix potential segfault in renderbuffer update
Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=31617

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
2010-11-15 01:32:42 -05:00
Marek Olšák
9cf25b3d1c r300g: return shader caps from Draw for SWTCL vertex shaders 2010-11-14 23:04:18 +01:00
Marek Olšák
ed7cb289b3 r300g: clean up redundancy in draw functions 2010-11-14 19:28:04 +01:00
Eric Anholt
3b337f5cd9 i965: Fix gl_FragCoord inversion when drawing to an FBO.
This showed up as cairo-gl gradients being inverted on everyone but
Intel, where I'd apparently tweaked the transformation to work around
the bug.  Fixes piglit fbo-fragcoord.
2010-11-14 22:35:17 +08:00
Vinson Lee
d11db2a857 i965: Silence uninitialized variable warning.
Silences this GCC warning.
brw_fs.cpp: In member function 'void fs_visitor::split_virtual_grfs()':
brw_fs.cpp:2516: warning: unused variable 'reg'
2010-11-13 21:19:59 -08:00
Marek Olšák
7e2256688a r300g: fix texture border color for all texture formats
This fixes 8 texwrap format tests.
The code should handle arbitrary formats now and is cleaner.

NOTE: This is a candidate for the 7.9 branch.
2010-11-13 16:43:20 +01:00
Vinson Lee
3f6b1756f8 mesa: Clean up header file inclusion in points.h. 2010-11-13 01:16:12 -08:00
Brian Paul
56b4819932 mesa: consolidate assertions in teximage code 2010-11-12 07:21:29 -07:00
Marek Olšák
93edd15178 svga: fill out CAPs for indirect addressing
As per the ps_3_0 and vs_3_0 documentation.
The aL register in D3D9 is quite tricky to use, though.
2010-11-12 03:13:23 +01:00
Marek Olšák
5c7127c07c r600g: fill out CAPs for indirect addressing 2010-11-12 03:13:23 +01:00
Marek Olšák
d279902b40 r300g: fill out CAPs for indirect addressing
To match shader model 2.0 (it's impossible to fully implement ARL
with shader model 3.0 relative addressing).
2010-11-12 03:13:22 +01:00
Marek Olšák
abe2c0d3b0 nvfx: fill out CAPs for indirect addressing
To match shader model 2.0.
2010-11-12 03:13:22 +01:00
Marek Olšák
3c6309e2f7 nv50: fill out CAPs for indirect addressing 2010-11-12 03:13:22 +01:00
Marek Olšák
04bafb2b55 i965g: fill out CAPs for indirect addressing 2010-11-12 03:13:22 +01:00
Marek Olšák
5bf7d668ac i915g: fill out CAPs for indirect addressing 2010-11-12 03:13:22 +01:00
Marek Olšák
53b7ec91ca tgsi: fill out CAPs for indirect addressing 2010-11-12 03:13:22 +01:00
Marek Olšák
cbfdf262cc gallium: add CAPs for indirect addressing and lower it in st/mesa when needed
Required because ATI and NVIDIA DX9 GPUs do not support indirect addressing
of temps, inputs, outputs, and consts (FS-only) or the hw support is so
limited that we cannot use it.

This should make r300g and possibly nvfx more feature complete.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
2010-11-12 03:13:22 +01:00
Brian Paul
d18df9e336 tdfx: s/Format/_BaseFormat/
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31560
2010-11-11 16:56:45 -07:00
Eric Anholt
6929cdd14b glsl: Free the loop state context when we free the loop state.
Since this was talloced off of NULL instead of the compile state, it
was a real leak over the course of the program.  Noticed with
valgrind --leak-check=full --show-reachable=yes.  We should really
change these passes to generally get the compile context as an argument
so simple mistakes like this stop mattering.
2010-11-11 15:12:37 -08:00
Brian Paul
78587ea012 mesa: fix glDeleteBuffers() regression
This fixes a regression (failed assertion) from commit
c552f273f5 which was hit if glDeleteBuffers()
was called on a buffer that was never bound.

NOTE: this is a candidate for the 7.9 branch.
2010-11-11 15:31:36 -07:00
Brian Paul
c552f273f5 mesa: make glIsBuffer() return false for never bound buffers
Use a dummy buffer object as we do for frame/renderbuffer objects.
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31514

Note: this is a candidate for the 7.9 branch.
2010-11-11 14:49:53 -07:00
Aras Pranckevicius
d67df5dd9d glsl: fix crash in loop analysis when some controls can't be determined
Fixes loop-07.frag.
2010-11-11 10:49:37 -08:00
Keith Whitwell
7fb16423cc r600g: enforce minimum stride on render target texture images
Fixes piglit/fbo_readpixels since staging upload changes.
2010-11-11 16:20:24 +00:00
Keith Whitwell
8a3c181e9c r600g: do not try to use staging resource for depth textures
Currently r600_resource_copy_region() will turn these copies into
transfers + memcpys, so to avoid recursion we must not turn those
transfers back into blits.
2010-11-11 15:43:31 +00:00
Brian Paul
b3b6476695 mesa: handle more pixel types in mipmap generation code
NOTE: This is a candidate for the 7.9 branch.
2010-11-11 08:33:42 -07:00
Brian Paul
79c65410c1 mesa: add missing formats in _mesa_format_to_type_and_comps()
NOTE: this is a candidate for the 7.9 branch
2010-11-11 08:31:21 -07:00
Brian Paul
c9126d66fa mesa: improve error message 2010-11-11 07:43:46 -07:00
Brian Paul
624661cae4 mesa: #include mfeatures.h in enums.h 2010-11-11 07:43:46 -07:00
Keith Whitwell
6baad55f15 r600g: guard experimental s3tc code with R600_ENABLE_S3TC 2010-11-11 14:30:09 +00:00
Lucas Stach
089056a5f3 nvfx: fill PIPE_CAP_PRIMITIVE_RESTART and PIPE_CAP_SHADER_STENCIL_EXPORT
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
2010-11-11 14:55:46 +01:00
Francisco Jerez
cdb38b5d3d dri/nouveau: Split hardware/software TNL instantiation more cleanly. 2010-11-11 14:50:50 +01:00
Vinson Lee
dc524adee2 mesa: Fix printf format warnings. 2010-11-10 17:30:59 -08:00
Ian Romanick
bcef51c3b8 mesa: Allow query of MAX_SAMPLES with EXT_framebuffer_multisample
Previously queries of MAX_SAMPLES were only allowed with
ARB_framebuffer_object, but EXT_framebuffer_multisample also enables
this query.  This seems to only effect the i915.  All other drivers
support both extensions or neither extension.

This patch is based on a patch that Kenneth sent along with the report.

NOTE: this is a candidate for the 7.9 branch.

Reported-by: Kenneth Waters <kwaters@chromium.org>
2010-11-10 16:00:03 -08:00
Jakob Bornecrantz
0faa7ada84 libgl-xlib: Use sw helper instead of roll your own 2010-11-10 23:40:18 +00:00
Jakob Bornecrantz
89deebb1af graw: Use inline sw helper instead of roll your own loader 2010-11-10 23:05:17 +00:00
Jakob Bornecrantz
d4c60575f8 galahad: Correct the name of the scons library 2010-11-10 23:05:17 +00:00
Jerome Glisse
8e0230a85c r600g: allow driver to work without submitting cmd to GPU
For driver performance analysis it usefull to be able to
disable as much as possible the GPU interaction so that
one can profile the userspace only.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-11-10 16:49:50 -05:00
Robert Hooker
e8b2d36723 intel: Add a new B43 pci id.
Signed-off-by: Robert Hooker <robert.hooker@canonical.com>
2010-11-10 13:37:47 -08:00
Eric Anholt
9effc1adf1 i965: re-enable gen6 IF statements in the fragment shader.
IF statements were getting flattened while they were broken.  With
Zhenyu's last fix for ENDIF's type, everything appears to have lined
up to actually work.

This regresses two tests:
glsl1-! (not) operator (1, fail)
glsl1-! (not) operator (1, pass)

but fixes tests that couldn't work before because the IFs couldn't be
flattened:
glsl-fs-discard-01
occlusion-query-discard

(and, naturally, this should be a performance improvement for apps
that actually use IF statements to avoid executing a bunch of code).
2010-11-10 13:33:27 -08:00
Eric Anholt
490c23ee6b i965: Work around strangeness in swizzling/masking of gen6 math.
Sometimes we swizzled in a different channel it looked like, and
sometimes we swizzled in zero.  Or something.

Having looked at the output of another code generator for this chip,
this is approximately what they do, too: use align1 math on
temporaries, and then move the results into place.

Fixes:
glean/vp1-EX2 test
glean/vp1-EXP test
glean/vp1-LG2 test
glean/vp1-RCP test (reciprocal)
glean/vp1-RSQ test 1 (reciprocal square root)
shaders/glsl-cos
shaders/glsl-sin
shaders/glsl-vs-masked-cos
shaders/vpfp-generic/vp-exp-alias
2010-11-10 12:36:23 -08:00
Francisco Jerez
47c471f281 meta: Handle bitmaps with alpha test enabled.
Acked-by: Brian Paul <brianp@vmware.com>
2010-11-10 21:24:31 +01:00
Zack Rusin
f623d0c1c2 gallivm: implement indirect addressing over inputs
Instead of messing with the callers simply copy our inputs into a
alloca array at the beginning of the function and then use it.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
2010-11-10 13:00:35 -05:00
Roland Scheidegger
aad65fa112 mesa: remove unneeded DD_POINT_SIZE and DD_LINE_WIDTH tricaps
DD_POINT_SIZE was broken for quite some time, and the only driver (r200) relying
on this no longer needs it.
Both DD_POINT_SIZE and DD_LINE_WIDTH have no users left outside of debugging
output, hence instead of fixing DD_POINT_SIZE setting just drop both of them -
there was a plan to remove tricaps flags entirely at some point.
2010-11-10 17:24:42 +01:00
Roland Scheidegger
c7192ab11f r200: fix r200 large points
DD_POINT_SIZE got never set for some time now (as it was set only in ifdefed
out code), which caused the r200 driver to use the point primitive mistakenly
in some cases which can only do size 1 instead of point sprite. Since the
logic to use point instead of point sprite prim is flaky at best anyway (can't
work correctly for per-vertex point size), just drop this and always emit point
sprites (except for AA points) - reasons why the driver tried to use points for
size 1.0 are unknown though it is possible they are faster or more conformant.
Note that we can't emit point sprites without point sprite cntl as that might
result in undefined point sizes, hence need drm version check (which was
unnecessary before as it should always have selected points). An
alternative would be to rely on the RE point size clamp controls which could
clamp the size to 1.0 min/max even if the SE point size is undefined, but currently
always use 0 for min clamp. (As a side note, this also means the driver does
not honor the gl spec which mandates points, but not point sprites, with zero size
to be rendered as size 1.)
This should fix recent reports of https://bugs.freedesktop.org/show_bug.cgi?id=702.
This is a candidate for the mesa 7.9 branch.
2010-11-10 17:24:41 +01:00
Chia-I Wu
aa139a14ba egl_dri2: Fix __DRI_DRI2 version 1 support.
Correctly set __DRI_API_OPENGL flag.
2010-11-10 23:57:50 +08:00
Marek Olšák
93c04749be r300g: turn magic numbers into names in the hyperz code 2010-11-10 15:14:25 +01:00
Marek Olšák
1d28936dea r300g: rename has_hyperz -> can_hyperz 2010-11-10 15:14:25 +01:00
Marek Olšák
88ddfc57e4 r300g: mention ATI in the renderer string 2010-11-10 15:14:25 +01:00
Keith Whitwell
9a04eca2f8 ws/r600: match bo_busy shared/fence logic in bo_wait
Fixes crash in piglit depthrange-clear.
2010-11-10 11:04:38 +00:00
Vinson Lee
5b8ed2f6d2 mesa: Clean up header file inclusion in pixelstore.h. 2010-11-10 00:49:53 -08:00
Vinson Lee
700add5707 mesa: Clean up header file inclusion in pixel.h. 2010-11-10 00:46:27 -08:00
Zhenyu Wang
65972f992f Revert "i965: VS use SPF mode on sandybridge for now"
This reverts commit 9c39a9fcb2.

Remove VS SPF mode, conditional instruction works for VS now.
2010-11-10 08:17:45 -05:00
Zhenyu Wang
9249af17b8 i965: fix dest type of 'endif' on sandybridge
That should also be immediate value for type W.
2010-11-10 08:17:29 -05:00
Eric Anholt
f289dcd849 i965: Add support for math on constants in gen6 brw_wm_glsl.c path.
Fixes 10 piglit cases that were assertion failing.
2010-11-09 20:20:00 -08:00
Ian Romanick
ad8cb131d8 ir_to_mesa: Refactor code for emitting DP instructions 2010-11-09 18:09:41 -08:00
Eric Anholt
f00929cbdd i965: Allow OPCODE_SWZ to put immediates in the first arg.
Fixes assertion failure with texture swizzling in the GLSL path when
it's triggered (such as gen6 FF or ARB_fp shadow comparisons).

Fixes:
texdepth
texSwizzle
fp1-DST test
fp1-LIT test 3
2010-11-09 17:18:52 -08:00
Kenneth Graunke
afb6fb9a92 glsl: Remove unnecessary "unused variable" warning suppression.
The "instructions" variable -is- used, so the cast to void can go away.
2010-11-09 15:55:40 -08:00
Peter Clifton
efb0417040 intel: Add assert check for blitting alignment.
Also fixup code comment to reflect that the GPU requires DWORD
alignment, but in this case does not actually pass the value "in
DWORDs" as I previously stated.
2010-11-09 14:35:28 -08:00
Eric Anholt
00391c7941 Revert "intel: Fix the client-side swapbuffers throttling."
This reverts commit 76360d6abc.  On
second thought, it turned out that sync objects also used the
wait_rendering API like this, and would need the same treatment, and
so wait_rendering itself is fixed in libdrm now.
2010-11-09 14:03:04 -08:00
Eric Anholt
76360d6abc intel: Fix the client-side swapbuffers throttling.
We were asking for a wait to GTT read (all GPU rendering to it
complete), instead of asking for all GPU reading from it to be
complete.  Prevents swapbuffers-based apps from running away with
rendering, and produces a better input experience.
2010-11-09 13:30:27 -08:00
Ian Romanick
956ae44dcf glsl: Fix incorrect gl_type of sampler2DArray and sampler1DArrayShadow
NOTE: this is a candidate for the 7.9 branch.
2010-11-09 13:05:07 -08:00
José Fonseca
10740acf46 gallivm: Allocate TEMP/OUT arrays only once. 2010-11-09 20:36:28 +00:00
Zack Rusin
528c3cd241 gallivm: implement indirect addressing of the output registers 2010-11-09 20:36:28 +00:00
Vinson Lee
520140a6c9 winsys/xlib: Add cygwin to SConscript.
Fixes SCons NameError exception on Cygwin.
2010-11-09 12:31:11 -08:00
Keith Whitwell
63c3e3a3dc r600: fix my pessimism about PIPE_TRANSFER_x flags
For some reason I though we needed the _DISCARD flag to avoid
readbacks, which isn't true at all.  Now write operations should
pipeline properly, gives a good speedup to demos/tunnel.
2010-11-09 20:12:46 +00:00
Keith Whitwell
9f7ec103e2 r600g: translate ARR instruction 2010-11-09 20:12:46 +00:00
Keith Whitwell
c2c55547dc r600g: attempt to turn on DXTn formats
Seems to sort-of work for non-mipmapped textures.  Better than just
black anyway.
2010-11-09 20:12:46 +00:00
Keith Whitwell
e3ea4aec03 r600g: avoid recursion with staged uploads
Don't use an intermediate for formats which don't support hardware
blits under u_blitter.c, as these will recursively attempt to create a
transfer.
2010-11-09 20:12:46 +00:00
Brian Paul
6e2e136428 mesa: no-op glBufferSubData() on size==0
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31439

NOTE: this is a candidate for the 7.9 branch
2010-11-09 12:24:51 -07:00
Brian Paul
61ea76c8da softpipe: can't no-op depth test stage when occlusion query is enabled
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31479
2010-11-09 11:44:34 -07:00
Chia-I Wu
5b6ec5a553 st/dri: Add support for surfaceless current contexts.
Tested with Wayland.
2010-11-10 02:01:04 +08:00
Chia-I Wu
3418f74a94 docs: Update egl docs. 2010-11-10 01:31:38 +08:00
Chia-I Wu
dbacbb8219 autoconf: Add --enable-gallium-egl.
This option comes handy when we want to build gallium DRI drivers but
not st/egl.
2010-11-10 00:57:49 +08:00
Vinson Lee
3e6a05b1aa mesa: Clean up header file inclusion in nvprogram.h. 2010-11-09 06:22:25 -08:00
Vinson Lee
0c123679fc mesa: Clean up header file inclusion in multisample.h. 2010-11-09 06:08:29 -08:00
Vinson Lee
c509bf91ec mesa: Clean up header file inclusion in matrix.h. 2010-11-09 06:00:01 -08:00
Vinson Lee
e09800432b mesa: Clean up header file inclusion in lines.h. 2010-11-09 05:47:17 -08:00
Vinson Lee
a20e440c65 mesa: Clean up header file inclusion in light.h. 2010-11-09 05:35:24 -08:00
Vinson Lee
934fc80b06 mesa: Add missing header and forward declarations in dd.h. 2010-11-09 05:13:48 -08:00
Vinson Lee
90394b2d96 mesa: Clean up header file inclusion in image.h. 2010-11-09 05:00:44 -08:00
Thomas Hellstrom
24c6c41bd0 gallium/targets: Trivial crosscompiling fix
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-09 12:50:12 +01:00
Thomas Hellstrom
0d5b4b320c svga/drm: Optionally resolve calls to powf during link-time
When linked with certain builds of libstdc++, it appears like powf is resolved
by a symbol in that library. Other builds of libstdc++ doesn't contain that
symbol resulting in a linker / loader error. Optionally
resolve that symbol and replace it with calls to logf and expf.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-09 12:31:25 +01:00
Thomas Hellstrom
8e630fad72 st/egl: Fix build for include files in nonstandard places
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-09 12:31:24 +01:00
Thomas Hellstrom
6af2a7fe2c mesa: Add talloc includes for gles
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-09 12:31:24 +01:00
Thomas Hellstrom
675aec8178 egl: Add an include for size_t
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
2010-11-09 12:31:24 +01:00
Zack Rusin
9d9df964c4 scons: build the xorg state trackers only when env includes drm 2010-11-09 10:41:59 +00:00
Vinson Lee
d79d942b2e mesa: Clean up header file inclusion in histogram.h. 2010-11-09 01:14:55 -08:00
Vinson Lee
5b3d6bd39e mesa: Clean up header file inclusion in hint.h. 2010-11-09 01:12:34 -08:00
Vinson Lee
63f1740a5d mesa: Clean up header file inclusion in framebuffer.h. 2010-11-09 01:04:22 -08:00
Vinson Lee
b35d3b33e7 mesa: Clean up header file inclusion in fog.h. 2010-11-09 00:58:46 -08:00
Vinson Lee
08354667a3 mesa: Clean up header file inclusion in ffvertex_prog.h. 2010-11-09 00:56:02 -08:00
Vinson Lee
6121730e74 mesa: Clean up header file inclusion in fbobject.h. 2010-11-09 00:52:49 -08:00
Chad Versace
b62c1c4595 glsl: Fix ir_expression::constant_expression_value()
When the type of the ir_expression is error_type, return NULL.
This fixes bug 31371.
2010-11-09 00:50:54 -08:00
Johann Rudloff
d7855ee332 radeon: Implement GL_OES_EGL_image
agd5f: add support to radeon/r200/r300 as well
2010-11-08 19:59:53 -05:00
Johann Rudloff
b42e562a11 radeon: Implement __DRI_IMAGE and EGL_MESA_image_drm 2010-11-08 19:59:53 -05:00
Alex Deucher
4990b771de egl_dri2: Add radeon chip ids 2010-11-08 19:59:53 -05:00
Johann Rudloff
f9b5201dbd radeon: Implement EGL_MESA_no_surface_extension 2010-11-08 19:59:53 -05:00
Kenneth Graunke
a457ca7844 ir_dead_functions: Actually free dead functions and signatures.
This makes linked shaders use around 36k less memory since the
built-in prototypes are now freed.
2010-11-08 16:22:15 -08:00
Hui Qi Tay
315f8daab1 llvmpipe: added llvm offset setup code 2010-11-04 12:57:30 +00:00
Hui Qi Tay
7f0dc5ea1b llvmpipe: Moved draw pipeline twoside function to llvm setup code 2010-11-01 14:14:55 +00:00
Keith Whitwell
a1ca5ac7c2 llvmpipe: turn off draw offset/twoside when we can handle it 2010-10-22 18:58:36 +01:00
930 changed files with 126760 additions and 39812 deletions

3
Android.mk Normal file
View File

@@ -0,0 +1,3 @@
ifneq ($(TARGET_SIMULATOR),true)
include $(call all-subdir-makefiles)
endif

View File

@@ -347,23 +347,19 @@ GALLIUM_FILES = \
DRI_FILES = \
$(DIRECTORY)/include/GL/internal/dri_interface.h \
$(DIRECTORY)/include/GL/internal/glcore.h \
$(DIRECTORY)/include/GL/internal/sarea.h \
$(DIRECTORY)/src/glx/Makefile \
$(DIRECTORY)/src/glx/Makefile \
$(DIRECTORY)/src/glx/*.[ch] \
$(DIRECTORY)/src/mesa/drivers/dri/Makefile \
$(DIRECTORY)/src/mesa/drivers/dri/Makefile.template \
$(DIRECTORY)/src/mesa/drivers/dri/dri.pc.in \
$(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.[ch] \
$(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po \
$(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS] \
$(DIRECTORY)/src/mesa/drivers/dri/*/*.cpp \
$(DIRECTORY)/src/mesa/drivers/dri/*/*/*.[chS] \
$(DIRECTORY)/src/mesa/drivers/dri/*/Makefile \
$(DIRECTORY)/src/mesa/drivers/dri/*/*/Makefile \
$(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile \
$(DIRECTORY)/src/mesa/drivers/dri/*/server/*.[ch]
$(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile
SGI_GLU_FILES = \
$(DIRECTORY)/src/glu/Makefile \

View File

@@ -32,7 +32,6 @@ import common
opts = Variables('config.py')
common.AddOptions(opts)
opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
env = Environment(
options = opts,

View File

@@ -91,3 +91,4 @@ def AddOptions(opts):
opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))

View File

@@ -15,7 +15,7 @@ ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DHAVE_UDIS86
# override -std=c99
CFLAGS += -std=gnu99 -D__STDC_CONSTANT_MACROS
CFLAGS += -std=gnu99
LLVM_VERSION := $(shell llvm-config --version)
@@ -30,7 +30,7 @@ else
endif
ifeq ($(MESA_LLVM),1)
# LLVM_CFLAGS=`llvm-config --cflags`
LLVM_CFLAGS=`llvm-config --cppflags`
LLVM_CXXFLAGS=`llvm-config --cxxflags backend bitreader engine ipo interpreter instrumentation` -Wno-long-long
LLVM_LDFLAGS = $(shell llvm-config --ldflags backend bitreader engine ipo interpreter instrumentation)
LLVM_LIBS = $(shell llvm-config --libs backend bitwriter bitreader engine ipo interpreter instrumentation)

View File

@@ -1340,6 +1340,27 @@ AC_SUBST([LLVM_VERSION])
dnl
dnl Gallium state trackers configuration
dnl
AC_ARG_ENABLE([gallium-egl],
[AS_HELP_STRING([--enable-gallium-egl],
[enable gallium EGL state tracker @<:@default=auto@:>@])],
[enable_gallium_egl="$enableval"],
[enable_gallium_egl=auto])
if test "x$enable_gallium_egl" = xauto; then
case "$mesa_driver" in
dri|no)
enable_gallium_egl=$enable_egl
;;
*)
enable_gallium_egl=no
;;
esac
fi
case "x$enable_egl$enable_gallium_egl" in
xnoyes)
AC_MSG_ERROR([cannot build Gallium EGL state tracker without EGL])
esac
AC_ARG_WITH([state-trackers],
[AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@],
[comma delimited state_trackers list, e.g.
@@ -1352,8 +1373,6 @@ no)
GALLIUM_STATE_TRACKERS_DIRS=""
;;
yes)
st_egl="no"
# look at what else is built
case "$mesa_driver" in
xlib)
@@ -1362,14 +1381,11 @@ yes)
dri)
GALLIUM_STATE_TRACKERS_DIRS="dri"
HAVE_ST_DRI="yes"
st_egl="yes"
# Have only tested st/xorg on 1.6.0 servers
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED],
HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
HAVE_ST_XORG="no")
;;
no)
st_egl="yes"
esac
if test "x$enable_egl" = xyes; then
@@ -1378,7 +1394,7 @@ yes)
st_egl="yes"
fi
if test "$st_egl" = yes; then
if test "$enable_gallium_egl" = yes; then
GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
HAVE_ST_EGL="yes"
fi
@@ -1542,7 +1558,7 @@ AC_ARG_ENABLE([gallium-llvm],
if test "x$enable_gallium_llvm" = xyes; then
if test "x$LLVM_CONFIG" != xno; then
LLVM_VERSION=`$LLVM_CONFIG --version`
LLVM_CFLAGS=`$LLVM_CONFIG --cflags`
LLVM_CFLAGS=`$LLVM_CONFIG --cppflags`
LLVM_LIBS="`$LLVM_CONFIG --libs jit interpreter nativecodegen bitwriter` -lstdc++"
if test "x$HAS_UDIS86" != xno; then
@@ -1692,6 +1708,19 @@ if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xau
fi
fi
dnl
dnl Gallium noop configuration
dnl
AC_ARG_ENABLE([gallium-noop],
[AS_HELP_STRING([--enable-gallium-noop],
[build gallium radeon @<:@default=disabled@:>@])],
[enable_gallium_noop="$enableval"],
[enable_gallium_noop=auto])
if test "x$enable_gallium_noop" = xyes; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS noop"
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-noop"
fi
dnl prepend CORE_DIRS to SRC_DIRS
SRC_DIRS="$CORE_DIRS $SRC_DIRS"

View File

@@ -20,7 +20,7 @@ Float textures, renderbuffers some infrastructure done
Framebuffer objects (GL_EXT_framebuffer_object) DONE
Half-float some infrastructure done
Multisample blit DONE
Non-normalized Integer texture/framebuffer formats not started
Non-normalized Integer texture/framebuffer formats ~50% done
1D/2D Texture arrays core Mesa, swrast done
Packed depth/stencil formats DONE
Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE
@@ -31,10 +31,11 @@ Transform feedback (GL_EXT_transform_feedback) ~50% done
glBindBufferRange, glBindBufferBase commands
Vertex array objects (GL_APPLE_vertex_array_object) DONE
sRGB framebuffer format (GL_EXT_framebuffer_sRGB) not started
glClearBuffer commands DONE, except for dispatch
glGetStringi command DONE, except for dispatch
glTexParameterI, glGetTexParameterI commands DONE, except for dispatch
glVertexAttribI commands not started
glClearBuffer commands DONE
glGetStringi command DONE
glTexParameterI, glGetTexParameterI commands DONE
glVertexAttribI commands DONE (but converts int
values to floats)
GL 3.1:
@@ -93,6 +94,18 @@ GL_ARB_texture_buffer_object_rgb32 not started
GL_ARB_texture_cube_map_array not started
GL_ARB_texture_gather not started
GL_ARB_transform_feedback2 not started
GL_ARB_transform_feedback3 not started
GL 4.1:
GLSL 4.1 not started
GL_ARB_ES2_compatibility not started
GL_ARB_get_program_binary not started
GL_ARB_separate_shader_objects some infrastructure done
GL_ARB_shader_precision not started
GL_ARB_vertex_attrib_64bit not started
GL_ARB_viewport_array not started

View File

@@ -83,7 +83,7 @@ Additions to the EGL 1.4 Specification:
EGLImageKHR eglCreateDRMImageMESA(EGLDisplay dpy,
const EGLint *attrib_list);
In the attribute list, pass EGL_WIDTH, EGL_EIGHT and format and
In the attribute list, pass EGL_WIDTH, EGL_HEIGHT and format and
use in the attrib list using EGL_DRM_BUFFER_FORMAT_MESA and
EGL_DRM_BUFFER_USE_MESA. The only format specified by this
extension is EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, where each pixel

View File

@@ -28,17 +28,16 @@ cards.</p>
<ol>
<li>
<p>Run <code>configure</code> with the desired state trackers and enable
the Gallium driver for your hardware. For example</p>
<p>Run <code>configure</code> with the desired client APIs and enable
the driver for your hardware. For example</p>
<pre>
$ ./configure --enable-gles-overlay --enable-openvg --enable-gallium-intel
$ ./configure --enable-gles2 --enable-openvg --enable-gallium-nouveau
</pre>
<p>The main library and OpenGL is enabled by default. The first option enables
<a href="opengles.html">OpenGL ES 1.x and 2.x</a>. The second option enables
<a href="openvg.html">OpenVG</a>.
</p>
<p>The main library and OpenGL is enabled by default. The first option above
enables <a href="opengles.html">OpenGL ES 2.x</a>. The second option enables
<a href="openvg.html">OpenVG</a>.</p>
</li>
@@ -80,31 +79,38 @@ types such as <code>EGLNativeDisplayType</code> or
<p>The available platforms are <code>x11</code>, <code>drm</code>,
<code>fbdev</code>, and <code>gdi</code>. The <code>gdi</code> platform can
only be built with SCons.</p>
</li>
<li><code>--enable-gles-overlay</code>
<p>OpenGL is built by default. To build OpenGL ES, this option must be
explicitly given.</p>
only be built with SCons. Unless for special needs, the build system should
select the right platforms automatically.</p>
</li>
<li><code>--enable-gles1</code> and <code>--enable-gles2</code>
<p>Unlike <code>--enable-gles-overlay</code>, which builds one library for each
rendering API, these options enable OpenGL ES support in OpenGL. The result is
<p>These options enable OpenGL ES support in OpenGL. The result is
one big library that supports multiple APIs.</p>
</li>
<li><code>--enable-gles-overlay</code>
<p>This option enables OpenGL ES as separate libraries. This is an alternative
approach to enable OpenGL ES. It is only supported by
<code>egl_gallium</code>.</p>
</li>
<li><code>--enable-openvg</code>
<p>OpenVG must be explicitly enabled by this option.</p>
</li>
<li><code>--enable-gallium-egl</code>
<p>Explicitly enable or disable <code>egl_gallium</code>.</p>
</li>
</ul>
<h2>Use EGL</h2>
@@ -143,7 +149,12 @@ specific driver. This variable is ignored for setuid/setgid binaries.</p>
<p>This variable specifies the native platform. The valid values are the same
as those for <code>--with-egl-platforms</code>. When the variable is not set,
the main library uses the first platform listed in
<code>--with-egl-platforms</code> as the native platform</p>
<code>--with-egl-platforms</code> as the native platform.</p>
<p>Extensions like <code>EGL_MESA_drm_display</code> define new functions to
create displays for non-native platforms. These extensions are usually used by
applications that support non-native platforms. Setting this variable is
probably required only for some of the demos found in mesa/demo repository.</p>
</li>
@@ -166,6 +177,14 @@ variable to true forces the use of software rendering.</p>
<h2>EGL Drivers</h2>
<ul>
<li><code>egl_dri2</code>
<p>This driver supports both <code>x11</code> and <code>drm</code> platforms.
It functions as a DRI2 driver loader. For <code>x11</code> support, it talks
to the X server directly using (XCB-)DRI2 protocol.</p>
</li>
<li><code>egl_gallium</code>
<p>This driver is based on Gallium3D. It supports all rendering APIs and
@@ -180,15 +199,6 @@ The supported platforms are X11, DRM, FBDEV, and GDI.</p>
the EGL API. It supports both direct and indirect rendering when the GLX does.
It is accelerated when the GLX is. As such, it cannot provide functions that
is not available in GLX or GLX extensions.</p>
</li>
<li><code>egl_dri2</code>
<p>This driver supports the X Window System as its window system. It functions
as a DRI2 driver loader. Unlike <code>egl_glx</code>, it has no dependency on
<code>libGL</code>. It talks to the X server directly using (XCB-)DRI2
protocol.</p>
</li>
</ul>

View File

@@ -49,7 +49,7 @@ tbd
<h2>Changes</h2>
<ul>
<li>tbd</li>
<li>Upgraded glext.h to version 66</li>
</ul>
</body>

View File

@@ -376,6 +376,28 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
#define EGL_Y_INVERTED_NOK 0x307F
#endif /* EGL_NOK_texture_from_pixmap */
#ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1
struct android_native_buffer_t;
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */
#endif
#ifndef EGL_ANDROID_get_render_buffer
#define EGL_ANDROID_get_render_buffer 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLClientBuffer EGLAPIENTRY eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw);
#endif
typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETRENDERBUFFERANDROIDPROC) (EGLDisplay dpy, EGLSurface draw);
#endif
#ifndef EGL_ANDROID_swap_rectangle
#define EGL_ANDROID_swap_rectangle 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
#ifdef __cplusplus
}

View File

@@ -78,6 +78,15 @@ typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(ANDROID) /* Android */
struct android_native_window_t;
struct egl_native_pixmap_t;
typedef struct android_native_window_t* EGLNativeWindowType;
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
typedef void* EGLNativeDisplayType;
#elif defined(__unix__) || defined(__unix)
#ifdef MESA_EGL_NO_X11_HEADERS

View File

@@ -29,9 +29,9 @@ extern "C" {
*/
/* Header file version number, required by OpenGL ABI for Linux */
/* glext.h last updated $Date: 2010-08-03 01:30:25 -0700 (Tue, 03 Aug 2010) $ */
/* glext.h last updated $Date: 2010-11-03 18:59:30 -0700 (Wed, 03 Nov 2010) $ */
/* Current version at http://www.opengl.org/registry/ */
#define GL_GLEXT_VERSION 64
#define GL_GLEXT_VERSION 66
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
@@ -4840,7 +4840,7 @@ extern "C" {
#endif
#ifndef GL_AMD_seamless_cubemap_per_texture
/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB */
/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
#endif
#ifndef GL_AMD_conservative_depth
@@ -4925,6 +4925,8 @@ extern "C" {
#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B
#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C
#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D
#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E
#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F
#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44
#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45
#endif
@@ -5019,6 +5021,11 @@ extern "C" {
#ifndef GL_AMD_transform_feedback3_lines_triangles
#endif
#ifndef GL_AMD_depth_clamp_separate
#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E
#define GL_DEPTH_CLAMP_FAR_AMD 0x901F
#endif
/*************************************************************/
@@ -8765,8 +8772,8 @@ GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdoubl
GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v);
GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v);
GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLuint count, const GLdouble *v);
GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLuint count, const GLfloat *v);
GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs);
GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform);
GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
@@ -8830,8 +8837,8 @@ typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint in
typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v);
typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v);
typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
@@ -11020,6 +11027,10 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons
#define GL_AMD_transform_feedback3_lines_triangles 1
#endif
#ifndef GL_AMD_depth_clamp_separate
#define GL_AMD_depth_clamp_separate 1
#endif
#ifdef __cplusplus
}

View File

@@ -788,6 +788,7 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FORMAT_RGB565 0x1001
#define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
#define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
#define __DRI_IMAGE_FORMAT_RGBA8888_REV 0x1004
#define __DRI_IMAGE_USE_SHARE 0x0001
#define __DRI_IMAGE_USE_SCANOUT 0x0002

View File

@@ -1,8 +1,8 @@
/* $Revision: 6822 $ on $Date:: 2008-10-30 05:14:19 -0400 #$ */
/* $Revision: 9203 $ on $Date:: 2009-10-07 02:21:52 -0700 #$ */
/*------------------------------------------------------------------------
*
* OpenVG 1.0.1 Reference Implementation
* OpenVG 1.1 Reference Implementation
* -------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
@@ -28,7 +28,7 @@
*
*//**
* \file
* \brief OpenVG 1.0.1 API.
* \brief OpenVG 1.1 API.
*//*-------------------------------------------------------------------*/
#ifndef _OPENVG_H
@@ -42,6 +42,7 @@ extern "C" {
#define OPENVG_VERSION_1_0 1
#define OPENVG_VERSION_1_0_1 1
#define OPENVG_VERSION_1_1 2
#ifndef VG_MAXSHORT
#define VG_MAXSHORT 0x7FFF
@@ -55,10 +56,12 @@ extern "C" {
#define VG_MAX_ENUM 0x7FFFFFFF
#endif
typedef long VGHandle;
typedef VGuint VGHandle;
typedef VGHandle VGPath;
typedef VGHandle VGImage;
typedef VGHandle VGMaskLayer;
typedef VGHandle VGFont;
typedef VGHandle VGPaint;
#define VG_INVALID_HANDLE ((VGHandle)0)
@@ -96,6 +99,10 @@ typedef enum {
/* Scissoring rectangles */
VG_SCISSOR_RECTS = 0x1106,
/* Color Transformation */
VG_COLOR_TRANSFORM = 0x1170,
VG_COLOR_TRANSFORM_VALUES = 0x1171,
/* Stroke parameters */
VG_STROKE_LINE_WIDTH = 0x1110,
VG_STROKE_CAP_STYLE = 0x1111,
@@ -111,6 +118,9 @@ typedef enum {
/* Color for vgClear */
VG_CLEAR_COLOR = 0x1121,
/* Glyph origin */
VG_GLYPH_ORIGIN = 0x1122,
/* Enable/disable alpha masking and scissoring */
VG_MASKING = 0x1130,
VG_SCISSORING = 0x1131,
@@ -165,6 +175,7 @@ typedef enum {
VG_MATRIX_IMAGE_USER_TO_SURFACE = 0x1401,
VG_MATRIX_FILL_PAINT_TO_USER = 0x1402,
VG_MATRIX_STROKE_PAINT_TO_USER = 0x1403,
VG_MATRIX_GLYPH_USER_TO_SURFACE = 0x1404,
VG_MATRIX_MODE_FORCE_SIZE = VG_MAX_ENUM
} VGMatrixMode;
@@ -365,6 +376,8 @@ typedef enum {
VG_lL_8 = 10,
VG_A_8 = 11,
VG_BW_1 = 12,
VG_A_1 = 13,
VG_A_4 = 14,
/* {A,X}RGB channel ordering */
VG_sXRGB_8888 = 0 | (1 << 6),
@@ -448,6 +461,12 @@ typedef enum {
VG_BLEND_MODE_FORCE_SIZE = VG_MAX_ENUM
} VGBlendMode;
typedef enum {
VG_FONT_NUM_GLYPHS = 0x2F00,
VG_FONT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
} VGFontParamType;
typedef enum {
VG_IMAGE_FORMAT_QUERY = 0x2100,
VG_PATH_DATATYPE_QUERY = 0x2101,
@@ -541,8 +560,22 @@ VG_API_CALL void VG_API_ENTRY vgShear(VGfloat shx, VGfloat shy) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgRotate(VGfloat angle) VG_API_EXIT;
/* Masking and Clearing */
VG_API_CALL void VG_API_ENTRY vgMask(VGImage mask, VGMaskOperation operation,
VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgMask(VGHandle mask, VGMaskOperation operation,
VGint x, VGint y,
VGint width, VGint height) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgRenderToMask(VGPath path,
VGbitfield paintModes,
VGMaskOperation operation) VG_API_EXIT;
VG_API_CALL VGMaskLayer VG_API_ENTRY vgCreateMaskLayer(VGint width, VGint height) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgDestroyMaskLayer(VGMaskLayer maskLayer) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgFillMaskLayer(VGMaskLayer maskLayer,
VGint x, VGint y,
VGint width, VGint height,
VGfloat value) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgCopyMask(VGMaskLayer maskLayer,
VGint dx, VGint dy,
VGint sx, VGint sy,
VGint width, VGint height) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgClear(VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
/* Paths */
@@ -636,6 +669,33 @@ VG_API_CALL void VG_API_ENTRY vgCopyPixels(VGint dx, VGint dy,
VGint sx, VGint sy,
VGint width, VGint height) VG_API_EXIT;
/* Text */
VG_API_CALL VGFont VG_API_ENTRY vgCreateFont(VGint glyphCapacityHint) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgDestroyFont(VGFont font) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgSetGlyphToPath(VGFont font,
VGuint glyphIndex,
VGPath path,
VGboolean isHinted,
const VGfloat glyphOrigin [2],
const VGfloat escapement[2]) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgSetGlyphToImage(VGFont font,
VGuint glyphIndex,
VGImage image,
const VGfloat glyphOrigin [2],
const VGfloat escapement[2]) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgClearGlyph(VGFont font,VGuint glyphIndex) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgDrawGlyph(VGFont font,
VGuint glyphIndex,
VGbitfield paintModes,
VGboolean allowAutoHinting) VG_API_EXIT;
VG_API_CALL void VG_API_ENTRY vgDrawGlyphs(VGFont font,
VGint glyphCount,
const VGuint *glyphIndices,
const VGfloat *adjustments_x,
const VGfloat *adjustments_y,
VGbitfield paintModes,
VGboolean allowAutoHinting) VG_API_EXIT;
/* Image Filters */
VG_API_CALL void VG_API_ENTRY vgColorMatrix(VGImage dst, VGImage src,
const VGfloat * matrix) VG_API_EXIT;

View File

@@ -1,233 +1,233 @@
/* $Revision: 6810 $ on $Date:: 2008-10-29 10:31:37 -0400 #$ */
/*------------------------------------------------------------------------
*
* VG extensions Reference Implementation
* -------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and /or associated documentation files
* (the "Materials "), to deal in the Materials without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Materials,
* and to permit persons to whom the Materials are furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*//**
* \file
* \brief VG extensions
*//*-------------------------------------------------------------------*/
#ifndef _VGEXT_H
#define _VGEXT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <VG/openvg.h>
#include <VG/vgu.h>
#ifndef VG_API_ENTRYP
# define VG_API_ENTRYP VG_API_ENTRY*
#endif
#ifndef VGU_API_ENTRYP
# define VGU_API_ENTRYP VGU_API_ENTRY*
#endif
/*-------------------------------------------------------------------------------
* KHR extensions
*------------------------------------------------------------------------------*/
typedef enum {
#ifndef VG_KHR_iterative_average_blur
VG_MAX_AVERAGE_BLUR_DIMENSION_KHR = 0x116B,
VG_AVERAGE_BLUR_DIMENSION_RESOLUTION_KHR = 0x116C,
VG_MAX_AVERAGE_BLUR_ITERATIONS_KHR = 0x116D,
#endif
VG_PARAM_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
} VGParamTypeKHR;
#ifndef VG_KHR_EGL_image
#define VG_KHR_EGL_image 1
/* VGEGLImageKHR is an opaque handle to an EGLImage */
typedef void* VGeglImageKHR;
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL VGImage VG_API_ENTRY vgCreateEGLImageTargetKHR(VGeglImageKHR image);
#endif
typedef VGImage (VG_API_ENTRYP PFNVGCREATEEGLIMAGETARGETKHRPROC) (VGeglImageKHR image);
#endif
#ifndef VG_KHR_iterative_average_blur
#define VG_KHR_iterative_average_blur 1
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL void vgIterativeAverageBlurKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
#endif
typedef void (VG_API_ENTRYP PFNVGITERATIVEAVERAGEBLURKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
#endif
#ifndef VG_KHR_advanced_blending
#define VG_KHR_advanced_blending 1
typedef enum {
VG_BLEND_OVERLAY_KHR = 0x2010,
VG_BLEND_HARDLIGHT_KHR = 0x2011,
VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
VG_BLEND_SOFTLIGHT_KHR = 0x2013,
VG_BLEND_COLORDODGE_KHR = 0x2014,
VG_BLEND_COLORBURN_KHR = 0x2015,
VG_BLEND_DIFFERENCE_KHR = 0x2016,
VG_BLEND_SUBTRACT_KHR = 0x2017,
VG_BLEND_INVERT_KHR = 0x2018,
VG_BLEND_EXCLUSION_KHR = 0x2019,
VG_BLEND_LINEARDODGE_KHR = 0x201a,
VG_BLEND_LINEARBURN_KHR = 0x201b,
VG_BLEND_VIVIDLIGHT_KHR = 0x201c,
VG_BLEND_LINEARLIGHT_KHR = 0x201d,
VG_BLEND_PINLIGHT_KHR = 0x201e,
VG_BLEND_HARDMIX_KHR = 0x201f,
VG_BLEND_CLEAR_KHR = 0x2020,
VG_BLEND_DST_KHR = 0x2021,
VG_BLEND_SRC_OUT_KHR = 0x2022,
VG_BLEND_DST_OUT_KHR = 0x2023,
VG_BLEND_SRC_ATOP_KHR = 0x2024,
VG_BLEND_DST_ATOP_KHR = 0x2025,
VG_BLEND_XOR_KHR = 0x2026,
VG_BLEND_MODE_KHR_FORCE_SIZE= VG_MAX_ENUM
} VGBlendModeKHR;
#endif
#ifndef VG_KHR_parametric_filter
#define VG_KHR_parametric_filter 1
typedef enum {
VG_PF_OBJECT_VISIBLE_FLAG_KHR = (1 << 0),
VG_PF_KNOCKOUT_FLAG_KHR = (1 << 1),
VG_PF_OUTER_FLAG_KHR = (1 << 2),
VG_PF_INNER_FLAG_KHR = (1 << 3),
VG_PF_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
} VGPfTypeKHR;
typedef enum {
VGU_IMAGE_IN_USE_ERROR = 0xF010,
VGU_ERROR_CODE_KHR_FORCE_SIZE = VG_MAX_ENUM
} VGUErrorCodeKHR;
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL void VG_API_ENTRY vgParametricFilterKHR(VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguDropShadowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA) ;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
#endif
typedef void (VG_API_ENTRYP PFNVGPARAMETRICFILTERKHRPROC) (VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUDROPSHADOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
#endif
/*-------------------------------------------------------------------------------
* NDS extensions
*------------------------------------------------------------------------------*/
#ifndef VG_NDS_paint_generation
#define VG_NDS_paint_generation 1
typedef enum {
VG_PAINT_COLOR_RAMP_LINEAR_NDS = 0x1A10,
VG_COLOR_MATRIX_NDS = 0x1A11,
VG_PAINT_COLOR_TRANSFORM_LINEAR_NDS = 0x1A12,
VG_PAINT_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGPaintParamTypeNds;
typedef enum {
VG_DRAW_IMAGE_COLOR_MATRIX_NDS = 0x1F10,
VG_IMAGE_MODE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGImageModeNds;
#endif
#ifndef VG_NDS_projective_geometry
#define VG_NDS_projective_geometry 1
typedef enum {
VG_CLIP_MODE_NDS = 0x1180,
VG_CLIP_LINES_NDS = 0x1181,
VG_MAX_CLIP_LINES_NDS = 0x1182,
VG_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGParamTypeNds;
typedef enum {
VG_CLIPMODE_NONE_NDS = 0x3000,
VG_CLIPMODE_CLIP_CLOSED_NDS = 0x3001,
VG_CLIPMODE_CLIP_OPEN_NDS = 0x3002,
VG_CLIPMODE_CULL_NDS = 0x3003,
VG_CLIPMODE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGClipModeNds;
typedef enum {
VG_RQUAD_TO_NDS = ( 13 << 1 ),
VG_RCUBIC_TO_NDS = ( 14 << 1 ),
VG_PATH_SEGMENT_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGPathSegmentNds;
typedef enum {
VG_RQUAD_TO_ABS_NDS = (VG_RQUAD_TO_NDS | VG_ABSOLUTE),
VG_RQUAD_TO_REL_NDS = (VG_RQUAD_TO_NDS | VG_RELATIVE),
VG_RCUBIC_TO_ABS_NDS = (VG_RCUBIC_TO_NDS | VG_ABSOLUTE),
VG_RCUBIC_TO_REL_NDS = (VG_RCUBIC_TO_NDS | VG_RELATIVE),
VG_PATH_COMMAND_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGPathCommandNds;
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL void VG_API_ENTRY vgProjectiveMatrixNDS(VGboolean enable) ;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguTransformClipLineNDS(const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
#endif
typedef void (VG_API_ENTRYP PFNVGPROJECTIVEMATRIXNDSPROC) (VGboolean enable) ;
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUTRANSFORMCLIPLINENDSPROC) (const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _VGEXT_H */
/* $Revision: 6810 $ on $Date:: 2008-10-29 07:31:37 -0700 #$ */
/*------------------------------------------------------------------------
*
* VG extensions Reference Implementation
* -------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and /or associated documentation files
* (the "Materials "), to deal in the Materials without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Materials,
* and to permit persons to whom the Materials are furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*//**
* \file
* \brief VG extensions
*//*-------------------------------------------------------------------*/
#ifndef _VGEXT_H
#define _VGEXT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <VG/openvg.h>
#include <VG/vgu.h>
#ifndef VG_API_ENTRYP
# define VG_API_ENTRYP VG_API_ENTRY*
#endif
#ifndef VGU_API_ENTRYP
# define VGU_API_ENTRYP VGU_API_ENTRY*
#endif
/*-------------------------------------------------------------------------------
* KHR extensions
*------------------------------------------------------------------------------*/
typedef enum {
#ifndef VG_KHR_iterative_average_blur
VG_MAX_AVERAGE_BLUR_DIMENSION_KHR = 0x116B,
VG_AVERAGE_BLUR_DIMENSION_RESOLUTION_KHR = 0x116C,
VG_MAX_AVERAGE_BLUR_ITERATIONS_KHR = 0x116D,
#endif
VG_PARAM_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
} VGParamTypeKHR;
#ifndef VG_KHR_EGL_image
#define VG_KHR_EGL_image 1
/* VGEGLImageKHR is an opaque handle to an EGLImage */
typedef void* VGeglImageKHR;
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL VGImage VG_API_ENTRY vgCreateEGLImageTargetKHR(VGeglImageKHR image);
#endif
typedef VGImage (VG_API_ENTRYP PFNVGCREATEEGLIMAGETARGETKHRPROC) (VGeglImageKHR image);
#endif
#ifndef VG_KHR_iterative_average_blur
#define VG_KHR_iterative_average_blur 1
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL void vgIterativeAverageBlurKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
#endif
typedef void (VG_API_ENTRYP PFNVGITERATIVEAVERAGEBLURKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
#endif
#ifndef VG_KHR_advanced_blending
#define VG_KHR_advanced_blending 1
typedef enum {
VG_BLEND_OVERLAY_KHR = 0x2010,
VG_BLEND_HARDLIGHT_KHR = 0x2011,
VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
VG_BLEND_SOFTLIGHT_KHR = 0x2013,
VG_BLEND_COLORDODGE_KHR = 0x2014,
VG_BLEND_COLORBURN_KHR = 0x2015,
VG_BLEND_DIFFERENCE_KHR = 0x2016,
VG_BLEND_SUBTRACT_KHR = 0x2017,
VG_BLEND_INVERT_KHR = 0x2018,
VG_BLEND_EXCLUSION_KHR = 0x2019,
VG_BLEND_LINEARDODGE_KHR = 0x201a,
VG_BLEND_LINEARBURN_KHR = 0x201b,
VG_BLEND_VIVIDLIGHT_KHR = 0x201c,
VG_BLEND_LINEARLIGHT_KHR = 0x201d,
VG_BLEND_PINLIGHT_KHR = 0x201e,
VG_BLEND_HARDMIX_KHR = 0x201f,
VG_BLEND_CLEAR_KHR = 0x2020,
VG_BLEND_DST_KHR = 0x2021,
VG_BLEND_SRC_OUT_KHR = 0x2022,
VG_BLEND_DST_OUT_KHR = 0x2023,
VG_BLEND_SRC_ATOP_KHR = 0x2024,
VG_BLEND_DST_ATOP_KHR = 0x2025,
VG_BLEND_XOR_KHR = 0x2026,
VG_BLEND_MODE_KHR_FORCE_SIZE= VG_MAX_ENUM
} VGBlendModeKHR;
#endif
#ifndef VG_KHR_parametric_filter
#define VG_KHR_parametric_filter 1
typedef enum {
VG_PF_OBJECT_VISIBLE_FLAG_KHR = (1 << 0),
VG_PF_KNOCKOUT_FLAG_KHR = (1 << 1),
VG_PF_OUTER_FLAG_KHR = (1 << 2),
VG_PF_INNER_FLAG_KHR = (1 << 3),
VG_PF_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
} VGPfTypeKHR;
typedef enum {
VGU_IMAGE_IN_USE_ERROR = 0xF010,
VGU_ERROR_CODE_KHR_FORCE_SIZE = VG_MAX_ENUM
} VGUErrorCodeKHR;
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL void VG_API_ENTRY vgParametricFilterKHR(VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguDropShadowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA) ;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
#endif
typedef void (VG_API_ENTRYP PFNVGPARAMETRICFILTERKHRPROC) (VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUDROPSHADOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
#endif
/*-------------------------------------------------------------------------------
* NDS extensions
*------------------------------------------------------------------------------*/
#ifndef VG_NDS_paint_generation
#define VG_NDS_paint_generation 1
typedef enum {
VG_PAINT_COLOR_RAMP_LINEAR_NDS = 0x1A10,
VG_COLOR_MATRIX_NDS = 0x1A11,
VG_PAINT_COLOR_TRANSFORM_LINEAR_NDS = 0x1A12,
VG_PAINT_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGPaintParamTypeNds;
typedef enum {
VG_DRAW_IMAGE_COLOR_MATRIX_NDS = 0x1F10,
VG_IMAGE_MODE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGImageModeNds;
#endif
#ifndef VG_NDS_projective_geometry
#define VG_NDS_projective_geometry 1
typedef enum {
VG_CLIP_MODE_NDS = 0x1180,
VG_CLIP_LINES_NDS = 0x1181,
VG_MAX_CLIP_LINES_NDS = 0x1182,
VG_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGParamTypeNds;
typedef enum {
VG_CLIPMODE_NONE_NDS = 0x3000,
VG_CLIPMODE_CLIP_CLOSED_NDS = 0x3001,
VG_CLIPMODE_CLIP_OPEN_NDS = 0x3002,
VG_CLIPMODE_CULL_NDS = 0x3003,
VG_CLIPMODE_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGClipModeNds;
typedef enum {
VG_RQUAD_TO_NDS = ( 13 << 1 ),
VG_RCUBIC_TO_NDS = ( 14 << 1 ),
VG_PATH_SEGMENT_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGPathSegmentNds;
typedef enum {
VG_RQUAD_TO_ABS_NDS = (VG_RQUAD_TO_NDS | VG_ABSOLUTE),
VG_RQUAD_TO_REL_NDS = (VG_RQUAD_TO_NDS | VG_RELATIVE),
VG_RCUBIC_TO_ABS_NDS = (VG_RCUBIC_TO_NDS | VG_ABSOLUTE),
VG_RCUBIC_TO_REL_NDS = (VG_RCUBIC_TO_NDS | VG_RELATIVE),
VG_PATH_COMMAND_NDS_FORCE_SIZE = VG_MAX_ENUM
} VGPathCommandNds;
#ifdef VG_VGEXT_PROTOTYPES
VG_API_CALL void VG_API_ENTRY vgProjectiveMatrixNDS(VGboolean enable) ;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguTransformClipLineNDS(const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
#endif
typedef void (VG_API_ENTRYP PFNVGPROJECTIVEMATRIXNDSPROC) (VGboolean enable) ;
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUTRANSFORMCLIPLINENDSPROC) (const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _VGEXT_H */

View File

@@ -1,92 +1,92 @@
/* $Revision: 6810 $ on $Date:: 2008-10-29 10:31:37 -0400 #$ */
/*------------------------------------------------------------------------
*
* VG platform specific header Reference Implementation
* ----------------------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and /or associated documentation files
* (the "Materials "), to deal in the Materials without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Materials,
* and to permit persons to whom the Materials are furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*//**
* \file
* \brief VG platform specific header
*//*-------------------------------------------------------------------*/
#ifndef _VGPLATFORM_H
#define _VGPLATFORM_H
#include <KHR/khrplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef VG_API_CALL
#if defined(OPENVG_STATIC_LIBRARY)
# define VG_API_CALL
#else
# define VG_API_CALL KHRONOS_APICALL
#endif /* defined OPENVG_STATIC_LIBRARY */
#endif /* ifndef VG_API_CALL */
#ifndef VGU_API_CALL
#if defined(OPENVG_STATIC_LIBRARY)
# define VGU_API_CALL
#else
# define VGU_API_CALL KHRONOS_APICALL
#endif /* defined OPENVG_STATIC_LIBRARY */
#endif /* ifndef VGU_API_CALL */
#ifndef VG_API_ENTRY
#define VG_API_ENTRY
#endif
#ifndef VG_API_EXIT
#define VG_API_EXIT
#endif
#ifndef VGU_API_ENTRY
#define VGU_API_ENTRY
#endif
#ifndef VGU_API_EXIT
#define VGU_API_EXIT
#endif
typedef float VGfloat;
typedef signed char VGbyte;
typedef unsigned char VGubyte;
typedef signed short VGshort;
typedef signed int VGint;
typedef unsigned int VGuint;
typedef unsigned int VGbitfield;
#ifndef VG_VGEXT_PROTOTYPES
#define VG_VGEXT_PROTOTYPES
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _VGPLATFORM_H */
/* $Revision: 6810 $ on $Date:: 2008-10-29 07:31:37 -0700 #$ */
/*------------------------------------------------------------------------
*
* VG platform specific header Reference Implementation
* ----------------------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and /or associated documentation files
* (the "Materials "), to deal in the Materials without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Materials,
* and to permit persons to whom the Materials are furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*//**
* \file
* \brief VG platform specific header
*//*-------------------------------------------------------------------*/
#ifndef _VGPLATFORM_H
#define _VGPLATFORM_H
#include <KHR/khrplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef VG_API_CALL
#if defined(OPENVG_STATIC_LIBRARY)
# define VG_API_CALL
#else
# define VG_API_CALL KHRONOS_APICALL
#endif /* defined OPENVG_STATIC_LIBRARY */
#endif /* ifndef VG_API_CALL */
#ifndef VGU_API_CALL
#if defined(OPENVG_STATIC_LIBRARY)
# define VGU_API_CALL
#else
# define VGU_API_CALL KHRONOS_APICALL
#endif /* defined OPENVG_STATIC_LIBRARY */
#endif /* ifndef VGU_API_CALL */
#ifndef VG_API_ENTRY
#define VG_API_ENTRY
#endif
#ifndef VG_API_EXIT
#define VG_API_EXIT
#endif
#ifndef VGU_API_ENTRY
#define VGU_API_ENTRY
#endif
#ifndef VGU_API_EXIT
#define VGU_API_EXIT
#endif
typedef float VGfloat;
typedef signed char VGbyte;
typedef unsigned char VGubyte;
typedef signed short VGshort;
typedef signed int VGint;
typedef unsigned int VGuint;
typedef unsigned int VGbitfield;
#ifndef VG_VGEXT_PROTOTYPES
#define VG_VGEXT_PROTOTYPES
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _VGPLATFORM_H */

View File

@@ -1,130 +1,131 @@
/* $Revision: 6810 $ on $Date:: 2008-10-29 10:31:37 -0400 #$ */
/*------------------------------------------------------------------------
*
* VGU 1.0.1 Reference Implementation
* -------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and /or associated documentation files
* (the "Materials "), to deal in the Materials without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Materials,
* and to permit persons to whom the Materials are furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*//**
* \file
* \brief VGU 1.0.1 API.
*//*-------------------------------------------------------------------*/
#ifndef _VGU_H
#define _VGU_H
#ifdef __cplusplus
extern "C" {
#endif
#include <VG/openvg.h>
#define VGU_VERSION_1_0 1
#ifndef VGU_API_CALL
# error VGU_API_CALL must be defined
#endif
#ifndef VGU_API_ENTRY
# error VGU_API_ENTRY must be defined
#endif
#ifndef VGU_API_EXIT
# error VGU_API_EXIT must be defined
#endif
typedef enum {
VGU_NO_ERROR = 0,
VGU_BAD_HANDLE_ERROR = 0xF000,
VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001,
VGU_OUT_OF_MEMORY_ERROR = 0xF002,
VGU_PATH_CAPABILITY_ERROR = 0xF003,
VGU_BAD_WARP_ERROR = 0xF004,
VGU_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
} VGUErrorCode;
typedef enum {
VGU_ARC_OPEN = 0xF100,
VGU_ARC_CHORD = 0xF101,
VGU_ARC_PIE = 0xF102,
VGU_ARC_TYPE_FORCE_SIZE = VG_MAX_ENUM
} VGUArcType;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguLine(VGPath path,
VGfloat x0, VGfloat y0,
VGfloat x1, VGfloat y1) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguPolygon(VGPath path,
const VGfloat * points, VGint count,
VGboolean closed) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRect(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRoundRect(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height,
VGfloat arcWidth, VGfloat arcHeight) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguEllipse(VGPath path,
VGfloat cx, VGfloat cy,
VGfloat width, VGfloat height) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguArc(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height,
VGfloat startAngle, VGfloat angleExtent,
VGUArcType arcType) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
VGfloat sx3, VGfloat sy3,
VGfloat * matrix) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2,
VGfloat dx3, VGfloat dy3,
VGfloat * matrix) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2,
VGfloat dx3, VGfloat dy3,
VGfloat sx0, VGfloat sy0,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
VGfloat sx3, VGfloat sy3,
VGfloat * matrix) VGU_API_EXIT;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* #ifndef _VGU_H */
/* $Revision: 6810 $ on $Date:: 2008-10-29 07:31:37 -0700 #$ */
/*------------------------------------------------------------------------
*
* VGU 1.1 Reference Implementation
* -------------------------------------
*
* Copyright (c) 2008 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and /or associated documentation files
* (the "Materials "), to deal in the Materials without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Materials,
* and to permit persons to whom the Materials are furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*//**
* \file
* \brief VGU 1.1 API.
*//*-------------------------------------------------------------------*/
#ifndef _VGU_H
#define _VGU_H
#ifdef __cplusplus
extern "C" {
#endif
#include <VG/openvg.h>
#define VGU_VERSION_1_0 1
#define VGU_VERSION_1_1 2
#ifndef VGU_API_CALL
# error VGU_API_CALL must be defined
#endif
#ifndef VGU_API_ENTRY
# error VGU_API_ENTRY must be defined
#endif
#ifndef VGU_API_EXIT
# error VGU_API_EXIT must be defined
#endif
typedef enum {
VGU_NO_ERROR = 0,
VGU_BAD_HANDLE_ERROR = 0xF000,
VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001,
VGU_OUT_OF_MEMORY_ERROR = 0xF002,
VGU_PATH_CAPABILITY_ERROR = 0xF003,
VGU_BAD_WARP_ERROR = 0xF004,
VGU_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
} VGUErrorCode;
typedef enum {
VGU_ARC_OPEN = 0xF100,
VGU_ARC_CHORD = 0xF101,
VGU_ARC_PIE = 0xF102,
VGU_ARC_TYPE_FORCE_SIZE = VG_MAX_ENUM
} VGUArcType;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguLine(VGPath path,
VGfloat x0, VGfloat y0,
VGfloat x1, VGfloat y1) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguPolygon(VGPath path,
const VGfloat * points, VGint count,
VGboolean closed) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRect(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRoundRect(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height,
VGfloat arcWidth, VGfloat arcHeight) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguEllipse(VGPath path,
VGfloat cx, VGfloat cy,
VGfloat width, VGfloat height) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguArc(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height,
VGfloat startAngle, VGfloat angleExtent,
VGUArcType arcType) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
VGfloat sx3, VGfloat sy3,
VGfloat * matrix) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2,
VGfloat dx3, VGfloat dy3,
VGfloat * matrix) VGU_API_EXIT;
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2,
VGfloat dx3, VGfloat dy3,
VGfloat sx0, VGfloat sy0,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
VGfloat sx3, VGfloat sy3,
VGfloat * matrix) VGU_API_EXIT;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* #ifndef _VGU_H */

96
src/Android.mk Normal file
View File

@@ -0,0 +1,96 @@
LOCAL_PATH := $(call my-dir)
# build classic static libraries
MESA_BUILD_CLASSIC := false
# build gallium static libraries
MESA_BUILD_GALLIUM := false
# build gralloc.i915
MESA_BUILD_I915 := false
# build libGLES_i915c
MESA_BUILD_I915C := false
# build libGLES_swrast
MESA_BUILD_SWRAST := false
# build gralloc.vmwgfx
MESA_BUILD_VMWGFX := false
# build libGLES_i915g
MESA_BUILD_I915G := false
# for testing purpose
#BOARD_USES_I915C := true
#BOARD_USES_I915G := true
#BOARD_USES_I965C := true
#BOARD_USES_VMWGFX := true
MESA_GRALLOC_NAME :=
MESA_GLES_NAME :=
ifeq ($(strip $(BOARD_USES_I915C)),true)
MESA_BUILD_CLASSIC := true
MESA_BUILD_I915 := true
MESA_BUILD_I915C := true
MESA_GRALLOC_NAME := i915
MESA_GLES_NAME := i915c
endif
ifeq ($(strip $(BOARD_USES_I915G)),true)
MESA_BUILD_GALLIUM := true
MESA_BUILD_I915 := true
MESA_BUILD_I915G := true
MESA_GRALLOC_NAME := i915
MESA_GLES_NAME := i915g
endif
ifeq ($(strip $(BOARD_USES_I965C)),true)
MESA_BUILD_CLASSIC := true
MESA_BUILD_I915 := true
MESA_BUILD_I965C := true
MESA_GRALLOC_NAME := i915
MESA_GLES_NAME := i965c
endif
ifeq ($(strip $(BOARD_USES_VMWGFX)),true)
MESA_BUILD_GALLIUM := true
MESA_BUILD_SWRAST := true
MESA_BUILD_VMWGFX := true
MESA_GRALLOC_NAME := vmwgfx
MESA_GLES_NAME := swrast
endif
ifneq ($(strip $(MESA_GRALLOC_NAME) $(MESA_GLES_NAME)),)
# build the real modules
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
symlink := $(TARGET_OUT_SHARED_LIBRARIES)/hw/gralloc.$(TARGET_PRODUCT)$(TARGET_SHLIB_SUFFIX)
symlink_to := gralloc.$(MESA_GRALLOC_NAME)$(TARGET_SHLIB_SUFFIX)
$(symlink): PRIVATE_TO := $(symlink_to)
$(symlink): $(TARGET_OUT_SHARED_LIBRARIES)/hw/$(symlink_to)
@echo "Symlink: $@ -> $(PRIVATE_TO)"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf $(PRIVATE_TO) $@
ALL_PREBUILT += $(symlink)
symlink := $(TARGET_OUT_SHARED_LIBRARIES)/egl/libGLES_mesa$(TARGET_SHLIB_SUFFIX)
symlink_to := libGLES_$(MESA_GLES_NAME)$(TARGET_SHLIB_SUFFIX)
$(symlink): PRIVATE_TO := $(symlink_to)
$(symlink): $(TARGET_OUT_SHARED_LIBRARIES)/egl/$(symlink_to)
@echo "Symlink: $@ -> $(PRIVATE_TO)"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf $(PRIVATE_TO) $@
ALL_PREBUILT += $(symlink)
endif # MESA_GRALLOC_NAME || MESA_GLES_NAME

68
src/egl/Android.mk Normal file
View File

@@ -0,0 +1,68 @@
LOCAL_PATH := $(call my-dir)
# from main/Makefile
SOURCES = \
eglapi.c \
eglarray.c \
eglconfig.c \
eglcontext.c \
eglcurrent.c \
egldisplay.c \
egldriver.c \
eglfallbacks.c \
eglglobals.c \
eglimage.c \
egllog.c \
eglmisc.c \
eglmode.c \
eglscreen.c \
eglstring.c \
eglsurface.c \
eglsync.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(addprefix main/, $(SOURCES))
LOCAL_CFLAGS := \
-DPTHREADS \
-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_ANDROID \
-D_EGL_DRIVER_SEARCH_DIR=\"/system/lib/egl\" \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include
LOCAL_MODULE := libmesa_egl
include $(BUILD_STATIC_LIBRARY)
ifeq ($(strip $(MESA_BUILD_CLASSIC)),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
drivers/android/egl_android.c \
drivers/android/droid.c \
drivers/android/droid_core.c \
drivers/android/droid_image.c
LOCAL_CFLAGS := \
-DPTHREADS \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/mapi \
external/mesa/src/egl/main \
external/mesa/src/gralloc \
external/drm \
external/drm/include/drm
LOCAL_MODULE := libmesa_classic_egl
include $(BUILD_STATIC_LIBRARY)
endif # MESA_BUILD_CLASSIC

View File

@@ -0,0 +1,649 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Kristian Høgsberg <krh@bitplanet.net>
*/
#define LOG_TAG "MESA-EGL"
#include <cutils/log.h>
#include "glapi/glapi.h"
#include "droid.h"
static const __DRIuseInvalidateExtension use_invalidate = {
{ __DRI_USE_INVALIDATE, 1 }
};
static __DRIimage *
droid_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
{
_EGLDisplay *disp = data;
struct droid_egl_image *dimg;
_EGLImage *img;
(void) screen;
img = _eglLookupImage(image, disp);
if (img == NULL) {
_eglError(EGL_BAD_PARAMETER, "droid_lookup_egl_image");
return NULL;
}
dimg = droid_egl_image(image);
return dimg->dri_image;
}
static const __DRIimageLookupExtension image_lookup_extension = {
{ __DRI_IMAGE_LOOKUP, 1 },
droid_lookup_egl_image
};
static int
get_format_bpp(int native)
{
int bpp;
/* see libpixelflinger/format.cpp */
switch (native) {
case GGL_PIXEL_FORMAT_RGBA_8888:
case GGL_PIXEL_FORMAT_RGBX_8888:
case GGL_PIXEL_FORMAT_BGRA_8888:
bpp = 4;
break;
case GGL_PIXEL_FORMAT_RGB_888:
bpp = 3;
break;
case GGL_PIXEL_FORMAT_RGB_565:
case GGL_PIXEL_FORMAT_RGBA_5551:
case GGL_PIXEL_FORMAT_RGBA_4444:
case GGL_PIXEL_FORMAT_LA_88:
bpp = 2;
break;
case GGL_PIXEL_FORMAT_RGB_332:
case GGL_PIXEL_FORMAT_A_8:
case GGL_PIXEL_FORMAT_L_8:
bpp = 1;
break;
default:
bpp = 0;
break;
}
return bpp;
}
#include <gralloc_gem.h>
int
get_native_buffer_name(struct android_native_buffer_t *buf)
{
struct drm_bo_t *bo;
bo = drm_gem_get(buf->handle);
return (bo) ? bo->name : 0;
}
EGLBoolean
droid_dequeue_buffer(struct droid_egl_surface *dsurf)
{
__DRIbuffer *buf = &dsurf->dri_buffer;
if (dsurf->window->dequeueBuffer(dsurf->window, &dsurf->buffer))
return EGL_FALSE;
dsurf->buffer->common.incRef(&dsurf->buffer->common);
dsurf->window->lockBuffer(dsurf->window, dsurf->buffer);
buf->attachment = __DRI_BUFFER_FAKE_FRONT_LEFT;
buf->name = get_native_buffer_name(dsurf->buffer);
buf->cpp = get_format_bpp(dsurf->buffer->format);
buf->pitch = dsurf->buffer->stride * buf->cpp;
buf->flags = 0;
return EGL_TRUE;
}
EGLBoolean
droid_enqueue_buffer(struct droid_egl_surface *dsurf)
{
dsurf->window->queueBuffer(dsurf->window, dsurf->buffer);
dsurf->buffer->common.decRef(&dsurf->buffer->common);
dsurf->buffer = NULL;
return EGL_TRUE;
}
static void
droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
}
static __DRIbuffer *
droid_get_buffers_with_format(__DRIdrawable * driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
struct droid_egl_surface *dsurf = loaderPrivate;
struct droid_egl_display *ddpy =
droid_egl_display(dsurf->base.Resource.Display);
if (!dsurf->buffer) {
if (!droid_dequeue_buffer(dsurf))
return NULL;
}
if (width)
*width = dsurf->buffer->width;
if (height)
*height = dsurf->buffer->height;
*out_count = 1;
return &dsurf->dri_buffer;
}
static const EGLint droid_to_egl_attribute_map[] = {
0,
EGL_BUFFER_SIZE, /* __DRI_ATTRIB_BUFFER_SIZE */
EGL_LEVEL, /* __DRI_ATTRIB_LEVEL */
EGL_RED_SIZE, /* __DRI_ATTRIB_RED_SIZE */
EGL_GREEN_SIZE, /* __DRI_ATTRIB_GREEN_SIZE */
EGL_BLUE_SIZE, /* __DRI_ATTRIB_BLUE_SIZE */
EGL_LUMINANCE_SIZE, /* __DRI_ATTRIB_LUMINANCE_SIZE */
EGL_ALPHA_SIZE, /* __DRI_ATTRIB_ALPHA_SIZE */
0, /* __DRI_ATTRIB_ALPHA_MASK_SIZE */
EGL_DEPTH_SIZE, /* __DRI_ATTRIB_DEPTH_SIZE */
EGL_STENCIL_SIZE, /* __DRI_ATTRIB_STENCIL_SIZE */
0, /* __DRI_ATTRIB_ACCUM_RED_SIZE */
0, /* __DRI_ATTRIB_ACCUM_GREEN_SIZE */
0, /* __DRI_ATTRIB_ACCUM_BLUE_SIZE */
0, /* __DRI_ATTRIB_ACCUM_ALPHA_SIZE */
EGL_SAMPLE_BUFFERS, /* __DRI_ATTRIB_SAMPLE_BUFFERS */
EGL_SAMPLES, /* __DRI_ATTRIB_SAMPLES */
0, /* __DRI_ATTRIB_RENDER_TYPE, */
0, /* __DRI_ATTRIB_CONFIG_CAVEAT */
0, /* __DRI_ATTRIB_CONFORMANT */
0, /* __DRI_ATTRIB_DOUBLE_BUFFER */
0, /* __DRI_ATTRIB_STEREO */
0, /* __DRI_ATTRIB_AUX_BUFFERS */
0, /* __DRI_ATTRIB_TRANSPARENT_TYPE */
0, /* __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE */
0, /* __DRI_ATTRIB_TRANSPARENT_RED_VALUE */
0, /* __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE */
0, /* __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE */
0, /* __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE */
0, /* __DRI_ATTRIB_FLOAT_MODE */
0, /* __DRI_ATTRIB_RED_MASK */
0, /* __DRI_ATTRIB_GREEN_MASK */
0, /* __DRI_ATTRIB_BLUE_MASK */
0, /* __DRI_ATTRIB_ALPHA_MASK */
EGL_MAX_PBUFFER_WIDTH, /* __DRI_ATTRIB_MAX_PBUFFER_WIDTH */
EGL_MAX_PBUFFER_HEIGHT, /* __DRI_ATTRIB_MAX_PBUFFER_HEIGHT */
EGL_MAX_PBUFFER_PIXELS, /* __DRI_ATTRIB_MAX_PBUFFER_PIXELS */
0, /* __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH */
0, /* __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT */
0, /* __DRI_ATTRIB_VISUAL_SELECT_GROUP */
0, /* __DRI_ATTRIB_SWAP_METHOD */
EGL_MAX_SWAP_INTERVAL, /* __DRI_ATTRIB_MAX_SWAP_INTERVAL */
EGL_MIN_SWAP_INTERVAL, /* __DRI_ATTRIB_MIN_SWAP_INTERVAL */
0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGB */
0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA */
0, /* __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE */
0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
EGL_Y_INVERTED_NOK, /* __DRI_ATTRIB_YINVERTED */
};
static struct droid_egl_config *
droid_add_config(_EGLDisplay *dpy, const __DRIconfig *dri_config, int id,
int depth, EGLint surface_type, int rgba_masks[4])
{
struct droid_egl_config *conf;
struct droid_egl_display *ddpy;
_EGLConfig base;
unsigned int attrib, value, double_buffer;
EGLint key, bind_to_texture_rgb, bind_to_texture_rgba;
int dri_masks[4] = { 0, 0, 0, 0 };
int i;
ddpy = dpy->DriverData;
_eglInitConfig(&base, dpy, id);
i = 0;
double_buffer = 0;
bind_to_texture_rgb = 0;
bind_to_texture_rgba = 0;
while (ddpy->core->indexConfigAttrib(dri_config, i++, &attrib, &value)) {
switch (attrib) {
case __DRI_ATTRIB_RENDER_TYPE:
if (value & __DRI_ATTRIB_RGBA_BIT)
value = EGL_RGB_BUFFER;
else if (value & __DRI_ATTRIB_LUMINANCE_BIT)
value = EGL_LUMINANCE_BUFFER;
else
assert(0);
_eglSetConfigKey(&base, EGL_COLOR_BUFFER_TYPE, value);
break;
case __DRI_ATTRIB_CONFIG_CAVEAT:
if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
value = EGL_NON_CONFORMANT_CONFIG;
else if (value & __DRI_ATTRIB_SLOW_BIT)
value = EGL_SLOW_CONFIG;
else
value = EGL_NONE;
_eglSetConfigKey(&base, EGL_CONFIG_CAVEAT, value);
break;
case __DRI_ATTRIB_BIND_TO_TEXTURE_RGB:
bind_to_texture_rgb = value;
break;
case __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA:
bind_to_texture_rgba = value;
break;
case __DRI_ATTRIB_DOUBLE_BUFFER:
double_buffer = value;
break;
case __DRI_ATTRIB_RED_MASK:
dri_masks[0] = value;
break;
case __DRI_ATTRIB_GREEN_MASK:
dri_masks[1] = value;
break;
case __DRI_ATTRIB_BLUE_MASK:
dri_masks[2] = value;
break;
case __DRI_ATTRIB_ALPHA_MASK:
dri_masks[3] = value;
break;
default:
key = droid_to_egl_attribute_map[attrib];
if (key != 0)
_eglSetConfigKey(&base, key, value);
break;
}
}
/* In EGL, double buffer or not isn't a config attribute. Pixmaps
* surfaces are always single buffered, pbuffer surfaces are always
* back buffers and windows can be either, selected by passing an
* attribute at window surface construction time. To support this
* we ignore all double buffer configs and manipulate the buffer we
* return in the getBuffer callback to get the behaviour we want. */
if (double_buffer)
return NULL;
if (depth > 0 && depth != _eglGetConfigKey(&base, EGL_BUFFER_SIZE))
return NULL;
if (memcmp(dri_masks, rgba_masks, sizeof(rgba_masks)))
return NULL;
_eglSetConfigKey(&base, EGL_NATIVE_RENDERABLE, EGL_TRUE);
_eglSetConfigKey(&base, EGL_SURFACE_TYPE, surface_type);
if (surface_type & (EGL_PIXMAP_BIT | EGL_PBUFFER_BIT)) {
_eglSetConfigKey(&base, EGL_BIND_TO_TEXTURE_RGB, bind_to_texture_rgb);
if (_eglGetConfigKey(&base, EGL_ALPHA_SIZE) > 0)
_eglSetConfigKey(&base,
EGL_BIND_TO_TEXTURE_RGBA, bind_to_texture_rgba);
}
_eglSetConfigKey(&base, EGL_RENDERABLE_TYPE, dpy->ClientAPIsMask);
_eglSetConfigKey(&base, EGL_CONFORMANT, dpy->ClientAPIsMask);
if (!_eglValidateConfig(&base, EGL_FALSE)) {
_eglLog(_EGL_DEBUG, "DRI2: failed to validate config %d", id);
return NULL;
}
conf = calloc(1, sizeof(*conf));
if (conf != NULL) {
memcpy(&conf->base, &base, sizeof(base));
conf->dri_config = dri_config;
_eglLinkConfig(&conf->base);
}
return conf;
}
static EGLBoolean
droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
{
struct droid_egl_display *ddpy = droid_egl_display(dpy);
const struct {
int format;
int size;
int rgba_masks[4];
} visuals[] = {
{ GGL_PIXEL_FORMAT_RGBA_8888, 32, { 0xff, 0xff00, 0xff0000, 0xff000000 } },
{ GGL_PIXEL_FORMAT_RGBX_8888, 32, { 0xff, 0xff00, 0xff0000, 0x0 } },
{ GGL_PIXEL_FORMAT_RGB_888, 24, { 0xff, 0xff00, 0xff0000, 0x0 } },
{ GGL_PIXEL_FORMAT_RGB_565, 16, { 0xf800, 0x7e0, 0x1f, 0x0 } },
{ GGL_PIXEL_FORMAT_BGRA_8888, 32, { 0xff0000, 0xff00, 0xff, 0xff000000 } },
{ GGL_PIXEL_FORMAT_A_8, 8, { 0xf800, 0x7e0, 0x1f, 0x0 } },
{ 0, 0, { 0, 0, 0, 0 } }
};
int count, i, j;
count = 0;
for (i = 0; visuals[i].format; i++) {
int format_count = 0;
for (j = 0; ddpy->dri_configs[j]; j++) {
struct droid_egl_config *dconf;
dconf = droid_add_config(dpy, ddpy->dri_configs[j], count + 1,
visuals[i].size, EGL_WINDOW_BIT, visuals[i].rgba_masks);
if (dconf) {
_eglSetConfigKey(&dconf->base,
EGL_NATIVE_VISUAL_TYPE, visuals[i].format);
count++;
format_count++;
}
}
if (!format_count) {
_eglLog(_EGL_DEBUG, "No DRI config supports native format 0x%x",
visuals[i].format);
}
}
return (count != 0);
}
struct droid_extension_match {
const char *name;
int version;
int offset;
};
static struct droid_extension_match droid_driver_extensions[] = {
{ __DRI_CORE, 1, offsetof(struct droid_egl_display, core) },
{ __DRI_DRI2, 1, offsetof(struct droid_egl_display, dri2) },
{ NULL, 0, 0 }
};
static struct droid_extension_match droid_core_extensions[] = {
{ __DRI2_FLUSH, 1, offsetof(struct droid_egl_display, flush) },
{ __DRI_IMAGE, 1, offsetof(struct droid_egl_display, image) },
{ NULL, 0, 0 }
};
extern const __DRIextension *__driDriverExtensions[];
static EGLBoolean
droid_bind_extensions(struct droid_egl_display *ddpy,
struct droid_extension_match *matches,
const __DRIextension **extensions)
{
int i, j, ret = EGL_TRUE;
void *field;
for (i = 0; extensions[i]; i++) {
_eglLog(_EGL_DEBUG, "DRI2: found extension `%s'", extensions[i]->name);
for (j = 0; matches[j].name; j++) {
if (strcmp(extensions[i]->name, matches[j].name) == 0 &&
extensions[i]->version >= matches[j].version) {
field = ((char *) ddpy + matches[j].offset);
*(const __DRIextension **) field = extensions[i];
_eglLog(_EGL_INFO, "DRI2: found extension %s version %d",
extensions[i]->name, extensions[i]->version);
}
}
}
for (j = 0; matches[j].name; j++) {
field = ((char *) ddpy + matches[j].offset);
if (*(const __DRIextension **) field == NULL) {
_eglLog(_EGL_FATAL, "DRI2: did not find extension %s version %d",
matches[j].name, matches[j].version);
ret = EGL_FALSE;
}
}
return ret;
}
static EGLBoolean
droid_create_screen(_EGLDisplay *dpy)
{
struct droid_egl_display *ddpy = droid_egl_display(dpy);
const __DRIextension **extensions;
unsigned int api_mask;
ddpy->dri_screen =
ddpy->dri2->createNewScreen(0, ddpy->fd, ddpy->extensions,
&ddpy->dri_configs, dpy);
if (ddpy->dri_screen == NULL) {
_eglLog(_EGL_WARNING, "failed to create dri screen");
return EGL_FALSE;
}
extensions = ddpy->core->getExtensions(ddpy->dri_screen);
if (!droid_bind_extensions(ddpy, droid_core_extensions, extensions)) {
ddpy->core->destroyScreen(ddpy->dri_screen);
return EGL_FALSE;
}
if (ddpy->dri2->base.version >= 2)
api_mask = ddpy->dri2->getAPIMask(ddpy->dri_screen);
else
api_mask = __DRI_API_OPENGL;
dpy->ClientAPIsMask = 0;
if (api_mask & (1 <<__DRI_API_OPENGL))
dpy->ClientAPIsMask |= EGL_OPENGL_BIT;
if (api_mask & (1 <<__DRI_API_GLES))
dpy->ClientAPIsMask |= EGL_OPENGL_ES_BIT;
if (api_mask & (1 << __DRI_API_GLES2))
dpy->ClientAPIsMask |= EGL_OPENGL_ES2_BIT;
if (ddpy->dri2->base.version >= 2) {
dpy->Extensions.KHR_surfaceless_gles1 = EGL_TRUE;
dpy->Extensions.KHR_surfaceless_gles2 = EGL_TRUE;
dpy->Extensions.KHR_surfaceless_opengl = EGL_TRUE;
}
return EGL_TRUE;
}
static EGLBoolean
droid_load_driver(_EGLDisplay *disp)
{
struct droid_egl_display *ddpy = disp->DriverData;
const __DRIextension **extensions;
extensions = __driDriverExtensions;
if (!droid_bind_extensions(ddpy, droid_driver_extensions, extensions))
return EGL_FALSE;
return EGL_TRUE;
}
static EGLBoolean
droid_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy,
EGLint *major, EGLint *minor)
{
struct droid_egl_display *ddpy;
int fd = -1, err, i;
const hw_module_t *mod;
err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod);
if (!err) {
const gralloc_module_t *gr = (gralloc_module_t *) mod;
err = -EINVAL;
if (gr->perform)
err = gr->perform(gr, GRALLOC_MODULE_PERFORM_GET_DRM_FD, &fd);
}
if (err || fd < 0) {
_eglLog(_EGL_WARNING, "fail to get drm fd");
return EGL_FALSE;
}
ddpy = calloc(1, sizeof(*ddpy));
if (!ddpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
dpy->DriverData = (void *) ddpy;
ddpy->fd = fd;
if (!droid_load_driver(dpy))
return EGL_FALSE;
ddpy->loader_extension.base.name = __DRI_DRI2_LOADER;
ddpy->loader_extension.base.version = 3;
ddpy->loader_extension.getBuffers = NULL;
ddpy->loader_extension.flushFrontBuffer = droid_flush_front_buffer;
ddpy->loader_extension.getBuffersWithFormat =
droid_get_buffers_with_format;
ddpy->extensions[0] = &ddpy->loader_extension.base;
ddpy->extensions[1] = &image_lookup_extension.base;
ddpy->extensions[2] = &use_invalidate.base;
ddpy->extensions[3] = NULL;
if (!droid_create_screen(dpy)) {
free(ddpy);
return EGL_FALSE;
}
if (!droid_add_configs_for_visuals(drv, dpy)) {
ddpy->core->destroyScreen(ddpy->dri_screen);
free(ddpy);
}
dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
dpy->Extensions.KHR_image_base = EGL_TRUE;
/* we're supporting EGL 1.4 */
*major = 1;
*minor = 4;
return EGL_TRUE;
}
static EGLBoolean
droid_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
struct droid_egl_display *ddpy = droid_egl_display(dpy);
_eglReleaseDisplayResources(drv, dpy);
_eglCleanupDisplay(dpy);
ddpy->core->destroyScreen(ddpy->dri_screen);
free(ddpy);
dpy->DriverData = NULL;
return EGL_TRUE;
}
static EGLBoolean
droid_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
EGLint *major, EGLint *minor)
{
switch (dpy->Platform) {
case _EGL_PLATFORM_ANDROID:
return droid_initialize_android(drv, dpy, major, minor);
default:
return EGL_FALSE;
}
}
static _EGLProc
droid_get_proc_address(_EGLDriver *drv, const char *procname)
{
return (_EGLProc) _glapi_get_proc_address(procname);
}
static void
droid_unload(_EGLDriver *drv)
{
struct droid_egl_driver *ddrv = droid_egl_driver(drv);
free(ddrv);
}
static void
droid_log(EGLint level, const char *msg)
{
switch (level) {
case _EGL_DEBUG:
LOGD(msg);
break;
case _EGL_INFO:
LOGI(msg);
break;
case _EGL_WARNING:
LOGW(msg);
break;
case _EGL_FATAL:
LOG_FATAL(msg);
break;
default:
break;
}
}
_EGLDriver *
droid_create_driver(void)
{
struct droid_egl_driver *ddrv;
ddrv = calloc(1, sizeof(*ddrv));
if (!ddrv)
return NULL;
_eglSetLogProc(droid_log);
ddrv->base.Name = "Droid";
ddrv->base.Unload = droid_unload;
_eglInitDriverFallbacks(&ddrv->base);
ddrv->base.API.Initialize = droid_initialize;
ddrv->base.API.Terminate = droid_terminate;
ddrv->base.API.GetProcAddress = droid_get_proc_address;
ddrv->glFlush =
(void (*)(void)) droid_get_proc_address(&ddrv->base, "glFlush");
ddrv->glFinish =
(void (*)(void)) droid_get_proc_address(&ddrv->base, "glFinish");
return &ddrv->base;
}

View File

@@ -0,0 +1,126 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Kristian Høgsberg <krh@bitplanet.net>
*/
#ifndef _DROID_H_
#define _DROID_H_
#include <errno.h>
#include <ui/egl/android_natives.h>
#include <ui/android_native_buffer.h>
#include <pixelflinger/format.h>
#include <GL/gl.h>
#include <GL/internal/dri_interface.h>
#include "egldriver.h"
#include "egldisplay.h"
#include "eglcontext.h"
#include "eglsurface.h"
#include "eglconfig.h"
#include "eglimage.h"
#include "eglcurrent.h"
#include "egllog.h"
struct droid_egl_driver
{
_EGLDriver base;
void (*glFlush)(void);
void (*glFinish)(void);
};
struct droid_egl_display
{
int fd;
__DRIscreen *dri_screen;
const __DRIconfig **dri_configs;
__DRIcoreExtension *core;
__DRIdri2Extension *dri2;
__DRI2flushExtension *flush;
__DRIimageExtension *image;
__DRIdri2LoaderExtension loader_extension;
const __DRIextension *extensions[8];
};
struct droid_egl_context
{
_EGLContext base;
__DRIcontext *dri_context;
};
struct droid_egl_surface
{
_EGLSurface base;
__DRIdrawable *dri_drawable;
__DRIbuffer dri_buffer;
android_native_window_t *window;
android_native_buffer_t *buffer;
};
struct droid_egl_config
{
_EGLConfig base;
const __DRIconfig *dri_config;
};
struct droid_egl_image
{
_EGLImage base;
__DRIimage *dri_image;
};
/* standard typecasts */
_EGL_DRIVER_STANDARD_TYPECASTS(droid_egl)
_EGL_DRIVER_TYPECAST(droid_egl_image, _EGLImage, obj)
_EGLDriver *
droid_create_driver(void);
void
droid_init_core_functions(_EGLDriver *drv);
void
droid_init_image_functions(_EGLDriver *drv);
EGLBoolean
droid_dequeue_buffer(struct droid_egl_surface *dsurf);
EGLBoolean
droid_enqueue_buffer(struct droid_egl_surface *dsurf);
int
get_native_buffer_name(struct android_native_buffer_t *buf);
#endif /* _DROID_H_ */

View File

@@ -0,0 +1,327 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Kristian Høgsberg <krh@bitplanet.net>
*/
#include "droid.h"
static _EGLContext *
droid_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
_EGLContext *share_list, const EGLint *attrib_list)
{
struct droid_egl_context *dctx;
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_context *dctx_shared = droid_egl_context(share_list);
struct droid_egl_config *dconf = droid_egl_config(conf);
const __DRIconfig *dri_config;
int api;
(void) drv;
dctx = calloc(1, sizeof *dctx);
if (!dctx) {
_eglError(EGL_BAD_ALLOC, "eglCreateContext");
return NULL;
}
if (!_eglInitContext(&dctx->base, disp, conf, attrib_list))
goto cleanup;
switch (dctx->base.ClientAPI) {
case EGL_OPENGL_ES_API:
switch (dctx->base.ClientVersion) {
case 1:
api = __DRI_API_GLES;
break;
case 2:
api = __DRI_API_GLES2;
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglCreateContext");
return NULL;
}
break;
case EGL_OPENGL_API:
api = __DRI_API_OPENGL;
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglCreateContext");
return NULL;
}
if (conf != NULL)
dri_config = dconf->dri_config;
else
dri_config = NULL;
if (ddpy->dri2->base.version >= 2) {
dctx->dri_context =
ddpy->dri2->createNewContextForAPI(ddpy->dri_screen,
api,
dri_config,
dctx_shared ?
dctx_shared->dri_context : NULL,
dctx);
} else if (api == __DRI_API_OPENGL) {
dctx->dri_context =
ddpy->dri2->createNewContext(ddpy->dri_screen,
dconf->dri_config,
dctx_shared ?
dctx_shared->dri_context : NULL,
dctx);
} else {
/* fail */
}
if (!dctx->dri_context)
goto cleanup;
return &dctx->base;
cleanup:
free(dctx);
return NULL;
}
static _EGLSurface *
droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
_EGLConfig *conf, EGLNativeWindowType window,
const EGLint *attrib_list)
{
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_config *dconf = droid_egl_config(conf);
struct droid_egl_surface *dsurf;
int format, vis_type;
(void) drv;
if (!window || window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
return NULL;
}
if (window->query(window, NATIVE_WINDOW_FORMAT, &format)) {
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
return NULL;
}
vis_type = _eglGetConfigKey(&dconf->base, EGL_NATIVE_VISUAL_TYPE);
if (format != vis_type) {
_eglLog(_EGL_WARNING, "Native format mismatch: 0x%x != 0x%x",
format, vis_type);
}
dsurf = calloc(1, sizeof *dsurf);
if (!dsurf) {
_eglError(EGL_BAD_ALLOC, "droid_create_surface");
return NULL;
}
if (!_eglInitSurface(&dsurf->base, disp, type, conf, attrib_list))
goto cleanup_surf;
dsurf->dri_drawable =
(*ddpy->dri2->createNewDrawable) (ddpy->dri_screen,
dconf->dri_config, dsurf);
if (dsurf->dri_drawable == NULL) {
_eglError(EGL_BAD_ALLOC, "dri2->createNewDrawable");
goto cleanup_pixmap;
}
window->common.incRef(&window->common);
window->query(window, NATIVE_WINDOW_WIDTH, &dsurf->base.Width);
window->query(window, NATIVE_WINDOW_HEIGHT, &dsurf->base.Height);
dsurf->window = window;
return &dsurf->base;
cleanup_dri_drawable:
ddpy->core->destroyDrawable(dsurf->dri_drawable);
cleanup_pixmap:
cleanup_surf:
free(dsurf);
return NULL;
}
static _EGLSurface *
droid_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, EGLNativeWindowType window,
const EGLint *attrib_list)
{
return droid_create_surface(drv, disp, EGL_WINDOW_BIT, conf,
window, attrib_list);
}
static _EGLSurface *
droid_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, EGLNativePixmapType pixmap,
const EGLint *attrib_list)
{
return NULL;
}
static _EGLSurface *
droid_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, const EGLint *attrib_list)
{
return NULL;
}
static EGLBoolean
droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
{
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_surface *dsurf = droid_egl_surface(surf);
(void) drv;
if (!_eglPutSurface(surf))
return EGL_TRUE;
(*ddpy->core->destroyDrawable)(dsurf->dri_drawable);
droid_enqueue_buffer(dsurf);
dsurf->window->common.decRef(&dsurf->window->common);
free(surf);
return EGL_TRUE;
}
static EGLBoolean
droid_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
_EGLSurface *rsurf, _EGLContext *ctx)
{
struct droid_egl_driver *ddrv = droid_egl_driver(drv);
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_surface *droid_dsurf = droid_egl_surface(dsurf);
struct droid_egl_surface *droid_rsurf = droid_egl_surface(rsurf);
struct droid_egl_context *dctx = droid_egl_context(ctx);
_EGLContext *old_ctx;
_EGLSurface *old_dsurf, *old_rsurf;
__DRIdrawable *ddraw, *rdraw;
__DRIcontext *cctx;
/* make new bindings */
if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf))
return EGL_FALSE;
/* flush before context switch */
if (old_ctx && ddrv->glFlush)
ddrv->glFlush();
ddraw = (droid_dsurf) ? droid_dsurf->dri_drawable : NULL;
rdraw = (droid_rsurf) ? droid_rsurf->dri_drawable : NULL;
cctx = (dctx) ? dctx->dri_context : NULL;
if ((cctx == NULL && ddraw == NULL && rdraw == NULL) ||
ddpy->core->bindContext(cctx, ddraw, rdraw)) {
droid_destroy_surface(drv, disp, old_dsurf);
droid_destroy_surface(drv, disp, old_rsurf);
if (old_ctx) {
/* unbind the old context only when there is no new context bound */
if (!ctx) {
__DRIcontext *old_cctx = droid_egl_context(old_ctx)->dri_context;
ddpy->core->unbindContext(old_cctx);
}
/* no destroy? */
_eglPutContext(old_ctx);
}
return EGL_TRUE;
} else {
/* undo the previous _eglBindContext */
_eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &dsurf, &rsurf);
assert(&dctx->base == ctx &&
&droid_dsurf->base == dsurf &&
&droid_rsurf->base == rsurf);
_eglPutSurface(dsurf);
_eglPutSurface(rsurf);
_eglPutContext(ctx);
_eglPutSurface(old_dsurf);
_eglPutSurface(old_rsurf);
_eglPutContext(old_ctx);
return EGL_FALSE;
}
}
static EGLBoolean
droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
struct droid_egl_driver *ddrv = droid_egl_driver(drv);
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_surface *dsurf = droid_egl_surface(draw);
_EGLContext *ctx;
if (ddrv->glFlush) {
ctx = _eglGetCurrentContext();
if (ctx && ctx->DrawSurface == &dsurf->base)
ddrv->glFlush();
}
(*ddpy->flush->flush)(dsurf->dri_drawable);
if (dsurf->buffer)
droid_enqueue_buffer(dsurf);
(*ddpy->flush->invalidate)(dsurf->dri_drawable);
return EGL_TRUE;
}
static EGLBoolean
droid_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
{
struct droid_egl_driver *ddrv = droid_egl_driver(drv);
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_surface *dsurf = droid_egl_surface(ctx->DrawSurface);
if (ddrv->glFinish)
ddrv->glFinish();
if (dsurf)
(*ddpy->flush->flush)(dsurf->dri_drawable);
return EGL_TRUE;
}
void
droid_init_core_functions(_EGLDriver *drv)
{
struct droid_egl_driver *ddrv = droid_egl_driver(drv);
ddrv->base.API.CreateContext = droid_create_context;
ddrv->base.API.CreateWindowSurface = droid_create_window_surface;
ddrv->base.API.CreatePixmapSurface = droid_create_pixmap_surface;
ddrv->base.API.CreatePbufferSurface = droid_create_pbuffer_surface;
ddrv->base.API.DestroySurface = droid_destroy_surface;
ddrv->base.API.MakeCurrent = droid_make_current;
ddrv->base.API.SwapBuffers = droid_swap_buffers;
ddrv->base.API.WaitClient = droid_wait_client;
}

View File

@@ -0,0 +1,134 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Kristian Høgsberg <krh@bitplanet.net>
*/
#include "droid.h"
static _EGLImage *
droid_create_image_android_native_buffer(_EGLDisplay *disp,
EGLClientBuffer buffer)
{
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct android_native_buffer_t *buf =
(struct android_native_buffer_t *) buffer;
struct droid_egl_image *dimg;
EGLint format, name;
if (!buf || buf->common.magic != ANDROID_NATIVE_BUFFER_MAGIC ||
buf->common.version != sizeof(*buf)) {
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
return NULL;
}
name = get_native_buffer_name(buf);
if (!name) {
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
return NULL;
}
switch (buf->format) {
case HAL_PIXEL_FORMAT_BGRA_8888:
format = __DRI_IMAGE_FORMAT_ARGB8888;
break;
case HAL_PIXEL_FORMAT_RGB_565:
format = __DRI_IMAGE_FORMAT_RGB565;
break;
case HAL_PIXEL_FORMAT_RGBA_8888:
format = __DRI_IMAGE_FORMAT_RGBA8888_REV;
break;
case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
/* unsupported */
default:
_eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", buf->format);
return NULL;
break;
}
dimg = calloc(1, sizeof(*dimg));
if (!dimg) {
_eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
return NULL;
}
if (!_eglInitImage(&dimg->base, disp)) {
free(dimg);
return NULL;
}
dimg->dri_image =
ddpy->image->createImageFromName(ddpy->dri_screen,
buf->width,
buf->height,
format,
name,
buf->stride,
dimg);
if (!dimg->dri_image) {
free(dimg);
_eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
return NULL;
}
return &dimg->base;
}
static _EGLImage *
droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
_EGLContext *ctx, EGLenum target,
EGLClientBuffer buffer, const EGLint *attr_list)
{
switch (target) {
case EGL_NATIVE_BUFFER_ANDROID:
return droid_create_image_android_native_buffer(disp, buffer);
default:
_eglError(EGL_BAD_PARAMETER, "droid_create_image_khr");
return EGL_NO_IMAGE_KHR;
}
}
static EGLBoolean
droid_destroy_image_khr(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image)
{
struct droid_egl_display *ddpy = droid_egl_display(disp);
struct droid_egl_image *dimg = droid_egl_image(image);
ddpy->image->destroyImage(dimg->dri_image);
free(dimg);
return EGL_TRUE;
}
void
droid_init_image_functions(_EGLDriver *drv)
{
struct droid_egl_driver *ddrv = droid_egl_driver(drv);
ddrv->base.API.CreateImageKHR = droid_create_image_khr;
ddrv->base.API.DestroyImageKHR = droid_destroy_image_khr;
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Kristian Høgsberg <krh@bitplanet.net>
*/
#include "droid.h"
_EGLDriver *
_eglMain(const char *args)
{
_EGLDriver *drv;
drv = droid_create_driver();
if (drv) {
droid_init_core_functions(drv);
droid_init_image_functions(drv);
}
return drv;
}

View File

@@ -750,7 +750,7 @@ dri2_create_screen(_EGLDisplay *disp)
if (dri2_dpy->dri2->base.version >= 2)
api_mask = dri2_dpy->dri2->getAPIMask(dri2_dpy->dri_screen);
else
api_mask = __DRI_API_OPENGL;
api_mask = 1 << __DRI_API_OPENGL;
disp->ClientAPIsMask = 0;
if (api_mask & (1 <<__DRI_API_OPENGL))
@@ -899,10 +899,20 @@ const int i915_chip_ids[] = {
0x29b2, /* PCI_CHIP_Q35_G */
0x29c2, /* PCI_CHIP_G33_G */
0x29d2, /* PCI_CHIP_Q33_G */
0xa001, /* PCI_CHIP_IGD_G */
0xa011, /* Pineview */
};
const int i965_chip_ids[] = {
0x0042, /* PCI_CHIP_ILD_G */
0x0046, /* PCI_CHIP_ILM_G */
0x0102, /* PCI_CHIP_SANDYBRIDGE_GT1 */
0x0106, /* PCI_CHIP_SANDYBRIDGE_M_GT1 */
0x010a, /* PCI_CHIP_SANDYBRIDGE_S */
0x0112, /* PCI_CHIP_SANDYBRIDGE_GT2 */
0x0116, /* PCI_CHIP_SANDYBRIDGE_M_GT2 */
0x0122, /* PCI_CHIP_SANDYBRIDGE_GT2_PLUS */
0x0126, /* PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS */
0x29a2, /* PCI_CHIP_I965_G */
0x2992, /* PCI_CHIP_I965_Q */
0x2982, /* PCI_CHIP_I965_G_1 */
@@ -914,11 +924,440 @@ const int i965_chip_ids[] = {
0x2e12, /* PCI_CHIP_Q45_G */
0x2e22, /* PCI_CHIP_G45_G */
0x2e32, /* PCI_CHIP_G41_G */
0x2e42, /* PCI_CHIP_B43_G */
0x2e92, /* PCI_CHIP_B43_G1 */
};
const int r100_chip_ids[] = {
0x4C57, /* PCI_CHIP_RADEON_LW */
0x4C58, /* PCI_CHIP_RADEON_LX */
0x4C59, /* PCI_CHIP_RADEON_LY */
0x4C5A, /* PCI_CHIP_RADEON_LZ */
0x5144, /* PCI_CHIP_RADEON_QD */
0x5145, /* PCI_CHIP_RADEON_QE */
0x5146, /* PCI_CHIP_RADEON_QF */
0x5147, /* PCI_CHIP_RADEON_QG */
0x5159, /* PCI_CHIP_RADEON_QY */
0x515A, /* PCI_CHIP_RADEON_QZ */
0x5157, /* PCI_CHIP_RV200_QW */
0x5158, /* PCI_CHIP_RV200_QX */
0x515E, /* PCI_CHIP_RN50_515E */
0x5969, /* PCI_CHIP_RN50_5969 */
0x4136, /* PCI_CHIP_RS100_4136 */
0x4336, /* PCI_CHIP_RS100_4336 */
0x4137, /* PCI_CHIP_RS200_4137 */
0x4337, /* PCI_CHIP_RS200_4337 */
0x4237, /* PCI_CHIP_RS250_4237 */
0x4437, /* PCI_CHIP_RS250_4437 */
};
const int r200_chip_ids[] = {
0x5148, /* PCI_CHIP_R200_QH */
0x514C, /* PCI_CHIP_R200_QL */
0x514D, /* PCI_CHIP_R200_QM */
0x4242, /* PCI_CHIP_R200_BB */
0x4243, /* PCI_CHIP_R200_BC */
0x4966, /* PCI_CHIP_RV250_If */
0x4967, /* PCI_CHIP_RV250_Ig */
0x4C64, /* PCI_CHIP_RV250_Ld */
0x4C66, /* PCI_CHIP_RV250_Lf */
0x4C67, /* PCI_CHIP_RV250_Lg */
0x5960, /* PCI_CHIP_RV280_5960 */
0x5961, /* PCI_CHIP_RV280_5961 */
0x5962, /* PCI_CHIP_RV280_5962 */
0x5964, /* PCI_CHIP_RV280_5964 */
0x5965, /* PCI_CHIP_RV280_5965 */
0x5C61, /* PCI_CHIP_RV280_5C61 */
0x5C63, /* PCI_CHIP_RV280_5C63 */
0x5834, /* PCI_CHIP_RS300_5834 */
0x5835, /* PCI_CHIP_RS300_5835 */
0x7834, /* PCI_CHIP_RS350_7834 */
0x7835, /* PCI_CHIP_RS350_7835 */
};
const int r300_chip_ids[] = {
0x4144, /* PCI_CHIP_R300_AD */
0x4145, /* PCI_CHIP_R300_AE */
0x4146, /* PCI_CHIP_R300_AF */
0x4147, /* PCI_CHIP_R300_AG */
0x4E44, /* PCI_CHIP_R300_ND */
0x4E45, /* PCI_CHIP_R300_NE */
0x4E46, /* PCI_CHIP_R300_NF */
0x4E47, /* PCI_CHIP_R300_NG */
0x4E48, /* PCI_CHIP_R350_NH */
0x4E49, /* PCI_CHIP_R350_NI */
0x4E4B, /* PCI_CHIP_R350_NK */
0x4148, /* PCI_CHIP_R350_AH */
0x4149, /* PCI_CHIP_R350_AI */
0x414A, /* PCI_CHIP_R350_AJ */
0x414B, /* PCI_CHIP_R350_AK */
0x4E4A, /* PCI_CHIP_R360_NJ */
0x4150, /* PCI_CHIP_RV350_AP */
0x4151, /* PCI_CHIP_RV350_AQ */
0x4152, /* PCI_CHIP_RV350_AR */
0x4153, /* PCI_CHIP_RV350_AS */
0x4154, /* PCI_CHIP_RV350_AT */
0x4155, /* PCI_CHIP_RV350_AU */
0x4156, /* PCI_CHIP_RV350_AV */
0x4E50, /* PCI_CHIP_RV350_NP */
0x4E51, /* PCI_CHIP_RV350_NQ */
0x4E52, /* PCI_CHIP_RV350_NR */
0x4E53, /* PCI_CHIP_RV350_NS */
0x4E54, /* PCI_CHIP_RV350_NT */
0x4E56, /* PCI_CHIP_RV350_NV */
0x5460, /* PCI_CHIP_RV370_5460 */
0x5462, /* PCI_CHIP_RV370_5462 */
0x5464, /* PCI_CHIP_RV370_5464 */
0x5B60, /* PCI_CHIP_RV370_5B60 */
0x5B62, /* PCI_CHIP_RV370_5B62 */
0x5B63, /* PCI_CHIP_RV370_5B63 */
0x5B64, /* PCI_CHIP_RV370_5B64 */
0x5B65, /* PCI_CHIP_RV370_5B65 */
0x3150, /* PCI_CHIP_RV380_3150 */
0x3152, /* PCI_CHIP_RV380_3152 */
0x3154, /* PCI_CHIP_RV380_3154 */
0x3155, /* PCI_CHIP_RV380_3155 */
0x3E50, /* PCI_CHIP_RV380_3E50 */
0x3E54, /* PCI_CHIP_RV380_3E54 */
0x4A48, /* PCI_CHIP_R420_JH */
0x4A49, /* PCI_CHIP_R420_JI */
0x4A4A, /* PCI_CHIP_R420_JJ */
0x4A4B, /* PCI_CHIP_R420_JK */
0x4A4C, /* PCI_CHIP_R420_JL */
0x4A4D, /* PCI_CHIP_R420_JM */
0x4A4E, /* PCI_CHIP_R420_JN */
0x4A4F, /* PCI_CHIP_R420_JO */
0x4A50, /* PCI_CHIP_R420_JP */
0x4A54, /* PCI_CHIP_R420_JT */
0x5548, /* PCI_CHIP_R423_UH */
0x5549, /* PCI_CHIP_R423_UI */
0x554A, /* PCI_CHIP_R423_UJ */
0x554B, /* PCI_CHIP_R423_UK */
0x5550, /* PCI_CHIP_R423_5550 */
0x5551, /* PCI_CHIP_R423_UQ */
0x5552, /* PCI_CHIP_R423_UR */
0x5554, /* PCI_CHIP_R423_UT */
0x5D57, /* PCI_CHIP_R423_5D57 */
0x554C, /* PCI_CHIP_R430_554C */
0x554D, /* PCI_CHIP_R430_554D */
0x554E, /* PCI_CHIP_R430_554E */
0x554F, /* PCI_CHIP_R430_554F */
0x5D48, /* PCI_CHIP_R430_5D48 */
0x5D49, /* PCI_CHIP_R430_5D49 */
0x5D4A, /* PCI_CHIP_R430_5D4A */
0x5D4C, /* PCI_CHIP_R480_5D4C */
0x5D4D, /* PCI_CHIP_R480_5D4D */
0x5D4E, /* PCI_CHIP_R480_5D4E */
0x5D4F, /* PCI_CHIP_R480_5D4F */
0x5D50, /* PCI_CHIP_R480_5D50 */
0x5D52, /* PCI_CHIP_R480_5D52 */
0x4B49, /* PCI_CHIP_R481_4B49 */
0x4B4A, /* PCI_CHIP_R481_4B4A */
0x4B4B, /* PCI_CHIP_R481_4B4B */
0x4B4C, /* PCI_CHIP_R481_4B4C */
0x564A, /* PCI_CHIP_RV410_564A */
0x564B, /* PCI_CHIP_RV410_564B */
0x564F, /* PCI_CHIP_RV410_564F */
0x5652, /* PCI_CHIP_RV410_5652 */
0x5653, /* PCI_CHIP_RV410_5653 */
0x5657, /* PCI_CHIP_RV410_5657 */
0x5E48, /* PCI_CHIP_RV410_5E48 */
0x5E4A, /* PCI_CHIP_RV410_5E4A */
0x5E4B, /* PCI_CHIP_RV410_5E4B */
0x5E4C, /* PCI_CHIP_RV410_5E4C */
0x5E4D, /* PCI_CHIP_RV410_5E4D */
0x5E4F, /* PCI_CHIP_RV410_5E4F */
0x5A41, /* PCI_CHIP_RS400_5A41 */
0x5A42, /* PCI_CHIP_RS400_5A42 */
0x5A61, /* PCI_CHIP_RC410_5A61 */
0x5A62, /* PCI_CHIP_RC410_5A62 */
0x5954, /* PCI_CHIP_RS480_5954 */
0x5955, /* PCI_CHIP_RS480_5955 */
0x5974, /* PCI_CHIP_RS482_5974 */
0x5975, /* PCI_CHIP_RS482_5975 */
0x7100, /* PCI_CHIP_R520_7100 */
0x7101, /* PCI_CHIP_R520_7101 */
0x7102, /* PCI_CHIP_R520_7102 */
0x7103, /* PCI_CHIP_R520_7103 */
0x7104, /* PCI_CHIP_R520_7104 */
0x7105, /* PCI_CHIP_R520_7105 */
0x7106, /* PCI_CHIP_R520_7106 */
0x7108, /* PCI_CHIP_R520_7108 */
0x7109, /* PCI_CHIP_R520_7109 */
0x710A, /* PCI_CHIP_R520_710A */
0x710B, /* PCI_CHIP_R520_710B */
0x710C, /* PCI_CHIP_R520_710C */
0x710E, /* PCI_CHIP_R520_710E */
0x710F, /* PCI_CHIP_R520_710F */
0x7140, /* PCI_CHIP_RV515_7140 */
0x7141, /* PCI_CHIP_RV515_7141 */
0x7142, /* PCI_CHIP_RV515_7142 */
0x7143, /* PCI_CHIP_RV515_7143 */
0x7144, /* PCI_CHIP_RV515_7144 */
0x7145, /* PCI_CHIP_RV515_7145 */
0x7146, /* PCI_CHIP_RV515_7146 */
0x7147, /* PCI_CHIP_RV515_7147 */
0x7149, /* PCI_CHIP_RV515_7149 */
0x714A, /* PCI_CHIP_RV515_714A */
0x714B, /* PCI_CHIP_RV515_714B */
0x714C, /* PCI_CHIP_RV515_714C */
0x714D, /* PCI_CHIP_RV515_714D */
0x714E, /* PCI_CHIP_RV515_714E */
0x714F, /* PCI_CHIP_RV515_714F */
0x7151, /* PCI_CHIP_RV515_7151 */
0x7152, /* PCI_CHIP_RV515_7152 */
0x7153, /* PCI_CHIP_RV515_7153 */
0x715E, /* PCI_CHIP_RV515_715E */
0x715F, /* PCI_CHIP_RV515_715F */
0x7180, /* PCI_CHIP_RV515_7180 */
0x7181, /* PCI_CHIP_RV515_7181 */
0x7183, /* PCI_CHIP_RV515_7183 */
0x7186, /* PCI_CHIP_RV515_7186 */
0x7187, /* PCI_CHIP_RV515_7187 */
0x7188, /* PCI_CHIP_RV515_7188 */
0x718A, /* PCI_CHIP_RV515_718A */
0x718B, /* PCI_CHIP_RV515_718B */
0x718C, /* PCI_CHIP_RV515_718C */
0x718D, /* PCI_CHIP_RV515_718D */
0x718F, /* PCI_CHIP_RV515_718F */
0x7193, /* PCI_CHIP_RV515_7193 */
0x7196, /* PCI_CHIP_RV515_7196 */
0x719B, /* PCI_CHIP_RV515_719B */
0x719F, /* PCI_CHIP_RV515_719F */
0x7200, /* PCI_CHIP_RV515_7200 */
0x7210, /* PCI_CHIP_RV515_7210 */
0x7211, /* PCI_CHIP_RV515_7211 */
0x71C0, /* PCI_CHIP_RV530_71C0 */
0x71C1, /* PCI_CHIP_RV530_71C1 */
0x71C2, /* PCI_CHIP_RV530_71C2 */
0x71C3, /* PCI_CHIP_RV530_71C3 */
0x71C4, /* PCI_CHIP_RV530_71C4 */
0x71C5, /* PCI_CHIP_RV530_71C5 */
0x71C6, /* PCI_CHIP_RV530_71C6 */
0x71C7, /* PCI_CHIP_RV530_71C7 */
0x71CD, /* PCI_CHIP_RV530_71CD */
0x71CE, /* PCI_CHIP_RV530_71CE */
0x71D2, /* PCI_CHIP_RV530_71D2 */
0x71D4, /* PCI_CHIP_RV530_71D4 */
0x71D5, /* PCI_CHIP_RV530_71D5 */
0x71D6, /* PCI_CHIP_RV530_71D6 */
0x71DA, /* PCI_CHIP_RV530_71DA */
0x71DE, /* PCI_CHIP_RV530_71DE */
0x7281, /* PCI_CHIP_RV560_7281 */
0x7283, /* PCI_CHIP_RV560_7283 */
0x7287, /* PCI_CHIP_RV560_7287 */
0x7290, /* PCI_CHIP_RV560_7290 */
0x7291, /* PCI_CHIP_RV560_7291 */
0x7293, /* PCI_CHIP_RV560_7293 */
0x7297, /* PCI_CHIP_RV560_7297 */
0x7280, /* PCI_CHIP_RV570_7280 */
0x7288, /* PCI_CHIP_RV570_7288 */
0x7289, /* PCI_CHIP_RV570_7289 */
0x728B, /* PCI_CHIP_RV570_728B */
0x728C, /* PCI_CHIP_RV570_728C */
0x7240, /* PCI_CHIP_R580_7240 */
0x7243, /* PCI_CHIP_R580_7243 */
0x7244, /* PCI_CHIP_R580_7244 */
0x7245, /* PCI_CHIP_R580_7245 */
0x7246, /* PCI_CHIP_R580_7246 */
0x7247, /* PCI_CHIP_R580_7247 */
0x7248, /* PCI_CHIP_R580_7248 */
0x7249, /* PCI_CHIP_R580_7249 */
0x724A, /* PCI_CHIP_R580_724A */
0x724B, /* PCI_CHIP_R580_724B */
0x724C, /* PCI_CHIP_R580_724C */
0x724D, /* PCI_CHIP_R580_724D */
0x724E, /* PCI_CHIP_R580_724E */
0x724F, /* PCI_CHIP_R580_724F */
0x7284, /* PCI_CHIP_R580_7284 */
0x793F, /* PCI_CHIP_RS600_793F */
0x7941, /* PCI_CHIP_RS600_7941 */
0x7942, /* PCI_CHIP_RS600_7942 */
0x791E, /* PCI_CHIP_RS690_791E */
0x791F, /* PCI_CHIP_RS690_791F */
0x796C, /* PCI_CHIP_RS740_796C */
0x796D, /* PCI_CHIP_RS740_796D */
0x796E, /* PCI_CHIP_RS740_796E */
0x796F, /* PCI_CHIP_RS740_796F */
};
const int r600_chip_ids[] = {
0x9400, /* PCI_CHIP_R600_9400 */
0x9401, /* PCI_CHIP_R600_9401 */
0x9402, /* PCI_CHIP_R600_9402 */
0x9403, /* PCI_CHIP_R600_9403 */
0x9405, /* PCI_CHIP_R600_9405 */
0x940A, /* PCI_CHIP_R600_940A */
0x940B, /* PCI_CHIP_R600_940B */
0x940F, /* PCI_CHIP_R600_940F */
0x94C0, /* PCI_CHIP_RV610_94C0 */
0x94C1, /* PCI_CHIP_RV610_94C1 */
0x94C3, /* PCI_CHIP_RV610_94C3 */
0x94C4, /* PCI_CHIP_RV610_94C4 */
0x94C5, /* PCI_CHIP_RV610_94C5 */
0x94C6, /* PCI_CHIP_RV610_94C6 */
0x94C7, /* PCI_CHIP_RV610_94C7 */
0x94C8, /* PCI_CHIP_RV610_94C8 */
0x94C9, /* PCI_CHIP_RV610_94C9 */
0x94CB, /* PCI_CHIP_RV610_94CB */
0x94CC, /* PCI_CHIP_RV610_94CC */
0x94CD, /* PCI_CHIP_RV610_94CD */
0x9580, /* PCI_CHIP_RV630_9580 */
0x9581, /* PCI_CHIP_RV630_9581 */
0x9583, /* PCI_CHIP_RV630_9583 */
0x9586, /* PCI_CHIP_RV630_9586 */
0x9587, /* PCI_CHIP_RV630_9587 */
0x9588, /* PCI_CHIP_RV630_9588 */
0x9589, /* PCI_CHIP_RV630_9589 */
0x958A, /* PCI_CHIP_RV630_958A */
0x958B, /* PCI_CHIP_RV630_958B */
0x958C, /* PCI_CHIP_RV630_958C */
0x958D, /* PCI_CHIP_RV630_958D */
0x958E, /* PCI_CHIP_RV630_958E */
0x958F, /* PCI_CHIP_RV630_958F */
0x9500, /* PCI_CHIP_RV670_9500 */
0x9501, /* PCI_CHIP_RV670_9501 */
0x9504, /* PCI_CHIP_RV670_9504 */
0x9505, /* PCI_CHIP_RV670_9505 */
0x9506, /* PCI_CHIP_RV670_9506 */
0x9507, /* PCI_CHIP_RV670_9507 */
0x9508, /* PCI_CHIP_RV670_9508 */
0x9509, /* PCI_CHIP_RV670_9509 */
0x950F, /* PCI_CHIP_RV670_950F */
0x9511, /* PCI_CHIP_RV670_9511 */
0x9515, /* PCI_CHIP_RV670_9515 */
0x9517, /* PCI_CHIP_RV670_9517 */
0x9519, /* PCI_CHIP_RV670_9519 */
0x95C0, /* PCI_CHIP_RV620_95C0 */
0x95C2, /* PCI_CHIP_RV620_95C2 */
0x95C4, /* PCI_CHIP_RV620_95C4 */
0x95C5, /* PCI_CHIP_RV620_95C5 */
0x95C6, /* PCI_CHIP_RV620_95C6 */
0x95C7, /* PCI_CHIP_RV620_95C7 */
0x95C9, /* PCI_CHIP_RV620_95C9 */
0x95CC, /* PCI_CHIP_RV620_95CC */
0x95CD, /* PCI_CHIP_RV620_95CD */
0x95CE, /* PCI_CHIP_RV620_95CE */
0x95CF, /* PCI_CHIP_RV620_95CF */
0x9590, /* PCI_CHIP_RV635_9590 */
0x9591, /* PCI_CHIP_RV635_9591 */
0x9593, /* PCI_CHIP_RV635_9593 */
0x9595, /* PCI_CHIP_RV635_9595 */
0x9596, /* PCI_CHIP_RV635_9596 */
0x9597, /* PCI_CHIP_RV635_9597 */
0x9598, /* PCI_CHIP_RV635_9598 */
0x9599, /* PCI_CHIP_RV635_9599 */
0x959B, /* PCI_CHIP_RV635_959B */
0x9610, /* PCI_CHIP_RS780_9610 */
0x9611, /* PCI_CHIP_RS780_9611 */
0x9612, /* PCI_CHIP_RS780_9612 */
0x9613, /* PCI_CHIP_RS780_9613 */
0x9614, /* PCI_CHIP_RS780_9614 */
0x9615, /* PCI_CHIP_RS780_9615 */
0x9616, /* PCI_CHIP_RS780_9616 */
0x9710, /* PCI_CHIP_RS880_9710 */
0x9711, /* PCI_CHIP_RS880_9711 */
0x9712, /* PCI_CHIP_RS880_9712 */
0x9713, /* PCI_CHIP_RS880_9713 */
0x9714, /* PCI_CHIP_RS880_9714 */
0x9715, /* PCI_CHIP_RS880_9715 */
0x9440, /* PCI_CHIP_RV770_9440 */
0x9441, /* PCI_CHIP_RV770_9441 */
0x9442, /* PCI_CHIP_RV770_9442 */
0x9443, /* PCI_CHIP_RV770_9443 */
0x9444, /* PCI_CHIP_RV770_9444 */
0x9446, /* PCI_CHIP_RV770_9446 */
0x944A, /* PCI_CHIP_RV770_944A */
0x944B, /* PCI_CHIP_RV770_944B */
0x944C, /* PCI_CHIP_RV770_944C */
0x944E, /* PCI_CHIP_RV770_944E */
0x9450, /* PCI_CHIP_RV770_9450 */
0x9452, /* PCI_CHIP_RV770_9452 */
0x9456, /* PCI_CHIP_RV770_9456 */
0x945A, /* PCI_CHIP_RV770_945A */
0x945B, /* PCI_CHIP_RV770_945B */
0x945E, /* PCI_CHIP_RV770_945E */
0x9460, /* PCI_CHIP_RV790_9460 */
0x9462, /* PCI_CHIP_RV790_9462 */
0x946A, /* PCI_CHIP_RV770_946A */
0x946B, /* PCI_CHIP_RV770_946B */
0x947A, /* PCI_CHIP_RV770_947A */
0x947B, /* PCI_CHIP_RV770_947B */
0x9480, /* PCI_CHIP_RV730_9480 */
0x9487, /* PCI_CHIP_RV730_9487 */
0x9488, /* PCI_CHIP_RV730_9488 */
0x9489, /* PCI_CHIP_RV730_9489 */
0x948A, /* PCI_CHIP_RV730_948A */
0x948F, /* PCI_CHIP_RV730_948F */
0x9490, /* PCI_CHIP_RV730_9490 */
0x9491, /* PCI_CHIP_RV730_9491 */
0x9495, /* PCI_CHIP_RV730_9495 */
0x9498, /* PCI_CHIP_RV730_9498 */
0x949C, /* PCI_CHIP_RV730_949C */
0x949E, /* PCI_CHIP_RV730_949E */
0x949F, /* PCI_CHIP_RV730_949F */
0x9540, /* PCI_CHIP_RV710_9540 */
0x9541, /* PCI_CHIP_RV710_9541 */
0x9542, /* PCI_CHIP_RV710_9542 */
0x954E, /* PCI_CHIP_RV710_954E */
0x954F, /* PCI_CHIP_RV710_954F */
0x9552, /* PCI_CHIP_RV710_9552 */
0x9553, /* PCI_CHIP_RV710_9553 */
0x9555, /* PCI_CHIP_RV710_9555 */
0x9557, /* PCI_CHIP_RV710_9557 */
0x955F, /* PCI_CHIP_RV710_955F */
0x94A0, /* PCI_CHIP_RV740_94A0 */
0x94A1, /* PCI_CHIP_RV740_94A1 */
0x94A3, /* PCI_CHIP_RV740_94A3 */
0x94B1, /* PCI_CHIP_RV740_94B1 */
0x94B3, /* PCI_CHIP_RV740_94B3 */
0x94B4, /* PCI_CHIP_RV740_94B4 */
0x94B5, /* PCI_CHIP_RV740_94B5 */
0x94B9, /* PCI_CHIP_RV740_94B9 */
0x68E0, /* PCI_CHIP_CEDAR_68E0 */
0x68E1, /* PCI_CHIP_CEDAR_68E1 */
0x68E4, /* PCI_CHIP_CEDAR_68E4 */
0x68E5, /* PCI_CHIP_CEDAR_68E5 */
0x68E8, /* PCI_CHIP_CEDAR_68E8 */
0x68E9, /* PCI_CHIP_CEDAR_68E9 */
0x68F1, /* PCI_CHIP_CEDAR_68F1 */
0x68F8, /* PCI_CHIP_CEDAR_68F8 */
0x68F9, /* PCI_CHIP_CEDAR_68F9 */
0x68FE, /* PCI_CHIP_CEDAR_68FE */
0x68C0, /* PCI_CHIP_REDWOOD_68C0 */
0x68C1, /* PCI_CHIP_REDWOOD_68C1 */
0x68C8, /* PCI_CHIP_REDWOOD_68C8 */
0x68C9, /* PCI_CHIP_REDWOOD_68C9 */
0x68D8, /* PCI_CHIP_REDWOOD_68D8 */
0x68D9, /* PCI_CHIP_REDWOOD_68D9 */
0x68DA, /* PCI_CHIP_REDWOOD_68DA */
0x68DE, /* PCI_CHIP_REDWOOD_68DE */
0x68A0, /* PCI_CHIP_JUNIPER_68A0 */
0x68A1, /* PCI_CHIP_JUNIPER_68A1 */
0x68A8, /* PCI_CHIP_JUNIPER_68A8 */
0x68A9, /* PCI_CHIP_JUNIPER_68A9 */
0x68B0, /* PCI_CHIP_JUNIPER_68B0 */
0x68B8, /* PCI_CHIP_JUNIPER_68B8 */
0x68B9, /* PCI_CHIP_JUNIPER_68B9 */
0x68BE, /* PCI_CHIP_JUNIPER_68BE */
0x6880, /* PCI_CHIP_CYPRESS_6880 */
0x6888, /* PCI_CHIP_CYPRESS_6888 */
0x6889, /* PCI_CHIP_CYPRESS_6889 */
0x688A, /* PCI_CHIP_CYPRESS_688A */
0x6898, /* PCI_CHIP_CYPRESS_6898 */
0x6899, /* PCI_CHIP_CYPRESS_6899 */
0x689E, /* PCI_CHIP_CYPRESS_689E */
0x689C, /* PCI_CHIP_HEMLOCK_689C */
0x689D, /* PCI_CHIP_HEMLOCK_689D */
};
const struct dri2_driver_map driver_map[] = {
{ 0x8086, "i915", i915_chip_ids, ARRAY_SIZE(i915_chip_ids) },
{ 0x8086, "i965", i965_chip_ids, ARRAY_SIZE(i965_chip_ids) },
{ 0x1002, "radeon", r100_chip_ids, ARRAY_SIZE(r100_chip_ids) },
{ 0x1002, "r200", r200_chip_ids, ARRAY_SIZE(r200_chip_ids) },
{ 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
{ 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
};
static char *
@@ -1209,7 +1648,11 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
dri2_destroy_surface(drv, disp, old_dsurf);
dri2_destroy_surface(drv, disp, old_rsurf);
if (old_ctx) {
dri2_dpy->core->unbindContext(dri2_egl_context(old_ctx)->dri_context);
/* unbind the old context only when there is no new context bound */
if (!ctx) {
__DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
dri2_dpy->core->unbindContext(old_cctx);
}
/* no destroy? */
_eglPutContext(old_ctx);
}

View File

@@ -916,6 +916,12 @@ eglGetProcAddress(const char *procname)
#ifdef EGL_MESA_drm_image
{ "eglCreateDRMImageMESA", (_EGLProc) eglCreateDRMImageMESA },
{ "eglExportDRMImageMESA", (_EGLProc) eglExportDRMImageMESA },
#endif
#ifdef EGL_ANDROID_swap_rectangle
{ "eglSetSwapRectangleANDROID", (_EGLProc) eglSetSwapRectangleANDROID },
#endif
#ifdef EGL_ANDROID_get_render_buffer
{ "eglGetRenderBufferANDROID", (_EGLProc) eglGetRenderBufferANDROID },
#endif
{ NULL, NULL }
};
@@ -1494,3 +1500,49 @@ eglExportDRMImageMESA(EGLDisplay dpy, EGLImageKHR image,
}
#endif
#ifdef EGL_ANDROID_swap_rectangle
EGLBoolean EGLAPIENTRY
eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
EGLint left, EGLint top,
EGLint width, EGLint height)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLSurface *surf = _eglLookupSurface(draw, disp);
_EGLDriver *drv;
EGLBoolean ret;
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
if (!disp->Extensions.ANDROID_swap_rectangle)
RETURN_EGL_EVAL(disp, EGL_FALSE);
ret = drv->API.SetSwapRectangleANDROID(drv, disp, surf, left, top, width, height);
RETURN_EGL_EVAL(disp, ret);
}
#endif
#ifdef EGL_ANDROID_get_render_buffer
EGLClientBuffer EGLAPIENTRY
eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLSurface *surf = _eglLookupSurface(draw, disp);
_EGLDriver *drv;
EGLClientBuffer ret;
_EGL_CHECK_SURFACE(disp, surf, NULL, drv);
if (!disp->Extensions.ANDROID_get_render_buffer)
RETURN_EGL_EVAL(disp, NULL);
ret = drv->API.GetRenderBufferANDROID(drv, disp, surf);
RETURN_EGL_EVAL(disp, ret);
}
#endif

View File

@@ -95,6 +95,14 @@ typedef _EGLImage *(*CreateDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, c
typedef EGLBoolean (*ExportDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride);
#endif
#ifdef EGL_ANDROID_swap_rectangle
typedef EGLBoolean (*SetSwapRectangleANDROID_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
#ifdef EGL_ANDROID_get_render_buffer
typedef EGLClientBuffer (*GetRenderBufferANDROID_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw);
#endif
/**
* The API dispatcher jumps through these functions
*/
@@ -169,6 +177,13 @@ struct _egl_api
CreateDRMImageMESA_t CreateDRMImageMESA;
ExportDRMImageMESA_t ExportDRMImageMESA;
#endif
#ifdef EGL_ANDROID_swap_rectangle
SetSwapRectangleANDROID_t SetSwapRectangleANDROID;
#endif
#ifdef EGL_ANDROID_get_render_buffer
GetRenderBufferANDROID_t GetRenderBufferANDROID;
#endif
};
#endif /* EGLAPI_INCLUDED */

View File

@@ -118,38 +118,39 @@ _eglFindArray(_EGLArray *array, void *elem)
/**
* Filter an array and return the filtered data. The returned data pointer
* should be freed.
* Filter an array and return the number of filtered elements.
*/
void **
_eglFilterArray(_EGLArray *array, EGLint *size,
EGLint
_eglFilterArray(_EGLArray *array, void **data, EGLint size,
_EGLArrayForEach filter, void *filter_data)
{
void **data;
EGLint count = 0, i;
if (!array) {
*size = 0;
return malloc(0);
}
data = malloc(array->Size * sizeof(array->Elements[0]));
if (!data)
return NULL;
if (!array)
return 0;
if (filter) {
for (i = 0; i < array->Size; i++) {
if (filter(array->Elements[i], filter_data))
data[count++] = array->Elements[i];
if (filter(array->Elements[i], filter_data)) {
if (data && count < size)
data[count] = array->Elements[i];
count++;
}
if (data && count >= size)
break;
}
}
else {
memcpy(data, array->Elements, array->Size * sizeof(array->Elements[0]));
if (data) {
count = (size < array->Size) ? size : array->Size;
memcpy(data, array->Elements, count * sizeof(array->Elements[0]));
}
else {
count = array->Size;
}
}
*size = count;
return data;
return count;
}

View File

@@ -37,8 +37,8 @@ void *
_eglFindArray(_EGLArray *array, void *elem);
PUBLIC void **
_eglFilterArray(_EGLArray *array, EGLint *size,
PUBLIC EGLint
_eglFilterArray(_EGLArray *array, void **data, EGLint size,
_EGLArrayForEach filter, void *filter_data);

View File

@@ -697,11 +697,22 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
if (!_eglParseConfigAttribList(&criteria, disp, attrib_list))
return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
configList = (_EGLConfig **) _eglFilterArray(disp->Configs, &count,
/* get the number of matched configs */
count = _eglFilterArray(disp->Configs, NULL, 0,
(_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
if (!count) {
*num_configs = count;
return EGL_TRUE;
}
configList = malloc(sizeof(*configList) * count);
if (!configList)
return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");
/* get the matched configs */
_eglFilterArray(disp->Configs, (void **) configList, count,
(_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
/* perform sorting of configs */
if (configs && count) {
_eglSortConfigs((const _EGLConfig **) configList, count,

View File

@@ -28,7 +28,8 @@ _eglGetNativePlatformFromEnv(void)
{ _EGL_PLATFORM_WINDOWS, "gdi" },
{ _EGL_PLATFORM_X11, "x11" },
{ _EGL_PLATFORM_DRM, "drm" },
{ _EGL_PLATFORM_FBDEV, "fbdev" }
{ _EGL_PLATFORM_FBDEV, "fbdev" },
{ _EGL_PLATFORM_ANDROID, "android" }
};
_EGLPlatformType plat = _EGL_INVALID_PLATFORM;
const char *plat_name;

View File

@@ -13,6 +13,7 @@ enum _egl_platform_type {
_EGL_PLATFORM_X11,
_EGL_PLATFORM_DRM,
_EGL_PLATFORM_FBDEV,
_EGL_PLATFORM_ANDROID,
_EGL_NUM_PLATFORMS,
_EGL_INVALID_PLATFORM = -1
@@ -75,6 +76,10 @@ struct _egl_extensions
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;
EGLBoolean ANDROID_image_native_buffer;
EGLBoolean ANDROID_swap_rectangle;
EGLBoolean ANDROID_get_render_buffer;
char String[_EGL_MAX_EXTENSIONS_LEN];
};

View File

@@ -86,6 +86,30 @@ library_suffix(void)
}
#else /* _EGL_PLATFORM_NO_OS */
typedef void *lib_handle;
static INLINE void *
open_library(const char *filename)
{
return (void *) filename;
}
static INLINE void
close_library(void *lib)
{
}
static const char *
library_suffix(void)
{
return NULL;
}
#endif
@@ -123,6 +147,8 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle)
else {
error = dlerror();
}
#else /* _EGL_PLATFORM_NO_OS */
mainFunc = (_EGLMain_t) _eglMain;
#endif
if (!lib) {
@@ -501,6 +527,10 @@ _eglAddDefaultDrivers(void)
"egl_dri2",
"egl_glx"
};
#else /* _EGL_PLATFORM_NO_OS */
const char *DefaultDriverNames[] = {
"<builtin>"
};
#endif
for (i = 0; i < ARRAY_SIZE(DefaultDriverNames); i++) {

View File

@@ -4,7 +4,7 @@
#include "egltypedefs.h"
#include "eglapi.h"
#include <stddef.h>
/**
* Define an inline driver typecast function.

View File

@@ -107,6 +107,10 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
_EGL_CHECK_EXTENSION(NOK_swap_region);
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_swap_rectangle);
_EGL_CHECK_EXTENSION(ANDROID_get_render_buffer);
#undef _EGL_CHECK_EXTENSION
}

3
src/gallium/Android.mk Normal file
View File

@@ -0,0 +1,3 @@
ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
include $(call all-subdir-makefiles)
endif

View File

@@ -116,7 +116,7 @@ if env['dri']:
'targets/dri-r600/SConscript',
])
if env['xorg']:
if env['xorg'] and env['drm']:
SConscript([
#'targets/xorg-i915/SConscript',
#'targets/xorg-i965/SConscript',

View File

@@ -0,0 +1,213 @@
LOCAL_PATH := $(call my-dir)
# from Makefile
C_SOURCES = \
cso_cache/cso_cache.c \
cso_cache/cso_context.c \
cso_cache/cso_hash.c \
draw/draw_context.c \
draw/draw_fs.c \
draw/draw_gs.c \
draw/draw_pipe.c \
draw/draw_pipe_aaline.c \
draw/draw_pipe_aapoint.c \
draw/draw_pipe_clip.c \
draw/draw_pipe_cull.c \
draw/draw_pipe_flatshade.c \
draw/draw_pipe_offset.c \
draw/draw_pipe_pstipple.c \
draw/draw_pipe_stipple.c \
draw/draw_pipe_twoside.c \
draw/draw_pipe_unfilled.c \
draw/draw_pipe_util.c \
draw/draw_pipe_validate.c \
draw/draw_pipe_vbuf.c \
draw/draw_pipe_wide_line.c \
draw/draw_pipe_wide_point.c \
draw/draw_pt.c \
draw/draw_pt_emit.c \
draw/draw_pt_fetch.c \
draw/draw_pt_fetch_emit.c \
draw/draw_pt_fetch_shade_emit.c \
draw/draw_pt_fetch_shade_pipeline.c \
draw/draw_pt_post_vs.c \
draw/draw_pt_so_emit.c \
draw/draw_pt_util.c \
draw/draw_pt_vsplit.c \
draw/draw_vertex.c \
draw/draw_vs.c \
draw/draw_vs_aos.c \
draw/draw_vs_aos_io.c \
draw/draw_vs_aos_machine.c \
draw/draw_vs_exec.c \
draw/draw_vs_ppc.c \
draw/draw_vs_sse.c \
draw/draw_vs_varient.c \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
os/os_misc.c \
os/os_stream.c \
os/os_stream_log.c \
os/os_stream_null.c \
os/os_stream_stdc.c \
os/os_stream_str.c \
os/os_time.c \
pipebuffer/pb_buffer_fenced.c \
pipebuffer/pb_buffer_malloc.c \
pipebuffer/pb_bufmgr_alt.c \
pipebuffer/pb_bufmgr_cache.c \
pipebuffer/pb_bufmgr_debug.c \
pipebuffer/pb_bufmgr_mm.c \
pipebuffer/pb_bufmgr_ondemand.c \
pipebuffer/pb_bufmgr_pool.c \
pipebuffer/pb_bufmgr_slab.c \
pipebuffer/pb_validate.c \
rbug/rbug_connection.c \
rbug/rbug_context.c \
rbug/rbug_core.c \
rbug/rbug_demarshal.c \
rbug/rbug_texture.c \
rbug/rbug_shader.c \
rtasm/rtasm_cpu.c \
rtasm/rtasm_execmem.c \
rtasm/rtasm_ppc.c \
rtasm/rtasm_ppc_spe.c \
rtasm/rtasm_x86sse.c \
tgsi/tgsi_build.c \
tgsi/tgsi_dump.c \
tgsi/tgsi_exec.c \
tgsi/tgsi_info.c \
tgsi/tgsi_iterate.c \
tgsi/tgsi_parse.c \
tgsi/tgsi_ppc.c \
tgsi/tgsi_sanity.c \
tgsi/tgsi_scan.c \
tgsi/tgsi_sse2.c \
tgsi/tgsi_text.c \
tgsi/tgsi_transform.c \
tgsi/tgsi_ureg.c \
tgsi/tgsi_util.c \
translate/translate.c \
translate/translate_cache.c \
translate/translate_generic.c \
translate/translate_sse.c \
util/u_debug.c \
util/u_debug_describe.c \
util/u_debug_refcnt.c \
util/u_debug_stack.c \
util/u_debug_symbol.c \
util/u_dump_defines.c \
util/u_dump_state.c \
util/u_bitmask.c \
util/u_blit.c \
util/u_blitter.c \
util/u_cache.c \
util/u_caps.c \
util/u_cpu_detect.c \
util/u_dl.c \
util/u_draw_quad.c \
util/u_format.c \
util/u_format_other.c \
util/u_format_s3tc.c \
util/u_format_srgb.c \
util/u_format_table.c \
util/u_format_tests.c \
util/u_format_yuv.c \
util/u_format_zs.c \
util/u_framebuffer.c \
util/u_gen_mipmap.c \
util/u_half.c \
util/u_handle_table.c \
util/u_hash.c \
util/u_hash_table.c \
util/u_index_modify.c \
util/u_keymap.c \
util/u_linear.c \
util/u_linkage.c \
util/u_network.c \
util/u_math.c \
util/u_mm.c \
util/u_rect.c \
util/u_ringbuffer.c \
util/u_sampler.c \
util/u_simple_shaders.c \
util/u_slab.c \
util/u_snprintf.c \
util/u_staging.c \
util/u_surface.c \
util/u_surfaces.c \
util/u_texture.c \
util/u_tile.c \
util/u_transfer.c \
util/u_resource.c \
util/u_upload_mgr.c
GENERATED_SOURCES = \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
util/u_format_srgb.c \
util/u_format_table.c \
util/u_half.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(filter-out $(GENERATED_SOURCES), $(C_SOURCES))
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/gallium/drivers \
external/mesa/src/gallium/auxiliary/util
LOCAL_MODULE := libmesa_gallium
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
intermediates := $(call local-intermediates-dir)
GEN_SCRIPT := $(LOCAL_PATH)/indices/u_indices_gen.py
GEN := $(intermediates)/indices/u_indices_gen.c
$(GEN): PRIVATE_CUSTOM_TOOL = python $< > $@
$(GEN): $(GEN_SCRIPT)
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
GEN_SCRIPT := $(LOCAL_PATH)/indices/u_unfilled_gen.py
GEN := $(intermediates)/indices/u_unfilled_gen.c
$(GEN): PRIVATE_CUSTOM_TOOL = python $< > $@
$(GEN): $(GEN_SCRIPT)
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
GEN_SCRIPT := $(LOCAL_PATH)/util/u_format_srgb.py
GEN := $(intermediates)/util/u_format_srgb.c
$(GEN): PRIVATE_CUSTOM_TOOL = python $< > $@
$(GEN): $(GEN_SCRIPT)
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
GEN_SCRIPT := $(LOCAL_PATH)/util/u_format_table.py
GEN := $(intermediates)/util/u_format_table.c
$(GEN): PRIVATE_CUSTOM_TOOL := python $(GEN_SCRIPT) $(LOCAL_PATH)/util/u_format.csv > $(GEN)
$(GEN): $(GEN_SCRIPT) $(LOCAL_PATH)/util/u_format.csv
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
GEN_SCRIPT := $(LOCAL_PATH)/util/u_half.py
GEN := $(intermediates)/util/u_half.c
$(GEN): PRIVATE_CUSTOM_TOOL = python $< > $@
$(GEN): $(GEN_SCRIPT)
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_STATIC_LIBRARY)

View File

@@ -128,12 +128,12 @@ C_SOURCES = \
util/u_linkage.c \
util/u_network.c \
util/u_math.c \
util/u_mempool.c \
util/u_mm.c \
util/u_rect.c \
util/u_ringbuffer.c \
util/u_sampler.c \
util/u_simple_shaders.c \
util/u_slab.c \
util/u_snprintf.c \
util/u_staging.c \
util/u_surface.c \
@@ -142,8 +142,7 @@ C_SOURCES = \
util/u_tile.c \
util/u_transfer.c \
util/u_resource.c \
util/u_upload_mgr.c \
target-helpers/wrap_screen.c
util/u_upload_mgr.c
# Disabling until pipe-video branch gets merged in
#vl/vl_bitstream_parser.c \
@@ -186,7 +185,7 @@ GALLIVM_SOURCES = \
draw/draw_pt_fetch_shade_pipeline_llvm.c
GALLIVM_CPP_SOURCES = \
gallivm/lp_bld_misc.cpp
gallivm/lp_bld_misc.cpp
GENERATED_SOURCES = \
indices/u_indices_gen.c \
@@ -204,9 +203,6 @@ CPP_SOURCES += \
endif
LIBRARY_DEFINES += -D__STDC_CONSTANT_MACROS
include ../Makefile.template

View File

@@ -175,13 +175,13 @@ source = [
'util/u_linkage.c',
'util/u_network.c',
'util/u_math.c',
'util/u_mempool.c',
'util/u_mm.c',
'util/u_rect.c',
'util/u_resource.c',
'util/u_ringbuffer.c',
'util/u_sampler.c',
'util/u_simple_shaders.c',
'util/u_slab.c',
'util/u_snprintf.c',
'util/u_staging.c',
'util/u_surface.c',
@@ -196,7 +196,6 @@ source = [
#'vl/vl_compositor.c',
#'vl/vl_csc.c',
#'vl/vl_shader_build.c',
'target-helpers/wrap_screen.c',
]
if env['llvm']:

View File

@@ -63,19 +63,32 @@ draw_get_option_use_llvm(void)
}
#endif
struct draw_context *draw_create( struct pipe_context *pipe )
/**
* Create new draw module context.
*/
struct draw_context *
draw_create(struct pipe_context *pipe)
{
return draw_create_gallivm(pipe, NULL);
}
/**
* Create new draw module context with gallivm state for LLVM JIT.
*/
struct draw_context *
draw_create_gallivm(struct pipe_context *pipe, struct gallivm_state *gallivm)
{
struct draw_context *draw = CALLOC_STRUCT( draw_context );
if (draw == NULL)
goto fail;
#if HAVE_LLVM
if(draw_get_option_use_llvm())
{
lp_build_init();
assert(lp_build_engine);
draw->engine = lp_build_engine;
draw->llvm = draw_llvm_create(draw);
if (draw_get_option_use_llvm() && gallivm) {
draw->llvm = draw_llvm_create(draw, gallivm);
}
#endif
@@ -91,6 +104,8 @@ fail:
return NULL;
}
boolean draw_init(struct draw_context *draw)
{
/*

View File

@@ -48,10 +48,15 @@ struct draw_vertex_shader;
struct draw_geometry_shader;
struct draw_fragment_shader;
struct tgsi_sampler;
struct gallivm_state;
struct draw_context *draw_create( struct pipe_context *pipe );
struct draw_context *
draw_create_gallivm(struct pipe_context *pipe, struct gallivm_state *gallivm);
void draw_destroy( struct draw_context *draw );
void draw_flush(struct draw_context *draw);

File diff suppressed because it is too large Load Diff

View File

@@ -103,41 +103,41 @@ struct draw_jit_context
};
#define draw_jit_context_vs_constants(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 0, "vs_constants")
#define draw_jit_context_vs_constants(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 0, "vs_constants")
#define draw_jit_context_gs_constants(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 1, "gs_constants")
#define draw_jit_context_gs_constants(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 1, "gs_constants")
#define draw_jit_context_planes(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 2, "planes")
#define draw_jit_context_planes(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 2, "planes")
#define draw_jit_context_viewport(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 3, "viewport")
#define draw_jit_context_viewport(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 3, "viewport")
#define DRAW_JIT_CTX_TEXTURES 4
#define draw_jit_context_textures(_builder, _ptr) \
lp_build_struct_get_ptr(_builder, _ptr, DRAW_JIT_CTX_TEXTURES, "textures")
#define draw_jit_context_textures(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_TEXTURES, "textures")
#define draw_jit_header_id(_builder, _ptr) \
lp_build_struct_get_ptr(_builder, _ptr, 0, "id")
#define draw_jit_header_id(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, 0, "id")
#define draw_jit_header_clip(_builder, _ptr) \
lp_build_struct_get_ptr(_builder, _ptr, 1, "clip")
#define draw_jit_header_clip(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, 1, "clip")
#define draw_jit_header_data(_builder, _ptr) \
lp_build_struct_get_ptr(_builder, _ptr, 2, "data")
#define draw_jit_header_data(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, 2, "data")
#define draw_jit_vbuffer_stride(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 0, "stride")
#define draw_jit_vbuffer_stride(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 0, "stride")
#define draw_jit_vbuffer_max_index(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 1, "max_index")
#define draw_jit_vbuffer_max_index(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 1, "max_index")
#define draw_jit_vbuffer_offset(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, 2, "buffer_offset")
#define draw_jit_vbuffer_offset(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, 2, "buffer_offset")
typedef int
@@ -246,21 +246,19 @@ struct draw_llvm {
struct draw_jit_context jit_context;
struct gallivm_state *gallivm;
struct draw_llvm_variant_list_item vs_variants_list;
int nr_variants;
LLVMModuleRef module;
LLVMExecutionEngineRef engine;
LLVMModuleProviderRef provider;
LLVMTargetDataRef target;
LLVMPassManagerRef pass;
/* LLVM JIT builder types */
LLVMTypeRef context_ptr_type;
LLVMTypeRef vertex_header_ptr_type;
LLVMTypeRef buffer_ptr_type;
LLVMTypeRef vb_ptr_type;
LLVMTypeRef vertex_header_ptr_type;
};
static INLINE struct llvm_vertex_shader *
llvm_vertex_shader(struct draw_vertex_shader *vs)
{
@@ -269,7 +267,7 @@ llvm_vertex_shader(struct draw_vertex_shader *vs)
struct draw_llvm *
draw_llvm_create(struct draw_context *draw);
draw_llvm_create(struct draw_context *draw, struct gallivm_state *gallivm);
void
draw_llvm_destroy(struct draw_llvm *llvm);
@@ -286,7 +284,7 @@ struct draw_llvm_variant_key *
draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store);
LLVMValueRef
draw_llvm_translate_from(LLVMBuilderRef builder,
draw_llvm_translate_from(struct gallivm_state *gallivm,
LLVMValueRef vbuffer,
enum pipe_format from_format);

View File

@@ -32,6 +32,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "gallivm/lp_bld_const.h"
#include "gallivm/lp_bld_debug.h"
#include "gallivm/lp_bld_type.h"
#include "gallivm/lp_bld_sample.h"
@@ -84,12 +85,13 @@ struct draw_llvm_sampler_soa
*/
static LLVMValueRef
draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit,
unsigned member_index,
const char *member_name,
boolean emit_load)
{
LLVMBuilderRef builder = gallivm->builder;
struct draw_llvm_sampler_dynamic_state *state =
(struct draw_llvm_sampler_dynamic_state *)base;
LLVMValueRef indices[4];
@@ -99,13 +101,13 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
debug_assert(unit < PIPE_MAX_VERTEX_SAMPLERS);
/* context[0] */
indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indices[0] = lp_build_const_int32(gallivm, 0);
/* context[0].textures */
indices[1] = LLVMConstInt(LLVMInt32Type(), DRAW_JIT_CTX_TEXTURES, 0);
indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_TEXTURES);
/* context[0].textures[unit] */
indices[2] = LLVMConstInt(LLVMInt32Type(), unit, 0);
indices[2] = lp_build_const_int32(gallivm, unit);
/* context[0].textures[unit].member */
indices[3] = LLVMConstInt(LLVMInt32Type(), member_index, 0);
indices[3] = lp_build_const_int32(gallivm, member_index);
ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), "");
@@ -132,10 +134,10 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
#define DRAW_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
draw_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \
LLVMBuilderRef builder, \
struct gallivm_state *gallivm, \
unsigned unit) \
{ \
return draw_llvm_texture_member(base, builder, unit, _index, #_name, _emit_load ); \
return draw_llvm_texture_member(base, gallivm, unit, _index, #_name, _emit_load ); \
}
@@ -165,7 +167,7 @@ draw_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler)
*/
static void
draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
struct lp_type type,
unsigned unit,
unsigned num_coords,
@@ -180,7 +182,7 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
assert(unit < PIPE_MAX_VERTEX_SAMPLERS);
lp_build_sample_soa(builder,
lp_build_sample_soa(gallivm,
&sampler->dynamic_state.static_state[unit],
&sampler->dynamic_state.base,
type,

View File

@@ -3,6 +3,7 @@
#include "draw_llvm.h"
#include "gallivm/lp_bld_const.h"
#include "gallivm/lp_bld_struct.h"
#include "gallivm/lp_bld_format.h"
#include "gallivm/lp_bld_debug.h"
@@ -16,272 +17,279 @@
#define DRAW_DBG 0
static LLVMValueRef
from_64_float(LLVMBuilderRef builder, LLVMValueRef val)
from_64_float(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMDoubleType(), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
return LLVMBuildFPTrunc(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMDoubleTypeInContext(gallivm->context), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
return LLVMBuildFPTrunc(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static LLVMValueRef
from_32_float(LLVMBuilderRef builder, LLVMValueRef val)
from_32_float(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMFloatType(), 0) , "");
return LLVMBuildLoad(builder, bc, "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0) , "");
return LLVMBuildLoad(gallivm->builder, bc, "");
}
static INLINE LLVMValueRef
from_8_uscaled(LLVMBuilderRef builder, LLVMValueRef val)
from_8_uscaled(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef l = LLVMBuildLoad(builder, val, "");
return LLVMBuildUIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, val, "");
return LLVMBuildUIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static INLINE LLVMValueRef
from_16_uscaled(LLVMBuilderRef builder, LLVMValueRef val)
from_16_uscaled(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
return LLVMBuildUIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
return LLVMBuildUIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static INLINE LLVMValueRef
from_32_uscaled(LLVMBuilderRef builder, LLVMValueRef val)
from_32_uscaled(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
return LLVMBuildUIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
return LLVMBuildUIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static INLINE LLVMValueRef
from_8_sscaled(LLVMBuilderRef builder, LLVMValueRef val)
from_8_sscaled(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef l = LLVMBuildLoad(builder, val, "");
return LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, val, "");
return LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static INLINE LLVMValueRef
from_16_sscaled(LLVMBuilderRef builder, LLVMValueRef val)
from_16_sscaled(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
return LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
return LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static INLINE LLVMValueRef
from_32_sscaled(LLVMBuilderRef builder, LLVMValueRef val)
from_32_sscaled(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
return LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
return LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
}
static INLINE LLVMValueRef
from_8_unorm(LLVMBuilderRef builder, LLVMValueRef val)
from_8_unorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef l = LLVMBuildLoad(builder, val, "");
LLVMValueRef uscaled = LLVMBuildUIToFP(builder, l, LLVMFloatType(), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 255.), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, val, "");
LLVMValueRef uscaled = LLVMBuildUIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 255.), "");
}
static INLINE LLVMValueRef
from_16_unorm(LLVMBuilderRef builder, LLVMValueRef val)
from_16_unorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
LLVMValueRef uscaled = LLVMBuildUIToFP(builder, l, LLVMFloatType(), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 65535.), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
LLVMValueRef uscaled = LLVMBuildUIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 65535.), "");
}
static INLINE LLVMValueRef
from_32_unorm(LLVMBuilderRef builder, LLVMValueRef val)
from_32_unorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
LLVMValueRef uscaled = LLVMBuildUIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
LLVMValueRef uscaled = LLVMBuildUIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 4294967295.), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 4294967295.), "");
}
static INLINE LLVMValueRef
from_8_snorm(LLVMBuilderRef builder, LLVMValueRef val)
from_8_snorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef l = LLVMBuildLoad(builder, val, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 127.0), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, val, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 127.0), "");
}
static INLINE LLVMValueRef
from_16_snorm(LLVMBuilderRef builder, LLVMValueRef val)
from_16_snorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 32767.0f), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 16), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 32767.0f), "");
}
static INLINE LLVMValueRef
from_32_snorm(LLVMBuilderRef builder, LLVMValueRef val)
from_32_snorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 2147483647.0), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 2147483647.0), "");
}
static INLINE LLVMValueRef
from_32_fixed(LLVMBuilderRef builder, LLVMValueRef val)
from_32_fixed(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef bc = LLVMBuildBitCast(builder, val,
LLVMPointerType(LLVMIntType(32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(builder, bc, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(builder, l, LLVMFloatType(), "");
LLVMValueRef bc = LLVMBuildBitCast(gallivm->builder, val,
LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 32), 0) , "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, bc, "");
LLVMValueRef uscaled = LLVMBuildSIToFP(gallivm->builder, l, LLVMFloatTypeInContext(gallivm->context), "");
return LLVMBuildFDiv(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 65536.0), "");
return LLVMBuildFDiv(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 65536.0), "");
}
static LLVMValueRef
to_64_float(LLVMBuilderRef builder, LLVMValueRef fp)
to_64_float(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPExt(builder, l, LLVMDoubleType(), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPExt(gallivm->builder, l, LLVMDoubleTypeInContext(gallivm->context), "");
}
static LLVMValueRef
to_32_float(LLVMBuilderRef builder, LLVMValueRef fp)
to_32_float(struct gallivm_state *gallivm, LLVMValueRef fp)
{
return LLVMBuildLoad(builder, fp, "");
return LLVMBuildLoad(gallivm->builder, fp, "");
}
static INLINE LLVMValueRef
to_8_uscaled(LLVMBuilderRef builder, LLVMValueRef fp)
to_8_uscaled(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPToUI(builder, l, LLVMIntType(8), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPToUI(gallivm->builder, l, LLVMIntTypeInContext(gallivm->context, 8), "");
}
static INLINE LLVMValueRef
to_16_uscaled(LLVMBuilderRef builder, LLVMValueRef fp)
to_16_uscaled(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPToUI(builder, l, LLVMIntType(16), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPToUI(gallivm->builder, l, LLVMIntTypeInContext(gallivm->context, 16), "");
}
static INLINE LLVMValueRef
to_32_uscaled(LLVMBuilderRef builder, LLVMValueRef fp)
to_32_uscaled(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPToUI(builder, l, LLVMIntType(32), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPToUI(gallivm->builder, l, LLVMIntTypeInContext(gallivm->context, 32), "");
}
static INLINE LLVMValueRef
to_8_sscaled(LLVMBuilderRef builder, LLVMValueRef fp)
to_8_sscaled(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPToSI(builder, l, LLVMIntType(8), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPToSI(gallivm->builder, l, LLVMIntTypeInContext(gallivm->context, 8), "");
}
static INLINE LLVMValueRef
to_16_sscaled(LLVMBuilderRef builder, LLVMValueRef fp)
to_16_sscaled(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPToSI(builder, l, LLVMIntType(16), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPToSI(gallivm->builder, l, LLVMIntTypeInContext(gallivm->context, 16), "");
}
static INLINE LLVMValueRef
to_32_sscaled(LLVMBuilderRef builder, LLVMValueRef fp)
to_32_sscaled(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
return LLVMBuildFPToSI(builder, l, LLVMIntType(32), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
return LLVMBuildFPToSI(gallivm->builder, l, LLVMIntTypeInContext(gallivm->context, 32), "");
}
static INLINE LLVMValueRef
to_8_unorm(LLVMBuilderRef builder, LLVMValueRef fp)
to_8_unorm(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToUI(builder, l, LLVMIntType(8), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 255.), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToUI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 8), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 255.), "");
}
static INLINE LLVMValueRef
to_16_unorm(LLVMBuilderRef builder, LLVMValueRef fp)
to_16_unorm(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToUI(builder, l, LLVMIntType(32), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 65535.), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToUI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 32), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 65535.), "");
}
static INLINE LLVMValueRef
to_32_unorm(LLVMBuilderRef builder, LLVMValueRef fp)
to_32_unorm(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToUI(builder, l, LLVMIntType(32), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToUI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 32), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 4294967295.), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 4294967295.), "");
}
static INLINE LLVMValueRef
to_8_snorm(LLVMBuilderRef builder, LLVMValueRef val)
to_8_snorm(struct gallivm_state *gallivm, LLVMValueRef val)
{
LLVMValueRef l = LLVMBuildLoad(builder, val, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(builder, l, LLVMIntType(8), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 127.0), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, val, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 8), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 127.0), "");
}
static INLINE LLVMValueRef
to_16_snorm(LLVMBuilderRef builder, LLVMValueRef fp)
to_16_snorm(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(builder, l, LLVMIntType(16), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 32767.0f), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 16), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 32767.0f), "");
}
static INLINE LLVMValueRef
to_32_snorm(LLVMBuilderRef builder, LLVMValueRef fp)
to_32_snorm(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(builder, l, LLVMIntType(32), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 32), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 2147483647.0), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 2147483647.0), "");
}
static INLINE LLVMValueRef
to_32_fixed(LLVMBuilderRef builder, LLVMValueRef fp)
to_32_fixed(struct gallivm_state *gallivm, LLVMValueRef fp)
{
LLVMValueRef l = LLVMBuildLoad(builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(builder, l, LLVMIntType(32), "");
LLVMValueRef l = LLVMBuildLoad(gallivm->builder, fp, "");
LLVMValueRef uscaled = LLVMBuildFPToSI(gallivm->builder, l,
LLVMIntTypeInContext(gallivm->context, 32), "");
return LLVMBuildFMul(builder, uscaled,
LLVMConstReal(LLVMFloatType(), 65536.0), "");
return LLVMBuildFMul(gallivm->builder, uscaled,
lp_build_const_float(gallivm, 65536.0), "");
}
typedef LLVMValueRef (*from_func)(LLVMBuilderRef, LLVMValueRef);
typedef LLVMValueRef (*to_func)(LLVMBuilderRef, LLVMValueRef);
typedef LLVMValueRef (*from_func)(struct gallivm_state *, LLVMValueRef);
typedef LLVMValueRef (*to_func)(struct gallivm_state *, LLVMValueRef);
/* so that underneath can avoid function calls which are prohibited
* for static initialization we need this conversion */
@@ -294,21 +302,21 @@ enum ll_type {
};
static INLINE LLVMTypeRef
ll_type_to_llvm(enum ll_type type)
ll_type_to_llvm(struct gallivm_state *gallivm, enum ll_type type)
{
switch (type) {
case LL_Double:
return LLVMDoubleType();
return LLVMDoubleTypeInContext(gallivm->context);
case LL_Float:
return LLVMFloatType();
return LLVMFloatTypeInContext(gallivm->context);
case LL_Int32:
return LLVMInt32Type();
return LLVMInt32TypeInContext(gallivm->context);
case LL_Int16:
return LLVMIntType(16);
return LLVMIntTypeInContext(gallivm->context, 16);
case LL_Int8:
return LLVMIntType(8);
return LLVMIntTypeInContext(gallivm->context, 8);
}
return LLVMIntType(8);
return LLVMIntTypeInContext(gallivm->context, 8);
}
static INLINE int
@@ -414,42 +422,42 @@ struct draw_llvm_translate {
static LLVMValueRef
fetch(LLVMBuilderRef builder,
fetch(struct gallivm_state *gallivm,
LLVMValueRef ptr, int val_size, int nr_components,
from_func func)
{
int i;
int offset = 0;
LLVMValueRef res = LLVMConstNull(
LLVMVectorType(LLVMFloatType(), 4));
LLVMValueRef res =
LLVMConstNull(LLVMVectorType(LLVMFloatTypeInContext(gallivm->context), 4));
LLVMValueRef defaults[4];
defaults[0] = LLVMConstReal(LLVMFloatType(), 0);
defaults[1] = LLVMConstReal(LLVMFloatType(), 0);
defaults[2] = LLVMConstReal(LLVMFloatType(), 0);
defaults[3] = LLVMConstReal(LLVMFloatType(), 1);
defaults[0] =
defaults[1] =
defaults[2] = lp_build_const_float(gallivm, 0.0);
defaults[3] = lp_build_const_float(gallivm, 1.0);
for (i = 0; i < nr_components; ++i) {
LLVMValueRef src_index = LLVMConstInt(LLVMInt32Type(), offset, 0);
LLVMValueRef dst_index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef src_index = lp_build_const_int32(gallivm, offset);
LLVMValueRef dst_index = lp_build_const_int32(gallivm, i);
LLVMValueRef src_tmp;
LLVMValueRef component;
src_tmp = LLVMBuildGEP(builder, ptr, &src_index, 1, "src_tmp");
src_tmp = LLVMBuildGEP(gallivm->builder, ptr, &src_index, 1, "src_tmp");
/* convert src_tmp to float */
component = func(builder, src_tmp);
component = func(gallivm, src_tmp);
/* vec.comp = component */
res = LLVMBuildInsertElement(builder,
res = LLVMBuildInsertElement(gallivm->builder,
res,
component,
dst_index, "");
offset += val_size;
}
for (; i < 4; ++i) {
LLVMValueRef dst_index = LLVMConstInt(LLVMInt32Type(), i, 0);
res = LLVMBuildInsertElement(builder,
LLVMValueRef dst_index = lp_build_const_int32(gallivm, i);
res = LLVMBuildInsertElement(gallivm->builder,
res,
defaults[i],
dst_index, "");
@@ -459,7 +467,7 @@ fetch(LLVMBuilderRef builder,
LLVMValueRef
draw_llvm_translate_from(LLVMBuilderRef builder,
draw_llvm_translate_from(struct gallivm_state *gallivm,
LLVMValueRef vbuffer,
enum pipe_format from_format)
{
@@ -476,7 +484,7 @@ draw_llvm_translate_from(LLVMBuilderRef builder,
for (i = 0; i < Elements(translates); ++i) {
if (translates[i].format == from_format) {
/*LLVMTypeRef type = ll_type_to_llvm(translates[i].type);*/
return fetch(builder,
return fetch(gallivm,
vbuffer,
ll_type_size(translates[i].type),
translates[i].num_components,
@@ -493,6 +501,6 @@ draw_llvm_translate_from(LLVMBuilderRef builder,
*/
format_desc = util_format_description(from_format);
zero = LLVMConstNull(LLVMInt32Type());
return lp_build_fetch_rgba_aos(builder, format_desc, type, vbuffer, zero, zero, zero);
zero = LLVMConstNull(LLVMInt32TypeInContext(gallivm->context));
return lp_build_fetch_rgba_aos(gallivm, format_desc, type, vbuffer, zero, zero, zero);
}

View File

@@ -406,6 +406,7 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
texTemp.array_size = 1;
texTemp.bind = PIPE_BIND_SAMPLER_VIEW;
aaline->texture = screen->resource_create(screen, &texTemp);
@@ -441,10 +442,10 @@ aaline_create_texture(struct aaline_stage *aaline)
/* This texture is new, no need to flush.
*/
transfer = pipe->get_transfer(pipe,
aaline->texture,
u_subresource(0, level),
PIPE_TRANSFER_WRITE,
&box);
aaline->texture,
level,
PIPE_TRANSFER_WRITE,
&box);
data = pipe->transfer_map(pipe, transfer);
if (data == NULL)

View File

@@ -393,8 +393,8 @@ pstip_update_texture(struct pstip_stage *pstip)
*/
pipe->flush( pipe, PIPE_FLUSH_TEXTURE_CACHE, NULL );
transfer = pipe_get_transfer(pipe, pstip->texture, 0, 0, 0,
PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
transfer = pipe_get_transfer(pipe, pstip->texture, 0, 0,
PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
data = pipe->transfer_map(pipe, transfer);
/*
@@ -440,6 +440,7 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.width0 = 32;
texTemp.height0 = 32;
texTemp.depth0 = 1;
texTemp.array_size = 1;
texTemp.bind = PIPE_BIND_SAMPLER_VIEW;
pstip->texture = screen->resource_create(screen, &texTemp);

View File

@@ -286,7 +286,6 @@ struct draw_context
#ifdef HAVE_LLVM
struct draw_llvm *llvm;
LLVMExecutionEngineRef engine;
#endif
struct pipe_sampler_view *sampler_views[PIPE_MAX_VERTEX_SAMPLERS];

View File

@@ -34,6 +34,7 @@
#include "draw/draw_pt.h"
#include "draw/draw_vs.h"
#include "draw/draw_llvm.h"
#include "gallivm/lp_bld_init.h"
struct llvm_middle_end {
@@ -72,19 +73,18 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
struct draw_llvm_variant_list_item *li;
unsigned i;
unsigned instance_id_index = ~0;
unsigned out_prim = (draw->gs.geometry_shader ?
draw->gs.geometry_shader->output_primitive :
in_prim);
const unsigned out_prim = (draw->gs.geometry_shader ?
draw->gs.geometry_shader->output_primitive :
in_prim);
/* Add one to num_outputs because the pipeline occasionally tags on
* an additional texcoord, eg for AA lines.
*/
unsigned nr = MAX2( shader->base.info.num_inputs,
shader->base.info.num_outputs + 1 );
const unsigned nr = MAX2( shader->base.info.num_inputs,
shader->base.info.num_outputs + 1 );
/* Scan for instanceID system value.
* XXX but we never use instance_id_index?!
*/
for (i = 0; i < shader->base.info.num_inputs; i++) {
if (shader->base.info.input_semantic_name[i] == TGSI_SEMANTIC_INSTANCEID) {
@@ -133,9 +133,10 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
key = draw_llvm_make_variant_key(fpme->llvm, store);
/* Search shader's list of variants for the key */
li = first_elem(&shader->variants);
while(!at_end(&shader->variants, li)) {
if(memcmp(&li->base->key, key, shader->variant_key_size) == 0) {
while (!at_end(&shader->variants, li)) {
if (memcmp(&li->base->key, key, shader->variant_key_size) == 0) {
variant = li->base;
break;
}
@@ -143,10 +144,16 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
}
if (variant) {
/* found the variant, move to head of global list (for LRU) */
move_to_head(&fpme->llvm->vs_variants_list, &variant->list_item_global);
}
else {
/* Need to create new variant */
unsigned i;
/* First check if we've created too many variants. If so, free
* 25% of the LRU to avoid using too much memory.
*/
if (fpme->llvm->nr_variants >= DRAW_MAX_SHADER_VARIANTS) {
/*
* XXX: should we flush here ?
@@ -422,7 +429,7 @@ draw_pt_fetch_pipeline_or_emit_llvm(struct draw_context *draw)
{
struct llvm_middle_end *fpme = 0;
if (!draw->engine)
if (!draw->llvm->gallivm->engine)
return NULL;
fpme = CALLOC_STRUCT( llvm_middle_end );

View File

@@ -55,4 +55,33 @@
#endif
/**
* Redefine these LLVM entrypoints as invalid macros to make sure we
* don't accidentally use them. We need to use the functions which
* take an explicit LLVMContextRef parameter.
*/
#define LLVMInt1Type ILLEGAL_LLVM_FUNCTION
#define LLVMInt8Type ILLEGAL_LLVM_FUNCTION
#define LLVMInt16Type ILLEGAL_LLVM_FUNCTION
#define LLVMInt32Type ILLEGAL_LLVM_FUNCTION
#define LLVMInt64Type ILLEGAL_LLVM_FUNCTION
#define LLVMIntType ILLEGAL_LLVM_FUNCTION
#define LLVMFloatType ILLEGAL_LLVM_FUNCTION
#define LLVMDoubleType ILLEGAL_LLVM_FUNCTION
#define LLVMX86FP80Type ILLEGAL_LLVM_FUNCTION
#define LLVMFP128Type ILLEGAL_LLVM_FUNCTION
#define LLVMPPCFP128Type ILLEGAL_LLVM_FUNCTION
#define LLVMStructType ILLEGAL_LLVM_FUNCTION
#define LLVMVoidType ILLEGAL_LLVM_FUNCTION
#define LLVMLabelType ILLEGAL_LLVM_FUNCTION
#define LLVMOpaqueType ILLEGAL_LLVM_FUNCTION
#define LLVMUnionType ILLEGAL_LLVM_FUNCTION
#define LLVMMDString ILLEGAL_LLVM_FUNCTION
#define LLVMMDNode ILLEGAL_LLVM_FUNCTION
#define LLVMConstString ILLEGAL_LLVM_FUNCTION
#define LLVMConstStruct ILLEGAL_LLVM_FUNCTION
#define LLVMAppendBasicBlock ILLEGAL_LLVM_FUNCTION
#define LLVMInsertBasicBlock ILLEGAL_LLVM_FUNCTION
#define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION
#endif /* LP_BLD_H */

File diff suppressed because it is too large Load Diff

View File

@@ -56,20 +56,21 @@ lp_assert(int condition, const char *msg)
* \param msg a string to print if the assertion fails.
*/
LLVMValueRef
lp_build_assert(LLVMBuilderRef builder, LLVMValueRef condition,
lp_build_assert(struct gallivm_state *gallivm,
LLVMValueRef condition,
const char *msg)
{
LLVMModuleRef module;
LLVMBuilderRef builder = gallivm->builder;
LLVMContextRef context = gallivm->context;
LLVMModuleRef module = gallivm->module;
LLVMTypeRef arg_types[2];
LLVMValueRef msg_string, assert_func, params[2], r;
module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(
LLVMGetInsertBlock(builder)));
msg_string = lp_build_const_string_variable(module, context,
msg, strlen(msg) + 1);
msg_string = lp_build_const_string_variable(module, msg, strlen(msg) + 1);
arg_types[0] = LLVMInt32Type();
arg_types[1] = LLVMPointerType(LLVMInt8Type(), 0);
arg_types[0] = LLVMInt32TypeInContext(context);
arg_types[1] = LLVMPointerType(LLVMInt8TypeInContext(context), 0);
/* lookup the lp_assert function */
assert_func = LLVMGetNamedFunction(module, "lp_assert");
@@ -77,12 +78,12 @@ lp_build_assert(LLVMBuilderRef builder, LLVMValueRef condition,
/* Create the assertion function if not found */
if (!assert_func) {
LLVMTypeRef func_type =
LLVMFunctionType(LLVMVoidType(), arg_types, 2, 0);
LLVMFunctionType(LLVMVoidTypeInContext(context), arg_types, 2, 0);
assert_func = LLVMAddFunction(module, "lp_assert", func_type);
LLVMSetFunctionCallConv(assert_func, LLVMCCallConv);
LLVMSetLinkage(assert_func, LLVMExternalLinkage);
LLVMAddGlobalMapping(lp_build_engine, assert_func,
LLVMAddGlobalMapping(gallivm->engine, assert_func,
func_to_pointer((func_pointer)lp_assert));
}
assert(assert_func);

View File

@@ -30,10 +30,12 @@
#include "lp_bld.h"
#include "lp_bld_init.h"
LLVMValueRef
lp_build_assert(LLVMBuilderRef builder, LLVMValueRef condition,
lp_build_assert(struct gallivm_state *gallivm,
LLVMValueRef condition,
const char *msg);

View File

@@ -40,6 +40,7 @@
LLVMValueRef
lp_build_or(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
@@ -48,14 +49,14 @@ lp_build_or(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
/* can't do bitwise ops on floating-point values */
if (type.floating) {
a = LLVMBuildBitCast(bld->builder, a, bld->int_vec_type, "");
b = LLVMBuildBitCast(bld->builder, b, bld->int_vec_type, "");
a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
}
res = LLVMBuildOr(bld->builder, a, b, "");
res = LLVMBuildOr(builder, a, b, "");
if (type.floating) {
res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
return res;
@@ -68,6 +69,7 @@ lp_build_or(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
LLVMValueRef
lp_build_and(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
@@ -76,14 +78,14 @@ lp_build_and(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
/* can't do bitwise ops on floating-point values */
if (type.floating) {
a = LLVMBuildBitCast(bld->builder, a, bld->int_vec_type, "");
b = LLVMBuildBitCast(bld->builder, b, bld->int_vec_type, "");
a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
}
res = LLVMBuildAnd(bld->builder, a, b, "");
res = LLVMBuildAnd(builder, a, b, "");
if (type.floating) {
res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
return res;
@@ -96,6 +98,7 @@ lp_build_and(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
LLVMValueRef
lp_build_andnot(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
@@ -104,15 +107,15 @@ lp_build_andnot(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
/* can't do bitwise ops on floating-point values */
if (type.floating) {
a = LLVMBuildBitCast(bld->builder, a, bld->int_vec_type, "");
b = LLVMBuildBitCast(bld->builder, b, bld->int_vec_type, "");
a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
}
res = LLVMBuildNot(bld->builder, b, "");
res = LLVMBuildAnd(bld->builder, a, res, "");
res = LLVMBuildNot(builder, b, "");
res = LLVMBuildAnd(builder, a, res, "");
if (type.floating) {
res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
return res;
@@ -125,6 +128,7 @@ lp_build_andnot(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
LLVMValueRef
lp_build_shl(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
@@ -133,7 +137,7 @@ lp_build_shl(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
assert(lp_check_value(type, a));
assert(lp_check_value(type, b));
res = LLVMBuildShl(bld->builder, a, b, "");
res = LLVMBuildShl(builder, a, b, "");
return res;
}
@@ -145,6 +149,7 @@ lp_build_shl(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
LLVMValueRef
lp_build_shr(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
@@ -154,9 +159,9 @@ lp_build_shr(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
assert(lp_check_value(type, b));
if (type.sign) {
res = LLVMBuildAShr(bld->builder, a, b, "");
res = LLVMBuildAShr(builder, a, b, "");
} else {
res = LLVMBuildLShr(bld->builder, a, b, "");
res = LLVMBuildLShr(builder, a, b, "");
}
return res;
@@ -169,7 +174,7 @@ lp_build_shr(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
LLVMValueRef
lp_build_shl_imm(struct lp_build_context *bld, LLVMValueRef a, unsigned imm)
{
LLVMValueRef b = lp_build_const_int_vec(bld->type, imm);
LLVMValueRef b = lp_build_const_int_vec(bld->gallivm, bld->type, imm);
assert(imm <= bld->type.width);
return lp_build_shl(bld, a, b);
}
@@ -181,7 +186,7 @@ lp_build_shl_imm(struct lp_build_context *bld, LLVMValueRef a, unsigned imm)
LLVMValueRef
lp_build_shr_imm(struct lp_build_context *bld, LLVMValueRef a, unsigned imm)
{
LLVMValueRef b = lp_build_const_int_vec(bld->type, imm);
LLVMValueRef b = lp_build_const_int_vec(bld->gallivm, bld->type, imm);
assert(imm <= bld->type.width);
return lp_build_shr(bld, a, b);
}

View File

@@ -39,6 +39,7 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_init.h"
unsigned
@@ -211,31 +212,31 @@ lp_const_eps(struct lp_type type)
LLVMValueRef
lp_build_undef(struct lp_type type)
lp_build_undef(struct gallivm_state *gallivm, struct lp_type type)
{
LLVMTypeRef vec_type = lp_build_vec_type(type);
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, type);
return LLVMGetUndef(vec_type);
}
LLVMValueRef
lp_build_zero(struct lp_type type)
lp_build_zero(struct gallivm_state *gallivm, struct lp_type type)
{
if (type.length == 1) {
if (type.floating)
return LLVMConstReal(LLVMFloatType(), 0.0);
return lp_build_const_float(gallivm, 0.0);
else
return LLVMConstInt(LLVMIntType(type.width), 0, 0);
return LLVMConstInt(LLVMIntTypeInContext(gallivm->context, type.width), 0, 0);
}
else {
LLVMTypeRef vec_type = lp_build_vec_type(type);
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, type);
return LLVMConstNull(vec_type);
}
}
LLVMValueRef
lp_build_one(struct lp_type type)
lp_build_one(struct gallivm_state *gallivm, struct lp_type type)
{
LLVMTypeRef elem_type;
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
@@ -243,7 +244,7 @@ lp_build_one(struct lp_type type)
assert(type.length <= LP_MAX_VECTOR_LENGTH);
elem_type = lp_build_elem_type(type);
elem_type = lp_build_elem_type(gallivm, type);
if(type.floating)
elems[0] = LLVMConstReal(elem_type, 1.0);
@@ -283,10 +284,11 @@ lp_build_one(struct lp_type type)
* Build constant-valued element from a scalar value.
*/
LLVMValueRef
lp_build_const_elem(struct lp_type type,
lp_build_const_elem(struct gallivm_state *gallivm,
struct lp_type type,
double val)
{
LLVMTypeRef elem_type = lp_build_elem_type(type);
LLVMTypeRef elem_type = lp_build_elem_type(gallivm, type);
LLVMValueRef elem;
if(type.floating) {
@@ -306,15 +308,15 @@ lp_build_const_elem(struct lp_type type,
* Build constant-valued vector from a scalar value.
*/
LLVMValueRef
lp_build_const_vec(struct lp_type type,
lp_build_const_vec(struct gallivm_state *gallivm, struct lp_type type,
double val)
{
if (type.length == 1) {
return lp_build_const_elem(type, val);
return lp_build_const_elem(gallivm, type, val);
} else {
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
elems[0] = lp_build_const_elem(type, val);
elems[0] = lp_build_const_elem(gallivm, type, val);
for(i = 1; i < type.length; ++i)
elems[i] = elems[0];
return LLVMConstVector(elems, type.length);
@@ -323,10 +325,10 @@ lp_build_const_vec(struct lp_type type,
LLVMValueRef
lp_build_const_int_vec(struct lp_type type,
long long val)
lp_build_const_int_vec(struct gallivm_state *gallivm, struct lp_type type,
long long val)
{
LLVMTypeRef elem_type = lp_build_int_elem_type(type);
LLVMTypeRef elem_type = lp_build_int_elem_type(gallivm, type);
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
@@ -343,7 +345,8 @@ lp_build_const_int_vec(struct lp_type type,
LLVMValueRef
lp_build_const_aos(struct lp_type type,
lp_build_const_aos(struct gallivm_state *gallivm,
struct lp_type type,
double r, double g, double b, double a,
const unsigned char *swizzle)
{
@@ -355,7 +358,7 @@ lp_build_const_aos(struct lp_type type,
assert(type.length % 4 == 0);
assert(type.length <= LP_MAX_VECTOR_LENGTH);
elem_type = lp_build_elem_type(type);
elem_type = lp_build_elem_type(gallivm, type);
if(swizzle == NULL)
swizzle = default_swizzle;
@@ -386,10 +389,11 @@ lp_build_const_aos(struct lp_type type,
* @param mask TGSI_WRITEMASK_xxx
*/
LLVMValueRef
lp_build_const_mask_aos(struct lp_type type,
lp_build_const_mask_aos(struct gallivm_state *gallivm,
struct lp_type type,
unsigned mask)
{
LLVMTypeRef elem_type = LLVMIntType(type.width);
LLVMTypeRef elem_type = LLVMIntTypeInContext(gallivm->context, type.width);
LLVMValueRef masks[LP_MAX_VECTOR_LENGTH];
unsigned i, j;

View File

@@ -39,6 +39,7 @@
#include "pipe/p_compiler.h"
#include "gallivm/lp_bld.h"
#include "gallivm/lp_bld_init.h"
@@ -73,46 +74,55 @@ lp_const_eps(struct lp_type type);
LLVMValueRef
lp_build_undef(struct lp_type type);
lp_build_undef(struct gallivm_state *gallivm, struct lp_type type);
LLVMValueRef
lp_build_zero(struct lp_type type);
lp_build_zero(struct gallivm_state *gallivm, struct lp_type type);
LLVMValueRef
lp_build_one(struct lp_type type);
lp_build_one(struct gallivm_state *gallivm, struct lp_type type);
LLVMValueRef
lp_build_const_elem(struct lp_type type,
lp_build_const_elem(struct gallivm_state *gallivm, struct lp_type type,
double val);
LLVMValueRef
lp_build_const_vec(struct lp_type type, double val);
lp_build_const_vec(struct gallivm_state *gallivm, struct lp_type type,
double val);
LLVMValueRef
lp_build_const_int_vec(struct lp_type type, long long val);
lp_build_const_int_vec(struct gallivm_state *gallivm,
struct lp_type type, long long val);
LLVMValueRef
lp_build_const_aos(struct lp_type type,
lp_build_const_aos(struct gallivm_state *gallivm, struct lp_type type,
double r, double g, double b, double a,
const unsigned char *swizzle);
LLVMValueRef
lp_build_const_mask_aos(struct lp_type type,
lp_build_const_mask_aos(struct gallivm_state *gallivm,
struct lp_type type,
unsigned mask);
static INLINE LLVMValueRef
lp_build_const_int32(int i)
lp_build_const_int32(struct gallivm_state *gallivm, int i)
{
return LLVMConstInt(LLVMInt32Type(), i, 0);
return LLVMConstInt(LLVMInt32TypeInContext(gallivm->context), i, 0);
}
static INLINE LLVMValueRef
lp_build_const_float(struct gallivm_state *gallivm, float x)
{
return LLVMConstReal(LLVMFloatTypeInContext(gallivm->context), x);
}
#endif /* !LP_BLD_CONST_H */

View File

@@ -89,12 +89,13 @@
* return { i32, i32, i32, i32 } where each value is in [0, 2^dst_width-1].
*/
LLVMValueRef
lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
lp_build_clamped_float_to_unsigned_norm(struct gallivm_state *gallivm,
struct lp_type src_type,
unsigned dst_width,
LLVMValueRef src)
{
LLVMTypeRef int_vec_type = lp_build_int_vec_type(src_type);
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef int_vec_type = lp_build_int_vec_type(gallivm, src_type);
LLVMValueRef res;
unsigned mantissa;
@@ -122,10 +123,11 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
scale = (double)mask/ubound;
bias = (double)(1ULL << (mantissa - dst_width));
res = LLVMBuildFMul(builder, src, lp_build_const_vec(src_type, scale), "");
res = LLVMBuildFAdd(builder, res, lp_build_const_vec(src_type, bias), "");
res = LLVMBuildFMul(builder, src, lp_build_const_vec(gallivm, src_type, scale), "");
res = LLVMBuildFAdd(builder, res, lp_build_const_vec(gallivm, src_type, bias), "");
res = LLVMBuildBitCast(builder, res, int_vec_type, "");
res = LLVMBuildAnd(builder, res, lp_build_const_int_vec(src_type, mask), "");
res = LLVMBuildAnd(builder, res,
lp_build_const_int_vec(gallivm, src_type, mask), "");
}
else if (dst_width == (mantissa + 1)) {
/*
@@ -138,7 +140,8 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
scale = (double)((1ULL << dst_width) - 1);
res = LLVMBuildFMul(builder, src, lp_build_const_vec(src_type, scale), "");
res = LLVMBuildFMul(builder, src,
lp_build_const_vec(gallivm, src_type, scale), "");
res = LLVMBuildFPToSI(builder, res, int_vec_type, "");
}
else {
@@ -166,7 +169,8 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
LLVMValueRef lshifted;
LLVMValueRef rshifted;
res = LLVMBuildFMul(builder, src, lp_build_const_vec(src_type, scale), "");
res = LLVMBuildFMul(builder, src,
lp_build_const_vec(gallivm, src_type, scale), "");
res = LLVMBuildFPToSI(builder, res, int_vec_type, "");
/*
@@ -177,7 +181,8 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
*/
if (lshift) {
lshifted = LLVMBuildShl(builder, res,
lp_build_const_int_vec(src_type, lshift), "");
lp_build_const_int_vec(gallivm, src_type,
lshift), "");
} else {
lshifted = res;
}
@@ -186,7 +191,8 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
* Align the most significant bit to the right.
*/
rshifted = LLVMBuildAShr(builder, res,
lp_build_const_int_vec(src_type, rshift), "");
lp_build_const_int_vec(gallivm, src_type, rshift),
"");
/*
* Subtract the MSB to the LSB, therefore re-scaling from
@@ -206,13 +212,14 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
* return {float, float, float, float} with values in range [0, 1].
*/
LLVMValueRef
lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
lp_build_unsigned_norm_to_float(struct gallivm_state *gallivm,
unsigned src_width,
struct lp_type dst_type,
LLVMValueRef src)
{
LLVMTypeRef vec_type = lp_build_vec_type(dst_type);
LLVMTypeRef int_vec_type = lp_build_int_vec_type(dst_type);
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, dst_type);
LLVMTypeRef int_vec_type = lp_build_int_vec_type(gallivm, dst_type);
LLVMValueRef bias_;
LLVMValueRef res;
unsigned mantissa;
@@ -230,7 +237,8 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
if (src_width == 8) {
scale = 1.0/255.0;
res = LLVMBuildSIToFP(builder, src, vec_type, "");
res = LLVMBuildFMul(builder, res, lp_build_const_vec(dst_type, scale), "");
res = LLVMBuildFMul(builder, res,
lp_build_const_vec(gallivm, dst_type, scale), "");
return res;
}
@@ -247,10 +255,11 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
if(src_width > mantissa) {
int shift = src_width - mantissa;
res = LLVMBuildLShr(builder, res, lp_build_const_int_vec(dst_type, shift), "");
res = LLVMBuildLShr(builder, res,
lp_build_const_int_vec(gallivm, dst_type, shift), "");
}
bias_ = lp_build_const_vec(dst_type, bias);
bias_ = lp_build_const_vec(gallivm, dst_type, bias);
res = LLVMBuildOr(builder,
res,
@@ -259,7 +268,7 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
res = LLVMBuildBitCast(builder, res, vec_type, "");
res = LLVMBuildFSub(builder, res, bias_, "");
res = LLVMBuildFMul(builder, res, lp_build_const_vec(dst_type, scale), "");
res = LLVMBuildFMul(builder, res, lp_build_const_vec(gallivm, dst_type, scale), "");
return res;
}
@@ -272,12 +281,13 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
* to the lp_type union.
*/
void
lp_build_conv(LLVMBuilderRef builder,
lp_build_conv(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
const LLVMValueRef *src, unsigned num_srcs,
LLVMValueRef *dst, unsigned num_dsts)
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_type tmp_type;
LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
unsigned num_tmps;
@@ -342,12 +352,12 @@ lp_build_conv(LLVMBuilderRef builder,
int32_type.length /= 4;
int32_type.sign = 1;
src_vec_type = lp_build_vec_type(src_type);
dst_vec_type = lp_build_vec_type(dst_type);
int16_vec_type = lp_build_vec_type(int16_type);
int32_vec_type = lp_build_vec_type(int32_type);
src_vec_type = lp_build_vec_type(gallivm, src_type);
dst_vec_type = lp_build_vec_type(gallivm, dst_type);
int16_vec_type = lp_build_vec_type(gallivm, int16_type);
int32_vec_type = lp_build_vec_type(gallivm, int32_type);
const_255f = lp_build_const_vec(src_type, 255.0f);
const_255f = lp_build_const_vec(gallivm, src_type, 255.0f);
a = LLVMBuildFMul(builder, src[0], const_255f, "");
b = LLVMBuildFMul(builder, src[1], const_255f, "");
@@ -357,14 +367,14 @@ lp_build_conv(LLVMBuilderRef builder,
{
struct lp_build_context bld;
bld.builder = builder;
bld.gallivm = gallivm;
bld.type = src_type;
bld.vec_type = src_vec_type;
bld.int_elem_type = lp_build_elem_type(int32_type);
bld.int_elem_type = lp_build_elem_type(gallivm, int32_type);
bld.int_vec_type = int32_vec_type;
bld.undef = lp_build_undef(src_type);
bld.zero = lp_build_zero(src_type);
bld.one = lp_build_one(src_type);
bld.undef = lp_build_undef(gallivm, src_type);
bld.zero = lp_build_zero(gallivm, src_type);
bld.one = lp_build_one(gallivm, src_type);
src_int0 = lp_build_iround(&bld, a);
src_int1 = lp_build_iround(&bld, b);
@@ -372,9 +382,9 @@ lp_build_conv(LLVMBuilderRef builder,
src_int3 = lp_build_iround(&bld, d);
}
/* relying on clamping behavior of sse2 intrinsics here */
lo = lp_build_pack2(builder, int32_type, int16_type, src_int0, src_int1);
hi = lp_build_pack2(builder, int32_type, int16_type, src_int2, src_int3);
dst[i] = lp_build_pack2(builder, int16_type, dst_type, lo, hi);
lo = lp_build_pack2(gallivm, int32_type, int16_type, src_int0, src_int1);
hi = lp_build_pack2(gallivm, int32_type, int16_type, src_int2, src_int3);
dst[i] = lp_build_pack2(gallivm, int16_type, dst_type, lo, hi);
}
return;
}
@@ -391,13 +401,13 @@ lp_build_conv(LLVMBuilderRef builder,
double dst_max = lp_const_max(dst_type);
LLVMValueRef thres;
lp_build_context_init(&bld, builder, tmp_type);
lp_build_context_init(&bld, gallivm, tmp_type);
if(src_min < dst_min) {
if(dst_min == 0.0)
thres = bld.zero;
else
thres = lp_build_const_vec(src_type, dst_min);
thres = lp_build_const_vec(gallivm, src_type, dst_min);
for(i = 0; i < num_tmps; ++i)
tmp[i] = lp_build_max(&bld, tmp[i], thres);
}
@@ -406,7 +416,7 @@ lp_build_conv(LLVMBuilderRef builder,
if(dst_max == 1.0)
thres = bld.one;
else
thres = lp_build_const_vec(src_type, dst_max);
thres = lp_build_const_vec(gallivm, src_type, dst_max);
for(i = 0; i < num_tmps; ++i)
tmp[i] = lp_build_min(&bld, tmp[i], thres);
}
@@ -422,7 +432,7 @@ lp_build_conv(LLVMBuilderRef builder,
else if(tmp_type.floating) {
if(!dst_type.fixed && !dst_type.sign && dst_type.norm) {
for(i = 0; i < num_tmps; ++i) {
tmp[i] = lp_build_clamped_float_to_unsigned_norm(builder,
tmp[i] = lp_build_clamped_float_to_unsigned_norm(gallivm,
tmp_type,
dst_type.width,
tmp[i]);
@@ -434,14 +444,14 @@ lp_build_conv(LLVMBuilderRef builder,
LLVMTypeRef tmp_vec_type;
if (dst_scale != 1.0) {
LLVMValueRef scale = lp_build_const_vec(tmp_type, dst_scale);
LLVMValueRef scale = lp_build_const_vec(gallivm, tmp_type, dst_scale);
for(i = 0; i < num_tmps; ++i)
tmp[i] = LLVMBuildFMul(builder, tmp[i], scale, "");
}
/* Use an equally sized integer for intermediate computations */
tmp_type.floating = FALSE;
tmp_vec_type = lp_build_vec_type(tmp_type);
tmp_vec_type = lp_build_vec_type(gallivm, tmp_type);
for(i = 0; i < num_tmps; ++i) {
#if 0
if(dst_type.sign)
@@ -461,7 +471,8 @@ lp_build_conv(LLVMBuilderRef builder,
/* FIXME: compensate different offsets too */
if(src_shift > dst_shift) {
LLVMValueRef shift = lp_build_const_int_vec(tmp_type, src_shift - dst_shift);
LLVMValueRef shift = lp_build_const_int_vec(gallivm, tmp_type,
src_shift - dst_shift);
for(i = 0; i < num_tmps; ++i)
if(src_type.sign)
tmp[i] = LLVMBuildAShr(builder, tmp[i], shift, "");
@@ -485,7 +496,7 @@ lp_build_conv(LLVMBuilderRef builder,
new_type.width = dst_type.width;
new_type.length = dst_type.length;
lp_build_resize(builder, tmp_type, new_type, tmp, num_srcs, tmp, num_dsts);
lp_build_resize(gallivm, tmp_type, new_type, tmp, num_srcs, tmp, num_dsts);
tmp_type = new_type;
num_tmps = num_dsts;
@@ -501,7 +512,7 @@ lp_build_conv(LLVMBuilderRef builder,
else if(!src_type.floating && dst_type.floating) {
if(!src_type.fixed && !src_type.sign && src_type.norm) {
for(i = 0; i < num_tmps; ++i) {
tmp[i] = lp_build_unsigned_norm_to_float(builder,
tmp[i] = lp_build_unsigned_norm_to_float(gallivm,
src_type.width,
dst_type,
tmp[i]);
@@ -515,7 +526,7 @@ lp_build_conv(LLVMBuilderRef builder,
/* Use an equally sized integer for intermediate computations */
tmp_type.floating = TRUE;
tmp_type.sign = TRUE;
tmp_vec_type = lp_build_vec_type(tmp_type);
tmp_vec_type = lp_build_vec_type(gallivm, tmp_type);
for(i = 0; i < num_tmps; ++i) {
#if 0
if(dst_type.sign)
@@ -529,7 +540,7 @@ lp_build_conv(LLVMBuilderRef builder,
}
if (src_scale != 1.0) {
LLVMValueRef scale = lp_build_const_vec(tmp_type, 1.0/src_scale);
LLVMValueRef scale = lp_build_const_vec(gallivm, tmp_type, 1.0/src_scale);
for(i = 0; i < num_tmps; ++i)
tmp[i] = LLVMBuildFMul(builder, tmp[i], scale, "");
}
@@ -541,7 +552,7 @@ lp_build_conv(LLVMBuilderRef builder,
/* FIXME: compensate different offsets too */
if(src_shift < dst_shift) {
LLVMValueRef shift = lp_build_const_int_vec(tmp_type, dst_shift - src_shift);
LLVMValueRef shift = lp_build_const_int_vec(gallivm, tmp_type, dst_shift - src_shift);
for(i = 0; i < num_tmps; ++i)
tmp[i] = LLVMBuildShl(builder, tmp[i], shift, "");
}
@@ -565,7 +576,7 @@ lp_build_conv(LLVMBuilderRef builder,
* This is basically a very trimmed down version of lp_build_conv.
*/
void
lp_build_conv_mask(LLVMBuilderRef builder,
lp_build_conv_mask(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
const LLVMValueRef *src, unsigned num_srcs,
@@ -599,11 +610,11 @@ lp_build_conv_mask(LLVMBuilderRef builder,
if(src_type.width > dst_type.width) {
assert(num_dsts == 1);
dst[0] = lp_build_pack(builder, src_type, dst_type, TRUE, src, num_srcs);
dst[0] = lp_build_pack(gallivm, src_type, dst_type, TRUE, src, num_srcs);
}
else if(src_type.width < dst_type.width) {
assert(num_srcs == 1);
lp_build_unpack(builder, src_type, dst_type, src[0], dst, num_dsts);
lp_build_unpack(gallivm, src_type, dst_type, src[0], dst, num_dsts);
}
else {
assert(num_srcs == num_dsts);

View File

@@ -44,27 +44,27 @@ struct lp_type;
LLVMValueRef
lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
lp_build_clamped_float_to_unsigned_norm(struct gallivm_state *gallivm,
struct lp_type src_type,
unsigned dst_width,
LLVMValueRef src);
LLVMValueRef
lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
lp_build_unsigned_norm_to_float(struct gallivm_state *gallivm,
unsigned src_width,
struct lp_type dst_type,
LLVMValueRef src);
void
lp_build_conv(LLVMBuilderRef builder,
lp_build_conv(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
const LLVMValueRef *srcs, unsigned num_srcs,
LLVMValueRef *dsts, unsigned num_dsts);
void
lp_build_conv_mask(LLVMBuilderRef builder,
lp_build_conv_mask(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
const LLVMValueRef *src, unsigned num_srcs,

View File

@@ -42,6 +42,7 @@
#define GALLIVM_DEBUG_NO_OPT (1 << 3)
#define GALLIVM_DEBUG_PERF (1 << 4)
#define GALLIVM_DEBUG_NO_BRILINEAR (1 << 5)
#define GALLIVM_DEBUG_GC (1 << 6)
#ifdef DEBUG

View File

@@ -34,6 +34,7 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "lp_bld_init.h"
#include "lp_bld_type.h"
#include "lp_bld_flow.h"
@@ -51,25 +52,25 @@
* be used elsewhere.
*/
LLVMBasicBlockRef
lp_build_insert_new_block(LLVMBuilderRef builder, const char *name)
lp_build_insert_new_block(struct gallivm_state *gallivm, const char *name)
{
LLVMBasicBlockRef current_block;
LLVMBasicBlockRef next_block;
LLVMBasicBlockRef new_block;
/* get current basic block */
current_block = LLVMGetInsertBlock(builder);
current_block = LLVMGetInsertBlock(gallivm->builder);
/* check if there's another block after this one */
next_block = LLVMGetNextBasicBlock(current_block);
if (next_block) {
/* insert the new block before the next block */
new_block = LLVMInsertBasicBlock(next_block, name);
new_block = LLVMInsertBasicBlockInContext(gallivm->context, next_block, name);
}
else {
/* append new block after current block */
LLVMValueRef function = LLVMGetBasicBlockParent(current_block);
new_block = LLVMAppendBasicBlock(function, name);
new_block = LLVMAppendBasicBlockInContext(gallivm->context, function, name);
}
return new_block;
@@ -82,12 +83,11 @@ lp_build_insert_new_block(LLVMBuilderRef builder, const char *name)
*/
void
lp_build_flow_skip_begin(struct lp_build_skip_context *skip,
LLVMBuilderRef builder)
struct gallivm_state *gallivm)
{
skip->builder = builder;
skip->gallivm = gallivm;
/* create new basic block */
skip->block = lp_build_insert_new_block(skip->builder, "skip");
skip->block = lp_build_insert_new_block(gallivm, "skip");
}
@@ -101,12 +101,12 @@ lp_build_flow_skip_cond_break(struct lp_build_skip_context *skip,
{
LLVMBasicBlockRef new_block;
new_block = lp_build_insert_new_block(skip->builder, "");
new_block = lp_build_insert_new_block(skip->gallivm, "");
/* if cond is true, goto skip->block, else goto new_block */
LLVMBuildCondBr(skip->builder, cond, skip->block, new_block);
LLVMBuildCondBr(skip->gallivm->builder, cond, skip->block, new_block);
LLVMPositionBuilderAtEnd(skip->builder, new_block);
LLVMPositionBuilderAtEnd(skip->gallivm->builder, new_block);
}
@@ -114,8 +114,8 @@ void
lp_build_flow_skip_end(struct lp_build_skip_context *skip)
{
/* goto block */
LLVMBuildBr(skip->builder, skip->block);
LLVMPositionBuilderAtEnd(skip->builder, skip->block);
LLVMBuildBr(skip->gallivm->builder, skip->block);
LLVMPositionBuilderAtEnd(skip->gallivm->builder, skip->block);
}
@@ -125,7 +125,7 @@ lp_build_flow_skip_end(struct lp_build_skip_context *skip)
void
lp_build_mask_check(struct lp_build_mask_context *mask)
{
LLVMBuilderRef builder = mask->skip.builder;
LLVMBuilderRef builder = mask->skip.gallivm->builder;
LLVMValueRef value;
LLVMValueRef cond;
@@ -152,27 +152,27 @@ lp_build_mask_check(struct lp_build_mask_context *mask)
*/
void
lp_build_mask_begin(struct lp_build_mask_context *mask,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
struct lp_type type,
LLVMValueRef value)
{
memset(mask, 0, sizeof *mask);
mask->reg_type = LLVMIntType(type.width * type.length);
mask->var = lp_build_alloca(builder,
lp_build_int_vec_type(type),
mask->reg_type = LLVMIntTypeInContext(gallivm->context, type.width * type.length);
mask->var = lp_build_alloca(gallivm,
lp_build_int_vec_type(gallivm, type),
"execution_mask");
LLVMBuildStore(builder, value, mask->var);
LLVMBuildStore(gallivm->builder, value, mask->var);
lp_build_flow_skip_begin(&mask->skip, builder);
lp_build_flow_skip_begin(&mask->skip, gallivm);
}
LLVMValueRef
lp_build_mask_value(struct lp_build_mask_context *mask)
{
return LLVMBuildLoad(mask->skip.builder, mask->var, "");
return LLVMBuildLoad(mask->skip.gallivm->builder, mask->var, "");
}
@@ -185,10 +185,10 @@ void
lp_build_mask_update(struct lp_build_mask_context *mask,
LLVMValueRef value)
{
value = LLVMBuildAnd(mask->skip.builder,
value = LLVMBuildAnd(mask->skip.gallivm->builder,
lp_build_mask_value(mask),
value, "");
LLVMBuildStore(mask->skip.builder, value, mask->var);
LLVMBuildStore(mask->skip.gallivm->builder, value, mask->var);
}
@@ -205,13 +205,17 @@ lp_build_mask_end(struct lp_build_mask_context *mask)
void
lp_build_loop_begin(LLVMBuilderRef builder,
LLVMValueRef start,
struct lp_build_loop_state *state)
lp_build_loop_begin(struct lp_build_loop_state *state,
struct gallivm_state *gallivm,
LLVMValueRef start)
{
state->block = lp_build_insert_new_block(builder, "loop_begin");
LLVMBuilderRef builder = gallivm->builder;
state->counter_var = lp_build_alloca(builder, LLVMTypeOf(start), "loop_counter");
state->block = lp_build_insert_new_block(gallivm, "loop_begin");
state->counter_var = lp_build_alloca(gallivm, LLVMTypeOf(start), "loop_counter");
state->gallivm = gallivm;
LLVMBuildStore(builder, start, state->counter_var);
@@ -224,12 +228,12 @@ lp_build_loop_begin(LLVMBuilderRef builder,
void
lp_build_loop_end_cond(LLVMBuilderRef builder,
lp_build_loop_end_cond(struct lp_build_loop_state *state,
LLVMValueRef end,
LLVMValueRef step,
LLVMIntPredicate llvm_cond,
struct lp_build_loop_state *state)
LLVMIntPredicate llvm_cond)
{
LLVMBuilderRef builder = state->gallivm->builder;
LLVMValueRef next;
LLVMValueRef cond;
LLVMBasicBlockRef after_block;
@@ -243,7 +247,7 @@ lp_build_loop_end_cond(LLVMBuilderRef builder,
cond = LLVMBuildICmp(builder, llvm_cond, next, end, "");
after_block = lp_build_insert_new_block(builder, "loop_end");
after_block = lp_build_insert_new_block(state->gallivm, "loop_end");
LLVMBuildCondBr(builder, cond, after_block, state->block);
@@ -254,12 +258,11 @@ lp_build_loop_end_cond(LLVMBuilderRef builder,
void
lp_build_loop_end(LLVMBuilderRef builder,
lp_build_loop_end(struct lp_build_loop_state *state,
LLVMValueRef end,
LLVMValueRef step,
struct lp_build_loop_state *state)
LLVMValueRef step)
{
lp_build_loop_end_cond(builder, end, step, LLVMIntNE, state);
lp_build_loop_end_cond(state, end, step, LLVMIntNE);
}
@@ -296,24 +299,27 @@ lp_build_loop_end(LLVMBuilderRef builder,
*/
void
lp_build_if(struct lp_build_if_state *ifthen,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
LLVMValueRef condition)
{
LLVMBasicBlockRef block = LLVMGetInsertBlock(builder);
LLVMBasicBlockRef block = LLVMGetInsertBlock(gallivm->builder);
memset(ifthen, 0, sizeof *ifthen);
ifthen->builder = builder;
ifthen->gallivm = gallivm;
ifthen->condition = condition;
ifthen->entry_block = block;
/* create endif/merge basic block for the phi functions */
ifthen->merge_block = lp_build_insert_new_block(builder, "endif-block");
ifthen->merge_block = lp_build_insert_new_block(gallivm, "endif-block");
/* create/insert true_block before merge_block */
ifthen->true_block = LLVMInsertBasicBlock(ifthen->merge_block, "if-true-block");
ifthen->true_block =
LLVMInsertBasicBlockInContext(gallivm->context,
ifthen->merge_block,
"if-true-block");
/* successive code goes into the true block */
LLVMPositionBuilderAtEnd(builder, ifthen->true_block);
LLVMPositionBuilderAtEnd(gallivm->builder, ifthen->true_block);
}
@@ -323,14 +329,19 @@ lp_build_if(struct lp_build_if_state *ifthen,
void
lp_build_else(struct lp_build_if_state *ifthen)
{
LLVMBuilderRef builder = ifthen->gallivm->builder;
/* Append an unconditional Br(anch) instruction on the true_block */
LLVMBuildBr(ifthen->builder, ifthen->merge_block);
LLVMBuildBr(builder, ifthen->merge_block);
/* create/insert false_block before the merge block */
ifthen->false_block = LLVMInsertBasicBlock(ifthen->merge_block, "if-false-block");
ifthen->false_block =
LLVMInsertBasicBlockInContext(ifthen->gallivm->context,
ifthen->merge_block,
"if-false-block");
/* successive code goes into the else block */
LLVMPositionBuilderAtEnd(ifthen->builder, ifthen->false_block);
LLVMPositionBuilderAtEnd(builder, ifthen->false_block);
}
@@ -340,28 +351,30 @@ lp_build_else(struct lp_build_if_state *ifthen)
void
lp_build_endif(struct lp_build_if_state *ifthen)
{
LLVMBuilderRef builder = ifthen->gallivm->builder;
/* Insert branch to the merge block from current block */
LLVMBuildBr(ifthen->builder, ifthen->merge_block);
LLVMBuildBr(builder, ifthen->merge_block);
/*
* Now patch in the various branch instructions.
*/
/* Insert the conditional branch instruction at the end of entry_block */
LLVMPositionBuilderAtEnd(ifthen->builder, ifthen->entry_block);
LLVMPositionBuilderAtEnd(builder, ifthen->entry_block);
if (ifthen->false_block) {
/* we have an else clause */
LLVMBuildCondBr(ifthen->builder, ifthen->condition,
LLVMBuildCondBr(builder, ifthen->condition,
ifthen->true_block, ifthen->false_block);
}
else {
/* no else clause */
LLVMBuildCondBr(ifthen->builder, ifthen->condition,
LLVMBuildCondBr(builder, ifthen->condition,
ifthen->true_block, ifthen->merge_block);
}
/* Resume building code at end of the ifthen->merge_block */
LLVMPositionBuilderAtEnd(ifthen->builder, ifthen->merge_block);
LLVMPositionBuilderAtEnd(builder, ifthen->merge_block);
}
@@ -381,15 +394,16 @@ lp_build_endif(struct lp_build_if_state *ifthen)
* - http://www.llvm.org/docs/tutorial/OCamlLangImpl7.html#memory
*/
LLVMValueRef
lp_build_alloca(LLVMBuilderRef builder,
lp_build_alloca(struct gallivm_state *gallivm,
LLVMTypeRef type,
const char *name)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMBasicBlockRef current_block = LLVMGetInsertBlock(builder);
LLVMValueRef function = LLVMGetBasicBlockParent(current_block);
LLVMBasicBlockRef first_block = LLVMGetEntryBasicBlock(function);
LLVMValueRef first_instr = LLVMGetFirstInstruction(first_block);
LLVMBuilderRef first_builder = LLVMCreateBuilder();
LLVMBuilderRef first_builder = LLVMCreateBuilderInContext(gallivm->context);
LLVMValueRef res;
if (first_instr) {
@@ -422,16 +436,17 @@ lp_build_alloca(LLVMBuilderRef builder,
* - http://www.llvm.org/docs/tutorial/OCamlLangImpl7.html#memory
*/
LLVMValueRef
lp_build_array_alloca(LLVMBuilderRef builder,
lp_build_array_alloca(struct gallivm_state *gallivm,
LLVMTypeRef type,
LLVMValueRef count,
const char *name)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMBasicBlockRef current_block = LLVMGetInsertBlock(builder);
LLVMValueRef function = LLVMGetBasicBlockParent(current_block);
LLVMBasicBlockRef first_block = LLVMGetEntryBasicBlock(function);
LLVMValueRef first_instr = LLVMGetFirstInstruction(first_block);
LLVMBuilderRef first_builder = LLVMCreateBuilder();
LLVMBuilderRef first_builder = LLVMCreateBuilderInContext(gallivm->context);
LLVMValueRef res;
if (first_instr) {

View File

@@ -47,7 +47,7 @@ struct lp_type;
*/
struct lp_build_skip_context
{
LLVMBuilderRef builder;
struct gallivm_state *gallivm;
/** Block to skip to */
LLVMBasicBlockRef block;
@@ -55,7 +55,7 @@ struct lp_build_skip_context
void
lp_build_flow_skip_begin(struct lp_build_skip_context *ctx,
LLVMBuilderRef builder);
struct gallivm_state *gallivm);
void
lp_build_flow_skip_cond_break(struct lp_build_skip_context *ctx,
@@ -77,7 +77,7 @@ struct lp_build_mask_context
void
lp_build_mask_begin(struct lp_build_mask_context *mask,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
struct lp_type type,
LLVMValueRef value);
@@ -107,31 +107,28 @@ lp_build_mask_end(struct lp_build_mask_context *mask);
*/
struct lp_build_loop_state
{
LLVMBasicBlockRef block;
LLVMValueRef counter_var;
LLVMValueRef counter;
LLVMBasicBlockRef block;
LLVMValueRef counter_var;
LLVMValueRef counter;
struct gallivm_state *gallivm;
};
void
lp_build_loop_begin(LLVMBuilderRef builder,
LLVMValueRef start,
struct lp_build_loop_state *state);
lp_build_loop_begin(struct lp_build_loop_state *state,
struct gallivm_state *gallivm,
LLVMValueRef start);
void
lp_build_loop_end(LLVMBuilderRef builder,
lp_build_loop_end(struct lp_build_loop_state *state,
LLVMValueRef end,
LLVMValueRef step,
struct lp_build_loop_state *state);
LLVMValueRef step);
void
lp_build_loop_end_cond(LLVMBuilderRef builder,
lp_build_loop_end_cond(struct lp_build_loop_state *state,
LLVMValueRef end,
LLVMValueRef step,
LLVMIntPredicate cond,
struct lp_build_loop_state *state);
LLVMIntPredicate cond);
@@ -140,7 +137,7 @@ lp_build_loop_end_cond(LLVMBuilderRef builder,
*/
struct lp_build_if_state
{
LLVMBuilderRef builder;
struct gallivm_state *gallivm;
LLVMValueRef condition;
LLVMBasicBlockRef entry_block;
LLVMBasicBlockRef true_block;
@@ -151,7 +148,7 @@ struct lp_build_if_state
void
lp_build_if(struct lp_build_if_state *ctx,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
LLVMValueRef condition);
void
@@ -161,15 +158,15 @@ void
lp_build_endif(struct lp_build_if_state *ctx);
LLVMBasicBlockRef
lp_build_insert_new_block(LLVMBuilderRef builder, const char *name);
lp_build_insert_new_block(struct gallivm_state *gallivm, const char *name);
LLVMValueRef
lp_build_alloca(LLVMBuilderRef builder,
lp_build_alloca(struct gallivm_state *gallivm,
LLVMTypeRef type,
const char *name);
LLVMValueRef
lp_build_array_alloca(LLVMBuilderRef builder,
lp_build_array_alloca(struct gallivm_state *gallivm,
LLVMTypeRef type,
LLVMValueRef count,
const char *name);

View File

@@ -35,6 +35,7 @@
*/
#include "gallivm/lp_bld.h"
#include "gallivm/lp_bld_init.h"
#include "pipe/p_format.h"
@@ -53,12 +54,12 @@ lp_build_format_swizzle_aos(const struct util_format_description *desc,
LLVMValueRef unswizzled);
LLVMValueRef
lp_build_pack_rgba_aos(LLVMBuilderRef builder,
lp_build_pack_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *desc,
LLVMValueRef rgba);
LLVMValueRef
lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef base_ptr,
@@ -78,20 +79,20 @@ lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
LLVMValueRef swizzled_out[4]);
void
lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
lp_build_unpack_rgba_soa(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef packed,
LLVMValueRef rgba_out[4]);
void
lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
lp_build_rgba8_to_f32_soa(struct gallivm_state *gallivm,
struct lp_type dst_type,
LLVMValueRef packed,
LLVMValueRef *rgba);
void
lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef base_ptr,
@@ -106,7 +107,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
LLVMValueRef
lp_build_fetch_subsampled_rgba_aos(LLVMBuilderRef builder,
lp_build_fetch_subsampled_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
unsigned n,
LLVMValueRef base_ptr,

View File

@@ -145,10 +145,11 @@ format_matches_type(const struct util_format_description *desc,
* @return RGBA in a float[4] or ubyte[4] or ushort[4] vector.
*/
static INLINE LLVMValueRef
lp_build_unpack_arith_rgba_aos(LLVMBuilderRef builder,
lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *desc,
LLVMValueRef packed)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef shifted, casted, scaled, masked;
LLVMValueRef shifts[4];
LLVMValueRef masks[4];
@@ -167,21 +168,21 @@ lp_build_unpack_arith_rgba_aos(LLVMBuilderRef builder,
/* Do the intermediate integer computations with 32bit integers since it
* matches floating point size */
assert (LLVMTypeOf(packed) == LLVMInt32Type());
assert (LLVMTypeOf(packed) == LLVMInt32TypeInContext(gallivm->context));
/* Broadcast the packed value to all four channels
* before: packed = BGRA
* after: packed = {BGRA, BGRA, BGRA, BGRA}
*/
packed = LLVMBuildInsertElement(builder,
LLVMGetUndef(LLVMVectorType(LLVMInt32Type(), 4)),
LLVMGetUndef(LLVMVectorType(LLVMInt32TypeInContext(gallivm->context), 4)),
packed,
LLVMConstNull(LLVMInt32Type()),
LLVMConstNull(LLVMInt32TypeInContext(gallivm->context)),
"");
packed = LLVMBuildShuffleVector(builder,
packed,
LLVMGetUndef(LLVMVectorType(LLVMInt32Type(), 4)),
LLVMConstNull(LLVMVectorType(LLVMInt32Type(), 4)),
LLVMGetUndef(LLVMVectorType(LLVMInt32TypeInContext(gallivm->context), 4)),
LLVMConstNull(LLVMVectorType(LLVMInt32TypeInContext(gallivm->context), 4)),
"");
/* Initialize vector constants */
@@ -194,9 +195,9 @@ lp_build_unpack_arith_rgba_aos(LLVMBuilderRef builder,
unsigned bits = desc->channel[i].size;
if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID) {
shifts[i] = LLVMGetUndef(LLVMInt32Type());
masks[i] = LLVMConstNull(LLVMInt32Type());
scales[i] = LLVMConstNull(LLVMFloatType());
shifts[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context));
masks[i] = LLVMConstNull(LLVMInt32TypeInContext(gallivm->context));
scales[i] = LLVMConstNull(LLVMFloatTypeInContext(gallivm->context));
}
else {
unsigned long long mask = (1ULL << bits) - 1;
@@ -207,15 +208,15 @@ lp_build_unpack_arith_rgba_aos(LLVMBuilderRef builder,
needs_uitofp = TRUE;
}
shifts[i] = LLVMConstInt(LLVMInt32Type(), shift, 0);
masks[i] = LLVMConstInt(LLVMInt32Type(), mask, 0);
shifts[i] = lp_build_const_int32(gallivm, shift);
masks[i] = lp_build_const_int32(gallivm, mask);
if (desc->channel[i].normalized) {
scales[i] = LLVMConstReal(LLVMFloatType(), 1.0/mask);
scales[i] = lp_build_const_float(gallivm, 1.0 / mask);
normalized = TRUE;
}
else
scales[i] = LLVMConstReal(LLVMFloatType(), 1.0);
scales[i] = lp_build_const_float(gallivm, 1.0);
}
shift += bits;
@@ -230,9 +231,9 @@ lp_build_unpack_arith_rgba_aos(LLVMBuilderRef builder,
if (!needs_uitofp) {
/* UIToFP can't be expressed in SSE2 */
casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), "");
casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatTypeInContext(gallivm->context), 4), "");
} else {
casted = LLVMBuildUIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), "");
casted = LLVMBuildUIToFP(builder, masked, LLVMVectorType(LLVMFloatTypeInContext(gallivm->context), 4), "");
}
/* At this point 'casted' may be a vector of floats such as
@@ -258,10 +259,11 @@ lp_build_unpack_arith_rgba_aos(LLVMBuilderRef builder,
* a time is rarely if ever needed.
*/
LLVMValueRef
lp_build_pack_rgba_aos(LLVMBuilderRef builder,
lp_build_pack_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *desc,
LLVMValueRef rgba)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef type;
LLVMValueRef packed = NULL;
LLVMValueRef swizzles[4];
@@ -276,7 +278,7 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
assert(desc->block.width == 1);
assert(desc->block.height == 1);
type = LLVMIntType(desc->block.bits);
type = LLVMIntTypeInContext(gallivm->context, desc->block.bits);
/* Unswizzle the color components into the source vector. */
for (i = 0; i < 4; ++i) {
@@ -285,13 +287,13 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
break;
}
if (j < 4)
swizzles[i] = LLVMConstInt(LLVMInt32Type(), j, 0);
swizzles[i] = lp_build_const_int32(gallivm, j);
else
swizzles[i] = LLVMGetUndef(LLVMInt32Type());
swizzles[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context));
}
unswizzled = LLVMBuildShuffleVector(builder, rgba,
LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4)),
LLVMGetUndef(LLVMVectorType(LLVMFloatTypeInContext(gallivm->context), 4)),
LLVMConstVector(swizzles, 4), "");
normalized = FALSE;
@@ -300,8 +302,8 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
unsigned bits = desc->channel[i].size;
if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID) {
shifts[i] = LLVMGetUndef(LLVMInt32Type());
scales[i] = LLVMGetUndef(LLVMFloatType());
shifts[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context));
scales[i] = LLVMGetUndef(LLVMFloatTypeInContext(gallivm->context));
}
else {
unsigned mask = (1 << bits) - 1;
@@ -309,14 +311,14 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
assert(desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED);
assert(bits < 32);
shifts[i] = LLVMConstInt(LLVMInt32Type(), shift, 0);
shifts[i] = lp_build_const_int32(gallivm, shift);
if (desc->channel[i].normalized) {
scales[i] = LLVMConstReal(LLVMFloatType(), mask);
scales[i] = lp_build_const_float(gallivm, mask);
normalized = TRUE;
}
else
scales[i] = LLVMConstReal(LLVMFloatType(), 1.0);
scales[i] = lp_build_const_float(gallivm, 1.0);
}
shift += bits;
@@ -327,14 +329,15 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
else
scaled = unswizzled;
casted = LLVMBuildFPToSI(builder, scaled, LLVMVectorType(LLVMInt32Type(), 4), "");
casted = LLVMBuildFPToSI(builder, scaled, LLVMVectorType(LLVMInt32TypeInContext(gallivm->context), 4), "");
shifted = LLVMBuildShl(builder, casted, LLVMConstVector(shifts, 4), "");
/* Bitwise or all components */
for (i = 0; i < 4; ++i) {
if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) {
LLVMValueRef component = LLVMBuildExtractElement(builder, shifted, LLVMConstInt(LLVMInt32Type(), i, 0), "");
LLVMValueRef component = LLVMBuildExtractElement(builder, shifted,
lp_build_const_int32(gallivm, i), "");
if (packed)
packed = LLVMBuildOr(builder, packed, component, "");
else
@@ -343,7 +346,7 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
}
if (!packed)
packed = LLVMGetUndef(LLVMInt32Type());
packed = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context));
if (desc->block.bits < 32)
packed = LLVMBuildTrunc(builder, packed, type, "");
@@ -364,7 +367,7 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
* \return a 4 element vector with the pixel's RGBA values.
*/
LLVMValueRef
lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef base_ptr,
@@ -372,13 +375,14 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef i,
LLVMValueRef j)
{
LLVMBuilderRef builder = gallivm->builder;
unsigned num_pixels = type.length / 4;
struct lp_build_context bld;
assert(type.length <= LP_MAX_VECTOR_LENGTH);
assert(type.length % 4 == 0);
lp_build_context_init(&bld, builder, type);
lp_build_context_init(&bld, gallivm, type);
/*
* Trivial case
@@ -397,13 +401,14 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
* scaling or converting.
*/
packed = lp_build_gather(builder, type.length/4,
packed = lp_build_gather(gallivm, type.length/4,
format_desc->block.bits, type.width*4,
base_ptr, offset);
assert(format_desc->block.bits <= type.width * type.length);
packed = LLVMBuildBitCast(builder, packed, lp_build_vec_type(type), "");
packed = LLVMBuildBitCast(gallivm->builder, packed,
lp_build_vec_type(gallivm, type), "");
return lp_build_format_swizzle_aos(format_desc, &bld, packed);
}
@@ -435,11 +440,12 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
for (k = 0; k < num_pixels; ++k) {
LLVMValueRef packed;
packed = lp_build_gather_elem(builder, num_pixels,
packed = lp_build_gather_elem(gallivm, num_pixels,
format_desc->block.bits, 32,
base_ptr, offset, k);
tmps[k] = lp_build_unpack_arith_rgba_aos(builder, format_desc,
tmps[k] = lp_build_unpack_arith_rgba_aos(gallivm,
format_desc,
packed);
}
@@ -455,7 +461,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
__FUNCTION__, format_desc->short_name);
}
lp_build_conv(builder,
lp_build_conv(gallivm,
lp_float32_vec4_type(),
type,
tmps, num_pixels, &res, 1);
@@ -476,14 +482,14 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
tmp_type.length = num_pixels * 4;
tmp_type.norm = TRUE;
tmp = lp_build_fetch_subsampled_rgba_aos(builder,
tmp = lp_build_fetch_subsampled_rgba_aos(gallivm,
format_desc,
num_pixels,
base_ptr,
offset,
i, j);
lp_build_conv(builder,
lp_build_conv(gallivm,
tmp_type, type,
&tmp, 1, &tmp, 1);
@@ -505,11 +511,11 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
* or incentive to optimize.
*/
LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder)));
char name[256];
LLVMTypeRef i8t = LLVMInt8Type();
LLVMTypeRef i8t = LLVMInt8TypeInContext(gallivm->context);
LLVMTypeRef pi8t = LLVMPointerType(i8t, 0);
LLVMTypeRef i32t = LLVMInt32Type();
LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context);
LLVMValueRef function;
LLVMValueRef tmp_ptr;
LLVMValueRef tmp;
@@ -533,10 +539,10 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
LLVMTypeRef arg_types[4];
LLVMTypeRef function_type;
ret_type = LLVMVoidType();
ret_type = LLVMVoidTypeInContext(gallivm->context);
arg_types[0] = pi8t;
arg_types[1] = pi8t;
arg_types[3] = arg_types[2] = LLVMIntType(sizeof(unsigned) * 8);
arg_types[3] = arg_types[2] = LLVMIntTypeInContext(gallivm->context, sizeof(unsigned) * 8);
function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0);
function = LLVMAddFunction(module, name, function_type);
@@ -545,11 +551,11 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
assert(LLVMIsDeclaration(function));
LLVMAddGlobalMapping(lp_build_engine, function,
LLVMAddGlobalMapping(gallivm->engine, function,
func_to_pointer((func_pointer)format_desc->fetch_rgba_8unorm));
}
tmp_ptr = lp_build_alloca(builder, i32t, "");
tmp_ptr = lp_build_alloca(gallivm, i32t, "");
res = LLVMGetUndef(LLVMVectorType(i32t, num_pixels));
@@ -559,11 +565,11 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
*/
for (k = 0; k < num_pixels; ++k) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), k, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, k);
LLVMValueRef args[4];
args[0] = LLVMBuildBitCast(builder, tmp_ptr, pi8t, "");
args[1] = lp_build_gather_elem_ptr(builder, num_pixels,
args[1] = lp_build_gather_elem_ptr(gallivm, num_pixels,
base_ptr, offset, k);
if (num_pixels == 1) {
@@ -610,7 +616,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
char name[256];
LLVMTypeRef f32t = LLVMFloatType();
LLVMTypeRef f32t = LLVMFloatTypeInContext(gallivm->context);
LLVMTypeRef f32x4t = LLVMVectorType(f32t, 4);
LLVMTypeRef pf32t = LLVMPointerType(f32t, 0);
LLVMValueRef function;
@@ -636,10 +642,10 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
LLVMTypeRef arg_types[4];
LLVMTypeRef function_type;
ret_type = LLVMVoidType();
ret_type = LLVMVoidTypeInContext(gallivm->context);
arg_types[0] = pf32t;
arg_types[1] = LLVMPointerType(LLVMInt8Type(), 0);
arg_types[3] = arg_types[2] = LLVMIntType(sizeof(unsigned) * 8);
arg_types[1] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
arg_types[3] = arg_types[2] = LLVMIntTypeInContext(gallivm->context, sizeof(unsigned) * 8);
function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0);
function = LLVMAddFunction(module, name, function_type);
@@ -648,11 +654,11 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
assert(LLVMIsDeclaration(function));
LLVMAddGlobalMapping(lp_build_engine, function,
LLVMAddGlobalMapping(gallivm->engine, function,
func_to_pointer((func_pointer)format_desc->fetch_rgba_float));
}
tmp_ptr = lp_build_alloca(builder, f32x4t, "");
tmp_ptr = lp_build_alloca(gallivm, f32x4t, "");
/*
* Invoke format_desc->fetch_rgba_float() for each pixel and insert the result
@@ -663,7 +669,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef args[4];
args[0] = LLVMBuildBitCast(builder, tmp_ptr, pf32t, "");
args[1] = lp_build_gather_elem_ptr(builder, num_pixels,
args[1] = lp_build_gather_elem_ptr(gallivm, num_pixels,
base_ptr, offset, k);
if (num_pixels == 1) {
@@ -671,7 +677,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
args[3] = j;
}
else {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), k, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, k);
args[2] = LLVMBuildExtractElement(builder, i, index, "");
args[3] = LLVMBuildExtractElement(builder, j, index, "");
}
@@ -681,7 +687,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
tmps[k] = LLVMBuildLoad(builder, tmp_ptr, "");
}
lp_build_conv(builder,
lp_build_conv(gallivm,
lp_float32_vec4_type(),
type,
tmps, num_pixels, &res, 1);
@@ -690,5 +696,5 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
}
assert(0);
return lp_build_undef(type);
return lp_build_undef(gallivm, type);
}

View File

@@ -97,12 +97,13 @@ lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
* \param rgba_out returns the SoA R,G,B,A vectors
*/
void
lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
lp_build_unpack_rgba_soa(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef packed,
LLVMValueRef rgba_out[4])
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_build_context bld;
LLVMValueRef inputs[4];
unsigned start;
@@ -116,7 +117,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
assert(type.floating);
assert(type.width == 32);
lp_build_context_init(&bld, builder, type);
lp_build_context_init(&bld, gallivm, type);
/* Decode the input vector components */
start = 0;
@@ -129,7 +130,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
switch(format_desc->channel[chan].type) {
case UTIL_FORMAT_TYPE_VOID:
input = lp_build_undef(type);
input = lp_build_undef(gallivm, type);
break;
case UTIL_FORMAT_TYPE_UNSIGNED:
@@ -138,7 +139,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
*/
if (start) {
input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(type, start), "");
input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(gallivm, type, start), "");
}
/*
@@ -147,7 +148,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
if (stop < format_desc->block.bits) {
unsigned mask = ((unsigned long long)1 << width) - 1;
input = LLVMBuildAnd(builder, input, lp_build_const_int_vec(type, mask), "");
input = LLVMBuildAnd(builder, input, lp_build_const_int_vec(gallivm, type, mask), "");
}
/*
@@ -156,14 +157,15 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
if (type.floating) {
if(format_desc->channel[chan].normalized)
input = lp_build_unsigned_norm_to_float(builder, width, type, input);
input = lp_build_unsigned_norm_to_float(gallivm, width, type, input);
else
input = LLVMBuildSIToFP(builder, input, lp_build_vec_type(type), "");
input = LLVMBuildSIToFP(builder, input,
lp_build_vec_type(gallivm, type), "");
}
else {
/* FIXME */
assert(0);
input = lp_build_undef(type);
input = lp_build_undef(gallivm, type);
}
break;
@@ -175,7 +177,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
if (stop < type.width) {
unsigned bits = type.width - stop;
LLVMValueRef bits_val = lp_build_const_int_vec(type, bits);
LLVMValueRef bits_val = lp_build_const_int_vec(gallivm, type, bits);
input = LLVMBuildShl(builder, input, bits_val, "");
}
@@ -185,7 +187,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
if (format_desc->channel[chan].size < type.width) {
unsigned bits = type.width - format_desc->channel[chan].size;
LLVMValueRef bits_val = lp_build_const_int_vec(type, bits);
LLVMValueRef bits_val = lp_build_const_int_vec(gallivm, type, bits);
input = LLVMBuildAShr(builder, input, bits_val, "");
}
@@ -194,17 +196,17 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
*/
if (type.floating) {
input = LLVMBuildSIToFP(builder, input, lp_build_vec_type(type), "");
input = LLVMBuildSIToFP(builder, input, lp_build_vec_type(gallivm, type), "");
if (format_desc->channel[chan].normalized) {
double scale = 1.0 / ((1 << (format_desc->channel[chan].size - 1)) - 1);
LLVMValueRef scale_val = lp_build_const_vec(type, scale);
LLVMValueRef scale_val = lp_build_const_vec(gallivm, type, scale);
input = LLVMBuildFMul(builder, input, scale_val, "");
}
}
else {
/* FIXME */
assert(0);
input = lp_build_undef(type);
input = lp_build_undef(gallivm, type);
}
break;
@@ -214,32 +216,32 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
assert(start == 0);
assert(stop == 32);
assert(type.width == 32);
input = LLVMBuildBitCast(builder, input, lp_build_vec_type(type), "");
input = LLVMBuildBitCast(builder, input, lp_build_vec_type(gallivm, type), "");
}
else {
/* FIXME */
assert(0);
input = lp_build_undef(type);
input = lp_build_undef(gallivm, type);
}
break;
case UTIL_FORMAT_TYPE_FIXED:
if (type.floating) {
double scale = 1.0 / ((1 << (format_desc->channel[chan].size/2)) - 1);
LLVMValueRef scale_val = lp_build_const_vec(type, scale);
input = LLVMBuildSIToFP(builder, input, lp_build_vec_type(type), "");
LLVMValueRef scale_val = lp_build_const_vec(gallivm, type, scale);
input = LLVMBuildSIToFP(builder, input, lp_build_vec_type(gallivm, type), "");
input = LLVMBuildFMul(builder, input, scale_val, "");
}
else {
/* FIXME */
assert(0);
input = lp_build_undef(type);
input = lp_build_undef(gallivm, type);
}
break;
default:
assert(0);
input = lp_build_undef(type);
input = lp_build_undef(gallivm, type);
break;
}
@@ -253,16 +255,17 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
void
lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
lp_build_rgba8_to_f32_soa(struct gallivm_state *gallivm,
struct lp_type dst_type,
LLVMValueRef packed,
LLVMValueRef *rgba)
{
LLVMValueRef mask = lp_build_const_int_vec(dst_type, 0xff);
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef mask = lp_build_const_int_vec(gallivm, dst_type, 0xff);
unsigned chan;
packed = LLVMBuildBitCast(builder, packed,
lp_build_int_vec_type(dst_type), "");
lp_build_int_vec_type(gallivm, dst_type), "");
/* Decode the input vector components */
for (chan = 0; chan < 4; ++chan) {
@@ -274,12 +277,12 @@ lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
if (start)
input = LLVMBuildLShr(builder, input,
lp_build_const_int_vec(dst_type, start), "");
lp_build_const_int_vec(gallivm, dst_type, start), "");
if (stop < 32)
input = LLVMBuildAnd(builder, input, mask, "");
input = lp_build_unsigned_norm_to_float(builder, 8, dst_type, input);
input = lp_build_unsigned_norm_to_float(gallivm, 8, dst_type, input);
rgba[chan] = input;
}
@@ -303,7 +306,7 @@ lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
* be in [0, block_width-1] and j will be in [0, block_height-1].
*/
void
lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef base_ptr,
@@ -312,6 +315,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
LLVMValueRef j,
LLVMValueRef rgba_out[4])
{
LLVMBuilderRef builder = gallivm->builder;
if (format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
@@ -334,7 +338,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
* gather the texels from the texture
* Ex: packed = {BGRA, BGRA, BGRA, BGRA}.
*/
packed = lp_build_gather(builder,
packed = lp_build_gather(gallivm,
type.length,
format_desc->block.bits,
type.width,
@@ -343,7 +347,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
/*
* convert texels to float rgba
*/
lp_build_unpack_rgba_soa(builder,
lp_build_unpack_rgba_soa(gallivm,
format_desc,
type,
packed, rgba_out);
@@ -364,10 +368,10 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
tmp_type.length = type.length * 4;
tmp_type.norm = TRUE;
tmp = lp_build_fetch_rgba_aos(builder, format_desc, tmp_type,
tmp = lp_build_fetch_rgba_aos(gallivm, format_desc, tmp_type,
base_ptr, offset, i, j);
lp_build_rgba8_to_f32_soa(builder,
lp_build_rgba8_to_f32_soa(gallivm,
type,
tmp,
rgba_out);
@@ -397,23 +401,24 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
tmp_type.length = 4;
for (chan = 0; chan < 4; ++chan) {
rgba_out[chan] = lp_build_undef(type);
rgba_out[chan] = lp_build_undef(gallivm, type);
}
/* loop over number of pixels */
for(k = 0; k < type.length; ++k) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), k, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, k);
LLVMValueRef offset_elem;
LLVMValueRef i_elem, j_elem;
LLVMValueRef tmp;
offset_elem = LLVMBuildExtractElement(builder, offset, index, "");
offset_elem = LLVMBuildExtractElement(builder, offset,
index, "");
i_elem = LLVMBuildExtractElement(builder, i, index, "");
j_elem = LLVMBuildExtractElement(builder, j, index, "");
/* Get a single float[4]={R,G,B,A} pixel */
tmp = lp_build_fetch_rgba_aos(builder, format_desc, tmp_type,
tmp = lp_build_fetch_rgba_aos(gallivm, format_desc, tmp_type,
base_ptr, offset_elem,
i_elem, j_elem);
@@ -422,7 +427,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
* position = 'index'.
*/
for (chan = 0; chan < 4; ++chan) {
LLVMValueRef chan_val = LLVMConstInt(LLVMInt32Type(), chan, 0),
LLVMValueRef chan_val = lp_build_const_int32(gallivm, chan),
tmp_chan = LLVMBuildExtractElement(builder, tmp, chan_val, "");
rgba_out[chan] = LLVMBuildInsertElement(builder, rgba_out[chan],
tmp_chan, index, "");

View File

@@ -43,6 +43,7 @@
#include "lp_bld_conv.h"
#include "lp_bld_gather.h"
#include "lp_bld_format.h"
#include "lp_bld_init.h"
#include "lp_bld_logic.h"
/**
@@ -51,7 +52,7 @@
* @param i is a <n x i32> vector with the x pixel coordinate (0 or 1)
*/
static void
uyvy_to_yuv_soa(LLVMBuilderRef builder,
uyvy_to_yuv_soa(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i,
@@ -59,6 +60,7 @@ uyvy_to_yuv_soa(LLVMBuilderRef builder,
LLVMValueRef *u,
LLVMValueRef *v)
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_type type;
LLVMValueRef mask;
@@ -86,25 +88,25 @@ uyvy_to_yuv_soa(LLVMBuilderRef builder,
LLVMValueRef sel, tmp, tmp2;
struct lp_build_context bld32;
lp_build_context_init(&bld32, builder, type);
lp_build_context_init(&bld32, gallivm, type);
tmp = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(type, 8), "");
tmp2 = LLVMBuildLShr(builder, tmp, lp_build_const_int_vec(type, 16), "");
sel = lp_build_compare(builder, type, PIPE_FUNC_EQUAL, i, lp_build_const_int_vec(type, 0));
tmp = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 8), "");
tmp2 = LLVMBuildLShr(builder, tmp, lp_build_const_int_vec(gallivm, type, 16), "");
sel = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, i, lp_build_const_int_vec(gallivm, type, 0));
*y = lp_build_select(&bld32, sel, tmp, tmp2);
} else
#endif
{
LLVMValueRef shift;
shift = LLVMBuildMul(builder, i, lp_build_const_int_vec(type, 16), "");
shift = LLVMBuildAdd(builder, shift, lp_build_const_int_vec(type, 8), "");
shift = LLVMBuildMul(builder, i, lp_build_const_int_vec(gallivm, type, 16), "");
shift = LLVMBuildAdd(builder, shift, lp_build_const_int_vec(gallivm, type, 8), "");
*y = LLVMBuildLShr(builder, packed, shift, "");
}
*u = packed;
*v = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(type, 16), "");
*v = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 16), "");
mask = lp_build_const_int_vec(type, 0xff);
mask = lp_build_const_int_vec(gallivm, type, 0xff);
*y = LLVMBuildAnd(builder, *y, mask, "y");
*u = LLVMBuildAnd(builder, *u, mask, "u");
@@ -118,7 +120,7 @@ uyvy_to_yuv_soa(LLVMBuilderRef builder,
* @param i is a <n x i32> vector with the x pixel coordinate (0 or 1)
*/
static void
yuyv_to_yuv_soa(LLVMBuilderRef builder,
yuyv_to_yuv_soa(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i,
@@ -126,6 +128,7 @@ yuyv_to_yuv_soa(LLVMBuilderRef builder,
LLVMValueRef *u,
LLVMValueRef *v)
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_type type;
LLVMValueRef mask;
@@ -153,23 +156,23 @@ yuyv_to_yuv_soa(LLVMBuilderRef builder,
LLVMValueRef sel, tmp;
struct lp_build_context bld32;
lp_build_context_init(&bld32, builder, type);
lp_build_context_init(&bld32, gallivm, type);
tmp = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(type, 16), "");
sel = lp_build_compare(builder, type, PIPE_FUNC_EQUAL, i, lp_build_const_int_vec(type, 0));
tmp = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 16), "");
sel = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, i, lp_build_const_int_vec(gallivm, type, 0));
*y = lp_build_select(&bld32, sel, packed, tmp);
} else
#endif
{
LLVMValueRef shift;
shift = LLVMBuildMul(builder, i, lp_build_const_int_vec(type, 16), "");
shift = LLVMBuildMul(builder, i, lp_build_const_int_vec(gallivm, type, 16), "");
*y = LLVMBuildLShr(builder, packed, shift, "");
}
*u = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(type, 8), "");
*v = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(type, 24), "");
*u = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 8), "");
*v = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 24), "");
mask = lp_build_const_int_vec(type, 0xff);
mask = lp_build_const_int_vec(gallivm, type, 0xff);
*y = LLVMBuildAnd(builder, *y, mask, "y");
*u = LLVMBuildAnd(builder, *u, mask, "u");
@@ -178,11 +181,12 @@ yuyv_to_yuv_soa(LLVMBuilderRef builder,
static INLINE void
yuv_to_rgb_soa(LLVMBuilderRef builder,
yuv_to_rgb_soa(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef y, LLVMValueRef u, LLVMValueRef v,
LLVMValueRef *r, LLVMValueRef *g, LLVMValueRef *b)
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_type type;
struct lp_build_context bld;
@@ -203,7 +207,7 @@ yuv_to_rgb_soa(LLVMBuilderRef builder,
type.width = 32;
type.length = n;
lp_build_context_init(&bld, builder, type);
lp_build_context_init(&bld, gallivm, type);
assert(lp_check_value(type, y));
assert(lp_check_value(type, u));
@@ -213,17 +217,17 @@ yuv_to_rgb_soa(LLVMBuilderRef builder,
* Constants
*/
c0 = lp_build_const_int_vec(type, 0);
c8 = lp_build_const_int_vec(type, 8);
c16 = lp_build_const_int_vec(type, 16);
c128 = lp_build_const_int_vec(type, 128);
c255 = lp_build_const_int_vec(type, 255);
c0 = lp_build_const_int_vec(gallivm, type, 0);
c8 = lp_build_const_int_vec(gallivm, type, 8);
c16 = lp_build_const_int_vec(gallivm, type, 16);
c128 = lp_build_const_int_vec(gallivm, type, 128);
c255 = lp_build_const_int_vec(gallivm, type, 255);
cy = lp_build_const_int_vec(type, 298);
cug = lp_build_const_int_vec(type, -100);
cub = lp_build_const_int_vec(type, 516);
cvr = lp_build_const_int_vec(type, 409);
cvg = lp_build_const_int_vec(type, -208);
cy = lp_build_const_int_vec(gallivm, type, 298);
cug = lp_build_const_int_vec(gallivm, type, -100);
cub = lp_build_const_int_vec(gallivm, type, 516);
cvr = lp_build_const_int_vec(gallivm, type, 409);
cvg = lp_build_const_int_vec(gallivm, type, -208);
/*
* y -= 16;
@@ -276,10 +280,11 @@ yuv_to_rgb_soa(LLVMBuilderRef builder,
static LLVMValueRef
rgb_to_rgba_aos(LLVMBuilderRef builder,
rgb_to_rgba_aos(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef r, LLVMValueRef g, LLVMValueRef b)
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_type type;
LLVMValueRef a;
LLVMValueRef rgba;
@@ -298,9 +303,9 @@ rgb_to_rgba_aos(LLVMBuilderRef builder,
*/
r = r;
g = LLVMBuildShl(builder, g, lp_build_const_int_vec(type, 8), "");
b = LLVMBuildShl(builder, b, lp_build_const_int_vec(type, 16), "");
a = lp_build_const_int_vec(type, 0xff000000);
g = LLVMBuildShl(builder, g, lp_build_const_int_vec(gallivm, type, 8), "");
b = LLVMBuildShl(builder, b, lp_build_const_int_vec(gallivm, type, 16), "");
a = lp_build_const_int_vec(gallivm, type, 0xff000000);
rgba = r;
rgba = LLVMBuildOr(builder, rgba, g, "");
@@ -308,7 +313,7 @@ rgb_to_rgba_aos(LLVMBuilderRef builder,
rgba = LLVMBuildOr(builder, rgba, a, "");
rgba = LLVMBuildBitCast(builder, rgba,
LLVMVectorType(LLVMInt8Type(), 4*n), "");
LLVMVectorType(LLVMInt8TypeInContext(gallivm->context), 4*n), "");
return rgba;
}
@@ -318,7 +323,7 @@ rgb_to_rgba_aos(LLVMBuilderRef builder,
* Convert from <n x i32> packed UYVY to <4n x i8> RGBA AoS
*/
static LLVMValueRef
uyvy_to_rgba_aos(LLVMBuilderRef builder,
uyvy_to_rgba_aos(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i)
@@ -327,9 +332,9 @@ uyvy_to_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef r, g, b;
LLVMValueRef rgba;
uyvy_to_yuv_soa(builder, n, packed, i, &y, &u, &v);
yuv_to_rgb_soa(builder, n, y, u, v, &r, &g, &b);
rgba = rgb_to_rgba_aos(builder, n, r, g, b);
uyvy_to_yuv_soa(gallivm, n, packed, i, &y, &u, &v);
yuv_to_rgb_soa(gallivm, n, y, u, v, &r, &g, &b);
rgba = rgb_to_rgba_aos(gallivm, n, r, g, b);
return rgba;
}
@@ -339,7 +344,7 @@ uyvy_to_rgba_aos(LLVMBuilderRef builder,
* Convert from <n x i32> packed YUYV to <4n x i8> RGBA AoS
*/
static LLVMValueRef
yuyv_to_rgba_aos(LLVMBuilderRef builder,
yuyv_to_rgba_aos(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i)
@@ -348,9 +353,9 @@ yuyv_to_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef r, g, b;
LLVMValueRef rgba;
yuyv_to_yuv_soa(builder, n, packed, i, &y, &u, &v);
yuv_to_rgb_soa(builder, n, y, u, v, &r, &g, &b);
rgba = rgb_to_rgba_aos(builder, n, r, g, b);
yuyv_to_yuv_soa(gallivm, n, packed, i, &y, &u, &v);
yuv_to_rgb_soa(gallivm, n, y, u, v, &r, &g, &b);
rgba = rgb_to_rgba_aos(gallivm, n, r, g, b);
return rgba;
}
@@ -360,7 +365,7 @@ yuyv_to_rgba_aos(LLVMBuilderRef builder,
* Convert from <n x i32> packed RG_BG to <4n x i8> RGBA AoS
*/
static LLVMValueRef
rgbg_to_rgba_aos(LLVMBuilderRef builder,
rgbg_to_rgba_aos(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i)
@@ -368,8 +373,8 @@ rgbg_to_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef r, g, b;
LLVMValueRef rgba;
uyvy_to_yuv_soa(builder, n, packed, i, &g, &r, &b);
rgba = rgb_to_rgba_aos(builder, n, r, g, b);
uyvy_to_yuv_soa(gallivm, n, packed, i, &g, &r, &b);
rgba = rgb_to_rgba_aos(gallivm, n, r, g, b);
return rgba;
}
@@ -379,7 +384,7 @@ rgbg_to_rgba_aos(LLVMBuilderRef builder,
* Convert from <n x i32> packed GR_GB to <4n x i8> RGBA AoS
*/
static LLVMValueRef
grgb_to_rgba_aos(LLVMBuilderRef builder,
grgb_to_rgba_aos(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i)
@@ -387,8 +392,8 @@ grgb_to_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef r, g, b;
LLVMValueRef rgba;
yuyv_to_yuv_soa(builder, n, packed, i, &g, &r, &b);
rgba = rgb_to_rgba_aos(builder, n, r, g, b);
yuyv_to_yuv_soa(gallivm, n, packed, i, &g, &r, &b);
rgba = rgb_to_rgba_aos(gallivm, n, r, g, b);
return rgba;
}
@@ -401,7 +406,7 @@ grgb_to_rgba_aos(LLVMBuilderRef builder,
* @return a <4*n x i8> vector with the pixel RGBA values in AoS
*/
LLVMValueRef
lp_build_fetch_subsampled_rgba_aos(LLVMBuilderRef builder,
lp_build_fetch_subsampled_rgba_aos(struct gallivm_state *gallivm,
const struct util_format_description *format_desc,
unsigned n,
LLVMValueRef base_ptr,
@@ -417,26 +422,26 @@ lp_build_fetch_subsampled_rgba_aos(LLVMBuilderRef builder,
assert(format_desc->block.width == 2);
assert(format_desc->block.height == 1);
packed = lp_build_gather(builder, n, 32, 32, base_ptr, offset);
packed = lp_build_gather(gallivm, n, 32, 32, base_ptr, offset);
(void)j;
switch (format_desc->format) {
case PIPE_FORMAT_UYVY:
rgba = uyvy_to_rgba_aos(builder, n, packed, i);
rgba = uyvy_to_rgba_aos(gallivm, n, packed, i);
break;
case PIPE_FORMAT_YUYV:
rgba = yuyv_to_rgba_aos(builder, n, packed, i);
rgba = yuyv_to_rgba_aos(gallivm, n, packed, i);
break;
case PIPE_FORMAT_R8G8_B8G8_UNORM:
rgba = rgbg_to_rgba_aos(builder, n, packed, i);
rgba = rgbg_to_rgba_aos(gallivm, n, packed, i);
break;
case PIPE_FORMAT_G8R8_G8B8_UNORM:
rgba = grgb_to_rgba_aos(builder, n, packed, i);
rgba = grgb_to_rgba_aos(gallivm, n, packed, i);
break;
default:
assert(0);
rgba = LLVMGetUndef(LLVMVectorType(LLVMInt8Type(), 4*n));
rgba = LLVMGetUndef(LLVMVectorType(LLVMInt8TypeInContext(gallivm->context), 4*n));
break;
}

View File

@@ -31,6 +31,7 @@
#include "lp_bld_const.h"
#include "lp_bld_format.h"
#include "lp_bld_gather.h"
#include "lp_bld_init.h"
/**
@@ -39,7 +40,7 @@
* @sa lp_build_gather()
*/
LLVMValueRef
lp_build_gather_elem_ptr(LLVMBuilderRef builder,
lp_build_gather_elem_ptr(struct gallivm_state *gallivm,
unsigned length,
LLVMValueRef base_ptr,
LLVMValueRef offsets,
@@ -48,17 +49,17 @@ lp_build_gather_elem_ptr(LLVMBuilderRef builder,
LLVMValueRef offset;
LLVMValueRef ptr;
assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8Type(), 0));
assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0));
if (length == 1) {
assert(i == 0);
offset = offsets;
} else {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
offset = LLVMBuildExtractElement(builder, offsets, index, "");
LLVMValueRef index = lp_build_const_int32(gallivm, i);
offset = LLVMBuildExtractElement(gallivm->builder, offsets, index, "");
}
ptr = LLVMBuildGEP(builder, base_ptr, &offset, 1, "");
ptr = LLVMBuildGEP(gallivm->builder, base_ptr, &offset, 1, "");
return ptr;
}
@@ -70,7 +71,7 @@ lp_build_gather_elem_ptr(LLVMBuilderRef builder,
* @sa lp_build_gather()
*/
LLVMValueRef
lp_build_gather_elem(LLVMBuilderRef builder,
lp_build_gather_elem(struct gallivm_state *gallivm,
unsigned length,
unsigned src_width,
unsigned dst_width,
@@ -78,23 +79,23 @@ lp_build_gather_elem(LLVMBuilderRef builder,
LLVMValueRef offsets,
unsigned i)
{
LLVMTypeRef src_type = LLVMIntType(src_width);
LLVMTypeRef src_type = LLVMIntTypeInContext(gallivm->context, src_width);
LLVMTypeRef src_ptr_type = LLVMPointerType(src_type, 0);
LLVMTypeRef dst_elem_type = LLVMIntType(dst_width);
LLVMTypeRef dst_elem_type = LLVMIntTypeInContext(gallivm->context, dst_width);
LLVMValueRef ptr;
LLVMValueRef res;
assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8Type(), 0));
assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0));
ptr = lp_build_gather_elem_ptr(builder, length, base_ptr, offsets, i);
ptr = LLVMBuildBitCast(builder, ptr, src_ptr_type, "");
res = LLVMBuildLoad(builder, ptr, "");
ptr = lp_build_gather_elem_ptr(gallivm, length, base_ptr, offsets, i);
ptr = LLVMBuildBitCast(gallivm->builder, ptr, src_ptr_type, "");
res = LLVMBuildLoad(gallivm->builder, ptr, "");
assert(src_width <= dst_width);
if (src_width > dst_width)
res = LLVMBuildTrunc(builder, res, dst_elem_type, "");
res = LLVMBuildTrunc(gallivm->builder, res, dst_elem_type, "");
if (src_width < dst_width)
res = LLVMBuildZExt(builder, res, dst_elem_type, "");
res = LLVMBuildZExt(gallivm->builder, res, dst_elem_type, "");
return res;
}
@@ -112,7 +113,7 @@ lp_build_gather_elem(LLVMBuilderRef builder,
* @param offsets vector with offsets
*/
LLVMValueRef
lp_build_gather(LLVMBuilderRef builder,
lp_build_gather(struct gallivm_state *gallivm,
unsigned length,
unsigned src_width,
unsigned dst_width,
@@ -123,24 +124,24 @@ lp_build_gather(LLVMBuilderRef builder,
if (length == 1) {
/* Scalar */
return lp_build_gather_elem(builder, length,
return lp_build_gather_elem(gallivm, length,
src_width, dst_width,
base_ptr, offsets, 0);
} else {
/* Vector */
LLVMTypeRef dst_elem_type = LLVMIntType(dst_width);
LLVMTypeRef dst_elem_type = LLVMIntTypeInContext(gallivm->context, dst_width);
LLVMTypeRef dst_vec_type = LLVMVectorType(dst_elem_type, length);
unsigned i;
res = LLVMGetUndef(dst_vec_type);
for (i = 0; i < length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, i);
LLVMValueRef elem;
elem = lp_build_gather_elem(builder, length,
elem = lp_build_gather_elem(gallivm, length,
src_width, dst_width,
base_ptr, offsets, i);
res = LLVMBuildInsertElement(builder, res, elem, index, "");
res = LLVMBuildInsertElement(gallivm->builder, res, elem, index, "");
}
}

View File

@@ -34,14 +34,14 @@
LLVMValueRef
lp_build_gather_elem_ptr(LLVMBuilderRef builder,
lp_build_gather_elem_ptr(struct gallivm_state *gallivm,
unsigned length,
LLVMValueRef base_ptr,
LLVMValueRef offsets,
unsigned i);
LLVMValueRef
lp_build_gather_elem(LLVMBuilderRef builder,
lp_build_gather_elem(struct gallivm_state *gallivm,
unsigned length,
unsigned src_width,
unsigned dst_width,
@@ -50,7 +50,7 @@ lp_build_gather_elem(LLVMBuilderRef builder,
unsigned i);
LLVMValueRef
lp_build_gather(LLVMBuilderRef builder,
lp_build_gather(struct gallivm_state *gallivm,
unsigned length,
unsigned src_width,
unsigned dst_width,

View File

@@ -29,6 +29,7 @@
#include "pipe/p_compiler.h"
#include "util/u_cpu_detect.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "lp_bld_debug.h"
#include "lp_bld_init.h"
@@ -45,6 +46,7 @@ static const struct debug_named_value lp_bld_debug_flags[] = {
{ "nopt", GALLIVM_DEBUG_NO_OPT, NULL },
{ "perf", GALLIVM_DEBUG_PERF, NULL },
{ "no_brilinear", GALLIVM_DEBUG_NO_BRILINEAR, NULL },
{ "gc", GALLIVM_DEBUG_GC, NULL },
DEBUG_NAMED_VALUE_END
};
@@ -52,11 +54,7 @@ DEBUG_GET_ONCE_FLAGS_OPTION(gallivm_debug, "GALLIVM_DEBUG", lp_bld_debug_flags,
#endif
LLVMModuleRef lp_build_module = NULL;
LLVMExecutionEngineRef lp_build_engine = NULL;
LLVMModuleProviderRef lp_build_provider = NULL;
LLVMTargetDataRef lp_build_target = NULL;
LLVMPassManagerRef lp_build_pass = NULL;
static boolean gallivm_initialized = FALSE;
/*
@@ -82,6 +80,19 @@ enum LLVM_CodeGenOpt_Level {
};
/**
* LLVM 2.6 permits only one ExecutionEngine to be created. This is it.
*/
static LLVMExecutionEngineRef GlobalEngine = NULL;
/**
* Same gallivm state shared by all contexts.
*/
static struct gallivm_state *GlobalGallivm = NULL;
extern void
lp_register_oprofile_jit_event_listener(LLVMExecutionEngineRef EE);
@@ -89,6 +100,288 @@ extern void
lp_set_target_options(void);
/**
* Create the LLVM (optimization) pass manager and install
* relevant optimization passes.
* \return TRUE for success, FALSE for failure
*/
static boolean
create_pass_manager(struct gallivm_state *gallivm)
{
assert(!gallivm->passmgr);
gallivm->passmgr = LLVMCreateFunctionPassManager(gallivm->provider);
if (!gallivm->passmgr)
return FALSE;
LLVMAddTargetData(gallivm->target, gallivm->passmgr);
if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) {
/* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
* but there are more on SVN.
* TODO: Add more passes.
*/
LLVMAddCFGSimplificationPass(gallivm->passmgr);
if (HAVE_LLVM >= 0x207 && sizeof(void*) == 4) {
/* For LLVM >= 2.7 and 32-bit build, use this order of passes to
* avoid generating bad code.
* Test with piglit glsl-vs-sqrt-zero test.
*/
LLVMAddConstantPropagationPass(gallivm->passmgr);
LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
}
else {
LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
LLVMAddConstantPropagationPass(gallivm->passmgr);
}
if (util_cpu_caps.has_sse4_1) {
/* FIXME: There is a bug in this pass, whereby the combination
* of fptosi and sitofp (necessary for trunc/floor/ceil/round
* implementation) somehow becomes invalid code.
*/
LLVMAddInstructionCombiningPass(gallivm->passmgr);
}
LLVMAddGVNPass(gallivm->passmgr);
}
else {
/* We need at least this pass to prevent the backends to fail in
* unexpected ways.
*/
LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
}
return TRUE;
}
/**
* Free gallivm object's LLVM allocations, but not the gallivm object itself.
*/
static void
free_gallivm_state(struct gallivm_state *gallivm)
{
#if HAVE_LLVM >= 0x207 /* XXX or 0x208? */
/* This leads to crashes w/ some versions of LLVM */
LLVMModuleRef mod;
char *error;
if (gallivm->engine && gallivm->provider)
LLVMRemoveModuleProvider(gallivm->engine, gallivm->provider,
&mod, &error);
#endif
#if 0
/* XXX this seems to crash with all versions of LLVM */
if (gallivm->provider)
LLVMDisposeModuleProvider(gallivm->provider);
#endif
if (gallivm->passmgr)
LLVMDisposePassManager(gallivm->passmgr);
#if HAVE_LLVM >= 0x207
if (gallivm->module)
LLVMDisposeModule(gallivm->module);
#endif
#if 0
/* Don't free the exec engine, it's a global/singleton */
if (gallivm->engine)
LLVMDisposeExecutionEngine(gallivm->engine);
#endif
#if 0
/* Don't free the TargetData, it's owned by the exec engine */
LLVMDisposeTargetData(gallivm->target);
#endif
if (gallivm->context)
LLVMContextDispose(gallivm->context);
if (gallivm->builder)
LLVMDisposeBuilder(gallivm->builder);
gallivm->engine = NULL;
gallivm->target = NULL;
gallivm->module = NULL;
gallivm->provider = NULL;
gallivm->passmgr = NULL;
gallivm->context = NULL;
gallivm->builder = NULL;
}
/**
* Allocate gallivm LLVM objects.
* \return TRUE for success, FALSE for failure
*/
static boolean
init_gallivm_state(struct gallivm_state *gallivm)
{
assert(gallivm_initialized);
assert(!gallivm->context);
assert(!gallivm->module);
assert(!gallivm->provider);
gallivm->context = LLVMContextCreate();
if (!gallivm->context)
goto fail;
gallivm->module = LLVMModuleCreateWithNameInContext("gallivm",
gallivm->context);
if (!gallivm->module)
goto fail;
gallivm->provider =
LLVMCreateModuleProviderForExistingModule(gallivm->module);
if (!gallivm->provider)
goto fail;
if (!GlobalEngine) {
/* We can only create one LLVMExecutionEngine (w/ LLVM 2.6 anyway) */
enum LLVM_CodeGenOpt_Level optlevel;
char *error = NULL;
if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) {
optlevel = None;
}
else {
optlevel = Default;
}
if (LLVMCreateJITCompiler(&GlobalEngine, gallivm->provider,
(unsigned) optlevel, &error)) {
_debug_printf("%s\n", error);
LLVMDisposeMessage(error);
goto fail;
}
#if defined(DEBUG) || defined(PROFILE)
lp_register_oprofile_jit_event_listener(GlobalEngine);
#endif
}
gallivm->engine = GlobalEngine;
LLVMAddModuleProvider(gallivm->engine, gallivm->provider);//new
gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine);
if (!gallivm->target)
goto fail;
if (!create_pass_manager(gallivm))
goto fail;
gallivm->builder = LLVMCreateBuilderInContext(gallivm->context);
if (!gallivm->builder)
goto fail;
return TRUE;
fail:
free_gallivm_state(gallivm);
return FALSE;
}
struct callback
{
garbage_collect_callback_func func;
void *cb_data;
};
#define MAX_CALLBACKS 32
static struct callback Callbacks[MAX_CALLBACKS];
static unsigned NumCallbacks = 0;
/**
* Register a function with gallivm which will be called when we
* do garbage collection.
*/
void
gallivm_register_garbage_collector_callback(garbage_collect_callback_func func,
void *cb_data)
{
unsigned i;
for (i = 0; i < NumCallbacks; i++) {
if (Callbacks[i].func == func && Callbacks[i].cb_data == cb_data) {
/* already in list: no-op */
return;
}
}
assert(NumCallbacks < MAX_CALLBACKS);
if (NumCallbacks < MAX_CALLBACKS) {
Callbacks[NumCallbacks].func = func;
Callbacks[NumCallbacks].cb_data = cb_data;
NumCallbacks++;
}
}
/**
* Remove a callback.
*/
void
gallivm_remove_garbage_collector_callback(garbage_collect_callback_func func,
void *cb_data)
{
unsigned i;
for (i = 0; i < NumCallbacks; i++) {
if (Callbacks[i].func == func && Callbacks[i].cb_data == cb_data) {
/* found, now remove it */
NumCallbacks--;
for ( ; i < NumCallbacks; i++) {
Callbacks[i] = Callbacks[i + 1];
}
return;
}
}
}
/**
* Call the callback functions (which are typically in the
* draw module and llvmpipe driver.
*/
static void
call_garbage_collector_callbacks(void)
{
unsigned i;
for (i = 0; i < NumCallbacks; i++) {
Callbacks[i].func(Callbacks[i].cb_data);
}
}
/**
* Other gallium components using gallivm should call this periodically
* to let us do garbage collection (or at least try to free memory
* accumulated by the LLVM libraries).
*/
void
gallivm_garbage_collect(struct gallivm_state *gallivm)
{
if (gallivm->context) {
if (gallivm_debug & GALLIVM_DEBUG_GC)
debug_printf("***** Doing LLVM garbage collection\n");
call_garbage_collector_callbacks();
free_gallivm_state(gallivm);
init_gallivm_state(gallivm);
}
}
void
lp_build_init(void)
{
@@ -102,60 +395,9 @@ lp_build_init(void)
LLVMLinkInJIT();
if (!lp_build_module)
lp_build_module = LLVMModuleCreateWithName("gallivm");
if (!lp_build_provider)
lp_build_provider = LLVMCreateModuleProviderForExistingModule(lp_build_module);
if (!lp_build_engine) {
enum LLVM_CodeGenOpt_Level optlevel;
char *error = NULL;
if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) {
optlevel = None;
}
else {
optlevel = Default;
}
if (LLVMCreateJITCompiler(&lp_build_engine, lp_build_provider,
(unsigned)optlevel, &error)) {
_debug_printf("%s\n", error);
LLVMDisposeMessage(error);
assert(0);
}
#if defined(DEBUG) || defined(PROFILE)
lp_register_oprofile_jit_event_listener(lp_build_engine);
#endif
}
if (!lp_build_target)
lp_build_target = LLVMGetExecutionEngineTargetData(lp_build_engine);
if (!lp_build_pass) {
lp_build_pass = LLVMCreateFunctionPassManager(lp_build_provider);
LLVMAddTargetData(lp_build_target, lp_build_pass);
if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) {
/* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
* but there are more on SVN. */
/* TODO: Add more passes */
LLVMAddCFGSimplificationPass(lp_build_pass);
LLVMAddPromoteMemoryToRegisterPass(lp_build_pass);
LLVMAddConstantPropagationPass(lp_build_pass);
LLVMAddInstructionCombiningPass(lp_build_pass);
LLVMAddGVNPass(lp_build_pass);
} else {
/* We need at least this pass to prevent the backends to fail in
* unexpected ways.
*/
LLVMAddPromoteMemoryToRegisterPass(lp_build_pass);
}
}
util_cpu_detect();
gallivm_initialized = TRUE;
#if 0
/* For simulating less capable machines */
@@ -166,6 +408,39 @@ lp_build_init(void)
}
/**
* Create a new gallivm_state object.
* Note that we return a singleton.
*/
struct gallivm_state *
gallivm_create(void)
{
if (!GlobalGallivm) {
GlobalGallivm = CALLOC_STRUCT(gallivm_state);
if (GlobalGallivm) {
if (!init_gallivm_state(GlobalGallivm)) {
FREE(GlobalGallivm);
GlobalGallivm = NULL;
}
}
}
return GlobalGallivm;
}
/**
* Destroy a gallivm_state object.
*/
void
gallivm_destroy(struct gallivm_state *gallivm)
{
/* No-op: don't destroy the singleton */
(void) gallivm;
}
/*
* Hack to allow the linking of release LLVM static libraries on a debug build.
*

View File

@@ -30,24 +30,53 @@
#define LP_BLD_INIT_H
#include "pipe/p_compiler.h"
#include "lp_bld.h"
#include <llvm-c/ExecutionEngine.h>
extern LLVMModuleRef lp_build_module;
extern LLVMExecutionEngineRef lp_build_engine;
extern LLVMModuleProviderRef lp_build_provider;
extern LLVMTargetDataRef lp_build_target;
extern LLVMPassManagerRef lp_build_pass;
struct gallivm_state
{
LLVMModuleRef module;
LLVMExecutionEngineRef engine;
LLVMModuleProviderRef provider;
LLVMTargetDataRef target;
LLVMPassManagerRef passmgr;
LLVMContextRef context;
LLVMBuilderRef builder;
};
void
lp_build_init(void);
extern void
lp_func_delete_body(LLVMValueRef func);
void
gallivm_garbage_collect(struct gallivm_state *gallivm);
typedef void (*garbage_collect_callback_func)(void *cb_data);
void
gallivm_register_garbage_collector_callback(garbage_collect_callback_func func,
void *cb_data);
void
gallivm_remove_garbage_collector_callback(garbage_collect_callback_func func,
void *cb_data);
struct gallivm_state *
gallivm_create(void);
void
gallivm_destroy(struct gallivm_state *gallivm);
extern LLVMValueRef
lp_build_load_volatile(LLVMBuilderRef B, LLVMValueRef PointerVal,
const char *Name);

View File

@@ -46,6 +46,7 @@
#include "util/u_debug.h"
#include "lp_bld_const.h"
#include "lp_bld_intr.h"
@@ -136,12 +137,13 @@ lp_build_intrinsic_binary(LLVMBuilderRef builder,
LLVMValueRef
lp_build_intrinsic_map(LLVMBuilderRef builder,
lp_build_intrinsic_map(struct gallivm_state *gallivm,
const char *name,
LLVMTypeRef ret_type,
LLVMValueRef *args,
unsigned num_args)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef ret_elem_type = LLVMGetElementType(ret_type);
unsigned n = LLVMGetVectorSize(ret_type);
unsigned i, j;
@@ -151,7 +153,7 @@ lp_build_intrinsic_map(LLVMBuilderRef builder,
res = LLVMGetUndef(ret_type);
for(i = 0; i < n; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, i);
LLVMValueRef arg_elems[LP_MAX_FUNC_ARGS];
LLVMValueRef res_elem;
for(j = 0; j < num_args; ++j)
@@ -165,17 +167,17 @@ lp_build_intrinsic_map(LLVMBuilderRef builder,
LLVMValueRef
lp_build_intrinsic_map_unary(LLVMBuilderRef builder,
lp_build_intrinsic_map_unary(struct gallivm_state *gallivm,
const char *name,
LLVMTypeRef ret_type,
LLVMValueRef a)
{
return lp_build_intrinsic_map(builder, name, ret_type, &a, 1);
return lp_build_intrinsic_map(gallivm, name, ret_type, &a, 1);
}
LLVMValueRef
lp_build_intrinsic_map_binary(LLVMBuilderRef builder,
lp_build_intrinsic_map_binary(struct gallivm_state *gallivm,
const char *name,
LLVMTypeRef ret_type,
LLVMValueRef a,
@@ -186,7 +188,7 @@ lp_build_intrinsic_map_binary(LLVMBuilderRef builder,
args[0] = a;
args[1] = b;
return lp_build_intrinsic_map(builder, name, ret_type, args, 2);
return lp_build_intrinsic_map(gallivm, name, ret_type, args, 2);
}

View File

@@ -38,6 +38,7 @@
#include "gallivm/lp_bld.h"
#include "gallivm/lp_bld_init.h"
/**
@@ -77,7 +78,7 @@ lp_build_intrinsic_binary(LLVMBuilderRef builder,
LLVMValueRef
lp_build_intrinsic_map(LLVMBuilderRef builder,
lp_build_intrinsic_map(struct gallivm_state *gallivm,
const char *name,
LLVMTypeRef ret_type,
LLVMValueRef *args,
@@ -85,14 +86,14 @@ lp_build_intrinsic_map(LLVMBuilderRef builder,
LLVMValueRef
lp_build_intrinsic_map_unary(LLVMBuilderRef builder,
lp_build_intrinsic_map_unary(struct gallivm_state *gallivm,
const char *name,
LLVMTypeRef ret_type,
LLVMValueRef a);
LLVMValueRef
lp_build_intrinsic_map_binary(LLVMBuilderRef builder,
lp_build_intrinsic_map_binary(struct gallivm_state *gallivm,
const char *name,
LLVMTypeRef ret_type,
LLVMValueRef a,

View File

@@ -39,6 +39,7 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_init.h"
#include "lp_bld_intr.h"
#include "lp_bld_debug.h"
#include "lp_bld_logic.h"
@@ -70,13 +71,14 @@
* The result values will be 0 for false or ~0 for true.
*/
LLVMValueRef
lp_build_compare(LLVMBuilderRef builder,
lp_build_compare(struct gallivm_state *gallivm,
const struct lp_type type,
unsigned func,
LLVMValueRef a,
LLVMValueRef b)
{
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef int_vec_type = lp_build_int_vec_type(gallivm, type);
LLVMValueRef zeros = LLVMConstNull(int_vec_type);
LLVMValueRef ones = LLVMConstAllOnes(int_vec_type);
LLVMValueRef cond;
@@ -115,7 +117,7 @@ lp_build_compare(LLVMBuilderRef builder,
if(type.width * type.length == 128) {
if(type.floating && util_cpu_caps.has_sse) {
/* float[4] comparison */
LLVMTypeRef vec_type = lp_build_vec_type(type);
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, type);
LLVMValueRef args[3];
unsigned cc;
boolean swap;
@@ -144,7 +146,7 @@ lp_build_compare(LLVMBuilderRef builder,
break;
default:
assert(0);
return lp_build_undef(type);
return lp_build_undef(gallivm, type);
}
if(swap) {
@@ -156,7 +158,7 @@ lp_build_compare(LLVMBuilderRef builder,
args[1] = b;
}
args[2] = LLVMConstInt(LLVMInt8Type(), cc, 0);
args[2] = LLVMConstInt(LLVMInt8TypeInContext(gallivm->context), cc, 0);
res = lp_build_intrinsic(builder,
"llvm.x86.sse.cmp.ps",
vec_type,
@@ -185,7 +187,7 @@ lp_build_compare(LLVMBuilderRef builder,
const char *pcmpgt;
LLVMValueRef args[2];
LLVMValueRef res;
LLVMTypeRef vec_type = lp_build_vec_type(type);
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, type);
switch (type.width) {
case 8:
@@ -202,14 +204,14 @@ lp_build_compare(LLVMBuilderRef builder,
break;
default:
assert(0);
return lp_build_undef(type);
return lp_build_undef(gallivm, type);
}
/* There are no unsigned comparison instructions. So flip the sign bit
* so that the results match.
*/
if (table[func].gt && !type.sign) {
LLVMValueRef msb = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1));
LLVMValueRef msb = lp_build_const_int_vec(gallivm, type, (unsigned long long)1 << (type.width - 1));
a = LLVMBuildXor(builder, a, msb, "");
b = LLVMBuildXor(builder, b, msb, "");
}
@@ -270,7 +272,7 @@ lp_build_compare(LLVMBuilderRef builder,
break;
default:
assert(0);
return lp_build_undef(type);
return lp_build_undef(gallivm, type);
}
#if HAVE_LLVM >= 0x0207
@@ -289,7 +291,7 @@ lp_build_compare(LLVMBuilderRef builder,
debug_printf("%s: warning: using slow element-wise float"
" vector comparison\n", __FUNCTION__);
for (i = 0; i < type.length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, i);
cond = LLVMBuildFCmp(builder, op,
LLVMBuildExtractElement(builder, a, index, ""),
LLVMBuildExtractElement(builder, b, index, ""),
@@ -326,7 +328,7 @@ lp_build_compare(LLVMBuilderRef builder,
break;
default:
assert(0);
return lp_build_undef(type);
return lp_build_undef(gallivm, type);
}
#if HAVE_LLVM >= 0x0207
@@ -348,7 +350,7 @@ lp_build_compare(LLVMBuilderRef builder,
}
for(i = 0; i < type.length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, i);
cond = LLVMBuildICmp(builder, op,
LLVMBuildExtractElement(builder, a, index, ""),
LLVMBuildExtractElement(builder, b, index, ""),
@@ -379,7 +381,7 @@ lp_build_cmp(struct lp_build_context *bld,
LLVMValueRef a,
LLVMValueRef b)
{
return lp_build_compare(bld->builder, bld->type, func, a, b);
return lp_build_compare(bld->gallivm, bld->type, func, a, b);
}
@@ -392,6 +394,7 @@ lp_build_select_bitwise(struct lp_build_context *bld,
LLVMValueRef a,
LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_type type = bld->type;
LLVMValueRef res;
@@ -403,25 +406,25 @@ lp_build_select_bitwise(struct lp_build_context *bld,
}
if(type.floating) {
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
b = LLVMBuildBitCast(bld->builder, b, int_vec_type, "");
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
a = LLVMBuildBitCast(builder, a, int_vec_type, "");
b = LLVMBuildBitCast(builder, b, int_vec_type, "");
}
a = LLVMBuildAnd(bld->builder, a, mask, "");
a = LLVMBuildAnd(builder, a, mask, "");
/* This often gets translated to PANDN, but sometimes the NOT is
* pre-computed and stored in another constant. The best strategy depends
* on available registers, so it is not a big deal -- hopefully LLVM does
* the right decision attending the rest of the program.
*/
b = LLVMBuildAnd(bld->builder, b, LLVMBuildNot(bld->builder, mask, ""), "");
b = LLVMBuildAnd(builder, b, LLVMBuildNot(builder, mask, ""), "");
res = LLVMBuildOr(bld->builder, a, b, "");
res = LLVMBuildOr(builder, a, b, "");
if(type.floating) {
LLVMTypeRef vec_type = lp_build_vec_type(type);
res = LLVMBuildBitCast(bld->builder, res, vec_type, "");
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
res = LLVMBuildBitCast(builder, res, vec_type, "");
}
return res;
@@ -440,6 +443,8 @@ lp_build_select(struct lp_build_context *bld,
LLVMValueRef a,
LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMContextRef lc = bld->gallivm->context;
struct lp_type type = bld->type;
LLVMValueRef res;
@@ -450,8 +455,8 @@ lp_build_select(struct lp_build_context *bld,
return a;
if (type.length == 1) {
mask = LLVMBuildTrunc(bld->builder, mask, LLVMInt1Type(), "");
res = LLVMBuildSelect(bld->builder, mask, a, b, "");
mask = LLVMBuildTrunc(builder, mask, LLVMInt1TypeInContext(lc), "");
res = LLVMBuildSelect(builder, mask, a, b, "");
}
else if (util_cpu_caps.has_sse4_1 &&
type.width * type.length == 128 &&
@@ -465,34 +470,34 @@ lp_build_select(struct lp_build_context *bld,
if (type.floating &&
type.width == 64) {
intrinsic = "llvm.x86.sse41.blendvpd";
arg_type = LLVMVectorType(LLVMDoubleType(), 2);
arg_type = LLVMVectorType(LLVMDoubleTypeInContext(lc), 2);
} else if (type.floating &&
type.width == 32) {
intrinsic = "llvm.x86.sse41.blendvps";
arg_type = LLVMVectorType(LLVMFloatType(), 4);
arg_type = LLVMVectorType(LLVMFloatTypeInContext(lc), 4);
} else {
intrinsic = "llvm.x86.sse41.pblendvb";
arg_type = LLVMVectorType(LLVMInt8Type(), 16);
arg_type = LLVMVectorType(LLVMInt8TypeInContext(lc), 16);
}
if (arg_type != bld->int_vec_type) {
mask = LLVMBuildBitCast(bld->builder, mask, arg_type, "");
mask = LLVMBuildBitCast(builder, mask, arg_type, "");
}
if (arg_type != bld->vec_type) {
a = LLVMBuildBitCast(bld->builder, a, arg_type, "");
b = LLVMBuildBitCast(bld->builder, b, arg_type, "");
a = LLVMBuildBitCast(builder, a, arg_type, "");
b = LLVMBuildBitCast(builder, b, arg_type, "");
}
args[0] = b;
args[1] = a;
args[2] = mask;
res = lp_build_intrinsic(bld->builder, intrinsic,
res = lp_build_intrinsic(builder, intrinsic,
arg_type, args, Elements(args));
if (arg_type != bld->vec_type) {
res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
}
else {
@@ -514,6 +519,7 @@ lp_build_select_aos(struct lp_build_context *bld,
LLVMValueRef a,
LLVMValueRef b)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const unsigned n = type.length;
unsigned i, j;
@@ -544,7 +550,7 @@ lp_build_select_aos(struct lp_build_context *bld,
/*
* Shuffle.
*/
LLVMTypeRef elem_type = LLVMInt32Type();
LLVMTypeRef elem_type = LLVMInt32TypeInContext(bld->gallivm->context);
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH];
for(j = 0; j < n; j += 4)
@@ -553,7 +559,7 @@ lp_build_select_aos(struct lp_build_context *bld,
(mask & (1 << i) ? 0 : n) + j + i,
0);
return LLVMBuildShuffleVector(bld->builder, a, b, LLVMConstVector(shuffles, n), "");
return LLVMBuildShuffleVector(builder, a, b, LLVMConstVector(shuffles, n), "");
}
else {
#if 0
@@ -567,9 +573,9 @@ lp_build_select_aos(struct lp_build_context *bld,
cond_vec[j + i] = LLVMConstInt(elem_type,
mask & (1 << i) ? 1 : 0, 0);
return LLVMBuildSelect(bld->builder, LLVMConstVector(cond_vec, n), a, b, "");
return LLVMBuildSelect(builder, LLVMConstVector(cond_vec, n), a, b, "");
#else
LLVMValueRef mask_vec = lp_build_const_mask_aos(type, mask);
LLVMValueRef mask_vec = lp_build_const_mask_aos(bld->gallivm, type, mask);
return lp_build_select(bld, mask_vec, a, b);
#endif
}

View File

@@ -47,7 +47,7 @@ struct lp_build_context;
LLVMValueRef
lp_build_compare(LLVMBuilderRef builder,
lp_build_compare(struct gallivm_state *gallivm,
const struct lp_type type,
unsigned func,
LLVMValueRef a,

View File

@@ -72,6 +72,7 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_init.h"
#include "lp_bld_intr.h"
#include "lp_bld_arit.h"
#include "lp_bld_pack.h"
@@ -81,7 +82,8 @@
* Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions.
*/
static LLVMValueRef
lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
lp_build_const_unpack_shuffle(struct gallivm_state *gallivm,
unsigned n, unsigned lo_hi)
{
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i, j;
@@ -92,8 +94,8 @@ lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
/* 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);
elems[i + 0] = lp_build_const_int32(gallivm, 0 + j);
elems[i + 1] = lp_build_const_int32(gallivm, n + j);
}
return LLVMConstVector(elems, n);
@@ -104,7 +106,7 @@ lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi)
* Build shuffle vectors that match PACKxx instructions.
*/
static LLVMValueRef
lp_build_const_pack_shuffle(unsigned n)
lp_build_const_pack_shuffle(struct gallivm_state *gallivm, unsigned n)
{
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
@@ -112,7 +114,7 @@ lp_build_const_pack_shuffle(unsigned n)
assert(n <= LP_MAX_VECTOR_LENGTH);
for(i = 0; i < n; ++i)
elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0);
elems[i] = lp_build_const_int32(gallivm, 2*i);
return LLVMConstVector(elems, n);
}
@@ -124,7 +126,7 @@ lp_build_const_pack_shuffle(unsigned n)
* Matches the PUNPCKLxx and PUNPCKHxx SSE instructions.
*/
LLVMValueRef
lp_build_interleave2(LLVMBuilderRef builder,
lp_build_interleave2(struct gallivm_state *gallivm,
struct lp_type type,
LLVMValueRef a,
LLVMValueRef b,
@@ -132,9 +134,9 @@ lp_build_interleave2(LLVMBuilderRef builder,
{
LLVMValueRef shuffle;
shuffle = lp_build_const_unpack_shuffle(type.length, lo_hi);
shuffle = lp_build_const_unpack_shuffle(gallivm, type.length, lo_hi);
return LLVMBuildShuffleVector(builder, a, b, shuffle, "");
return LLVMBuildShuffleVector(gallivm->builder, a, b, shuffle, "");
}
@@ -145,13 +147,14 @@ lp_build_interleave2(LLVMBuilderRef builder,
* values themselves.
*/
void
lp_build_unpack2(LLVMBuilderRef builder,
lp_build_unpack2(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef src,
LLVMValueRef *dst_lo,
LLVMValueRef *dst_hi)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef msb;
LLVMTypeRef dst_vec_type;
@@ -162,24 +165,24 @@ lp_build_unpack2(LLVMBuilderRef builder,
if(dst_type.sign && src_type.sign) {
/* Replicate the sign bit in the most significant bits */
msb = LLVMBuildAShr(builder, src, lp_build_const_int_vec(src_type, src_type.width - 1), "");
msb = LLVMBuildAShr(builder, src, lp_build_const_int_vec(gallivm, src_type, src_type.width - 1), "");
}
else
/* Most significant bits always zero */
msb = lp_build_zero(src_type);
msb = lp_build_zero(gallivm, src_type);
/* Interleave bits */
#ifdef PIPE_ARCH_LITTLE_ENDIAN
*dst_lo = lp_build_interleave2(builder, src_type, src, msb, 0);
*dst_hi = lp_build_interleave2(builder, src_type, src, msb, 1);
*dst_lo = lp_build_interleave2(gallivm, src_type, src, msb, 0);
*dst_hi = lp_build_interleave2(gallivm, 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);
*dst_lo = lp_build_interleave2(gallivm, src_type, msb, src, 0);
*dst_hi = lp_build_interleave2(gallivm, src_type, msb, src, 1);
#endif
/* Cast the result into the new type (twice as wide) */
dst_vec_type = lp_build_vec_type(dst_type);
dst_vec_type = lp_build_vec_type(gallivm, dst_type);
*dst_lo = LLVMBuildBitCast(builder, *dst_lo, dst_vec_type, "");
*dst_hi = LLVMBuildBitCast(builder, *dst_hi, dst_vec_type, "");
@@ -193,7 +196,7 @@ lp_build_unpack2(LLVMBuilderRef builder,
* values themselves.
*/
void
lp_build_unpack(LLVMBuilderRef builder,
lp_build_unpack(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef src,
@@ -218,7 +221,7 @@ lp_build_unpack(LLVMBuilderRef builder,
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]);
lp_build_unpack2(gallivm, src_type, tmp_type, dst[i], &dst[2*i + 0], &dst[2*i + 1]);
}
src_type = tmp_type;
@@ -247,16 +250,17 @@ lp_build_unpack(LLVMBuilderRef builder,
* lp_build_packs2 instead.
*/
LLVMValueRef
lp_build_pack2(LLVMBuilderRef builder,
lp_build_pack2(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef lo,
LLVMValueRef hi)
{
LLVMBuilderRef builder = gallivm->builder;
#if HAVE_LLVM < 0x0207
LLVMTypeRef src_vec_type = lp_build_vec_type(src_type);
LLVMTypeRef src_vec_type = lp_build_vec_type(gallivm, src_type);
#endif
LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type);
LLVMTypeRef dst_vec_type = lp_build_vec_type(gallivm, dst_type);
LLVMValueRef shuffle;
LLVMValueRef res = NULL;
@@ -318,7 +322,7 @@ lp_build_pack2(LLVMBuilderRef builder,
lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");
shuffle = lp_build_const_pack_shuffle(dst_type.length);
shuffle = lp_build_const_pack_shuffle(gallivm, dst_type.length);
res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, "");
@@ -334,7 +338,7 @@ lp_build_pack2(LLVMBuilderRef builder,
* destination type.
*/
LLVMValueRef
lp_build_packs2(LLVMBuilderRef builder,
lp_build_packs2(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef lo,
@@ -360,14 +364,14 @@ lp_build_packs2(LLVMBuilderRef builder,
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_const_int_vec(src_type, ((unsigned long long)1 << dst_bits) - 1);
lp_build_context_init(&bld, builder, src_type);
LLVMValueRef dst_max = lp_build_const_int_vec(gallivm, src_type, ((unsigned long long)1 << dst_bits) - 1);
lp_build_context_init(&bld, gallivm, 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);
return lp_build_pack2(gallivm, src_type, dst_type, lo, hi);
}
@@ -377,13 +381,13 @@ lp_build_packs2(LLVMBuilderRef builder,
* TODO: Handle saturation consistently.
*/
LLVMValueRef
lp_build_pack(LLVMBuilderRef builder,
lp_build_pack(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
boolean clamped,
const LLVMValueRef *src, unsigned num_srcs)
{
LLVMValueRef (*pack2)(LLVMBuilderRef builder,
LLVMValueRef (*pack2)(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef lo,
@@ -419,7 +423,8 @@ lp_build_pack(LLVMBuilderRef builder,
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]);
tmp[i] = pack2(gallivm, src_type, tmp_type,
tmp[2*i + 0], tmp[2*i + 1]);
src_type = tmp_type;
}
@@ -437,12 +442,13 @@ lp_build_pack(LLVMBuilderRef builder,
* intrinsics that do saturation.
*/
void
lp_build_resize(LLVMBuilderRef builder,
lp_build_resize(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
const LLVMValueRef *src, unsigned num_srcs,
LLVMValueRef *dst, unsigned num_dsts)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
unsigned i;
@@ -482,7 +488,7 @@ lp_build_resize(LLVMBuilderRef builder,
* Register width remains constant -- use vector packing intrinsics
*/
tmp[0] = lp_build_pack(builder, src_type, dst_type, TRUE, src, num_srcs);
tmp[0] = lp_build_pack(gallivm, src_type, dst_type, TRUE, src, num_srcs);
}
else {
/*
@@ -490,11 +496,11 @@ lp_build_resize(LLVMBuilderRef builder,
*/
assert(src_type.length == dst_type.length);
tmp[0] = lp_build_undef(dst_type);
tmp[0] = lp_build_undef(gallivm, dst_type);
for (i = 0; i < dst_type.length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, i);
LLVMValueRef val = LLVMBuildExtractElement(builder, src[0], index, "");
val = LLVMBuildTrunc(builder, val, lp_build_elem_type(dst_type), "");
val = LLVMBuildTrunc(builder, val, lp_build_elem_type(gallivm, dst_type), "");
tmp[0] = LLVMBuildInsertElement(builder, tmp[0], val, index, "");
}
}
@@ -510,7 +516,7 @@ lp_build_resize(LLVMBuilderRef builder,
/*
* Register width remains constant -- use vector unpack intrinsics
*/
lp_build_unpack(builder, src_type, dst_type, src[0], tmp, num_dsts);
lp_build_unpack(gallivm, src_type, dst_type, src[0], tmp, num_dsts);
}
else {
/*
@@ -518,15 +524,15 @@ lp_build_resize(LLVMBuilderRef builder,
*/
assert(src_type.length == dst_type.length);
tmp[0] = lp_build_undef(dst_type);
tmp[0] = lp_build_undef(gallivm, dst_type);
for (i = 0; i < dst_type.length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = lp_build_const_int32(gallivm, i);
LLVMValueRef val = LLVMBuildExtractElement(builder, src[0], index, "");
if (src_type.sign && dst_type.sign) {
val = LLVMBuildSExt(builder, val, lp_build_elem_type(dst_type), "");
val = LLVMBuildSExt(builder, val, lp_build_elem_type(gallivm, dst_type), "");
} else {
val = LLVMBuildZExt(builder, val, lp_build_elem_type(dst_type), "");
val = LLVMBuildZExt(builder, val, lp_build_elem_type(gallivm, dst_type), "");
}
tmp[0] = LLVMBuildInsertElement(builder, tmp[0], val, index, "");
}

View File

@@ -46,7 +46,7 @@ struct lp_type;
LLVMValueRef
lp_build_interleave2(LLVMBuilderRef builder,
lp_build_interleave2(struct gallivm_state *gallivm,
struct lp_type type,
LLVMValueRef a,
LLVMValueRef b,
@@ -54,7 +54,7 @@ lp_build_interleave2(LLVMBuilderRef builder,
void
lp_build_unpack2(LLVMBuilderRef builder,
lp_build_unpack2(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef src,
@@ -63,7 +63,7 @@ lp_build_unpack2(LLVMBuilderRef builder,
void
lp_build_unpack(LLVMBuilderRef builder,
lp_build_unpack(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef src,
@@ -71,7 +71,7 @@ lp_build_unpack(LLVMBuilderRef builder,
LLVMValueRef
lp_build_packs2(LLVMBuilderRef builder,
lp_build_packs2(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef lo,
@@ -79,7 +79,7 @@ lp_build_packs2(LLVMBuilderRef builder,
LLVMValueRef
lp_build_pack2(LLVMBuilderRef builder,
lp_build_pack2(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef lo,
@@ -87,7 +87,7 @@ lp_build_pack2(LLVMBuilderRef builder,
LLVMValueRef
lp_build_pack(LLVMBuilderRef builder,
lp_build_pack(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
boolean clamped,
@@ -95,7 +95,7 @@ lp_build_pack(LLVMBuilderRef builder,
void
lp_build_resize(LLVMBuilderRef builder,
lp_build_resize(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
const LLVMValueRef *src, unsigned num_srcs,

View File

@@ -31,6 +31,8 @@
#include "util/u_memory.h"
#include "util/u_string.h"
#include "lp_bld_const.h"
#include "lp_bld_init.h"
#include "lp_bld_const.h"
#include "lp_bld_printf.h"
@@ -65,12 +67,14 @@ lp_get_printf_arg_count(const char *fmt)
}
LLVMValueRef
lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len)
lp_build_const_string_variable(LLVMModuleRef module,
LLVMContextRef context,
const char *str, int len)
{
LLVMValueRef string = LLVMAddGlobal(module, LLVMArrayType(LLVMInt8Type(), len + 1), "");
LLVMValueRef string = LLVMAddGlobal(module, LLVMArrayType(LLVMInt8TypeInContext(context), len + 1), "");
LLVMSetGlobalConstant(string, TRUE);
LLVMSetLinkage(string, LLVMInternalLinkage);
LLVMSetInitializer(string, LLVMConstString(str, len + 1, TRUE));
LLVMSetInitializer(string, LLVMConstStringInContext(context, str, len + 1, TRUE));
return string;
}
@@ -83,15 +87,18 @@ lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len)
* LLVMValueRef.
*/
LLVMValueRef
lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...)
lp_build_printf(struct gallivm_state *gallivm, const char *fmt, ...)
{
va_list arglist;
int i = 0;
int argcount = lp_get_printf_arg_count(fmt);
LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
LLVMBuilderRef builder = gallivm->builder;
LLVMContextRef context = gallivm->context;
LLVMModuleRef module = gallivm->module;
LLVMValueRef params[50];
LLVMValueRef fmtarg = lp_build_const_string_variable(module, fmt, strlen(fmt) + 1);
LLVMValueRef int0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
LLVMValueRef fmtarg = lp_build_const_string_variable(module, context,
fmt, strlen(fmt) + 1);
LLVMValueRef int0 = lp_build_const_int32(gallivm, 0);
LLVMValueRef index[2];
LLVMValueRef func_printf = LLVMGetNamedFunction(module, "printf");
@@ -100,7 +107,7 @@ lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...)
index[0] = index[1] = int0;
if (!func_printf) {
LLVMTypeRef printf_type = LLVMFunctionType(LLVMIntType(32), NULL, 0, 1);
LLVMTypeRef printf_type = LLVMFunctionType(LLVMIntTypeInContext(context, 32), NULL, 0, 1);
func_printf = LLVMAddFunction(module, "printf", printf_type);
}
@@ -113,7 +120,7 @@ lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...)
/* printf wants doubles, so lets convert so that
* we can actually print them */
if (LLVMGetTypeKind(type) == LLVMFloatTypeKind)
val = LLVMBuildFPExt(builder, val, LLVMDoubleType(), "");
val = LLVMBuildFPExt(builder, val, LLVMDoubleTypeInContext(context), "");
params[i] = val;
}
va_end(arglist);
@@ -127,16 +134,18 @@ lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...)
* Print a float[4] vector.
*/
LLVMValueRef
lp_build_print_vec4(LLVMBuilderRef builder, const char *msg, LLVMValueRef vec)
lp_build_print_vec4(struct gallivm_state *gallivm,
const char *msg, LLVMValueRef vec)
{
LLVMBuilderRef builder = gallivm->builder;
char format[1000];
LLVMValueRef x, y, z, w;
x = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(0), "");
y = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(1), "");
z = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(2), "");
w = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(3), "");
x = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(gallivm, 0), "");
y = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(gallivm, 1), "");
z = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(gallivm, 2), "");
w = LLVMBuildExtractElement(builder, vec, lp_build_const_int32(gallivm, 3), "");
util_snprintf(format, sizeof(format), "%s %%f %%f %%f %%f\n", msg);
return lp_build_printf(builder, format, x, y, z, w);
return lp_build_printf(gallivm, format, x, y, z, w);
}

View File

@@ -31,12 +31,19 @@
#include "pipe/p_compiler.h"
#include "lp_bld.h"
#include "lp_bld_init.h"
LLVMValueRef lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len);
LLVMValueRef lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...);
LLVMValueRef lp_build_const_string_variable(LLVMModuleRef module,
LLVMContextRef context,
const char *str, int len);
LLVMValueRef lp_build_printf(struct gallivm_state *gallivm,
const char *fmt, ...);
LLVMValueRef
lp_build_print_vec4(LLVMBuilderRef builder, const char *msg, LLVMValueRef vec);
lp_build_print_vec4(struct gallivm_state *gallivm,
const char *msg, LLVMValueRef vec);
#endif

View File

@@ -28,6 +28,7 @@
#include "lp_bld_type.h"
#include "lp_bld_arit.h"
#include "lp_bld_const.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_quad.h"
@@ -81,15 +82,15 @@ LLVMValueRef
lp_build_scalar_ddx(struct lp_build_context *bld,
LLVMValueRef a)
{
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef idx_left = LLVMConstInt(i32t, LP_BLD_QUAD_TOP_LEFT, 0);
LLVMValueRef idx_right = LLVMConstInt(i32t, LP_BLD_QUAD_TOP_RIGHT, 0);
LLVMValueRef a_left = LLVMBuildExtractElement(bld->builder, a, idx_left, "left");
LLVMValueRef a_right = LLVMBuildExtractElement(bld->builder, a, idx_right, "right");
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef idx_left = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_TOP_LEFT);
LLVMValueRef idx_right = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_TOP_RIGHT);
LLVMValueRef a_left = LLVMBuildExtractElement(builder, a, idx_left, "left");
LLVMValueRef a_right = LLVMBuildExtractElement(builder, a, idx_right, "right");
if (bld->type.floating)
return LLVMBuildFSub(bld->builder, a_right, a_left, "ddx");
return LLVMBuildFSub(builder, a_right, a_left, "ddx");
else
return LLVMBuildSub(bld->builder, a_right, a_left, "ddx");
return LLVMBuildSub(builder, a_right, a_left, "ddx");
}
@@ -97,13 +98,13 @@ LLVMValueRef
lp_build_scalar_ddy(struct lp_build_context *bld,
LLVMValueRef a)
{
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef idx_top = LLVMConstInt(i32t, LP_BLD_QUAD_TOP_LEFT, 0);
LLVMValueRef idx_bottom = LLVMConstInt(i32t, LP_BLD_QUAD_BOTTOM_LEFT, 0);
LLVMValueRef a_top = LLVMBuildExtractElement(bld->builder, a, idx_top, "top");
LLVMValueRef a_bottom = LLVMBuildExtractElement(bld->builder, a, idx_bottom, "bottom");
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef idx_top = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_TOP_LEFT);
LLVMValueRef idx_bottom = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_BOTTOM_LEFT);
LLVMValueRef a_top = LLVMBuildExtractElement(builder, a, idx_top, "top");
LLVMValueRef a_bottom = LLVMBuildExtractElement(builder, a, idx_bottom, "bottom");
if (bld->type.floating)
return LLVMBuildFSub(bld->builder, a_bottom, a_top, "ddy");
return LLVMBuildFSub(builder, a_bottom, a_top, "ddy");
else
return LLVMBuildSub(bld->builder, a_bottom, a_top, "ddy");
return LLVMBuildSub(builder, a_bottom, a_top, "ddy");
}

View File

@@ -134,7 +134,7 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
state->min_img_filter = sampler->min_img_filter;
state->mag_img_filter = sampler->mag_img_filter;
if (view->last_level && sampler->max_lod > 0.0f) {
if (view->u.tex.last_level && sampler->max_lod > 0.0f) {
state->min_mip_filter = sampler->min_mip_filter;
} else {
state->min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
@@ -155,7 +155,7 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
state->apply_min_lod = 1;
}
if (sampler->max_lod < (float)view->last_level) {
if (sampler->max_lod < (float)view->u.tex.last_level) {
state->apply_max_lod = 1;
}
}
@@ -190,7 +190,8 @@ lp_build_rho(struct lp_build_sample_context *bld,
struct lp_build_context *float_size_bld = &bld->float_size_bld;
struct lp_build_context *float_bld = &bld->float_bld;
const unsigned dims = bld->dims;
LLVMTypeRef i32t = LLVMInt32Type();
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMTypeRef i32t = LLVMInt32TypeInContext(bld->gallivm->context);
LLVMValueRef index0 = LLVMConstInt(i32t, 0, 0);
LLVMValueRef index1 = LLVMConstInt(i32t, 1, 0);
LLVMValueRef index2 = LLVMConstInt(i32t, 2, 0);
@@ -211,21 +212,21 @@ lp_build_rho(struct lp_build_sample_context *bld,
rho_x = float_size_bld->undef;
rho_y = float_size_bld->undef;
rho_x = LLVMBuildInsertElement(bld->builder, rho_x, dsdx, index0, "");
rho_y = LLVMBuildInsertElement(bld->builder, rho_y, dsdy, index0, "");
rho_x = LLVMBuildInsertElement(builder, rho_x, dsdx, index0, "");
rho_y = LLVMBuildInsertElement(builder, rho_y, dsdy, index0, "");
dtdx = ddx[1];
dtdy = ddy[1];
rho_x = LLVMBuildInsertElement(bld->builder, rho_x, dtdx, index1, "");
rho_y = LLVMBuildInsertElement(bld->builder, rho_y, dtdy, index1, "");
rho_x = LLVMBuildInsertElement(builder, rho_x, dtdx, index1, "");
rho_y = LLVMBuildInsertElement(builder, rho_y, dtdy, index1, "");
if (dims >= 3) {
drdx = ddx[2];
drdy = ddy[2];
rho_x = LLVMBuildInsertElement(bld->builder, rho_x, drdx, index2, "");
rho_y = LLVMBuildInsertElement(bld->builder, rho_y, drdy, index2, "");
rho_x = LLVMBuildInsertElement(builder, rho_x, drdx, index2, "");
rho_y = LLVMBuildInsertElement(builder, rho_y, drdy, index2, "");
}
}
@@ -245,13 +246,13 @@ lp_build_rho(struct lp_build_sample_context *bld,
if (dims >= 2) {
LLVMValueRef rho_s, rho_t, rho_r;
rho_s = LLVMBuildExtractElement(bld->builder, rho_vec, index0, "");
rho_t = LLVMBuildExtractElement(bld->builder, rho_vec, index1, "");
rho_s = LLVMBuildExtractElement(builder, rho_vec, index0, "");
rho_t = LLVMBuildExtractElement(builder, rho_vec, index1, "");
rho = lp_build_max(float_bld, rho_s, rho_t);
if (dims >= 3) {
rho_r = LLVMBuildExtractElement(bld->builder, rho_vec, index0, "");
rho_r = LLVMBuildExtractElement(builder, rho_vec, index0, "");
rho = lp_build_max(float_bld, rho, rho_r);
}
}
@@ -304,19 +305,19 @@ lp_build_brilinear_lod(struct lp_build_context *bld,
double post_offset = 1 - factor;
if (0) {
lp_build_printf(bld->builder, "lod = %f\n", lod);
lp_build_printf(bld->gallivm, "lod = %f\n", lod);
}
lod = lp_build_add(bld, lod,
lp_build_const_vec(bld->type, pre_offset));
lp_build_const_vec(bld->gallivm, bld->type, pre_offset));
lp_build_ifloor_fract(bld, lod, out_lod_ipart, &lod_fpart);
lod_fpart = lp_build_mul(bld, lod_fpart,
lp_build_const_vec(bld->type, factor));
lp_build_const_vec(bld->gallivm, bld->type, factor));
lod_fpart = lp_build_add(bld, lod_fpart,
lp_build_const_vec(bld->type, post_offset));
lp_build_const_vec(bld->gallivm, bld->type, post_offset));
/*
* It's not necessary to clamp lod_fpart since:
@@ -327,8 +328,8 @@ lp_build_brilinear_lod(struct lp_build_context *bld,
*out_lod_fpart = lod_fpart;
if (0) {
lp_build_printf(bld->builder, "lod_ipart = %i\n", *out_lod_ipart);
lp_build_printf(bld->builder, "lod_fpart = %f\n\n", *out_lod_fpart);
lp_build_printf(bld->gallivm, "lod_ipart = %i\n", *out_lod_ipart);
lp_build_printf(bld->gallivm, "lod_fpart = %f\n\n", *out_lod_fpart);
}
}
@@ -363,7 +364,7 @@ lp_build_brilinear_rho(struct lp_build_context *bld,
* part will not need any post adjustments.
*/
rho = lp_build_mul(bld, rho,
lp_build_const_vec(bld->type, pre_factor));
lp_build_const_vec(bld->gallivm, bld->type, pre_factor));
/* ipart = ifloor(log2(rho)) */
lod_ipart = lp_build_extract_exponent(bld, rho, 0);
@@ -372,10 +373,10 @@ lp_build_brilinear_rho(struct lp_build_context *bld,
lod_fpart = lp_build_extract_mantissa(bld, rho);
lod_fpart = lp_build_mul(bld, lod_fpart,
lp_build_const_vec(bld->type, factor));
lp_build_const_vec(bld->gallivm, bld->type, factor));
lod_fpart = lp_build_add(bld, lod_fpart,
lp_build_const_vec(bld->type, post_offset));
lp_build_const_vec(bld->gallivm, bld->type, post_offset));
/*
* Like lp_build_brilinear_lod, it's not necessary to clamp lod_fpart since:
@@ -413,6 +414,7 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
LLVMValueRef *out_lod_fpart)
{
LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_build_context *float_bld = &bld->float_bld;
LLVMValueRef lod;
@@ -424,17 +426,17 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
* This is hit during mipmap generation.
*/
LLVMValueRef min_lod =
bld->dynamic_state->min_lod(bld->dynamic_state, bld->builder, unit);
bld->dynamic_state->min_lod(bld->dynamic_state, bld->gallivm, unit);
lod = min_lod;
}
else {
LLVMValueRef sampler_lod_bias =
bld->dynamic_state->lod_bias(bld->dynamic_state, bld->builder, unit);
LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
bld->dynamic_state->lod_bias(bld->dynamic_state, bld->gallivm, unit);
LLVMValueRef index0 = lp_build_const_int32(bld->gallivm, 0);
if (explicit_lod) {
lod = LLVMBuildExtractElement(bld->builder, explicit_lod,
lod = LLVMBuildExtractElement(builder, explicit_lod,
index0, "");
}
else {
@@ -479,27 +481,27 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
/* add shader lod bias */
if (lod_bias) {
lod_bias = LLVMBuildExtractElement(bld->builder, lod_bias,
lod_bias = LLVMBuildExtractElement(builder, lod_bias,
index0, "");
lod = LLVMBuildFAdd(bld->builder, lod, lod_bias, "shader_lod_bias");
lod = LLVMBuildFAdd(builder, lod, lod_bias, "shader_lod_bias");
}
}
/* add sampler lod bias */
if (bld->static_state->lod_bias_non_zero)
lod = LLVMBuildFAdd(bld->builder, lod, sampler_lod_bias, "sampler_lod_bias");
lod = LLVMBuildFAdd(builder, lod, sampler_lod_bias, "sampler_lod_bias");
/* clamp lod */
if (bld->static_state->apply_max_lod) {
LLVMValueRef max_lod =
bld->dynamic_state->max_lod(bld->dynamic_state, bld->builder, unit);
bld->dynamic_state->max_lod(bld->dynamic_state, bld->gallivm, unit);
lod = lp_build_min(float_bld, lod, max_lod);
}
if (bld->static_state->apply_min_lod) {
LLVMValueRef min_lod =
bld->dynamic_state->min_lod(bld->dynamic_state, bld->builder, unit);
bld->dynamic_state->min_lod(bld->dynamic_state, bld->gallivm, unit);
lod = lp_build_max(float_bld, lod, min_lod);
}
@@ -542,10 +544,10 @@ lp_build_nearest_mip_level(struct lp_build_sample_context *bld,
struct lp_build_context *int_bld = &bld->int_bld;
LLVMValueRef last_level, level;
LLVMValueRef zero = LLVMConstInt(LLVMInt32Type(), 0, 0);
LLVMValueRef zero = lp_build_const_int32(bld->gallivm, 0);
last_level = bld->dynamic_state->last_level(bld->dynamic_state,
bld->builder, unit);
bld->gallivm, unit);
/* convert float lod to integer */
level = lod_ipart;
@@ -568,7 +570,7 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
LLVMValueRef *level0_out,
LLVMValueRef *level1_out)
{
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_build_context *int_bld = &bld->int_bld;
struct lp_build_context *float_bld = &bld->float_bld;
LLVMValueRef last_level;
@@ -579,7 +581,7 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
*level1_out = lp_build_add(int_bld, lod_ipart, int_bld->one);
last_level = bld->dynamic_state->last_level(bld->dynamic_state,
bld->builder, unit);
bld->gallivm, unit);
/*
* Clamp both lod_ipart and lod_ipart + 1 to [0, last_level], with the
@@ -630,11 +632,13 @@ LLVMValueRef
lp_build_get_mipmap_level(struct lp_build_sample_context *bld,
LLVMValueRef level)
{
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef indexes[2], data_ptr;
indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indexes[0] = lp_build_const_int32(bld->gallivm, 0);
indexes[1] = level;
data_ptr = LLVMBuildGEP(bld->builder, bld->data_array, indexes, 2, "");
data_ptr = LLVMBuildLoad(bld->builder, data_ptr, "");
data_ptr = LLVMBuildGEP(builder, bld->data_array, indexes, 2, "");
data_ptr = LLVMBuildLoad(builder, data_ptr, "");
return data_ptr;
}
@@ -643,7 +647,7 @@ LLVMValueRef
lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld,
int level)
{
LLVMValueRef lvl = LLVMConstInt(LLVMInt32Type(), level, 0);
LLVMValueRef lvl = lp_build_const_int32(bld->gallivm, level);
return lp_build_get_mipmap_level(bld, lvl);
}
@@ -657,6 +661,7 @@ lp_build_minify(struct lp_build_context *bld,
LLVMValueRef base_size,
LLVMValueRef level)
{
LLVMBuilderRef builder = bld->gallivm->builder;
assert(lp_check_value(bld->type, base_size));
assert(lp_check_value(bld->type, level));
@@ -666,7 +671,7 @@ lp_build_minify(struct lp_build_context *bld,
}
else {
LLVMValueRef size =
LLVMBuildLShr(bld->builder, base_size, level, "minify");
LLVMBuildLShr(builder, base_size, level, "minify");
assert(bld->type.sign);
size = lp_build_max(bld, size, bld->one);
return size;
@@ -682,11 +687,12 @@ static LLVMValueRef
lp_build_get_level_stride_vec(struct lp_build_sample_context *bld,
LLVMValueRef stride_array, LLVMValueRef level)
{
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef indexes[2], stride;
indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indexes[0] = lp_build_const_int32(bld->gallivm, 0);
indexes[1] = level;
stride = LLVMBuildGEP(bld->builder, stride_array, indexes, 2, "");
stride = LLVMBuildLoad(bld->builder, stride, "");
stride = LLVMBuildGEP(builder, stride_array, indexes, 2, "");
stride = LLVMBuildLoad(builder, stride, "");
stride = lp_build_broadcast_scalar(&bld->int_coord_bld, stride);
return stride;
}
@@ -747,21 +753,21 @@ lp_build_extract_image_sizes(struct lp_build_sample_context *bld,
LLVMValueRef *out_depth)
{
const unsigned dims = bld->dims;
LLVMTypeRef i32t = LLVMInt32Type();
LLVMTypeRef i32t = LLVMInt32TypeInContext(bld->gallivm->context);
*out_width = lp_build_extract_broadcast(bld->builder,
*out_width = lp_build_extract_broadcast(bld->gallivm,
size_type,
coord_type,
size,
LLVMConstInt(i32t, 0, 0));
if (dims >= 2) {
*out_height = lp_build_extract_broadcast(bld->builder,
*out_height = lp_build_extract_broadcast(bld->gallivm,
size_type,
coord_type,
size,
LLVMConstInt(i32t, 1, 0));
if (dims == 3) {
*out_depth = lp_build_extract_broadcast(bld->builder,
*out_depth = lp_build_extract_broadcast(bld->gallivm,
size_type,
coord_type,
size,
@@ -812,7 +818,7 @@ static LLVMValueRef
lp_build_cube_ima(struct lp_build_context *coord_bld, LLVMValueRef coord)
{
/* ima = -0.5 / abs(coord); */
LLVMValueRef negHalf = lp_build_const_vec(coord_bld->type, -0.5);
LLVMValueRef negHalf = lp_build_const_vec(coord_bld->gallivm, coord_bld->type, -0.5);
LLVMValueRef absCoord = lp_build_abs(coord_bld, coord);
LLVMValueRef ima = lp_build_div(coord_bld, negHalf, absCoord);
return ima;
@@ -831,7 +837,7 @@ lp_build_cube_coord(struct lp_build_context *coord_bld,
LLVMValueRef coord, LLVMValueRef ima)
{
/* return negate(coord) * ima * sign + 0.5; */
LLVMValueRef half = lp_build_const_vec(coord_bld->type, 0.5);
LLVMValueRef half = lp_build_const_vec(coord_bld->gallivm, coord_bld->type, 0.5);
LLVMValueRef res;
assert(negate_coord == +1 || negate_coord == -1);
@@ -859,12 +865,14 @@ lp_build_cube_face(struct lp_build_sample_context *bld,
LLVMValueRef major_coord,
unsigned pos_face, unsigned neg_face)
{
LLVMValueRef cmp = LLVMBuildFCmp(bld->builder, LLVMRealUGE,
struct gallivm_state *gallivm = bld->gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef cmp = LLVMBuildFCmp(builder, LLVMRealUGE,
major_coord,
bld->float_bld.zero, "");
LLVMValueRef pos = LLVMConstInt(LLVMInt32Type(), pos_face, 0);
LLVMValueRef neg = LLVMConstInt(LLVMInt32Type(), neg_face, 0);
LLVMValueRef res = LLVMBuildSelect(bld->builder, cmp, pos, neg, "");
LLVMValueRef pos = lp_build_const_int32(gallivm, pos_face);
LLVMValueRef neg = lp_build_const_int32(gallivm, neg_face);
LLVMValueRef res = LLVMBuildSelect(builder, cmp, pos, neg, "");
return res;
}
@@ -884,9 +892,10 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
{
struct lp_build_context *float_bld = &bld->float_bld;
struct lp_build_context *coord_bld = &bld->coord_bld;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef rx, ry, rz;
LLVMValueRef arx, ary, arz;
LLVMValueRef c25 = LLVMConstReal(LLVMFloatType(), 0.25);
LLVMValueRef c25 = lp_build_const_float(bld->gallivm, 0.25);
LLVMValueRef arx_ge_ary, arx_ge_arz;
LLVMValueRef ary_ge_arx, ary_ge_arz;
LLVMValueRef arx_ge_ary_arz, ary_ge_arx_arz;
@@ -911,17 +920,17 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
/*
* Compare sign/magnitude of rx,ry,rz to determine face
*/
arx_ge_ary = LLVMBuildFCmp(bld->builder, LLVMRealUGE, arx, ary, "");
arx_ge_arz = LLVMBuildFCmp(bld->builder, LLVMRealUGE, arx, arz, "");
ary_ge_arx = LLVMBuildFCmp(bld->builder, LLVMRealUGE, ary, arx, "");
ary_ge_arz = LLVMBuildFCmp(bld->builder, LLVMRealUGE, ary, arz, "");
arx_ge_ary = LLVMBuildFCmp(builder, LLVMRealUGE, arx, ary, "");
arx_ge_arz = LLVMBuildFCmp(builder, LLVMRealUGE, arx, arz, "");
ary_ge_arx = LLVMBuildFCmp(builder, LLVMRealUGE, ary, arx, "");
ary_ge_arz = LLVMBuildFCmp(builder, LLVMRealUGE, ary, arz, "");
arx_ge_ary_arz = LLVMBuildAnd(bld->builder, arx_ge_ary, arx_ge_arz, "");
ary_ge_arx_arz = LLVMBuildAnd(bld->builder, ary_ge_arx, ary_ge_arz, "");
arx_ge_ary_arz = LLVMBuildAnd(builder, arx_ge_ary, arx_ge_arz, "");
ary_ge_arx_arz = LLVMBuildAnd(builder, ary_ge_arx, ary_ge_arz, "");
rx_pos = LLVMBuildFCmp(bld->builder, LLVMRealUGE, rx, float_bld->zero, "");
ry_pos = LLVMBuildFCmp(bld->builder, LLVMRealUGE, ry, float_bld->zero, "");
rz_pos = LLVMBuildFCmp(bld->builder, LLVMRealUGE, rz, float_bld->zero, "");
rx_pos = LLVMBuildFCmp(builder, LLVMRealUGE, rx, float_bld->zero, "");
ry_pos = LLVMBuildFCmp(builder, LLVMRealUGE, ry, float_bld->zero, "");
rz_pos = LLVMBuildFCmp(builder, LLVMRealUGE, rz, float_bld->zero, "");
{
struct lp_build_if_state if_ctx;
@@ -929,11 +938,11 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
LLVMValueRef face_t_var;
LLVMValueRef face_var;
face_s_var = lp_build_alloca(bld->builder, bld->coord_bld.vec_type, "face_s_var");
face_t_var = lp_build_alloca(bld->builder, bld->coord_bld.vec_type, "face_t_var");
face_var = lp_build_alloca(bld->builder, bld->int_bld.vec_type, "face_var");
face_s_var = lp_build_alloca(bld->gallivm, bld->coord_bld.vec_type, "face_s_var");
face_t_var = lp_build_alloca(bld->gallivm, bld->coord_bld.vec_type, "face_t_var");
face_var = lp_build_alloca(bld->gallivm, bld->int_bld.vec_type, "face_var");
lp_build_if(&if_ctx, bld->builder, arx_ge_ary_arz);
lp_build_if(&if_ctx, bld->gallivm, arx_ge_ary_arz);
{
/* +/- X face */
LLVMValueRef sign = lp_build_sgn(float_bld, rx);
@@ -943,17 +952,17 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
*face = lp_build_cube_face(bld, rx,
PIPE_TEX_FACE_POS_X,
PIPE_TEX_FACE_NEG_X);
LLVMBuildStore(bld->builder, *face_s, face_s_var);
LLVMBuildStore(bld->builder, *face_t, face_t_var);
LLVMBuildStore(bld->builder, *face, face_var);
LLVMBuildStore(builder, *face_s, face_s_var);
LLVMBuildStore(builder, *face_t, face_t_var);
LLVMBuildStore(builder, *face, face_var);
}
lp_build_else(&if_ctx);
{
struct lp_build_if_state if_ctx2;
ary_ge_arx_arz = LLVMBuildAnd(bld->builder, ary_ge_arx, ary_ge_arz, "");
ary_ge_arx_arz = LLVMBuildAnd(builder, ary_ge_arx, ary_ge_arz, "");
lp_build_if(&if_ctx2, bld->builder, ary_ge_arx_arz);
lp_build_if(&if_ctx2, bld->gallivm, ary_ge_arx_arz);
{
/* +/- Y face */
LLVMValueRef sign = lp_build_sgn(float_bld, ry);
@@ -963,9 +972,9 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
*face = lp_build_cube_face(bld, ry,
PIPE_TEX_FACE_POS_Y,
PIPE_TEX_FACE_NEG_Y);
LLVMBuildStore(bld->builder, *face_s, face_s_var);
LLVMBuildStore(bld->builder, *face_t, face_t_var);
LLVMBuildStore(bld->builder, *face, face_var);
LLVMBuildStore(builder, *face_s, face_s_var);
LLVMBuildStore(builder, *face_t, face_t_var);
LLVMBuildStore(builder, *face, face_var);
}
lp_build_else(&if_ctx2);
{
@@ -977,18 +986,18 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
*face = lp_build_cube_face(bld, rz,
PIPE_TEX_FACE_POS_Z,
PIPE_TEX_FACE_NEG_Z);
LLVMBuildStore(bld->builder, *face_s, face_s_var);
LLVMBuildStore(bld->builder, *face_t, face_t_var);
LLVMBuildStore(bld->builder, *face, face_var);
LLVMBuildStore(builder, *face_s, face_s_var);
LLVMBuildStore(builder, *face_t, face_t_var);
LLVMBuildStore(builder, *face, face_var);
}
lp_build_endif(&if_ctx2);
}
lp_build_endif(&if_ctx);
*face_s = LLVMBuildLoad(bld->builder, face_s_var, "face_s");
*face_t = LLVMBuildLoad(bld->builder, face_t_var, "face_t");
*face = LLVMBuildLoad(bld->builder, face_var, "face");
*face_s = LLVMBuildLoad(builder, face_s_var, "face_s");
*face_t = LLVMBuildLoad(builder, face_t_var, "face_t");
*face = LLVMBuildLoad(builder, face_var, "face");
}
}
@@ -1011,6 +1020,7 @@ lp_build_sample_partial_offset(struct lp_build_context *bld,
LLVMValueRef *out_offset,
LLVMValueRef *out_subcoord)
{
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef offset;
LLVMValueRef subcoord;
@@ -1028,14 +1038,14 @@ lp_build_sample_partial_offset(struct lp_build_context *bld,
*/
#if 0
LLVMValueRef block_width = lp_build_const_int_vec(bld->type, block_length);
subcoord = LLVMBuildURem(bld->builder, coord, block_width, "");
coord = LLVMBuildUDiv(bld->builder, coord, block_width, "");
subcoord = LLVMBuildURem(builder, coord, block_width, "");
coord = LLVMBuildUDiv(builder, coord, block_width, "");
#else
unsigned logbase2 = util_unsigned_logbase2(block_length);
LLVMValueRef block_shift = lp_build_const_int_vec(bld->type, logbase2);
LLVMValueRef block_mask = lp_build_const_int_vec(bld->type, block_length - 1);
subcoord = LLVMBuildAnd(bld->builder, coord, block_mask, "");
coord = LLVMBuildLShr(bld->builder, coord, block_shift, "");
LLVMValueRef block_shift = lp_build_const_int_vec(bld->gallivm, bld->type, logbase2);
LLVMValueRef block_mask = lp_build_const_int_vec(bld->gallivm, bld->type, block_length - 1);
subcoord = LLVMBuildAnd(builder, coord, block_mask, "");
coord = LLVMBuildLShr(builder, coord, block_shift, "");
#endif
}
@@ -1071,7 +1081,8 @@ lp_build_sample_offset(struct lp_build_context *bld,
LLVMValueRef x_stride;
LLVMValueRef offset;
x_stride = lp_build_const_vec(bld->type, format_desc->block.bits/8);
x_stride = lp_build_const_vec(bld->gallivm, bld->type,
format_desc->block.bits/8);
lp_build_sample_partial_offset(bld,
format_desc->block.width,

View File

@@ -105,64 +105,64 @@ struct lp_sampler_dynamic_state
/** Obtain the base texture width (returns int32) */
LLVMValueRef
(*width)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain the base texture height (returns int32) */
LLVMValueRef
(*height)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain the base texture depth (returns int32) */
LLVMValueRef
(*depth)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain the number of mipmap levels minus one (returns int32) */
LLVMValueRef
(*last_level)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain stride in bytes between image rows/blocks (returns int32) */
LLVMValueRef
(*row_stride)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain stride in bytes between image slices (returns int32) */
LLVMValueRef
(*img_stride)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain pointer to array of pointers to mimpap levels */
LLVMValueRef
(*data_ptr)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
unsigned unit);
/** Obtain texture min lod (returns float) */
LLVMValueRef
(*min_lod)(const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder, unsigned unit);
struct gallivm_state *gallivm, unsigned unit);
/** Obtain texture max lod (returns float) */
LLVMValueRef
(*max_lod)(const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder, unsigned unit);
struct gallivm_state *gallivm, unsigned unit);
/** Obtain texture lod bias (returns float) */
LLVMValueRef
(*lod_bias)(const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder, unsigned unit);
struct gallivm_state *gallivm, unsigned unit);
/** Obtain texture border color (returns ptr to float[4]) */
LLVMValueRef
(*border_color)(const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder, unsigned unit);
struct gallivm_state *gallivm, unsigned unit);
};
@@ -171,7 +171,7 @@ struct lp_sampler_dynamic_state
*/
struct lp_build_sample_context
{
LLVMBuilderRef builder;
struct gallivm_state *gallivm;
const struct lp_sampler_static_state *static_state;
@@ -385,7 +385,7 @@ lp_build_sample_offset(struct lp_build_context *bld,
void
lp_build_sample_soa(LLVMBuilderRef builder,
lp_build_sample_soa(struct gallivm_state *gallivm,
const struct lp_sampler_static_state *static_state,
struct lp_sampler_dynamic_state *dynamic_state,
struct lp_type fp_type,
@@ -399,7 +399,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
LLVMValueRef texel_out[4]);
void
lp_build_sample_nop(struct lp_type type,
lp_build_sample_nop(struct gallivm_state *gallivm, struct lp_type type,
LLVMValueRef texel_out[4]);

View File

@@ -52,6 +52,7 @@
#include "lp_bld_flow.h"
#include "lp_bld_gather.h"
#include "lp_bld_format.h"
#include "lp_bld_init.h"
#include "lp_bld_sample.h"
#include "lp_bld_sample_aos.h"
#include "lp_bld_quad.h"
@@ -82,6 +83,7 @@ lp_build_sample_wrap_nearest_int(struct lp_build_sample_context *bld,
LLVMValueRef *out_i)
{
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef length_minus_one;
length_minus_one = lp_build_sub(int_coord_bld, length, int_coord_bld->one);
@@ -89,12 +91,12 @@ lp_build_sample_wrap_nearest_int(struct lp_build_sample_context *bld,
switch(wrap_mode) {
case PIPE_TEX_WRAP_REPEAT:
if(is_pot)
coord = LLVMBuildAnd(bld->builder, coord, length_minus_one, "");
coord = LLVMBuildAnd(builder, coord, length_minus_one, "");
else {
/* Add a bias to the texcoord to handle negative coords */
LLVMValueRef bias = lp_build_mul_imm(int_coord_bld, length, 1024);
coord = LLVMBuildAdd(bld->builder, coord, bias, "");
coord = LLVMBuildURem(bld->builder, coord, length, "");
coord = LLVMBuildAdd(builder, coord, bias, "");
coord = LLVMBuildURem(builder, coord, length, "");
}
break;
@@ -147,6 +149,7 @@ lp_build_sample_wrap_linear_int(struct lp_build_sample_context *bld,
LLVMValueRef *i1)
{
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef length_minus_one;
LLVMValueRef lmask, umask, mask;
@@ -195,39 +198,39 @@ lp_build_sample_wrap_linear_int(struct lp_build_sample_context *bld,
switch(wrap_mode) {
case PIPE_TEX_WRAP_REPEAT:
if (is_pot) {
coord0 = LLVMBuildAnd(bld->builder, coord0, length_minus_one, "");
coord0 = LLVMBuildAnd(builder, coord0, length_minus_one, "");
}
else {
/* Add a bias to the texcoord to handle negative coords */
LLVMValueRef bias = lp_build_mul_imm(int_coord_bld, length, 1024);
coord0 = LLVMBuildAdd(bld->builder, coord0, bias, "");
coord0 = LLVMBuildURem(bld->builder, coord0, length, "");
coord0 = LLVMBuildAdd(builder, coord0, bias, "");
coord0 = LLVMBuildURem(builder, coord0, length, "");
}
mask = lp_build_compare(bld->builder, int_coord_bld->type,
mask = lp_build_compare(bld->gallivm, int_coord_bld->type,
PIPE_FUNC_NOTEQUAL, coord0, length_minus_one);
*offset0 = lp_build_mul(int_coord_bld, coord0, stride);
*offset1 = LLVMBuildAnd(bld->builder,
*offset1 = LLVMBuildAnd(builder,
lp_build_add(int_coord_bld, *offset0, stride),
mask, "");
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
lmask = lp_build_compare(int_coord_bld->builder, int_coord_bld->type,
lmask = lp_build_compare(int_coord_bld->gallivm, int_coord_bld->type,
PIPE_FUNC_GEQUAL, coord0, int_coord_bld->zero);
umask = lp_build_compare(int_coord_bld->builder, int_coord_bld->type,
umask = lp_build_compare(int_coord_bld->gallivm, int_coord_bld->type,
PIPE_FUNC_LESS, coord0, length_minus_one);
coord0 = lp_build_select(int_coord_bld, lmask, coord0, int_coord_bld->zero);
coord0 = lp_build_select(int_coord_bld, umask, coord0, length_minus_one);
mask = LLVMBuildAnd(bld->builder, lmask, umask, "");
mask = LLVMBuildAnd(builder, lmask, umask, "");
*offset0 = lp_build_mul(int_coord_bld, coord0, stride);
*offset1 = lp_build_add(int_coord_bld,
*offset0,
LLVMBuildAnd(bld->builder, stride, mask, ""));
LLVMBuildAnd(builder, stride, mask, ""));
break;
case PIPE_TEX_WRAP_CLAMP:
@@ -263,7 +266,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
LLVMValueRef *colors_hi)
{
const unsigned dims = bld->dims;
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_build_context i32, h16, u8n;
LLVMTypeRef i32_vec_type, h16_vec_type, u8n_vec_type;
LLVMValueRef i32_c8;
@@ -273,13 +276,13 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
LLVMValueRef x_offset, offset;
LLVMValueRef x_subcoord, y_subcoord, z_subcoord;
lp_build_context_init(&i32, builder, lp_type_int_vec(32));
lp_build_context_init(&h16, builder, lp_type_ufixed(16));
lp_build_context_init(&u8n, builder, lp_type_unorm(8));
lp_build_context_init(&i32, bld->gallivm, lp_type_int_vec(32));
lp_build_context_init(&h16, bld->gallivm, lp_type_ufixed(16));
lp_build_context_init(&u8n, bld->gallivm, lp_type_unorm(8));
i32_vec_type = lp_build_vec_type(i32.type);
h16_vec_type = lp_build_vec_type(h16.type);
u8n_vec_type = lp_build_vec_type(u8n.type);
i32_vec_type = lp_build_vec_type(bld->gallivm, i32.type);
h16_vec_type = lp_build_vec_type(bld->gallivm, h16.type);
u8n_vec_type = lp_build_vec_type(bld->gallivm, u8n.type);
lp_build_extract_image_sizes(bld,
bld->int_size_type,
@@ -317,7 +320,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
r = LLVMBuildFPToSI(builder, r, i32_vec_type, "");
/* compute floor (shift right 8) */
i32_c8 = lp_build_const_int_vec(i32.type, 8);
i32_c8 = lp_build_const_int_vec(bld->gallivm, i32.type, 8);
s_ipart = LLVMBuildAShr(builder, s, i32_c8, "");
if (dims >= 2)
t_ipart = LLVMBuildAShr(builder, t, i32_c8, "");
@@ -325,7 +328,8 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
r_ipart = LLVMBuildAShr(builder, r, i32_c8, "");
/* get pixel, row, image strides */
x_stride = lp_build_const_vec(bld->int_coord_bld.type,
x_stride = lp_build_const_vec(bld->gallivm,
bld->int_coord_bld.type,
bld->format_desc->block.bits/8);
/* Do texcoord wrapping, compute texel offset */
@@ -387,7 +391,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
* Given the format is a rgba8, just read the pixels as is,
* without any swizzling. Swizzling will be done later.
*/
rgba8 = lp_build_gather(bld->builder,
rgba8 = lp_build_gather(bld->gallivm,
bld->texel_type.length,
bld->format_desc->block.bits,
bld->texel_type.width,
@@ -396,7 +400,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
rgba8 = LLVMBuildBitCast(builder, rgba8, u8n_vec_type, "");
}
else {
rgba8 = lp_build_fetch_rgba_aos(bld->builder,
rgba8 = lp_build_fetch_rgba_aos(bld->gallivm,
bld->format_desc,
u8n.type,
data_ptr, offset,
@@ -405,7 +409,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
}
/* Expand one 4*rgba8 to two 2*rgba16 */
lp_build_unpack2(builder, u8n.type, h16.type,
lp_build_unpack2(bld->gallivm, u8n.type, h16.type,
rgba8,
colors_lo, colors_hi);
}
@@ -429,7 +433,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
LLVMValueRef *colors_hi)
{
const unsigned dims = bld->dims;
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_build_context i32, h16, u8n;
LLVMTypeRef i32_vec_type, h16_vec_type, u8n_vec_type;
LLVMValueRef i32_c8, i32_c128, i32_c255;
@@ -450,13 +454,13 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
unsigned i, j, k;
unsigned numj, numk;
lp_build_context_init(&i32, builder, lp_type_int_vec(32));
lp_build_context_init(&h16, builder, lp_type_ufixed(16));
lp_build_context_init(&u8n, builder, lp_type_unorm(8));
lp_build_context_init(&i32, bld->gallivm, lp_type_int_vec(32));
lp_build_context_init(&h16, bld->gallivm, lp_type_ufixed(16));
lp_build_context_init(&u8n, bld->gallivm, lp_type_unorm(8));
i32_vec_type = lp_build_vec_type(i32.type);
h16_vec_type = lp_build_vec_type(h16.type);
u8n_vec_type = lp_build_vec_type(u8n.type);
i32_vec_type = lp_build_vec_type(bld->gallivm, i32.type);
h16_vec_type = lp_build_vec_type(bld->gallivm, h16.type);
u8n_vec_type = lp_build_vec_type(bld->gallivm, u8n.type);
lp_build_extract_image_sizes(bld,
bld->int_size_type,
@@ -494,7 +498,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
r = LLVMBuildFPToSI(builder, r, i32_vec_type, "");
/* subtract 0.5 (add -128) */
i32_c128 = lp_build_const_int_vec(i32.type, -128);
i32_c128 = lp_build_const_int_vec(bld->gallivm, i32.type, -128);
s = LLVMBuildAdd(builder, s, i32_c128, "");
if (dims >= 2) {
t = LLVMBuildAdd(builder, t, i32_c128, "");
@@ -504,7 +508,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
}
/* compute floor (shift right 8) */
i32_c8 = lp_build_const_int_vec(i32.type, 8);
i32_c8 = lp_build_const_int_vec(bld->gallivm, i32.type, 8);
s_ipart = LLVMBuildAShr(builder, s, i32_c8, "");
if (dims >= 2)
t_ipart = LLVMBuildAShr(builder, t, i32_c8, "");
@@ -512,7 +516,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
r_ipart = LLVMBuildAShr(builder, r, i32_c8, "");
/* compute fractional part (AND with 0xff) */
i32_c255 = lp_build_const_int_vec(i32.type, 255);
i32_c255 = lp_build_const_int_vec(bld->gallivm, i32.type, 255);
s_fpart = LLVMBuildAnd(builder, s, i32_c255, "");
if (dims >= 2)
t_fpart = LLVMBuildAnd(builder, t, i32_c255, "");
@@ -520,7 +524,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
r_fpart = LLVMBuildAnd(builder, r, i32_c255, "");
/* get pixel, row and image strides */
x_stride = lp_build_const_vec(bld->int_coord_bld.type,
x_stride = lp_build_const_vec(bld->gallivm, bld->int_coord_bld.type,
bld->format_desc->block.bits/8);
y_stride = row_stride_vec;
z_stride = img_stride_vec;
@@ -612,7 +616,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
r_fpart = LLVMBuildBitCast(builder, r_fpart, h16_vec_type, "");
{
LLVMTypeRef elem_type = LLVMInt32Type();
LLVMTypeRef elem_type = LLVMInt32TypeInContext(bld->gallivm->context);
LLVMValueRef shuffles_lo[LP_MAX_VECTOR_LENGTH];
LLVMValueRef shuffles_hi[LP_MAX_VECTOR_LENGTH];
LLVMValueRef shuffle_lo;
@@ -685,7 +689,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
* Given the format is a rgba8, just read the pixels as is,
* without any swizzling. Swizzling will be done later.
*/
rgba8 = lp_build_gather(bld->builder,
rgba8 = lp_build_gather(bld->gallivm,
bld->texel_type.length,
bld->format_desc->block.bits,
bld->texel_type.width,
@@ -694,7 +698,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
rgba8 = LLVMBuildBitCast(builder, rgba8, u8n_vec_type, "");
}
else {
rgba8 = lp_build_fetch_rgba_aos(bld->builder,
rgba8 = lp_build_fetch_rgba_aos(bld->gallivm,
bld->format_desc,
u8n.type,
data_ptr, offset[k][j][i],
@@ -703,7 +707,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
}
/* Expand one 4*rgba8 to two 2*rgba16 */
lp_build_unpack2(builder, u8n.type, h16.type,
lp_build_unpack2(bld->gallivm, u8n.type, h16.type,
rgba8,
&neighbors_lo[k][j][i], &neighbors_hi[k][j][i]);
}
@@ -790,7 +794,7 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
LLVMValueRef colors_lo_var,
LLVMValueRef colors_hi_var)
{
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef size0;
LLVMValueRef size1;
LLVMValueRef row_stride0_vec;
@@ -802,7 +806,6 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
LLVMValueRef colors0_lo, colors0_hi;
LLVMValueRef colors1_lo, colors1_hi;
/* sample the first mipmap level */
lp_build_mipmap_level_sizes(bld, ilevel0,
&size0,
@@ -829,8 +832,8 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
LLVMBuildStore(builder, colors0_hi, colors_hi_var);
if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
LLVMValueRef h16_scale = LLVMConstReal(LLVMFloatType(), 256.0);
LLVMTypeRef i32_type = LLVMIntType(32);
LLVMValueRef h16_scale = lp_build_const_float(bld->gallivm, 256.0);
LLVMTypeRef i32_type = LLVMIntTypeInContext(bld->gallivm->context, 32);
struct lp_build_if_state if_ctx;
LLVMValueRef need_lerp;
@@ -842,11 +845,11 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
lod_fpart, LLVMConstNull(i32_type),
"need_lerp");
lp_build_if(&if_ctx, builder, need_lerp);
lp_build_if(&if_ctx, bld->gallivm, need_lerp);
{
struct lp_build_context h16_bld;
lp_build_context_init(&h16_bld, builder, lp_type_ufixed(16));
lp_build_context_init(&h16_bld, bld->gallivm, lp_type_ufixed(16));
/* sample the second mipmap level */
lp_build_mipmap_level_sizes(bld, ilevel1,
@@ -885,7 +888,7 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
int i;
assert(h16_bld.type.length <= Elements(shuffles));
for (i = 0; i < h16_bld.type.length; i++)
shuffles[i] = lp_build_const_int32(2 * (i & 1));
shuffles[i] = lp_build_const_int32(bld->gallivm, 2 * (i & 1));
shuffle = LLVMConstVector(shuffles, h16_bld.type.length);
lod_fpart = LLVMBuildShuffleVector(builder,
lod_fpart, lod_fpart,
@@ -925,7 +928,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
LLVMValueRef texel_out[4])
{
struct lp_build_context *int_bld = &bld->int_bld;
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
const unsigned mip_filter = bld->static_state->min_mip_filter;
const unsigned min_filter = bld->static_state->min_img_filter;
const unsigned mag_filter = bld->static_state->mag_img_filter;
@@ -936,8 +939,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
LLVMValueRef unswizzled[4];
LLVMValueRef face_ddx[4], face_ddy[4];
struct lp_build_context h16_bld;
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef i32t_zero = LLVMConstInt(i32t, 0, 0);
LLVMValueRef i32t_zero = lp_build_const_int32(bld->gallivm, 0);
/* we only support the common/simple wrap modes at this time */
assert(lp_is_simple_wrap_mode(bld->static_state->wrap_s));
@@ -948,7 +950,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
/* make 16-bit fixed-pt builder context */
lp_build_context_init(&h16_bld, builder, lp_type_ufixed(16));
lp_build_context_init(&h16_bld, bld->gallivm, lp_type_ufixed(16));
/* cube face selection, compute pre-face coords, etc. */
if (bld->static_state->target == PIPE_TEXTURE_CUBE) {
@@ -1026,8 +1028,8 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
* Get/interpolate texture colors.
*/
packed_lo = lp_build_alloca(builder, h16_bld.vec_type, "packed_lo");
packed_hi = lp_build_alloca(builder, h16_bld.vec_type, "packed_hi");
packed_lo = lp_build_alloca(bld->gallivm, h16_bld.vec_type, "packed_lo");
packed_hi = lp_build_alloca(bld->gallivm, h16_bld.vec_type, "packed_hi");
if (min_filter == mag_filter) {
/* no need to distinquish between minification and magnification */
@@ -1048,7 +1050,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
minify = LLVMBuildICmp(builder, LLVMIntSGE,
lod_ipart, int_bld->zero, "");
lp_build_if(&if_ctx, builder, minify);
lp_build_if(&if_ctx, bld->gallivm, minify);
{
/* Use the minification filter */
lp_build_sample_mipmap(bld,
@@ -1073,7 +1075,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
* combine the values stored in 'packed_lo' and 'packed_hi' variables
* into 'packed'
*/
packed = lp_build_pack2(builder,
packed = lp_build_pack2(bld->gallivm,
h16_bld.type, lp_type_unorm(8),
LLVMBuildLoad(builder, packed_lo, ""),
LLVMBuildLoad(builder, packed_hi, ""));
@@ -1081,7 +1083,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
/*
* Convert to SoA and swizzle.
*/
lp_build_rgba8_to_f32_soa(builder,
lp_build_rgba8_to_f32_soa(bld->gallivm,
bld->texel_type,
packed, unswizzled);

View File

@@ -84,6 +84,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
const struct lp_sampler_static_state *static_state = bld->static_state;
const unsigned dims = bld->dims;
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef offset;
LLVMValueRef i, j;
LLVMValueRef use_border = NULL;
@@ -95,7 +96,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
LLVMValueRef b1, b2;
b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, x, int_coord_bld->zero);
b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, x, width);
use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2");
use_border = LLVMBuildOr(builder, b1, b2, "b1_or_b2");
}
if (dims >= 2 &&
@@ -106,11 +107,11 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, y, int_coord_bld->zero);
b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, y, height);
if (use_border) {
use_border = LLVMBuildOr(bld->builder, use_border, b1, "ub_or_b1");
use_border = LLVMBuildOr(bld->builder, use_border, b2, "ub_or_b2");
use_border = LLVMBuildOr(builder, use_border, b1, "ub_or_b1");
use_border = LLVMBuildOr(builder, use_border, b2, "ub_or_b2");
}
else {
use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2");
use_border = LLVMBuildOr(builder, b1, b2, "b1_or_b2");
}
}
@@ -122,11 +123,11 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, z, int_coord_bld->zero);
b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, z, depth);
if (use_border) {
use_border = LLVMBuildOr(bld->builder, use_border, b1, "ub_or_b1");
use_border = LLVMBuildOr(bld->builder, use_border, b2, "ub_or_b2");
use_border = LLVMBuildOr(builder, use_border, b1, "ub_or_b1");
use_border = LLVMBuildOr(builder, use_border, b2, "ub_or_b2");
}
else {
use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2");
use_border = LLVMBuildOr(builder, b1, b2, "b1_or_b2");
}
}
@@ -148,7 +149,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
offset = lp_build_andnot(&bld->int_coord_bld, offset, use_border);
}
lp_build_fetch_rgba_soa(bld->builder,
lp_build_fetch_rgba_soa(bld->gallivm,
bld->format_desc,
bld->texel_type,
data_ptr, offset,
@@ -174,12 +175,12 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
/* select texel color or border color depending on use_border */
LLVMValueRef border_color_ptr =
bld->dynamic_state->border_color(bld->dynamic_state,
bld->builder, unit);
bld->gallivm, unit);
int chan;
for (chan = 0; chan < 4; chan++) {
LLVMValueRef border_chan =
lp_build_array_get(bld->builder, border_color_ptr,
lp_build_const_int32(chan));
lp_build_array_get(bld->gallivm, border_color_ptr,
lp_build_const_int32(bld->gallivm, chan));
LLVMValueRef border_chan_vec =
lp_build_broadcast_scalar(&bld->float_vec_bld, border_chan);
texel_out[chan] = lp_build_select(&bld->texel_bld, use_border,
@@ -205,7 +206,7 @@ lp_build_coord_mirror(struct lp_build_sample_context *bld,
lp_build_ifloor_fract(coord_bld, coord, &flr, &fract);
/* isOdd = flr & 1 */
isOdd = LLVMBuildAnd(bld->builder, flr, int_coord_bld->one, "");
isOdd = LLVMBuildAnd(bld->gallivm->builder, flr, int_coord_bld->one, "");
/* make coord positive or negative depending on isOdd */
coord = lp_build_set_sign(coord_bld, fract, isOdd);
@@ -239,7 +240,8 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
{
struct lp_build_context *coord_bld = &bld->coord_bld;
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
LLVMValueRef half = lp_build_const_vec(coord_bld->type, 0.5);
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef half = lp_build_const_vec(bld->gallivm, coord_bld->type, 0.5);
LLVMValueRef length_minus_one = lp_build_sub(int_coord_bld, length, int_coord_bld->one);
LLVMValueRef coord0, coord1, weight;
@@ -253,18 +255,18 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
/* repeat wrap */
if (is_pot) {
coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one);
coord0 = LLVMBuildAnd(bld->builder, coord0, length_minus_one, "");
coord1 = LLVMBuildAnd(bld->builder, coord1, length_minus_one, "");
coord0 = LLVMBuildAnd(builder, coord0, length_minus_one, "");
coord1 = LLVMBuildAnd(builder, coord1, length_minus_one, "");
}
else {
/* Add a bias to the texcoord to handle negative coords */
LLVMValueRef bias = lp_build_mul_imm(int_coord_bld, length, 1024);
LLVMValueRef mask;
coord0 = LLVMBuildAdd(bld->builder, coord0, bias, "");
coord0 = LLVMBuildURem(bld->builder, coord0, length, "");
mask = lp_build_compare(bld->builder, int_coord_bld->type,
coord0 = LLVMBuildAdd(builder, coord0, bias, "");
coord0 = LLVMBuildURem(builder, coord0, length, "");
mask = lp_build_compare(bld->gallivm, int_coord_bld->type,
PIPE_FUNC_NOTEQUAL, coord0, length_minus_one);
coord1 = LLVMBuildAnd(bld->builder,
coord1 = LLVMBuildAnd(builder,
lp_build_add(int_coord_bld, coord0, int_coord_bld->one),
mask, "");
}
@@ -318,7 +320,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
}
/* was: clamp to [-0.5, length + 0.5], then sub 0.5 */
coord = lp_build_sub(coord_bld, coord, half);
min = lp_build_const_vec(coord_bld->type, -1.0F);
min = lp_build_const_vec(bld->gallivm, coord_bld->type, -1.0F);
coord = lp_build_clamp(coord_bld, coord, min, length_f);
/* convert to int, compute lerp weight */
lp_build_ifloor_fract(coord_bld, coord, &coord0, &weight);
@@ -437,6 +439,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld,
{
struct lp_build_context *coord_bld = &bld->coord_bld;
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef length_minus_one = lp_build_sub(int_coord_bld, length, int_coord_bld->one);
LLVMValueRef icoord;
@@ -445,12 +448,12 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld,
coord = lp_build_mul(coord_bld, coord, length_f);
icoord = lp_build_ifloor(coord_bld, coord);
if (is_pot)
icoord = LLVMBuildAnd(bld->builder, icoord, length_minus_one, "");
icoord = LLVMBuildAnd(builder, icoord, length_minus_one, "");
else {
/* Add a bias to the texcoord to handle negative coords */
LLVMValueRef bias = lp_build_mul_imm(int_coord_bld, length, 1024);
icoord = LLVMBuildAdd(bld->builder, icoord, bias, "");
icoord = LLVMBuildURem(bld->builder, icoord, length, "");
icoord = LLVMBuildAdd(builder, icoord, bias, "");
icoord = LLVMBuildURem(builder, icoord, length, "");
}
break;
@@ -830,7 +833,7 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
LLVMValueRef lod_fpart,
LLVMValueRef *colors_out)
{
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef size0;
LLVMValueRef size1;
LLVMValueRef row_stride0_vec;
@@ -878,7 +881,7 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
bld->float_bld.zero,
"need_lerp");
lp_build_if(&if_ctx, builder, need_lerp);
lp_build_if(&if_ctx, bld->gallivm, need_lerp);
{
/* sample the second mipmap level */
lp_build_mipmap_level_sizes(bld, ilevel1,
@@ -934,7 +937,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
LLVMValueRef *colors_out)
{
struct lp_build_context *int_bld = &bld->int_bld;
LLVMBuilderRef builder = bld->builder;
LLVMBuilderRef builder = bld->gallivm->builder;
const unsigned mip_filter = bld->static_state->min_mip_filter;
const unsigned min_filter = bld->static_state->min_img_filter;
const unsigned mag_filter = bld->static_state->mag_img_filter;
@@ -942,8 +945,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
LLVMValueRef ilevel0, ilevel1 = NULL;
LLVMValueRef face_ddx[4], face_ddy[4];
LLVMValueRef texels[4];
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef i32t_zero = LLVMConstInt(i32t, 0, 0);
LLVMValueRef i32t_zero = lp_build_const_int32(bld->gallivm, 0);
unsigned chan;
/*
@@ -1030,7 +1032,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
*/
for (chan = 0; chan < 4; ++chan) {
texels[chan] = lp_build_alloca(builder, bld->texel_bld.vec_type, "");
texels[chan] = lp_build_alloca(bld->gallivm, bld->texel_bld.vec_type, "");
lp_build_name(texels[chan], "sampler%u_texel_%c_var", unit, "xyzw"[chan]);
}
@@ -1053,7 +1055,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
minify = LLVMBuildICmp(builder, LLVMIntSGE,
lod_ipart, int_bld->zero, "");
lp_build_if(&if_ctx, builder, minify);
lp_build_if(&if_ctx, bld->gallivm, minify);
{
/* Use the minification filter */
lp_build_sample_mipmap(bld, unit,
@@ -1092,6 +1094,7 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
LLVMValueRef texel[4])
{
struct lp_build_context *texel_bld = &bld->texel_bld;
LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef res;
const unsigned chan = 0;
@@ -1100,11 +1103,10 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
/* debug code */
if (0) {
LLVMValueRef indx = lp_build_const_int32(0);
LLVMValueRef coord = LLVMBuildExtractElement(bld->builder, p, indx, "");
LLVMValueRef tex = LLVMBuildExtractElement(bld->builder,
texel[chan], indx, "");
lp_build_printf(bld->builder, "shadow compare coord %f to texture %f\n",
LLVMValueRef indx = lp_build_const_int32(bld->gallivm, 0);
LLVMValueRef coord = LLVMBuildExtractElement(builder, p, indx, "");
LLVMValueRef tex = LLVMBuildExtractElement(builder, texel[chan], indx, "");
lp_build_printf(bld->gallivm, "shadow compare coord %f to texture %f\n",
coord, tex);
}
@@ -1126,10 +1128,10 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
* For debugging.
*/
void
lp_build_sample_nop(struct lp_type type,
lp_build_sample_nop(struct gallivm_state *gallivm, struct lp_type type,
LLVMValueRef texel_out[4])
{
LLVMValueRef one = lp_build_one(type);
LLVMValueRef one = lp_build_one(gallivm, type);
unsigned chan;
for (chan = 0; chan < 4; chan++) {
@@ -1147,7 +1149,7 @@ lp_build_sample_nop(struct lp_type type,
* \param ddy partial derivatives of (s,t,r,q) with respect to y
*/
void
lp_build_sample_soa(LLVMBuilderRef builder,
lp_build_sample_soa(struct gallivm_state *gallivm,
const struct lp_sampler_static_state *static_state,
struct lp_sampler_dynamic_state *dynamic_state,
struct lp_type type,
@@ -1162,8 +1164,8 @@ lp_build_sample_soa(LLVMBuilderRef builder,
{
unsigned dims = texture_dims(static_state->target);
struct lp_build_sample_context bld;
LLVMTypeRef i32t = LLVMInt32Type();
LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context);
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef s;
LLVMValueRef t;
LLVMValueRef r;
@@ -1178,7 +1180,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
/* Setup our build context */
memset(&bld, 0, sizeof bld);
bld.builder = builder;
bld.gallivm = gallivm;
bld.static_state = static_state;
bld.dynamic_state = dynamic_state;
bld.format_desc = util_format_description(static_state->format);
@@ -1195,22 +1197,22 @@ lp_build_sample_soa(LLVMBuilderRef builder,
float_vec_type = lp_type_float_vec(32);
lp_build_context_init(&bld.float_bld, builder, bld.float_type);
lp_build_context_init(&bld.float_vec_bld, builder, float_vec_type);
lp_build_context_init(&bld.int_bld, builder, bld.int_type);
lp_build_context_init(&bld.coord_bld, builder, bld.coord_type);
lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type);
lp_build_context_init(&bld.int_size_bld, builder, bld.int_size_type);
lp_build_context_init(&bld.float_size_bld, builder, bld.float_size_type);
lp_build_context_init(&bld.texel_bld, builder, bld.texel_type);
lp_build_context_init(&bld.float_bld, gallivm, bld.float_type);
lp_build_context_init(&bld.float_vec_bld, gallivm, float_vec_type);
lp_build_context_init(&bld.int_bld, gallivm, bld.int_type);
lp_build_context_init(&bld.coord_bld, gallivm, bld.coord_type);
lp_build_context_init(&bld.int_coord_bld, gallivm, bld.int_coord_type);
lp_build_context_init(&bld.int_size_bld, gallivm, bld.int_size_type);
lp_build_context_init(&bld.float_size_bld, gallivm, bld.float_size_type);
lp_build_context_init(&bld.texel_bld, gallivm, bld.texel_type);
/* Get the dynamic state */
bld.width = dynamic_state->width(dynamic_state, builder, unit);
bld.height = dynamic_state->height(dynamic_state, builder, unit);
bld.depth = dynamic_state->depth(dynamic_state, builder, unit);
bld.row_stride_array = dynamic_state->row_stride(dynamic_state, builder, unit);
bld.img_stride_array = dynamic_state->img_stride(dynamic_state, builder, unit);
bld.data_array = dynamic_state->data_ptr(dynamic_state, builder, unit);
bld.width = dynamic_state->width(dynamic_state, gallivm, unit);
bld.height = dynamic_state->height(dynamic_state, gallivm, unit);
bld.depth = dynamic_state->depth(dynamic_state, gallivm, unit);
bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm, unit);
bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm, unit);
bld.data_array = dynamic_state->data_ptr(dynamic_state, gallivm, unit);
/* Note that data_array is an array[level] of pointers to texture images */
s = coords[0];
@@ -1236,7 +1238,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
if (0) {
/* For debug: no-op texture sampling */
lp_build_sample_nop(bld.texel_type, texel_out);
lp_build_sample_nop(gallivm, bld.texel_type, texel_out);
}
else if (util_format_fits_8unorm(bld.format_desc) &&
lp_is_simple_wrap_mode(static_state->wrap_s) &&

View File

@@ -37,12 +37,13 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "lp_bld_const.h"
#include "lp_bld_debug.h"
#include "lp_bld_struct.h"
LLVMValueRef
lp_build_struct_get_ptr(LLVMBuilderRef builder,
lp_build_struct_get_ptr(struct gallivm_state *gallivm,
LLVMValueRef ptr,
unsigned member,
const char *name)
@@ -51,16 +52,16 @@ lp_build_struct_get_ptr(LLVMBuilderRef builder,
LLVMValueRef member_ptr;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind);
indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indices[1] = LLVMConstInt(LLVMInt32Type(), member, 0);
member_ptr = LLVMBuildGEP(builder, ptr, indices, Elements(indices), "");
indices[0] = lp_build_const_int32(gallivm, 0);
indices[1] = lp_build_const_int32(gallivm, member);
member_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), "");
lp_build_name(member_ptr, "%s.%s_ptr", LLVMGetValueName(ptr), name);
return member_ptr;
}
LLVMValueRef
lp_build_struct_get(LLVMBuilderRef builder,
lp_build_struct_get(struct gallivm_state *gallivm,
LLVMValueRef ptr,
unsigned member,
const char *name)
@@ -69,15 +70,15 @@ lp_build_struct_get(LLVMBuilderRef builder,
LLVMValueRef res;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind);
member_ptr = lp_build_struct_get_ptr(builder, ptr, member, name);
res = LLVMBuildLoad(builder, member_ptr, "");
member_ptr = lp_build_struct_get_ptr(gallivm, ptr, member, name);
res = LLVMBuildLoad(gallivm->builder, member_ptr, "");
lp_build_name(res, "%s.%s", LLVMGetValueName(ptr), name);
return res;
}
LLVMValueRef
lp_build_array_get_ptr(LLVMBuilderRef builder,
lp_build_array_get_ptr(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index)
{
@@ -85,9 +86,9 @@ lp_build_array_get_ptr(LLVMBuilderRef builder,
LLVMValueRef element_ptr;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indices[0] = lp_build_const_int32(gallivm, 0);
indices[1] = index;
element_ptr = LLVMBuildGEP(builder, ptr, indices, Elements(indices), "");
element_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), "");
#ifdef DEBUG
lp_build_name(element_ptr, "&%s[%s]",
LLVMGetValueName(ptr), LLVMGetValueName(index));
@@ -97,7 +98,7 @@ lp_build_array_get_ptr(LLVMBuilderRef builder,
LLVMValueRef
lp_build_array_get(LLVMBuilderRef builder,
lp_build_array_get(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index)
{
@@ -105,8 +106,8 @@ lp_build_array_get(LLVMBuilderRef builder,
LLVMValueRef res;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
element_ptr = lp_build_array_get_ptr(builder, ptr, index);
res = LLVMBuildLoad(builder, element_ptr, "");
element_ptr = lp_build_array_get_ptr(gallivm, ptr, index);
res = LLVMBuildLoad(gallivm->builder, element_ptr, "");
#ifdef DEBUG
lp_build_name(res, "%s[%s]", LLVMGetValueName(ptr), LLVMGetValueName(index));
#endif
@@ -115,7 +116,7 @@ lp_build_array_get(LLVMBuilderRef builder,
void
lp_build_array_set(LLVMBuilderRef builder,
lp_build_array_set(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index,
LLVMValueRef value)
@@ -123,8 +124,8 @@ lp_build_array_set(LLVMBuilderRef builder,
LLVMValueRef element_ptr;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
element_ptr = lp_build_array_get_ptr(builder, ptr, index);
LLVMBuildStore(builder, value, element_ptr);
element_ptr = lp_build_array_get_ptr(gallivm, ptr, index);
LLVMBuildStore(gallivm->builder, value, element_ptr);
}

View File

@@ -38,7 +38,7 @@
#include "gallivm/lp_bld.h"
#include <llvm-c/Target.h>
#include "gallivm/lp_bld_init.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
@@ -57,7 +57,7 @@
* Get value pointer to a structure member.
*/
LLVMValueRef
lp_build_struct_get_ptr(LLVMBuilderRef builder,
lp_build_struct_get_ptr(struct gallivm_state *gallivm,
LLVMValueRef ptr,
unsigned member,
const char *name);
@@ -66,7 +66,7 @@ lp_build_struct_get_ptr(LLVMBuilderRef builder,
* Get the value of a structure member.
*/
LLVMValueRef
lp_build_struct_get(LLVMBuilderRef builder,
lp_build_struct_get(struct gallivm_state *gallivm,
LLVMValueRef ptr,
unsigned member,
const char *name);
@@ -75,7 +75,7 @@ lp_build_struct_get(LLVMBuilderRef builder,
* Get value pointer to an array element.
*/
LLVMValueRef
lp_build_array_get_ptr(LLVMBuilderRef builder,
lp_build_array_get_ptr(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index);
@@ -83,7 +83,7 @@ lp_build_array_get_ptr(LLVMBuilderRef builder,
* Get the value of an array element.
*/
LLVMValueRef
lp_build_array_get(LLVMBuilderRef builder,
lp_build_array_get(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index);
@@ -91,7 +91,7 @@ lp_build_array_get(LLVMBuilderRef builder,
* Set the value of an array element.
*/
void
lp_build_array_set(LLVMBuilderRef builder,
lp_build_array_set(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index,
LLVMValueRef value);

View File

@@ -37,12 +37,13 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_init.h"
#include "lp_bld_logic.h"
#include "lp_bld_swizzle.h"
LLVMValueRef
lp_build_broadcast(LLVMBuilderRef builder,
lp_build_broadcast(struct gallivm_state *gallivm,
LLVMTypeRef vec_type,
LLVMValueRef scalar)
{
@@ -52,8 +53,8 @@ lp_build_broadcast(LLVMBuilderRef builder,
res = LLVMGetUndef(vec_type);
for(i = 0; i < n; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
res = LLVMBuildInsertElement(builder, res, scalar, index, "");
LLVMValueRef index = lp_build_const_int32(gallivm, i);
res = LLVMBuildInsertElement(gallivm->builder, res, scalar, index, "");
}
return res;
@@ -67,6 +68,7 @@ LLVMValueRef
lp_build_broadcast_scalar(struct lp_build_context *bld,
LLVMValueRef scalar)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(lp_check_elem_type(type, LLVMTypeOf(scalar)));
@@ -82,17 +84,17 @@ lp_build_broadcast_scalar(struct lp_build_context *bld,
struct lp_type i32_vec_type = lp_type_int_vec(32);
i32_vec_type.length = type.length;
res = LLVMBuildInsertElement(bld->builder, bld->undef, scalar,
LLVMConstInt(LLVMInt32Type(), 0, 0), "");
res = LLVMBuildShuffleVector(bld->builder, res, bld->undef,
lp_build_const_int_vec(i32_vec_type, 0), "");
res = LLVMBuildInsertElement(builder, bld->undef, scalar,
lp_build_const_int32(bld->gallivm, 0), "");
res = LLVMBuildShuffleVector(builder, res, bld->undef,
lp_build_const_int_vec(bld->gallivm, i32_vec_type, 0), "");
#else
/* XXX: The above path provokes a bug in LLVM 2.6 */
unsigned i;
res = bld->undef;
for(i = 0; i < type.length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
res = LLVMBuildInsertElement(bld->builder, res, scalar, index, "");
LLVMValueRef index = lp_build_const_int32(bld->gallivm, i);
res = LLVMBuildInsertElement(builder, res, scalar, index, "");
}
#endif
return res;
@@ -104,13 +106,13 @@ lp_build_broadcast_scalar(struct lp_build_context *bld,
* Combined extract and broadcast (or a mere shuffle when the two types match)
*/
LLVMValueRef
lp_build_extract_broadcast(LLVMBuilderRef builder,
lp_build_extract_broadcast(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef vector,
LLVMValueRef index)
{
LLVMTypeRef i32t = LLVMInt32Type();
LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context);
LLVMValueRef res;
assert(src_type.floating == dst_type.floating);
@@ -132,8 +134,8 @@ lp_build_extract_broadcast(LLVMBuilderRef builder,
* Broadcast scalar -> vector.
*/
res = lp_build_broadcast(builder,
lp_build_vec_type(dst_type),
res = lp_build_broadcast(gallivm,
lp_build_vec_type(gallivm, dst_type),
vector);
}
}
@@ -144,16 +146,16 @@ lp_build_extract_broadcast(LLVMBuilderRef builder,
*/
LLVMValueRef shuffle;
shuffle = lp_build_broadcast(builder,
shuffle = lp_build_broadcast(gallivm,
LLVMVectorType(i32t, dst_type.length),
index);
res = LLVMBuildShuffleVector(builder, vector,
LLVMGetUndef(lp_build_vec_type(dst_type)),
res = LLVMBuildShuffleVector(gallivm->builder, vector,
LLVMGetUndef(lp_build_vec_type(gallivm, dst_type)),
shuffle, "");
}
else {
LLVMValueRef scalar;
scalar = LLVMBuildExtractElement(builder, vector, index, "");
scalar = LLVMBuildExtractElement(gallivm->builder, vector, index, "");
if (dst_type.length == 1) {
/*
* Trivial extract scalar from vector.
@@ -166,8 +168,8 @@ lp_build_extract_broadcast(LLVMBuilderRef builder,
* General case of different sized vectors.
*/
res = lp_build_broadcast(builder,
lp_build_vec_type(dst_type),
res = lp_build_broadcast(gallivm,
lp_build_vec_type(gallivm, dst_type),
vector);
}
}
@@ -185,6 +187,7 @@ lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
LLVMValueRef a,
unsigned channel)
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const unsigned n = type.length;
unsigned i, j;
@@ -199,14 +202,14 @@ lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
/*
* Shuffle.
*/
LLVMTypeRef elem_type = LLVMInt32Type();
LLVMTypeRef elem_type = LLVMInt32TypeInContext(bld->gallivm->context);
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH];
for(j = 0; j < n; j += 4)
for(i = 0; i < 4; ++i)
shuffles[j + i] = LLVMConstInt(elem_type, j + channel, 0);
return LLVMBuildShuffleVector(bld->builder, a, bld->undef, LLVMConstVector(shuffles, n), "");
return LLVMBuildShuffleVector(builder, a, bld->undef, LLVMConstVector(shuffles, n), "");
}
else {
/*
@@ -226,8 +229,9 @@ lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
};
unsigned i;
a = LLVMBuildAnd(bld->builder, a,
lp_build_const_mask_aos(type, 1 << channel), "");
a = LLVMBuildAnd(builder, a,
lp_build_const_mask_aos(bld->gallivm,
type, 1 << channel), "");
/*
* Build a type where each element is an integer that cover the four
@@ -239,7 +243,7 @@ lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
type4.width *= 4;
type4.length /= 4;
a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(type4), "");
a = LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, type4), "");
for(i = 0; i < 2; ++i) {
LLVMValueRef tmp = NULL;
@@ -250,16 +254,16 @@ lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
#endif
if(shift > 0)
tmp = LLVMBuildLShr(bld->builder, a, lp_build_const_int_vec(type4, shift*type.width), "");
tmp = LLVMBuildLShr(builder, a, lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
if(shift < 0)
tmp = LLVMBuildShl(bld->builder, a, lp_build_const_int_vec(type4, -shift*type.width), "");
tmp = LLVMBuildShl(builder, a, lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
assert(tmp);
if(tmp)
a = LLVMBuildOr(bld->builder, a, tmp, "");
a = LLVMBuildOr(builder, a, tmp, "");
}
return LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(type), "");
return LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, type), "");
}
}
@@ -269,6 +273,7 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
LLVMValueRef a,
const unsigned char swizzles[4])
{
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const unsigned n = type.length;
unsigned i, j;
@@ -303,8 +308,8 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
/*
* Shuffle.
*/
LLVMValueRef undef = LLVMGetUndef(lp_build_elem_type(type));
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef undef = LLVMGetUndef(lp_build_elem_type(bld->gallivm, type));
LLVMTypeRef i32t = LLVMInt32TypeInContext(bld->gallivm->context);
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH];
LLVMValueRef aux[LP_MAX_VECTOR_LENGTH];
@@ -326,13 +331,13 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
case PIPE_SWIZZLE_ZERO:
shuffle = type.length + 0;
if (!aux[0]) {
aux[0] = lp_build_const_elem(type, 0.0);
aux[0] = lp_build_const_elem(bld->gallivm, type, 0.0);
}
break;
case PIPE_SWIZZLE_ONE:
shuffle = type.length + 1;
if (!aux[1]) {
aux[1] = lp_build_const_elem(type, 1.0);
aux[1] = lp_build_const_elem(bld->gallivm, type, 1.0);
}
break;
}
@@ -346,7 +351,7 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
}
}
return LLVMBuildShuffleVector(bld->builder, a,
return LLVMBuildShuffleVector(builder, a,
LLVMConstVector(aux, n),
LLVMConstVector(shuffles, n), "");
} else {
@@ -387,8 +392,8 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
type4.width *= 4;
type4.length /= 4;
a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(type4), "");
res = LLVMBuildBitCast(bld->builder, res, lp_build_vec_type(type4), "");
a = LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, type4), "");
res = LLVMBuildBitCast(builder, res, lp_build_vec_type(bld->gallivm, type4), "");
/*
* Mask and shift the channels, trying to group as many channels in the
@@ -414,23 +419,24 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
if (0)
debug_printf("shift = %i, mask = 0x%08llx\n", shift, mask);
masked = LLVMBuildAnd(bld->builder, a,
lp_build_const_int_vec(type4, mask), "");
masked = LLVMBuildAnd(builder, a,
lp_build_const_int_vec(bld->gallivm, type4, mask), "");
if (shift > 0) {
shifted = LLVMBuildShl(bld->builder, masked,
lp_build_const_int_vec(type4, shift*type.width), "");
shifted = LLVMBuildShl(builder, masked,
lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
} else if (shift < 0) {
shifted = LLVMBuildLShr(bld->builder, masked,
lp_build_const_int_vec(type4, -shift*type.width), "");
shifted = LLVMBuildLShr(builder, masked,
lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
} else {
shifted = masked;
}
res = LLVMBuildOr(bld->builder, res, shifted, "");
res = LLVMBuildOr(builder, res, shifted, "");
}
}
return LLVMBuildBitCast(bld->builder, res, lp_build_vec_type(type), "");
return LLVMBuildBitCast(builder, res,
lp_build_vec_type(bld->gallivm, type), "");
}
}

View File

@@ -45,7 +45,7 @@ struct lp_build_context;
LLVMValueRef
lp_build_broadcast(LLVMBuilderRef builder,
lp_build_broadcast(struct gallivm_state *gallivm,
LLVMTypeRef vec_type,
LLVMValueRef scalar);
@@ -56,7 +56,7 @@ lp_build_broadcast_scalar(struct lp_build_context *bld,
LLVMValueRef
lp_build_extract_broadcast(LLVMBuilderRef builder,
lp_build_extract_broadcast(struct gallivm_state *gallivm,
struct lp_type src_type,
struct lp_type dst_type,
LLVMValueRef vector,

View File

@@ -46,6 +46,7 @@ struct tgsi_shader_info;
struct lp_type;
struct lp_build_context;
struct lp_build_mask_context;
struct gallivm_state;
enum lp_build_tex_modifier {
@@ -141,7 +142,7 @@ struct lp_build_sampler_soa
void
(*emit_fetch_texel)( const struct lp_build_sampler_soa *sampler,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
struct lp_type type,
unsigned unit,
unsigned num_coords,
@@ -174,7 +175,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
void
lp_build_tgsi_soa(LLVMBuilderRef builder,
lp_build_tgsi_soa(struct gallivm_state *gallivm,
const struct tgsi_token *tokens,
struct lp_type type,
struct lp_build_mask_context *mask,
@@ -187,7 +188,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
void
lp_build_tgsi_aos(LLVMBuilderRef builder,
lp_build_tgsi_aos(struct gallivm_state *gallivm,
const struct tgsi_token *tokens,
struct lp_type type,
const unsigned char swizzles[4],

View File

@@ -151,6 +151,7 @@ emit_fetch(
const struct tgsi_full_instruction *inst,
unsigned src_op)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
struct lp_type type = bld->base.type;
const struct tgsi_full_src_register *reg = &inst->Src[src_op];
LLVMValueRef res;
@@ -175,14 +176,12 @@ emit_fetch(
LLVMValueRef scalar;
LLVMValueRef swizzle;
index = LLVMConstInt(LLVMInt32Type(),
reg->Register.Index*4 + chan,
0);
index = lp_build_const_int32(bld->base.gallivm, reg->Register.Index * 4 + chan);
scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr,
scalar_ptr = LLVMBuildGEP(builder, bld->consts_ptr,
&index, 1, "");
scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
scalar = LLVMBuildLoad(builder, scalar_ptr, "");
lp_build_name(scalar, "const[%u].%c", reg->Register.Index, "xyzw"[chan]);
@@ -190,9 +189,9 @@ emit_fetch(
* NOTE: constants array is always assumed to be RGBA
*/
swizzle = LLVMConstInt(LLVMInt32Type(), chan, 0);
swizzle = lp_build_const_int32(bld->base.gallivm, chan);
res = LLVMBuildInsertElement(bld->base.builder, res, scalar, swizzle, "");
res = LLVMBuildInsertElement(builder, res, scalar, swizzle, "");
}
/*
@@ -206,14 +205,14 @@ emit_fetch(
unsigned i;
for (chan = 0; chan < 4; ++chan) {
shuffles[chan] = LLVMConstInt(LLVMInt32Type(), chan, 0);
shuffles[chan] = lp_build_const_int32(bld->base.gallivm, chan);
}
for (i = 4; i < type.length; ++i) {
shuffles[i] = shuffles[i % 4];
}
res = LLVMBuildShuffleVector(bld->base.builder,
res = LLVMBuildShuffleVector(builder,
res, bld->base.undef,
LLVMConstVector(shuffles, type.length),
"");
@@ -234,7 +233,7 @@ emit_fetch(
{
LLVMValueRef temp_ptr;
temp_ptr = bld->temps[reg->Register.Index];
res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
res = LLVMBuildLoad(builder, temp_ptr, "");
if (!res)
return bld->base.undef;
}
@@ -281,6 +280,7 @@ emit_store(
unsigned index,
LLVMValueRef value)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
const struct tgsi_full_dst_register *reg = &inst->Dst[index];
LLVMValueRef mask = NULL;
LLVMValueRef ptr;
@@ -299,7 +299,7 @@ emit_store(
break;
case TGSI_SAT_MINUS_PLUS_ONE:
value = lp_build_max(&bld->base, value, lp_build_const_vec(bld->base.type, -1.0));
value = lp_build_max(&bld->base, value, lp_build_const_vec(bld->base.gallivm, bld->base.type, -1.0));
value = lp_build_min(&bld->base, value, bld->base.one);
break;
@@ -344,20 +344,20 @@ emit_store(
assert(inst->Predicate.Index < LP_MAX_TGSI_PREDS);
pred = LLVMBuildLoad(bld->base.builder,
pred = LLVMBuildLoad(builder,
bld->preds[inst->Predicate.Index], "");
/*
* Convert the value to an integer mask.
*/
pred = lp_build_compare(bld->base.builder,
pred = lp_build_compare(bld->base.gallivm,
bld->base.type,
PIPE_FUNC_NOTEQUAL,
pred,
bld->base.zero);
if (inst->Predicate.Negate) {
pred = LLVMBuildNot(bld->base.builder, pred, "");
pred = LLVMBuildNot(builder, pred, "");
}
pred = swizzle_aos(bld, pred,
@@ -367,7 +367,7 @@ emit_store(
inst->Predicate.SwizzleW);
if (mask) {
mask = LLVMBuildAnd(bld->base.builder, mask, pred, "");
mask = LLVMBuildAnd(builder, mask, pred, "");
} else {
mask = pred;
}
@@ -380,10 +380,11 @@ emit_store(
if (reg->Register.WriteMask != TGSI_WRITEMASK_XYZW) {
LLVMValueRef writemask;
writemask = lp_build_const_mask_aos(bld->base.type, reg->Register.WriteMask);
writemask = lp_build_const_mask_aos(bld->base.gallivm, bld->base.type,
reg->Register.WriteMask);
if (mask) {
mask = LLVMBuildAnd(bld->base.builder, mask, writemask, "");
mask = LLVMBuildAnd(builder, mask, writemask, "");
} else {
mask = writemask;
}
@@ -392,12 +393,12 @@ emit_store(
if (mask) {
LLVMValueRef orig_value;
orig_value = LLVMBuildLoad(bld->base.builder, ptr, "");
orig_value = LLVMBuildLoad(builder, ptr, "");
value = lp_build_select(&bld->base,
mask, value, orig_value);
}
LLVMBuildStore(bld->base.builder, value, ptr);
LLVMBuildStore(builder, value, ptr);
}
@@ -454,7 +455,8 @@ emit_declaration(
struct lp_build_tgsi_aos_context *bld,
const struct tgsi_full_declaration *decl)
{
LLVMTypeRef vec_type = lp_build_vec_type(bld->base.type);
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMTypeRef vec_type = lp_build_vec_type(bld->base.gallivm, bld->base.type);
unsigned first = decl->Range.First;
unsigned last = decl->Range.Last;
@@ -465,31 +467,26 @@ emit_declaration(
case TGSI_FILE_TEMPORARY:
assert(idx < LP_MAX_TGSI_TEMPS);
if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(),
last + 1, 0);
bld->temps_array = lp_build_array_alloca(bld->base.builder,
LLVMValueRef array_size = lp_build_const_int32(gallivm, last + 1);
bld->temps_array = lp_build_array_alloca(bld->base.gallivm,
vec_type, array_size, "");
} else {
bld->temps[idx] = lp_build_alloca(bld->base.builder,
vec_type, "");
bld->temps[idx] = lp_build_alloca(gallivm, vec_type, "");
}
break;
case TGSI_FILE_OUTPUT:
bld->outputs[idx] = lp_build_alloca(bld->base.builder,
vec_type, "");
bld->outputs[idx] = lp_build_alloca(gallivm, vec_type, "");
break;
case TGSI_FILE_ADDRESS:
assert(idx < LP_MAX_TGSI_ADDRS);
bld->addr[idx] = lp_build_alloca(bld->base.builder,
vec_type, "");
bld->addr[idx] = lp_build_alloca(gallivm, vec_type, "");
break;
case TGSI_FILE_PREDICATE:
assert(idx < LP_MAX_TGSI_PREDS);
bld->preds[idx] = lp_build_alloca(bld->base.builder,
vec_type, "");
bld->preds[idx] = lp_build_alloca(gallivm, vec_type, "");
break;
default:
@@ -644,7 +641,7 @@ emit_instruction(
src0 = emit_fetch(bld, inst, 0);
src1 = emit_fetch(bld, inst, 1);
src2 = emit_fetch(bld, inst, 2);
tmp1 = lp_build_const_vec(bld->base.type, 0.5);
tmp1 = lp_build_const_vec(bld->base.gallivm, bld->base.type, 0.5);
tmp0 = lp_build_cmp(&bld->base, PIPE_FUNC_GREATER, src2, tmp1);
dst0 = lp_build_select(&bld->base, tmp0, src0, src1);
break;
@@ -1039,7 +1036,7 @@ emit_instruction(
void
lp_build_tgsi_aos(LLVMBuilderRef builder,
lp_build_tgsi_aos(struct gallivm_state *gallivm,
const struct tgsi_token *tokens,
struct lp_type type,
const unsigned char swizzles[4],
@@ -1058,8 +1055,8 @@ lp_build_tgsi_aos(LLVMBuilderRef builder,
/* Setup build context */
memset(&bld, 0, sizeof bld);
lp_build_context_init(&bld.base, builder, type);
lp_build_context_init(&bld.int_bld, builder, lp_int_type(type));
lp_build_context_init(&bld.base, gallivm, type);
lp_build_context_init(&bld.int_bld, gallivm, lp_int_type(type));
for (chan = 0; chan < 4; ++chan) {
bld.swizzles[chan] = swizzles[chan];
@@ -1131,7 +1128,7 @@ lp_build_tgsi_aos(LLVMBuilderRef builder,
imm[swizzle] = parse.FullToken.FullImmediate.u[chan].Float;
}
bld.immediates[num_immediates] =
lp_build_const_aos(type,
lp_build_const_aos(gallivm, type,
imm[0], imm[1], imm[2], imm[3],
NULL);
num_immediates++;
@@ -1156,7 +1153,7 @@ lp_build_tgsi_aos(LLVMBuilderRef builder,
}
if (0) {
LLVMBasicBlockRef block = LLVMGetInsertBlock(builder);
LLVMBasicBlockRef block = LLVMGetInsertBlock(gallivm->builder);
LLVMValueRef function = LLVMGetBasicBlockParent(block);
debug_printf("11111111111111111111111111111 \n");
tgsi_dump(tokens, 0);
@@ -1167,7 +1164,7 @@ lp_build_tgsi_aos(LLVMBuilderRef builder,
if (0) {
LLVMModuleRef module = LLVMGetGlobalParent(
LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld.base.builder)));
LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder)));
LLVMDumpModule(module);
}

View File

@@ -51,6 +51,7 @@
#include "lp_bld_arit.h"
#include "lp_bld_bitarit.h"
#include "lp_bld_gather.h"
#include "lp_bld_init.h"
#include "lp_bld_logic.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_flow.h"
@@ -144,6 +145,18 @@ struct lp_build_tgsi_soa_context
*/
LLVMValueRef temps_array;
/* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is
* set in the indirect_files field.
* The outputs[] array above is unused then.
*/
LLVMValueRef outputs_array;
/* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is
* set in the indirect_files field.
* The inputs[] array above is unused then.
*/
LLVMValueRef inputs_array;
const struct tgsi_shader_info *info;
/** bitmask indicating which register files are accessed indirectly */
unsigned indirect_files;
@@ -163,22 +176,24 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context
mask->loop_stack_size = 0;
mask->call_stack_size = 0;
mask->int_vec_type = lp_build_int_vec_type(mask->bld->type);
mask->int_vec_type = lp_build_int_vec_type(bld->gallivm, mask->bld->type);
mask->exec_mask = mask->ret_mask = mask->break_mask = mask->cont_mask = mask->cond_mask =
LLVMConstAllOnes(mask->int_vec_type);
}
static void lp_exec_mask_update(struct lp_exec_mask *mask)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
if (mask->loop_stack_size) {
/*for loops we need to update the entire mask at runtime */
LLVMValueRef tmp;
assert(mask->break_mask);
tmp = LLVMBuildAnd(mask->bld->builder,
tmp = LLVMBuildAnd(builder,
mask->cont_mask,
mask->break_mask,
"maskcb");
mask->exec_mask = LLVMBuildAnd(mask->bld->builder,
mask->exec_mask = LLVMBuildAnd(builder,
mask->cond_mask,
tmp,
"maskfull");
@@ -186,7 +201,7 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask)
mask->exec_mask = mask->cond_mask;
if (mask->call_stack_size) {
mask->exec_mask = LLVMBuildAnd(mask->bld->builder,
mask->exec_mask = LLVMBuildAnd(builder,
mask->exec_mask,
mask->ret_mask,
"callmask");
@@ -200,13 +215,15 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask)
static void lp_exec_mask_cond_push(struct lp_exec_mask *mask,
LLVMValueRef val)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
assert(mask->cond_stack_size < LP_MAX_TGSI_NESTING);
if (mask->cond_stack_size == 0) {
assert(mask->cond_mask == LLVMConstAllOnes(mask->int_vec_type));
}
mask->cond_stack[mask->cond_stack_size++] = mask->cond_mask;
assert(LLVMTypeOf(val) == mask->int_vec_type);
mask->cond_mask = LLVMBuildAnd(mask->bld->builder,
mask->cond_mask = LLVMBuildAnd(builder,
mask->cond_mask,
val,
"");
@@ -215,6 +232,7 @@ static void lp_exec_mask_cond_push(struct lp_exec_mask *mask,
static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMValueRef prev_mask;
LLVMValueRef inv_mask;
@@ -224,9 +242,9 @@ static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask)
assert(prev_mask == LLVMConstAllOnes(mask->int_vec_type));
}
inv_mask = LLVMBuildNot(mask->bld->builder, mask->cond_mask, "");
inv_mask = LLVMBuildNot(builder, mask->cond_mask, "");
mask->cond_mask = LLVMBuildAnd(mask->bld->builder,
mask->cond_mask = LLVMBuildAnd(builder,
inv_mask,
prev_mask, "");
lp_exec_mask_update(mask);
@@ -241,6 +259,8 @@ static void lp_exec_mask_cond_pop(struct lp_exec_mask *mask)
static void lp_exec_bgnloop(struct lp_exec_mask *mask)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
if (mask->loop_stack_size == 0) {
assert(mask->loop_block == NULL);
assert(mask->cont_mask == LLVMConstAllOnes(mask->int_vec_type));
@@ -256,25 +276,26 @@ static void lp_exec_bgnloop(struct lp_exec_mask *mask)
mask->loop_stack[mask->loop_stack_size].break_var = mask->break_var;
++mask->loop_stack_size;
mask->break_var = lp_build_alloca(mask->bld->builder, mask->int_vec_type, "");
LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var);
mask->break_var = lp_build_alloca(mask->bld->gallivm, mask->int_vec_type, "");
LLVMBuildStore(builder, mask->break_mask, mask->break_var);
mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop");
LLVMBuildBr(mask->bld->builder, mask->loop_block);
LLVMPositionBuilderAtEnd(mask->bld->builder, mask->loop_block);
mask->loop_block = lp_build_insert_new_block(mask->bld->gallivm, "bgnloop");
LLVMBuildBr(builder, mask->loop_block);
LLVMPositionBuilderAtEnd(builder, mask->loop_block);
mask->break_mask = LLVMBuildLoad(mask->bld->builder, mask->break_var, "");
mask->break_mask = LLVMBuildLoad(builder, mask->break_var, "");
lp_exec_mask_update(mask);
}
static void lp_exec_break(struct lp_exec_mask *mask)
{
LLVMValueRef exec_mask = LLVMBuildNot(mask->bld->builder,
LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMValueRef exec_mask = LLVMBuildNot(builder,
mask->exec_mask,
"break");
mask->break_mask = LLVMBuildAnd(mask->bld->builder,
mask->break_mask = LLVMBuildAnd(builder,
mask->break_mask,
exec_mask, "break_full");
@@ -283,11 +304,12 @@ static void lp_exec_break(struct lp_exec_mask *mask)
static void lp_exec_continue(struct lp_exec_mask *mask)
{
LLVMValueRef exec_mask = LLVMBuildNot(mask->bld->builder,
LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMValueRef exec_mask = LLVMBuildNot(builder,
mask->exec_mask,
"");
mask->cont_mask = LLVMBuildAnd(mask->bld->builder,
mask->cont_mask = LLVMBuildAnd(builder,
mask->cont_mask,
exec_mask, "");
@@ -295,11 +317,14 @@ static void lp_exec_continue(struct lp_exec_mask *mask)
}
static void lp_exec_endloop(struct lp_exec_mask *mask)
static void lp_exec_endloop(struct gallivm_state *gallivm,
struct lp_exec_mask *mask)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMBasicBlockRef endloop;
LLVMTypeRef reg_type = LLVMIntType(mask->bld->type.width*
mask->bld->type.length);
LLVMTypeRef reg_type = LLVMIntTypeInContext(gallivm->context,
mask->bld->type.width *
mask->bld->type.length);
LLVMValueRef i1cond;
assert(mask->break_mask);
@@ -315,21 +340,21 @@ static void lp_exec_endloop(struct lp_exec_mask *mask)
* Unlike the continue mask, the break_mask must be preserved across loop
* iterations
*/
LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var);
LLVMBuildStore(builder, mask->break_mask, mask->break_var);
/* i1cond = (mask == 0) */
i1cond = LLVMBuildICmp(
mask->bld->builder,
builder,
LLVMIntNE,
LLVMBuildBitCast(mask->bld->builder, mask->exec_mask, reg_type, ""),
LLVMBuildBitCast(builder, mask->exec_mask, reg_type, ""),
LLVMConstNull(reg_type), "");
endloop = lp_build_insert_new_block(mask->bld->builder, "endloop");
endloop = lp_build_insert_new_block(mask->bld->gallivm, "endloop");
LLVMBuildCondBr(mask->bld->builder,
LLVMBuildCondBr(builder,
i1cond, mask->loop_block, endloop);
LLVMPositionBuilderAtEnd(mask->bld->builder, endloop);
LLVMPositionBuilderAtEnd(builder, endloop);
assert(mask->loop_stack_size);
--mask->loop_stack_size;
@@ -351,10 +376,12 @@ static void lp_exec_mask_store(struct lp_exec_mask *mask,
LLVMValueRef val,
LLVMValueRef dst)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
/* Mix the predicate and execution mask */
if (mask->has_mask) {
if (pred) {
pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, "");
pred = LLVMBuildAnd(builder, pred, mask->exec_mask, "");
} else {
pred = mask->exec_mask;
}
@@ -363,14 +390,14 @@ static void lp_exec_mask_store(struct lp_exec_mask *mask,
if (pred) {
LLVMValueRef real_val, dst_val;
dst_val = LLVMBuildLoad(mask->bld->builder, dst, "");
dst_val = LLVMBuildLoad(builder, dst, "");
real_val = lp_build_select(mask->bld,
pred,
val, dst_val);
LLVMBuildStore(mask->bld->builder, real_val, dst);
LLVMBuildStore(builder, real_val, dst);
} else
LLVMBuildStore(mask->bld->builder, val, dst);
LLVMBuildStore(builder, val, dst);
}
static void lp_exec_mask_call(struct lp_exec_mask *mask,
@@ -386,6 +413,7 @@ static void lp_exec_mask_call(struct lp_exec_mask *mask,
static void lp_exec_mask_ret(struct lp_exec_mask *mask, int *pc)
{
LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMValueRef exec_mask;
if (mask->call_stack_size == 0) {
@@ -393,11 +421,11 @@ static void lp_exec_mask_ret(struct lp_exec_mask *mask, int *pc)
*pc = -1;
return;
}
exec_mask = LLVMBuildNot(mask->bld->builder,
exec_mask = LLVMBuildNot(builder,
mask->exec_mask,
"ret");
mask->ret_mask = LLVMBuildAnd(mask->bld->builder,
mask->ret_mask = LLVMBuildAnd(builder,
mask->ret_mask,
exec_mask, "ret_full");
@@ -429,16 +457,39 @@ get_temp_ptr(struct lp_build_tgsi_soa_context *bld,
unsigned index,
unsigned chan)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
assert(chan < 4);
if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
LLVMValueRef lindex = lp_build_const_int32(index * 4 + chan);
return LLVMBuildGEP(bld->base.builder, bld->temps_array, &lindex, 1, "");
LLVMValueRef lindex = lp_build_const_int32(bld->base.gallivm, index * 4 + chan);
return LLVMBuildGEP(builder, bld->temps_array, &lindex, 1, "");
}
else {
return bld->temps[index][chan];
}
}
/**
* Return pointer to a output register channel (src or dest).
* Note that indirect addressing cannot be handled here.
* \param index which output register
* \param chan which channel of the output register.
*/
static LLVMValueRef
get_output_ptr(struct lp_build_tgsi_soa_context *bld,
unsigned index,
unsigned chan)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
assert(chan < 4);
if (bld->indirect_files & (1 << TGSI_FILE_OUTPUT)) {
LLVMValueRef lindex = lp_build_const_int32(bld->base.gallivm,
index * 4 + chan);
return LLVMBuildGEP(builder, bld->outputs_array, &lindex, 1, "");
}
else {
return bld->outputs[index][chan];
}
}
/**
* Gather vector.
@@ -450,6 +501,7 @@ build_gather(struct lp_build_tgsi_soa_context *bld,
LLVMValueRef base_ptr,
LLVMValueRef indexes)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
LLVMValueRef res = bld->base.undef;
unsigned i;
@@ -457,14 +509,14 @@ build_gather(struct lp_build_tgsi_soa_context *bld,
* Loop over elements of index_vec, load scalar value, insert it into 'res'.
*/
for (i = 0; i < bld->base.type.length; i++) {
LLVMValueRef ii = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef index = LLVMBuildExtractElement(bld->base.builder,
LLVMValueRef ii = lp_build_const_int32(bld->base.gallivm, i);
LLVMValueRef index = LLVMBuildExtractElement(builder,
indexes, ii, "");
LLVMValueRef scalar_ptr = LLVMBuildGEP(bld->base.builder, base_ptr,
LLVMValueRef scalar_ptr = LLVMBuildGEP(builder, base_ptr,
&index, 1, "gather_ptr");
LLVMValueRef scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
LLVMValueRef scalar = LLVMBuildLoad(builder, scalar_ptr, "");
res = LLVMBuildInsertElement(bld->base.builder, res, scalar, ii, "");
res = LLVMBuildInsertElement(builder, res, scalar, ii, "");
}
return res;
@@ -482,13 +534,14 @@ emit_mask_scatter(struct lp_build_tgsi_soa_context *bld,
struct lp_exec_mask *mask,
LLVMValueRef pred)
{
LLVMBuilderRef builder = bld->base.builder;
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
unsigned i;
/* Mix the predicate and execution mask */
if (mask->has_mask) {
if (pred) {
pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, "");
pred = LLVMBuildAnd(builder, pred, mask->exec_mask, "");
}
else {
pred = mask->exec_mask;
@@ -499,7 +552,7 @@ emit_mask_scatter(struct lp_build_tgsi_soa_context *bld,
* Loop over elements of index_vec, store scalar value.
*/
for (i = 0; i < bld->base.type.length; i++) {
LLVMValueRef ii = LLVMConstInt(LLVMInt32Type(), i, 0);
LLVMValueRef ii = lp_build_const_int32(gallivm, i);
LLVMValueRef index = LLVMBuildExtractElement(builder, indexes, ii, "");
LLVMValueRef scalar_ptr = LLVMBuildGEP(builder, base_ptr, &index, 1, "scatter_ptr");
LLVMValueRef val = LLVMBuildExtractElement(builder, values, ii, "scatter_val");
@@ -507,7 +560,7 @@ emit_mask_scatter(struct lp_build_tgsi_soa_context *bld,
LLVMBuildExtractElement(builder, pred, ii, "scatter_pred") : NULL;
if (0)
lp_build_printf(builder, "scatter %d: val %f at %d %p\n",
lp_build_printf(gallivm, "scatter %d: val %f at %d %p\n",
ii, val, index, scalar_ptr);
if (scalar_pred) {
@@ -534,6 +587,7 @@ get_indirect_index(struct lp_build_tgsi_soa_context *bld,
unsigned reg_file, unsigned reg_index,
const struct tgsi_src_register *indirect_reg)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
struct lp_build_context *uint_bld = &bld->uint_bld;
/* always use X component of address register */
unsigned swizzle = indirect_reg->SwizzleX;
@@ -544,21 +598,22 @@ get_indirect_index(struct lp_build_tgsi_soa_context *bld,
assert(bld->indirect_files & (1 << reg_file));
base = lp_build_const_int_vec(uint_bld->type, reg_index);
base = lp_build_const_int_vec(bld->base.gallivm, uint_bld->type, reg_index);
assert(swizzle < 4);
rel = LLVMBuildLoad(bld->base.builder,
rel = LLVMBuildLoad(builder,
bld->addr[indirect_reg->Index][swizzle],
"load addr reg");
/* for indexing we want integers */
rel = LLVMBuildFPToSI(bld->base.builder,
rel = LLVMBuildFPToSI(builder,
rel,
uint_bld->vec_type, "");
index = lp_build_add(uint_bld, base, rel);
max_index = lp_build_const_int_vec(uint_bld->type,
max_index = lp_build_const_int_vec(bld->base.gallivm,
uint_bld->type,
bld->info->file_max[reg_file]);
assert(!uint_bld->type.sign);
@@ -578,6 +633,8 @@ emit_fetch(
unsigned src_op,
const unsigned chan_index )
{
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
struct lp_build_context *uint_bld = &bld->uint_bld;
const struct tgsi_full_src_register *reg = &inst->Src[src_op];
const unsigned swizzle =
@@ -603,7 +660,7 @@ emit_fetch(
case TGSI_FILE_CONSTANT:
if (reg->Register.Indirect) {
LLVMValueRef swizzle_vec =
lp_build_const_int_vec(uint_bld->type, swizzle);
lp_build_const_int_vec(bld->base.gallivm, uint_bld->type, swizzle);
LLVMValueRef index_vec; /* index into the const buffer */
/* index_vec = indirect_index * 4 + swizzle */
@@ -617,11 +674,11 @@ emit_fetch(
LLVMValueRef index; /* index into the const buffer */
LLVMValueRef scalar, scalar_ptr;
index = lp_build_const_int32(reg->Register.Index*4 + swizzle);
index = lp_build_const_int32(gallivm, reg->Register.Index*4 + swizzle);
scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr,
scalar_ptr = LLVMBuildGEP(builder, bld->consts_ptr,
&index, 1, "");
scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
scalar = LLVMBuildLoad(builder, scalar_ptr, "");
res = lp_build_broadcast_scalar(&bld->base, scalar);
}
@@ -633,16 +690,49 @@ emit_fetch(
break;
case TGSI_FILE_INPUT:
res = bld->inputs[reg->Register.Index][swizzle];
if (reg->Register.Indirect) {
LLVMValueRef swizzle_vec =
lp_build_const_int_vec(gallivm, uint_bld->type, swizzle);
LLVMValueRef length_vec =
lp_build_const_int_vec(gallivm, uint_bld->type, bld->base.type.length);
LLVMValueRef index_vec; /* index into the const buffer */
LLVMValueRef inputs_array;
LLVMTypeRef float4_ptr_type;
/* index_vec = (indirect_index * 4 + swizzle) * length */
index_vec = lp_build_shl_imm(uint_bld, indirect_index, 2);
index_vec = lp_build_add(uint_bld, index_vec, swizzle_vec);
index_vec = lp_build_mul(uint_bld, index_vec, length_vec);
/* cast inputs_array pointer to float* */
float4_ptr_type = LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0);
inputs_array = LLVMBuildBitCast(builder, bld->inputs_array,
float4_ptr_type, "");
/* Gather values from the temporary register array */
res = build_gather(bld, inputs_array, index_vec);
} else {
if (bld->indirect_files & (1 << TGSI_FILE_INPUT)) {
LLVMValueRef lindex = lp_build_const_int32(gallivm,
reg->Register.Index * 4 + swizzle);
LLVMValueRef input_ptr = LLVMBuildGEP(builder,
bld->inputs_array, &lindex, 1, "");
res = LLVMBuildLoad(builder, input_ptr, "");
}
else {
res = bld->inputs[reg->Register.Index][swizzle];
}
}
assert(res);
break;
case TGSI_FILE_TEMPORARY:
if (reg->Register.Indirect) {
LLVMValueRef swizzle_vec =
lp_build_const_int_vec(uint_bld->type, swizzle);
lp_build_const_int_vec(bld->base.gallivm, uint_bld->type, swizzle);
LLVMValueRef length_vec =
lp_build_const_int_vec(uint_bld->type, bld->base.type.length);
lp_build_const_int_vec(bld->base.gallivm, uint_bld->type,
bld->base.type.length);
LLVMValueRef index_vec; /* index into the const buffer */
LLVMValueRef temps_array;
LLVMTypeRef float4_ptr_type;
@@ -653,8 +743,8 @@ emit_fetch(
index_vec = lp_build_mul(uint_bld, index_vec, length_vec);
/* cast temps_array pointer to float* */
float4_ptr_type = LLVMPointerType(LLVMFloatType(), 0);
temps_array = LLVMBuildBitCast(uint_bld->builder, bld->temps_array,
float4_ptr_type = LLVMPointerType(LLVMFloatTypeInContext(bld->base.gallivm->context), 0);
temps_array = LLVMBuildBitCast(builder, bld->temps_array,
float4_ptr_type, "");
/* Gather values from the temporary register array */
@@ -663,7 +753,7 @@ emit_fetch(
else {
LLVMValueRef temp_ptr;
temp_ptr = get_temp_ptr(bld, reg->Register.Index, swizzle);
res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
res = LLVMBuildLoad(builder, temp_ptr, "");
if (!res)
return bld->base.undef;
}
@@ -733,6 +823,7 @@ emit_fetch_predicate(
const struct tgsi_full_instruction *inst,
LLVMValueRef *pred)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
unsigned index;
unsigned char swizzles[4];
LLVMValueRef unswizzled[4] = {NULL, NULL, NULL, NULL};
@@ -762,7 +853,7 @@ emit_fetch_predicate(
* in the swizzles
*/
if (!unswizzled[swizzle]) {
value = LLVMBuildLoad(bld->base.builder,
value = LLVMBuildLoad(builder,
bld->preds[index][swizzle], "");
/*
@@ -772,13 +863,13 @@ emit_fetch_predicate(
* is needlessly causing two comparisons due to storing the intermediate
* result as float vector instead of an integer mask vector.
*/
value = lp_build_compare(bld->base.builder,
value = lp_build_compare(bld->base.gallivm,
bld->base.type,
PIPE_FUNC_NOTEQUAL,
value,
bld->base.zero);
if (inst->Predicate.Negate) {
value = LLVMBuildNot(bld->base.builder, value, "");
value = LLVMBuildNot(builder, value, "");
}
unswizzled[swizzle] = value;
@@ -803,6 +894,8 @@ emit_store(
LLVMValueRef pred,
LLVMValueRef value)
{
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
const struct tgsi_full_dst_register *reg = &inst->Dst[index];
struct lp_build_context *uint_bld = &bld->uint_bld;
LLVMValueRef indirect_index = NULL;
@@ -817,7 +910,7 @@ emit_store(
break;
case TGSI_SAT_MINUS_PLUS_ONE:
value = lp_build_max(&bld->base, value, lp_build_const_vec(bld->base.type, -1.0));
value = lp_build_max(&bld->base, value, lp_build_const_vec(bld->base.gallivm, bld->base.type, -1.0));
value = lp_build_min(&bld->base, value, bld->base.one);
break;
@@ -836,27 +929,21 @@ emit_store(
switch( reg->Register.File ) {
case TGSI_FILE_OUTPUT:
lp_exec_mask_store(&bld->exec_mask, pred, value,
bld->outputs[reg->Register.Index][chan_index]);
break;
case TGSI_FILE_TEMPORARY:
if (reg->Register.Indirect) {
LLVMBuilderRef builder = bld->base.builder;
LLVMValueRef chan_vec =
lp_build_const_int_vec(uint_bld->type, chan_index);
lp_build_const_int_vec(gallivm, uint_bld->type, chan_index);
LLVMValueRef length_vec =
lp_build_const_int_vec(uint_bld->type, bld->base.type.length);
lp_build_const_int_vec(gallivm, uint_bld->type, bld->base.type.length);
LLVMValueRef index_vec; /* indexes into the temp registers */
LLVMValueRef temps_array;
LLVMValueRef outputs_array;
LLVMValueRef pixel_offsets;
LLVMTypeRef float_ptr_type;
int i;
/* build pixel offset vector: {0, 1, 2, 3, ...} */
pixel_offsets = uint_bld->undef;
pixel_offsets = uint_bld->undef;
for (i = 0; i < bld->base.type.length; i++) {
LLVMValueRef ii = lp_build_const_int32(i);
LLVMValueRef ii = lp_build_const_int32(gallivm, i);
pixel_offsets = LLVMBuildInsertElement(builder, pixel_offsets,
ii, ii, "");
}
@@ -867,7 +954,51 @@ emit_store(
index_vec = lp_build_mul(uint_bld, index_vec, length_vec);
index_vec = lp_build_add(uint_bld, index_vec, pixel_offsets);
float_ptr_type = LLVMPointerType(LLVMFloatType(), 0);
float_ptr_type =
LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0);
outputs_array = LLVMBuildBitCast(builder, bld->outputs_array,
float_ptr_type, "");
/* Scatter store values into temp registers */
emit_mask_scatter(bld, outputs_array, index_vec, value,
&bld->exec_mask, pred);
}
else {
LLVMValueRef out_ptr = get_output_ptr(bld, reg->Register.Index,
chan_index);
lp_exec_mask_store(&bld->exec_mask, pred, value, out_ptr);
}
break;
case TGSI_FILE_TEMPORARY:
if (reg->Register.Indirect) {
LLVMValueRef chan_vec =
lp_build_const_int_vec(gallivm, uint_bld->type, chan_index);
LLVMValueRef length_vec =
lp_build_const_int_vec(gallivm, uint_bld->type,
bld->base.type.length);
LLVMValueRef index_vec; /* indexes into the temp registers */
LLVMValueRef temps_array;
LLVMValueRef pixel_offsets;
LLVMTypeRef float_ptr_type;
int i;
/* build pixel offset vector: {0, 1, 2, 3, ...} */
pixel_offsets = uint_bld->undef;
for (i = 0; i < bld->base.type.length; i++) {
LLVMValueRef ii = lp_build_const_int32(gallivm, i);
pixel_offsets = LLVMBuildInsertElement(builder, pixel_offsets,
ii, ii, "");
}
/* index_vec = (indirect_index * 4 + chan_index) * length + offsets */
index_vec = lp_build_shl_imm(uint_bld, indirect_index, 2);
index_vec = lp_build_add(uint_bld, index_vec, chan_vec);
index_vec = lp_build_mul(uint_bld, index_vec, length_vec);
index_vec = lp_build_add(uint_bld, index_vec, pixel_offsets);
float_ptr_type =
LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0);
temps_array = LLVMBuildBitCast(builder, bld->temps_array,
float_ptr_type, "");
@@ -884,7 +1015,7 @@ emit_store(
case TGSI_FILE_ADDRESS:
lp_exec_mask_store(&bld->exec_mask, pred, value,
bld->addr[reg->Indirect.Index][chan_index]);
bld->addr[reg->Register.Index][chan_index]);
break;
case TGSI_FILE_PREDICATE:
@@ -908,6 +1039,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
enum lp_build_tex_modifier modifier,
LLVMValueRef *texel)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
unsigned unit;
LLVMValueRef lod_bias, explicit_lod;
LLVMValueRef oow = NULL;
@@ -973,13 +1105,12 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
}
if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) {
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef index0 = LLVMConstInt(i32t, 0, 0);
LLVMValueRef index0 = lp_build_const_int32(bld->base.gallivm, 0);
for (i = 0; i < num_coords; i++) {
LLVMValueRef src1 = emit_fetch( bld, inst, 1, i );
LLVMValueRef src2 = emit_fetch( bld, inst, 2, i );
ddx[i] = LLVMBuildExtractElement(bld->base.builder, src1, index0, "");
ddy[i] = LLVMBuildExtractElement(bld->base.builder, src2, index0, "");
ddx[i] = LLVMBuildExtractElement(builder, src1, index0, "");
ddy[i] = LLVMBuildExtractElement(builder, src2, index0, "");
}
unit = inst->Src[3].Register.Index;
} else {
@@ -995,7 +1126,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
}
bld->sampler->emit_fetch_texel(bld->sampler,
bld->base.builder,
bld->base.gallivm,
bld->base.type,
unit, num_coords, coords,
ddx, ddy,
@@ -1050,6 +1181,7 @@ emit_kil(
const struct tgsi_full_instruction *inst,
int pc)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
const struct tgsi_full_src_register *reg = &inst->Src[0];
LLVMValueRef terms[NUM_CHANNELS];
LLVMValueRef mask;
@@ -1081,7 +1213,7 @@ emit_kil(
chan_mask = lp_build_cmp(&bld->base, PIPE_FUNC_GEQUAL, terms[chan_index], bld->base.zero);
if(mask)
mask = LLVMBuildAnd(bld->base.builder, mask, chan_mask, "");
mask = LLVMBuildAnd(builder, mask, chan_mask, "");
else
mask = chan_mask;
}
@@ -1107,13 +1239,14 @@ emit_kilp(struct lp_build_tgsi_soa_context *bld,
const struct tgsi_full_instruction *inst,
int pc)
{
LLVMBuilderRef builder = bld->base.gallivm->builder;
LLVMValueRef mask;
/* For those channels which are "alive", disable fragment shader
* execution.
*/
if (bld->exec_mask.has_mask) {
mask = LLVMBuildNot(bld->base.builder, bld->exec_mask.exec_mask, "kilp");
mask = LLVMBuildNot(builder, bld->exec_mask.exec_mask, "kilp");
}
else {
LLVMValueRef zero = LLVMConstNull(bld->base.int_vec_type);
@@ -1134,38 +1267,39 @@ emit_kilp(struct lp_build_tgsi_soa_context *bld,
static void
emit_dump_temps(struct lp_build_tgsi_soa_context *bld)
{
LLVMBuilderRef builder = bld->base.builder;
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef temp_ptr;
LLVMValueRef i0 = lp_build_const_int32(0);
LLVMValueRef i1 = lp_build_const_int32(1);
LLVMValueRef i2 = lp_build_const_int32(2);
LLVMValueRef i3 = lp_build_const_int32(3);
LLVMValueRef i0 = lp_build_const_int32(gallivm, 0);
LLVMValueRef i1 = lp_build_const_int32(gallivm, 1);
LLVMValueRef i2 = lp_build_const_int32(gallivm, 2);
LLVMValueRef i3 = lp_build_const_int32(gallivm, 3);
int index;
int n = bld->info->file_max[TGSI_FILE_TEMPORARY];
for (index = 0; index < n; index++) {
LLVMValueRef idx = lp_build_const_int32(index);
LLVMValueRef idx = lp_build_const_int32(gallivm, index);
LLVMValueRef v[4][4], res;
int chan;
lp_build_printf(builder, "TEMP[%d]:\n", idx);
lp_build_printf(gallivm, "TEMP[%d]:\n", idx);
for (chan = 0; chan < 4; chan++) {
temp_ptr = get_temp_ptr(bld, index, chan);
res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
res = LLVMBuildLoad(builder, temp_ptr, "");
v[chan][0] = LLVMBuildExtractElement(builder, res, i0, "");
v[chan][1] = LLVMBuildExtractElement(builder, res, i1, "");
v[chan][2] = LLVMBuildExtractElement(builder, res, i2, "");
v[chan][3] = LLVMBuildExtractElement(builder, res, i3, "");
}
lp_build_printf(builder, " X: %f %f %f %f\n",
lp_build_printf(gallivm, " X: %f %f %f %f\n",
v[0][0], v[0][1], v[0][2], v[0][3]);
lp_build_printf(builder, " Y: %f %f %f %f\n",
lp_build_printf(gallivm, " Y: %f %f %f %f\n",
v[1][0], v[1][1], v[1][2], v[1][3]);
lp_build_printf(builder, " Z: %f %f %f %f\n",
lp_build_printf(gallivm, " Z: %f %f %f %f\n",
v[2][0], v[2][1], v[2][2], v[2][3]);
lp_build_printf(builder, " W: %f %f %f %f\n",
lp_build_printf(gallivm, " W: %f %f %f %f\n",
v[3][0], v[3][1], v[3][2], v[3][3]);
}
}
@@ -1177,6 +1311,7 @@ emit_declaration(
struct lp_build_tgsi_soa_context *bld,
const struct tgsi_full_declaration *decl)
{
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMTypeRef vec_type = bld->base.vec_type;
const unsigned first = decl->Range.First;
const unsigned last = decl->Range.Last;
@@ -1187,39 +1322,31 @@ emit_declaration(
switch (decl->Declaration.File) {
case TGSI_FILE_TEMPORARY:
assert(idx < LP_MAX_TGSI_TEMPS);
if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
/* ignore 'first' - we want to index into a 0-based array */
LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(),
last*4 + 4, 0);
bld->temps_array = lp_build_array_alloca(bld->base.builder,
vec_type, array_size,
"temporary");
idx = last;
} else {
if (!(bld->indirect_files & (1 << TGSI_FILE_TEMPORARY))) {
for (i = 0; i < NUM_CHANNELS; i++)
bld->temps[idx][i] = lp_build_alloca(bld->base.builder,
vec_type, "temp");
bld->temps[idx][i] = lp_build_alloca(gallivm, vec_type, "temp");
}
break;
case TGSI_FILE_OUTPUT:
for (i = 0; i < NUM_CHANNELS; i++)
bld->outputs[idx][i] = lp_build_alloca(bld->base.builder,
vec_type, "output");
if (!(bld->indirect_files & (1 << TGSI_FILE_OUTPUT))) {
for (i = 0; i < NUM_CHANNELS; i++)
bld->outputs[idx][i] = lp_build_alloca(gallivm,
vec_type, "output");
}
break;
case TGSI_FILE_ADDRESS:
assert(idx < LP_MAX_TGSI_ADDRS);
for (i = 0; i < NUM_CHANNELS; i++)
bld->addr[idx][i] = lp_build_alloca(bld->base.builder,
vec_type, "addr");
bld->addr[idx][i] = lp_build_alloca(gallivm, vec_type, "addr");
break;
case TGSI_FILE_PREDICATE:
assert(idx < LP_MAX_TGSI_PREDS);
for (i = 0; i < NUM_CHANNELS; i++)
bld->preds[idx][i] = lp_build_alloca(bld->base.builder,
vec_type, "predicate");
bld->preds[idx][i] = lp_build_alloca(gallivm, vec_type,
"predicate");
break;
default:
@@ -1545,7 +1672,7 @@ emit_instruction(
src0 = emit_fetch( bld, inst, 0, chan_index );
src1 = emit_fetch( bld, inst, 1, chan_index );
src2 = emit_fetch( bld, inst, 2, chan_index );
tmp1 = lp_build_const_vec(bld->base.type, 0.5);
tmp1 = lp_build_const_vec(bld->base.gallivm, bld->base.type, 0.5);
tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_GREATER, src2, tmp1);
dst0[chan_index] = lp_build_select( &bld->base, tmp0, src0, src1 );
}
@@ -2057,7 +2184,7 @@ emit_instruction(
break;
case TGSI_OPCODE_ENDLOOP:
lp_exec_endloop(&bld->exec_mask);
lp_exec_endloop(bld->base.gallivm, &bld->exec_mask);
break;
case TGSI_OPCODE_ENDSUB:
@@ -2190,7 +2317,7 @@ emit_instruction(
void
lp_build_tgsi_soa(LLVMBuilderRef builder,
lp_build_tgsi_soa(struct gallivm_state *gallivm,
const struct tgsi_token *tokens,
struct lp_type type,
struct lp_build_mask_context *mask,
@@ -2218,9 +2345,9 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
/* Setup build context */
memset(&bld, 0, sizeof bld);
lp_build_context_init(&bld.base, builder, type);
lp_build_context_init(&bld.uint_bld, builder, lp_uint_type(type));
lp_build_context_init(&bld.elem_bld, builder, lp_elem_type(type));
lp_build_context_init(&bld.base, gallivm, type);
lp_build_context_init(&bld.uint_bld, gallivm, lp_uint_type(type));
lp_build_context_init(&bld.elem_bld, gallivm, lp_elem_type(type));
bld.mask = mask;
bld.pos = pos;
bld.inputs = inputs;
@@ -2239,6 +2366,51 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
lp_exec_mask_init(&bld.exec_mask, &bld.base);
if (bld.indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
LLVMValueRef array_size =
lp_build_const_int32(gallivm,
info->file_max[TGSI_FILE_TEMPORARY] * 4 + 4);
bld.temps_array = lp_build_array_alloca(gallivm,
bld.base.vec_type, array_size,
"temp_array");
}
if (bld.indirect_files & (1 << TGSI_FILE_OUTPUT)) {
LLVMValueRef array_size =
lp_build_const_int32(gallivm,
info->file_max[TGSI_FILE_OUTPUT] * 4 + 4);
bld.outputs_array = lp_build_array_alloca(gallivm,
bld.base.vec_type, array_size,
"output_array");
}
/* If we have indirect addressing in inputs we need to copy them into
* our alloca array to be able to iterate over them */
if (bld.indirect_files & (1 << TGSI_FILE_INPUT)) {
unsigned index, chan;
LLVMTypeRef vec_type = bld.base.vec_type;
LLVMValueRef array_size =
lp_build_const_int32(gallivm, info->file_max[TGSI_FILE_INPUT]*4 + 4);
bld.inputs_array = lp_build_array_alloca(gallivm,
vec_type, array_size,
"input_array");
assert(info->num_inputs <= info->file_max[TGSI_FILE_INPUT] + 1);
for (index = 0; index < info->num_inputs; ++index) {
for (chan = 0; chan < NUM_CHANNELS; ++chan) {
LLVMValueRef lindex =
lp_build_const_int32(gallivm, index * 4 + chan);
LLVMValueRef input_ptr =
LLVMBuildGEP(gallivm->builder, bld.inputs_array,
&lindex, 1, "");
LLVMValueRef value = bld.inputs[index][chan];
if (value)
LLVMBuildStore(gallivm->builder, value, input_ptr);
}
}
}
tgsi_parse_init( &parse, tokens );
while( !tgsi_parse_end_of_tokens( &parse ) ) {
@@ -2284,7 +2456,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
assert(num_immediates < LP_MAX_TGSI_IMMEDIATES);
for( i = 0; i < size; ++i )
bld.immediates[num_immediates][i] =
lp_build_const_vec(type, parse.FullToken.FullImmediate.u[i].Float);
lp_build_const_vec(gallivm, type, parse.FullToken.FullImmediate.u[i].Float);
for( i = size; i < 4; ++i )
bld.immediates[num_immediates][i] = bld.base.undef;
num_immediates++;
@@ -2308,8 +2480,20 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
opcode_info->mnemonic);
}
/* If we have indirect addressing in outputs we need to copy our alloca array
* to the outputs slots specified by the called */
if (bld.indirect_files & (1 << TGSI_FILE_OUTPUT)) {
unsigned index, chan;
assert(info->num_outputs <= info->file_max[TGSI_FILE_OUTPUT] + 1);
for (index = 0; index < info->num_outputs; ++index) {
for (chan = 0; chan < NUM_CHANNELS; ++chan) {
bld.outputs[index][chan] = get_output_ptr(&bld, index, chan);
}
}
}
if (0) {
LLVMBasicBlockRef block = LLVMGetInsertBlock(builder);
LLVMBasicBlockRef block = LLVMGetInsertBlock(gallivm->builder);
LLVMValueRef function = LLVMGetBasicBlockParent(block);
debug_printf("11111111111111111111111111111 \n");
tgsi_dump(tokens, 0);
@@ -2320,7 +2504,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
if (0) {
LLVMModuleRef module = LLVMGetGlobalParent(
LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld.base.builder)));
LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder)));
LLVMDumpModule(module);
}

View File

@@ -30,34 +30,35 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_init.h"
LLVMTypeRef
lp_build_elem_type(struct lp_type type)
lp_build_elem_type(struct gallivm_state *gallivm, struct lp_type type)
{
if (type.floating) {
switch(type.width) {
case 32:
return LLVMFloatType();
return LLVMFloatTypeInContext(gallivm->context);
break;
case 64:
return LLVMDoubleType();
return LLVMDoubleTypeInContext(gallivm->context);
break;
default:
assert(0);
return LLVMFloatType();
return LLVMFloatTypeInContext(gallivm->context);
}
}
else {
return LLVMIntType(type.width);
return LLVMIntTypeInContext(gallivm->context, type.width);
}
}
LLVMTypeRef
lp_build_vec_type(struct lp_type type)
lp_build_vec_type(struct gallivm_state *gallivm,struct lp_type type)
{
LLVMTypeRef elem_type = lp_build_elem_type(type);
LLVMTypeRef elem_type = lp_build_elem_type(gallivm, type);
if (type.length == 1)
return elem_type;
else
@@ -149,16 +150,16 @@ lp_check_value(struct lp_type type, LLVMValueRef val)
LLVMTypeRef
lp_build_int_elem_type(struct lp_type type)
lp_build_int_elem_type(struct gallivm_state *gallivm, struct lp_type type)
{
return LLVMIntType(type.width);
return LLVMIntTypeInContext(gallivm->context, type.width);
}
LLVMTypeRef
lp_build_int_vec_type(struct lp_type type)
lp_build_int_vec_type(struct gallivm_state *gallivm, struct lp_type type)
{
LLVMTypeRef elem_type = lp_build_int_elem_type(type);
LLVMTypeRef elem_type = lp_build_int_elem_type(gallivm, type);
if (type.length == 1)
return elem_type;
else
@@ -170,7 +171,7 @@ lp_build_int_vec_type(struct lp_type type)
* Build int32[4] vector type
*/
LLVMTypeRef
lp_build_int32_vec4_type(void)
lp_build_int32_vec4_type(struct gallivm_state *gallivm)
{
struct lp_type t;
LLVMTypeRef type;
@@ -182,7 +183,7 @@ lp_build_int32_vec4_type(void)
t.width = 32; /* 32-bit int */
t.length = 4; /* 4 elements per vector */
type = lp_build_int_elem_type(t);
type = lp_build_int_elem_type(gallivm, t);
return LLVMVectorType(type, t.length);
}
@@ -383,15 +384,15 @@ lp_dump_llvmtype(LLVMTypeRef t)
void
lp_build_context_init(struct lp_build_context *bld,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
struct lp_type type)
{
bld->builder = builder;
bld->gallivm = gallivm;
bld->type = type;
bld->int_elem_type = lp_build_int_elem_type(type);
bld->int_elem_type = lp_build_int_elem_type(gallivm, type);
if (type.floating)
bld->elem_type = lp_build_elem_type(type);
bld->elem_type = lp_build_elem_type(gallivm, type);
else
bld->elem_type = bld->int_elem_type;
@@ -406,5 +407,5 @@ lp_build_context_init(struct lp_build_context *bld,
bld->undef = LLVMGetUndef(bld->vec_type);
bld->zero = LLVMConstNull(bld->vec_type);
bld->one = lp_build_one(type);
bld->one = lp_build_one(gallivm, type);
}

View File

@@ -120,7 +120,7 @@ struct lp_type {
*/
struct lp_build_context
{
LLVMBuilderRef builder;
struct gallivm_state *gallivm;
/**
* This not only describes the input/output LLVM types, but also whether
@@ -285,11 +285,11 @@ lp_type_ufixed(unsigned width)
LLVMTypeRef
lp_build_elem_type(struct lp_type type);
lp_build_elem_type(struct gallivm_state *gallivm, struct lp_type type);
LLVMTypeRef
lp_build_vec_type(struct lp_type type);
lp_build_vec_type(struct gallivm_state *gallivm, struct lp_type type);
boolean
@@ -305,15 +305,15 @@ lp_check_value(struct lp_type type, LLVMValueRef val);
LLVMTypeRef
lp_build_int_elem_type(struct lp_type type);
lp_build_int_elem_type(struct gallivm_state *gallivm, struct lp_type type);
LLVMTypeRef
lp_build_int_vec_type(struct lp_type type);
lp_build_int_vec_type(struct gallivm_state *gallivm, struct lp_type type);
LLVMTypeRef
lp_build_int32_vec4_type(void);
lp_build_int32_vec4_type(struct gallivm_state *gallivm);
static INLINE struct lp_type
@@ -394,7 +394,7 @@ lp_dump_llvmtype(LLVMTypeRef t);
void
lp_build_context_init(struct lp_build_context *bld,
LLVMBuilderRef builder,
struct gallivm_state *gallivm,
struct lp_type type);

View File

@@ -306,7 +306,7 @@ typedef int64_t pipe_condvar;
* pipe_barrier
*/
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)) && !defined(PIPE_OS_ANDROID)
typedef pthread_barrier_t pipe_barrier;

View File

@@ -1,68 +0,0 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
**************************************************************************/
/*
* Authors:
* Keith Whitwell
*/
#include "target-helpers/wrap_screen.h"
#include "trace/tr_public.h"
#include "rbug/rbug_public.h"
#include "identity/id_public.h"
#include "util/u_debug.h"
/* Centralized code to inject common wrapping layers:
*/
struct pipe_screen *
gallium_wrap_screen( struct pipe_screen *screen )
{
/* Screen wrapping functions are required not to fail. If it is
* impossible to wrap a screen, the unwrapped screen should be
* returned instead. Any failure condition should be returned in
* an OUT argument.
*
* Otherwise it is really messy trying to clean up in this code.
*/
if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) {
screen = identity_screen_create(screen);
}
/* Trace does its own checking if it should run */
screen = trace_screen_create(screen);
/* Rbug does its own checking if it should run */
screen = rbug_screen_create(screen);
return screen;
}

View File

@@ -1,16 +0,0 @@
#ifndef WRAP_SCREEN_HELPER_H
#define WRAP_SCREEN_HELPER_H
#include "pipe/p_compiler.h"
struct pipe_screen;
/* Centralized code to inject common wrapping layers. Other layers
* can be introduced by specific targets, but these are the generally
* helpful ones we probably want everywhere.
*/
struct pipe_screen *
gallium_wrap_screen( struct pipe_screen *screen );
#endif

View File

@@ -383,6 +383,13 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
return TGSI_EXEC_NUM_PREDS;
case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
return 1;
case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
return 1;
case PIPE_SHADER_CAP_SUBROUTINES:
return 1;
default:
return 0;
}

View File

@@ -1007,7 +1007,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
"FACE",
"EDGEFLAG",
"PRIM_ID",
"INSTANCEID"
"INSTANCEID",
"STENCIL"
};
static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =

View File

@@ -291,7 +291,7 @@ regions_overlap(int srcX0, int srcY0,
void
util_blit_pixels_writemask(struct blit_state *ctx,
struct pipe_resource *src_tex,
struct pipe_subresource srcsub,
unsigned src_level,
int srcX0, int srcY0,
int srcX1, int srcY1,
int srcZ0,
@@ -316,13 +316,12 @@ util_blit_pixels_writemask(struct blit_state *ctx,
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
filter == PIPE_TEX_MIPFILTER_LINEAR);
assert(srcsub.level <= src_tex->last_level);
assert(src_level <= src_tex->last_level);
/* do the regions overlap? */
overlap = src_tex == dst->texture &&
dst->face == srcsub.face &&
dst->level == srcsub.level &&
dst->zslice == srcZ0 &&
dst->u.tex.level == src_level &&
dst->u.tex.first_layer == srcZ0 &&
regions_overlap(srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1);
@@ -339,16 +338,19 @@ util_blit_pixels_writemask(struct blit_state *ctx,
(dstX1 - dstX0) == (srcX1 - srcX0) &&
(dstY1 - dstY0) == (srcY1 - srcY0) &&
!overlap) {
struct pipe_subresource subdst;
subdst.face = dst->face;
subdst.level = dst->level;
struct pipe_box src_box;
src_box.x = srcX0;
src_box.y = srcY0;
src_box.z = srcZ0;
src_box.width = srcW;
src_box.height = srcH;
src_box.depth = 1;
pipe->resource_copy_region(pipe,
dst->texture, subdst,
dstX0, dstY0, dst->zslice,/* dest */
src_tex, srcsub,
srcX0, srcY0, srcZ0,/* src */
srcW, srcH); /* size */
return;
dst->texture, dst->u.tex.level,
dstX0, dstY0, dst->u.tex.first_layer,/* dest */
src_tex, src_level,
&src_box);
return;
}
/* Create a temporary texture when src and dest alias or when src
@@ -359,16 +361,16 @@ util_blit_pixels_writemask(struct blit_state *ctx,
* This can still be improved upon.
*/
if ((src_tex == dst->texture &&
dst->face == srcsub.face &&
dst->level == srcsub.level &&
dst->zslice == srcZ0) ||
dst->u.tex.level == src_level &&
dst->u.tex.first_layer == srcZ0) ||
(src_tex->target != PIPE_TEXTURE_2D &&
src_tex->target != PIPE_TEXTURE_2D &&
src_tex->target != PIPE_TEXTURE_RECT))
{
struct pipe_resource texTemp;
struct pipe_resource *tex;
struct pipe_sampler_view sv_templ;
struct pipe_subresource texsub;
struct pipe_box src_box;
const int srcLeft = MIN2(srcX0, srcX1);
const int srcTop = MIN2(srcY0, srcY1);
@@ -394,19 +396,23 @@ util_blit_pixels_writemask(struct blit_state *ctx,
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
texTemp.array_size = 1;
texTemp.bind = PIPE_BIND_SAMPLER_VIEW;
tex = screen->resource_create(screen, &texTemp);
if (!tex)
return;
texsub.face = 0;
texsub.level = 0;
src_box.x = srcLeft;
src_box.y = srcTop;
src_box.z = srcZ0;
src_box.width = srcW;
src_box.height = srcH;
src_box.depth = 1;
/* load temp texture */
pipe->resource_copy_region(pipe,
tex, texsub, 0, 0, 0, /* dest */
src_tex, srcsub, srcLeft, srcTop, srcZ0, /* src */
srcW, srcH); /* size */
tex, 0, 0, 0, 0, /* dest */
src_tex, src_level, &src_box);
normalized = tex->target != PIPE_TEXTURE_RECT;
if(normalized) {
@@ -433,7 +439,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
}
else {
u_sampler_view_default_template(&sv_templ, src_tex, src_tex->format);
sv_templ.first_level = sv_templ.last_level = srcsub.level;
sampler_view = pipe->create_sampler_view(pipe, src_tex, &sv_templ);
if (!sampler_view) {
@@ -447,10 +452,10 @@ util_blit_pixels_writemask(struct blit_state *ctx,
normalized = sampler_view->texture->target != PIPE_TEXTURE_RECT;
if(normalized)
{
s0 /= (float)(u_minify(sampler_view->texture->width0, srcsub.level));
s1 /= (float)(u_minify(sampler_view->texture->width0, srcsub.level));
t0 /= (float)(u_minify(sampler_view->texture->height0, srcsub.level));
t1 /= (float)(u_minify(sampler_view->texture->height0, srcsub.level));
s0 /= (float)(u_minify(sampler_view->texture->width0, src_level));
s1 /= (float)(u_minify(sampler_view->texture->width0, src_level));
t0 /= (float)(u_minify(sampler_view->texture->height0, src_level));
t1 /= (float)(u_minify(sampler_view->texture->height0, src_level));
}
}
@@ -489,9 +494,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
ctx->sampler.normalized_coords = normalized;
ctx->sampler.min_img_filter = filter;
ctx->sampler.mag_img_filter = filter;
/* we've limited this already with the sampler view but you never know... */
ctx->sampler.min_lod = srcsub.level;
ctx->sampler.max_lod = srcsub.level;
ctx->sampler.min_lod = src_level;
ctx->sampler.max_lod = src_level;
cso_single_sampler(ctx->cso, 0, &ctx->sampler);
cso_single_sampler_done(ctx->cso);
@@ -575,7 +579,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
void
util_blit_pixels(struct blit_state *ctx,
struct pipe_resource *src_tex,
struct pipe_subresource srcsub,
unsigned src_level,
int srcX0, int srcY0,
int srcX1, int srcY1,
int srcZ,
@@ -585,7 +589,7 @@ util_blit_pixels(struct blit_state *ctx,
float z, uint filter )
{
util_blit_pixels_writemask( ctx, src_tex,
srcsub,
src_level,
srcX0, srcY0,
srcX1, srcY1,
srcZ,
@@ -662,6 +666,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_save_rasterizer(ctx->cso);
cso_save_samplers(ctx->cso);
cso_save_fragment_sampler_views(ctx->cso);
cso_save_viewport(ctx->cso);
cso_save_framebuffer(ctx->cso);
cso_save_fragment_shader(ctx->cso);
cso_save_vertex_shader(ctx->cso);
@@ -729,6 +734,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_restore_rasterizer(ctx->cso);
cso_restore_samplers(ctx->cso);
cso_restore_fragment_sampler_views(ctx->cso);
cso_restore_viewport(ctx->cso);
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
cso_restore_vertex_shader(ctx->cso);

View File

@@ -42,7 +42,6 @@ struct cso_context;
struct pipe_context;
struct pipe_resource;
struct pipe_sampler_view;
struct pipe_subresource;
struct pipe_surface;
@@ -55,7 +54,7 @@ util_destroy_blit(struct blit_state *ctx);
extern void
util_blit_pixels(struct blit_state *ctx,
struct pipe_resource *src_tex,
struct pipe_subresource srcsub,
unsigned src_level,
int srcX0, int srcY0,
int srcX1, int srcY1,
int srcZ0,
@@ -67,7 +66,7 @@ util_blit_pixels(struct blit_state *ctx,
void
util_blit_pixels_writemask(struct blit_state *ctx,
struct pipe_resource *src_tex,
struct pipe_subresource srcsub,
unsigned src_level,
int srcX0, int srcY0,
int srcX1, int srcY1,
int srcZ0,

Some files were not shown because too many files have changed in this diff Show More