Compare commits

...

62 Commits

Author SHA1 Message Date
Ian Romanick
d0aa394741 Bump version to 10.2-rc3
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2014-05-16 23:48:44 -07:00
Brian Paul
4baf6f12a5 mesa: fix double-freeing of dispatch tables inside glBegin/End.
We allocate dispatch tables for BeginEnd and OutsideBeginEnd.  But
when we destroy the context we were freeing the BeginEnd and Exec
tables.  If Exec==BeginEnd we did a double-free.  This would happen
if the context was destroyed while inside a glBegin/End pair.  Now
free the BeginEnd and OutsideBeginEnd pointers.

Cc: "10.1", "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit ef6b6658f9)
2014-05-16 23:46:34 -07:00
Michel Dänzer
21792665c7 glsl_to_tgsi: Make sure the 'shader' member is always initialized
Fixes the valgrind report below and random crashes with piglit on radeonsi.

==30005== Conditional jump or move depends on uninitialised value(s)
==30005==    at 0xB13584E: st_translate_program (st_glsl_to_tgsi.cpp:5100)
==30005==    by 0xB14698B: st_translate_fragment_program (st_program.c:747)
==30005==    by 0xB14777D: st_get_fp_variant (st_program.c:824)
==30005==    by 0xB11219C: get_color_fp_variant (st_cb_drawpixels.c:1042)
==30005==    by 0xB1131AE: st_DrawPixels (st_cb_drawpixels.c:1154)
==30005==    by 0xAFF8806: _mesa_DrawPixels (drawpix.c:162)
==30005==    by 0x4EB86DB: stub_glDrawPixels (generated_dispatch.c:6640)
==30005==    by 0x4F1DF08: piglit_visualize_image (piglit-util-gl.c:1574)
==30005==    by 0x40691D: draw_image_to_window_system_fb(int, bool) (draw-buffers-common.cpp:733)
==30005==    by 0x406C8B: draw_reference_image(bool, bool) (draw-buffers-common.cpp:854)
==30005==    by 0x40722A: piglit_display (alpha-to-coverage-dual-src-blend.cpp:117)
==30005==    by 0x4EA7168: run_test (piglit_fbo_framework.c:52)

Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
(cherry picked from commit 2bab95973d)
2014-05-16 23:45:50 -07:00
Topi Pohjolainen
872ea423ac i965/fb: Use meta path for stencil up/downsampling
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
(cherry picked from commit d45fadf11a)
2014-05-16 23:45:24 -07:00
Topi Pohjolainen
ad8ad99eff i965/meta: Stencil blit for miptree updownsampling
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 475216a4f0)
2014-05-16 23:43:16 -07:00
Topi Pohjolainen
62f1509070 i965/fb: Use meta path for stencil blits
This is effective only on gen8 for now as previous generations still
go through blorp.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit b18f6b9b86)
2014-05-16 23:42:08 -07:00
Topi Pohjolainen
eb2ef1641c i965/meta: Stencil blits
v2: Create the intel renderbuffer with level hardcoded to zero instead
    of overriding it in the surface state configuration. Also moved the
    dimension adjustments for tiling, mip level, msaa into the render
    buffer creation. Finally prepares for another blit path needed for
    miptree updownsampling.
v3 (Ken): Dropped unnecessary memory context for "ralloc_asprintf()"

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
(cherry picked from commit d1829badf5)
2014-05-16 23:41:56 -07:00
Topi Pohjolainen
947b60d19e meta: Refactor state save/restore for framebuffer texture blits
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 2a549c43a8)

Note: This patch was cherry picked so that the next patch would build.
2014-05-16 23:41:40 -07:00
Topi Pohjolainen
cb37016f89 i965: Extend brw_get_rb_for_first_slice() for specified level/layer
v2: Configure stencil directly for final dimensions instead of
    adjusting bit by bit for tiling, mip level and msaa.
v3 (Ken): Used non-static constant for horizontal alignment

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 9d752c098c)
2014-05-16 23:31:05 -07:00
Topi Pohjolainen
43ea5f9347 i965/gen8: Surface state overriding for stencil
v2: Allow hardware to offset accesses to individual layers. Also leave
    the mip-level overriding for the creator of the intel renderbuffer
    to handle. Merged with "i965/gen8: Allow stencil buffers to be
    configured as single sampled"

Ken: I left the "_mesa_problem()" still in place. I think it is clearer
     to remove it in a separate patch.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 36caae48b2)
2014-05-16 23:28:04 -07:00
Topi Pohjolainen
b5e717a618 i965/wm: Surface state overrides for configuring w-tiled as y-tiled
v2: Use intel_mipmap_tree::total_width in order to get correct alignment
    automatically. Also use "mt->total_height / mt->physical_depth0" as
    surface height allowing hardware to offset to correct slice.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 6aefaa4eb2)
2014-05-16 23:27:29 -07:00
Jordan Justen
f5848ec2e4 i965 meta up/downsample: Fix renderbuffer _BaseFormat
mt->format is of type mesa_format, and therefore can't be
used with _mesa_base_fbo_format which requires a GLenum input.

On gen8, this fixes various piglit fbo-depthstencil tests with
samples > 1.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 103057b2b7)
2014-05-16 23:26:58 -07:00
Roland Scheidegger
79a34441d5 mesa/st: fix number of ubos being declared in a shader
Previously the code used the total number of ubos being declared in the
linked program (so the ubos of all shaders combined), use the number
from the particular shader instead.
This fixes an assertion failure with piglit arb_uniform_buffer_object-maxblocks
seen in llvmpipe since 8a9f5ecdb1 as it now emits
code for each declared buffer, not just the ones actually used.

CC: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit 3e817e7e56)
2014-05-16 23:17:47 -07:00
Emil Velikov
1041fb86c0 docs: Add a note about llvm-shared-libs and libxatracker
Both changes landed in 10.2, and for people not following the
development cycle these will come as a surprise. Note that the
pipe_* interface is not stable.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Rob Clark <robclark@freedesktop.org>
(cherry picked from commit e48054d036)
2014-05-16 23:15:14 -07:00
Emil Velikov
b1aa25907a configure: correctly set LD_NO_UNDEFINED
Commit 11623be934 was meant to have this hunk, which
I accidently dropped during git rebase.

Cc: 10.2 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jonathan Gray <jsg@jsg.id.au>
(cherry picked from commit f57d092199)
2014-05-16 23:15:09 -07:00
Michel Dänzer
5d6e822d03 radeonsi: Fix anisotropic filtering state setup
Bring it back in line with r600g. I broke this in the original radeonsi
bringup. :(

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

Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c5828b0599)
2014-05-16 23:14:36 -07:00
Jonathan Gray
26d5b22039 glsl: simplify the M_PI*f macros, fixes build on OpenBSD
The M_PI*f macros used a preprocessor paste to append 'f'
to M_PI defines, which works if the values are only numbers
but breaks on OpenBSD where M_PI definitions have casts
and brackets to meet requirements of a future version of POSIX,

http://austingroupbugs.net/view.php?id=801
http://austingroupbugs.net/view.php?id=828

Simplify the M_PI*f macros by using casts directly in the defines
as suggested by Kenneth Graunke.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78665
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
(cherry picked from commit 0c0bbe77d0)
2014-05-16 23:13:37 -07:00
Kenneth Graunke
3171da3402 i965: Don't _swrast_BlitFramebuffer when doing CopyTexSubImage.
The point of copytexsubimage_using_blit_framebuffer is to use a hardware
accelerated BlitFramebuffer path.  If that fails, we shouldn't do a
swrast blit---we should try our CTSI fallback code.

This is especially important for i965 and GLES, where we don't even
create a swrast context.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77705
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit bd44ac8b5c)
2014-05-16 23:13:04 -07:00
Kristian Høgsberg
875fd92d16 wayland: Move version 2 request to end of interface specification
We're moving towards requiring interface additions to be appended to the
end of the interface block.  No functional change, opcodes are assigned as
before, but version 2 additions are now grouped together, which prevents
a scanner warning.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
(cherry picked from commit 06842d436e)
2014-05-16 23:12:45 -07:00
Topi Pohjolainen
fb5c68d312 meta: Refactor configuration of renderbuffer sampling
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 4dc9c314c8)
2014-05-16 23:07:02 -07:00
Topi Pohjolainen
0e7b0f2a0a meta: Refactor binding of renderbuffer as texture image
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit a2952315ac)
2014-05-16 23:05:22 -07:00
Topi Pohjolainen
5f495b85a0 meta: Merge compiling and linking of blit program
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit ac4db0aa55)
2014-05-16 23:04:22 -07:00
Topi Pohjolainen
253834cbf6 i965/blorp: Expose coordinate scissoring and mirroring
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 3a43cd0c3e)
2014-05-16 23:00:40 -07:00
Topi Pohjolainen
f5c083dbc3 i965/gen8: Use helper variables for surface parameters
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 4a92ad5531)
2014-05-16 22:55:44 -07:00
Jordan Justen
2b4a871e05 i965/gen8: Set depth extent field
The depth extent field is used to limit the allowed slice range that
can be rendered to.

With the previous setting, only slice 0 could be rendered.

This fixes piglit amd_vertex_shader_layer-layered-depth-texture-render.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
(cherry picked from commit c51c192891)
2014-05-14 12:19:16 -07:00
Jordan Justen
27da0bbeb4 i965/gen8 depth: Set depth size based on LOD0 for 3D textures
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
(cherry picked from commit 294ada2fef)
2014-05-14 12:19:14 -07:00
Jordan Justen
91e2808c41 i965/gen7 depth: Set depth size based on LOD0 for 3D textures
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
(cherry picked from commit e6d6ed55ab)
2014-05-14 12:19:13 -07:00
Jordan Justen
6cad93daab i965/gen8 renderbuffer: Set depth size based on LOD0 for 3D textures
Fixes piglit's
'gl-3.2-layered-rendering-clear-color-all-types 3d mipmapped'

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
(cherry picked from commit e47d08adef)
2014-05-14 12:19:12 -07:00
Jordan Justen
71f78bb87e i965/gen7 renderbuffer: Set depth size based on LOD0 for 3D textures
If blorp is disabled for color clears, then piglit's
'gl-3.2-layered-rendering-clear-color-all-types 3d mipmapped'
will fail.

Currently, gen8 fails similarly on this test because gen8
does not use blorp.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
(cherry picked from commit b875f39e29)
2014-05-14 12:19:08 -07:00
Chris Forbes
ab43a98fcf i965/Gen8: Set up layer constraints properly for depth buffers
Same issues as the previous commit fixed for Gen7:
- Bogus physical->logical layer conversion; depth/stencil surfaces
  are still IMS layout on Gen8.
- mt_layer ignored in layered rendering case, which breaks handling
  of views with MinLayer.
- Render target array extent not set correctly for arrays.

I'm not able to test this one since I can't get a Broadwell yet, but
it's the same set of fixes as for Gen7.

V2: Restore the MAX2() to account for zero depth/layer_count.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 23e9f06569)
2014-05-14 12:16:54 -07:00
Chris Forbes
af228e999c i965/Gen7: Set up layer constraints properly for depth buffers
Again, a few problems:
- Layered attachments did not honor MinLayer.
- Non-layered MSAA attachments rendered to the wrong layer due to
  dividing by the layer count. All depth buffers use the IMS layout, so
  the physical layer count == logical layer count.
- Layered attachments were not limited to irb->layer_count, so we could
  render off the end of the texture.

V2: Restore the MAX2() to account for zero depth/layer_count.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 77d55ef481)
2014-05-14 12:16:51 -07:00
Chris Forbes
725a27e04d i965/Gen8: Set up layer constraints properly for renderbuffers
Fixing the same issues the previous commit does for Gen7.

Note that I can't test this one, since I don't have a Broadwell.

V2: Restore the MAX2() to account for zero depth/layer_count.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 9269ea599c)
2014-05-14 12:16:50 -07:00
Chris Forbes
b0609b715b i965/Gen7: Set up layer constraints properly for renderbuffers
There were a few problems here, which mostly just broke layered
rendering into a view:

- Render target view extent was always set to be == depth. This is
  benign for non-layered-rendering, but allows writes off the end of the
  render target for layered rendering, which ends badly.
- Layered rendering did not honor the mt_layer setting, so would not
  properly handle MinLayer being set on a view.

V2: Restore the MAX2() to account for zero depth/layer_count.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit dd43900b7b)
2014-05-14 12:16:47 -07:00
Ilia Mirkin
ca549a0f19 nv50,nvc0: fix blit 3d path for 1d array textures
Need to adjust coordinates since the shader receives the array index as
depth in z, but the TEX instruction expects it to be the second
coordinate for a 1D array texture. This fixes fbo-generatemipmap-array.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 8baed87212)
2014-05-13 10:19:04 -07:00
Ilia Mirkin
407bff9db0 nv50,nvc0: leave queries on during blit, turn them on for 2d engine
Fixes the new logic of the conditional rendering piglit test.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 4467c0c9fb)
2014-05-13 10:18:05 -07:00
Ilia Mirkin
0e14b19492 mesa/st: leave current query enabled during glBlitFramebuffer
Also make sure that pipe_blit_info gets zero'd out so that query isn't
accidentally left enabled.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 64a7ddf40d)
2014-05-13 10:11:00 -07:00
Ilia Mirkin
a233f4c303 gallium: add bit to pipe_blit_info to leave current query enabled
Previously the implication was that queries should be disabled during
blits. However glBlitFramebuffer() is supposed to obey the current
query, and this new bit will indicate that to the driver.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 752ce0affb)
2014-05-13 10:08:33 -07:00
Ilia Mirkin
7a81788c67 nv50: fix setting of texture ms info to be per-stage
Different textures may be bound to each slot for each stage. So we need
to be able to upload ms parameters for each one without stages
overwriting each other.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 863573b9cb)
2014-05-13 10:08:01 -07:00
Ilia Mirkin
13bb2bc84b nv50/ir: make sure to reverse cond codes on all the OP_SET variants
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: "10.2 10.1" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 68f47cad0d)
2014-05-13 09:57:28 -07:00
Ian Romanick
98b66e8d96 Add .cherry-ignore file
e696727 adds a change, and 155f98d reverts that change.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2014-05-13 09:55:23 -07:00
Ian Romanick
0b3126bddd mesa: Bump version to 10.2-rc2
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2014-05-09 20:10:38 -07:00
Emil Velikov
f2682b3b9f glx/tests: Partially revert commit 51e3569573
C++ does not support designated initializers, thus compilation
is not guaranteed to succeed. Surprisingly gcc 4.6.3 fails to
build the code, while version 4.9.0 compiles it without a hitch.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78403
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Tested-by: Vinson Lee <vlee@freedesktop.org>
(cherry picked from commit 326b8e253e)
2014-05-09 20:10:38 -07:00
Emil Velikov
d259928a56 configure: error out if building GBM without dri
Both backends require --enable-dri, and building an empty libgbm
makes little to no sense. Error out at configure to prevent the
user from shooting themselves in the foot.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78225
Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit e477d12c33)
2014-05-09 20:10:38 -07:00
Kenneth Graunke
ec6bd21162 i965: Fix GPU hangs on Broadwell in shaders with some control flow.
According to the documentation, we need to set the source 0 register
type to IMM for flow control instructions that have both JIP and UIP.

Fixes GPU hangs in approximately 10 Piglit tests, 5 es3conform tests,
Unigine Crypt, a WebGL raytracer demo, and several Steam titles.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75478
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75878
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76939
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Tested-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
(cherry picked from commit 9584959123)
2014-05-09 20:10:37 -07:00
Tom Stellard
53a0f9d0ba radeonsi: Enable geometry shaders with LLVM 3.4.1
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>

CC: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 93c2ebbd83)
2014-05-09 20:10:37 -07:00
Tom Stellard
0f0f1106b6 configure.ac: Add LLVM_VERSION_PATCH to DEFINES
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>

CC: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit c5d0008325)
2014-05-09 20:10:37 -07:00
Thomas Hellstrom
2b34277bbd st/xa: Fix performance regression introduced by commit "Cache render target surface"
The mentioned commit has the nasty side-effect of turning off accelerated
copies.

Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit 9306b7c171)
2014-05-09 20:10:37 -07:00
Tom Stellard
e29daf82cc clover: Destory pipe_screen when device does not support compute v2
v2:
  - Make sure screen was successfully created before destroying it.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
(cherry picked from commit c5f0c98c49)
2014-05-09 20:10:37 -07:00
Tom Stellard
03673bcf6c pipe-loader: Don't destroy the winsys in the sw loader
The screen takes ownership of the winsys, and is responsible for
destroying it.  Users of pipe-loader should make sure they destory
and  screens they've created to avoid memory leaks.

This fixes a crash in clover introduced by
ce6c17c083 where the pipe-loader was
destroying the winsys while a screen was still using it.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
(cherry picked from commit c650033b86)
2014-05-09 20:10:37 -07:00
Roland Scheidegger
af47859aed draw: do not use draw_get_option_use_llvm() inside draw execution paths
1c73e919a4 made it possible to not allocate
the tgsi machine if llvm was used. However, draw_get_option_use_llvm() is
not reliable after draw context creation, since drivers can explicitly
request a non-llvm draw context even if draw_get_option_use_llvm() would
return true (and softpipe does just that) which leads to crashes.
Thus use draw->llvm to determine if we're using llvm or not instead (and
make draw->llvm available even if HAVE_LLVM is false so we don't have to put
even more ifdefs).

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit 9af68e9b1d)
2014-05-09 20:10:37 -07:00
Kenneth Graunke
e120f1a958 mesa: Fix MaxNumLayers for 1D array textures.
1D array targets store the number of slices in the Height field.

