Compare commits

...

54 Commits

Author SHA1 Message Date
Chih-Wei Huang
2af6b7090a android: enlarge cache_resources 2014-06-05 10:51:43 +08:00
Chih-Wei Huang
06a2d36edc android: get rid of HAL pixelformats 5551 and 4444 2014-01-23 09:24:32 +08:00
Chih-Wei Huang
a48404d26d android: set driver name to debug.mesa.driver 2014-01-23 09:21:39 +08:00
Chih-Wei Huang
9cc0a0d2b0 android: remove log2, log2f
The functions are already defined in the latest bionic.
2013-07-24 01:16:55 +08:00
Chih-Wei Huang
b68e24c438 android: add CleanSpec.mk
To ensure all mesa libs are properly rebuilt.
2013-07-24 01:16:54 +08:00
Chih-Wei Huang
2ed885535b android: fix for jb-x86
Fix the building errors of gallium drivers

* Ensure libmesa_glsl is built with stlport
* Implement program_invocation_short_name for android
* Add libmesa_pipe_radeon for r600g
2013-07-24 01:16:52 +08:00
Chih-Wei Huang
c9f20a7c91 r600g/sb: Fix Android build v2
Add the sb CXX files to the Android Makefile and also stop using some
c++11 features.

v2 (Vadim Girlin): use &bc[0] instead of bc.begin()
2013-07-24 01:16:51 +08:00
Chih-Wei Huang
f5158a9510 android: fix i915_dri build
The error was introduced by the commit 34d4216e64
"Merge per-type *_FILES variables in intel drivers".
2013-07-24 01:16:50 +08:00
Chih-Wei Huang
8a786becea Revert "Only build when BOARD_USE_MESA is true"
This reverts commit 2e6d9f9b5f.
2013-07-24 01:16:03 +08:00
Sean V Kelley
604d73de88 i915: Support Android RGBX8888 format for EGL generated images
Enabled MESA_FORMAT_RGBX8888_REV for RGBX with i915.  Android software
requires RGBX8888 format to be supported for software rendering.
Previously had done so for i965 but have requests for i915 support.

Change-Id: I87c3a8e3f206d75d58b63182ed94851749740762
Signed-off-by: Sean V Kelley <sean.v.kelley@linux.intel.com>
2013-07-23 23:30:49 +08:00
Chia-I Wu
c505b6b604 intel: add support for GL_OES_EGL_image_external
The changes to i965 are untested.
2013-07-23 23:30:28 +08:00
Chia-I Wu
2145cc57d4 i915: enable GL_APPLE_texture_2D_limited_npot
Enable GL_ARB_texture_non_power_of_two for GLESv1 to advertise
GL_APPLE_texture_2D_limited_npo.  The former is actually a superset of
the latter, but we really want to enable NPOT support in some way.
2013-07-23 23:30:06 +08:00
Chia-I Wu
e5fcf46723 android: disable SSE translate
It does not support FIXED and will fail anyway.
2013-07-23 23:30:04 +08:00
Chia-I Wu
03cd5b7ef8 android: advertise GL_ARB_texture_non_power_of_two
It maps to DisplayHardware::NPOT_EXTENSION in SurfaceFlinger.  Does not
seem to matter when EGL_ANDROID_image_native_buffer is available.
2013-07-23 23:30:03 +08:00
Ian Romanick
1aa54e3ac2 glsl: Move all of the var decls to the front of the IR list in reverse order.
This has the (intended!) side effect that vertex shader inputs and
fragment shader outputs will appear in the IR in the same order that
they appeared in the shader code.  This results in the locations being
assigned in the declared order.  Many (arguably buggy) applications
depend on this behavior, and it matches what nearly all other drivers
do.

Fixes the (new) piglit test attrib-assignments.

NOTE: This is a candidate for stable release branches.

Change-Id: I9ee61278dd975eb02f04d5227ea60c0dda0c76e9
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Chad Versace <chad.versace@linux.intel.com>
Issue: AXIA-2742
2013-06-13 08:18:48 -07:00
Ian Romanick
ea2e80e1d0 glsl: Generate smaller values for uniform locations
Previously we would generate uniform locations as (slot << 16) +
array_index.  We do this to handle applications that assume the location
of a[2] will be +1 from the location of a[1].  This resulted in every
uniform location being at least 0x10000.  The OpenGL 4.3 spec was
amended to require this behavior, but previous versions did not require
locations of array (or structure) members be sequential.

We've now encountered two applications that assume uniform values will
be "small."  As far as we can tell, these applications store the GLint
returned by glGetUniformLocation in a int16_t or possibly an int8_t.

THIS BEHAVIOR IS NOT GUARANTEED OR IMPLIED BY ANY VERSION OF OpenGL.

Other implementations happen to have both these behaviors (sequential
array elements and small values) since OpenGL 2.0, so let's just match
their behavior.

Fixes "3D Bowling" on Android.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-and-tested-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit cfa3c5ad82)
2013-06-13 08:18:19 -07:00
Ian Romanick
c8cc27c980 glsl: Add gl_shader_program::UniformLocationBaseScale
This is used by _mesa_uniform_merge_location_offset and
_mesa_uniform_split_location_offset to determine how the base and offset
are packed.  Previously, this value was hard coded as (1U<<16) in those
functions via the shift and mask contained therein.  The value is still
(1U<<16), but it can be changed in the future.

The next patch dynamically generates this value.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-and-tested-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 26d86d26f9)
2013-06-13 08:18:04 -07:00
Ian Romanick
fb494ce303 glsl: Add a gl_shader_program parameter to _mesa_uniform_{merge,split}_location_offset
This will be used in the next commit.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-and-tested-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 5097f35841)
2013-06-13 08:17:56 -07:00
Chad Versace
e81df76f28 Merge freedesktop/master into otc-private/master 2013-06-11 16:54:51 -07:00
Chad Versace
83c1d4c961 i965: Fix glColorPointer(GL_FIXED)
When a gl_client_array is created with glColorPointer,
gl_client_array::Normalized is true. This caused the translation from the
gl_client_array's type to a BRW_SURFACEFORMAT to assertion fail.

Fixes the spinning cube's color in Android 4.2's ApiDemos.apk,
"Graphics > OpenGL ES".