Cc: "10.2 10.1 10.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
(cherry picked from commit 5c399ca8e4)
2014-05-09 18:27:26 -07:00
Kenneth Graunke
cc92276cb8 i965: Enable GL_ARB_texture_view on Broadwell.
This is a port of commit c9c08867ed.
A tiny bit of extra work was necessary to not break stencil texturing.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
(cherry picked from commit ecfc418b68)
2014-05-08 14:57:12 -07:00
Ilia Mirkin
fac042fa05 nv50/ir/gk110: fix set with f32 dest
Should fix comparison opcodes like SGE/SLT/etc which expected a float to
be returned. These were previously getting integer 0/-1 values.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: 10.2 <mesa-stable@lists.freedesktop.org>
(cherry picked from commit e7047f2917)
2014-05-08 14:50:33 -07:00
Ian Romanick
d26b59ec27 linker: Fix consumer_inputs_with_locations indexing
In an earlier incarnation of populate_consumer_input_sets and
get_matching_input, the consumer_inputs_with_locations array was indexed
using the user-specified location.  In that version, only user-defined
varyings were included in the array.

In the current incarnation, the Mesa location is used to index the
array, and built-in varyings are included.

This change fixes the unit test to exepect gl_ClipDistance in the array,
and it resizes the arrays to actually be big enough.  It's just dumb
luck that the existing piglit tests use small enough locations to not
stomp the stack. :(

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78258
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Cc: Vinson Lee <vlee@freedesktop.org>
(cherry picked from commit f7bf37cb13)
2014-05-07 09:50:52 -07:00
Kenneth Graunke
c2c15a9a37 meta: Only clear the requested color buffers.
This path is used to implement both glClear and glClearBuffer; the
latter is only supposed to clear particular buffers.  Core Mesa provides
us that information in the buffers bitmask; we must only clear buffers
mentioned there.

To accomplish this, we save/restore the color draw buffers state, and
use glDrawBuffers to restrict drawing to the relevant buffers.

Fixes Piglit's spec/!OpenGL 3.0/clearbuffer-mixed-formats and
spec/ARB_framebuffer_object/fbo-drawbuffers-none glClearBuffer tests
for drivers using meta clears (such as Broadwell).

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77852
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77856
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 9701c6984d)
2014-05-07 09:49:13 -07:00
Kenneth Graunke
e6c98309c6 meta: Add infrastructure for saving/restoring the DrawBuffers state.
Sometimes we need to configure what draw buffers we render to, without
creating a new FBO.  This path will make that possible.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit c1c1cf5f92)
2014-05-07 09:48:34 -07:00
Kenneth Graunke
ffc0cc027a meta: Add a new MESA_META_DRAW_BUFFERS bit.
This will be used for saving/restoring the glDrawBuffers state.
For now, make sure that existing users of MESA_META_ALL don't get
the new bit, since they probably won't want it.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit e526ebf35c)
2014-05-07 09:48:34 -07:00
Kenneth Graunke
658d0410d0 meta: Unify the GLSL and fixed-function clear paths.
The majority of _mesa_meta_Clear and _mesa_meta_glsl_Clear was the same;
adding a boolean for whether to use GLSL allows us to share most of it
without polluting either path too much.

Tested for regressions by hacking i965 to always use the non-GLSL path.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 7c8df60f31)
2014-05-07 09:48:34 -07:00
Kenneth Graunke
a1dd1e62fa i965: Always intel_prepare_render() after invalidating front buffers.
Fixes glean/texture_srgb, which hit recursive-flush prevention
assertions in vbo_exec_FlushVertices.

This probably hurts the performance of front buffer rendering, but
very few people in their right mind do front buffer rendering.

Fixes Glean's texture_srgb test.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit cde8bad1c9)
2014-05-07 09:48:34 -07:00
Tapani Pälli
c7a3c2d29d glsl: fix bogus layout qualifier warnings
Print out GL_ARB_explicit_attrib_location warnings only
when parsing attribute that uses "location" qualifier.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77245
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit e65917f94e)
2014-05-07 09:48:34 -07:00
Kenneth Graunke
0a5034517a i965: Set miptree target field when creating from a BO.
Prior to commit 8435b60a35, the region
equivalent of this function called intel_miptree_create_layout, which
set mt->target to target.  With that commit, it no longer copied target.

Piglit's ext_image_dma_buf_import-sample_[xa]rgb8888 tests would then
hit an assertion failure, where image->TexObject->Target was
GL_TEXTURE_EXTERNAL_OES, and mt->target was GL_TEXTURE_2D.

Copying the target fixes this assertion failure.

Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 829cb0423d)
2014-05-05 10:10:54 -07:00
Ian Romanick
e8f6150320 mesa: Bump version to 10.2-rc1
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2014-05-02 21:17:00 -07:00
65 changed files with 1429 additions and 497 deletions

View File

@@ -1 +1 @@
10.2.0-devel
10.2.0-rc3

3
bin/.cherry-ignore Normal file
View File

@@ -0,0 +1,3 @@
# The first is the change, and the second is the revert of that change.
e6967270c75a5b669152127bb7a746d55f4407a6 i965: Fix depth (array slices) computation for 1D_ARRAY render targets.
155f98d49fdc2f46c760f8214327b3804ee60079 Revert "i965: Fix depth (array slices) computation for 1D_ARRAY render targets."

View File