Fixes assertion failure in mesa-demos/src/egl/opengles1/tri_x11 on Haswell
and Ivybridge:
  brw_draw_upload.c:287: get_surface_type: Assertion `0' failed.

No Piglit regressions on Haswell.

Note: This is a candidate for the 9.1 branch.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42182
Issue: AXIA-2954
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 7a9f4d3e71)
2013-06-03 13:08:59 -07:00
Chad Versace
04ba428a6e Merge branch freedesktop/master into otc-private/master
Topi's GL_OES_EGL_image_external patches and Anholt's miptree cleanups
conflicted nontrivially in {brw,gen7}_wm_surface_state.c

Conflicts:
    src/mesa/drivers/dri/i965/brw_clear.c
	Anholt removed the 8x4 alignemtn restriction, and Tapani added
        a workaround below it.

    src/mesa/drivers/dri/i965/brw_wm_surface_state.c
    src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
        Topi's GL_OES_EGL_image_external patches conflicted with Anholt's
        miptree cleanups.

    src/mesa/drivers/dri/intel/intel_mipmap_tree.c
    src/mesa/drivers/dri/intel/intel_mipmap_tree.h
        Trivial conflicts.
2013-05-31 14:52:36 -07:00
Chad Versace
0b3146348b i965: Fix segfault by checking for null pointer
Commit 055f3e8 introduced a segfault in gles2_conform/depth_texture for
some EGLConfigs. That commit should have checked for a null pointer.

Issue: AXIA-2689
Change-Id: Ie059fb0647e5880b1ddc60341b102d0283eee9ca
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2013-05-24 13:21:21 -07:00
Chad Versace
7dc74b79bb mesa: Expose GL_OES_texture_npot on GLES1
Mesa's extension table incorrectly lists this GL_OES_texture_npot as
ES2-only. It's also an ES1 extension. This patch adds ES1 to the
extensions API mask.

From the GL_OES_texture_npot spec:
    OpenGL ES 1.0 or OpenGL ES 2.0 is required. This extension is
    written against OpenGL ES 1.1.12 and OpenGL ES 2.0.25.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Change-Id: Ia8a8f6a239156dd95b4085b9290316900f764e6a
2013-05-22 10:18:05 -07:00
Chad Versace
072a4fba46 egl/android: Fix error condition for EGL_ANDROID_image_native_buffer
Emit EGL_BAD_CONTEXT if the user passes a context to
eglCreateImageKHR(type=EGL_ANDROID_image_native_buffer).

From the EGL_ANDROID_image_native_buffer spec:
  * If <target> is EGL_NATIVE_BUFFER_ANDROID and <ctx> is not
    EGL_NO_CONTEXT, the error EGL_BAD_CONTEXT is generated.

Note: This is a candidate for the stable branches.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Change-Id: I01c4f09aaa13fc01a75b5a721b85df6a99e2072a
2013-05-22 10:17:44 -07:00
Rodrigo Vivi
aec0139c83 i965: Add missing Haswell GT3 Desktop to IS_HSW_GT3 check.
NOTE: This is a candidate for stable branches.

Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-05-16 14:20:53 -07:00
Paulo Zanoni
c5b49e93d1 i965: make GT3 machines work as GT3 instead of GT2
We were not allowed to say the "GT3" name, but we really needed to
have the PCI IDs because too many people had such machines, so we had
to make the GT3 machines work as GT2.

Let's just say that GT2_PLUS was a short for GT2_PLUS_1 :)

NOTE: This is a candidate for stable branches.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2013-05-01 09:46:48 -07:00
Kenneth Graunke
04b776caae i965: Add chipset limits for the Haswell GT3 variant.
NOTE: This is a candidate for stable branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2013-05-01 09:46:43 -07:00
Kenneth Graunke
f878d95d27 i965: Update URB partitioning code for Haswell's GT3 variant.
Haswell's GT3 variant offers 32kB of URB space for push constants, while
GT1 and GT2 match Ivybridge, providing 16kB.  Update the code to reserve
the full 32kB on GT3.

v2: Specify push constant size correctly.  I thought GT3 reinterpreted
    the value as multiples of 2kB, but it doesn't.  You simply have to
    program an even number.

NOTE: This is a candidate for stable branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2013-05-01 09:46:37 -07:00
Chad Versace
669fdaffe1 Merge otc-private/master into freedesktop/master
* otc-private/master
  i965: Fix Linux build
  intel: Fall back to X-tiling when larger than estimated aperture size.
  intel: Refactor code in intel_miptree_choose_tiling().
  intel: Move the max_gtt_map_object_size estimation to intel_context.
  mesa: Insert custom text into version string at buildtime
  android: NV12 support in buffer creation
  YV12 support for Android
  i965: enable image external textures
  i965: support for YUV formatted external textures
  gbm: dri: support for creating YUV formatted buffers
  dri: introduce YVU420 (YV12)
  intel: refactor planar format lookup
  i965: support for setting surfaces for planar external
  i965: refactor sampling engine surface state setup
  intel: treat mip-tree as constant when resolving offsets
  i965: re-compile shader if external texture unit changes
  i965: support for reserving surfaces for planar textures
  intel: support for creating planar external image textures
  i965: extend VS sampler to surface relation to 1:N
  i965: extend FS sampler to surface relation to 1:N
  dri2: x11: remove compiler warnings when converting native/opaque
  enable S3TC always
  i965: fast clear depth only if depth equals to color buffer depth
  Only build when BOARD_USE_MESA is true
  i915: Create mock implementation of GL_OES_image_external

Conflicts:
	src/mesa/drivers/dri/i965/brw_context.h
	src/mesa/drivers/dri/i965/brw_vs.c
	src/mesa/drivers/dri/intel/intel_mipmap_tree.c
	src/mesa/drivers/dri/intel/intel_screen.c
2013-05-01 09:18:01 -07:00
Chad Versace
f498624254 i965: Fix Linux build
Fix the following errors:

  brw_state_cache.c:352:1: error: no previous prototype for 'brw_clear_cache' [-Werror=missing-prototypes]

  brw_program.c: In function 'brwProgramStringNotify':
  brw_program.c:138:7: error: implicit declaration of function 'brw_clear_cache' [-Werror=implicit-function-declaration]

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2013-05-01 08:43:08 -07:00
Kenneth Graunke
d7a06ebcaa intel: Fall back to X-tiling when larger than estimated aperture size.
If a region is larger than the estimated aperture size, we map/unmap it
by copying with the BLT engine.  Which means we can't use Y-tiling.

Fixes Piglit max-texture-size and tex3d-maxsize, which regressed in my
recent change to use Y-tiling by default on Gen6+.  This was due to a
botched merge conflict resolution.

v2: Return a mask of valid tilings from intel_miptree_select_tiling.
    This allows us to avoid the X-tiling fallback if Y-tiling is actually
    mandatory.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2013-04-26 10:03:15 +02:00
Kenneth Graunke
2b4b6e00e3 intel: Refactor code in intel_miptree_choose_tiling().
This reduces the nesting level slightly, and in my opinion, makes it a
bit easier to follow.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2013-04-26 10:03:15 +02:00
Kenneth Graunke
4cfad2dc94 intel: Move the max_gtt_map_object_size estimation to intel_context.
We need know this in order to decide what tiling mode to use.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2013-04-26 10:03:15 +02:00
Chad Versace
e6a5c78510 mesa: Insert custom text into version string at buildtime
This allows maintainers/packagers/testers to tag the build with custom
information that will be reported by GL_VERSION.

If during build time (not configure time), the environemt variable or make
variable MESA_VERSION_STRING_EXTRA is set, then its value will appear in
the GL_VERSION string immediately after "Mesa X.Y" and before
"(git-xxxxxxx)".

This patch implements support for MESA_VERSION_STRING_EXTRA only for
Android.  Other build systems are left as an excercise.

Change-Id: I06432f6bd66546a3a62abf22347a2a0fb381ab74
CC: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2013-04-10 12:08:29 -07:00
Juha-Pekka Heikkila
96ba7df413 android: NV12 support in buffer creation
Change-Id: I5e0afe862aa0b73fc315c9b9f39f9c0b6dd39613
Signed-off-by: Juha-Pekka Heikkila <juha-pekka.heikkila@linux.intel.com>
2013-04-10 12:08:29 -07:00
Juha-Pekka Heikkila
5522a3eec0 YV12 support for Android
Enable YV12 buffers on Android.

Issue: AIA-416
Change-Id: Icce005884bebf6ee934ad879c52c145bf7125103
Signed-off-by: Juha-Pekka Heikkila <juha-pekka.heikkila@linux.intel.com>
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
abb80d88e6 i965: enable image external textures
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
e9a56dba2c i965: support for YUV formatted external textures
Namely YUV420, YVU420 (YV12) and NV12. Here one extends the shader
program with instructions that sample the separate Y- and U/V-planes
and convert the YUV to RGB as specified by ITU-R BT.601. Packed
formats are handled through the normal paths.
Here is only support for fragment shaders for now. I'm yet to study
the vec4-backend in order to add the support for vertex shaders.
(There aren't any tests or examples for them available anyway).

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
ec048ea12b gbm: dri: support for creating YUV formatted buffers
Specifically YUV420, YVU420 (YV12) and NV12 formatted. The logic is
pretty much taken from Kristian Hogsberg [1]. All the planes are
back-to-back but each starts at page boundary. Horizontal and
vertical alignment are set according to sampling engine constraints.
This is to serve piglit testing of the image external extension as
one needs a way of creating and writing YUV formatted buffers that
can be further passed to EGL as images.

[1] http://cgit.freedesktop.org/~krh/simple-yuv

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
e3f7da8985 dri: introduce YVU420 (YV12)
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
25ae4f440d intel: refactor planar format lookup
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
240f2ea392 i965: support for setting surfaces for planar external
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
20f26275dc i965: refactor sampling engine surface state setup
This prepares for image external textures having multiple planes
and hence calling for one to set up more than one surface per
texture.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
b397ce7dd6 intel: treat mip-tree as constant when resolving offsets
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
d3174a03c3 i965: re-compile shader if external texture unit changes
Both sampling and possible conversion to RGB are dependent on the
format of the DRI image representing the pixel source. In order to
accomodate this one re-compiles the program upon any changes.

Altering the program key effectively kicks off the re-compilation
as part of brw state uploading.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
53aa7234b2 i965: support for reserving surfaces for planar textures
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
6dd7173146 intel: support for creating planar external image textures
One needs to check here if the shader compiler backend is capable of
producing the extra instructions for the given format. One is not
allowed to fail in the code generation phase anymore and it is
probably better from the shader author point of view also to know as
soon as possible.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
db848452a5 i965: extend VS sampler to surface relation to 1:N
In preparation for supporting external image textures consisting of
multiple planes (YUV).

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
d2f1855025 i965: extend FS sampler to surface relation to 1:N
In preparation for supporting external image textures consisting of
multiple planes (YUV). One now reserves entries in the sampling engine
surface state table only for those samplers that are really used in the
current program using a binding table associating a sampler with a slot
in the state table. Previously the slot in the state table was
determined using the sampler id as the state table index directly. This
arrangement allows one to reserve continuous ranges in the state table
instead of fixed single entries.
Note that one does not have zero pointers in the state table anymore
as one only uses as many slots from the beginning that are really
needed by the program.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Topi Pohjolainen
adba4d4405 dri2: x11: remove compiler warnings when converting native/opaque
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2013-04-10 12:08:29 -07:00
Tapani Pälli
8de19279bd enable S3TC always
This makes DXT using applications work on Android, such as Epic
Citadel demo and GLBenchmark2.5 DXT1 tests.

Change-Id: I8b6d49f54e816ab9c5da137962bb7c294b40a6de
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
2013-04-10 12:08:29 -07:00
Tapani Pälli
055f3e8934 i965: fast clear depth only if depth equals to color buffer depth
Patch makes GLBenchmark 2.1.x, An3DBenchXL and BasemarkES2 work with
Android on Ivybridge. In all failing cases color buffer is 16bit and
depth buffer 24bit. I did not find limitations on fast depth clear with
this combination though.

Change-Id: I76603141908855f0d1581427b48c67f29411bab7
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
2013-04-10 12:08:29 -07:00
Daniel Leung
2e6d9f9b5f Only build when BOARD_USE_MESA is true
This causes emulator builds to fail. So only build this
when board config specifies the need for this module.

Change-Id: Iad623b13a8ea568830c6729efdfb41890c9ede13
Depends-Change-Id: I574e53bbefad16e7b866c550df46f4f52c831ddd
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2013-04-10 12:08:29 -07:00
Chad Versace
e8c790caa5 i915: Create mock implementation of GL_OES_image_external
(See also similar commit 7420c9dab4aaf87e6b840410226c296c4668a48f.)

In Android IceCreamSandwich, SurfaceFlinger requires
GL_OES_image_external for basic compositing tasks. Without the extension,
SurfaceFlinger fails to start.

Despite the incompleteness of the extension's implementation introduced by
this patch, it is good enough to enable SurfaceFlinger and to unblock the
people who need to begin testing Mesa on IceCreamSandwich on i915.

To enable the extension, set the environment variable
MESA_EXTENSION_OVERRIDE="+GL_OES_EGL_image_external". Ideally, Android
should set this in init.rc.

WARNING: This implementation of GL_OES_EGL_image_external is not complete.
Some of it is even incorrect. The Intel Mesa team has no intention of
really implementing GL_OES_image_external for the i915 driver. This is
just a workaround for people who want to experiment with Android on i915.

Change-Id: Id2fce598a749a20d0fe78a0ac574937ec35d3545
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2013-04-10 12:08:29 -07:00
59 changed files with 1084 additions and 197 deletions

49
CleanSpec.mk Normal file
View File

@@ -0,0 +1,49 @@
# Copyright (C) 2013 The Android-x86 Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libmesa_*_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libdrm_*intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/i9?5_dri_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libglapi_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/gralloc.drm_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libgralloc_drm_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_OS)-$(HOST_ARCH)/obj/EXECUTABLES/mesa_*_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_OS)-$(HOST_ARCH)/obj/EXECUTABLES/glsl_compiler_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_OS)-$(HOST_ARCH)/obj/STATIC_LIBRARIES/libmesa_glsl_utils_intermediates)

View File

@@ -983,6 +983,7 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FOURCC_YUV410 0x39565559
#define __DRI_IMAGE_FOURCC_YUV411 0x31315559
#define __DRI_IMAGE_FOURCC_YUV420 0x32315559
#define __DRI_IMAGE_FOURCC_YVU420 0x32315659
#define __DRI_IMAGE_FOURCC_YUV422 0x36315559
#define __DRI_IMAGE_FOURCC_YUV444 0x34325559
#define __DRI_IMAGE_FOURCC_NV12 0x3231564e

View File

@@ -38,6 +38,7 @@
#include <xf86drm.h>
#include <i915_drm.h>
#include <radeon_drm.h>
#include <gralloc_drm.h>
#include "egl_dri2.h"
#include "gralloc_drm.h"
@@ -56,9 +57,9 @@ get_format_bpp(int native)
case HAL_PIXEL_FORMAT_RGB_888:
bpp = 3;
break;
case HAL_PIXEL_FORMAT_DRM_NV12:
case HAL_PIXEL_FORMAT_YV12:
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
bpp = 2;
break;
default:
@@ -339,6 +340,7 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_image *dri2_img;
int name;
uint32_t offsets[3], strides[3], handles[3], tmp;
EGLint format;
if (ctx != NULL) {
@@ -367,6 +369,12 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
/* see the table in droid_add_configs_for_visuals */
switch (buf->format) {
case HAL_PIXEL_FORMAT_DRM_NV12:
format = __DRI_IMAGE_FOURCC_NV12;
break;
case HAL_PIXEL_FORMAT_YV12:
format = __DRI_IMAGE_FOURCC_YVU420;
break;
case HAL_PIXEL_FORMAT_BGRA_8888:
format = __DRI_IMAGE_FORMAT_ARGB8888;
break;
@@ -380,8 +388,6 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
format = __DRI_IMAGE_FORMAT_XBGR8888;
break;
case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
/* unsupported */
default:
_eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", buf->format);
@@ -400,6 +406,11 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
return NULL;
}
switch (format) {
case __DRI_IMAGE_FORMAT_ARGB8888:
case __DRI_IMAGE_FORMAT_RGB565:
case __DRI_IMAGE_FORMAT_ABGR8888:
case __DRI_IMAGE_FORMAT_XBGR8888:
dri2_img->dri_image =
dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
buf->width,
@@ -408,6 +419,57 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp, _EGLContext *ctx,
name,
buf->stride,
dri2_img);
break;
case __DRI_IMAGE_FOURCC_YVU420:
offsets[0] = offsets[1] = offsets[2] = 0;
strides[0] = strides[1] = strides[2] = 0;
gralloc_drm_resolve_format(buf->handle, &strides[0], &offsets[0],
&handles[0]);
/* u anv v are given in wrong order than what we need here thus this:*/
tmp = offsets[1];
offsets[1] = offsets[2];
offsets[2] = tmp;
tmp = strides[1];
strides[1] = strides[2];
strides[2] = tmp;
dri2_img->dri_image =
dri2_dpy->image->createImageFromNames(dri2_dpy->dri_screen,
buf->width,
buf->height,
format,
&name, 1,
(int*)strides,
(int*)offsets,
dri2_img);
break;
case __DRI_IMAGE_FOURCC_NV12:
offsets[0] = offsets[1] = offsets[2] = 0;
strides[0] = strides[1] = strides[2] = 0;
gralloc_drm_resolve_format(buf->handle, &strides[0], &offsets[0],
&handles[0]);
dri2_img->dri_image =
dri2_dpy->image->createImageFromNames(dri2_dpy->dri_screen,
buf->width,
buf->height,
format,
&name, 1,
(int*)strides,
(int*)offsets,
dri2_img);
break;
default:
/* We should never arrive here */
_eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x",
buf->format);
break;
}
if (!dri2_img->dri_image) {
free(dri2_img);
_eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");

View File

@@ -212,7 +212,7 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
dri2_surf->drawable, s.data->root,
dri2_surf->base.Width, dri2_surf->base.Height);
} else {
dri2_surf->drawable = window;
dri2_surf->drawable = (xcb_drawable_t)window;
}
if (dri2_dpy->dri2) {
@@ -836,10 +836,10 @@ dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
(*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
gc = xcb_generate_id(dri2_dpy->conn);
xcb_create_gc(dri2_dpy->conn, gc, target, 0, NULL);
xcb_create_gc(dri2_dpy->conn, gc, (xcb_drawable_t)target, 0, NULL);
xcb_copy_area(dri2_dpy->conn,
dri2_surf->drawable,
target,
(xcb_drawable_t)target,
gc,
0, 0,
0, 0,

View File

@@ -121,11 +121,13 @@ endif
# r300g/r600g/radeonsi
ifneq ($(filter r300g r600g radeonsi, $(MESA_GPU_DRIVERS)),)
gallium_DRIVERS += libmesa_winsys_radeon
LOCAL_SHARED_LIBRARIES += libdrm_radeon
ifneq ($(filter r300g, $(MESA_GPU_DRIVERS)),)
gallium_DRIVERS += libmesa_pipe_r300
endif
ifneq ($(filter r600g, $(MESA_GPU_DRIVERS)),)
gallium_DRIVERS += libmesa_pipe_r600
gallium_DRIVERS += libmesa_pipe_r600 libmesa_pipe_radeon
LOCAL_SHARED_LIBRARIES += libstlport
endif
ifneq ($(filter radeonsi, $(MESA_GPU_DRIVERS)),)
gallium_DRIVERS += libmesa_pipe_radeonsi

View File

@@ -61,7 +61,7 @@ ifneq ($(filter r300g, $(MESA_GPU_DRIVERS)),)
SUBDIRS += drivers/r300
endif
ifneq ($(filter r600g, $(MESA_GPU_DRIVERS)),)
SUBDIRS += drivers/r600
SUBDIRS += drivers/r600 drivers/radeon
endif
ifneq ($(filter radeonsi, $(MESA_GPU_DRIVERS)),)
SUBDIRS += drivers/radeonsi

View File

@@ -39,7 +39,7 @@ struct translate *translate_create( const struct translate_key *key )
struct translate *translate = NULL;
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
translate = translate_sse2_create( key );
/*translate = translate_sse2_create( key );*/
if (translate)
return translate;
#else

View File

@@ -136,30 +136,6 @@ roundf(float x)
#endif /* _MSC_VER */
#ifdef PIPE_OS_ANDROID
static INLINE
double log2(double d)
{
return log(d) * (1.0 / M_LN2);
}
/* workaround a conflict with main/imports.h */
#ifdef log2f
#undef log2f
#endif
static INLINE
float log2f(float f)
{
return logf(f) * (float) (1.0 / M_LN2);
}
#endif
#define POW2_TABLE_SIZE_LOG2 9
#define POW2_TABLE_SIZE (1 << POW2_TABLE_SIZE_LOG2)
#define POW2_TABLE_OFFSET (POW2_TABLE_SIZE/2)

View File

@@ -35,6 +35,11 @@
static void r300_apply_hyperz_blacklist(struct r300_capabilities* caps)
{
#ifdef ANDROID
extern const char *__progname;
const char *arg = strrchr(__progname, '/');
const char *program_invocation_short_name = arg ? arg + 1 : __progname;
#endif
static const char *list[] = {
"X", /* the DDX or indirect rendering */
"Xorg", /* (alternative name) */

View File

@@ -28,11 +28,12 @@ include $(LOCAL_PATH)/Makefile.sources
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(C_SOURCES)
LOCAL_SRC_FILES := $(C_SOURCES) $(CXX_SOURCES)
LOCAL_C_INCLUDES :=
LOCAL_C_INCLUDES := $(DRM_TOP)
LOCAL_MODULE := libmesa_pipe_r600
include external/stlport/libstlport.mk
include $(GALLIUM_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)

View File

@@ -846,7 +846,7 @@ public:
unsigned ndw() { return bc.size(); }
void write_data(uint32_t* dst) {
memcpy(dst, bc.data(), 4 * bc.size());
std::copy(bc.begin(), bc.end(), dst);
}
void align(unsigned a) {
@@ -870,7 +870,7 @@ public:
}
unsigned get_pos() { return pos; }
uint32_t *data() { return bc.data(); }
uint32_t *data() { return &bc[0]; }
bytecode & operator <<(uint32_t v) {
if (pos == ndw()) {

View File

@@ -680,7 +680,7 @@ void ra_split::split_vec(vvec &vv, vvec &v1, vvec &v2, bool allow_swz) {
value *t;
vvec::iterator F =
allow_swz ? find(v2.begin(), v2.end(), o) : v2.end();
allow_swz ? std::find(v2.begin(), v2.end(), o) : v2.end();
if (F != v2.end()) {
t = *(v1.begin() + (F - v2.begin()));

View File

@@ -207,7 +207,7 @@ void value_table::get_values(vvec& v) {
for(vt_table::iterator I = hashtable.begin(), E = hashtable.end();
I != E; ++I) {
T = copy(I->begin(), I->end(), T);
T = std::copy(I->begin(), I->end(), T);
}
}
@@ -368,7 +368,7 @@ inline bool sb_bitset::set_chk(unsigned id, bool bit) {
}
void sb_bitset::clear() {
memset(data.data(), 0, sizeof(basetype) * data.size());
std::fill(data.begin(), data.end(), 0);
}
void sb_bitset::resize(unsigned size) {

View File

@@ -0,0 +1,38 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 LunarG Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
LOCAL_PATH := $(call my-dir)
# get C_SOURCES
include $(LOCAL_PATH)/Makefile.sources
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(C_SOURCES)
LOCAL_C_INCLUDES := $(DRM_TOP)
LOCAL_MODULE := libmesa_pipe_radeon
include $(GALLIUM_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)

View File

@@ -98,8 +98,8 @@ struct android_surface {
int height;
int format;
} cache_key;
void *cache_handles[2];
struct pipe_resource *cache_resources[2];
void *cache_handles[4];
struct pipe_resource *cache_resources[4];
};
struct android_config {
@@ -147,10 +147,6 @@ get_pipe_format(int native)
case HAL_PIXEL_FORMAT_BGRA_8888:
fmt = PIPE_FORMAT_B8G8R8A8_UNORM;
break;
case HAL_PIXEL_FORMAT_RGBA_5551:
/* fmt = PIPE_FORMAT_A1B5G5R5_UNORM; */
case HAL_PIXEL_FORMAT_RGBA_4444:
/* fmt = PIPE_FORMAT_A4B4G4R4_UNORM; */
default:
ALOGE("unsupported native format 0x%x", native);
fmt = PIPE_FORMAT_NONE;

View File

@@ -40,6 +40,8 @@
#include "egl_pipe.h"
#include "egl_st.h"
#include <cutils/properties.h>
static struct egl_g3d_loader egl_g3d_loader;
static struct st_module {
@@ -231,12 +233,15 @@ static struct pipe_screen *
create_drm_screen(const char *name, int fd)
{
struct pipe_screen *screen;
char value[PROPERTY_VALUE_MAX];
if (!name) {
name = drm_fd_get_screen_name(fd);
if (!name)
return NULL;
}
if (!property_get("debug.mesa.driver", value, NULL))
property_set("debug.mesa.driver", name);
screen = egl_pipe_create_drm_screen(name, fd);
if (screen)

View File

@@ -41,7 +41,7 @@
*/
#include "pipebuffer/pb_buffer.h"
#include "libdrm/radeon_surface.h"
#include "radeon/radeon_surface.h"
#define RADEON_MAX_CMDBUF_DWORDS (16 * 1024)

View File

@@ -547,6 +547,15 @@ gbm_dri_bo_create(struct gbm_device *gbm,
case GBM_FORMAT_ABGR8888:
dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
break;
case GBM_FORMAT_YUV420:
dri_format = __DRI_IMAGE_FOURCC_YUV420;
break;
case GBM_FORMAT_YVU420:
dri_format = __DRI_IMAGE_FOURCC_YVU420;
break;
case GBM_FORMAT_NV12:
dri_format = __DRI_IMAGE_FOURCC_NV12;
break;
default:
return NULL;
}

View File

@@ -39,12 +39,12 @@ LOCAL_SRC_FILES := \
$(LIBGLSL_FILES)
LOCAL_C_INCLUDES := \
external/astl/include \
$(MESA_TOP)/src/mapi \
$(MESA_TOP)/src/mesa
LOCAL_MODULE := libmesa_glsl
include external/stlport/libstlport.mk
include $(LOCAL_PATH)/Android.gen.mk
include $(MESA_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)

View File

@@ -94,6 +94,24 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
detect_conflicting_assignments(state, instructions);
state->toplevel_ir = NULL;
/* Move all of the variable declarations to the front of the IR list, and
* reverse the order. This has the (intended!) side effect that vertex
* shader inputs and fragment shader outputs will appear in the IR in the
* same order that they appeared in the shader code. This results in the
* locations being assigned in the declared order. Many (arguably buggy)
* applications depend on this behavior, and it matches what nearly all
* other drivers do.
*/
foreach_list_safe(node, instructions) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL)
continue;
var->remove();
instructions->push_head(var);
}
}

View File

@@ -739,6 +739,20 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
sizeof(prog->_LinkedShaders[i]->SamplerTargets));
}
/* Determine the size of the largest uniform array queryable via
* glGetUniformLocation. Using this as the location scale guarantees that
* there is enough "room" for the array index to be stored in the low order
* part of the uniform location. It also makes the locations be more
* tightly packed.
*/
unsigned max_array_size = 1;
for (unsigned i = 0; i < num_user_uniforms; i++) {
if (uniforms[i].array_elements > max_array_size)
max_array_size = uniforms[i].array_elements;
}
prog->UniformLocationBaseScale = max_array_size;
#ifndef NDEBUG
for (unsigned i = 0; i < num_user_uniforms; i++) {
assert(uniforms[i].storage != NULL);

View File

@@ -52,6 +52,10 @@ endif # MESA_ENABLE_ASM
LOCAL_CFLAGS := \
$(patsubst %,-DFEATURE_%=1,$(MESA_ENABLED_APIS))
ifneq ($(strip $(MESA_VERSION_STRING_EXTRA)),)
LOCAL_CFLAGS += -DMESA_VERSION_STRING_EXTRA="\"$(MESA_VERSION_STRING_EXTRA)\""
endif
LOCAL_C_INCLUDES := \
$(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
$(MESA_TOP)/src/mapi \

View File

@@ -42,7 +42,7 @@ LOCAL_C_INCLUDES := \
$(DRM_TOP)/intel
LOCAL_SRC_FILES := \
$(i915_C_FILES)
$(i915_FILES)
LOCAL_WHOLE_STATIC_LIBRARIES := \
$(MESA_DRI_WHOLE_STATIC_LIBRARIES)

View File

@@ -335,6 +335,7 @@ i830UpdateTextureState(struct intel_context *intel)
case TEXTURE_1D_BIT:
case TEXTURE_2D_BIT:
case TEXTURE_CUBE_BIT:
case TEXTURE_EXTERNAL_BIT:
ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_NORMAL);
break;
case TEXTURE_RECT_BIT:

View File

@@ -107,6 +107,7 @@ intel_init_texture_formats(struct gl_context *ctx)
ctx->TextureFormatSupported[MESA_FORMAT_ARGB4444] = true;
ctx->TextureFormatSupported[MESA_FORMAT_ARGB1555] = true;
ctx->TextureFormatSupported[MESA_FORMAT_RGB565] = true;
ctx->TextureFormatSupported[MESA_FORMAT_RGBX8888_REV] = true;
ctx->TextureFormatSupported[MESA_FORMAT_L8] = true;
ctx->TextureFormatSupported[MESA_FORMAT_A8] = true;
ctx->TextureFormatSupported[MESA_FORMAT_I8] = true;

View File

@@ -258,6 +258,8 @@ translate_tex_src_target(struct i915_fragment_program *p, GLubyte bit)
return D0_SAMPLE_TYPE_VOLUME;
case TEXTURE_CUBE_INDEX:
return D0_SAMPLE_TYPE_CUBE;
case TEXTURE_EXTERNAL_INDEX:
return D0_SAMPLE_TYPE_2D;
default:
i915_program_error(p, "TexSrcBit: %d", bit);
return 0;

View File

@@ -788,6 +788,7 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
switch (cap) {
case GL_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES:
break;
case GL_LIGHTING:

View File

@@ -236,6 +236,7 @@ i915_miptree_layout(struct intel_mipmap_tree * mt)
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES:
case GL_TEXTURE_RECTANGLE_ARB:
i915_miptree_layout_2d(mt);
break;
@@ -468,6 +469,7 @@ i945_miptree_layout(struct intel_mipmap_tree * mt)
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES:
case GL_TEXTURE_RECTANGLE_ARB:
i945_miptree_layout_2d(mt);
break;

View File

@@ -61,6 +61,8 @@ translate_texture_format(gl_format mesa_format, GLenum DepthMode)
return MAPSURF_32BIT | MT_32BIT_ARGB8888;
case MESA_FORMAT_XRGB8888:
return MAPSURF_32BIT | MT_32BIT_XRGB8888;
case MESA_FORMAT_RGBX8888_REV:
return MAPSURF_32BIT | MT_32BIT_XBGR8888;
case MESA_FORMAT_RGBA8888_REV:
return MAPSURF_32BIT | MT_32BIT_ABGR8888;
case MESA_FORMAT_YCBCR_REV:
@@ -422,6 +424,7 @@ i915UpdateTextureState(struct intel_context *intel)
case TEXTURE_2D_BIT:
case TEXTURE_CUBE_BIT:
case TEXTURE_3D_BIT:
case TEXTURE_EXTERNAL_BIT:
ok = i915_update_tex_unit(intel, i, SS3_NORMALIZED_COORDS);
break;
case TEXTURE_RECT_BIT:

View File

@@ -551,6 +551,7 @@ static uint32_t i915_render_target_format_for_mesa_format[MESA_FORMAT_COUNT] =
{
[MESA_FORMAT_ARGB8888] = DV_PF_8888,
[MESA_FORMAT_XRGB8888] = DV_PF_8888,
[MESA_FORMAT_RGBX8888_REV] = DV_PF_8888,
[MESA_FORMAT_RGB565] = DV_PF_565 | DITHER_FULL_ALWAYS,
[MESA_FORMAT_ARGB1555] = DV_PF_1555 | DITHER_FULL_ALWAYS,
[MESA_FORMAT_ARGB4444] = DV_PF_4444 | DITHER_FULL_ALWAYS,

View File

@@ -60,6 +60,7 @@ i965_FILES = \
brw_fs_live_variables.cpp \
brw_fs_reg_allocate.cpp \
brw_fs_vector_splitting.cpp \
brw_fs_ext_texture.cpp \
brw_fs_visitor.cpp \
brw_gs.c \
brw_gs_emit.c \

View File

@@ -128,6 +128,14 @@ brw_fast_clear_depth(struct gl_context *ctx)
return false;
}
/* check that colorbuffer depth equals to depthbuffer depth on IVB */
if(intel->gen == 7) {
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
if (rb && _mesa_get_format_bytes(rb->Format) !=
_mesa_get_format_bytes(intel_rb_format(depth_irb)))
return false;
}
uint32_t depth_clear_value;
switch (mt->format) {
case MESA_FORMAT_Z32_FLOAT_X24S8:

View File

@@ -263,19 +263,52 @@ static inline uint32_t AUB_TRACE_SUBTYPE(enum state_struct_type ss_type)
return ss_type & 0xFFFF;
}
/** Number of texture sampler units */
#define BRW_MAX_TEX_UNIT 16
/** Subclass of Mesa vertex program */
struct brw_vertex_program {
struct gl_vertex_program program;
GLuint id;
/** See equivalent member of 'brw_fragment_program' for details */
uint32_t sampler_to_surf_state_start[BRW_MAX_TEX_UNIT];
};
static inline uint32_t brw_surf_index_vs_texture(
const struct brw_vertex_program *vp, unsigned sampler)
{
return vp->sampler_to_surf_state_start[sampler];
}
/** Subclass of Mesa fragment program */
struct brw_fragment_program {
struct gl_fragment_program program;
GLuint id; /**< serial no. to identify frag progs, never re-used */
/**
* Relation assigning shader samplers with a region in the HW surface state
* binding table. This used to be explicit one-sampler-one-surface-relation.
* However, in order to support image-external-textures a sampler
* representing, for example, multi-planar YUV texture may require up to
* three HW surfaces, one for each of the components/planes (Y, U and V). The
* actual number of HW surfaces associated with a sampler can be deduced from
* the format/layout of the texture image - here one simply stores the
* starting index.
* This relation can be set after linking but must in place before WM FS
* emission (one needs to know the surface state indices when generating the
* sampling commands). In addition, this relation must be accessible just
* before the actual execution of the shader is kicked off. (The contents of
* the surface state binding table itself are updated at that point).
*/
uint32_t sampler_to_surf_state_start[BRW_MAX_TEX_UNIT];
};
static inline uint32_t brw_surf_index_texture(
const struct brw_fragment_program *fp, unsigned sampler)
{
return fp->sampler_to_surf_state_start[sampler];
}
struct brw_shader {
struct gl_shader base;
@@ -482,9 +515,6 @@ struct brw_vs_prog_data {
bool uses_vertexid;
};
/** Number of texture sampler units */
#define BRW_MAX_TEX_UNIT 16
/** Max number of render targets in a shader */
#define BRW_MAX_DRAW_BUFFERS 8

View File

@@ -184,6 +184,7 @@ public:
int base_mrf; /**< First MRF in the SEND message, if mlen is nonzero. */
uint32_t texture_offset; /**< Texture offset bitfield */
int sampler;
int surf_index_offset;
int target; /**< MRT target. */
bool eot;
bool header_present;
@@ -349,6 +350,7 @@ public:
fs_reg *emit_general_interpolation(ir_variable *ir);
void emit_interpolation_setup_gen4();
void emit_interpolation_setup_gen6();
bool emit_texture_external(ir_texture *ir, fs_reg& coordinate, int sampler);
fs_reg rescale_texcoord(ir_texture *ir, fs_reg coordinate,
bool is_rect, int sampler, int texunit);
fs_inst *emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,

View File

@@ -492,7 +492,8 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
retype(dst, BRW_REGISTER_TYPE_UW),
inst->base_mrf,
src,
SURF_INDEX_TEXTURE(inst->sampler),
brw_surf_index_texture((const struct brw_fragment_program*)fp,
inst->sampler) + inst->surf_index_offset,
inst->sampler,
msg_type,
rlen,

View File

@@ -0,0 +1,274 @@
/*
* Copyright © 2013 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Topi Pohjolainen <topi.pohjolainen@intel.com>
*
*/
/** @file brw_fs_ext_texture.cpp
*
* This file implements the generation of FS LIR for converting YUV samples into
* RGB as part of single GLSL texture sampling instruction. The implementation
* follows the one found in "brw_wm_fp.c::precalc_tex()".
*
* B = 1.164(Y - 16) + 2.018(U - 128)
* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
* R = 1.164(Y - 16) + 1.596(V - 128)
*
* Implementation in 'brw_wm_fp.c':
*
* Need to emit YUV texture conversions by hand. Probably need to do this here
* - the alternative is in execution unit emisson time , but the conversion
* requires allocating a temporary variable which one doesn't have the facility
* to do that late in the compilation.
*
* CONST C0 = { -.0625, -.5, -.5, 1.164 }
* CONST C1 = { 1.596, -0.813, 2.018, -.391 }
* YUV = TEX ...
* YUV.xyz = ADD YUV, C0
* YUV.x = MUL YUV.x, C0.w
* RGB.xyz = MAD YUV.zzy, C1, YUV.x
* RGB.y = MAD YUV.y, C1.w, RGB.y
*/
extern "C" {
#include <sys/types.h>
#include "main/macros.h"
#include "brw_context.h"
}
#include "brw_shader.h"
#include "brw_fs.h"
struct fs_reg_const_float4 : public fs_reg {
fs_reg_const_float4(fs_visitor *v, float f1, float f2, float f3, float f4) :
fs_reg(v, glsl_type::vec4_type)
{
fs_reg tmp = *this;
v->emit(BRW_OPCODE_MOV, tmp, fs_reg(f1));
++tmp.reg_offset;
v->emit(BRW_OPCODE_MOV, tmp, fs_reg(f2));
++tmp.reg_offset;
v->emit(BRW_OPCODE_MOV, tmp, fs_reg(f3));
++tmp.reg_offset;
v->emit(BRW_OPCODE_MOV, tmp, fs_reg(f4));
}
};
static fs_reg
add_mul_yuv_c0(fs_visitor *v, const fs_reg& yuv)
{
/**
* Whereas original uses 16/256 = .0625, 128/256 = .5, here one uses the
* divider of 255 corresponding to the range [0,255]. The multiplier of 1.164
* in turn corresponds to treating Y-components being in the range of
* [16,235] (219 steps).
*/
fs_reg_const_float4 c0(v, -16.0f/255, -128.0f/255, -128.0f/255, 255.0/219);
fs_reg res(v, glsl_type::vec4_type);
fs_reg tmp_res(res);
fs_reg tmp_yuv(yuv);
/* YUV.xyz = ADD YUV, C0 */
for (unsigned i = 0; i < 3; ++i) {
v->emit(BRW_OPCODE_ADD, tmp_res, tmp_yuv, c0);
tmp_yuv.reg_offset++;
c0.reg_offset++;
tmp_res.reg_offset++;
}
/* YUV.x = MUL YUV.x, C0.w */
tmp_res.reg_offset = 0;
v->emit(BRW_OPCODE_MUL, tmp_res, tmp_res, c0);
return res;
}
static fs_reg
mad_yuv_c1(fs_visitor *v, const fs_reg& yuv)
{
/**
* The multipliers are result of treating V- and U-components having range
* of [16,240] (224 steps).
*/
fs_reg_const_float4 c1(v, 1.402 * 255.0 / 224, -0.714 * 255.0 / 224,
1.772 * 255.0 / 224, -0.344 * 255.0 / 224);
fs_reg res(v, glsl_type::vec4_type);
fs_reg tmp_res(res);
fs_reg tmp_uv(yuv);
fs_reg tmp_y(yuv);
/* RGB.x = MAD YUV.x, C1.x, YUV.z */
tmp_uv.reg_offset = 2;
v->emit(BRW_OPCODE_MAD, tmp_res, tmp_y, c1, tmp_uv);
c1.reg_offset++;
tmp_res.reg_offset++;
/* RGB.y = MAD YUV.x, C1.y, YUV.z */
v->emit(BRW_OPCODE_MAD, tmp_res, tmp_y, c1, tmp_uv);
c1.reg_offset++;
tmp_res.reg_offset++;
/* RGB.z = MAD YUV.x, C1.z, YUV.y */
tmp_uv.reg_offset = 1;
v->emit(BRW_OPCODE_MAD, tmp_res, tmp_y, c1, tmp_uv);
c1.reg_offset++;
/* RGB.y = MAD RGB.y, C1.w, YUV.y */
tmp_res.reg_offset = 1;
v->emit(BRW_OPCODE_MAD, tmp_res, tmp_res, c1, tmp_uv);
/* Specification says that alpha is to be set to 255 if not available */
tmp_res.reg_offset = 3;
v->emit(BRW_OPCODE_MOV, tmp_res, fs_reg(1.0f));
return res;
}
static const struct intel_texture_image *
resolve_tex_img(const struct gl_context *ctx, const GLbitfield *used, int unit)
{
if (!(used[unit] & (1 << TEXTURE_EXTERNAL_INDEX)))
return 0;
const struct gl_texture_object *obj =
ctx->Texture.Unit[unit].CurrentTex[TEXTURE_EXTERNAL_INDEX];
if (!obj)
return 0;
return (const struct intel_texture_image *)obj->Image[0][obj->BaseLevel];
}
static fs_inst *
emit_texture_gen(fs_visitor *visitor, ir_texture *ir, int gen,
fs_reg& dst, fs_reg& coord, int sampler,
int surf_index_offset)
{
fs_reg shadow_c;
fs_reg lod;
fs_reg lod2;
fs_inst *inst;
if (gen >= 7) {
inst = visitor->emit_texture_gen7(ir, dst, coord, shadow_c, lod, lod2, 0);
} else if (gen >= 5) {
inst = visitor->emit_texture_gen5(ir, dst, coord, shadow_c, lod, lod2, 0);
} else {
inst = visitor->emit_texture_gen4(ir, dst, coord, shadow_c, lod, lod2);
}
/* The header is set up by generate_tex() when necessary. */
inst->src[0] = reg_undef;
inst->sampler = sampler;
inst->surf_index_offset = surf_index_offset;
return inst;
}
static void
yuv420_chroma(fs_visitor *v, ir_texture *ir, int gen, fs_reg& yuv,
fs_reg& coord, int sampler,
unsigned chroma_src_i, unsigned chroma_dst_i)
{
fs_reg tmp_yuv_dst(yuv);
fs_reg c = fs_reg(v, glsl_type::vec4_type);
emit_texture_gen(v, ir, gen, c, coord, sampler, chroma_src_i);
tmp_yuv_dst.reg_offset += chroma_dst_i;
v->emit(BRW_OPCODE_MOV, tmp_yuv_dst, c);
}
static void
nv12_chroma(fs_visitor *v, ir_texture *ir, int gen, fs_reg& yuv,
fs_reg& coord, int sampler)
{
fs_reg tmp_yuv_dst(yuv);
fs_reg uv = fs_reg(v, glsl_type::vec4_type);
emit_texture_gen(v, ir, gen, uv, coord, sampler, 1);
tmp_yuv_dst.reg_offset++;
v->emit(BRW_OPCODE_MOV, tmp_yuv_dst, uv);
tmp_yuv_dst.reg_offset++;
uv.reg_offset++;
v->emit(BRW_OPCODE_MOV, tmp_yuv_dst, uv);
}
/* Consider the YUV format in question and fetch the different components from
* single plane in case of packed formats or from separate planes in case of
* planar formats.
* The components are then packed into one register allowing one to use the same
* conversion logic independent on the component layout in the texture being
* sampled. Naturally one could write texture format aware converters and
* possibly improve the performance by reducing the amount of instructions. Here
* things are, however, rather kept simple.
*/
bool
fs_visitor::emit_texture_external(ir_texture *ir, fs_reg& coordinate,
int sampler)
{
const struct intel_texture_image *img = resolve_tex_img(ctx,
fp->Base.TexturesUsed,
fp->Base.SamplerUnits[sampler]);
if (img && !img->ext_format)
return false;
/**
* "Sampling an external texture which is not associated with any EGLImage
* sibling will return a sample value of (0,0,0,1)."
*/
if (!img) {
swizzle_result(ir, fs_reg_const_float4(this, 0, 0, 0, 1), sampler);
return true;
}
fs_reg yuv = fs_reg(this, glsl_type::vec4_type);
emit_texture_gen(this, ir, intel->gen, yuv, coordinate, sampler, 0);
switch (img->ext_format->fourcc) {
case __DRI_IMAGE_FOURCC_YUV420:
yuv420_chroma(this, ir, intel->gen, yuv, coordinate, sampler, 1, 1);
yuv420_chroma(this, ir, intel->gen, yuv, coordinate, sampler, 2, 2);
break;
case __DRI_IMAGE_FOURCC_YVU420:
yuv420_chroma(this, ir, intel->gen, yuv, coordinate, sampler, 1, 2);
yuv420_chroma(this, ir, intel->gen, yuv, coordinate, sampler, 2, 1);
break;
case __DRI_IMAGE_FOURCC_NV12:
nv12_chroma(this, ir, intel->gen, yuv, coordinate, sampler);
break;
default:
return false;
}
fs_reg rgb = mad_yuv_c1(this, add_mul_yuv_c0(this, yuv));
swizzle_result(ir, rgb, sampler);
return true;
}

View File

@@ -1440,6 +1440,11 @@ fs_visitor::visit(ir_texture *ir)
sampler, texunit);
}
if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_EXTERNAL &&
emit_texture_external(ir, coordinate, sampler)) {
return;
}
fs_reg shadow_comparitor;
if (ir->shadow_comparitor) {
ir->shadow_comparitor->accept(this);

View File

@@ -40,6 +40,7 @@
#include "glsl/ralloc.h"
#include "brw_context.h"
#include "brw_state.h"
#include "brw_wm.h"
static unsigned
@@ -135,6 +136,7 @@ brwProgramStringNotify(struct gl_context *ctx,
if (newFP == curFP)
brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM;
newFP->id = get_new_program_id(brw->intel.intelScreen);
brw_clear_cache(brw, &brw->cache);
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog;
@@ -206,6 +208,14 @@ brw_get_scratch_bo(struct intel_context *intel,
}
}
static void
brwSamplerUniformChange(struct gl_context *ctx,
GLenum target, struct gl_program *prog)
{
brwProgramStringNotify(ctx, target, prog);
}
void brwInitFragProgFuncs( struct dd_function_table *functions )
{
assert(functions->ProgramStringNotify == _tnl_program_string);
@@ -215,6 +225,7 @@ void brwInitFragProgFuncs( struct dd_function_table *functions )
functions->DeleteProgram = brwDeleteProgram;
functions->IsProgramNative = brwIsProgramNative;
functions->ProgramStringNotify = brwProgramStringNotify;
functions->SamplerUniformChange = brwSamplerUniformChange;
functions->NewShader = brw_new_shader;
functions->NewShaderProgram = brw_new_shader_program;

View File

@@ -40,6 +40,12 @@ struct brw_sampler_prog_key_data {
*/
uint16_t yuvtex_mask;
uint16_t yuvtex_swap_mask; /**< UV swaped */
/**
* Format of the sampled texture when it is of the type image
* external and needs special sampling/conversion.
*/
const struct intel_image_format *ext_format;
};
void brw_populate_sampler_prog_key_data(struct gl_context *ctx,

View File

@@ -152,6 +152,7 @@ bool brw_search_cache(struct brw_cache *cache,
const void *key,
GLuint key_size,
uint32_t *inout_offset, void *out_aux);
void brw_clear_cache(struct brw_context *brw, struct brw_cache *cache);
void brw_state_cache_check_size( struct brw_context *brw );
void brw_init_caches( struct brw_context *brw );

View File

@@ -348,7 +348,7 @@ brw_init_caches(struct brw_context *brw)
cache->aux_free[BRW_WM_PROG] = brw_wm_prog_data_free;
}
static void
void
brw_clear_cache(struct brw_context *brw, struct brw_cache *cache)
{
struct intel_context *intel = &brw->intel;

View File

@@ -209,7 +209,6 @@ brw_vec4_prog_data_compare(const struct brw_vec4_prog_data *a,
return true;
}
bool
brw_vs_prog_data_compare(const void *in_a, const void *in_b,
int aux_size, const void *in_key)
@@ -231,6 +230,29 @@ brw_vs_prog_data_compare(const void *in_a, const void *in_b,
return true;
}
static bool brw_vs_surf_setup(GLbitfield samplers,
const GLubyte *samplers_units,
const GLbitfield *textures_used,
const struct gl_texture_unit *units,
uint32_t *sampler_to_surf_state_start)
{
unsigned num_samplers = _mesa_fls(samplers);
unsigned surf_index = 0;
for (unsigned s = 0; s < num_samplers; s++) {
if (samplers & (1 << s)) {
sampler_to_surf_state_start[s] = SURF_INDEX_VS_TEXTURE(surf_index);
surf_index += resolve_hw_surf_num(units, textures_used,
samplers_units[s]);
if (surf_index > SURF_INDEX_VS_TEXTURE(BRW_MAX_TEX_UNIT))
return false;
}
}
return true;
}
static bool
do_vs_prog(struct brw_context *brw,
struct gl_shader_program *prog,
@@ -307,6 +329,13 @@ do_vs_prog(struct brw_context *brw,
true);
}
if (!brw_vs_surf_setup(c.vp->program.Base.SamplersUsed,
c.vp->program.Base.SamplerUnits,
c.vp->program.Base.TexturesUsed,
brw->intel.ctx.Texture.Unit,
c.vp->sampler_to_surf_state_start))
return false;
/* Emit GEN4 code.
*/
program = brw_vs_emit(brw, prog, &c, &prog_data, mem_ctx, &program_size);

View File

@@ -130,6 +130,29 @@ brw_wm_prog_data_free(const void *in_prog_data)
ralloc_free((void *)prog_data->pull_param);
}
static bool brw_wm_fs_surf_setup(GLbitfield samplers,
const GLubyte *samplers_units,
const GLbitfield *textures_used,
const struct gl_texture_unit *units,
uint32_t *sampler_to_surf_state_start)
{
unsigned num_samplers = _mesa_fls(samplers);
unsigned surf_index = 0;
for (unsigned s = 0; s < num_samplers; s++) {
if (samplers & (1 << s)) {
sampler_to_surf_state_start[s] = SURF_INDEX_TEXTURE(surf_index);
surf_index += resolve_hw_surf_num(units, textures_used,
samplers_units[s]);
if (surf_index > SURF_INDEX_TEXTURE(BRW_MAX_TEX_UNIT))
return false;
}
}
return true;
}
/**
* All Mesa program -> GPU code generation goes through this function.
* Depending on the instructions used (i.e. flow control instructions)
@@ -172,6 +195,13 @@ bool do_wm_prog(struct brw_context *brw,
brw_compute_barycentric_interp_modes(brw, c->key.flat_shade,
&fp->program);
if (!brw_wm_fs_surf_setup(fp->program.Base.SamplersUsed,
fp->program.Base.SamplerUnits,
fp->program.Base.TexturesUsed,
brw->intel.ctx.Texture.Unit,
fp->sampler_to_surf_state_start))
return false;
program = brw_wm_fs_emit(brw, c, &fp->program, prog, &program_size);
if (program == NULL)
return false;
@@ -343,6 +373,13 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
if (sampler->WrapR == GL_CLAMP)
key->gl_clamp_mask[2] |= 1 << s;
}
if (unit->_Current->Target == GL_TEXTURE_EXTERNAL_OES) {
const struct intel_texture_image *intel_img =
(const struct intel_texture_image *)img;
key->ext_format = intel_img->ext_format;
}
}
}
}

View File

@@ -949,56 +949,37 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
}
static void
brw_update_texture_surface(struct gl_context *ctx,
unsigned unit,
uint32_t *binding_table,
unsigned surf_index)
brw_update_texture_component(struct brw_context *brw,
uint32_t *binding_table_slot,
const struct intel_mipmap_tree *mt,
unsigned width, unsigned height,
unsigned depth, unsigned stride,
GLuint target, GLuint tex_format,
uint32_t offset, uint32_t levels,
uint32_t first_level)
{
struct intel_context *intel = intel_context(ctx);
struct brw_context *brw = brw_context(ctx);
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
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);
uint32_t *surf;
int width, height, depth;
uint32_t tile_x, tile_y;
uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
6 * 4, 32, binding_table_slot);
if (tObj->Target == GL_TEXTURE_BUFFER) {
brw_update_buffer_texture_surface(ctx, unit, binding_table, surf_index);
return;
}
intel_miptree_get_dimensions_for_image(firstImage, &width, &height, &depth);
surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
6 * 4, 32, &binding_table[surf_index]);
surf[0] = (translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
surf[0] = (target << BRW_SURFACE_TYPE_SHIFT |
BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT |
BRW_SURFACE_CUBEFACE_ENABLES |
(translate_tex_format(intel,
mt->format,
firstImage->InternalFormat,
tObj->DepthMode,
sampler->sRGBDecode) <<
BRW_SURFACE_FORMAT_SHIFT));
(tex_format << BRW_SURFACE_FORMAT_SHIFT));
surf[1] = intelObj->mt->region->bo->offset + intelObj->mt->offset; /* reloc */
surf[1] += intel_miptree_get_tile_offsets(intelObj->mt, firstImage->Level, 0,
surf[1] = mt->region->bo->offset + offset;
surf[1] += intel_miptree_get_tile_offsets(mt, first_level, 0,
&tile_x, &tile_y);
surf[2] = ((intelObj->_MaxLevel - tObj->BaseLevel) << BRW_SURFACE_LOD_SHIFT |
surf[2] = (levels << BRW_SURFACE_LOD_SHIFT |
(width - 1) << BRW_SURFACE_WIDTH_SHIFT |
(height - 1) << BRW_SURFACE_HEIGHT_SHIFT);
surf[3] = (brw_get_surface_tiling_bits(intelObj->mt->region->tiling) |
surf[3] = (brw_get_surface_tiling_bits(mt->region->tiling) |
(depth - 1) << BRW_SURFACE_DEPTH_SHIFT |
(intelObj->mt->region->pitch - 1) <<
BRW_SURFACE_PITCH_SHIFT);
(stride - 1) << BRW_SURFACE_PITCH_SHIFT);
surf[4] = brw_get_surface_num_multisamples(intelObj->mt->num_samples);
surf[4] = brw_get_surface_num_multisamples(mt->num_samples);
assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
/* Note that the low bits of these fields are missing, so
@@ -1012,12 +993,80 @@ brw_update_texture_surface(struct gl_context *ctx,
/* Emit relocation to surface contents */
drm_intel_bo_emit_reloc(brw->intel.batch.bo,
binding_table[surf_index] + 4,
intelObj->mt->region->bo,
surf[1] - intelObj->mt->region->bo->offset,
*binding_table_slot + 4,
mt->region->bo,
surf[1] - mt->region->bo->offset,
I915_GEM_DOMAIN_SAMPLER, 0);
}
static void
brw_update_ext_texture_surface(struct brw_context *brw,
uint32_t *binding_table_slots,
const struct intel_texture_image *intel_img)
{
unsigned i;
const struct intel_region *region = intel_img->mt->region;
const struct intel_image_format *f = intel_img->ext_format;
for (i = 0; i < f->nplanes; ++i) {
int format = BRW_SURFACEFORMAT_R8_UNORM;
int index = f->planes[i].buffer_index;
if (f->planes[i].dri_format == __DRI_IMAGE_FORMAT_GR88)
format = BRW_SURFACEFORMAT_R8G8_UNORM;
brw_update_texture_component(brw, binding_table_slots + i,
intel_img->mt,
region->width >> f->planes[i].width_shift,
region->height >> f->planes[i].height_shift,
intel_img->base.Base.Depth,
intel_img->ext_strides[index],
BRW_SURFACE_2D,
format,
intel_img->ext_offsets[index],
0 /*levels*/,
0 /*first_level*/);
}
}
static void
brw_update_texture_surface(struct gl_context *ctx,
unsigned unit,
uint32_t *binding_table,
unsigned surf_index)
{
struct brw_context *brw = brw_context(ctx);
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct intel_mipmap_tree *mt = intelObj->mt;
struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
const struct intel_texture_image *intel_img =
(const struct intel_texture_image *)firstImage;
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
int width, height, depth;
if (tObj->Target == GL_TEXTURE_BUFFER) {
brw_update_buffer_texture_surface(ctx, unit, binding_table, surf_index);
return;
}
else if (tObj->Target == GL_TEXTURE_EXTERNAL_OES && intel_img->ext_format) {
brw_update_ext_texture_surface(brw, binding_table + surf_index,
intel_img);
return;
}
intel_miptree_get_dimensions_for_image(firstImage, &width, &height, &depth);
brw_update_texture_component(brw, binding_table + surf_index,
mt, width, height, depth, mt->region->pitch,
translate_tex_target(tObj->Target),
translate_tex_format(intel_context(ctx), mt->format,
firstImage->InternalFormat, tObj->DepthMode, sampler->sRGBDecode),
mt->offset,
intelObj->_MaxLevel - tObj->BaseLevel,
firstImage->Level);
}
/**
* Create the constant buffer surface. Vertex/fragment shader constants will be
* read from this buffer with Data Port Read instructions/messages.
@@ -1479,9 +1528,6 @@ brw_update_texture_surfaces(struct brw_context *brw)
unsigned num_samplers = _mesa_fls(vs->SamplersUsed | fs->SamplersUsed);
for (unsigned s = 0; s < num_samplers; s++) {
brw->vs.surf_offset[SURF_INDEX_VS_TEXTURE(s)] = 0;
brw->wm.surf_offset[SURF_INDEX_TEXTURE(s)] = 0;
if (vs->SamplersUsed & (1 << s)) {
const unsigned unit = vs->SamplerUnits[s];
@@ -1489,7 +1535,9 @@ brw_update_texture_surfaces(struct brw_context *brw)
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
intel->vtbl.update_texture_surface(ctx, unit,
brw->vs.surf_offset,
SURF_INDEX_VS_TEXTURE(s));
brw_surf_index_vs_texture(
(const struct brw_vertex_program *)brw->vertex_program,
s));
}
}
@@ -1500,7 +1548,9 @@ brw_update_texture_surfaces(struct brw_context *brw)
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
intel->vtbl.update_texture_surface(ctx, unit,
brw->wm.surf_offset,
SURF_INDEX_TEXTURE(s));
brw_surf_index_texture(
(const struct brw_fragment_program *)brw->fragment_program,
s));
}
}
}

View File

@@ -282,6 +282,103 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
gen7_check_surface_setup(surf, false /* is_render_target */);
}
static void
gen7_update_texture_component(struct brw_context *brw,
uint32_t *binding_table_slot,
const struct intel_mipmap_tree *mt,
unsigned width, unsigned height,
unsigned depth, unsigned stride,
GLenum target, GLuint tex_format,
uint32_t offset, GLuint first_level,
uint32_t levels, int swizzle)
{
uint32_t tile_x, tile_y;
const struct intel_region *region = mt->region;
uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
8 * 4, 32, binding_table_slot);
memset(surf, 0, 8 * 4);
surf[0] = translate_tex_target(target) << BRW_SURFACE_TYPE_SHIFT |
tex_format << BRW_SURFACE_FORMAT_SHIFT |
gen7_surface_tiling_mode(region->tiling) |
BRW_SURFACE_CUBEFACE_ENABLES;
if (mt->align_h == 4)
surf[0] |= GEN7_SURFACE_VALIGN_4;
if (mt->align_w == 8)
surf[0] |= GEN7_SURFACE_HALIGN_8;
if (depth > 1 && target != GL_TEXTURE_3D)
surf[0] |= GEN7_SURFACE_IS_ARRAY;
if (mt->array_spacing_lod0)
surf[0] |= GEN7_SURFACE_ARYSPC_LOD0;
surf[1] = mt->region->bo->offset + offset;
surf[1] += intel_miptree_get_tile_offsets(mt, first_level, 0,
&tile_x, &tile_y);
surf[2] = SET_FIELD(width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(height - 1, GEN7_SURFACE_HEIGHT);
surf[3] = SET_FIELD(depth - 1, BRW_SURFACE_DEPTH) | (stride - 1);
surf[4] = gen7_surface_msaa_bits(mt->num_samples, mt->msaa_layout);
assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
/* Note that the low bits of these fields are missing, so
* there's the possibility of getting in trouble.
*/
surf[5] = ((tile_x / 4) << BRW_SURFACE_X_OFFSET_SHIFT |
(tile_y / 2) << BRW_SURFACE_Y_OFFSET_SHIFT |
/* mip count */
levels);
if (brw->intel.is_haswell) {
surf[7] =
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 0)), GEN7_SURFACE_SCS_R) |
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 1)), GEN7_SURFACE_SCS_G) |
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 2)), GEN7_SURFACE_SCS_B) |
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 3)), GEN7_SURFACE_SCS_A);
}
/* Emit relocation to surface contents */
drm_intel_bo_emit_reloc(brw->intel.batch.bo,
*binding_table_slot + 4,
mt->region->bo,
surf[1] - mt->region->bo->offset,
I915_GEM_DOMAIN_SAMPLER, 0);
gen7_check_surface_setup(surf, false /* is_render_target */);
}
static void
gen7_update_ext_texture_surface(struct brw_context *brw,
uint32_t *binding_table_slots,
const struct intel_texture_image *intel_img)
{
unsigned i;
const struct intel_region *region = intel_img->mt->region;
const struct intel_image_format *f = intel_img->ext_format;
for (i = 0; i < f->nplanes; ++i) {
int format = BRW_SURFACEFORMAT_R8_UNORM;
int index = f->planes[i].buffer_index;
if (f->planes[i].dri_format == __DRI_IMAGE_FORMAT_GR88)
format = BRW_SURFACEFORMAT_R8G8_UNORM;
gen7_update_texture_component(brw, binding_table_slots + i,
intel_img->mt,
region->width >> f->planes[i].width_shift,
region->height >> f->planes[i].height_shift,
intel_img->base.Base.Depth, intel_img->ext_strides[index],
GL_TEXTURE_EXTERNAL_OES,
format,
intel_img->ext_offsets[index],
0, 0, 0);
}
}
static void
gen7_update_texture_surface(struct gl_context *ctx,
unsigned unit,
@@ -294,63 +391,29 @@ gen7_update_texture_surface(struct gl_context *ctx,
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct intel_mipmap_tree *mt = intelObj->mt;
struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
const struct intel_texture_image *intel_img =
(const struct intel_texture_image *)firstImage;
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
int width, height, depth;
uint32_t tile_x, tile_y;
int swizzle = 0;
if (tObj->Target == GL_TEXTURE_BUFFER) {
gen7_update_buffer_texture_surface(ctx, unit, binding_table, surf_index);
return;
}
else if (tObj->Target == GL_TEXTURE_EXTERNAL_OES && intel_img->ext_format) {
gen7_update_ext_texture_surface(brw, binding_table + surf_index,
intel_img);
return;
}
/* We don't support MSAA for textures. */
assert(!mt->array_spacing_lod0);
assert(mt->num_samples <= 1);
intel_miptree_get_dimensions_for_image(firstImage, &width, &height, &depth);
uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
8 * 4, 32, &binding_table[surf_index]);
memset(surf, 0, 8 * 4);
uint32_t tex_format = translate_tex_format(intel,
mt->format,
firstImage->InternalFormat,
tObj->DepthMode,
sampler->sRGBDecode);
surf[0] = translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
tex_format << BRW_SURFACE_FORMAT_SHIFT |
gen7_surface_tiling_mode(mt->region->tiling) |
BRW_SURFACE_CUBEFACE_ENABLES;
if (mt->align_h == 4)
surf[0] |= GEN7_SURFACE_VALIGN_4;
if (mt->align_w == 8)
surf[0] |= GEN7_SURFACE_HALIGN_8;
if (depth > 1 && tObj->Target != GL_TEXTURE_3D)
surf[0] |= GEN7_SURFACE_IS_ARRAY;
if (mt->array_spacing_lod0)
surf[0] |= GEN7_SURFACE_ARYSPC_LOD0;
surf[1] = mt->region->bo->offset + mt->offset; /* reloc */
surf[1] += intel_miptree_get_tile_offsets(intelObj->mt, firstImage->Level, 0,
&tile_x, &tile_y);
surf[2] = SET_FIELD(width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(height - 1, GEN7_SURFACE_HEIGHT);
surf[3] = SET_FIELD(depth - 1, BRW_SURFACE_DEPTH) |
((intelObj->mt->region->pitch) - 1);
surf[4] = gen7_surface_msaa_bits(mt->num_samples, mt->msaa_layout);
assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
/* Note that the low bits of these fields are missing, so
* there's the possibility of getting in trouble.
*/
surf[5] = ((tile_x / 4) << BRW_SURFACE_X_OFFSET_SHIFT |
(tile_y / 2) << BRW_SURFACE_Y_OFFSET_SHIFT |
/* mip count */
(intelObj->_MaxLevel - tObj->BaseLevel));
if (intel->is_haswell) {
/* Handling GL_ALPHA as a surface format override breaks 1.30+ style
* texturing functions that return a float, as our code generation always
@@ -360,24 +423,17 @@ gen7_update_texture_surface(struct gl_context *ctx,
(firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
firstImage->_BaseFormat == GL_DEPTH_STENCIL);
const int swizzle = unlikely(alpha_depth)
? SWIZZLE_XYZW : brw_get_texture_swizzle(ctx, tObj);
surf[7] =
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 0)), GEN7_SURFACE_SCS_R) |
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 1)), GEN7_SURFACE_SCS_G) |
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 2)), GEN7_SURFACE_SCS_B) |
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 3)), GEN7_SURFACE_SCS_A);
swizzle =
unlikely(alpha_depth) ? SWIZZLE_XYZW :
brw_get_texture_swizzle(ctx, tObj);
}
/* Emit relocation to surface contents */
drm_intel_bo_emit_reloc(brw->intel.batch.bo,
binding_table[surf_index] + 4,
intelObj->mt->region->bo,
surf[1] - intelObj->mt->region->bo->offset,
I915_GEM_DOMAIN_SAMPLER, 0);
gen7_check_surface_setup(surf, false /* is_render_target */);
gen7_update_texture_component(brw, binding_table + surf_index,
mt, width, height, depth, mt->region->pitch, tObj->Target,
translate_tex_format(intel, mt->format, firstImage->InternalFormat,
tObj->DepthMode, sampler->sRGBDecode),
mt->offset, firstImage->Level,
intelObj->_MaxLevel - tObj->BaseLevel, swizzle);
}
/**

View File

@@ -83,7 +83,9 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.NV_texture_rectangle = true;
ctx->Extensions.TDFX_texture_compression_FXT1 = true;
ctx->Extensions.OES_EGL_image = true;
ctx->Extensions.OES_EGL_image_external = true;
ctx->Extensions.OES_draw_texture = true;
ctx->Extensions.OES_EGL_image_external = true;
if (intel->gen >= 6)
ctx->Const.GLSLVersion = 140;
@@ -181,6 +183,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.EXT_texture_compression_s3tc = true;
ctx->Extensions.ANGLE_texture_compression_dxt = true;
ctx->Extensions.EXT_texture_compression_s3tc = true;
if (intel->gen >= 4) {
ctx->Extensions.NV_primitive_restart = true;

View File

@@ -43,6 +43,7 @@
#include <errno.h>
#include "main/hash.h"
#include "main/macros.h"
#include "intel_context.h"
#include "intel_regions.h"
#include "intel_blit.h"
@@ -158,6 +159,69 @@ intel_region_alloc(struct intel_screen *screen,
return region;
}
/**
* The region is allocated in a way that it can be accessed by the sampling
* engine as it is (width aligned by four and height by two). Also the plane
* offsets are on page boundary in order to allow them to be further used as
* images on their own.
*/
struct intel_region *
intel_region_planar_alloc(struct intel_screen *screen,
int fourcc, GLuint width, GLuint height,
uint32_t *strides, uint32_t *offsets)
{
drm_intel_bo *buffer;
struct intel_region *region;
unsigned total;
/* For now one supports only formats with 2x2 subsampled UV-planes */
if (height % 2 || width % 2)
return NULL;
strides[0] = ALIGN(width, 4);
offsets[0] = 0;
total = strides[0] * ALIGN(height, 2);
switch (fourcc) {
case __DRI_IMAGE_FOURCC_YUV420:
case __DRI_IMAGE_FOURCC_YVU420:
strides[1] = ALIGN(width / 2, 4);
offsets[1] = ALIGN(total, 4096);
total = offsets[1] + strides[1] * ALIGN(height / 2, 2);
strides[2] = ALIGN(width / 2, 4);
offsets[2] = ALIGN(total, 4096);
total = offsets[2] + strides[2] * ALIGN(height / 2, 2);
break;
case __DRI_IMAGE_FOURCC_NV12:
strides[1] = ALIGN(width, 4);
offsets[1] = ALIGN(total, 4096);
total = offsets[1] + strides[1] * ALIGN(height / 2, 2);
strides[2] = 0;
offsets[2] = 0;
break;
default:
return NULL;
}
buffer = drm_intel_bo_alloc(screen->bufmgr, "region", total, 0);
if (buffer == NULL)
return NULL;
region = intel_region_alloc_internal(screen, 1, width, height,
width, I915_TILING_NONE, buffer);
if (region == NULL) {
drm_intel_bo_unreference(buffer);
return NULL;
}
return region;
}
bool
intel_region_flink(struct intel_region *region, uint32_t *name)
{
@@ -283,7 +347,7 @@ intel_region_release(struct intel_region **region_handle)
* untiled, the masks are set to 0.
*/
void
intel_region_get_tile_masks(struct intel_region *region,
intel_region_get_tile_masks(const struct intel_region *region,
uint32_t *mask_x, uint32_t *mask_y,
bool map_stencil_as_y_tiled)
{

View File

@@ -81,6 +81,12 @@ struct intel_region *intel_region_alloc(struct intel_screen *screen,
GLuint height,
bool expect_accelerated_upload);
struct intel_region *intel_region_planar_alloc(struct intel_screen *screen,
int fourcc,
GLuint width, GLuint height,
uint32_t *strides,
uint32_t *offsets);
struct intel_region *
intel_region_alloc_for_handle(struct intel_screen *screen,
GLuint cpp,
@@ -104,7 +110,7 @@ void intel_region_release(struct intel_region **ib);
void intel_recreate_static_regions(struct intel_context *intel);
void
intel_region_get_tile_masks(struct intel_region *region,
intel_region_get_tile_masks(const struct intel_region *region,
uint32_t *mask_x, uint32_t *mask_y,
bool map_stencil_as_y_tiled);

View File

@@ -210,6 +210,11 @@ static struct intel_image_format intel_image_formats[] = {
{ 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
{ 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
{ __DRI_IMAGE_FOURCC_YVU420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
{ 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
{ 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
{ __DRI_IMAGE_FOURCC_YUV422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
{ 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
@@ -241,6 +246,21 @@ static struct intel_image_format intel_image_formats[] = {
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
};
static struct intel_image_format *
intel_image_format_lookup(int fourcc)
{
struct intel_image_format *f = 0;
for (unsigned i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
if (intel_image_formats[i].fourcc == fourcc) {
f = &intel_image_formats[i];
break;
}
}
return f;
}
static __DRIimage *
intel_allocate_image(int dri_format, void *loaderPrivate)
{
@@ -275,6 +295,12 @@ intel_allocate_image(int dri_format, void *loaderPrivate)
case __DRI_IMAGE_FORMAT_GR88:
image->format = MESA_FORMAT_GR88;
break;
case __DRI_IMAGE_FOURCC_YUV420:
case __DRI_IMAGE_FOURCC_YVU420:
case __DRI_IMAGE_FOURCC_NV12:
image->format = MESA_FORMAT_R8;
image->planar_format = intel_image_format_lookup(dri_format);
break;
case __DRI_IMAGE_FORMAT_NONE:
image->format = MESA_FORMAT_NONE;
break;
@@ -502,9 +528,18 @@ intel_create_image(__DRIscreen *screen,
if (image == NULL)
return NULL;
if (format == __DRI_IMAGE_FOURCC_YUV420 ||
format == __DRI_IMAGE_FOURCC_YVU420 ||
format == __DRI_IMAGE_FOURCC_NV12) {
image->region =
intel_region_planar_alloc(intelScreen, format, width, height,
image->strides, image->offsets);
} else {
cpp = _mesa_get_format_bytes(image->format);
image->region =
intel_region_alloc(intelScreen, tiling, cpp, width, height, true);
}
if (image->region == NULL) {
free(image);
return NULL;
@@ -608,17 +643,12 @@ intel_create_image_from_names(__DRIscreen *screen,
if (screen == NULL || names == NULL || num_names != 1)
return NULL;
for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
if (intel_image_formats[i].fourcc == fourcc) {
f = &intel_image_formats[i];
}
}
f = intel_image_format_lookup(fourcc);
if (f == NULL)
return NULL;
image = intel_create_image_from_name(screen, width, height,
__DRI_IMAGE_FORMAT_NONE,
__DRI_IMAGE_FORMAT_R8,
names[0], strides[0],
loaderPrivate);

View File

@@ -388,6 +388,27 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
image->format, image->offset,
image->width, image->height,
image->tile_x, image->tile_y);
if (image->planar_format) {
struct intel_texture_image *intel_image = intel_texture_image(texImage);
const struct intel_image_format *f = image->planar_format;
unsigned i, index;
/* Check for sampling support here - shader compile time is too late. */
if (f->fourcc != __DRI_IMAGE_FOURCC_YUV420 &&
f->fourcc != __DRI_IMAGE_FOURCC_YVU420 &&
f->fourcc != __DRI_IMAGE_FOURCC_NV12) {
_mesa_error(ctx, GL_INVALID_OPERATION, __func__);
return;
}
intel_image->ext_format = f;
for (i = 0; i < f->nplanes; i++) {
index = f->planes[i].buffer_index;
intel_image->ext_offsets[index] = image->offsets[index];
intel_image->ext_strides[index] = image->strides[index];
}
}
}
void

View File

@@ -29,6 +29,7 @@
#define _INTEL_TEX_OBJ_H
#include "swrast/s_context.h"
#include "intel_regions.h"
struct intel_texture_object
@@ -71,8 +72,44 @@ struct intel_texture_image
* Else there is no image data.
*/
struct intel_mipmap_tree *mt;
/* If ext_format != NULL, the image represents an external buffer. Depending
* on the format the details for the individual components of planar formats
* (such as NV12) are set in ext_strides and ext_offsets.
*/
const struct intel_image_format *ext_format;
uint32_t ext_strides[3];
uint32_t ext_offsets[3];
};
/** Use specifically the format of the first image as this is set directly based
* on the format of "__DRIimage" representing the external surface:
* (see intel_image_target_texture_2d() and intel_set_texture_image_region()).
*/
static INLINE unsigned
resolve_hw_surf_num(const struct gl_texture_unit *units, const GLbitfield *used,
unsigned unit)
{
const struct intel_texture_image *intel_img;
const struct gl_texture_object *tex_obj;
/** Only external textures may require more than one surface */
if (!(used[unit] & (1 << TEXTURE_EXTERNAL_INDEX)))
return 1;
tex_obj = units[unit].CurrentTex[TEXTURE_EXTERNAL_INDEX];
assert(tex_obj->Target == GL_TEXTURE_EXTERNAL_OES);
intel_img = (const struct intel_texture_image *)
tex_obj->Image[0][tex_obj->BaseLevel];
/** Assume one surface as no images are bound yet */
if (!intel_img)
return 1;
return intel_img->ext_format ? intel_img->ext_format->nplanes : 1;
}
static INLINE struct intel_texture_object *
intel_texture_object(struct gl_texture_object *obj)
{

View File

@@ -143,7 +143,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_texture_float", o(ARB_texture_float), GL, 2004 },
{ "GL_ARB_texture_mirrored_repeat", o(dummy_true), GLL, 2001 },
{ "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL, 2009 },
{ "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL, 2003 },
{ "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL | ES1, 2003 },
{ "GL_ARB_texture_query_lod", o(ARB_texture_query_lod), GL, 2009 },
{ "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL, 2004 },
{ "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL, 2009 },
@@ -212,7 +212,7 @@ static const struct extension extension_table[] = {
{ "GL_ANGLE_texture_compression_dxt5", o(ANGLE_texture_compression_dxt), GL | ES1 | ES2, 2011 },
{ "GL_EXT_texture_compression_latc", o(EXT_texture_compression_latc), GL, 2006 },
{ "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 },
{ "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL, 2000 },
{ "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL | ES1 | ES2, 2000 },
{ "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GLL, 2001 },
{ "GL_EXT_texture_edge_clamp", o(dummy_true), GLL, 1997 },
{ "GL_EXT_texture_env_add", o(dummy_true), GLL, 1999 },
@@ -291,6 +291,7 @@ static const struct extension extension_table[] = {
{ "GL_AMD_vertex_shader_layer", o(AMD_vertex_shader_layer), GL, 2012 },
{ "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL, 2006 },
{ "GL_APPLE_packed_pixels", o(dummy_true), GLL, 2002 },
{ "GL_APPLE_texture_2D_limited_npot", o(ARB_texture_non_power_of_two), ES1, 2011 },
{ "GL_APPLE_texture_max_level", o(dummy_true), ES1 | ES2, 2009 },
{ "GL_APPLE_vertex_array_object", o(dummy_true), GLL, 2002 },
{ "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 },

View File

@@ -2332,6 +2332,21 @@ struct gl_shader_program
struct gl_uniform_block *UniformBlocks;
unsigned NumUniformBlocks;
/**
* Scale factor for the uniform base location
*
* This is used to generate locations (returned by \c glGetUniformLocation)
* of uniforms. The base location of the uniform is multiplied by this
* value, and the array index is added.
*
* \note
* Must be >= 1.
*
* \sa
* _mesa_uniform_merge_location_offset, _mesa_uniform_split_location_offset
*/
unsigned UniformLocationBaseScale;
/**
* Indices into the _LinkedShaders's UniformBlocks[] array for each stage
* they're used in, or -1.

View File

@@ -283,6 +283,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
ralloc_free(shProg->UniformStorage);
shProg->NumUserUniformStorage = 0;
shProg->UniformStorage = NULL;
shProg->UniformLocationBaseScale = 0;
}
if (shProg->UniformHash) {

View File

@@ -235,7 +235,7 @@ validate_uniform_parameters(struct gl_context *ctx,
return false;
}
_mesa_uniform_split_location_offset(location, loc, array_index);
_mesa_uniform_split_location_offset(shProg, location, loc, array_index);
if (*loc >= shProg->NumUserUniformStorage) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",

View File

@@ -538,7 +538,7 @@ _mesa_GetUniformLocation(GLhandleARB programObj, const GLcharARB *name)
if (shProg->UniformStorage[index].block_index != -1)
return -1;
return _mesa_uniform_merge_location_offset(index, offset);
return _mesa_uniform_merge_location_offset(shProg, index, offset);
}
GLuint GLAPIENTRY

View File

@@ -269,20 +269,24 @@ struct gl_builtin_uniform_desc {
* Combine the uniform's base location and the offset
*/
static inline GLint
_mesa_uniform_merge_location_offset(unsigned base_location, unsigned offset)
_mesa_uniform_merge_location_offset(const struct gl_shader_program *prog,
unsigned base_location, unsigned offset)
{
return (base_location << 16) | offset;
assert(prog->UniformLocationBaseScale >= 0);
assert(offset < prog->UniformLocationBaseScale);
return (base_location * prog->UniformLocationBaseScale) + offset;
}
/**
* Separate the uniform base location and parameter offset
*/
static inline void
_mesa_uniform_split_location_offset(GLint location, unsigned *base_location,
_mesa_uniform_split_location_offset(const struct gl_shader_program *prog,
GLint location, unsigned *base_location,
unsigned *offset)
{
*offset = location & 0xffff;
*base_location = location >> 16;
*offset = location % prog->UniformLocationBaseScale;
*base_location = location / prog->UniformLocationBaseScale;
}
/*@}*/

View File

@@ -101,6 +101,9 @@ create_version_string(struct gl_context *ctx, const char *prefix)
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"%s%u.%u%s Mesa " PACKAGE_VERSION
#ifdef MESA_VERSION_STRING_EXTRA
" " MESA_VERSION_STRING_EXTRA
#endif
#ifdef MESA_GIT_SHA1
" (" MESA_GIT_SHA1 ")"
#endif

View File

@@ -3096,7 +3096,7 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
"Couldn't find uniform for initializer %s\n", name);
return;
}
int loc = _mesa_uniform_merge_location_offset(index, offset);
int loc = _mesa_uniform_merge_location_offset(shader_program, index, offset);
for (unsigned int i = 0; i < (type->is_array() ? type->length : 1); i++) {
ir_constant *element;