@@ -331,6 +331,19 @@ LDFLAGS=$save_LDFLAGS
AC_SUBST([GC_SECTIONS])
dnl
dnl OpenBSD does not have DT_NEEDED entries for libc by design
dnl so when these flags are passed to ld via libtool the checks will fail
dnl
case "$host_os" in
openbsd*)
LD_NO_UNDEFINED="" ;;
*)
LD_NO_UNDEFINED="-Wl,--no-undefined" ;;
esac
AC_SUBST([LD_NO_UNDEFINED])
dnl
dnl compatibility symlinks
dnl
@@ -1179,6 +1192,13 @@ if test "x$enable_gbm" = xyes; then
if test "x$enable_shared_glapi" = xno; then
AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
fi
else
# Strictly speaking libgbm does not require --enable-dri, although
# both of its backends do. Thus one can build libgbm without any
# backends if --disable-dri is set.
# To avoid unnecessary complexity of checking if at least one backend
# is available when building, just mandate --enable-dri.
AC_MSG_ERROR([gbm requires --enable-dri])
fi
fi
AM_CONDITIONAL(HAVE_GBM, test "x$enable_gbm" = xyes)
@@ -1605,6 +1625,12 @@ if test "x$enable_gallium_llvm" = xyes; then
AC_COMPUTE_INT([LLVM_VERSION_MINOR], [LLVM_VERSION_MINOR],
[#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
dnl In LLVM 3.4.1 patch level was defined in config.h and not
dnl llvm-config.h
AC_COMPUTE_INT([LLVM_VERSION_PATCH], [LLVM_VERSION_PATCH],
[#include "${LLVM_INCLUDEDIR}/llvm/Config/config.h"],
LLVM_VERSION_PATCH=0) dnl Default if LLVM_VERSION_PATCH not found
if test -n "${LLVM_VERSION_MAJOR}"; then
LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}"
else
@@ -1627,7 +1653,7 @@ if test "x$enable_gallium_llvm" = xyes; then
LLVM_COMPONENTS="${LLVM_COMPONENTS} option"
fi
fi
DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT"
DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DLLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
MESA_LLVM=1
dnl Check for Clang internal headers

View File

@@ -67,6 +67,25 @@ TBD.
<h2>Changes</h2>
<ul>
<li>Renamed <i>--with-llvm-shared-libs</i> to <i>--enable-llvm-shared-libs</i></li>
<p>
The option is used to control how mesa is linked against LLVM, and now
defaults to enabled (shared linking).
</p>
<li>Split <i>libxatracker.so</i> into a standalone library which can be used
with any gallium driver.</li>
<p>
Previously the library was linked statically against vmware's virtual gpu
driver(svga), whereas now it loads a shared pipe_*.so driver. Provide the
following options during configure, if you would like support for svga driver
<i>--enable-xa --with-gallium-drivers=svga</i>
</p>
<p>
Note: The files are installed in $(libdir)/gallium-pipe/ and the interface
between them and libxatracker.so is <strong>not</strong> stable.
</p>
</ul>
</div>

View File

@@ -135,22 +135,6 @@
<arg name="stride2" type="int"/>
</request>
<!-- Create a wayland buffer for the prime fd. Use for regular and planar
buffers. Pass 0 for offset and stride for unused planes. -->
<request name="create_prime_buffer" since="2">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="fd"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="format" type="uint"/>
<arg name="offset0" type="int"/>
<arg name="stride0" type="int"/>
<arg name="offset1" type="int"/>
<arg name="stride1" type="int"/>
<arg name="offset2" type="int"/>
<arg name="stride2" type="int"/>
</request>
<!-- Notification of the path of the drm device which is used by
the server. The client should use this device for creating
local buffers. Only buffers created from this device should
@@ -177,6 +161,25 @@
<event name="capabilities">
<arg name="value" type="uint"/>
</event>
<!-- Version 2 additions -->
<!-- Create a wayland buffer for the prime fd. Use for regular and planar
buffers. Pass 0 for offset and stride for unused planes. -->
<request name="create_prime_buffer" since="2">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="fd"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="format" type="uint"/>
<arg name="offset0" type="int"/>
<arg name="stride0" type="int"/>
<arg name="offset1" type="int"/>
<arg name="stride1" type="int"/>
<arg name="offset2" type="int"/>
<arg name="stride2" type="int"/>
</request>
</interface>
</protocol>

View File

@@ -1000,6 +1000,8 @@ draw_get_shader_param_no_llvm(unsigned shader, enum pipe_shader_cap param)
/**
* XXX: Results for PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS because there are two
* different ways of setting textures, and drivers typically only support one.
* Drivers requesting a draw context explicitly without llvm must call
* draw_get_shader_param_no_llvm instead.
*/
int
draw_get_shader_param(unsigned shader, enum pipe_shader_cap param)

View File

@@ -597,7 +597,7 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
#ifdef HAVE_LLVM
if (draw_get_option_use_llvm()) {
if (shader->draw->llvm) {
shader->gs_output = output_verts->verts;
if (max_out_prims > shader->max_out_prims) {
unsigned i;
@@ -674,7 +674,7 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
struct draw_context *draw)
{
boolean use_llvm = draw_get_option_use_llvm();
boolean use_llvm = draw->llvm != NULL;
if (!use_llvm && shader && shader->machine->Tokens != shader->state.tokens) {
tgsi_exec_machine_bind_shader(shader->machine,
shader->state.tokens,
@@ -686,7 +686,7 @@ void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
boolean
draw_gs_init( struct draw_context *draw )
{
if (!draw_get_option_use_llvm()) {
if (!draw->llvm) {
draw->gs.tgsi.machine = tgsi_exec_machine_create();
if (!draw->gs.tgsi.machine)
return FALSE;
@@ -715,7 +715,7 @@ draw_create_geometry_shader(struct draw_context *draw,
const struct pipe_shader_state *state)
{
#ifdef HAVE_LLVM
boolean use_llvm = draw_get_option_use_llvm();
boolean use_llvm = draw->llvm != NULL;
struct llvm_geometry_shader *llvm_gs;
#endif
struct draw_geometry_shader *gs;
@@ -870,7 +870,7 @@ void draw_delete_geometry_shader(struct draw_context *draw,
return;
}
#ifdef HAVE_LLVM
if (draw_get_option_use_llvm()) {
if (draw->llvm) {
struct llvm_geometry_shader *shader = llvm_geometry_shader(dgs);
struct draw_gs_llvm_variant_list_item *li;

View File

@@ -47,7 +47,6 @@
#include "tgsi/tgsi_scan.h"
#ifdef HAVE_LLVM
struct draw_llvm;
struct gallivm_state;
#endif
@@ -69,6 +68,7 @@ struct tgsi_exec_machine;
struct tgsi_sampler;
struct draw_pt_front_end;
struct draw_assembler;
struct draw_llvm;
/**
@@ -318,9 +318,7 @@ struct draw_context
unsigned start_instance;
unsigned start_index;
#ifdef HAVE_LLVM
struct draw_llvm *llvm;
#endif
/** Texture sampler and sampler view state.
* Note that we have arrays indexed by shader type. At this time

View File

@@ -149,7 +149,7 @@ draw_vs_init( struct draw_context *draw )
{
draw->dump_vs = debug_get_option_gallium_dump_vs();
if (!draw_get_option_use_llvm()) {
if (!draw->llvm) {
draw->vs.tgsi.machine = tgsi_exec_machine_create();
if (!draw->vs.tgsi.machine)
return FALSE;
@@ -175,7 +175,7 @@ draw_vs_destroy( struct draw_context *draw )
if (draw->vs.emit_cache)
translate_cache_destroy(draw->vs.emit_cache);
if (!draw_get_option_use_llvm())
if (!draw->llvm)
tgsi_exec_machine_destroy(draw->vs.tgsi.machine);
}

View File

@@ -63,7 +63,7 @@ vs_exec_prepare( struct draw_vertex_shader *shader,
{
struct exec_vertex_shader *evs = exec_vertex_shader(shader);
debug_assert(!draw_get_option_use_llvm());
debug_assert(!draw->llvm);
/* Specify the vertex program to interpret/execute.
* Avoid rebinding when possible.
*/
@@ -97,7 +97,7 @@ vs_exec_run_linear( struct draw_vertex_shader *shader,
unsigned slot;
boolean clamp_vertex_color = shader->draw->rasterizer->clamp_vertex_color;
debug_assert(!draw_get_option_use_llvm());
debug_assert(!shader->draw->llvm);
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
constants, const_size);

View File

@@ -145,9 +145,6 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
{
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
if (sdev->ws && sdev->ws->destroy)
sdev->ws->destroy(sdev->ws);
if (sdev->lib)
util_dl_close(sdev->lib);

View File

@@ -915,6 +915,9 @@ CodeEmitterGK110::emitSET(const CmpInstruction *i)
modNegAbsF32_3b(i, 1);
}
FTZ_(3a);
if (i->dType == TYPE_F32)
code[1] |= 1 << 23;
}
if (i->sType == TYPE_S32)
code[1] |= 1 << 19;

View File

@@ -591,6 +591,10 @@ void NV50LoweringPreSSA::loadTexMsInfo(uint32_t off, Value **ms,
Value *tmp = new_LValue(func, FILE_GPR);
uint8_t b = prog->driver->io.resInfoCBSlot;
off += prog->driver->io.suInfoBase;
if (prog->getType() > Program::TYPE_VERTEX)
off += 16 * 2 * 4;
if (prog->getType() > Program::TYPE_GEOMETRY)
off += 16 * 2 * 4;
*ms_x = bld.mkLoadv(TYPE_U32, bld.mkSymbol(
FILE_MEMORY_CONST, b, TYPE_U32, off + 0), NULL);
*ms_y = bld.mkLoadv(TYPE_U32, bld.mkSymbol(

View File

@@ -187,7 +187,8 @@ LoadPropagation::checkSwapSrc01(Instruction *insn)
return;
}
if (insn->op == OP_SET)
if (insn->op == OP_SET || insn->op == OP_SET_AND ||
insn->op == OP_SET_OR || insn->op == OP_SET_XOR)
insn->asCmp()->setCond = reverseCondCode(insn->asCmp()->setCond);
else
if (insn->op == OP_SLCT)

View File

@@ -78,16 +78,16 @@
/* 8 user clip planes, at 4 32-bit floats each */
#define NV50_CB_AUX_UCP_OFFSET 0x0000
#define NV50_CB_AUX_UCP_SIZE (8 * 4 * 4)
/* 256 textures, each with ms_x, ms_y u32 pairs */
/* 16 textures * 3 shaders, each with ms_x, ms_y u32 pairs */
#define NV50_CB_AUX_TEX_MS_OFFSET 0x0080
#define NV50_CB_AUX_TEX_MS_SIZE (256 * 2 * 4)
#define NV50_CB_AUX_TEX_MS_SIZE (16 * 3 * 2 * 4)
/* For each MS level (4), 8 sets of 32-bit integer pairs sample offsets */
#define NV50_CB_AUX_MS_OFFSET 0x880
#define NV50_CB_AUX_MS_OFFSET 0x200
#define NV50_CB_AUX_MS_SIZE (4 * 8 * 4 * 2)
/* Sample position pairs for the current output MS level */
#define NV50_CB_AUX_SAMPLE_OFFSET 0x980
#define NV50_CB_AUX_SAMPLE_OFFSET 0x300
#define NV50_CB_AUX_SAMPLE_OFFSET_SIZE (4 * 8 * 2)
/* next spot: 0x9c0 */
/* next spot: 0x340 */
/* 4 32-bit floats for the vertex runout, put at the end */
#define NV50_CB_AUX_RUNOUT_OFFSET (NV50_CB_AUX_SIZE - 0x10)

View File

@@ -332,7 +332,7 @@ nv50_render_condition(struct pipe_context *pipe,
nv50->cond_cond = condition;
nv50->cond_mode = mode;
PUSH_SPACE(push, 6);
PUSH_SPACE(push, 9);
if (!pq) {
BEGIN_NV04(push, NV50_3D(COND_MODE), 1);
@@ -351,6 +351,10 @@ nv50_render_condition(struct pipe_context *pipe,
PUSH_DATAh(push, q->bo->offset + q->offset);
PUSH_DATA (push, q->bo->offset + q->offset);
PUSH_DATA (push, NV50_3D_COND_MODE_RES_NON_ZERO);
BEGIN_NV04(push, NV50_2D(COND_ADDRESS_HIGH), 2);
PUSH_DATAh(push, q->bo->offset + q->offset);
PUSH_DATA (push, q->bo->offset + q->offset);
}
void

View File

@@ -397,6 +397,8 @@ nv50_screen_init_hwctx(struct nv50_screen *screen)
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_2D(0x0888), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, NV50_2D(COND_MODE), 1);
PUSH_DATA (push, NV50_2D_COND_MODE_ALWAYS);
BEGIN_NV04(push, SUBC_3D(NV01_SUBCHAN_OBJECT), 1);
PUSH_DATA (push, screen->tesla->handle);

View File

@@ -611,6 +611,7 @@ struct nv50_blitctx
uint8_t mode;
uint16_t color_mask;
uint8_t filter;
uint8_t render_condition_enable;
enum pipe_texture_target target;
struct {
struct pipe_framebuffer_state fb;
@@ -697,6 +698,12 @@ nv50_blitter_make_fp(struct pipe_context *pipe,
tc = ureg_DECL_fs_input(
ureg, TGSI_SEMANTIC_GENERIC, 0, TGSI_INTERPOLATE_LINEAR);
if (ptarg == PIPE_TEXTURE_1D_ARRAY) {
/* Adjust coordinates. Depth is in z, but TEX expects it to be in y. */
tc = ureg_swizzle(tc, TGSI_SWIZZLE_X, TGSI_SWIZZLE_Z,
TGSI_SWIZZLE_Z, TGSI_SWIZZLE_Z);
}
data = ureg_DECL_temporary(ureg);
if (tex_s) {
@@ -933,7 +940,7 @@ nv50_blitctx_prepare_state(struct nv50_blitctx *blit)
{
struct nouveau_pushbuf *push = blit->nv50->base.pushbuf;
if (blit->nv50->cond_query) {
if (blit->nv50->cond_query && !blit->render_condition_enable) {
BEGIN_NV04(push, NV50_3D(COND_MODE), 1);
PUSH_DATA (push, NV50_3D_COND_MODE_ALWAYS);
}
@@ -1071,7 +1078,7 @@ nv50_blitctx_post_blit(struct nv50_blitctx *blit)
nv50->samplers[2][0] = blit->saved.sampler[0];
nv50->samplers[2][1] = blit->saved.sampler[1];
if (nv50->cond_query)
if (nv50->cond_query && !blit->render_condition_enable)
nv50->base.pipe.render_condition(&nv50->base.pipe, nv50->cond_query,
nv50->cond_cond, nv50->cond_mode);
@@ -1105,6 +1112,7 @@ nv50_blit_3d(struct nv50_context *nv50, const struct pipe_blit_info *info)
blit->mode = nv50_blit_select_mode(info);
blit->color_mask = nv50_blit_derive_color_mask(info);
blit->filter = nv50_blit_get_filter(info);
blit->render_condition_enable = info->render_condition_enable;
nv50_blit_select_fp(blit, info);
nv50_blitctx_pre_blit(blit);
@@ -1262,6 +1270,11 @@ nv50_blit_eng2d(struct nv50_context *nv50, const struct pipe_blit_info *info)
PUSH_DATA (push, 1); /* enable */
}
if (nv50->cond_query && info->render_condition_enable) {
BEGIN_NV04(push, NV50_2D(COND_MODE), 1);
PUSH_DATA (push, NV50_2D_COND_MODE_RES_NON_ZERO);
}
if (mask != 0xffffffff) {
BEGIN_NV04(push, NV50_2D(ROP), 1);
PUSH_DATA (push, 0xca); /* DPSDxax */
@@ -1384,6 +1397,10 @@ nv50_blit_eng2d(struct nv50_context *nv50, const struct pipe_blit_info *info)
BEGIN_NV04(push, NV50_2D(OPERATION), 1);
PUSH_DATA (push, NV50_2D_OPERATION_SRCCOPY);
}
if (nv50->cond_query && info->render_condition_enable) {
BEGIN_NV04(push, NV50_2D(COND_MODE), 1);
PUSH_DATA (push, NV50_2D_COND_MODE_ALWAYS);
}
}
static void

View File

@@ -286,7 +286,7 @@ nv50_validate_tic(struct nv50_context *nv50, int s)
}
if (nv50->num_textures[s]) {
BEGIN_NV04(push, NV50_3D(CB_ADDR), 1);
PUSH_DATA (push, (NV50_CB_AUX_TEX_MS_OFFSET << (8 - 2)) | NV50_CB_AUX);
PUSH_DATA (push, ((NV50_CB_AUX_TEX_MS_OFFSET + 16 * s * 2 * 4) << (8 - 2)) | NV50_CB_AUX);
BEGIN_NI04(push, NV50_3D(CB_DATA(0)), nv50->num_textures[s] * 2);
for (i = 0; i < nv50->num_textures[s]; i++) {
struct nv50_tic_entry *tic = nv50_tic_entry(nv50->textures[s][i]);

View File

@@ -585,12 +585,15 @@ nvc0_render_condition(struct pipe_context *pipe,
if (wait)
nvc0_query_fifo_wait(push, pq);
PUSH_SPACE(push, 4);
PUSH_SPACE(push, 7);
PUSH_REFN (push, q->bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD);
BEGIN_NVC0(push, NVC0_3D(COND_ADDRESS_HIGH), 3);
PUSH_DATAh(push, q->bo->offset + q->offset);
PUSH_DATA (push, q->bo->offset + q->offset);
PUSH_DATA (push, cond);
BEGIN_NVC0(push, NVC0_2D(COND_ADDRESS_HIGH), 2);
PUSH_DATAh(push, q->bo->offset + q->offset);
PUSH_DATA (push, q->bo->offset + q->offset);
}
void

View File

@@ -676,6 +676,8 @@ nvc0_screen_create(struct nouveau_device *dev)
PUSH_DATA (push, 0x3f);
BEGIN_NVC0(push, SUBC_2D(0x0888), 1);
PUSH_DATA (push, 1);
BEGIN_NVC0(push, NVC0_2D(COND_MODE), 1);
PUSH_DATA (push, NVC0_2D_COND_MODE_ALWAYS);
BEGIN_NVC0(push, SUBC_2D(NVC0_GRAPH_NOTIFY_ADDRESS_HIGH), 2);
PUSH_DATAh(push, screen->fence.bo->offset + 16);

View File

@@ -503,6 +503,7 @@ struct nvc0_blitctx
uint8_t mode;
uint16_t color_mask;
uint8_t filter;
uint8_t render_condition_enable;
enum pipe_texture_target target;
struct {
struct pipe_framebuffer_state fb;
@@ -691,7 +692,7 @@ nvc0_blitctx_prepare_state(struct nvc0_blitctx *blit)
/* TODO: maybe make this a MACRO (if we need more logic) ? */
if (blit->nvc0->cond_query)
if (blit->nvc0->cond_query && !blit->render_condition_enable)
IMMED_NVC0(push, NVC0_3D(COND_MODE), NVC0_3D_COND_MODE_ALWAYS);
/* blend state */
@@ -833,7 +834,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit)
nvc0->textures_dirty[4] |= 3;
nvc0->samplers_dirty[4] |= 3;
if (nvc0->cond_query)
if (nvc0->cond_query && !blit->render_condition_enable)
nvc0->base.pipe.render_condition(&nvc0->base.pipe, nvc0->cond_query,
nvc0->cond_cond, nvc0->cond_mode);
@@ -868,6 +869,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info)
blit->mode = nv50_blit_select_mode(info);
blit->color_mask = nv50_blit_derive_color_mask(info);
blit->filter = nv50_blit_get_filter(info);
blit->render_condition_enable = info->render_condition_enable;
nvc0_blit_select_fp(blit, info);
nvc0_blitctx_pre_blit(blit);
@@ -1030,6 +1032,9 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info)
PUSH_DATA (push, 1); /* enable */
}
if (nvc0->cond_query && info->render_condition_enable)
IMMED_NVC0(push, NVC0_2D(COND_MODE), NVC0_2D_COND_MODE_RES_NON_ZERO);
if (mask != 0xffffffff) {
IMMED_NVC0(push, NVC0_2D(ROP), 0xca); /* DPSDxax */
IMMED_NVC0(push, NVC0_2D(PATTERN_COLOR_FORMAT),
@@ -1154,6 +1159,8 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info)
IMMED_NVC0(push, NVC0_2D(CLIP_ENABLE), 0);
if (mask != 0xffffffff)
IMMED_NVC0(push, NVC0_2D(OPERATION), NVC0_2D_OPERATION_SRCCOPY);
if (nvc0->cond_query && info->render_condition_enable)
IMMED_NVC0(push, NVC0_2D(COND_MODE), NVC0_2D_COND_MODE_ALWAYS);
}
static void

View File

@@ -829,15 +829,6 @@ static INLINE uint32_t S_FIXED(float value, uint32_t frac_bits)
}
#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y))
static inline unsigned r600_tex_aniso_filter(unsigned filter)
{
if (filter <= 1) return 0;
if (filter <= 2) return 1;
if (filter <= 4) return 2;
if (filter <= 8) return 3;
/* else */ return 4;
}
/* 12.4 fixed-point */
static INLINE unsigned r600_pack_float_12p4(float x)
{

View File

@@ -489,6 +489,15 @@ r600_resource_reference(struct r600_resource **ptr, struct r600_resource *res)
(struct pipe_resource *)res);
}
static inline unsigned r600_tex_aniso_filter(unsigned filter)
{
if (filter <= 1) return 0;
if (filter <= 2) return 1;
if (filter <= 4) return 2;
if (filter <= 8) return 3;
/* else */ return 4;
}
#define R600_ERR(fmt, args...) \
fprintf(stderr, "EE %s:%d %s - "fmt, __FILE__, __LINE__, __func__, ##args)

View File

@@ -152,7 +152,7 @@ static void si_update_descriptors(struct si_context *sctx,
7 + /* copy */
(4 + desc->element_dw_size) * util_bitcount(desc->dirty_mask) + /* update */
4; /* pointer update */
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
if (desc->shader_userdata_reg >= R_00B130_SPI_SHADER_USER_DATA_VS_0 &&
desc->shader_userdata_reg < R_00B230_SPI_SHADER_USER_DATA_GS_0)
desc->atom.num_dw += 4; /* second pointer update */
@@ -177,7 +177,7 @@ static void si_emit_shader_pointer(struct si_context *sctx,
radeon_emit(cs, va);
radeon_emit(cs, va >> 32);
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
if (desc->shader_userdata_reg >= R_00B130_SPI_SHADER_USER_DATA_VS_0 &&
desc->shader_userdata_reg < R_00B230_SPI_SHADER_USER_DATA_GS_0) {
radeon_emit(cs, PKT3(PKT3_SET_SH_REG, 2, 0));

View File

@@ -224,7 +224,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
return 4;
case PIPE_CAP_GLSL_FEATURE_LEVEL:
return HAVE_LLVM >= 0x0305 ? 330 : 140;
return (LLVM_SUPPORTS_GEOM_SHADERS) ? 330 : 140;
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
return MIN2(sscreen->b.info.vram_size, 0xFFFFFFFF);
@@ -308,7 +308,7 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu
case PIPE_SHADER_VERTEX:
break;
case PIPE_SHADER_GEOMETRY:
#if HAVE_LLVM < 0x0305
#if !(LLVM_SUPPORTS_GEOM_SHADERS)
return 0;
#endif
break;

View File

@@ -39,6 +39,10 @@
#define SI_MAX_DRAW_CS_DWORDS 18
#define LLVM_SUPPORTS_GEOM_SHADERS \
((HAVE_LLVM >= 0x0305) || \
(HAVE_LLVM == 0x0304 && LLVM_VERSION_PATCH >= 1))
struct si_pipe_compute;
struct si_screen {

View File

@@ -2173,7 +2173,7 @@ static void *si_create_fs_state(struct pipe_context *ctx,
return si_create_shader_state(ctx, state, PIPE_SHADER_FRAGMENT);
}
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
static void *si_create_gs_state(struct pipe_context *ctx,
const struct pipe_shader_state *state)
@@ -2203,7 +2203,7 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
sctx->vs_shader = sel;
}
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
{
@@ -2271,7 +2271,7 @@ static void si_delete_vs_shader(struct pipe_context *ctx, void *state)
si_delete_shader_selector(ctx, sel);
}
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
static void si_delete_gs_shader(struct pipe_context *ctx, void *state)
{
@@ -2599,16 +2599,15 @@ static void *si_create_sampler_state(struct pipe_context *ctx,
rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) |
S_008F30_CLAMP_Y(si_tex_wrap(state->wrap_t)) |
S_008F30_CLAMP_Z(si_tex_wrap(state->wrap_r)) |
(state->max_anisotropy & 0x7) << 9 | /* XXX */
r600_tex_aniso_filter(state->max_anisotropy) << 9 |
S_008F30_DEPTH_COMPARE_FUNC(si_tex_compare(state->compare_func)) |
S_008F30_FORCE_UNNORMALIZED(!state->normalized_coords) |
aniso_flag_offset << 16 | /* XXX */
S_008F30_DISABLE_CUBE_WRAP(!state->seamless_cube_map));
rstate->val[1] = (S_008F34_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 8)) |
S_008F34_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 8)));
rstate->val[2] = (S_008F38_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 8)) |
S_008F38_XY_MAG_FILTER(si_tex_filter(state->mag_img_filter)) |
S_008F38_XY_MIN_FILTER(si_tex_filter(state->min_img_filter)) |
S_008F38_XY_MAG_FILTER(si_tex_filter(state->mag_img_filter) | aniso_flag_offset) |
S_008F38_XY_MIN_FILTER(si_tex_filter(state->min_img_filter) | aniso_flag_offset) |
S_008F38_MIP_FILTER(si_tex_mipfilter(state->min_mip_filter)));
rstate->val[3] = S_008F3C_BORDER_COLOR_TYPE(border_color_type);
@@ -2767,7 +2766,7 @@ static void si_bind_vs_sampler_states(struct pipe_context *ctx, unsigned count,
si_set_sampler_states(sctx, pm4, count, states,
&sctx->samplers[PIPE_SHADER_VERTEX],
R_00B130_SPI_SHADER_USER_DATA_VS_0);
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
si_set_sampler_states(sctx, pm4, count, states,
&sctx->samplers[PIPE_SHADER_VERTEX],
R_00B330_SPI_SHADER_USER_DATA_ES_0);
@@ -2999,7 +2998,7 @@ void si_init_state_functions(struct si_context *sctx)
sctx->b.b.bind_fs_state = si_bind_ps_shader;
sctx->b.b.delete_vs_state = si_delete_vs_shader;
sctx->b.b.delete_fs_state = si_delete_ps_shader;
#if HAVE_LLVM >= 0x0305
#if LLVM_SUPPORTS_GEOM_SHADERS
sctx->b.b.create_gs_state = si_create_gs_state;
sctx->b.b.bind_gs_state = si_bind_gs_shader;
sctx->b.b.delete_gs_state = si_delete_gs_shader;

View File

@@ -591,6 +591,9 @@ struct pipe_blit_info
boolean scissor_enable;
struct pipe_scissor_state scissor;
boolean render_condition_enable; /**< whether to leave current render
condition enabled */
};

View File

@@ -42,8 +42,11 @@ namespace {
device::device(clover::platform &platform, pipe_loader_device *ldev) :
platform(platform), ldev(ldev) {
pipe = pipe_loader_create_screen(ldev, PIPE_SEARCH_DIR);
if (!pipe || !pipe->get_param(pipe, PIPE_CAP_COMPUTE))
if (!pipe || !pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
if (pipe)
pipe->destroy(pipe);
throw error(CL_INVALID_DEVICE);
}
}
device::~device() {

View File

@@ -223,7 +223,7 @@ XA_EXPORT int
xa_copy_prepare(struct xa_context *ctx,
struct xa_surface *dst, struct xa_surface *src)
{
if (src == dst || ctx->srf != NULL)
if (src == dst)
return -XA_ERR_INVAL;
if (src->tex->format != dst->tex->format) {

View File

@@ -62,11 +62,9 @@
#include "program/prog_instruction.h"
#include <limits>
#define f(x) join(x)
#define join(x) x ## f
#define M_PIf f(M_PI)
#define M_PI_2f f(M_PI_2)
#define M_PI_4f f(M_PI_4)
#define M_PIf ((float) M_PI)
#define M_PI_2f ((float) M_PI_2)
#define M_PI_4f ((float) M_PI_4)
using namespace ir_builder;

View File

@@ -1319,6 +1319,13 @@ layout_qualifier_id:
if (match_layout_qualifier("location", $1, state) == 0) {
$$.flags.q.explicit_location = 1;
if ($$.flags.q.attribute == 1 &&
state->ARB_explicit_attrib_location_warn) {
_mesa_glsl_warning(& @1, state,
"GL_ARB_explicit_attrib_location layout "
"identifier `%s' used", $1);
}
if ($3 >= 0) {
$$.location = $3;
} else {
@@ -1426,10 +1433,6 @@ layout_qualifier_id:
_mesa_glsl_error(& @1, state, "unrecognized layout identifier "
"`%s'", $1);
YYERROR;
} else if (state->ARB_explicit_attrib_location_warn) {
_mesa_glsl_warning(& @1, state,
"GL_ARB_explicit_attrib_location layout "
"identifier `%s' used", $1);
}
}
| interface_block_layout_qualifier

View File

@@ -1092,11 +1092,11 @@ bool
populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
hash_table *consumer_inputs,
hash_table *consumer_interface_inputs,
ir_variable *consumer_inputs_with_locations[MAX_VARYING])
ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX])
{
memset(consumer_inputs_with_locations,
0,
sizeof(consumer_inputs_with_locations[0]) * MAX_VARYING);
sizeof(consumer_inputs_with_locations[0]) * VARYING_SLOT_MAX);
foreach_list(node, ir) {
ir_variable *const input_var = ((ir_instruction *) node)->as_variable();
@@ -1152,7 +1152,7 @@ get_matching_input(void *mem_ctx,
const ir_variable *output_var,
hash_table *consumer_inputs,
hash_table *consumer_interface_inputs,
ir_variable *consumer_inputs_with_locations[MAX_VARYING])
ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX])
{
ir_variable *input_var;
@@ -1277,7 +1277,7 @@ assign_varying_locations(struct gl_context *ctx,
= hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
hash_table *consumer_interface_inputs
= hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
ir_variable *consumer_inputs_with_locations[MAX_VARYING] = {
ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX] = {
NULL,
};

View File

@@ -39,14 +39,14 @@ bool
populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
hash_table *consumer_inputs,
hash_table *consumer_interface_inputs,
ir_variable *consumer_inputs_with_locations[MAX_VARYING]);
ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX]);
ir_variable *
get_matching_input(void *mem_ctx,
const ir_variable *output_var,
hash_table *consumer_inputs,
hash_table *consumer_interface_inputs,
ir_variable *consumer_inputs_with_locations[MAX_VARYING]);
ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX]);
}
class link_varyings : public ::testing::Test {
@@ -70,7 +70,7 @@ public:
hash_table *consumer_interface_inputs;
const glsl_type *simple_interface;
ir_variable *junk[MAX_VARYING];
ir_variable *junk[VARYING_SLOT_MAX];
};
link_varyings::link_varyings()
@@ -197,9 +197,8 @@ TEST_F(link_varyings, gl_ClipDistance)
consumer_interface_inputs,
junk));
EXPECT_EQ((void *) clipdistance,
hash_table_find(consumer_inputs, "gl_ClipDistance"));
EXPECT_EQ(1u, num_elements(consumer_inputs));
EXPECT_EQ(clipdistance, junk[VARYING_SLOT_CLIP_DIST0]);
EXPECT_TRUE(is_empty(consumer_inputs));
EXPECT_TRUE(is_empty(consumer_interface_inputs));
}

View File

@@ -141,10 +141,10 @@ fake_queryString(__DRIscreen *screen, int attribute, const char **val)
}
static const __DRI2rendererQueryExtension rendererQueryExt = {
.base = { __DRI2_RENDERER_QUERY, 1 },
{ __DRI2_RENDERER_QUERY, 1 },
.queryInteger = fake_queryInteger,
.queryString = fake_queryString
fake_queryInteger,
fake_queryString
};
void dri2_query_renderer_string_test::SetUp()

View File

@@ -86,6 +86,9 @@
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
static void
meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl);
static struct blit_shader *
choose_blit_shader(GLenum target, struct blit_shader_table *table);
@@ -201,6 +204,31 @@ _mesa_meta_link_program_with_debug(struct gl_context *ctx, GLuint program)
return 0;
}
void
_mesa_meta_compile_and_link_program(struct gl_context *ctx,
const char *vs_source,
const char *fs_source,
const char *name,
GLuint *program)
{
GLuint vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER,
vs_source);
GLuint fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER,
fs_source);
*program = _mesa_CreateProgram();
_mesa_AttachShader(*program, fs);
_mesa_DeleteShader(fs);
_mesa_AttachShader(*program, vs);
_mesa_DeleteShader(vs);
_mesa_BindAttribLocation(*program, 0, "position");
_mesa_BindAttribLocation(*program, 1, "texcoords");
_mesa_meta_link_program_with_debug(ctx, *program);
_mesa_ObjectLabel(GL_PROGRAM, *program, -1, name);
_mesa_UseProgram(*program);
}
/**
* Generate a generic shader to blit from a texture to a framebuffer
*
@@ -216,10 +244,8 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
{
const char *vs_source;
char *fs_source;
GLuint vs, fs;
void *const mem_ctx = ralloc_context(NULL);
struct blit_shader *shader = choose_blit_shader(target, table);
char *name;
assert(shader != NULL);
@@ -279,22 +305,12 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
shader->texcoords);
}
vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source);
fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source);
shader->shader_prog = _mesa_CreateProgram();
_mesa_AttachShader(shader->shader_prog, fs);
_mesa_DeleteShader(fs);
_mesa_AttachShader(shader->shader_prog, vs);
_mesa_DeleteShader(vs);
_mesa_BindAttribLocation(shader->shader_prog, 0, "position");
_mesa_BindAttribLocation(shader->shader_prog, 1, "texcoords");
_mesa_meta_link_program_with_debug(ctx, shader->shader_prog);
name = ralloc_asprintf(mem_ctx, "%s blit", shader->type);
_mesa_ObjectLabel(GL_PROGRAM, shader->shader_prog, -1, name);
_mesa_meta_compile_and_link_program(ctx, vs_source, fs_source,
ralloc_asprintf(mem_ctx, "%s blit",
shader->type),
&shader->shader_prog);
ralloc_free(mem_ctx);
_mesa_UseProgram(shader->shader_prog);
}
/**
@@ -389,6 +405,24 @@ _mesa_meta_init(struct gl_context *ctx)
ctx->Meta = CALLOC_STRUCT(gl_meta_state);
}
static GLenum
gl_buffer_index_to_drawbuffers_enum(gl_buffer_index bufindex)
{
assert(bufindex < BUFFER_COUNT);
if (bufindex >= BUFFER_COLOR0)
return GL_COLOR_ATTACHMENT0 + bufindex - BUFFER_COLOR0;
else if (bufindex == BUFFER_FRONT_LEFT)
return GL_FRONT_LEFT;
else if (bufindex == BUFFER_FRONT_RIGHT)
return GL_FRONT_RIGHT;
else if (bufindex == BUFFER_BACK_LEFT)
return GL_BACK_LEFT;
else if (bufindex == BUFFER_BACK_RIGHT)
return GL_BACK_RIGHT;
return GL_NONE;
}
/**
* Free context meta-op state.
@@ -775,6 +809,23 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
_mesa_set_framebuffer_srgb(ctx, GL_FALSE);
}
if (state & MESA_META_DRAW_BUFFERS) {
int buf, real_color_buffers = 0;
memset(save->ColorDrawBuffers, 0, sizeof(save->ColorDrawBuffers));
for (buf = 0; buf < MAX_DRAW_BUFFERS; buf++) {
int buf_index = ctx->DrawBuffer->_ColorDrawBufferIndexes[buf];
if (buf_index == -1)
continue;
save->ColorDrawBuffers[buf] =
gl_buffer_index_to_drawbuffers_enum(buf_index);
if (++real_color_buffers >= ctx->DrawBuffer->_NumColorDrawBuffers)
break;
}
}
/* misc */
{
save->Lighting = ctx->Light.Enabled;
@@ -1173,6 +1224,10 @@ _mesa_meta_end(struct gl_context *ctx)
ctx->CurrentRenderbuffer->Name != save->RenderbufferName)
_mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
if (state & MESA_META_DRAW_BUFFERS) {
_mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
}
ctx->Meta->SaveStackDepth--;
ctx->API = save->API;
@@ -1459,100 +1514,13 @@ _mesa_meta_setup_ff_tnl_for_blit(GLuint *VAO, GLuint *VBO,
void
_mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers)
{
struct clear_state *clear = &ctx->Meta->Clear;
struct vertex verts[4];
/* save all state but scissor, pixel pack/unpack */
GLbitfield metaSave = (MESA_META_ALL -
MESA_META_SCISSOR -
MESA_META_PIXEL_STORE -
MESA_META_CONDITIONAL_RENDER -
MESA_META_FRAMEBUFFER_SRGB);
const GLuint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
meta_clear(ctx, buffers, false);
}
if (buffers & BUFFER_BITS_COLOR) {
/* if clearing color buffers, don't save/restore colormask */
metaSave -= MESA_META_COLOR_MASK;
}
_mesa_meta_begin(ctx, metaSave);
_mesa_meta_setup_vertex_objects(&clear->VAO, &clear->VBO, false, 3, 0, 4);
/* GL_COLOR_BUFFER_BIT */
if (buffers & BUFFER_BITS_COLOR) {
/* leave colormask, glDrawBuffer state as-is */
/* Clears never have the color clamped. */
if (ctx->Extensions.ARB_color_buffer_float)
_mesa_ClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
}
else {
ASSERT(metaSave & MESA_META_COLOR_MASK);
_mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
}
/* GL_DEPTH_BUFFER_BIT */
if (buffers & BUFFER_BIT_DEPTH) {
_mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE);
_mesa_DepthFunc(GL_ALWAYS);
_mesa_DepthMask(GL_TRUE);
}
else {
assert(!ctx->Depth.Test);
}
/* GL_STENCIL_BUFFER_BIT */
if (buffers & BUFFER_BIT_STENCIL) {
_mesa_set_enable(ctx, GL_STENCIL_TEST, GL_TRUE);
_mesa_StencilOpSeparate(GL_FRONT_AND_BACK,
GL_REPLACE, GL_REPLACE, GL_REPLACE);
_mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS,
ctx->Stencil.Clear & stencilMax,
ctx->Stencil.WriteMask[0]);
}
else {
assert(!ctx->Stencil.Enabled);
}
/* vertex positions/colors */
{
const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin;
const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin;
const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax;
const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax;
const GLfloat z = invert_z(ctx->Depth.Clear);
GLuint i;
verts[0].x = x0;
verts[0].y = y0;
verts[0].z = z;
verts[1].x = x1;
verts[1].y = y0;
verts[1].z = z;
verts[2].x = x1;
verts[2].y = y1;
verts[2].z = z;
verts[3].x = x0;
verts[3].y = y1;
verts[3].z = z;
/* vertex colors */
for (i = 0; i < 4; i++) {
verts[i].r = ctx->Color.ClearColor.f[0];
verts[i].g = ctx->Color.ClearColor.f[1];
verts[i].b = ctx->Color.ClearColor.f[2];
verts[i].a = ctx->Color.ClearColor.f[3];
}
/* upload new vertex data */
_mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
GL_DYNAMIC_DRAW_ARB);
}
/* draw quad */
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
_mesa_meta_end(ctx);
void
_mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
{
meta_clear(ctx, buffers, true);
}
static void
@@ -1699,22 +1667,61 @@ meta_glsl_clear_cleanup(struct clear_state *clear)
}
}
/**
* Given a bitfield of BUFFER_BIT_x draw buffers, call glDrawBuffers to
* set GL to only draw to those buffers.
*
* Since the bitfield has no associated order, the assignment of draw buffer
* indices to color attachment indices is rather arbitrary.
*/
static void
drawbuffers_from_bitfield(GLbitfield bits)
{
GLenum enums[MAX_DRAW_BUFFERS];
int i = 0;
int n;
/* This function is only legal for color buffer bitfields. */
assert((bits & ~BUFFER_BITS_COLOR) == 0);
/* Make sure we don't overflow any arrays. */
assert(_mesa_bitcount(bits) <= MAX_DRAW_BUFFERS);
enums[0] = GL_NONE;
if (bits & BUFFER_BIT_FRONT_LEFT)
enums[i++] = GL_FRONT_LEFT;
if (bits & BUFFER_BIT_FRONT_RIGHT)
enums[i++] = GL_FRONT_RIGHT;
if (bits & BUFFER_BIT_BACK_LEFT)
enums[i++] = GL_BACK_LEFT;
if (bits & BUFFER_BIT_BACK_RIGHT)
enums[i++] = GL_BACK_RIGHT;
for (n = 0; n < MAX_COLOR_ATTACHMENTS; n++) {
if (bits & (1 << (BUFFER_COLOR0 + n)))
enums[i++] = GL_COLOR_ATTACHMENT0 + n;
}
_mesa_DrawBuffers(i, enums);
}
/**
* Meta implementation of ctx->Driver.Clear() in terms of polygon rendering.
*/
void
_mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
static void
meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl)
{
struct clear_state *clear = &ctx->Meta->Clear;
GLbitfield metaSave;
const GLuint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
struct gl_framebuffer *fb = ctx->DrawBuffer;
const float x0 = ((float)fb->_Xmin / fb->Width) * 2.0f - 1.0f;
const float y0 = ((float)fb->_Ymin / fb->Height) * 2.0f - 1.0f;
const float x1 = ((float)fb->_Xmax / fb->Width) * 2.0f - 1.0f;
const float y1 = ((float)fb->_Ymax / fb->Height) * 2.0f - 1.0f;
const float z = -invert_z(ctx->Depth.Clear);
float x0, y0, x1, y1, z;
struct vertex verts[4];
int i;
metaSave = (MESA_META_ALPHA_TEST |
MESA_META_BLEND |
@@ -1729,7 +1736,18 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
MESA_META_MULTISAMPLE |
MESA_META_OCCLUSION_QUERY);
if (!(buffers & BUFFER_BITS_COLOR)) {
if (!glsl) {
metaSave |= MESA_META_FOG |
MESA_META_PIXEL_TRANSFER |
MESA_META_TRANSFORM |
MESA_META_TEXTURE |
MESA_META_CLAMP_VERTEX_COLOR |
MESA_META_SELECT_FEEDBACK;
}
if (buffers & BUFFER_BITS_COLOR) {
metaSave |= MESA_META_DRAW_BUFFERS;
} else {
/* We'll use colormask to disable color writes. Otherwise,
* respect color mask
*/
@@ -1738,13 +1756,30 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
_mesa_meta_begin(ctx, metaSave);
meta_glsl_clear_init(ctx, clear);
if (glsl) {
meta_glsl_clear_init(ctx, clear);
x0 = ((float) fb->_Xmin / fb->Width) * 2.0f - 1.0f;
y0 = ((float) fb->_Ymin / fb->Height) * 2.0f - 1.0f;
x1 = ((float) fb->_Xmax / fb->Width) * 2.0f - 1.0f;
y1 = ((float) fb->_Ymax / fb->Height) * 2.0f - 1.0f;
z = -invert_z(ctx->Depth.Clear);
} else {
_mesa_meta_setup_vertex_objects(&clear->VAO, &clear->VBO, false, 3, 0, 4);
x0 = (float) fb->_Xmin;
y0 = (float) fb->_Ymin;
x1 = (float) fb->_Xmax;
y1 = (float) fb->_Ymax;
z = invert_z(ctx->Depth.Clear);
}
if (fb->_IntegerColor) {
assert(glsl);
_mesa_UseProgram(clear->IntegerShaderProg);
_mesa_Uniform4iv(clear->IntegerColorLocation, 1,
ctx->Color.ClearColor.i);
} else {
} else if (glsl) {
_mesa_UseProgram(clear->ShaderProg);
_mesa_Uniform4fv(clear->ColorLocation, 1,
ctx->Color.ClearColor.f);
@@ -1752,7 +1787,10 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
/* GL_COLOR_BUFFER_BIT */
if (buffers & BUFFER_BITS_COLOR) {
/* leave colormask, glDrawBuffer state as-is */
/* Only draw to the buffers we were asked to clear. */
drawbuffers_from_bitfield(buffers & BUFFER_BITS_COLOR);
/* leave colormask state as-is */
/* Clears never have the color clamped. */
if (ctx->Extensions.ARB_color_buffer_float)
@@ -1800,6 +1838,15 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
verts[3].y = y1;
verts[3].z = z;
if (!glsl) {
for (i = 0; i < 4; i++) {
verts[i].r = ctx->Color.ClearColor.f[0];
verts[i].g = ctx->Color.ClearColor.f[1];
verts[i].b = ctx->Color.ClearColor.f[2];
verts[i].a = ctx->Color.ClearColor.f[3];
}
}
/* upload new vertex data */
_mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
GL_DYNAMIC_DRAW_ARB);
@@ -1807,6 +1854,7 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
/* draw quad(s) */
if (fb->MaxNumLayers > 0) {
unsigned layer;
assert(glsl);
for (layer = 0; layer < fb->MaxNumLayers; layer++) {
if (fb->_IntegerColor)
_mesa_Uniform1i(clear->IntegerLayerLocation, layer);
@@ -2774,7 +2822,7 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims,
_mesa_unlock_texture(ctx, texObj);
_mesa_meta_begin(ctx, MESA_META_ALL);
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS);
_mesa_GenFramebuffers(1, &fbo);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
@@ -2996,7 +3044,8 @@ decompress_texture_image(struct gl_context *ctx,
break;
}
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_PIXEL_STORE);
_mesa_meta_begin(ctx, MESA_META_ALL & ~(MESA_META_PIXEL_STORE |
MESA_META_DRAW_BUFFERS));
samplerSave = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;

View File

@@ -58,6 +58,7 @@
#define MESA_META_MULTISAMPLE 0x100000
#define MESA_META_FRAMEBUFFER_SRGB 0x200000
#define MESA_META_OCCLUSION_QUERY 0x400000
#define MESA_META_DRAW_BUFFERS 0x800000
/**\}*/
/**
@@ -180,6 +181,9 @@ struct save_state
GLboolean TransformFeedbackNeedsResume;
GLuint DrawBufferName, ReadBufferName, RenderbufferName;
/** MESA_META_DRAW_BUFFERS */
GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
};
/**
@@ -263,6 +267,13 @@ struct blit_state
bool no_ctsi_fallback;
};
struct fb_tex_blit_state
{
GLint baseLevelSave, maxLevelSave;
GLuint sampler, samplerSave;
GLuint tempTex;
};
/**
* State for glClear()
@@ -391,6 +402,26 @@ _mesa_meta_end(struct gl_context *ctx);
extern GLboolean
_mesa_meta_in_progress(struct gl_context *ctx);
extern void
_mesa_meta_fb_tex_blit_begin(const struct gl_context *ctx,
struct fb_tex_blit_state *blit);
extern void
_mesa_meta_fb_tex_blit_end(const struct gl_context *ctx, GLenum target,
struct fb_tex_blit_state *blit);
extern GLboolean
_mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint *tex,
struct gl_texture_object **texObj,
GLenum *target);
GLuint
_mesa_meta_setup_sampler(struct gl_context *ctx,
const struct gl_texture_object *texObj,
GLenum target, GLenum filter, GLuint srcLevel);
extern void
_mesa_meta_BlitFramebuffer(struct gl_context *ctx,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
@@ -451,6 +482,13 @@ _mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target,
GLuint
_mesa_meta_link_program_with_debug(struct gl_context *ctx, GLuint program);
void
_mesa_meta_compile_and_link_program(struct gl_context *ctx,
const char *vs_source,
const char *fs_source,
const char *name,
GLuint *program);
GLboolean
_mesa_meta_alloc_texture(struct temp_texture *tex,
GLsizei width, GLsizei height, GLenum intFormat);

View File

@@ -62,7 +62,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
{
const char *vs_source;
char *fs_source;
GLuint vs, fs;
void *mem_ctx;
enum blit_msaa_shader shader_index;
bool dst_is_msaa = false;
@@ -314,21 +313,10 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
sample_resolve);
}
vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source);
fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source);
_mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, name,
&blit->msaa_shaders[shader_index]);
blit->msaa_shaders[shader_index] = _mesa_CreateProgram();
_mesa_AttachShader(blit->msaa_shaders[shader_index], fs);
_mesa_DeleteShader(fs);
_mesa_AttachShader(blit->msaa_shaders[shader_index], vs);
_mesa_DeleteShader(vs);
_mesa_BindAttribLocation(blit->msaa_shaders[shader_index], 0, "position");
_mesa_BindAttribLocation(blit->msaa_shaders[shader_index], 1, "texcoords");
_mesa_meta_link_program_with_debug(ctx, blit->msaa_shaders[shader_index]);
_mesa_ObjectLabel(GL_PROGRAM, blit->msaa_shaders[shader_index], -1, name);
ralloc_free(mem_ctx);
_mesa_UseProgram(blit->msaa_shaders[shader_index]);
}
static void
@@ -368,19 +356,14 @@ blitframebuffer_texture(struct gl_context *ctx,
const struct gl_renderbuffer_attachment *readAtt =
&readFb->Attachment[att_index];
struct blit_state *blit = &ctx->Meta->Blit;
struct fb_tex_blit_state fb_tex_blit;
const GLint dstX = MIN2(dstX0, dstX1);
const GLint dstY = MIN2(dstY0, dstY1);
const GLint dstW = abs(dstX1 - dstX0);
const GLint dstH = abs(dstY1 - dstY0);
struct gl_texture_object *texObj;
GLuint srcLevel;
GLint baseLevelSave;
GLint maxLevelSave;
GLenum target;
GLuint sampler, samplerSave =
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
GLuint tempTex = 0;
struct gl_renderbuffer *rb = readAtt->Renderbuffer;
struct temp_texture *meta_temp_texture;
@@ -392,6 +375,8 @@ blitframebuffer_texture(struct gl_context *ctx,
filter = GL_LINEAR;
}
_mesa_meta_fb_tex_blit_begin(ctx, &fb_tex_blit);
if (readAtt->Texture &&
(readAtt->Texture->Target == GL_TEXTURE_2D ||
readAtt->Texture->Target == GL_TEXTURE_RECTANGLE ||
@@ -404,38 +389,16 @@ blitframebuffer_texture(struct gl_context *ctx,
texObj = readAtt->Texture;
target = texObj->Target;
} else if (!readAtt->Texture && ctx->Driver.BindRenderbufferTexImage) {
/* Otherwise, we need the driver to be able to bind a renderbuffer as
* a texture image.
*/
struct gl_texture_image *texImage;
if (rb->NumSamples > 1)
target = GL_TEXTURE_2D_MULTISAMPLE;
else
target = GL_TEXTURE_2D;
_mesa_GenTextures(1, &tempTex);
_mesa_BindTexture(target, tempTex);
srcLevel = 0;
texObj = _mesa_lookup_texture(ctx, tempTex);
texImage = _mesa_get_tex_image(ctx, texObj, target, srcLevel);
if (!ctx->Driver.BindRenderbufferTexImage(ctx, rb, texImage)) {
_mesa_DeleteTextures(1, &tempTex);
if (!_mesa_meta_bind_rb_as_tex_image(ctx, rb, &fb_tex_blit.tempTex,
&texObj, &target))
return false;
} else {
if (ctx->Driver.FinishRenderTexture &&
!rb->NeedsFinishRenderTexture) {
rb->NeedsFinishRenderTexture = true;
ctx->Driver.FinishRenderTexture(ctx, rb);
}
if (_mesa_is_winsys_fbo(readFb)) {
GLint temp = srcY0;
srcY0 = rb->Height - srcY1;
srcY1 = rb->Height - temp;
flipY = -flipY;
}
srcLevel = 0;
if (_mesa_is_winsys_fbo(readFb)) {
GLint temp = srcY0;
srcY0 = rb->Height - srcY1;
srcY1 = rb->Height - temp;
flipY = -flipY;
}
} else {
GLenum tex_base_format;
@@ -476,8 +439,8 @@ blitframebuffer_texture(struct gl_context *ctx,
srcY1 = srcH;
}
baseLevelSave = texObj->BaseLevel;
maxLevelSave = texObj->MaxLevel;
fb_tex_blit.baseLevelSave = texObj->BaseLevel;
fb_tex_blit.maxLevelSave = texObj->MaxLevel;
if (glsl_version) {
setup_glsl_blit_framebuffer(ctx, blit, rb, target);
@@ -488,25 +451,14 @@ blitframebuffer_texture(struct gl_context *ctx,
2);
}
_mesa_GenSamplers(1, &sampler);
_mesa_BindSampler(ctx->Texture.CurrentUnit, sampler);
/*
printf("Blit from texture!\n");
printf(" srcAtt %p dstAtt %p\n", readAtt, drawAtt);
printf(" srcTex %p dstText %p\n", texObj, drawAtt->Texture);
*/
/* Prepare src texture state */
_mesa_BindTexture(target, texObj->Name);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, filter);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, filter);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
}
_mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
fb_tex_blit.sampler = _mesa_meta_setup_sampler(ctx, texObj, target, filter,
srcLevel);
/* Always do our blits with no net sRGB decode or encode.
*
@@ -527,11 +479,12 @@ blitframebuffer_texture(struct gl_context *ctx,
if (ctx->Extensions.EXT_texture_sRGB_decode) {
if (_mesa_get_format_color_encoding(rb->Format) == GL_SRGB &&
ctx->DrawBuffer->Visual.sRGBCapable) {
_mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
GL_DECODE_EXT);
_mesa_SamplerParameteri(fb_tex_blit.sampler,
GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT);
_mesa_set_framebuffer_srgb(ctx, GL_TRUE);
} else {
_mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
_mesa_SamplerParameteri(fb_tex_blit.sampler,
GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
/* set_framebuffer_srgb was set by _mesa_meta_begin(). */
}
@@ -598,23 +551,95 @@ blitframebuffer_texture(struct gl_context *ctx,
_mesa_DepthFunc(GL_ALWAYS);
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
_mesa_meta_fb_tex_blit_end(ctx, target, &fb_tex_blit);
return true;
}
void
_mesa_meta_fb_tex_blit_begin(const struct gl_context *ctx,
struct fb_tex_blit_state *blit)
{
blit->samplerSave =
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
blit->tempTex = 0;
}
void
_mesa_meta_fb_tex_blit_end(const struct gl_context *ctx, GLenum target,
struct fb_tex_blit_state *blit)
{
/* Restore texture object state, the texture binding will
* be restored by _mesa_meta_end().
*/
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, blit->baseLevelSave);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, blit->maxLevelSave);
}
_mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
_mesa_DeleteSamplers(1, &sampler);
if (tempTex)
_mesa_DeleteTextures(1, &tempTex);
_mesa_BindSampler(ctx->Texture.CurrentUnit, blit->samplerSave);
_mesa_DeleteSamplers(1, &blit->sampler);
if (blit->tempTex)
_mesa_DeleteTextures(1, &blit->tempTex);
}
GLboolean
_mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint *tex,
struct gl_texture_object **texObj,
GLenum *target)
{
struct gl_texture_image *texImage;
if (rb->NumSamples > 1)
*target = GL_TEXTURE_2D_MULTISAMPLE;
else
*target = GL_TEXTURE_2D;
_mesa_GenTextures(1, tex);
_mesa_BindTexture(*target, *tex);
*texObj = _mesa_lookup_texture(ctx, *tex);
texImage = _mesa_get_tex_image(ctx, *texObj, *target, 0);
if (!ctx->Driver.BindRenderbufferTexImage(ctx, rb, texImage)) {
_mesa_DeleteTextures(1, tex);
return false;
}
if (ctx->Driver.FinishRenderTexture && !rb->NeedsFinishRenderTexture) {
rb->NeedsFinishRenderTexture = true;
ctx->Driver.FinishRenderTexture(ctx, rb);
}
return true;
}
GLuint
_mesa_meta_setup_sampler(struct gl_context *ctx,
const struct gl_texture_object *texObj,
GLenum target, GLenum filter, GLuint srcLevel)
{
GLuint sampler;
_mesa_GenSamplers(1, &sampler);
_mesa_BindSampler(ctx->Texture.CurrentUnit, sampler);
/* Prepare src texture state */
_mesa_BindTexture(target, texObj->Name);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, filter);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, filter);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
}
_mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
return sampler;
}
/**
* Meta implementation of ctx->Driver.BlitFramebuffer() in terms
* of texture mapping and polygon rendering.
@@ -659,7 +684,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
/* Only scissor affects blit, but we're doing to set a custom scissor if
* necessary anyway, so save/clear state.
*/
_mesa_meta_begin(ctx, MESA_META_ALL);
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS);
/* If the clipping earlier changed the destination rect at all, then
* enable the scissor to clip to it.
@@ -707,7 +732,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
_mesa_meta_end(ctx);
fallback:
if (mask) {
if (mask && !ctx->Meta->Blit.no_ctsi_fallback) {
_swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1, mask, filter);
}

View File

@@ -182,7 +182,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
faceTarget = target;
}
_mesa_meta_begin(ctx, MESA_META_ALL);
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS);
/* Choose between glsl version and fixed function version of
* GenerateMipmap function.

View File

@@ -76,6 +76,8 @@ i965_FILES = \
brw_lower_texture_gradients.cpp \
brw_lower_unnormalized_offset.cpp \
brw_meta_updownsample.c \
brw_meta_stencil_blit.c \
brw_meta_util.c \
brw_misc_state.c \
brw_object_purgeable.c \
brw_performance_monitor.c \

View File

@@ -31,87 +31,10 @@
#include "brw_context.h"
#include "brw_blorp_blit_eu.h"
#include "brw_state.h"
#include "brw_meta_util.h"
#define FILE_DEBUG_FLAG DEBUG_BLORP
/**
* Helper function for handling mirror image blits.
*
* If coord0 > coord1, swap them and invert the "mirror" boolean.
*/
static inline void
fixup_mirroring(bool &mirror, GLfloat &coord0, GLfloat &coord1)
{
if (coord0 > coord1) {
mirror = !mirror;
GLfloat tmp = coord0;
coord0 = coord1;
coord1 = tmp;
}
}
/**
* Adjust {src,dst}_x{0,1} to account for clipping and scissoring of
* destination coordinates.
*
* Return true if there is still blitting to do, false if all pixels got
* rejected by the clip and/or scissor.
*
* For clarity, the nomenclature of this function assumes we are clipping and
* scissoring the X coordinate; the exact same logic applies for Y
* coordinates.
*
* Note: this function may also be used to account for clipping of source
* coordinates, by swapping the roles of src and dst.
*/
static inline bool
clip_or_scissor(bool mirror, GLfloat &src_x0, GLfloat &src_x1, GLfloat &dst_x0,
GLfloat &dst_x1, GLfloat fb_xmin, GLfloat fb_xmax)
{
float scale = (float) (src_x1 - src_x0) / (dst_x1 - dst_x0);
/* If we are going to scissor everything away, stop. */
if (!(fb_xmin < fb_xmax &&
dst_x0 < fb_xmax &&
fb_xmin < dst_x1 &&
dst_x0 < dst_x1)) {
return false;
}
/* Clip the destination rectangle, and keep track of how many pixels we
* clipped off of the left and right sides of it.
*/
GLint pixels_clipped_left = 0;
GLint pixels_clipped_right = 0;
if (dst_x0 < fb_xmin) {
pixels_clipped_left = fb_xmin - dst_x0;
dst_x0 = fb_xmin;
}
if (fb_xmax < dst_x1) {
pixels_clipped_right = dst_x1 - fb_xmax;
dst_x1 = fb_xmax;
}
/* If we are mirrored, then before applying pixels_clipped_{left,right} to
* the source coordinates, we need to flip them to account for the
* mirroring.
*/
if (mirror) {
GLint tmp = pixels_clipped_left;
pixels_clipped_left = pixels_clipped_right;
pixels_clipped_right = tmp;
}
/* Adjust the source rectangle to remove the pixels corresponding to those
* that were clipped/scissored out of the destination rectangle.
*/
src_x0 += pixels_clipped_left * scale;
src_x1 -= pixels_clipped_right * scale;
return true;
}
static struct intel_mipmap_tree *
find_miptree(GLbitfield buffer_bit, struct intel_renderbuffer *irb)
{
@@ -244,47 +167,12 @@ try_blorp_blit(struct brw_context *brw,
const struct gl_framebuffer *read_fb = ctx->ReadBuffer;
const struct gl_framebuffer *draw_fb = ctx->DrawBuffer;
/* Detect if the blit needs to be mirrored */
bool mirror_x = false, mirror_y = false;
fixup_mirroring(mirror_x, srcX0, srcX1);
fixup_mirroring(mirror_x, dstX0, dstX1);
fixup_mirroring(mirror_y, srcY0, srcY1);
fixup_mirroring(mirror_y, dstY0, dstY1);
/* If the destination rectangle needs to be clipped or scissored, do so.
*/
if (!(clip_or_scissor(mirror_x, srcX0, srcX1, dstX0, dstX1,
draw_fb->_Xmin, draw_fb->_Xmax) &&
clip_or_scissor(mirror_y, srcY0, srcY1, dstY0, dstY1,
draw_fb->_Ymin, draw_fb->_Ymax))) {
/* Everything got clipped/scissored away, so the blit was successful. */
bool mirror_x, mirror_y;
if (brw_meta_mirror_clip_and_scissor(ctx,
&srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1,
&mirror_x, &mirror_y))
return true;
}
/* If the source rectangle needs to be clipped or scissored, do so. */
if (!(clip_or_scissor(mirror_x, dstX0, dstX1, srcX0, srcX1,
0, read_fb->Width) &&
clip_or_scissor(mirror_y, dstY0, dstY1, srcY0, srcY1,
0, read_fb->Height))) {
/* Everything got clipped/scissored away, so the blit was successful. */
return true;
}
/* Account for the fact that in the system framebuffer, the origin is at
* the lower left.
*/
if (_mesa_is_winsys_fbo(read_fb)) {
GLint tmp = read_fb->Height - srcY0;
srcY0 = read_fb->Height - srcY1;
srcY1 = tmp;
mirror_y = !mirror_y;
}
if (_mesa_is_winsys_fbo(draw_fb)) {
GLint tmp = draw_fb->Height - dstY0;
dstY0 = draw_fb->Height - dstY1;
dstY1 = tmp;
mirror_y = !mirror_y;
}
/* Find buffers */
struct intel_renderbuffer *src_irb;

View File

@@ -1475,9 +1475,23 @@ GLboolean brwCreateContext(gl_api api,
/*======================================================================
* brw_misc_state.c
*/
GLuint brw_get_rb_for_slice(struct brw_context *brw,
struct intel_mipmap_tree *mt,
unsigned level, unsigned layer, bool flat);
void brw_meta_updownsample(struct brw_context *brw,
struct intel_mipmap_tree *src,
struct intel_mipmap_tree *dst);
void brw_meta_fbo_stencil_blit(struct brw_context *brw,
GLfloat srcX0, GLfloat srcY0,
GLfloat srcX1, GLfloat srcY1,
GLfloat dstX0, GLfloat dstY0,
GLfloat dstX1, GLfloat dstY1);
void brw_meta_stencil_updownsample(struct brw_context *brw,
struct intel_mipmap_tree *src,
struct intel_mipmap_tree *dst);
/*======================================================================
* brw_misc_state.c
*/

View File

@@ -0,0 +1,524 @@
/*
* Copyright © 2014 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/**
* @file brw_meta_stencil_blit.c
*
* Implements upsampling, downsampling and scaling of stencil miptrees. The
* logic can be originally found in brw_blorp_blit.c.
* Implementation creates a temporary draw framebuffer object and attaches the
* destination stencil buffer attachment as color attachment. Source attachment
* is in turn treated as a stencil texture and the glsl program used for the
* blitting samples it using stencil-indexing.
*
* Unfortunately as the data port does not support interleaved msaa-surfaces
* (stencil is always IMS), the glsl program needs to handle the writing of
* individual samples manually. Surface is configured as if it were single
* sampled (with adjusted dimensions) and the glsl program extracts the
* sample indices from the input coordinates for correct texturing.
*
* Target surface is also configured as Y-tiled instead of W-tiled in order
* to support generations 6-7. Later hardware supports W-tiled as render target
* and the logic here could be simplified for those.
*/
#include "brw_context.h"
#include "intel_batchbuffer.h"
#include "intel_fbo.h"
#include "main/blit.h"
#include "main/buffers.h"
#include "main/fbobject.h"
#include "main/uniforms.h"
#include "main/texparam.h"
#include "main/texobj.h"
#include "main/viewport.h"
#include "main/enable.h"
#include "main/blend.h"
#include "main/varray.h"
#include "main/shaderapi.h"
#include "glsl/ralloc.h"
#include "drivers/common/meta.h"
#include "brw_meta_util.h"
#define FILE_DEBUG_FLAG DEBUG_FBO
struct blit_dims {
int src_x0, src_y0, src_x1, src_y1;
int dst_x0, dst_y0, dst_x1, dst_y1;
bool mirror_x, mirror_y;
};
static const char *vs_source =
"#version 130\n"
"in vec2 position;\n"
"out vec2 tex_coords;\n"
"void main()\n"
"{\n"
" tex_coords = (position + 1.0) / 2.0;\n"
" gl_Position = vec4(position, 0.0, 1.0);\n"
"}\n";
static const struct sampler_and_fetch {
const char *sampler;
const char *fetch;
} samplers[] = {
{ "uniform usampler2D texSampler;\n",
" out_color = texelFetch(texSampler, txl_coords, 0)" },
{ "#extension GL_ARB_texture_multisample : enable\n"
"uniform usampler2DMS texSampler;\n",
" out_color = texelFetch(texSampler, txl_coords, sample_index)" }
};
/**
* Translating Y-tiled to W-tiled:
*
* X' = (X & ~0b1011) >> 1 | (Y & 0b1) << 2 | X & 0b1
* Y' = (Y & ~0b1) << 1 | (X & 0b1000) >> 2 | (X & 0b10) >> 1
*/
static const char *fs_tmpl =
"#version 130\n"
"%s"
"uniform float src_x_scale;\n"
"uniform float src_y_scale;\n"
"uniform float src_x_off;\n" /* Top right coordinates of the source */
"uniform float src_y_off;\n" /* rectangle in W-tiled space. */
"uniform float dst_x_off;\n" /* Top right coordinates of the target */
"uniform float dst_y_off;\n" /* rectangle in Y-tiled space. */
"uniform float draw_rect_w;\n" /* This is the unnormalized size of the */
"uniform float draw_rect_h;\n" /* drawing rectangle in Y-tiled space. */
"uniform int dst_x0;\n" /* This is the bounding rectangle in the W-tiled */
"uniform int dst_x1;\n" /* space that will be used to skip pixels lying */
"uniform int dst_y0;\n" /* outside. In some cases the Y-tiled rectangle */
"uniform int dst_y1;\n" /* is larger. */
"uniform int dst_num_samples;\n"
"in vec2 tex_coords;\n"
"ivec2 txl_coords;\n"
"int sample_index;\n"
"out uvec4 out_color;\n"
"\n"
"void get_unorm_target_coords()\n"
"{\n"
" txl_coords.x = int(tex_coords.x * draw_rect_w + dst_x_off);\n"
" txl_coords.y = int(tex_coords.y * draw_rect_h + dst_y_off);\n"
"}\n"
"\n"
"void translate_dst_to_src()\n"
"{\n"
" txl_coords.x = int(float(txl_coords.x) * src_x_scale + src_x_off);\n"
" txl_coords.y = int(float(txl_coords.y) * src_y_scale + src_y_off);\n"
"}\n"
"\n"
"void translate_y_to_w_tiling()\n"
"{\n"
" int X = txl_coords.x;\n"
" int Y = txl_coords.y;\n"
" txl_coords.x = (X & int(0xfff4)) >> 1;\n"
" txl_coords.x |= ((Y & int(0x1)) << 2);\n"
" txl_coords.x |= (X & int(0x1));\n"
" txl_coords.y = (Y & int(0xfffe)) << 1;\n"
" txl_coords.y |= ((X & int(0x8)) >> 2);\n"
" txl_coords.y |= ((X & int(0x2)) >> 1);\n"
"}\n"
"\n"
"void decode_msaa()\n"
"{\n"
" int X = txl_coords.x;\n"
" int Y = txl_coords.y;\n"
" switch (dst_num_samples) {\n"
" case 0:\n"
" sample_index = 0;\n"
" break;\n"
" case 2:\n"
" txl_coords.x = ((X & int(0xfffc)) >> 1) | (X & int(0x1));\n"
" sample_index = (X & 0x2) >> 1;\n"
" break;\n"
" case 4:\n"
" txl_coords.x = ((X & int(0xfffc)) >> 1) | (X & int(0x1));\n"
" txl_coords.y = ((Y & int(0xfffc)) >> 1) | (Y & int(0x1));\n"
" sample_index = (Y & 0x2) | ((X & 0x2) >> 1);\n"
" break;\n"
" case 8:\n"
" txl_coords.x = ((X & int(0xfff8)) >> 2) | (X & int(0x1));\n"
" txl_coords.y = ((Y & int(0xfffc)) >> 1) | (Y & int(0x1));\n"
" sample_index = (X & 0x4) | (Y & 0x2) | ((X & 0x2) >> 1);\n"
" }\n"
"}\n"
"\n"
"void discard_outside_bounding_rect()\n"
"{\n"
" int X = txl_coords.x;\n"
" int Y = txl_coords.y;\n"
" if (X >= dst_x1 || X < dst_x0 || Y >= dst_y1 || Y < dst_y0)\n"
" discard;\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" get_unorm_target_coords();\n"
" translate_y_to_w_tiling();\n"
" decode_msaa();"
" discard_outside_bounding_rect();\n"
" translate_dst_to_src();\n"
" %s;\n"
"}\n";
/**
* Setup uniforms telling the coordinates of the destination rectangle in the
* native w-tiled space. These are needed to ignore pixels that lie outside.
* The destination is drawn as Y-tiled and in some cases the Y-tiled drawing
* rectangle is larger than the original (for example 1x4 w-tiled requires
* 16x2 y-tiled).
*/
static void
setup_bounding_rect(GLuint prog, const struct blit_dims *dims)
{
_mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_x0"), dims->dst_x0);
_mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_x1"), dims->dst_x1);
_mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_y0"), dims->dst_y0);
_mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_y1"), dims->dst_y1);
}
/**
* Setup uniforms telling the destination width, height and the offset. These
* are needed to unnoormalize the input coordinates and to correctly translate
* between destination and source that may have differing offsets.
*/
static void
setup_drawing_rect(GLuint prog, const struct blit_dims *dims)
{
_mesa_Uniform1f(_mesa_GetUniformLocation(prog, "draw_rect_w"),
dims->dst_x1 - dims->dst_x0);
_mesa_Uniform1f(_mesa_GetUniformLocation(prog, "draw_rect_h"),
dims->dst_y1 - dims->dst_y0);
_mesa_Uniform1f(_mesa_GetUniformLocation(prog, "dst_x_off"), dims->dst_x0);
_mesa_Uniform1f(_mesa_GetUniformLocation(prog, "dst_y_off"), dims->dst_y0);
}
/**
* When not mirroring a coordinate (say, X), we need:
* src_x - src_x0 = (dst_x - dst_x0 + 0.5) * scale
* Therefore:
* src_x = src_x0 + (dst_x - dst_x0 + 0.5) * scale
*
* The program uses "round toward zero" to convert the transformed floating
* point coordinates to integer coordinates, whereas the behaviour we actually
* want is "round to nearest", so 0.5 provides the necessary correction.
*
* When mirroring X we need:
* src_x - src_x0 = dst_x1 - dst_x - 0.5
* Therefore:
* src_x = src_x0 + (dst_x1 -dst_x - 0.5) * scale
*/
static void
setup_coord_coeff(GLuint prog, GLuint multiplier, GLuint offset,
int src_0, int src_1, int dst_0, int dst_1, bool mirror)
{
const float scale = ((float)(src_1 - src_0)) / (dst_1 - dst_0);
if (mirror) {
_mesa_Uniform1f(multiplier, -scale);
_mesa_Uniform1f(offset, src_0 + (dst_1 - 0.5) * scale);
} else {
_mesa_Uniform1f(multiplier, scale);
_mesa_Uniform1f(offset, src_0 + (-dst_0 + 0.5) * scale);
}
}
/**
* Setup uniforms providing relation between source and destination surfaces.
* Destination coordinates are in Y-tiling layout while texelFetch() expects
* W-tiled coordinates. Once the destination coordinates are re-interpreted by
* the program into the original W-tiled layout, the program needs to know the
* offset and scaling factors between the destination and source.
* Note that these are calculated in the original W-tiled space before the
* destination rectangle is adjusted for possible msaa and Y-tiling.
*/
static void
setup_coord_transform(GLuint prog, const struct blit_dims *dims)
{
setup_coord_coeff(prog,
_mesa_GetUniformLocation(prog, "src_x_scale"),
_mesa_GetUniformLocation(prog, "src_x_off"),
dims->src_x0, dims->src_x1, dims->dst_x0, dims->dst_x1,
dims->mirror_x);
setup_coord_coeff(prog,
_mesa_GetUniformLocation(prog, "src_y_scale"),
_mesa_GetUniformLocation(prog, "src_y_off"),
dims->src_y0, dims->src_y1, dims->dst_y0, dims->dst_y1,
dims->mirror_y);
}
static GLuint
setup_program(struct gl_context *ctx, bool msaa_tex)
{
struct blit_state *blit = &ctx->Meta->Blit;
static GLuint prog_cache[] = { 0, 0 };
const char *fs_source;
const struct sampler_and_fetch *sampler = &samplers[msaa_tex];
_mesa_meta_setup_vertex_objects(&blit->VAO, &blit->VBO, true, 2, 2, 0);
if (prog_cache[msaa_tex]) {
_mesa_UseProgram(prog_cache[msaa_tex]);
return prog_cache[msaa_tex];
}
fs_source = ralloc_asprintf(NULL, fs_tmpl, sampler->sampler,
sampler->fetch);
_mesa_meta_compile_and_link_program(ctx, vs_source, fs_source,
"i965 stencil blit",
&prog_cache[msaa_tex]);
ralloc_free(fs_source);
return prog_cache[msaa_tex];
}
/**
* Samples in stencil buffer are interleaved, and unfortunately the data port
* does not support it as render target. Therefore the surface is set up as
* single sampled and the program handles the interleaving.
* In case of single sampled stencil, the render buffer is adjusted with
* twice the base level height in order for the program to be able to write
* any mip-level. (Used to set the drawing rectangle for the hw).
*/
static void
adjust_msaa(struct blit_dims *dims, int num_samples)
{
if (num_samples == 2) {
dims->dst_x0 *= 2;
dims->dst_x1 *= 2;
} else if (num_samples) {
const int x_num_samples = num_samples / 2;
dims->dst_x0 = ROUND_DOWN_TO(dims->dst_x0 * x_num_samples, num_samples);
dims->dst_y0 = ROUND_DOWN_TO(dims->dst_y0 * 2, 4);
dims->dst_x1 = ALIGN(dims->dst_x1 * x_num_samples, num_samples);
dims->dst_y1 = ALIGN(dims->dst_y1 * 2, 4);
}
}
/**
* Stencil is mapped as Y-tiled render target and the dimensions need to be
* adjusted in order for the Y-tiled rectangle to cover the entire linear
* memory space of the original W-tiled rectangle.
*/
static void
adjust_tiling(struct blit_dims *dims, int num_samples)
{
const unsigned x_align = 8, y_align = num_samples > 2 ? 8 : 4;
dims->dst_x0 = ROUND_DOWN_TO(dims->dst_x0, x_align) * 2;
dims->dst_y0 = ROUND_DOWN_TO(dims->dst_y0, y_align) / 2;
dims->dst_x1 = ALIGN(dims->dst_x1, x_align) * 2;
dims->dst_y1 = ALIGN(dims->dst_y1, y_align) / 2;
}
/**
* When stencil is mapped as Y-tiled render target the mip-level offsets
* calculated for the Y-tiling do not always match the offsets in W-tiling.
* Therefore the sampling engine cannot be used for individual mip-level
* access but the program needs to do it internally. This can be achieved
* by shifting the coordinates of the blit rectangle here.
*/
static void
adjust_mip_level(const struct intel_mipmap_tree *mt,
unsigned level, unsigned layer, struct blit_dims *dims)
{
unsigned x_offset;
unsigned y_offset;
intel_miptree_get_image_offset(mt, level, layer, &x_offset, &y_offset);
dims->dst_x0 += x_offset;
dims->dst_y0 += y_offset;
dims->dst_x1 += x_offset;
dims->dst_y1 += y_offset;
}
static void
prepare_vertex_data(void)
{
static const struct vertex verts[] = {
{ .x = -1.0f, .y = -1.0f },
{ .x = 1.0f, .y = -1.0f },
{ .x = 1.0f, .y = 1.0f },
{ .x = -1.0f, .y = 1.0f } };
_mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
}
static void
set_read_rb_tex_image(struct gl_context *ctx, struct fb_tex_blit_state *blit,
GLenum *target)
{
const struct gl_renderbuffer_attachment *att =
&ctx->ReadBuffer->Attachment[BUFFER_STENCIL];
struct gl_renderbuffer *rb = att->Renderbuffer;
struct gl_texture_object *tex_obj;
unsigned level = 0;
/* If the renderbuffer is already backed by an tex image, use it. */
if (att->Texture) {
tex_obj = att->Texture;
*target = tex_obj->Target;
level = att->TextureLevel;
} else {
_mesa_meta_bind_rb_as_tex_image(ctx, rb, &blit->tempTex, &tex_obj,
target);
}
blit->baseLevelSave = tex_obj->BaseLevel;
blit->maxLevelSave = tex_obj->MaxLevel;
blit->sampler = _mesa_meta_setup_sampler(ctx, tex_obj, *target,
GL_NEAREST, level);
}
static void
brw_meta_stencil_blit(struct brw_context *brw,
struct intel_mipmap_tree *dst_mt,
unsigned dst_level, unsigned dst_layer,
const struct blit_dims *orig_dims)
{
struct gl_context *ctx = &brw->ctx;
struct blit_dims dims = *orig_dims;
struct fb_tex_blit_state blit;
GLuint prog, fbo, rbo;
GLenum target;
_mesa_meta_fb_tex_blit_begin(ctx, &blit);
_mesa_GenFramebuffers(1, &fbo);
/* Force the surface to be configured for level zero. */
rbo = brw_get_rb_for_slice(brw, dst_mt, 0, dst_layer, true);
adjust_msaa(&dims, dst_mt->num_samples);
adjust_tiling(&dims, dst_mt->num_samples);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
_mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_RENDERBUFFER, rbo);
_mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
ctx->DrawBuffer->_Status = GL_FRAMEBUFFER_COMPLETE;
set_read_rb_tex_image(ctx, &blit, &target);
_mesa_TexParameteri(target, GL_DEPTH_STENCIL_TEXTURE_MODE,
GL_STENCIL_INDEX);
prog = setup_program(ctx, target != GL_TEXTURE_2D);
setup_bounding_rect(prog, orig_dims);
setup_drawing_rect(prog, &dims);
setup_coord_transform(prog, orig_dims);
_mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_num_samples"),
dst_mt->num_samples);
prepare_vertex_data();
_mesa_set_viewport(ctx, 0, dims.dst_x0, dims.dst_y0,
dims.dst_x1 - dims.dst_x0, dims.dst_y1 - dims.dst_y0);
_mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
_mesa_set_enable(ctx, GL_DEPTH_TEST, false);
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
_mesa_meta_fb_tex_blit_end(ctx, target, &blit);
_mesa_meta_end(ctx);
_mesa_DeleteRenderbuffers(1, &rbo);
_mesa_DeleteFramebuffers(1, &fbo);
}
void
brw_meta_fbo_stencil_blit(struct brw_context *brw,
GLfloat src_x0, GLfloat src_y0,
GLfloat src_x1, GLfloat src_y1,
GLfloat dst_x0, GLfloat dst_y0,
GLfloat dst_x1, GLfloat dst_y1)
{
struct gl_context *ctx = &brw->ctx;
struct gl_renderbuffer *draw_fb =
ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
const struct intel_renderbuffer *dst_irb = intel_renderbuffer(draw_fb);
struct intel_mipmap_tree *dst_mt = dst_irb->mt;
if (!dst_mt)
return;
if (dst_mt->stencil_mt)
dst_mt = dst_mt->stencil_mt;
bool mirror_x, mirror_y;
if (brw_meta_mirror_clip_and_scissor(ctx,
&src_x0, &src_y0, &src_x1, &src_y1,
&dst_x0, &dst_y0, &dst_x1, &dst_y1,
&mirror_x, &mirror_y))
return;
struct blit_dims dims = { .src_x0 = src_x0, .src_y0 = src_y0,
.src_x1 = src_x1, .src_y1 = src_y1,
.dst_x0 = dst_x0, .dst_y0 = dst_y0,
.dst_x1 = dst_x1, .dst_y1 = dst_y1,
.mirror_x = mirror_x, .mirror_y = mirror_y };
adjust_mip_level(dst_mt, dst_irb->mt_level, dst_irb->mt_layer, &dims);
intel_batchbuffer_emit_mi_flush(brw);
_mesa_meta_begin(ctx, MESA_META_ALL);
brw_meta_stencil_blit(brw,
dst_mt, dst_irb->mt_level, dst_irb->mt_layer, &dims);
intel_batchbuffer_emit_mi_flush(brw);
}
void
brw_meta_stencil_updownsample(struct brw_context *brw,
struct intel_mipmap_tree *src,
struct intel_mipmap_tree *dst)
{
struct gl_context *ctx = &brw->ctx;
struct blit_dims dims = {
.src_x0 = 0, .src_y0 = 0,
.src_x1 = src->logical_width0, .src_y1 = src->logical_height0,
.dst_x0 = 0, .dst_y0 = 0,
.dst_x1 = dst->logical_width0, .dst_y1 = dst->logical_height0,
.mirror_x = 0, .mirror_y = 0 };
GLuint fbo, rbo;
if (dst->stencil_mt)
dst = dst->stencil_mt;
intel_batchbuffer_emit_mi_flush(brw);
_mesa_meta_begin(ctx, MESA_META_ALL);
_mesa_GenFramebuffers(1, &fbo);
rbo = brw_get_rb_for_slice(brw, src, 0, 0, false);
_mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
_mesa_FramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, rbo);
brw_meta_stencil_blit(brw, dst, 0, 0, &dims);
intel_batchbuffer_emit_mi_flush(brw);
_mesa_DeleteRenderbuffers(1, &rbo);
_mesa_DeleteFramebuffers(1, &fbo);
}

View File

@@ -27,6 +27,7 @@
#include "main/blit.h"
#include "main/buffers.h"
#include "main/enums.h"
#include "main/fbobject.h"
#include "drivers/common/meta.h"
@@ -44,8 +45,10 @@
*
* Clobbers the current renderbuffer binding (ctx->CurrentRenderbuffer).
*/
static GLuint
brw_get_rb_for_first_slice(struct brw_context *brw, struct intel_mipmap_tree *mt)
GLuint
brw_get_rb_for_slice(struct brw_context *brw,
struct intel_mipmap_tree *mt,
unsigned level, unsigned layer, bool flat)
{
struct gl_context *ctx = &brw->ctx;
GLuint rbo;
@@ -62,11 +65,27 @@ brw_get_rb_for_first_slice(struct brw_context *brw, struct intel_mipmap_tree *mt
irb = intel_renderbuffer(rb);
rb->Format = mt->format;
rb->_BaseFormat = _mesa_base_fbo_format(ctx, mt->format);
rb->_BaseFormat = _mesa_get_format_base_format(mt->format);
rb->NumSamples = mt->num_samples;
rb->Width = mt->logical_width0;
rb->Height = mt->logical_height0;
/* Program takes care of msaa and mip-level access manually for stencil.
* The surface is also treated as Y-tiled instead of as W-tiled calling for
* twice the width and half the height in dimensions.
*/
if (flat) {
const unsigned halign_stencil = 8;
rb->NumSamples = 0;
rb->Width = ALIGN(mt->total_width, halign_stencil) * 2;
rb->Height = (mt->total_height / mt->physical_depth0) / 2;
irb->mt_level = 0;
} else {
rb->NumSamples = mt->num_samples;
rb->Width = mt->logical_width0;
rb->Height = mt->logical_height0;
irb->mt_level = level;
}
irb->mt_layer = layer;
intel_miptree_reference(&irb->mt, mt);
@@ -101,8 +120,8 @@ brw_meta_updownsample(struct brw_context *brw,
_mesa_meta_begin(ctx, MESA_META_ALL);
_mesa_GenFramebuffers(2, fbos);
src_rbo = brw_get_rb_for_first_slice(brw, src_mt);
dst_rbo = brw_get_rb_for_first_slice(brw, dst_mt);
src_rbo = brw_get_rb_for_slice(brw, src_mt, 0, 0, false);
dst_rbo = brw_get_rb_for_slice(brw, dst_mt, 0, 0, false);
src_fbo = fbos[0];
dst_fbo = fbos[1];

View File

@@ -0,0 +1,160 @@
/*
* Copyright © 2014 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "brw_meta_util.h"
#include "main/fbobject.h"
/**
* Helper function for handling mirror image blits.
*
* If coord0 > coord1, swap them and invert the "mirror" boolean.
*/
static inline void
fixup_mirroring(bool *mirror, float *coord0, float *coord1)
{
if (*coord0 > *coord1) {
*mirror = !*mirror;
float tmp = *coord0;
*coord0 = *coord1;
*coord1 = tmp;
}
}
/**
* Adjust {src,dst}_x{0,1} to account for clipping and scissoring of
* destination coordinates.
*
* Return true if there is still blitting to do, false if all pixels got
* rejected by the clip and/or scissor.
*
* For clarity, the nomenclature of this function assumes we are clipping and
* scissoring the X coordinate; the exact same logic applies for Y
* coordinates.
*
* Note: this function may also be used to account for clipping of source
* coordinates, by swapping the roles of src and dst.
*/
static inline bool
clip_or_scissor(bool mirror,
GLfloat *src_x0, GLfloat *src_x1,
GLfloat *dst_x0, GLfloat *dst_x1,
GLfloat fb_xmin, GLfloat fb_xmax)
{
float scale = (float) (*src_x1 - *src_x0) / (*dst_x1 - *dst_x0);
/* If we are going to scissor everything away, stop. */
if (!(fb_xmin < fb_xmax &&
*dst_x0 < fb_xmax &&
fb_xmin < *dst_x1 &&
*dst_x0 < *dst_x1)) {
return false;
}
/* Clip the destination rectangle, and keep track of how many pixels we
* clipped off of the left and right sides of it.
*/
int pixels_clipped_left = 0;
int pixels_clipped_right = 0;
if (*dst_x0 < fb_xmin) {
pixels_clipped_left = fb_xmin - *dst_x0;
*dst_x0 = fb_xmin;
}
if (fb_xmax < *dst_x1) {
pixels_clipped_right = *dst_x1 - fb_xmax;
*dst_x1 = fb_xmax;
}
/* If we are mirrored, then before applying pixels_clipped_{left,right} to
* the source coordinates, we need to flip them to account for the
* mirroring.
*/
if (mirror) {
int tmp = pixels_clipped_left;
pixels_clipped_left = pixels_clipped_right;
pixels_clipped_right = tmp;
}
/* Adjust the source rectangle to remove the pixels corresponding to those
* that were clipped/scissored out of the destination rectangle.
*/
*src_x0 += pixels_clipped_left * scale;
*src_x1 -= pixels_clipped_right * scale;
return true;
}
bool
brw_meta_mirror_clip_and_scissor(const struct gl_context *ctx,
GLfloat *srcX0, GLfloat *srcY0,
GLfloat *srcX1, GLfloat *srcY1,
GLfloat *dstX0, GLfloat *dstY0,
GLfloat *dstX1, GLfloat *dstY1,
bool *mirror_x, bool *mirror_y)
{
const struct gl_framebuffer *read_fb = ctx->ReadBuffer;
const struct gl_framebuffer *draw_fb = ctx->DrawBuffer;
*mirror_x = false;
*mirror_y = false;
/* Detect if the blit needs to be mirrored */
fixup_mirroring(mirror_x, srcX0, srcX1);
fixup_mirroring(mirror_x, dstX0, dstX1);
fixup_mirroring(mirror_y, srcY0, srcY1);
fixup_mirroring(mirror_y, dstY0, dstY1);
/* If the destination rectangle needs to be clipped or scissored, do so. */
if (!(clip_or_scissor(*mirror_x, srcX0, srcX1, dstX0, dstX1,
draw_fb->_Xmin, draw_fb->_Xmax) &&
clip_or_scissor(*mirror_y, srcY0, srcY1, dstY0, dstY1,
draw_fb->_Ymin, draw_fb->_Ymax))) {
/* Everything got clipped/scissored away, so the blit was successful. */
return true;
}
/* If the source rectangle needs to be clipped or scissored, do so. */
if (!(clip_or_scissor(*mirror_x, dstX0, dstX1, srcX0, srcX1,
0, read_fb->Width) &&
clip_or_scissor(*mirror_y, dstY0, dstY1, srcY0, srcY1,
0, read_fb->Height))) {
/* Everything got clipped/scissored away, so the blit was successful. */
return true;
}
/* Account for the fact that in the system framebuffer, the origin is at
* the lower left.
*/
if (_mesa_is_winsys_fbo(read_fb)) {
GLint tmp = read_fb->Height - *srcY0;
*srcY0 = read_fb->Height - *srcY1;
*srcY1 = tmp;
*mirror_y = !*mirror_y;
}
if (_mesa_is_winsys_fbo(draw_fb)) {
GLint tmp = draw_fb->Height - *dstY0;
*dstY0 = draw_fb->Height - *dstY1;
*dstY1 = tmp;
*mirror_y = !*mirror_y;
}
return false;
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright © 2014 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef BRW_META_UTIL_H
#define BRW_META_UTIL_H
#include <stdbool.h>
#include "main/mtypes.h"
#ifdef __cplusplus
extern "C" {
#endif
bool
brw_meta_mirror_clip_and_scissor(const struct gl_context *ctx,
GLfloat *srcX0, GLfloat *srcY0,
GLfloat *srcX1, GLfloat *srcY1,
GLfloat *dstX0, GLfloat *dstY0,
GLfloat *dstX1, GLfloat *dstY1,
bool *mirror_x, bool *mirror_y);
#ifdef __cplusplus
}
#endif
#endif /* BRW_META_UTIL_H */

View File

@@ -206,6 +206,12 @@ void gen4_init_vtable_surface_functions(struct brw_context *brw);
uint32_t brw_get_surface_tiling_bits(uint32_t tiling);
uint32_t brw_get_surface_num_multisamples(unsigned num_samples);
void brw_configure_w_tiled(const struct intel_mipmap_tree *mt,
bool is_render_target,
unsigned *width, unsigned *height,
unsigned *pitch, uint32_t *tiling,
unsigned *format);
uint32_t brw_format_for_mesa_format(mesa_format mesa_format);
GLuint translate_tex_target(GLenum target);

View File

@@ -101,6 +101,30 @@ brw_get_surface_num_multisamples(unsigned num_samples)
return BRW_SURFACE_MULTISAMPLECOUNT_1;
}
void
brw_configure_w_tiled(const struct intel_mipmap_tree *mt,
bool is_render_target,
unsigned *width, unsigned *height,
unsigned *pitch, uint32_t *tiling, unsigned *format)
{
static const unsigned halign_stencil = 8;
/* In Y-tiling row is twice as wide as in W-tiling, and subsequently
* there are half as many rows.
* In addition, mip-levels are accessed manually by the program and
* therefore the surface is setup to cover all the mip-levels for one slice.
* (Hardware is still used to access individual slices).
*/
*tiling = I915_TILING_Y;
*pitch = mt->pitch * 2;
*width = ALIGN(mt->total_width, halign_stencil) * 2;
*height = (mt->total_height / mt->physical_depth0) / 2;
if (is_render_target) {
*format = BRW_SURFACEFORMAT_R8_UINT;
}
}
/**
* Compute the combination of DEPTH_TEXTURE_MODE and EXT_texture_swizzle

View File

@@ -65,7 +65,7 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
rb = (struct gl_renderbuffer*) irb;
if (rb) {
depth = MAX2(rb->Depth, 1);
depth = MAX2(irb->layer_count, 1);
if (rb->TexImage)
gl_target = rb->TexImage->TexObject->Target;
}
@@ -81,19 +81,16 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
surftype = BRW_SURFACE_2D;
depth *= 6;
break;
case GL_TEXTURE_3D:
assert(mt);
depth = MAX2(mt->logical_depth0, 1);
/* fallthrough */
default:
surftype = translate_tex_target(gl_target);
break;
}
if (fb->MaxNumLayers > 0 || !irb) {
min_array_element = 0;
} else if (irb->mt->num_samples > 1) {
/* Convert physical layer to logical layer. */
min_array_element = irb->mt_layer / irb->mt->num_samples;
} else {
min_array_element = irb->mt_layer;
}
min_array_element = irb ? irb->mt_layer : 0;
lod = irb ? irb->mt_level - irb->mt->first_level : 0;

View File

@@ -454,9 +454,11 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
mesa_format rb_format = _mesa_get_render_format(ctx, intel_rb_format(irb));
uint32_t surftype;
bool is_array = false;
int depth = MAX2(rb->Depth, 1);
int min_array_element;
int depth = MAX2(irb->layer_count, 1);
const uint8_t mocs = GEN7_MOCS_L3;
int min_array_element = irb->mt_layer / MAX2(mt->num_samples, 1);
GLenum gl_target = rb->TexImage ?
rb->TexImage->TexObject->Target : GL_TEXTURE_2D;
@@ -486,20 +488,15 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
is_array = true;
depth *= 6;
break;
case GL_TEXTURE_3D:
depth = MAX2(irb->mt->logical_depth0, 1);
/* fallthrough */
default:
surftype = translate_tex_target(gl_target);
is_array = _mesa_tex_target_is_array(gl_target);
break;
}
if (layered) {
min_array_element = 0;
} else if (irb->mt->num_samples > 1) {
min_array_element = irb->mt_layer / irb->mt->num_samples;
} else {
min_array_element = irb->mt_layer;
}
surf[0] = surftype << BRW_SURFACE_TYPE_SHIFT |
format << BRW_SURFACE_FORMAT_SHIFT |
(irb->mt->array_spacing_lod0 ? GEN7_SURFACE_ARYSPC_LOD0

View File

@@ -75,7 +75,7 @@ emit_depth_packets(struct brw_context *brw,
OUT_BATCH(((width - 1) << 4) | ((height - 1) << 18) | lod);
OUT_BATCH(((depth - 1) << 21) | (min_array_element << 10) | BDW_MOCS_WB);
OUT_BATCH(0);
OUT_BATCH(depth_mt ? depth_mt->qpitch >> 2 : 0);
OUT_BATCH(((depth - 1) << 21) | (depth_mt ? depth_mt->qpitch >> 2 : 0));
ADVANCE_BATCH();
if (!hiz) {
@@ -168,7 +168,7 @@ gen8_emit_depth_stencil_hiz(struct brw_context *brw,
rb = (struct gl_renderbuffer *) irb;
if (rb) {
depth = MAX2(rb->Depth, 1);
depth = MAX2(irb->layer_count, 1);
if (rb->TexImage)
gl_target = rb->TexImage->TexObject->Target;
}
@@ -184,19 +184,16 @@ gen8_emit_depth_stencil_hiz(struct brw_context *brw,
surftype = BRW_SURFACE_2D;
depth *= 6;
break;
case GL_TEXTURE_3D:
assert(mt);
depth = MAX2(mt->logical_depth0, 1);
/* fallthrough */
default:
surftype = translate_tex_target(gl_target);
break;
}
if (fb->MaxNumLayers > 0 || !irb) {
min_array_element = 0;
} else if (irb->mt->num_samples > 1) {
/* Convert physical to logical layer. */
min_array_element = irb->mt_layer / irb->mt->num_samples;
} else {
min_array_element = irb->mt_layer;
}
min_array_element = irb ? irb->mt_layer : 0;
lod = irb ? irb->mt_level - irb->mt->first_level : 0;

View File

@@ -422,6 +422,7 @@ gen8_generator::IF(unsigned predicate)
{
gen8_instruction *inst = next_inst(BRW_OPCODE_IF);
gen8_set_dst(brw, inst, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D)));
gen8_set_src0(brw, inst, brw_imm_d(0));
gen8_set_exec_size(inst, default_state.exec_size);
gen8_set_pred_control(inst, predicate);
gen8_set_mask_control(inst, BRW_MASK_ENABLE);
@@ -435,6 +436,7 @@ gen8_generator::ELSE()
{
gen8_instruction *inst = next_inst(BRW_OPCODE_ELSE);
gen8_set_dst(brw, inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src0(brw, inst, brw_imm_d(0));
gen8_set_mask_control(inst, BRW_MASK_ENABLE);
push_if_stack(inst);
return inst;
@@ -456,6 +458,7 @@ gen8_generator::ENDIF()
gen8_instruction *endif_inst = next_inst(BRW_OPCODE_ENDIF);
gen8_set_mask_control(endif_inst, BRW_MASK_ENABLE);
gen8_set_src0(brw, endif_inst, brw_imm_d(0));
patch_IF_ELSE(if_inst, else_inst, endif_inst);
return endif_inst;
@@ -577,8 +580,7 @@ gen8_generator::BREAK()
{
gen8_instruction *inst = next_inst(BRW_OPCODE_BREAK);
gen8_set_dst(brw, inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src0(brw, inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src1(brw, inst, brw_imm_d(0));
gen8_set_src0(brw, inst, brw_imm_d(0));
gen8_set_exec_size(inst, default_state.exec_size);
return inst;
}
@@ -588,8 +590,7 @@ gen8_generator::CONTINUE()
{
gen8_instruction *inst = next_inst(BRW_OPCODE_CONTINUE);
gen8_set_dst(brw, inst, brw_ip_reg());
gen8_set_src0(brw, inst, brw_ip_reg());
gen8_set_src1(brw, inst, brw_imm_d(0));
gen8_set_src0(brw, inst, brw_imm_d(0));
gen8_set_exec_size(inst, default_state.exec_size);
return inst;
}
@@ -601,8 +602,7 @@ gen8_generator::WHILE()
gen8_instruction *while_inst = next_inst(BRW_OPCODE_WHILE);
gen8_set_dst(brw, while_inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src0(brw, while_inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src1(brw, while_inst, brw_imm_ud(0));
gen8_set_src0(brw, while_inst, brw_imm_d(0));
gen8_set_jip(while_inst, 16 * (do_inst - while_inst));
gen8_set_exec_size(while_inst, default_state.exec_size);
@@ -614,7 +614,7 @@ gen8_generator::HALT()
{
gen8_instruction *inst = next_inst(BRW_OPCODE_HALT);
gen8_set_dst(brw, inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src0(brw, inst, retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
gen8_set_src0(brw, inst, brw_imm_d(0));
gen8_set_exec_size(inst, default_state.exec_size);
gen8_set_mask_control(inst, BRW_MASK_DISABLE);
return inst;

View File

@@ -134,17 +134,20 @@ gen8_update_texture_surface(struct gl_context *ctx,
struct intel_mipmap_tree *mt = intelObj->mt;
struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
mesa_format format = intelObj->_Format;
if (tObj->Target == GL_TEXTURE_BUFFER) {
brw_update_buffer_texture_surface(ctx, unit, surf_offset);
return;
}
if (tObj->StencilSampling && firstImage->_BaseFormat == GL_DEPTH_STENCIL)
if (tObj->StencilSampling && firstImage->_BaseFormat == GL_DEPTH_STENCIL) {
mt = mt->stencil_mt;
format = MESA_FORMAT_S_UINT8;
}
unsigned tiling_mode, pitch;
if (mt->format == MESA_FORMAT_S_UINT8) {
if (format == MESA_FORMAT_S_UINT8) {
tiling_mode = GEN8_SURFACE_TILING_W;
pitch = 2 * mt->pitch;
} else {
@@ -152,9 +155,14 @@ gen8_update_texture_surface(struct gl_context *ctx,
pitch = mt->pitch;
}
uint32_t tex_format = translate_tex_format(brw,
mt->format,
sampler->sRGBDecode);
/* If this is a view with restricted NumLayers, then our effective depth
* is not just the miptree depth.
*/
uint32_t effective_depth =
(tObj->Immutable && tObj->Target != GL_TEXTURE_3D) ? tObj->NumLayers
: mt->logical_depth0;
uint32_t tex_format = translate_tex_format(brw, format, sampler->sRGBDecode);
uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
13 * 4, 64, surf_offset);
@@ -178,11 +186,15 @@ gen8_update_texture_surface(struct gl_context *ctx,
surf[2] = SET_FIELD(mt->logical_width0 - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(mt->logical_height0 - 1, GEN7_SURFACE_HEIGHT);
surf[3] = SET_FIELD(mt->logical_depth0 - 1, BRW_SURFACE_DEPTH) | (pitch - 1);
surf[3] = SET_FIELD(effective_depth - 1, BRW_SURFACE_DEPTH) | (pitch - 1);
surf[4] = gen7_surface_msaa_bits(mt->num_samples, mt->msaa_layout);
surf[4] = gen7_surface_msaa_bits(mt->num_samples, mt->msaa_layout) |
SET_FIELD(tObj->MinLayer, GEN7_SURFACE_MIN_ARRAY_ELEMENT) |
SET_FIELD(effective_depth - 1,
GEN7_SURFACE_RENDER_TARGET_VIEW_EXTENT);
surf[5] = SET_FIELD(tObj->BaseLevel - mt->first_level, GEN7_SURFACE_MIN_LOD) |
surf[5] = SET_FIELD(tObj->MinLevel + tObj->BaseLevel - mt->first_level,
GEN7_SURFACE_MIN_LOD) |
(intelObj->_MaxLevel - tObj->BaseLevel); /* mip count */
surf[6] = 0;
@@ -272,12 +284,16 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
struct gl_context *ctx = &brw->ctx;
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
struct intel_mipmap_tree *mt = irb->mt;
unsigned width = mt->logical_width0;
unsigned height = mt->logical_height0;
unsigned pitch = mt->pitch;
uint32_t tiling = mt->tiling;
uint32_t format = 0;
uint32_t surf_type;
bool is_array = false;
int depth = MAX2(rb->Depth, 1);
int min_array_element;
int depth = MAX2(irb->layer_count, 1);
const int min_array_element = (mt->format == MESA_FORMAT_S_UINT8) ?
irb->mt_layer : (irb->mt_layer / MAX2(mt->num_samples, 1));
GLenum gl_target =
rb->TexImage ? rb->TexImage->TexObject->Target : GL_TEXTURE_2D;
@@ -286,9 +302,6 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
intel_miptree_used_for_rendering(mt);
/* Render targets can't use IMS layout. */
assert(mt->msaa_layout != INTEL_MSAA_LAYOUT_IMS);
switch (gl_target) {
case GL_TEXTURE_CUBE_MAP_ARRAY:
case GL_TEXTURE_CUBE_MAP:
@@ -296,27 +309,31 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
is_array = true;
depth *= 6;
break;
case GL_TEXTURE_3D:
depth = MAX2(irb->mt->logical_depth0, 1);
/* fallthrough */
default:
surf_type = translate_tex_target(gl_target);
is_array = _mesa_tex_target_is_array(gl_target);
break;
}
if (layered) {
min_array_element = 0;
} else if (mt->num_samples > 1) {
min_array_element = irb->mt_layer / mt->num_samples;
} else {
min_array_element = irb->mt_layer;
}
/* _NEW_BUFFERS */
mesa_format rb_format = _mesa_get_render_format(ctx, intel_rb_format(irb));
assert(brw_render_target_supported(brw, rb));
format = brw->render_target_format[rb_format];
if (unlikely(!brw->format_supported_as_render_target[rb_format])) {
_mesa_problem(ctx, "%s: renderbuffer format %s unsupported\n",
__FUNCTION__, _mesa_get_format_name(rb_format));
/* Render targets can't use IMS layout. Stencil in turn gets configured as
* single sampled and indexed manually by the program.
*/
if (mt->format == MESA_FORMAT_S_UINT8) {
brw_configure_w_tiled(mt, true, &width, &height, &pitch,
&tiling, &format);
} else {
assert(mt->msaa_layout != INTEL_MSAA_LAYOUT_IMS);
assert(brw_render_target_supported(brw, rb));
mesa_format rb_format = _mesa_get_render_format(ctx,
intel_rb_format(irb));
format = brw->render_target_format[rb_format];
if (unlikely(!brw->format_supported_as_render_target[rb_format]))
_mesa_problem(ctx, "%s: renderbuffer format %s unsupported\n",
__FUNCTION__, _mesa_get_format_name(rb_format));
}
uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, 13 * 4, 64,
@@ -327,20 +344,22 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
(format << BRW_SURFACE_FORMAT_SHIFT) |
vertical_alignment(mt) |
horizontal_alignment(mt) |
surface_tiling_mode(mt->tiling);
surface_tiling_mode(tiling);
surf[1] = SET_FIELD(BDW_MOCS_WT, GEN8_SURFACE_MOCS) | mt->qpitch >> 2;
surf[2] = SET_FIELD(mt->logical_width0 - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(mt->logical_height0 - 1, GEN7_SURFACE_HEIGHT);
surf[2] = SET_FIELD(width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(height - 1, GEN7_SURFACE_HEIGHT);
surf[3] = (depth - 1) << BRW_SURFACE_DEPTH_SHIFT |
(mt->pitch - 1); /* Surface Pitch */
(pitch - 1); /* Surface Pitch */
surf[4] = gen7_surface_msaa_bits(mt->num_samples, mt->msaa_layout) |
min_array_element << GEN7_SURFACE_MIN_ARRAY_ELEMENT_SHIFT |
surf[4] = min_array_element << GEN7_SURFACE_MIN_ARRAY_ELEMENT_SHIFT |
(depth - 1) << GEN7_SURFACE_RENDER_TARGET_VIEW_EXTENT_SHIFT;
if (mt->format != MESA_FORMAT_S_UINT8)
surf[4] |= gen7_surface_msaa_bits(mt->num_samples, mt->msaa_layout);
surf[5] = irb->mt_level - irb->mt->first_level;
surf[6] = 0; /* Nothing of relevance. */

View File

@@ -65,6 +65,7 @@ intelDrawBuffer(struct gl_context * ctx, GLenum mode)
* (including the fake front) before we start rendering again.
*/
dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
intel_prepare_render(brw);
}
}
@@ -80,6 +81,7 @@ intelReadBuffer(struct gl_context * ctx, GLenum mode)
* (including the fake front) before we start reading again.
*/
dri2InvalidateDrawable(brw->driContext->driReadablePriv);
intel_prepare_render(brw);
}
}

View File

@@ -284,6 +284,7 @@ intelInitExtensions(struct gl_context *ctx)
if (brw->gen >= 7) {
ctx->Extensions.ARB_conservative_depth = true;
ctx->Extensions.ARB_texture_view = true;
ctx->Extensions.AMD_vertex_shader_layer = true;
if (can_do_pipelined_register_writes(brw)) {
ctx->Extensions.ARB_transform_feedback2 = true;
@@ -302,10 +303,6 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.ARB_compute_shader = true;
}
if (brw->gen == 7) {
ctx->Extensions.ARB_texture_view = true;
}
if (brw->gen >= 8) {
ctx->Extensions.ARB_stencil_texturing = true;
}

View File

@@ -879,6 +879,15 @@ intel_blit_framebuffer(struct gl_context *ctx,
if (mask == 0x0)
return;
if (mask & GL_STENCIL_BUFFER_BIT) {
brw_meta_fbo_stencil_blit(brw_context(ctx),
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1);
mask &= ~GL_STENCIL_BUFFER_BIT;
if (mask == 0x0)
return;
}
/* Try using the BLT engine. */
mask = intel_blit_framebuffer_with_blitter(ctx,
srcX0, srcY0, srcX1, srcY1,

View File

@@ -1655,7 +1655,7 @@ intel_miptree_updownsample(struct brw_context *brw,
struct intel_mipmap_tree *src,
struct intel_mipmap_tree *dst)
{
if (brw->gen < 8 || src->format == MESA_FORMAT_S_UINT8) {
if (brw->gen < 8) {
brw_blorp_blit_miptrees(brw,
src, 0 /* level */, 0 /* layer */,
dst, 0 /* level */, 0 /* layer */,
@@ -1664,11 +1664,18 @@ intel_miptree_updownsample(struct brw_context *brw,
0, 0,
dst->logical_width0, dst->logical_height0,
GL_NEAREST, false, false /*mirror x, y*/);
} else if (src->format == MESA_FORMAT_S_UINT8) {
brw_meta_stencil_updownsample(brw, src, dst);
} else {
brw_meta_updownsample(brw, src, dst);
}
if (src->stencil_mt) {
if (brw->gen >= 8) {
brw_meta_stencil_updownsample(brw, src->stencil_mt, dst);
return;
}
brw_blorp_blit_miptrees(brw,
src->stencil_mt, 0 /* level */, 0 /* layer */,
dst->stencil_mt, 0 /* level */, 0 /* layer */,

View File

@@ -234,6 +234,7 @@ intel_set_texture_image_bo(struct gl_context *ctx,
0, width, height, pitch);
if (intel_image->mt == NULL)
return;
intel_image->mt->target = target;
intel_image->mt->total_width = width;
intel_image->mt->total_height = height;
intel_image->mt->level[0].slice[0].x_offset = tile_x;

View File

@@ -1141,7 +1141,7 @@ _mesa_initialize_context(struct gl_context *ctx,
fail:
_mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
free(ctx->BeginEnd);
free(ctx->Exec);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
return GL_FALSE;
}
@@ -1242,7 +1242,7 @@ _mesa_free_context_data( struct gl_context *ctx )
/* free dispatch tables */
free(ctx->BeginEnd);
free(ctx->Exec);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
/* Shared context state (display lists, textures, etc) */

View File

@@ -1058,6 +1058,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
if (att->Layered) {
if (att_tex_target == GL_TEXTURE_CUBE_MAP)
att_layer_count = 6;
else if (att_tex_target == GL_TEXTURE_1D_ARRAY)
att_layer_count = att->Renderbuffer->Height;
else
att_layer_count = att->Renderbuffer->Depth;
} else {

View File

@@ -187,6 +187,7 @@ st_BlitFramebuffer(struct gl_context *ctx,
}
blit.filter = pFilter;
blit.render_condition_enable = TRUE;
if (mask & GL_COLOR_BUFFER_BIT) {
struct gl_renderbuffer_attachment *srcAtt =

View File

@@ -165,6 +165,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
goto fallback;
}
memset(&blit, 0, sizeof(blit));
blit.src.resource = src;
blit.src.level = strb->surface->u.tex.level;
blit.src.format = src_format;

View File

@@ -765,6 +765,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
_mesa_unmap_teximage_pbo(ctx, unpack);
/* Blit. */
memset(&blit, 0, sizeof(blit));
blit.src.resource = src;
blit.src.level = 0;
blit.src.format = src_format;
@@ -998,6 +999,7 @@ st_GetTexImage(struct gl_context * ctx,
height = 1;
}
memset(&blit, 0, sizeof(blit));
blit.src.resource = src;
blit.src.level = texImage->Level;
blit.src.format = src_format;

View File

@@ -326,6 +326,7 @@ public:
struct gl_context *ctx;
struct gl_program *prog;
struct gl_shader_program *shader_program;
struct gl_shader *shader;
struct gl_shader_compiler_options *options;
int next_temp;
@@ -3094,6 +3095,7 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
ctx = NULL;
prog = NULL;
shader_program = NULL;
shader = NULL;
options = NULL;
}
@@ -3965,6 +3967,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
v->ctx = original->ctx;
v->prog = prog;
v->shader_program = NULL;
v->shader = NULL;
v->glsl_version = original->glsl_version;
v->native_integers = original->native_integers;
v->options = original->options;
@@ -4095,6 +4098,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
v->ctx = original->ctx;
v->prog = prog;
v->shader_program = NULL;
v->shader = NULL;
v->glsl_version = original->glsl_version;
v->native_integers = original->native_integers;
v->options = original->options;
@@ -5058,11 +5062,11 @@ st_translate_program(
}
}
if (program->shader_program) {
unsigned num_ubos = program->shader_program->NumUniformBlocks;
if (program->shader) {
unsigned num_ubos = program->shader->NumUniformBlocks;
for (i = 0; i < num_ubos; i++) {
ureg_DECL_constant2D(t->ureg, 0, program->shader_program->UniformBlocks[i].UniformBufferSize / 4, i + 1);
ureg_DECL_constant2D(t->ureg, 0, program->shader->UniformBlocks[i].UniformBufferSize / 4, i + 1);
}
}
@@ -5183,6 +5187,7 @@ get_mesa_program(struct gl_context *ctx,
v->ctx = ctx;
v->prog = prog;
v->shader_program = shader_program;
v->shader = shader;
v->options = options;
v->glsl_version = ctx->Const.GLSLVersion;
v->native_integers = ctx->Const.NativeIntegers;