Compare commits

..

22 Commits

Author SHA1 Message Date
Chih-Wei Huang
f189dfe9e9 mesa: fix compiling issues with gcc 4.4.x
Gcc 4.4 requires a class with virtual functions has to
define the virtual destructor.
2010-12-29 17:35:47 +08:00
Chia-I Wu
d1ccafa5b7 android: Enable OpenGL ES 2.0. 2010-12-29 16:56:47 +08:00
Chia-I Wu
f7a0636329 i965: Add support for GL_FIXED. 2010-12-11 21:47:18 +08:00
Chih-Wei Huang
6269411b81 android: enable support of i965c 2010-12-09 20:01:35 -05:00
Chia-I Wu
88721c8555 android: Add Android.mk's. 2010-12-09 20:01:35 -05:00
Chia-I Wu
4128957d30 android: Add pre-generated files. 2010-12-09 20:01:35 -05:00
Chia-I Wu
07a8209c3f android: Add __DRI_IMAGE_FORMAT_RGBA8888_REV. 2010-12-09 20:01:35 -05:00
Chia-I Wu
b0a79b3512 android: Add DRM-based gralloc. 2010-12-09 20:01:35 -05:00
Chia-I Wu
121fc671f4 android: Add new classic EGL driver for Android. 2010-12-09 20:01:35 -05:00
Chia-I Wu
8148db591a android: Add android backend for st/egl. 2010-12-09 20:01:35 -05:00
Chia-I Wu
0d4dcb2584 android: Add Android EGL extensions. 2010-12-09 20:01:35 -05:00
Chia-I Wu
1337551451 android: Add _EGL_PLATFORM_ANDROID. 2010-12-09 20:01:35 -05:00
Chia-I Wu
6719d59a85 android: Enable extensions required by ES1 for i915c. 2010-12-09 20:01:35 -05:00
Chia-I Wu
3fe7753b70 android: Fix depth/stencil with i915c. 2010-12-09 20:01:34 -05:00
Chia-I Wu
017c563cff android: Fix GL_OES_EGL_image with SurfaceFlinger. 2010-12-09 20:01:34 -05:00
Chia-I Wu
bf21df37c6 android: Use __mmap2 in winsys/svga. 2010-12-09 20:01:34 -05:00
Chia-I Wu
17935c0191 android: Fix build with bionic. 2010-12-09 20:01:34 -05:00
Chia-I Wu
7aceb74db7 i915c: Add GL_OES_draw_texture support. 2010-12-09 20:01:34 -05:00
Chia-I Wu
88e9712a68 tnl: Add support for GL_FIXED. 2010-12-09 20:01:34 -05:00
Chia-I Wu
2e9e27c0f7 i915: Free with FREE. 2010-12-09 19:39:22 -05:00
Chia-I Wu
455a7585de targets/egl-gdi: Optional support for DRM screen. 2010-12-09 19:39:22 -05:00
Chia-I Wu
25ed79d830 Revert "egl: Drop broken _EGL_PLATFORM_NO_OS code"
This reverts commit 021a68b7e8.
2010-12-09 19:39:22 -05:00
221 changed files with 81357 additions and 5798 deletions

3
Android.mk Normal file
View File

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

View File

@@ -180,7 +180,7 @@ ultrix-gcc:
# Rules for making release tarballs
VERSION=7.10
VERSION=7.10-devel
DIRECTORY = Mesa-$(VERSION)
LIB_NAME = MesaLib-$(VERSION)
GLUT_NAME = MesaGLUT-$(VERSION)

View File

@@ -1352,7 +1352,7 @@ if test "x$enable_gallium_egl" = xauto; then
enable_gallium_egl=$enable_egl
;;
*)
enable_gallium_egl=$enable_openvg
enable_gallium_egl=no
;;
esac
fi
@@ -1467,6 +1467,10 @@ AC_SUBST([EGL_CLIENT_APIS])
if test "x$HAVE_ST_EGL" = xyes; then
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl"
# define GLX_DIRECT_RENDERING even when the driver is not dri
if test "x$mesa_driver" != xdri -a "x$driglx_direct" = xyes; then
DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
fi
fi
if test "x$HAVE_ST_XORG" = xyes; then

View File

@@ -19,7 +19,10 @@ API entry points and helper functions for use by the drivers. Drivers are
dynamically loaded by the main library and most of the EGL API calls are
directly dispatched to the drivers.</p>
<p>The driver in use decides the window system to support.</p>
<p>The driver in use decides the window system to support. For drivers that
support hardware rendering, there are usually multiple drivers supporting the
same window system. Each one of of them supports a certain range of graphics
cards.</p>
<h2>Build EGL</h2>
@@ -83,19 +86,16 @@ select the right platforms automatically.</p>
<li><code>--enable-gles1</code> and <code>--enable-gles2</code>
<p>These options enable OpenGL ES support in OpenGL. The result is one big
internal library that supports multiple APIs.</p>
<p>These options enable OpenGL ES support in OpenGL. The result is
one big library that supports multiple APIs.</p>
</li>
<li><code>--enable-gles-overlay</code>
<p>This option enables OpenGL ES as separate internal libraries. This is an
alternative approach to enable OpenGL ES.</p>
<p>This is only supported by <code>egl_gallium</code>. For systems using DRI
drivers, <code>--enable-gles1</code> and <code>--enable-gles2</code> are
suggested instead as all drivers will benefit.</p>
<p>This option enables OpenGL ES as separate libraries. This is an alternative
approach to enable OpenGL ES. It is only supported by
<code>egl_gallium</code>.</p>
</li>
@@ -134,16 +134,6 @@ colon-separated directories where the main library will look for drivers, in
addition to the default directory. This variable is ignored for setuid/setgid
binaries.</p>
<p>This variable is usually set to test an uninstalled build. For example, one
may set</p>
<pre>
$ export LD_LIBRARY_PATH=$mesa/lib
$ export EGL_DRIVERS_PATH=$mesa/lib/egl
</pre>
<p>to test a build without installation</p>
</li>
<li><code>EGL_DRIVER</code>
@@ -190,10 +180,8 @@ variable to true forces the use of software rendering.</p>
<li><code>egl_dri2</code>
<p>This driver supports both <code>x11</code> and <code>drm</code> platforms.
It functions as a DRI driver loader. For <code>x11</code> support, it talks to
the X server directly using (XCB-)DRI2 protocol.</p>
<p>This driver can share DRI drivers with <code>libGL</code>.</p>
It functions as a DRI2 driver loader. For <code>x11</code> support, it talks
to the X server directly using (XCB-)DRI2 protocol.</p>
</li>
@@ -203,10 +191,6 @@ the X server directly using (XCB-)DRI2 protocol.</p>
hardwares supported by Gallium3D. It is the only driver that supports OpenVG.
The supported platforms are X11, DRM, FBDEV, and GDI.</p>
<p>This driver comes with its own hardware drivers
(<code>pipe_&lt;hw&gt;</code>) and client API modules
(<code>st_&lt;api&gt;</code>).</p>
</li>
<li><code>egl_glx</code>
@@ -218,21 +202,6 @@ is not available in GLX or GLX extensions.</p>
</li>
</ul>
<h2>Packaging</h2>
<p>The ABI between the main library and its drivers are not stable. Nor is
there a plan to stabilize it at the moment. Of the EGL drivers,
<code>egl_gallium</code> has its own hardware drivers and client API modules.
They are considered internal to <code>egl_gallium</code> and there is also no
stable ABI between them. These should be kept in mind when packaging for
distribution.</p>
<p>Generally, <code>egl_dri2</code> is preferred over <code>egl_gallium</code>
when the system already has DRI drivers. As <code>egl_gallium</code> is loaded
before <code>egl_dri2</code> when both are available, <code>egl_gallium</code>
may either be disabled with <code>--disable-gallium-egl</code> or packaged
separately.</p>
<h2>Developers</h2>
<p>The sources of the main library and the classic drivers can be found at

File diff suppressed because it is too large Load Diff

View File

@@ -1,404 +0,0 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.9.1 Release Notes / January 7, 2011</H1>
<p>
Mesa 7.9.1 is a bug fix release which fixes bugs found since the 7.9 release.
</p>
<p>
Mesa 7.9.1 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
78422843ea875ad4eac35b9b8584032b MesaLib-7.9.1.tar.gz
07dc6cfb5928840b8b9df5bd1b3ae434 MesaLib-7.9.1.tar.bz2
c8eaea5b3c3d6dee784bd8c2db91c80f MesaLib-7.9.1.zip
ee9ecae4ca56fbb2d14dc15e3a0a7640 MesaGLUT-7.9.1.tar.gz
41fc477d524e7dc5c84da8ef22422bea MesaGLUT-7.9.1.tar.bz2
90b287229afdf19317aa989d19462e7a MesaGLUT-7.9.1.zip
</pre>
<h2>New features</h2>
<p>None.</p>
<h2>Bug fixes</h2>
<p>This list is likely incomplete.</p>
<ul>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=28800">Bug 28800</a> - [r300c, r300g] Texture corruption with World of Warcraft</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=29420">Bug 29420</a> - Amnesia / HPL2 RendererFeatTest - not rendering correctly</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=29946">Bug 29946</a> - [swrast] piglit valgrind glsl-array-bounds-04 fails</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=30261">Bug 30261</a> - [GLSL 1.20] allowing inconsistent invariant declaration between two vertex shaders</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=30632">Bug 30632</a> - [softpipe] state_tracker/st_manager.c:489: st_context_notify_invalid_framebuffer: Assertion `stfb &amp;&amp; stfb-&gt;iface == stfbi' failed.</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=30694">Bug 30694</a> - wincopy will crash on Gallium drivers when going to front buffer</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=30787">Bug 30787</a> - Invalid asm shader does not generate draw-time error when used with GLSL shader</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=30993">Bug 30993</a> - getFramebufferAttachmentParameteriv wrongly generates error</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31101">Bug 31101</a> - [glsl2] abort() in ir_validate::visit_enter(ir_assignment *ir)</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31193">Bug 31193</a> - [regression] aa43176e break water reflections</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31194">Bug 31194</a> - The mesa meta save/restore code doesn't ref the current GLSL program</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31371">Bug 31371</a> - glslparsertest: ir.cpp:358: ir_constant::ir_constant(const glsl_type*, const ir_constant_data*): Assertion `(type->base_type &gt;= 0) &amp;&amp; (type->base_type &lt;= 3)' failed.</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31439">Bug 31439</a> - Crash in glBufferSubData() with size == 0</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31495">Bug 31495</a> - [i965 gles2c bisected] OpenGL ES 2.0 conformance GL2Tests_GetBIFD_input.run regressed</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31514">Bug 31514</a> - isBuffer returns true for unbound buffers</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31560">Bug 31560</a> - [tdfx] tdfx_tex.c:702: error: const struct gl_color_table has no member named Format</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31617">Bug 31617</a> - Radeon/Compiz: 'failed to attach dri2 front buffer', error case not handled</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31648">Bug 31648</a> - [GLSL] array-struct-array gets assertion: `(size &gt;= 1) && (size &lt;= 4)' failed.</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31650">Bug 31650</a> - [GLSL] varying gl_TexCoord fails to be re-declared to different size in the second shader</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31673">Bug 31673</a> - GL_FRAGMENT_PRECISION_HIGH preprocessor macro undefined in GLSL ES</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31690">Bug 31690</a> - i915 shader compiler fails to flatten if in Aquarium webgl demo.</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31832">Bug 31832</a> - [i915] Bad renderbuffer format: 21</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31841">Bug 31841</a> - [drm:radeon_cs_ioctl] *ERROR* Invalid command stream !</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31894">Bug 31894</a> - Writing to gl_PointSize with GLES2 corrupts other varyings</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31909">Bug 31909</a> - [i965] brw_fs.cpp:1461: void fs_visitor::emit_bool_to_cond_code(ir_rvalue*): Assertion `expr-&gt;operands[i]-&gt;type-&gt;is_scalar()' failed.</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31934">Bug 31934</a> - [gallium] Mapping empty buffer object causes SIGSEGV</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31983">Bug 31983</a> - [i915 gles2] "if (expression with builtin/varying variables) discard" breaks linkage</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31985">Bug 31985</a> - [GLSL 1.20] initialized uniform array considered as "unsized"</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=31987">Bug 31987</a> - [gles2] if input a wrong pname(GL_NONE) to glGetBoolean, it will not case GL_INVALID_ENUM</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32035">Bug 32035</a> - [GLSL bisected] comparing unsized array gets segfault</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32070">Bug 32070</a> - llvmpipe renders stencil demo incorrectly</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32273">Bug 32273</a> - assertion fails when starting vdrift 2010 release with shaders enabled</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32287">Bug 32287</a> - [bisected GLSL] float-int failure</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32311">Bug 32311</a> - [965 bisected] Array look-ups broken on GM45</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32520">Bug 32520</a> - [gles2] glBlendFunc(GL_ZERO, GL_DST_COLOR) will result in GL_INVALID_ENUM</li>
<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=32825">Bug 32825</a> - egl_glx driver completely broken in 7.9 branch [fix in master]</li>
</ul>
<h2>Changes</h2>
<p>The full set of changes can be viewed by using the following GIT command:</p>
<pre>
git log mesa-7.9..mesa-7.9.1
</pre>
<p>Alex Deucher (5):
<ul>
<li>r100: revalidate after radeon_update_renderbuffers</li>
<li>r600c: add missing radeon_prepare_render() call on evergreen</li>
<li>r600c: properly align mipmaps to group size</li>
<li>gallium/egl: fix r300 vs r600 loading</li>
<li>r600c: fix some opcodes on evergreen</li>
</ul></p>
<p>Aras Pranckevicius (2):
<ul>
<li>glsl: fix crash in loop analysis when some controls can't be determined</li>
<li>glsl: fix matrix type check in ir_algebraic</li>
</ul></p>
<p>Brian Paul (27):
<ul>
<li>swrast: fix choose_depth_texture_level() to respect mipmap filtering state</li>
<li>st/mesa: replace assertion w/ conditional in framebuffer invalidation</li>
<li>egl/i965: include inline_wrapper_sw_helper.h</li>
<li>mesa: Add missing else in do_row_3D</li>
<li>mesa: add missing formats in _mesa_format_to_type_and_comps()</li>
<li>mesa: handle more pixel types in mipmap generation code</li>
<li>mesa: make glIsBuffer() return false for never bound buffers</li>
<li>mesa: fix glDeleteBuffers() regression</li>
<li>swrast: init alpha value to 1.0 in opt_sample_rgb_2d()</li>
<li>meta: Mask Stencil.Clear against stencilMax in _mesa_meta_Clear</li>
<li>st/mesa: fix mapping of zero-sized buffer objects</li>
<li>mesa: check for posix_memalign() errors</li>
<li>llvmpipe: fix broken stencil writemask</li>
<li>mesa: fix GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME query</li>
<li>mesa: return GL_FRAMEBUFFER_DEFAULT as FBO attachment type</li>
<li>mesa: make glGet*(GL_NONE) generate GL_INVALID_ENUM</li>
<li>mesa: test for cube map completeness in glGenerateMipmap()</li>
<li>tnl: Initialize gl_program_machine memory in run_vp.</li>
<li>tnl: a better way to initialize the gl_program_machine memory</li>
<li>mesa, st/mesa: disable GL_ARB_geometry_shader4</li>
<li>glsl: fix off by one in register index assertion</li>
<li>st/mesa: fix mipmap generation bug</li>
<li>glsl: new glsl_strtod() wrapper to fix decimal point interpretation</li>
<li>mesa: no-op glBufferSubData() on size==0</li>
<li>tdfx: s/Format/_BaseFormat/</li>
<li>st/mesa: fix renderbuffer pointer check in st_Clear()</li>
<li>mesa: Bump the number of bits in the register index.</li>
</ul></p>
<p>Chad Versace (5):
<ul>
<li>glsl: Fix lexer rule for ^=</li>
<li>glsl: Fix ast-to-hir for ARB_fragment_coord_conventions</li>
<li>glsl: Fix ir_expression::constant_expression_value()</li>
<li>glsl: Fix erroneous cast in ast_jump_statement::hir()</li>
<li>glsl: Fix linker bug in cross_validate_globals()</li>
</ul></p>
<p>Chia-I Wu (10):
<ul>
<li>targets/egl: Fix linking with libdrm.</li>
<li>st/vega: Fix version check in context creation.</li>
<li>st/egl: Do not finish a fence that is NULL.</li>
<li>egl: Fix a false negative check in _eglCheckMakeCurrent.</li>
<li>st/mesa: Unreference the sampler view in st_bind_surface.</li>
<li>egl_dri2: Fix __DRI_DRI2 version 1 support.</li>
<li>st/vega: Do not wait NULL fences.</li>
<li>mesa: Do not advertise GL_OES_texture_3D.</li>
<li>egl_glx: Fix borken driver.</li>
<li>egl: Check extensions.</li>
</ul></p>
<p>Daniel Lichtenberger (1):
<ul>
<li>radeon: fix potential segfault in renderbuffer update</li>
</ul></p>
<p>Daniel Vetter (1):
<ul>
<li>r200: revalidate after radeon_update_renderbuffers</li>
</ul></p>
<p>Dave Airlie (1):
<ul>
<li>r300g: fixup rs690 tiling stride alignment calculations.</li>
</ul></p>
<p>Eric Anholt (13):
<ul>
<li>intel: Allow CopyTexSubImage to InternalFormat 3/4 textures, like RGB/RGBA.</li>
<li>glsl: Free the loop state context when we free the loop state.</li>
<li>i965: Allow OPCODE_SWZ to put immediates in the first arg.</li>
<li>i965: Add support for rendering to SARGB8 FBOs.</li>
<li>glsl: Add a helper constructor for expressions that works out result type.</li>
<li>glsl: Fix structure and array comparisions.</li>
<li>glsl: Quiet unreachable no-return-from-function warning.</li>
<li>glsl: Mark the array access for whole-array comparisons.</li>
<li>glsl: Fix flipped return of has_value() for array constants.</li>
<li>mesa: Add getters for the rest of the supported draw buffers.</li>
<li>mesa: Add getters for ARB_copy_buffer's attachment points.</li>
<li>i965: Correct the dp_read message descriptor setup on g4x.</li>
<li>glsl: Correct the marking of InputsRead/OutputsWritten on in/out matrices.</li>
</ul></p>
<p>Fabian Bieler (1):
<ul>
<li>glsl: fix lowering conditional returns in subroutines</li>
</ul></p>
<p>Francisco Jerez (3):
<ul>
<li>meta: Don't leak alpha function/reference value changes.</li>
<li>meta: Fix incorrect rendering of the bitmap alpha component.</li>
<li>meta: Don't try to disable cube maps if the driver doesn't expose the extension.</li>
</ul></p>
<p>Henri Verbeet (2):
<ul>
<li>r600: Evergreen has two extra frac_bits for the sampler LOD state.</li>
<li>st/mesa: Handle wrapped depth buffers in st_copy_texsubimage().</li>
</ul></p>
<p>Ian Romanick (33):
<ul>
<li>Add 7.9 md5sums</li>
<li>docs: Import 7.8.x release notes from 7.8 branch.</li>
<li>docs: download.html does not need to be updated for each release</li>
<li>docs: Update mailing lines from sf.net to freedesktop.org</li>
<li>docs: added news item for 7.9 release</li>
<li>mesa: Validate assembly shaders when GLSL shaders are used</li>
<li>linker: Reject shaders that have unresolved function calls</li>
<li>mesa: Refactor validation of shader targets</li>
<li>glsl: Slightly change the semantic of _LinkedShaders</li>
<li>linker: Improve handling of unread/unwritten shader inputs/outputs</li>
<li>glsl: Commit lexer files changed by previous cherry picking</li>
<li>mesa: Make metaops use program refcounts instead of names.</li>
<li>glsl: Fix incorrect gl_type of sampler2DArray and sampler1DArrayShadow</li>
<li>mesa: Allow query of MAX_SAMPLES with EXT_framebuffer_multisample</li>
<li>glsl: better handling of linker failures</li>
<li>mesa: Fix glGet of ES2's GL_MAX_*_VECTORS properties.</li>
<li>i915: Disallow alpha, red, RG, and sRGB as render targets</li>
<li>glsl/linker: Free any IR discarded by optimization passes.</li>
<li>glsl: Add an optimization pass to simplify discards.</li>
<li>glsl: Add a lowering pass to move discards out of if-statements.</li>
<li>i915: Correctly generate unconditional KIL instructions</li>
<li>glsl: Add unary ir_expression constructor</li>
<li>glsl: Ensure that equality comparisons don't return a NULL IR tree</li>
<li>glcpp: Commit changes in generated files cause by previous commit</li>
<li>glsl: Inherrit type of declared variable from initializer</li>
<li>glsl: Inherrit type of declared variable from initializer after processing assignment</li>
<li>linker: Ensure that unsized arrays have a size after linking</li>
<li>linker: Fix regressions caused by previous commit</li>
<li>linker: Allow built-in arrays to have different sizes between shader stages</li>
<li>ir_to_mesa: Don't generate swizzles for record derefs of non-scalar/vectors</li>
<li>Refresh autogenerated file builtin_function.cpp.</li>
<li>docs: Initial set of release notes for 7.9.1</li>
<li>mesa: set version string to 7.9.1</li>
</ul></p>
<p>Julien Cristau (1):
<ul>
<li>Makefile: don't include the same files twice in the tarball</li>
</ul></p>
<p>Kenneth Graunke (19):
<ul>
<li>glcpp: Return NEWLINE token for newlines inside multi-line comments.</li>
<li>generate_builtins.py: Output large strings as arrays of characters.</li>
<li>glsl: Fix constant component count in vector constructor emitting.</li>
<li>ir_dead_functions: Actually free dead functions and signatures.</li>
<li>glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version &gt;= 1.30.</li>
<li>glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.</li>
<li>glsl: Fix constant expression handling for &lt, &gt;, &lt=, &gt;= on vectors.</li>
<li>glsl: Use do_common_optimization in the standalone compiler.</li>
<li>glsl: Don't inline function prototypes.</li>
<li>glsl: Add a virtual as_discard() method.</li>
<li>glsl: Remove "discard" support from lower_jumps.</li>
<li>glsl: Refactor get_num_operands.</li>
<li>glcpp: Don't emit SPACE tokens in conditional_tokens production.</li>
<li>glsl: Clean up code by adding a new is_break() function.</li>
<li>glsl: Consider the "else" branch when looking for loop breaks.</li>
<li>Remove OES_compressed_paletted_texture from the ES2 extension list.</li>
<li>glsl/builtins: Compute the correct value for smoothstep(vec, vec, vec).</li>
<li>Fix build on systems where "python" is python 3.</li>
<li>i965: Internally enable GL_NV_blend_square on ES2.</li>
</ul></p>
<p>Kristian Høgsberg (1):
<ul>
<li>i965: Don't write mrf assignment for pointsize output</li>
</ul></p>
<p>Luca Barbieri (1):
<ul>
<li>glsl: Unroll loops with conditional breaks anywhere (not just the end)</li>
</ul></p>
<p>Marek Olšák (17):
<ul>
<li>r300g: fix microtiling for 16-bits-per-channel formats</li>
<li>r300g: fix texture border for 16-bits-per-channel formats</li>
<li>r300g: add a default channel ordering of texture border for unhandled formats</li>
<li>r300g: fix texture border color for all texture formats</li>
<li>r300g: fix rendering with no vertex elements</li>
<li>r300/compiler: fix rc_rewrite_depth_out for it to work with any instruction</li>
<li>r300g: fix texture border color once again</li>
<li>r300g: fix texture swizzling with compressed textures on r400-r500</li>
<li>r300g: disable ARB_texture_swizzle if S3TC is enabled on r3xx-only</li>
<li>mesa, st/mesa: fix gl_FragCoord with FBOs in Gallium</li>
<li>st/mesa: initialize key in st_vp_varient</li>
<li>r300/compiler: fix swizzle lowering with a presubtract source operand</li>
<li>r300g: fix rendering with a vertex attrib having a zero stride</li>
<li>ir_to_mesa: Add support for conditional discards.</li>
<li>r300g: finally fix the texture corruption on r3xx-r4xx</li>
<li>mesa: fix texel store functions for some float formats</li>
<li>r300/compiler: disable the rename_regs pass for loops</li>
</ul></p>
<p>Mario Kleiner (1):
<ul>
<li>mesa/r300classic: Fix dri2Invalidate/radeon_prepare_render for page flipping.</li>
</ul></p>
<p>Peter Clifton (1):
<ul>
<li>intel: Fix emit_linear_blit to use DWORD aligned width blits</li>
</ul></p>
<p>Robert Hooker (2):
<ul>
<li>intel: Add a new B43 pci id.</li>
<li>egl_dri2: Add missing intel chip ids.</li>
</ul></p>
<p>Roland Scheidegger (1):
<ul>
<li>r200: fix r200 large points</li>
</ul></p>
<p>Thomas Hellstrom (17):
<ul>
<li>st/xorg: Don't try to use option values before processing options</li>
<li>xorg/vmwgfx: Make vmwarectrl work also on 64-bit servers</li>
<li>st/xorg: Add a customizer option to get rid of annoying cursor update flicker</li>
<li>xorg/vmwgfx: Don't hide HW cursors when updating them</li>
<li>st/xorg: Don't try to remove invalid fbs</li>
<li>st/xorg: Fix typo</li>
<li>st/xorg, xorg/vmwgfx: Be a bit more frendly towards cross-compiling environments</li>
<li>st/xorg: Fix compilation errors for Xservers compiled without Composite</li>
<li>st/xorg: Don't use deprecated x*alloc / xfree functions</li>
<li>xorg/vmwgfx: Don't use deprecated x*alloc / xfree functions</li>
<li>st/xorg: Fix compilation for Xservers &gt;= 1.10</li>
<li>mesa: Make sure we have the talloc cflags when using the talloc headers</li>
<li>egl: Add an include for size_t</li>
<li>mesa: Add talloc includes for gles</li>
<li>st/egl: Fix build for include files in nonstandard places</li>
<li>svga/drm: Optionally resolve calls to powf during link-time</li>
<li>gallium/targets: Trivial crosscompiling fix</li>
</ul></p>
<p>Tom Stellard (7):
<ul>
<li>r300/compiler: Make sure presubtract sources use supported swizzles</li>
<li>r300/compiler: Fix register allocator's handling of loops</li>
<li>r300/compiler: Fix instruction scheduling within IF blocks</li>
<li>r300/compiler: Use zero as the register index for unused sources</li>
<li>r300/compiler: Ignore alpha dest register when replicating the result</li>
<li>r300/compiler: Use correct swizzles for all presubtract sources</li>
<li>r300/compiler: Don't allow presubtract sources to be remapped twice</li>
</ul></p>
<p>Vinson Lee (1):
<ul>
<li>glsl: Fix 'control reaches end of non-void function' warning.</li>
</ul></p>
<p>richard (1):
<ul>
<li>r600c : inline vertex format is not updated in an app, switch to use vfetch constants. For the 7.9 and 7.10 branches as well.</li>
</ul></p>
</body>
</html>

View File

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

View File

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

View File

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

96
src/Android.mk Normal file
View File

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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

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

View File

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

View File

@@ -65,7 +65,19 @@ static void
vs_llvm_delete( struct draw_vertex_shader *dvs )
{
struct llvm_vertex_shader *shader = llvm_vertex_shader(dvs);
struct pipe_fence_handle *fence = NULL;
struct draw_llvm_variant_list_item *li;
struct pipe_context *pipe = dvs->draw->pipe;
/*
* XXX: This might be not neccessary at all.
*/
pipe->flush(pipe, 0, &fence);
if (fence) {
pipe->screen->fence_finish(pipe->screen, fence, 0);
pipe->screen->fence_reference(pipe->screen, &fence, NULL);
}
li = first_elem(&shader->variants);
while(!at_end(&shader->variants, li)) {

View File

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

View File

@@ -187,6 +187,16 @@ static INLINE double log2( double x )
#endif /* _MSC_VER */
#ifdef PIPE_OS_ANDROID
static INLINE
double log2(double d)
{
return log(d) / M_LN2;
}
#endif

View File

@@ -0,0 +1 @@
include $(call all-subdir-makefiles)

View File

@@ -0,0 +1,48 @@
ifeq ($(strip $(MESA_BUILD_I915G)),true)
LOCAL_PATH := $(call my-dir)
# from Makefile
C_SOURCES = \
i915_blit.c \
i915_clear.c \
i915_flush.c \
i915_context.c \
i915_debug.c \
i915_debug_fp.c \
i915_state.c \
i915_state_immediate.c \
i915_state_dynamic.c \
i915_state_derived.c \
i915_state_emit.c \
i915_state_fpc.c \
i915_state_sampler.c \
i915_state_static.c \
i915_screen.c \
i915_prim_emit.c \
i915_prim_vbuf.c \
i915_resource.c \
i915_resource_texture.c \
i915_resource_buffer.c \
i915_fpc_emit.c \
i915_fpc_translate.c \
i915_surface.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(C_SOURCES)
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary
LOCAL_MODULE := libmesa_pipe_i915
include $(BUILD_STATIC_LIBRARY)
endif # MESA_BUILD_I915G

View File

@@ -55,7 +55,7 @@ i915_buffer_destroy(struct pipe_screen *screen,
{
struct i915_buffer *buffer = i915_buffer(resource);
if (buffer->free_on_destroy)
align_free(buffer->data);
FREE(buffer->data);
FREE(buffer);
}

View File

@@ -74,7 +74,6 @@ lp_scene_create( struct pipe_context *pipe )
void
lp_scene_destroy(struct lp_scene *scene)
{
lp_fence_reference(&scene->fence, NULL);
pipe_mutex_destroy(scene->mutex);
assert(scene->data.head->next == NULL);
FREE(scene->data.head);

View File

@@ -996,8 +996,6 @@ lp_setup_destroy( struct lp_setup_context *setup )
lp_scene_destroy(scene);
}
lp_fence_reference(&setup->last_fence, NULL);
FREE( setup );
}

View File

@@ -35,9 +35,7 @@
#include "r300_screen_buffer.h"
#include "r300_winsys.h"
#ifdef HAVE_LLVM
#include "gallivm/lp_bld_init.h"
#endif
#include <inttypes.h>
static void r300_update_num_contexts(struct r300_screen *r300screen,
int diff)
@@ -105,14 +103,9 @@ static void r300_destroy_context(struct pipe_context* context)
if (r300->blitter)
util_blitter_destroy(r300->blitter);
if (r300->draw) {
if (r300->draw)
draw_destroy(r300->draw);
#ifdef HAVE_LLVM
gallivm_destroy(r300->gallivm);
#endif
}
if (r300->upload_vb)
u_upload_destroy(r300->upload_vb);
if (r300->upload_ib)
@@ -431,12 +424,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
if (!r300screen->caps.has_tcl) {
/* Create a Draw. This is used for SW TCL. */
#ifdef HAVE_LLVM
r300->gallivm = gallivm_create();
r300->draw = draw_create_gallivm(&r300->context, r300->gallivm);
#else
r300->draw = draw_create(&r300->context);
#endif
if (r300->draw == NULL)
goto fail;
/* Enable our renderer. */

View File

@@ -459,7 +459,6 @@ struct r300_context {
struct r300_screen *screen;
/* Draw module. Used mostly for SW TCL. */
struct gallivm_state *gallivm;
struct draw_context* draw;
/* Vertex buffer for SW TCL. */
struct pipe_resource* vbo;

View File

@@ -34,10 +34,6 @@
#include "draw/draw_context.h"
#ifdef HAVE_LLVM
#include "gallivm/lp_bld_init.h"
#endif
/* Return the identifier behind whom the brave coders responsible for this
* amalgamation of code, sweat, and duct tape, routinely obscure their names.
*
@@ -488,9 +484,5 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws)
util_format_s3tc_init();
#ifdef HAVE_LLVM
lp_build_init();
#endif
return &r300screen->screen;
}

View File

@@ -119,7 +119,6 @@ int r300_upload_user_buffers(struct r300_context *r300)
vb->buffer = upload_buffer;
vb->buffer_offset = upload_offset;
r300->validate_buffers = TRUE;
r300->aos_dirty = TRUE;
}
}
return ret;

View File

@@ -1298,27 +1298,29 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
}
for (i = 0; i < count; i++) {
pipe_sampler_view_reference(
(struct pipe_sampler_view**)&state->sampler_views[i],
views[i]);
if (&state->sampler_views[i]->base != views[i]) {
pipe_sampler_view_reference(
(struct pipe_sampler_view**)&state->sampler_views[i],
views[i]);
if (!views[i]) {
continue;
}
if (!views[i]) {
continue;
}
/* A new sampler view (= texture)... */
dirty_tex = TRUE;
/* A new sampler view (= texture)... */
dirty_tex = TRUE;
/* Set the texrect factor in the fragment shader.
/* Set the texrect factor in the fragment shader.
* Needed for RECT and NPOT fallback. */
texture = r300_texture(views[i]->texture);
if (texture->desc.is_npot) {
r300_mark_atom_dirty(r300, &r300->fs_rc_constant_state);
}
texture = r300_texture(views[i]->texture);
if (texture->desc.is_npot) {
r300_mark_atom_dirty(r300, &r300->fs_rc_constant_state);
}
state->sampler_views[i]->texcache_region =
state->sampler_views[i]->texcache_region =
r300_assign_texture_cache_region(view_index, real_num_views);
view_index++;
view_index++;
}
}
for (i = count; i < tex_units; i++) {
@@ -1494,14 +1496,14 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
any_user_buffer = TRUE;
}
/* The stride of zero means we will be fetching only the first
* vertex, so don't care about max_index. */
if (!vbo->stride)
continue;
if (vbo->max_index == ~0) {
vbo->max_index =
(vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
/* if no VBO stride then only one vertex value so max index is 1 */
/* should think about converting to VS constants like svga does */
if (!vbo->stride)
vbo->max_index = 1;
else
vbo->max_index =
(vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
}
max_index = MIN2(vbo->max_index, max_index);

View File

@@ -899,7 +899,7 @@ struct pipe_surface* r300_create_surface(struct pipe_context * ctx,
tex->desc.b.b.nr_samples,
tex->desc.microtile,
tex->desc.macrotile[level],
DIM_HEIGHT, 0);
DIM_HEIGHT);
surface->cbzb_height = align((surface->base.height + 1) / 2,
tile_height);

View File

@@ -34,7 +34,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
unsigned num_samples,
enum r300_buffer_tiling microtile,
enum r300_buffer_tiling macrotile,
enum r300_dim dim, boolean is_rs690)
enum r300_dim dim)
{
static const unsigned table[2][5][3][2] =
{
@@ -57,7 +57,6 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
{{ 16, 8}, { 0, 0}, { 0, 0}} /* 128 bits per pixel */
}
};
static const unsigned aa_block[2] = {4, 8};
unsigned tile = 0;
unsigned pixsize = util_format_get_blocksize(format);
@@ -75,14 +74,6 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
} else {
/* Standard alignment. */
tile = table[macrotile][util_logbase2(pixsize)][microtile][dim];
if (macrotile == 0 && is_rs690 && dim == DIM_WIDTH) {
int align;
int h_tile;
h_tile = table[macrotile][util_logbase2(pixsize)][microtile][DIM_HEIGHT];
align = 64 / (pixsize * h_tile);
if (tile < align)
tile = align;
}
}
assert(tile);
@@ -98,7 +89,7 @@ static boolean r300_texture_macro_switch(struct r300_texture_desc *desc,
unsigned tile, texdim;
tile = r300_get_pixel_alignment(desc->b.b.format, desc->b.b.nr_samples,
desc->microtile, R300_BUFFER_TILED, dim, 0);
desc->microtile, R300_BUFFER_TILED, dim);
if (dim == DIM_WIDTH) {
texdim = u_minify(desc->width0, level);
} else {
@@ -122,9 +113,6 @@ static unsigned r300_texture_get_stride(struct r300_screen *screen,
unsigned level)
{
unsigned tile_width, width, stride;
boolean is_rs690 = (screen->caps.family == CHIP_FAMILY_RS600 ||
screen->caps.family == CHIP_FAMILY_RS690 ||
screen->caps.family == CHIP_FAMILY_RS740);
if (desc->stride_in_bytes_override)
return desc->stride_in_bytes_override;
@@ -143,14 +131,38 @@ static unsigned r300_texture_get_stride(struct r300_screen *screen,
desc->b.b.nr_samples,
desc->microtile,
desc->macrotile[level],
DIM_WIDTH, is_rs690);
DIM_WIDTH);
width = align(width, tile_width);
stride = util_format_get_stride(desc->b.b.format, width);
/* Some IGPs need a minimum stride of 64 bytes, hmm... */
if (!desc->macrotile[level] &&
(screen->caps.family == CHIP_FAMILY_RS600 ||
screen->caps.family == CHIP_FAMILY_RS690 ||
screen->caps.family == CHIP_FAMILY_RS740)) {
unsigned min_stride;
if (desc->microtile) {
unsigned tile_height =
r300_get_pixel_alignment(desc->b.b.format,
desc->b.b.nr_samples,
desc->microtile,
desc->macrotile[level],
DIM_HEIGHT);
min_stride = 64 / tile_height;
} else {
min_stride = 64;
}
return stride < min_stride ? min_stride : stride;
}
/* The alignment to 32 bytes is sort of implied by the layout... */
return stride;
} else {
return align(util_format_get_stride(desc->b.b.format, width), is_rs690 ? 64 : 32);
return align(util_format_get_stride(desc->b.b.format, width), 32);
}
}
@@ -167,7 +179,7 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture_desc *desc,
desc->b.b.nr_samples,
desc->microtile,
desc->macrotile[level],
DIM_HEIGHT, 0);
DIM_HEIGHT);
height = align(height, tile_height);
/* This is needed for the kernel checker, unfortunately. */

View File

@@ -41,7 +41,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
unsigned num_samples,
enum r300_buffer_tiling microtile,
enum r300_buffer_tiling macrotile,
enum r300_dim dim, boolean is_rs690);
enum r300_dim dim);
boolean r300_texture_desc_init(struct r300_screen *rscreen,
struct r300_texture_desc *desc,

View File

@@ -21,7 +21,6 @@ C_SOURCES = \
evergreen_state.c \
eg_asm.c \
r600_translate.c \
r600_state_common.c \
r600_upload.c
r600_state_common.c
include ../../Makefile.template

View File

@@ -28,7 +28,6 @@ r600 = env.ConvenienceLibrary(
'r600_state_common.c',
'r600_texture.c',
'r600_translate.c',
'r600_upload.c',
'r700_asm.c',
'evergreen_state.c',
'eg_asm.c',

View File

@@ -1069,76 +1069,12 @@ void evergreen_init_config(struct r600_pipe_context *rctx)
num_hs_stack_entries = 42;
num_ls_stack_entries = 42;
break;
case CHIP_BARTS:
num_ps_gprs = 93;
num_vs_gprs = 46;
num_temp_gprs = 4;
num_gs_gprs = 31;
num_es_gprs = 31;
num_hs_gprs = 23;
num_ls_gprs = 23;
num_ps_threads = 128;
num_vs_threads = 20;
num_gs_threads = 20;
num_es_threads = 20;
num_hs_threads = 20;
num_ls_threads = 20;
num_ps_stack_entries = 85;
num_vs_stack_entries = 85;
num_gs_stack_entries = 85;
num_es_stack_entries = 85;
num_hs_stack_entries = 85;
num_ls_stack_entries = 85;
break;
case CHIP_TURKS:
num_ps_gprs = 93;
num_vs_gprs = 46;
num_temp_gprs = 4;
num_gs_gprs = 31;
num_es_gprs = 31;
num_hs_gprs = 23;
num_ls_gprs = 23;
num_ps_threads = 128;
num_vs_threads = 20;
num_gs_threads = 20;
num_es_threads = 20;
num_hs_threads = 20;
num_ls_threads = 20;
num_ps_stack_entries = 42;
num_vs_stack_entries = 42;
num_gs_stack_entries = 42;
num_es_stack_entries = 42;
num_hs_stack_entries = 42;
num_ls_stack_entries = 42;
break;
case CHIP_CAICOS:
num_ps_gprs = 93;
num_vs_gprs = 46;
num_temp_gprs = 4;
num_gs_gprs = 31;
num_es_gprs = 31;
num_hs_gprs = 23;
num_ls_gprs = 23;
num_ps_threads = 128;
num_vs_threads = 10;
num_gs_threads = 10;
num_es_threads = 10;
num_hs_threads = 10;
num_ls_threads = 10;
num_ps_stack_entries = 42;
num_vs_stack_entries = 42;
num_gs_stack_entries = 42;
num_es_stack_entries = 42;
num_hs_stack_entries = 42;
num_ls_stack_entries = 42;
break;
}
tmp = 0x00000000;
switch (family) {
case CHIP_CEDAR:
case CHIP_PALM:
case CHIP_CAICOS:
break;
default:
tmp |= S_008C00_VC_ENABLE(1);
@@ -1359,6 +1295,11 @@ void evergreen_vertex_buffer_update(struct r600_pipe_context *rctx)
if (rctx->vertex_elements == NULL || !rctx->nvertex_buffer)
return;
/* delete previous translated vertex elements */
if (rctx->tran.new_velems) {
r600_end_vertex_translate(rctx);
}
if (rctx->vertex_elements->incompatible_layout) {
/* translate rebind new vertex elements so
* return once translated
@@ -1391,21 +1332,21 @@ void evergreen_vertex_buffer_update(struct r600_pipe_context *rctx)
vbuffer_index = rctx->vertex_elements->elements[i].vertex_buffer_index;
vertex_buffer = &rctx->vertex_buffer[vbuffer_index];
rbuffer = (struct r600_resource*)vertex_buffer->buffer;
offset = rctx->vertex_elements->vbuffer_offset[i];
offset = rctx->vertex_elements->vbuffer_offset[i] +
vertex_buffer->buffer_offset +
r600_bo_offset(rbuffer->bo);
} else {
/* bind vertex buffer once */
vertex_buffer = &rctx->vertex_buffer[i];
rbuffer = (struct r600_resource*)vertex_buffer->buffer;
offset = 0;
offset = vertex_buffer->buffer_offset +
r600_bo_offset(rbuffer->bo);
}
if (vertex_buffer == NULL || rbuffer == NULL)
continue;
offset += vertex_buffer->buffer_offset + r600_bo_offset(rbuffer->bo);
r600_pipe_state_add_reg(rstate, R_030000_RESOURCE0_WORD0,
offset, 0xFFFFFFFF, rbuffer->bo);
r600_pipe_state_add_reg(rstate, R_030004_RESOURCE0_WORD1,
rbuffer->bo_size - offset - 1, 0xFFFFFFFF, NULL);
rbuffer->size - offset - 1, 0xFFFFFFFF, NULL);
r600_pipe_state_add_reg(rstate, R_030008_RESOURCE0_WORD2,
S_030008_STRIDE(vertex_buffer->stride),
0xFFFFFFFF, NULL);

View File

@@ -92,9 +92,6 @@ enum radeon_family {
CHIP_CYPRESS,
CHIP_HEMLOCK,
CHIP_PALM,
CHIP_BARTS,
CHIP_TURKS,
CHIP_CAICOS,
CHIP_LAST,
};

View File

@@ -155,9 +155,6 @@ int r600_bc_init(struct r600_bc *bc, enum radeon_family family)
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
case CHIP_PALM:
case CHIP_BARTS:
case CHIP_TURKS:
case CHIP_CAICOS:
bc->chiprev = CHIPREV_EVERGREEN;
break;
default:
@@ -473,22 +470,7 @@ int r600_bc_add_alu_type(struct r600_bc *bc, const struct r600_bc_alu *alu, int
bc->cf_last->ndw += 2;
bc->ndw += 2;
/* The following configuration provides 64 128-bit constants.
* Each cacheline holds 16 128-bit constants and each
* kcache can lock 2 cachelines and there are 2 kcaches per
* ALU clause for a max of 64 constants.
* For supporting more than 64 constants, the code needs
* to be broken down into multiple ALU clauses.
*/
/* select the constant buffer (0-15) for each kcache */
bc->cf_last->kcache0_bank = 0;
bc->cf_last->kcache1_bank = 0;
/* lock 2 cachelines per kcache; 4 total */
bc->cf_last->kcache0_mode = V_SQ_CF_KCACHE_LOCK_2;
bc->cf_last->kcache1_mode = V_SQ_CF_KCACHE_LOCK_2;
/* set the cacheline offsets for each kcache */
bc->cf_last->kcache0_addr = 0;
bc->cf_last->kcache1_addr = 2;
bc->cf_last->kcache0_mode = 2;
/* process cur ALU instructions for bank swizzle */
if (alu->last) {

View File

@@ -29,6 +29,7 @@
#include <util/u_math.h>
#include <util/u_inlines.h>
#include <util/u_memory.h>
#include <util/u_upload_mgr.h>
#include "state_tracker/drm_driver.h"
#include <xf86drm.h>
#include "radeon_drm.h"
@@ -52,13 +53,12 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
rbuffer->magic = R600_BUFFER_MAGIC;
rbuffer->user_buffer = NULL;
rbuffer->num_ranges = 0;
rbuffer->r.base.b = *templ;
pipe_reference_init(&rbuffer->r.base.b.reference, 1);
rbuffer->r.base.b.screen = screen;
rbuffer->r.base.vtbl = &r600_buffer_vtbl;
rbuffer->r.size = rbuffer->r.base.b.width0;
rbuffer->r.bo_size = rbuffer->r.size;
rbuffer->uploaded = FALSE;
bo = r600_bo((struct radeon*)screen->winsys, rbuffer->r.base.b.width0, alignment, rbuffer->r.base.b.bind, rbuffer->r.base.b.usage);
if (bo == NULL) {
FREE(rbuffer);
@@ -91,10 +91,9 @@ struct pipe_resource *r600_user_buffer_create(struct pipe_screen *screen,
rbuffer->r.base.b.depth0 = 1;
rbuffer->r.base.b.array_size = 1;
rbuffer->r.base.b.flags = 0;
rbuffer->num_ranges = 0;
rbuffer->r.bo = NULL;
rbuffer->r.bo_size = 0;
rbuffer->user_buffer = ptr;
rbuffer->uploaded = FALSE;
return &rbuffer->r.base.b;
}
@@ -106,7 +105,6 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
if (rbuffer->r.bo) {
r600_bo_reference((struct radeon*)screen->winsys, &rbuffer->r.bo, NULL);
}
rbuffer->r.bo = NULL;
FREE(rbuffer);
}
@@ -116,10 +114,29 @@ static void *r600_buffer_transfer_map(struct pipe_context *pipe,
struct r600_resource_buffer *rbuffer = r600_buffer(transfer->resource);
int write = 0;
uint8_t *data;
int i;
boolean flush = FALSE;
if (rbuffer->user_buffer)
return (uint8_t*)rbuffer->user_buffer + transfer->box.x;
if (transfer->usage & PIPE_TRANSFER_DISCARD) {
for (i = 0; i < rbuffer->num_ranges; i++) {
if ((transfer->box.x >= rbuffer->ranges[i].start) &&
(transfer->box.x < rbuffer->ranges[i].end))
flush = TRUE;
if (flush) {
r600_bo_reference((struct radeon*)pipe->winsys, &rbuffer->r.bo, NULL);
rbuffer->num_ranges = 0;
rbuffer->r.bo = r600_bo((struct radeon*)pipe->winsys,
rbuffer->r.base.b.width0, 0,
rbuffer->r.base.b.bind,
rbuffer->r.base.b.usage);
break;
}
}
}
if (transfer->usage & PIPE_TRANSFER_DONTBLOCK) {
/* FIXME */
}
@@ -138,17 +155,36 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
{
struct r600_resource_buffer *rbuffer = r600_buffer(transfer->resource);
if (rbuffer->user_buffer)
return;
if (rbuffer->r.bo)
r600_bo_unmap((struct radeon*)pipe->winsys, rbuffer->r.bo);
}
static void r600_buffer_transfer_flush_region(struct pipe_context *pipe,
struct pipe_transfer *transfer,
const struct pipe_box *box)
struct pipe_transfer *transfer,
const struct pipe_box *box)
{
struct r600_resource_buffer *rbuffer = r600_buffer(transfer->resource);
unsigned i;
unsigned offset = transfer->box.x + box->x;
unsigned length = box->width;
assert(box->x + box->width <= transfer->box.width);
if (rbuffer->user_buffer)
return;
/* mark the range as used */
for(i = 0; i < rbuffer->num_ranges; ++i) {
if(offset <= rbuffer->ranges[i].end && rbuffer->ranges[i].start <= (offset+box->width)) {
rbuffer->ranges[i].start = MIN2(rbuffer->ranges[i].start, offset);
rbuffer->ranges[i].end = MAX2(rbuffer->ranges[i].end, (offset+length));
return;
}
}
rbuffer->ranges[rbuffer->num_ranges].start = offset;
rbuffer->ranges[rbuffer->num_ranges].end = offset+length;
rbuffer->num_ranges++;
}
unsigned r600_buffer_is_referenced_by_cs(struct pipe_context *context,
@@ -200,25 +236,29 @@ struct u_resource_vtbl r600_buffer_vtbl =
int r600_upload_index_buffer(struct r600_pipe_context *rctx, struct r600_drawl *draw)
{
if (r600_buffer_is_user_buffer(draw->index_buffer)) {
struct r600_resource_buffer *rbuffer = r600_buffer(draw->index_buffer);
unsigned upload_offset;
int ret = 0;
struct pipe_resource *upload_buffer = NULL;
unsigned index_offset = draw->index_buffer_offset;
int ret = 0;
ret = r600_upload_buffer(rctx->rupload_vb,
draw->index_buffer_offset,
draw->count * draw->index_size,
rbuffer,
&upload_offset,
&rbuffer->r.bo_size,
&rbuffer->r.bo);
if (ret)
return ret;
rbuffer->uploaded = TRUE;
draw->index_buffer_offset = upload_offset;
if (r600_buffer_is_user_buffer(draw->index_buffer)) {
ret = u_upload_buffer(rctx->upload_ib,
index_offset,
draw->count * draw->index_size,
draw->index_buffer,
&index_offset,
&upload_buffer);
if (ret) {
goto done;
}
draw->index_buffer_offset = index_offset;
/* Transfer ownership. */
pipe_resource_reference(&draw->index_buffer, upload_buffer);
pipe_resource_reference(&upload_buffer, NULL);
}
return 0;
done:
return ret;
}
int r600_upload_user_buffers(struct r600_pipe_context *rctx)
@@ -230,21 +270,23 @@ int r600_upload_user_buffers(struct r600_pipe_context *rctx)
nr = rctx->nvertex_buffer;
for (i = 0; i < nr; i++) {
// struct pipe_vertex_buffer *vb = &rctx->vertex_buffer[rctx->vertex_elements->elements[i].vertex_buffer_index];
struct pipe_vertex_buffer *vb = &rctx->vertex_buffer[i];
if (r600_buffer_is_user_buffer(vb->buffer)) {
struct r600_resource_buffer *rbuffer = r600_buffer(vb->buffer);
struct pipe_resource *upload_buffer = NULL;
unsigned offset = 0; /*vb->buffer_offset * 4;*/
unsigned size = vb->buffer->width0;
unsigned upload_offset;
ret = r600_upload_buffer(rctx->rupload_vb,
0, vb->buffer->width0,
rbuffer,
&upload_offset,
&rbuffer->r.bo_size,
&rbuffer->r.bo);
ret = u_upload_buffer(rctx->upload_vb,
offset, size,
vb->buffer,
&upload_offset, &upload_buffer);
if (ret)
return ret;
rbuffer->uploaded = TRUE;
pipe_resource_reference(&vb->buffer, NULL);
vb->buffer = upload_buffer;
vb->buffer_offset = upload_offset;
}
}

View File

@@ -35,6 +35,7 @@
#include <util/u_pack_color.h>
#include <util/u_memory.h>
#include <util/u_inlines.h>
#include <util/u_upload_mgr.h>
#include <pipebuffer/pb_buffer.h>
#include "r600.h"
#include "r600d.h"
@@ -58,6 +59,9 @@ static void r600_flush(struct pipe_context *ctx, unsigned flags,
if (!rctx->ctx.pm4_cdwords)
return;
u_upload_flush(rctx->upload_vb);
u_upload_flush(rctx->upload_ib);
#if 0
sprintf(dname, "gallium-%08d.bof", dc);
if (dc < 20) {
@@ -67,8 +71,6 @@ static void r600_flush(struct pipe_context *ctx, unsigned flags,
dc++;
#endif
r600_context_flush(&rctx->ctx);
r600_upload_flush(rctx->rupload_vb);
}
static void r600_destroy_context(struct pipe_context *context)
@@ -87,7 +89,8 @@ static void r600_destroy_context(struct pipe_context *context)
free(rctx->states[i]);
}
r600_upload_destroy(rctx->rupload_vb);
u_upload_destroy(rctx->upload_vb);
u_upload_destroy(rctx->upload_ib);
if (rctx->tran.translate_cache)
translate_cache_destroy(rctx->tran.translate_cache);
@@ -148,9 +151,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
case CHIP_PALM:
case CHIP_BARTS:
case CHIP_TURKS:
case CHIP_CAICOS:
rctx->context.draw_vbo = evergreen_draw;
evergreen_init_state_functions(rctx);
if (evergreen_context_init(&rctx->ctx, rctx->radeon)) {
@@ -165,8 +165,16 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
return NULL;
}
rctx->rupload_vb = r600_upload_create(rctx, 128 * 1024, 16);
if (rctx->rupload_vb == NULL) {
rctx->upload_ib = u_upload_create(&rctx->context, 32 * 1024, 16,
PIPE_BIND_INDEX_BUFFER);
if (rctx->upload_ib == NULL) {
r600_destroy_context(&rctx->context);
return NULL;
}
rctx->upload_vb = u_upload_create(&rctx->context, 128 * 1024, 16,
PIPE_BIND_VERTEX_BUFFER);
if (rctx->upload_vb == NULL) {
r600_destroy_context(&rctx->context);
return NULL;
}
@@ -235,9 +243,6 @@ static const char *r600_get_family_name(enum radeon_family family)
case CHIP_CYPRESS: return "AMD CYPRESS";
case CHIP_HEMLOCK: return "AMD HEMLOCK";
case CHIP_PALM: return "AMD PALM";
case CHIP_BARTS: return "AMD BARTS";
case CHIP_TURKS: return "AMD TURKS";
case CHIP_CAICOS: return "AMD CAICOS";
default: return "AMD unknown";
}
}

View File

@@ -111,7 +111,7 @@ struct r600_pipe_shader {
#define NUM_TEX_UNITS 16
struct r600_textures_info {
struct r600_pipe_sampler_view *views[NUM_TEX_UNITS];
struct r600_pipe_sampler_view *views[NUM_TEX_UNITS];
unsigned n_views;
void *samplers[NUM_TEX_UNITS];
unsigned n_samplers;
@@ -131,8 +131,6 @@ struct r600_translate_context {
#define R600_CONSTANT_ARRAY_SIZE 256
#define R600_RESOURCE_ARRAY_SIZE 160
struct r600_upload;
struct r600_pipe_context {
struct pipe_context context;
struct blitter_context *blitter;
@@ -165,7 +163,8 @@ struct r600_pipe_context {
/* shader information */
unsigned sprite_coord_enable;
bool flatshade;
struct r600_upload *rupload_vb;
struct u_upload_mgr *upload_vb;
struct u_upload_mgr *upload_ib;
unsigned any_user_vbs;
struct r600_textures_info ps_samplers;
unsigned vb_max_index;
@@ -271,13 +270,13 @@ void r600_sampler_view_destroy(struct pipe_context *ctx,
void r600_bind_state(struct pipe_context *ctx, void *state);
void r600_delete_state(struct pipe_context *ctx, void *state);
void r600_bind_vertex_elements(struct pipe_context *ctx, void *state);
void *r600_create_shader_state(struct pipe_context *ctx,
const struct pipe_shader_state *state);
void r600_bind_ps_shader(struct pipe_context *ctx, void *state);
void r600_bind_vs_shader(struct pipe_context *ctx, void *state);
void r600_delete_ps_shader(struct pipe_context *ctx, void *state);
void r600_delete_vs_shader(struct pipe_context *ctx, void *state);
/*
* common helpers
*/

View File

@@ -46,7 +46,6 @@ struct r600_resource {
struct u_resource base;
struct r600_bo *bo;
u32 size;
unsigned bo_size;
};
struct r600_resource_texture {
@@ -62,21 +61,7 @@ struct r600_resource_texture {
unsigned tile_type;
unsigned depth;
unsigned dirty;
struct r600_resource_texture *flushed_depth_texture;
};
#define R600_BUFFER_MAGIC 0xabcd1600
struct r600_resource_buffer {
struct r600_resource r;
uint32_t magic;
void *user_buffer;
bool uploaded;
};
struct r600_surface {
struct pipe_surface base;
unsigned aligned_height;
struct r600_resource_texture *flushed_depth_texture;
};
void r600_init_screen_resource_functions(struct pipe_screen *screen);
@@ -88,25 +73,41 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
const struct pipe_resource *base,
struct winsys_handle *whandle);
#define R600_BUFFER_MAGIC 0xabcd1600
#define R600_BUFFER_MAX_RANGES 32
struct r600_buffer_range {
uint32_t start;
uint32_t end;
};
struct r600_resource_buffer {
struct r600_resource r;
uint32_t magic;
void *user_buffer;
struct r600_buffer_range ranges[R600_BUFFER_MAX_RANGES];
unsigned num_ranges;
};
/* r600_buffer */
static INLINE struct r600_resource_buffer *r600_buffer(struct pipe_resource *buffer)
{
if (buffer) {
assert(((struct r600_resource_buffer *)buffer)->magic == R600_BUFFER_MAGIC);
return (struct r600_resource_buffer *)buffer;
}
return NULL;
}
return NULL;
}
static INLINE boolean r600_buffer_is_user_buffer(struct pipe_resource *buffer)
{
if (r600_buffer(buffer)->uploaded)
return FALSE;
return r600_buffer(buffer)->user_buffer ? TRUE : FALSE;
return r600_buffer(buffer)->user_buffer ? TRUE : FALSE;
}
int r600_texture_depth_flush(struct pipe_context *ctx, struct pipe_resource *texture);
int (*r600_blit_uncompress_depth_ptr)(struct pipe_context *ctx, struct r600_resource_texture *texture);
int r600_texture_depth_flush(struct pipe_context *ctx,
struct pipe_resource *texture);
extern int (*r600_blit_uncompress_depth_ptr)(struct pipe_context *ctx, struct r600_resource_texture *texture);
/* r600_texture.c texture transfer functions. */
struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
@@ -121,15 +122,9 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
void r600_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer* transfer);
struct r600_pipe_context;
struct r600_upload *r600_upload_create(struct r600_pipe_context *rctx,
unsigned default_size,
unsigned alignment);
void r600_upload_flush(struct r600_upload *upload);
void r600_upload_destroy(struct r600_upload *upload);
int r600_upload_buffer(struct r600_upload *upload, unsigned offset,
unsigned size, struct r600_resource_buffer *in_buffer,
unsigned *out_offset, unsigned *out_size,
struct r600_bo **out_buffer);
struct r600_surface {
struct pipe_surface base;
unsigned aligned_height;
};
#endif

View File

@@ -589,8 +589,6 @@ int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_shader *s
if (r)
goto out_err;
break;
case TGSI_TOKEN_TYPE_PROPERTY:
break;
default:
R600_ERR("unsupported token type %d\n", ctx.parse.FullToken.Token.Type);
r = -EINVAL;
@@ -1453,7 +1451,7 @@ static int tgsi_pow(struct r600_shader_ctx *ctx)
return r;
/* b * LOG2(a) */
memset(&alu, 0, sizeof(struct r600_bc_alu));
alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL_IEEE);
r = tgsi_src(ctx, &inst->Src[1], &alu.src[0]);
if (r)
return r;

View File

@@ -74,10 +74,6 @@
#define S_SQ_CF_ALU_WORD0_KCACHE_MODE0(x) (((x) & 0x3) << 30)
#define G_SQ_CF_ALU_WORD0_KCACHE_MODE0(x) (((x) >> 30) & 0x3)
#define C_SQ_CF_ALU_WORD0_KCACHE_MODE0 0x3FFFFFFF
#define V_SQ_CF_KCACHE_NOP 0x00000000
#define V_SQ_CF_KCACHE_LOCK_1 0x00000001
#define V_SQ_CF_KCACHE_LOCK_2 0x00000002
#define V_SQ_CF_KCACHE_LOCK_LOOP_INDEX 0x00000003
#define P_SQ_CF_ALU_WORD1
#define S_SQ_CF_ALU_WORD1_KCACHE_MODE1(x) (((x) & 0x3) << 0)
#define G_SQ_CF_ALU_WORD1_KCACHE_MODE1(x) (((x) >> 0) & 0x3)

View File

@@ -36,6 +36,7 @@
#include <util/u_pack_color.h>
#include <util/u_memory.h>
#include <util/u_inlines.h>
#include <util/u_upload_mgr.h>
#include <util/u_framebuffer.h>
#include <pipebuffer/pb_buffer.h>
#include "r600.h"
@@ -135,6 +136,11 @@ void r600_vertex_buffer_update(struct r600_pipe_context *rctx)
if (rctx->vertex_elements == NULL || !rctx->nvertex_buffer)
return;
/* delete previous translated vertex elements */
if (rctx->tran.new_velems) {
r600_end_vertex_translate(rctx);
}
if (rctx->vertex_elements->incompatible_layout) {
/* translate rebind new vertex elements so
* return once translated
@@ -167,21 +173,21 @@ void r600_vertex_buffer_update(struct r600_pipe_context *rctx)
vbuffer_index = rctx->vertex_elements->elements[i].vertex_buffer_index;
vertex_buffer = &rctx->vertex_buffer[vbuffer_index];
rbuffer = (struct r600_resource*)vertex_buffer->buffer;
offset = rctx->vertex_elements->vbuffer_offset[i];
offset = rctx->vertex_elements->vbuffer_offset[i] +
vertex_buffer->buffer_offset +
r600_bo_offset(rbuffer->bo);
} else {
/* bind vertex buffer once */
vertex_buffer = &rctx->vertex_buffer[i];
rbuffer = (struct r600_resource*)vertex_buffer->buffer;
offset = 0;
offset = vertex_buffer->buffer_offset +
r600_bo_offset(rbuffer->bo);
}
if (vertex_buffer == NULL || rbuffer == NULL)
continue;
offset += vertex_buffer->buffer_offset + r600_bo_offset(rbuffer->bo);
r600_pipe_state_add_reg(rstate, R_038000_RESOURCE0_WORD0,
offset, 0xFFFFFFFF, rbuffer->bo);
r600_pipe_state_add_reg(rstate, R_038004_RESOURCE0_WORD1,
rbuffer->bo_size - offset - 1, 0xFFFFFFFF, NULL);
rbuffer->size - offset - 1, 0xFFFFFFFF, NULL);
r600_pipe_state_add_reg(rstate, R_038008_RESOURCE0_WORD2,
S_038008_STRIDE(vertex_buffer->stride),
0xFFFFFFFF, NULL);
@@ -275,6 +281,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
{
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct r600_drawl draw;
boolean translate = FALSE;
memset(&draw, 0, sizeof(struct r600_drawl));
draw.ctx = ctx;
@@ -306,6 +313,9 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
}
r600_draw_common(&draw);
if (translate)
r600_end_vertex_translate(rctx);
pipe_resource_reference(&draw.index_buffer, NULL);
}

View File

@@ -119,11 +119,6 @@ void r600_bind_vertex_elements(struct pipe_context *ctx, void *state)
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct r600_vertex_element *v = (struct r600_vertex_element*)state;
/* delete previous translated vertex elements */
if (rctx->tran.new_velems) {
r600_end_vertex_translate(rctx);
}
rctx->vertex_elements = v;
if (v) {
rctx->states[v->rstate.id] = &v->rstate;
@@ -179,16 +174,8 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
struct pipe_vertex_buffer *vbo;
unsigned max_index = (unsigned)-1;
if (rctx->family >= CHIP_CEDAR) {
for (int i = 0; i < rctx->nvertex_buffer; i++) {
pipe_resource_reference(&rctx->vertex_buffer[i].buffer, NULL);
evergreen_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
}
} else {
for (int i = 0; i < rctx->nvertex_buffer; i++) {
pipe_resource_reference(&rctx->vertex_buffer[i].buffer, NULL);
r600_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
}
for (int i = 0; i < rctx->nvertex_buffer; i++) {
pipe_resource_reference(&rctx->vertex_buffer[i].buffer, NULL);
}
memcpy(rctx->vertex_buffer, buffers, sizeof(struct pipe_vertex_buffer) * count);
@@ -196,19 +183,15 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
vbo = (struct pipe_vertex_buffer*)&buffers[i];
rctx->vertex_buffer[i].buffer = NULL;
if (buffers[i].buffer == NULL)
continue;
if (r600_buffer_is_user_buffer(buffers[i].buffer))
rctx->any_user_vbs = TRUE;
pipe_resource_reference(&rctx->vertex_buffer[i].buffer, buffers[i].buffer);
/* The stride of zero means we will be fetching only the first
* vertex, so don't care about max_index. */
if (!vbo->stride)
continue;
if (vbo->max_index == ~0) {
vbo->max_index = (vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
if (!vbo->stride)
vbo->max_index = 1;
else
vbo->max_index = (vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
}
max_index = MIN2(vbo->max_index, max_index);
}

View File

@@ -42,7 +42,6 @@ void r600_begin_vertex_translate(struct r600_pipe_context *rctx)
struct pipe_resource *out_buffer;
unsigned i, num_verts;
struct pipe_vertex_element new_velems[PIPE_MAX_ATTRIBS];
void *tmp;
/* Initialize the translate key, i.e. the recipe how vertices should be
* translated. */
@@ -160,9 +159,8 @@ void r600_begin_vertex_translate(struct r600_pipe_context *rctx)
}
}
tmp = pipe->create_vertex_elements_state(pipe, ve->count, new_velems);
pipe->bind_vertex_elements_state(pipe, tmp);
rctx->tran.new_velems = tmp;
rctx->tran.new_velems = pipe->create_vertex_elements_state(pipe, ve->count, new_velems);
pipe->bind_vertex_elements_state(pipe, rctx->tran.new_velems);
pipe_resource_reference(&out_buffer, NULL);
}
@@ -175,11 +173,15 @@ void r600_end_vertex_translate(struct r600_pipe_context *rctx)
return;
}
/* Restore vertex elements. */
if (rctx->vertex_elements == rctx->tran.new_velems) {
pipe->bind_vertex_elements_state(pipe, NULL);
}
pipe->delete_vertex_elements_state(pipe, rctx->tran.new_velems);
rctx->tran.new_velems = NULL;
/* Delete the now-unused VBO. */
pipe_resource_reference(&rctx->vertex_buffer[rctx->tran.vb_slot].buffer, NULL);
pipe_resource_reference(&rctx->vertex_buffer[rctx->tran.vb_slot].buffer,
NULL);
}
void r600_translate_index_buffer(struct r600_pipe_context *r600,

View File

@@ -1,114 +0,0 @@
/*
* Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Jerome Glisse <jglisse@redhat.com>
*/
#include <errno.h>
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "r600.h"
#include "r600_pipe.h"
#include "r600_resource.h"
struct r600_upload {
struct r600_pipe_context *rctx;
struct r600_bo *buffer;
char *ptr;
unsigned size;
unsigned default_size;
unsigned total_alloc_size;
unsigned offset;
unsigned alignment;
};
struct r600_upload *r600_upload_create(struct r600_pipe_context *rctx,
unsigned default_size,
unsigned alignment)
{
struct r600_upload *upload = CALLOC_STRUCT(r600_upload);
if (upload == NULL)
return NULL;
upload->rctx = rctx;
upload->size = 0;
upload->default_size = default_size;
upload->alignment = alignment;
upload->ptr = NULL;
upload->buffer = NULL;
upload->total_alloc_size = 0;
return upload;
}
void r600_upload_flush(struct r600_upload *upload)
{
if (upload->buffer) {
r600_bo_reference(upload->rctx->radeon, &upload->buffer, NULL);
}
upload->default_size = MAX2(upload->total_alloc_size, upload->default_size);
upload->total_alloc_size = 0;
upload->size = 0;
upload->offset = 0;
upload->ptr = NULL;
upload->buffer = NULL;
}
void r600_upload_destroy(struct r600_upload *upload)
{
r600_upload_flush(upload);
FREE(upload);
}
int r600_upload_buffer(struct r600_upload *upload, unsigned offset,
unsigned size, struct r600_resource_buffer *in_buffer,
unsigned *out_offset, unsigned *out_size,
struct r600_bo **out_buffer)
{
unsigned alloc_size = align(size, upload->alignment);
const void *in_ptr = NULL;
if (upload->offset + alloc_size > upload->size) {
if (upload->size) {
r600_bo_reference(upload->rctx->radeon, &upload->buffer, NULL);
}
upload->size = align(MAX2(upload->default_size, alloc_size), 4096);
upload->total_alloc_size += upload->size;
upload->offset = 0;
upload->buffer = r600_bo(upload->rctx->radeon, upload->size, 4096, PIPE_BIND_VERTEX_BUFFER, 0);
if (upload->buffer == NULL) {
return -ENOMEM;
}
upload->ptr = r600_bo_map(upload->rctx->radeon, upload->buffer, 0, NULL);
}
in_ptr = in_buffer->user_buffer;
memcpy(upload->ptr + upload->offset, (uint8_t *) in_ptr + offset, size);
*out_offset = upload->offset;
*out_size = upload->size;
*out_buffer = NULL;
r600_bo_reference(upload->rctx->radeon, out_buffer, upload->buffer);
upload->offset += alloc_size;
return 0;
}

View File

@@ -0,0 +1,52 @@
LOCAL_PATH := $(call my-dir)
# from Makefile
C_SOURCES = \
sp_fs_exec.c \
sp_fs_sse.c \
sp_clear.c \
sp_fence.c \
sp_flush.c \
sp_query.c \
sp_context.c \
sp_draw_arrays.c \
sp_prim_vbuf.c \
sp_quad_pipe.c \
sp_quad_stipple.c \
sp_quad_depth_test.c \
sp_quad_fs.c \
sp_quad_blend.c \
sp_screen.c \
sp_setup.c \
sp_state_blend.c \
sp_state_clip.c \
sp_state_derived.c \
sp_state_sampler.c \
sp_state_shader.c \
sp_state_so.c \
sp_state_rasterizer.c \
sp_state_surface.c \
sp_state_vertex.c \
sp_texture.c \
sp_tex_sample.c \
sp_tex_tile_cache.c \
sp_tile_cache.c \
sp_surface.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(C_SOURCES)
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary
LOCAL_MODULE := libmesa_pipe_softpipe
include $(BUILD_STATIC_LIBRARY)

View File

@@ -50,7 +50,7 @@ softpipe_flush( struct pipe_context *pipe,
draw_flush(softpipe->draw);
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
if (1 || (flags & PIPE_FLUSH_TEXTURE_CACHE)) {
for (i = 0; i < softpipe->num_sampler_views; i++) {
sp_flush_tex_tile_cache(softpipe->tex_cache[i]);
}

View File

@@ -0,0 +1,73 @@
ifeq ($(strip $(MESA_BUILD_VMWGFX)),true)
LOCAL_PATH := $(call my-dir)
# from Makefile
C_SOURCES = \
svgadump/svga_shader_dump.c \
svgadump/svga_shader_op.c \
svgadump/svga_dump.c \
svga_cmd.c \
svga_context.c \
svga_draw.c \
svga_draw_arrays.c \
svga_draw_elements.c \
svga_pipe_blend.c \
svga_pipe_blit.c \
svga_pipe_clear.c \
svga_pipe_constants.c \
svga_pipe_depthstencil.c \
svga_pipe_draw.c \
svga_pipe_flush.c \
svga_pipe_fs.c \
svga_pipe_misc.c \
svga_pipe_query.c \
svga_pipe_rasterizer.c \
svga_pipe_sampler.c \
svga_pipe_vertex.c \
svga_pipe_vs.c \
svga_screen.c \
svga_screen_cache.c \
svga_state.c \
svga_state_need_swtnl.c \
svga_state_constants.c \
svga_state_framebuffer.c \
svga_state_rss.c \
svga_state_tss.c \
svga_state_vdecl.c \
svga_state_fs.c \
svga_state_vs.c \
svga_swtnl_backend.c \
svga_swtnl_draw.c \
svga_swtnl_state.c \
svga_tgsi.c \
svga_tgsi_decl_sm20.c \
svga_tgsi_decl_sm30.c \
svga_tgsi_insn.c \
svga_sampler_view.c \
svga_surface.c \
svga_resource.c \
svga_resource_texture.c \
svga_resource_buffer.c \
svga_resource_buffer_upload.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(C_SOURCES)
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/gallium/drivers/svga/include
LOCAL_MODULE := libmesa_pipe_svga
include $(BUILD_STATIC_LIBRARY)
endif # MESA_BUILD_VMWGFX

View File

@@ -67,7 +67,9 @@ extern "C" {
#if !defined(__HAIKU__) && !defined(__USE_MISC)
#if !defined(PIPE_OS_ANDROID)
typedef unsigned int uint;
#endif
typedef unsigned short ushort;
#endif
typedef unsigned char ubyte;

View File

@@ -133,6 +133,14 @@
#define PIPE_OS_UNIX
#endif
/*
* Android defines __linux__ so PIPE_OS_LINUX and PIPE_OS_UNIX will also be
* defined.
*/
#if defined(ANDROID)
#define PIPE_OS_ANDROID
#endif
#if defined(__FreeBSD__)
#define PIPE_OS_FREEBSD
#define PIPE_OS_BSD

View File

@@ -0,0 +1,38 @@
LOCAL_PATH := $(call my-dir)
common_SOURCES := \
egl/common/egl_g3d.c \
egl/common/egl_g3d_api.c \
egl/common/egl_g3d_image.c \
egl/common/egl_g3d_st.c \
egl/common/egl_g3d_sync.c \
egl/common/native_helper.c
android_SOURCES := \
egl/android/native_android.cpp
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(common_SOURCES) \
$(android_SOURCES)
LOCAL_CFLAGS := \
-DHAVE_ANDROID_BACKEND \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/egl/main \
external/mesa/src/gallium/state_trackers/egl \
external/mesa/src/gallium/winsys/sw \
external/mesa/src/gralloc \
external/drm \
external/drm/include/drm
LOCAL_MODULE := libmesa_st_egl
include $(BUILD_STATIC_LIBRARY)

View File

@@ -0,0 +1,679 @@
/*
* Mesa 3-D graphics library
* Version: 7.9
*
* Copyright (C) 2010 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.
*
* Authors:
* Chia-I Wu <olv@lunarg.com>
*/
#define LOG_TAG "MESA-EGL"
#include <cutils/log.h>
#include <cutils/properties.h>
#include <ui/PixelFormat.h>
#include <ui/android_native_buffer.h>
extern "C" {
#include "egllog.h"
}
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "common/native.h"
#include "common/native_helper.h"
#include "android/android_sw_winsys.h"
#include "state_tracker/drm_driver.h"
struct android_config;
struct android_display {
struct native_display base;
boolean use_drm;
struct native_event_handler *event_handler;
struct android_config *configs;
int num_configs;
};
struct android_surface {
struct native_surface base;
struct android_display *adpy;
android_native_window_t *win;
uint stamp;
android_native_buffer_t *buf;
struct pipe_resource *res;
/* cache the current front and back resources */
void *cache_handles[2];
struct pipe_resource *cache_resources[2];
};
struct android_config {
struct native_config base;
};
static INLINE struct android_display *
android_display(const struct native_display *ndpy)
{
return (struct android_display *) ndpy;
}
static INLINE struct android_surface *
android_surface(const struct native_surface *nsurf)
{
return (struct android_surface *) nsurf;
}
static INLINE struct android_config *
android_config(const struct native_config *nconf)
{
return (struct android_config *) nconf;
}
namespace android {
static enum pipe_format
get_pipe_format(int native)
{
enum pipe_format fmt;
/* see libpixelflinger/format.cpp */
switch (native) {
case PIXEL_FORMAT_RGBA_8888:
fmt = PIPE_FORMAT_R8G8B8A8_UNORM;
break;
case PIXEL_FORMAT_RGBX_8888:
fmt = PIPE_FORMAT_R8G8B8X8_UNORM;
break;
case PIXEL_FORMAT_RGB_888:
fmt = PIPE_FORMAT_R8G8B8_UNORM;
break;
case PIXEL_FORMAT_RGB_565:
fmt = PIPE_FORMAT_B5G6R5_UNORM;
break;
case PIXEL_FORMAT_BGRA_8888:
fmt = PIPE_FORMAT_B8G8R8A8_UNORM;
break;
case PIXEL_FORMAT_A_8:
fmt = PIPE_FORMAT_A8_UNORM;
break;
case PIXEL_FORMAT_L_8:
fmt = PIPE_FORMAT_L8_UNORM;
break;
case PIXEL_FORMAT_LA_88:
fmt = PIPE_FORMAT_L8A8_UNORM;
break;
case PIXEL_FORMAT_NONE:
case PIXEL_FORMAT_RGBA_5551:
case PIXEL_FORMAT_RGBA_4444:
case PIXEL_FORMAT_RGB_332:
default:
LOGE("unsupported native format 0x%x", native);
fmt = PIPE_FORMAT_NONE;
break;
}
return fmt;
}
#include <gralloc_gem.h>
static int
get_handle_name(buffer_handle_t handle)
{
struct drm_bo_t *bo;
bo = drm_gem_get(handle);
return (bo) ? bo->name : 0;
}
static struct pipe_resource *
import_buffer(struct android_display *adpy, const struct pipe_resource *templ,
struct android_native_buffer_t *abuf)
{
struct pipe_screen *screen = adpy->base.screen;
struct pipe_resource *res;
if (templ->bind & PIPE_BIND_RENDER_TARGET) {
if (!screen->is_format_supported(screen, templ->format,
templ->target, 0, PIPE_BIND_RENDER_TARGET, 0))
LOGW("importing unsupported buffer as render target");
}
if (templ->bind & PIPE_BIND_SAMPLER_VIEW) {
if (!screen->is_format_supported(screen, templ->format,
templ->target, 0, PIPE_BIND_SAMPLER_VIEW, 0))
LOGW("importing unsupported buffer as sampler view");
}
if (adpy->use_drm) {
struct winsys_handle handle;
memset(&handle, 0, sizeof(handle));
handle.type = DRM_API_HANDLE_TYPE_SHARED;
handle.handle = get_handle_name(abuf->handle);
if (!handle.handle) {
LOGE("unable to import invalid buffer %p", abuf);
return NULL;
}
handle.stride =
abuf->stride * util_format_get_blocksize(templ->format);
res = screen->resource_from_handle(screen, templ, &handle);
}
else {
struct android_winsys_handle handle;
memset(&handle, 0, sizeof(handle));
handle.handle = abuf->handle;
handle.stride =
abuf->stride * util_format_get_blocksize(templ->format);
res = screen->resource_from_handle(screen,
templ, (struct winsys_handle *) &handle);
}
if (!res)
LOGE("failed to import buffer %p", abuf);
return res;
}
static boolean
android_surface_dequeue_buffer(struct native_surface *nsurf)
{
struct android_surface *asurf = android_surface(nsurf);
void *handle;
int idx;
if (asurf->win->dequeueBuffer(asurf->win, &asurf->buf) != NO_ERROR) {
LOGE("failed to dequeue window %p", asurf->win);
return FALSE;
}
asurf->buf->common.incRef(&asurf->buf->common);
asurf->win->lockBuffer(asurf->win, asurf->buf);
if (asurf->adpy->use_drm)
handle = (void *) get_handle_name(asurf->buf->handle);
else
handle = (void *) asurf->buf->handle;
/* NULL is invalid */
if (!handle) {
LOGE("window %p returned an invalid buffer", asurf->win);
return TRUE;
}
/* find the slot to use */
for (idx = 0; idx < Elements(asurf->cache_handles); idx++) {
if (asurf->cache_handles[idx] == handle || !asurf->cache_handles[idx])
break;
}
if (idx == Elements(asurf->cache_handles)) {
/* buffer reallocated; clear the cache */
for (idx = 0; idx < Elements(asurf->cache_handles); idx++) {
asurf->cache_handles[idx] = 0;
pipe_resource_reference(&asurf->cache_resources[idx], NULL);
}
idx = 0;
}
/* update the cache */
if (!asurf->cache_handles[idx]) {
struct pipe_resource templ;
assert(!asurf->cache_resources[idx]);
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
templ.width0 = asurf->buf->width;
templ.height0 = asurf->buf->height;
templ.depth0 = 1;
templ.bind = PIPE_BIND_RENDER_TARGET;
if (!asurf->adpy->use_drm) {
templ.bind |= PIPE_BIND_TRANSFER_WRITE |
PIPE_BIND_TRANSFER_READ;
}
templ.format = get_pipe_format(asurf->buf->format);
if (templ.format != PIPE_FORMAT_NONE) {
asurf->cache_resources[idx] =
import_buffer(asurf->adpy, &templ, asurf->buf);
}
else {
asurf->cache_resources[idx] = NULL;
}
asurf->cache_handles[idx] = handle;
}
pipe_resource_reference(&asurf->res, asurf->cache_resources[idx]);
return TRUE;
}
static boolean
android_surface_enqueue_buffer(struct native_surface *nsurf)
{
struct android_surface *asurf = android_surface(nsurf);
pipe_resource_reference(&asurf->res, NULL);
asurf->win->queueBuffer(asurf->win, asurf->buf);
asurf->buf->common.decRef(&asurf->buf->common);
asurf->buf = NULL;
return TRUE;
}
static boolean
android_surface_swap_buffers(struct native_surface *nsurf)
{
struct android_surface *asurf = android_surface(nsurf);
struct android_display *adpy = asurf->adpy;
if (!asurf->buf)
return FALSE;
android_surface_enqueue_buffer(&asurf->base);
asurf->stamp++;
adpy->event_handler->invalid_surface(&adpy->base,
&asurf->base, asurf->stamp);
return TRUE;
}
static boolean
android_surface_present(struct native_surface *nsurf,
enum native_attachment natt,
boolean preserve,
uint swap_interval)
{
boolean ret;
if (swap_interval || natt != NATIVE_ATTACHMENT_BACK_LEFT)
return FALSE;
return android_surface_swap_buffers(nsurf);
}
static boolean
android_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
{
struct android_surface *asurf = android_surface(nsurf);
struct winsys_handle handle;
if (!asurf->buf) {
if (!android_surface_dequeue_buffer(&asurf->base))
return FALSE;
}
if (textures) {
const enum native_attachment att = NATIVE_ATTACHMENT_BACK_LEFT;
if (native_attachment_mask_test(attachment_mask, att)) {
textures[att] = NULL;
pipe_resource_reference(&textures[att], asurf->res);
}
}
if (seq_num)
*seq_num = asurf->stamp;
if (width)
*width = asurf->buf->width;
if (height)
*height = asurf->buf->height;
return TRUE;
}
static void
android_surface_wait(struct native_surface *nsurf)
{
}
static void
android_surface_destroy(struct native_surface *nsurf)
{
struct android_surface *asurf = android_surface(nsurf);
int i;
if (asurf->buf)
android_surface_enqueue_buffer(&asurf->base);
for (i = 0; i < Elements(asurf->cache_handles); i++)
pipe_resource_reference(&asurf->cache_resources[i], NULL);
asurf->win->common.decRef(&asurf->win->common);
FREE(asurf);
}
static struct native_surface *
android_display_create_window_surface(struct native_display *ndpy,
EGLNativeWindowType win,
const struct native_config *nconf)
{
struct android_display *adpy = android_display(ndpy);
struct android_config *aconf = android_config(nconf);
struct android_surface *asurf;
enum pipe_format format;
int val;
if (win->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
LOGE("invalid native window with magic 0x%x", win->common.magic);
return NULL;
}
if (win->query(win, NATIVE_WINDOW_FORMAT, &val)) {
LOGE("failed to query native window format");
return NULL;
}
format = get_pipe_format(val);
if (format != nconf->color_format) {
LOGW("native window format 0x%x != config format 0x%x",
format, nconf->color_format);
if (!adpy->base.screen->is_format_supported(adpy->base.screen,
format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0)) {
LOGE("and the native window cannot be used as a render target");
return NULL;
}
}
asurf = CALLOC_STRUCT(android_surface);
if (!asurf)
return NULL;
asurf->adpy = adpy;
asurf->win = win;
asurf->win->common.incRef(&asurf->win->common);
if (!adpy->use_drm) {
native_window_set_usage(asurf->win,
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
}
asurf->base.destroy = android_surface_destroy;
asurf->base.present = android_surface_present;
asurf->base.validate = android_surface_validate;
asurf->base.wait = android_surface_wait;
return &asurf->base;
}
static boolean
android_display_init_configs(struct native_display *ndpy)
{
struct android_display *adpy = android_display(ndpy);
const int native_formats[] = {
PIXEL_FORMAT_RGBA_8888,
PIXEL_FORMAT_RGBX_8888,
PIXEL_FORMAT_RGB_888,
PIXEL_FORMAT_RGB_565,
PIXEL_FORMAT_BGRA_8888,
PIXEL_FORMAT_A_8
};
int i;
adpy->configs = (struct android_config *)
CALLOC(Elements(native_formats), sizeof(*adpy->configs));
if (!adpy->configs)
return FALSE;
for (i = 0; i < Elements(native_formats); i++) {
enum pipe_format color_format;
struct android_config *aconf;
color_format = get_pipe_format(native_formats[i]);
if (color_format == PIPE_FORMAT_NONE ||
!adpy->base.screen->is_format_supported(adpy->base.screen,
color_format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0)) {
LOGI("skip unsupported native format 0x%x", native_formats[i]);
continue;
}
aconf = &adpy->configs[adpy->num_configs++];
aconf->base.buffer_mask = 1 << NATIVE_ATTACHMENT_BACK_LEFT;
aconf->base.color_format = color_format;
aconf->base.window_bit = TRUE;
if (!adpy->use_drm)
aconf->base.slow_config = TRUE;
aconf->base.native_visual_type = native_formats[i];
}
return TRUE;
}
static boolean
android_display_init(struct native_display *ndpy)
{
struct android_display *adpy = android_display(ndpy);
const hw_module_t *mod;
int fd, err;
boolean force_sw;
char value[PROPERTY_VALUE_MAX];
if (property_get("debug.mesa.software", value, NULL))
force_sw = (atoi(value) != 0);
else
force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
/* try DRM first */
if (!force_sw) {
err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod);
if (!err) {
const gralloc_module_t *gr = (gralloc_module_t *) mod;
err = -EINVAL;
if (gr->perform)
err = gr->perform(gr, GRALLOC_MODULE_PERFORM_GET_DRM_FD, &fd);
}
if (!err && fd >= 0) {
adpy->base.screen =
adpy->event_handler->new_drm_screen(&adpy->base, "i915", fd);
if (adpy->base.screen)
adpy->use_drm = TRUE;
}
if (adpy->base.screen)
LOGI("using DRM screen");
else
LOGE("failed to create DRM screen");
}
/* try SW screen */
if (!adpy->base.screen) {
struct sw_winsys *ws = android_create_sw_winsys();
if (ws) {
adpy->base.screen =
adpy->event_handler->new_sw_screen(&adpy->base, ws);
}
if (adpy->base.screen)
LOGI("using SW screen");
else
LOGE("failed to create SW screen");
}
if (adpy->base.screen) {
if (!android_display_init_configs(&adpy->base)) {
adpy->base.screen->destroy(adpy->base.screen);
adpy->base.screen = NULL;
}
}
return (adpy->base.screen != NULL);
}
static void
android_display_destroy(struct native_display *ndpy)
{
struct android_display *adpy = android_display(ndpy);
FREE(adpy->configs);
adpy->base.screen->destroy(adpy->base.screen);
FREE(adpy);
}
static const struct native_config **
android_display_get_configs(struct native_display *ndpy, int *num_configs)
{
struct android_display *adpy = android_display(ndpy);
const struct native_config **configs;
int i;
configs = (const struct native_config **)
MALLOC(adpy->num_configs * sizeof(*configs));
if (configs) {
for (i = 0; i < adpy->num_configs; i++)
configs[i] = (const struct native_config *) &adpy->configs[i];
if (num_configs)
*num_configs = adpy->num_configs;
}
return configs;
}
static int
android_display_get_param(struct native_display *ndpy,
enum native_param_type param)
{
int val;
switch (param) {
default:
val = 0;
break;
}
return val;
}
static struct pipe_resource *
android_display_import_buffer(struct native_display *ndpy,
const struct pipe_resource *templ,
void *buf)
{
struct android_display *adpy = android_display(ndpy);
struct android_native_buffer_t *abuf =
(struct android_native_buffer_t *) buf;
return import_buffer(adpy, templ, abuf);
}
static boolean
android_display_export_buffer(struct native_display *ndpy,
struct pipe_resource *res,
void *buf)
{
return FALSE;
}
static struct native_display_buffer android_display_buffer = {
android_display_import_buffer,
android_display_export_buffer
};
static struct android_display *
android_display_create(struct native_event_handler *event_handler,
void *user_data)
{
struct android_display *adpy;
adpy = CALLOC_STRUCT(android_display);
if (!adpy)
return NULL;
adpy->event_handler = event_handler;
adpy->base.user_data = user_data;
if (!android_display_init(&adpy->base)) {
FREE(adpy);
return NULL;
}
adpy->base.destroy = android_display_destroy;
adpy->base.get_param = android_display_get_param;
adpy->base.get_configs = android_display_get_configs;
adpy->base.create_window_surface = android_display_create_window_surface;
adpy->base.buffer = &android_display_buffer;
return adpy;
}
static struct native_display *
native_create_display(void *dpy, struct native_event_handler *event_handler,
void *user_data)
{
struct android_display *adpy;
adpy = android_display_create(event_handler, user_data);
return (adpy) ? &adpy->base : NULL;
}
static const struct native_platform android_platform = {
"Android", /* name */
native_create_display
};
}; /* namespace android */
using namespace android;
static void
android_log(EGLint level, const char *msg)
{
switch (level) {
case _EGL_DEBUG:
LOGD(msg);
break;
case _EGL_INFO:
LOGI(msg);
break;
case _EGL_WARNING:
LOGW(msg);
break;
case _EGL_FATAL:
LOG_FATAL(msg);
break;
default:
break;
}
}
const struct native_platform *
native_get_android_platform(void)
{
_eglSetLogProc(android_log);
return &android_platform;
}

View File

@@ -73,6 +73,12 @@ egl_g3d_get_platform(_EGLDriver *drv, _EGLPlatformType plat)
plat_name = "FBDEV";
#ifdef HAVE_FBDEV_BACKEND
nplat = native_get_fbdev_platform();
#endif
break;
case _EGL_PLATFORM_ANDROID:
plat_name = "Android";
#ifdef HAVE_ANDROID_BACKEND
nplat = native_get_android_platform();
#endif
break;
default:
@@ -557,6 +563,11 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
dpy->Extensions.MESA_drm_image = EGL_TRUE;
}
#ifdef EGL_ANDROID_image_native_buffer
if (dpy->Platform == _EGL_PLATFORM_ANDROID && gdpy->native->buffer)
dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
#endif
if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
_eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)");
goto fail;

View File

@@ -94,6 +94,9 @@ struct egl_g3d_image {
struct pipe_resource *texture;
unsigned level;
unsigned layer;
EGLenum target;
EGLClientBuffer buffer;
};
/* standard typecasts */

View File

@@ -158,17 +158,17 @@ egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
(_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria);
/* perform sorting of configs */
if (configs && tmp_size) {
if (tmp_configs && tmp_size) {
_eglSortConfigs((const _EGLConfig **) tmp_configs, tmp_size,
egl_g3d_compare_config, (void *) &criteria);
tmp_size = MIN2(tmp_size, size);
for (i = 0; i < tmp_size; i++)
size = MIN2(tmp_size, size);
for (i = 0; i < size; i++)
configs[i] = _eglGetConfigHandle(tmp_configs[i]);
}
FREE(tmp_configs);
*num_configs = tmp_size;
*num_configs = size;
return EGL_TRUE;
}
@@ -402,6 +402,7 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLConfig *conf, const EGLint *attribs)
{
struct egl_g3d_surface *gsurf;
struct pipe_resource *ptex = NULL;
gsurf = create_pbuffer_surface(dpy, conf, attribs,
"eglCreatePbufferSurface");
@@ -410,6 +411,13 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
gsurf->client_buffer_type = EGL_NONE;
if (!gsurf->stfbi->validate(gsurf->stfbi,
&gsurf->stvis.render_buffer, 1, &ptex)) {
egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
FREE(gsurf);
return NULL;
}
return &gsurf->base;
}
@@ -469,14 +477,12 @@ egl_g3d_create_pbuffer_from_client_buffer(_EGLDriver *drv, _EGLDisplay *dpy,
gsurf->client_buffer_type = buftype;
gsurf->client_buffer = buffer;
/* validate now so that it fails if the client buffer is invalid */
if (!gsurf->stfbi->validate(gsurf->stfbi,
&gsurf->stvis.render_buffer, 1, &ptex)) {
egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
FREE(gsurf);
return NULL;
}
pipe_resource_reference(&ptex, NULL);
return &gsurf->base;
}
@@ -670,13 +676,14 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
ptex = get_pipe_resource(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
if (ptex) {
struct pipe_resource *psrc = gsurf->render_texture;
struct pipe_box src_box;
u_box_origin_2d(ptex->width0, ptex->height0, &src_box);
gdpy->pipe->resource_copy_region(gdpy->pipe, ptex, 0, 0, 0, 0,
gsurf->render_texture, 0, &src_box);
gdpy->pipe->flush(gdpy->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
nsurf->present(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
if (psrc) {
gdpy->pipe->resource_copy_region(gdpy->pipe, ptex, 0, 0, 0, 0,
gsurf->render_texture, 0, &src_box);
nsurf->present(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
}
pipe_resource_reference(&ptex, NULL);
}

View File

@@ -41,6 +41,11 @@
/* for struct winsys_handle */
#include "state_tracker/drm_driver.h"
#ifdef EGL_ANDROID_image_native_buffer
#include <ui/android_native_buffer.h>
#include "android/android_sw_winsys.h"
#endif
/**
* Reference and return the front left buffer of the native pixmap.
*/
@@ -185,6 +190,67 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
#endif /* EGL_MESA_drm_image */
#ifdef EGL_ANDROID_image_native_buffer
static struct pipe_resource *
egl_g3d_reference_android_native_buffer(_EGLDisplay *dpy,
struct android_native_buffer_t *buf)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
struct pipe_screen *screen = gdpy->native->screen;
enum pipe_format format;
struct pipe_resource templ, *res;
struct android_winsys_handle handle;
if (!buf || buf->common.magic != ANDROID_NATIVE_BUFFER_MAGIC ||
buf->common.version != sizeof(*buf)) {
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
return NULL;
}
switch (buf->format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
format = PIPE_FORMAT_R8G8B8A8_UNORM;
break;
case HAL_PIXEL_FORMAT_RGBX_8888:
format = PIPE_FORMAT_R8G8B8X8_UNORM;
break;
case HAL_PIXEL_FORMAT_RGB_888:
format = PIPE_FORMAT_R8G8B8_UNORM;
break;
case HAL_PIXEL_FORMAT_RGB_565:
format = PIPE_FORMAT_B5G6R5_UNORM;
break;
case HAL_PIXEL_FORMAT_BGRA_8888:
format = PIPE_FORMAT_B8G8R8A8_UNORM;
break;
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
/* unsupported */
default:
_eglLog(_EGL_WARNING, "unsupported native format 0x%x", buf->format);
return NULL;
break;
}
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
templ.format = format;
templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
templ.width0 = buf->width;
templ.height0 = buf->height;
templ.depth0 = 1;
res = gdpy->native->buffer->import_buffer(gdpy->native,
&templ, (void *) buf);
if (res)
buf->common.incRef(&buf->common);
return res;
}
#endif /* EGL_ANDROID_image_native_buffer */
_EGLImage *
egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
EGLenum target, EGLClientBuffer buffer,
@@ -205,6 +271,8 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
return NULL;
}
gimg->target = target;
switch (target) {
case EGL_NATIVE_PIXMAP_KHR:
ptex = egl_g3d_reference_native_pixmap(dpy,
@@ -215,6 +283,13 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
ptex = egl_g3d_reference_drm_buffer(dpy,
(EGLint) buffer, &gimg->base, attribs);
break;
#endif
#ifdef EGL_ANDROID_image_native_buffer
case EGL_NATIVE_BUFFER_ANDROID:
gimg->buffer = buffer;
ptex = egl_g3d_reference_android_native_buffer(dpy,
(struct android_native_buffer_t *) buffer);
break;
#endif
default:
ptex = NULL;
@@ -252,6 +327,14 @@ egl_g3d_destroy_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img)
{
struct egl_g3d_image *gimg = egl_g3d_image(img);
#ifdef EGL_ANDROID_image_native_buffer
if (gimg->target == EGL_NATIVE_BUFFER_ANDROID) {
struct android_native_buffer_t * buf =
(struct android_native_buffer_t *) gimg->buffer;
buf->common.decRef(&buf->common);
}
#endif
pipe_resource_reference(&gimg->texture, NULL);
FREE(gimg);

View File

@@ -243,6 +243,9 @@ native_get_drm_platform(void);
const struct native_platform *
native_get_fbdev_platform(void);
const struct native_platform *
native_get_android_platform(void);
#ifdef __cplusplus
}
#endif

View File

@@ -548,10 +548,6 @@ dri2_display_convert_config(struct native_display *ndpy,
if (!mode->xRenderable || !mode->drawableType)
return FALSE;
/* fast/slow configs are probably not relevant */
if (mode->visualRating == GLX_SLOW_CONFIG)
return FALSE;
nconf->buffer_mask = 1 << NATIVE_ATTACHMENT_FRONT_LEFT;
if (mode->doubleBufferMode)
nconf->buffer_mask |= 1 << NATIVE_ATTACHMENT_BACK_LEFT;
@@ -572,32 +568,13 @@ dri2_display_convert_config(struct native_display *ndpy,
if (nconf->color_format == PIPE_FORMAT_NONE)
return FALSE;
if ((mode->drawableType & GLX_WINDOW_BIT) && mode->visualID)
if (mode->drawableType & GLX_WINDOW_BIT)
nconf->window_bit = TRUE;
if (mode->drawableType & GLX_PIXMAP_BIT)
nconf->pixmap_bit = TRUE;
nconf->native_visual_id = mode->visualID;
switch (mode->visualType) {
case GLX_TRUE_COLOR:
nconf->native_visual_type = TrueColor;
break;
case GLX_DIRECT_COLOR:
nconf->native_visual_type = DirectColor;
break;
case GLX_PSEUDO_COLOR:
nconf->native_visual_type = PseudoColor;
break;
case GLX_STATIC_COLOR:
nconf->native_visual_type = StaticColor;
break;
case GLX_GRAY_SCALE:
nconf->native_visual_type = GrayScale;
break;
case GLX_STATIC_GRAY:
nconf->native_visual_type = StaticGray;
break;
}
nconf->native_visual_type = mode->visualType;
nconf->level = mode->level;
nconf->samples = mode->samples;
@@ -637,17 +614,8 @@ dri2_display_get_configs(struct native_display *ndpy, int *num_configs)
count = 0;
for (i = 0; i < num_modes; i++) {
struct native_config *nconf = &dri2dpy->configs[count].base;
if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) {
int j;
/* look for duplicates */
for (j = 0; j < count; j++) {
if (memcmp(&dri2dpy->configs[j], nconf, sizeof(*nconf)) == 0)
break;
}
if (j == count)
count++;
}
if (dri2_display_convert_config(&dri2dpy->base, modes, nconf))
count++;
modes = modes->next;
}

View File

@@ -0,0 +1,157 @@
LOCAL_PATH := $(call my-dir)
gles_SRC_FILES := \
egl-gdi/egl-static.c
gles_CFLAGS := \
-DFEATURE_ES1=1 \
-DFEATURE_ES2=1 \
-DGALLIUM_SOFTPIPE \
-fvisibility=hidden \
-Wno-sign-compare
gles_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/gallium/drivers \
external/mesa/src/gallium/winsys \
external/mesa/src/gallium/state_trackers/vega \
external/mesa/src/gallium/state_trackers/egl \
external/mesa/src/egl/main \
external/mesa/src/mesa
gles_STATIC_LIBRARIES := \
libmesa_st_egl \
libmesa_winsys_sw \
libmesa_pipe_softpipe \
libmesa_st_mesa \
libmesa_glsl \
libmesa_st_mesa \
libmesa_talloc \
libmesa_gallium
gles_WHOLE_STATIC_LIBRARIES := \
libmesa_egl \
libmesa_glapi
gles_SHARED_LIBRARIES := \
libdl \
libhardware \
liblog \
libcutils
gralloc_SRC_FILES :=
gralloc_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
gralloc_C_INCLUDES := \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/gallium/drivers \
external/mesa/src/gallium/winsys
gralloc_STATIC_LIBRARIES := \
libmesa_gallium
gralloc_WHOLE_STATIC_LIBRARIES := \
libmesa_st_gralloc
gralloc_SHARED_LIBRARIES := \
libdl \
liblog \
libcutils \
libdrm \
libEGL
ifeq ($(strip $(MESA_BUILD_SWRAST)),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(gles_SRC_FILES)
LOCAL_CFLAGS := \
$(gles_CFLAGS)
LOCAL_C_INCLUDES := \
$(gles_C_INCLUDES)
LOCAL_STATIC_LIBRARIES := \
$(gles_STATIC_LIBRARIES)
LOCAL_WHOLE_STATIC_LIBRARIES := \
$(gles_WHOLE_STATIC_LIBRARIES)
LOCAL_SHARED_LIBRARIES := \
$(gles_SHARED_LIBRARIES)
LOCAL_MODULE := libGLES_swrast
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
include $(BUILD_SHARED_LIBRARY)
endif # MESA_BUILD_SWRAST
ifeq ($(strip $(MESA_BUILD_I915G)),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(gles_SRC_FILES) \
egl/pipe_i915.c
LOCAL_CFLAGS := \
$(gles_CFLAGS) \
-DFEATURE_DRM=1
LOCAL_C_INCLUDES := \
$(gles_C_INCLUDES)
LOCAL_STATIC_LIBRARIES := \
libmesa_winsys_i915 \
libmesa_pipe_i915 \
$(gles_STATIC_LIBRARIES)
LOCAL_WHOLE_STATIC_LIBRARIES := \
$(gles_WHOLE_STATIC_LIBRARIES)
LOCAL_SHARED_LIBRARIES := \
$(gles_SHARED_LIBRARIES) \
libdrm \
libdrm_intel
LOCAL_MODULE := libGLES_i915g
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
include $(BUILD_SHARED_LIBRARY)
endif # MESA_BUILD_I915G
ifeq ($(strip $(MESA_BUILD_VMWGFX)),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
egl/pipe_vmwgfx.c \
$(gralloc_SRC_FILES)
LOCAL_CFLAGS := \
$(gralloc_CFLAGS)
LOCAL_C_INCLUDES := \
$(gralloc_C_INCLUDES)
LOCAL_STATIC_LIBRARIES := \
libmesa_pipe_svga \
libmesa_winsys_svga \
$(gralloc_STATIC_LIBRARIES)
LOCAL_WHOLE_STATIC_LIBRARIES := \
$(gralloc_WHOLE_STATIC_LIBRARIES)
LOCAL_SHARED_LIBRARIES := \
$(gralloc_SHARED_LIBRARIES)
LOCAL_MODULE := gralloc.vmwgfx
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
include $(BUILD_SHARED_LIBRARY)
endif # MESA_BUILD_VMWGFX

View File

@@ -28,6 +28,7 @@
#include "common/egl_g3d_loader.h"
#include "state_tracker/st_gl_api.h"
#include "state_tracker/drm_driver.h"
#include "vg_api.h"
#include "target-helpers/inline_sw_helper.h"
#include "target-helpers/inline_debug_helper.h"
@@ -73,7 +74,11 @@ guess_gl_api(enum st_profile_type profile)
static struct pipe_screen *
create_drm_screen(const char *name, int fd)
{
#if FEATURE_DRM
return driver_descriptor.create_screen(fd);
#else
return NULL;
#endif
}
static struct pipe_screen *

View File

@@ -0,0 +1 @@
include $(call all-subdir-makefiles)

View File

@@ -0,0 +1,33 @@
ifeq ($(strip $(MESA_BUILD_I915G)),true)
LOCAL_PATH := $(call my-dir)
# from drm/Makefile
C_SOURCES = \
i915_drm_batchbuffer.c \
i915_drm_buffer.c \
i915_drm_fence.c \
i915_drm_winsys.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(addprefix drm/, $(C_SOURCES))
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/gallium/drivers \
external/drm \
external/drm/include/drm \
external/drm/intel
LOCAL_MODULE := libmesa_winsys_i915
include $(BUILD_STATIC_LIBRARY)
endif # MESA_BUILD_I915G

View File

@@ -8,12 +8,12 @@ C_SOURCES = \
bof.c \
evergreen_hw_context.c \
radeon_bo.c \
radeon_bo_pb.c \
radeon_pciid.c \
r600.c \
r600_bo.c \
r600_drm.c \
r600_hw_context.c \
r600_bomgr.c
r600_hw_context.c
LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r600 \
$(shell pkg-config libdrm --cflags-only-I)

View File

@@ -6,12 +6,12 @@ r600_sources = [
'bof.c',
'evergreen_hw_context.c',
'radeon_bo.c',
'radeon_bo_pb.c',
'radeon_pciid.c',
'r600.c',
'r600_bo.c',
'r600_drm.c',
'r600_hw_context.c',
'r600_bomgr.c',
]
env.ParseConfig('pkg-config --cflags libdrm_radeon')

View File

@@ -36,6 +36,7 @@
#include "pipe/p_compiler.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include <pipebuffer/pb_bufmgr.h>
#include "r600_priv.h"
#define GROUP_FORCE_NEW_BLOCK 0

View File

@@ -27,6 +27,7 @@
#include "radeon_drm.h"
#include "pipe/p_compiler.h"
#include "util/u_inlines.h"
#include <pipebuffer/pb_bufmgr.h>
#include "r600_priv.h"
enum radeon_family r600_get_family(struct radeon *r600)
@@ -79,6 +80,58 @@ struct radeon *r600_new(int fd, unsigned device)
r600_delete(r600);
return NULL;
}
switch (r600->family) {
case CHIP_R600:
case CHIP_RV610:
case CHIP_RV630:
case CHIP_RV670:
case CHIP_RV620:
case CHIP_RV635:
case CHIP_RS780:
case CHIP_RS880:
case CHIP_RV770:
case CHIP_RV730:
case CHIP_RV710:
case CHIP_RV740:
case CHIP_CEDAR:
case CHIP_REDWOOD:
case CHIP_JUNIPER:
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
case CHIP_PALM:
break;
case CHIP_R100:
case CHIP_RV100:
case CHIP_RS100:
case CHIP_RV200:
case CHIP_RS200:
case CHIP_R200:
case CHIP_RV250:
case CHIP_RS300:
case CHIP_RV280:
case CHIP_R300:
case CHIP_R350:
case CHIP_RV350:
case CHIP_RV380:
case CHIP_R420:
case CHIP_R423:
case CHIP_RV410:
case CHIP_RS400:
case CHIP_RS480:
case CHIP_RS600:
case CHIP_RS690:
case CHIP_RS740:
case CHIP_RV515:
case CHIP_R520:
case CHIP_RV530:
case CHIP_RV560:
case CHIP_RV570:
case CHIP_R580:
default:
R600_ERR("unknown or unsupported chipset 0x%04X\n", r600->device);
break;
}
/* setup class */
switch (r600->family) {
case CHIP_R600:
@@ -103,9 +156,6 @@ struct radeon *r600_new(int fd, unsigned device)
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
case CHIP_PALM:
case CHIP_BARTS:
case CHIP_TURKS:
case CHIP_CAICOS:
r600->chip_class = EVERGREEN;
break;
default:

View File

@@ -36,153 +36,142 @@ struct r600_bo *r600_bo(struct radeon *radeon,
unsigned size, unsigned alignment,
unsigned binding, unsigned usage)
{
struct r600_bo *bo;
struct radeon_bo *rbo;
struct r600_bo *ws_bo = calloc(1, sizeof(struct r600_bo));
struct pb_desc desc;
struct pb_manager *man;
if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)) {
bo = r600_bomgr_bo_create(radeon->bomgr, size, alignment, *radeon->cfence);
if (bo) {
return bo;
}
}
desc.alignment = alignment;
desc.usage = (PB_USAGE_CPU_READ_WRITE | PB_USAGE_GPU_READ_WRITE);
ws_bo->size = size;
rbo = radeon_bo(radeon, 0, size, alignment);
if (rbo == NULL) {
return NULL;
}
bo = calloc(1, sizeof(struct r600_bo));
bo->size = size;
bo->alignment = alignment;
bo->bo = rbo;
if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)) {
r600_bomgr_bo_init(radeon->bomgr, bo);
}
if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER))
man = radeon->cman;
else
man = radeon->kman;
/* Staging resources particpate in transfers and blits only
* and are used for uploads and downloads from regular
* resources. We generate them internally for some transfers.
*/
if (usage == PIPE_USAGE_STAGING)
bo->domains = RADEON_GEM_DOMAIN_CPU | RADEON_GEM_DOMAIN_GTT;
else
bo->domains = (RADEON_GEM_DOMAIN_CPU |
RADEON_GEM_DOMAIN_GTT |
RADEON_GEM_DOMAIN_VRAM);
ws_bo->domains = RADEON_GEM_DOMAIN_CPU | RADEON_GEM_DOMAIN_GTT;
else
ws_bo->domains = (RADEON_GEM_DOMAIN_CPU |
RADEON_GEM_DOMAIN_GTT |
RADEON_GEM_DOMAIN_VRAM);
pipe_reference_init(&bo->reference, 1);
return bo;
ws_bo->pb = man->create_buffer(man, size, &desc);
if (ws_bo->pb == NULL) {
free(ws_bo);
return NULL;
}
pipe_reference_init(&ws_bo->reference, 1);
return ws_bo;
}
struct r600_bo *r600_bo_handle(struct radeon *radeon,
unsigned handle, unsigned *array_mode)
{
struct r600_bo *bo = calloc(1, sizeof(struct r600_bo));
struct radeon_bo *rbo;
struct r600_bo *ws_bo = calloc(1, sizeof(struct r600_bo));
struct radeon_bo *bo;
rbo = bo->bo = radeon_bo(radeon, handle, 0, 0);
if (rbo == NULL) {
free(bo);
ws_bo->pb = radeon_bo_pb_create_buffer_from_handle(radeon->kman, handle);
if (!ws_bo->pb) {
free(ws_bo);
return NULL;
}
bo->size = rbo->size;
bo->domains = (RADEON_GEM_DOMAIN_CPU |
RADEON_GEM_DOMAIN_GTT |
RADEON_GEM_DOMAIN_VRAM);
bo = radeon_bo_pb_get_bo(ws_bo->pb);
ws_bo->size = bo->size;
ws_bo->domains = (RADEON_GEM_DOMAIN_CPU |
RADEON_GEM_DOMAIN_GTT |
RADEON_GEM_DOMAIN_VRAM);
pipe_reference_init(&bo->reference, 1);
pipe_reference_init(&ws_bo->reference, 1);
radeon_bo_get_tiling_flags(radeon, rbo, &bo->tiling_flags, &bo->kernel_pitch);
radeon_bo_get_tiling_flags(radeon, bo, &ws_bo->tiling_flags,
&ws_bo->kernel_pitch);
if (array_mode) {
if (bo->tiling_flags) {
if (bo->tiling_flags & RADEON_TILING_MICRO)
if (ws_bo->tiling_flags) {
if (ws_bo->tiling_flags & RADEON_TILING_MICRO)
*array_mode = V_0280A0_ARRAY_1D_TILED_THIN1;
if ((bo->tiling_flags & (RADEON_TILING_MICRO | RADEON_TILING_MACRO)) ==
if ((ws_bo->tiling_flags & (RADEON_TILING_MICRO | RADEON_TILING_MACRO)) ==
(RADEON_TILING_MICRO | RADEON_TILING_MACRO))
*array_mode = V_0280A0_ARRAY_2D_TILED_THIN1;
} else {
*array_mode = 0;
}
}
return bo;
return ws_bo;
}
void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, void *ctx)
{
struct pipe_context *pctx = ctx;
if (usage & PB_USAGE_UNSYNCHRONIZED) {
radeon_bo_map(radeon, bo->bo);
return (uint8_t *) bo->bo->data + bo->offset;
}
if (p_atomic_read(&bo->bo->reference.count) > 1) {
if (usage & PB_USAGE_DONTBLOCK) {
return NULL;
}
if (ctx) {
pctx->flush(pctx, 0, NULL);
}
}
if (usage & PB_USAGE_DONTBLOCK) {
uint32_t domain;
if (radeon_bo_busy(radeon, bo->bo, &domain))
return NULL;
if (radeon_bo_map(radeon, bo->bo)) {
return NULL;
}
goto out;
}
radeon_bo_map(radeon, bo->bo);
if (radeon_bo_wait(radeon, bo->bo)) {
radeon_bo_unmap(radeon, bo->bo);
return NULL;
}
out:
return (uint8_t *) bo->bo->data + bo->offset;
return pb_map(bo->pb, usage, ctx);
}
void r600_bo_unmap(struct radeon *radeon, struct r600_bo *bo)
{
radeon_bo_unmap(radeon, bo->bo);
pb_unmap(bo->pb);
}
void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo)
static void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo)
{
if (bo->manager_id) {
if (!r600_bomgr_bo_destroy(radeon->bomgr, bo)) {
/* destroy is delayed by buffer manager */
return;
}
}
radeon_bo_reference(radeon, &bo->bo, NULL);
if (bo->pb)
pb_reference(&bo->pb, NULL);
free(bo);
}
void r600_bo_reference(struct radeon *radeon, struct r600_bo **dst, struct r600_bo *src)
void r600_bo_reference(struct radeon *radeon, struct r600_bo **dst,
struct r600_bo *src)
{
struct r600_bo *old = *dst;
if (pipe_reference(&(*dst)->reference, &src->reference)) {
r600_bo_destroy(radeon, old);
}
*dst = src;
}
boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *bo,
unsigned r600_bo_get_handle(struct r600_bo *pb_bo)
{
struct radeon_bo *bo;
bo = radeon_bo_pb_get_bo(pb_bo->pb);
if (!bo)
return 0;
return bo->handle;
}
unsigned r600_bo_get_size(struct r600_bo *pb_bo)
{
struct radeon_bo *bo;
bo = radeon_bo_pb_get_bo(pb_bo->pb);
if (!bo)
return 0;
return bo->size;
}
boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *pb_bo,
unsigned stride, struct winsys_handle *whandle)
{
struct radeon_bo *bo;
bo = radeon_bo_pb_get_bo(pb_bo->pb);
if (!bo)
return FALSE;
whandle->stride = stride;
switch(whandle->type) {
case DRM_API_HANDLE_TYPE_KMS:
whandle->handle = r600_bo_get_handle(bo);
whandle->handle = r600_bo_get_handle(pb_bo);
break;
case DRM_API_HANDLE_TYPE_SHARED:
if (radeon_bo_get_name(radeon, bo->bo, &whandle->handle))
if (radeon_bo_get_name(radeon, bo, &whandle->handle))
return FALSE;
break;
default:

View File

@@ -1,161 +0,0 @@
/*
* Copyright 2010 VMWare.
* Copyright 2010 Red Hat 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Jose Fonseca <jrfonseca-at-vmware-dot-com>
* Thomas Hellström <thomas-at-vmware-dot-com>
* Jerome Glisse <jglisse@redhat.com>
*/
#include <util/u_memory.h>
#include <util/u_double_list.h>
#include <util/u_time.h>
#include <pipebuffer/pb_bufmgr.h>
#include "r600_priv.h"
static void r600_bomgr_timeout_flush(struct r600_bomgr *mgr)
{
struct r600_bo *bo, *tmp;
int64_t now;
now = os_time_get();
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &mgr->delayed, list) {
if(!os_time_timeout(bo->start, bo->end, now))
break;
mgr->num_delayed--;
bo->manager_id = 0;
LIST_DEL(&bo->list);
r600_bo_destroy(mgr->radeon, bo);
}
}
static INLINE int r600_bo_is_compat(struct r600_bomgr *mgr,
struct r600_bo *bo,
unsigned size,
unsigned alignment,
unsigned cfence)
{
if(bo->size < size) {
return 0;
}
/* be lenient with size */
if(bo->size >= 2*size) {
return 0;
}
if(!pb_check_alignment(alignment, bo->alignment)) {
return 0;
}
if (!fence_is_after(cfence, bo->fence)) {
return 0;
}
return 1;
}
struct r600_bo *r600_bomgr_bo_create(struct r600_bomgr *mgr,
unsigned size,
unsigned alignment,
unsigned cfence)
{
struct r600_bo *bo, *tmp;
int64_t now;
pipe_mutex_lock(mgr->mutex);
now = os_time_get();
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &mgr->delayed, list) {
if(r600_bo_is_compat(mgr, bo, size, alignment, cfence)) {
LIST_DEL(&bo->list);
--mgr->num_delayed;
r600_bomgr_timeout_flush(mgr);
pipe_mutex_unlock(mgr->mutex);
LIST_INITHEAD(&bo->list);
pipe_reference_init(&bo->reference, 1);
return bo;
}
if(os_time_timeout(bo->start, bo->end, now)) {
mgr->num_delayed--;
bo->manager_id = 0;
LIST_DEL(&bo->list);
r600_bo_destroy(mgr->radeon, bo);
}
}
pipe_mutex_unlock(mgr->mutex);
return NULL;
}
void r600_bomgr_bo_init(struct r600_bomgr *mgr, struct r600_bo *bo)
{
LIST_INITHEAD(&bo->list);
bo->manager_id = 1;
}
bool r600_bomgr_bo_destroy(struct r600_bomgr *mgr, struct r600_bo *bo)
{
bo->start = os_time_get();
bo->end = bo->start + mgr->usecs;
pipe_mutex_lock(mgr->mutex);
LIST_ADDTAIL(&bo->list, &mgr->delayed);
++mgr->num_delayed;
pipe_mutex_unlock(mgr->mutex);
return FALSE;
}
void r600_bomgr_destroy(struct r600_bomgr *mgr)
{
struct r600_bo *bo, *tmp;
pipe_mutex_lock(mgr->mutex);
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &mgr->delayed, list) {
mgr->num_delayed--;
bo->manager_id = 0;
LIST_DEL(&bo->list);
r600_bo_destroy(mgr->radeon, bo);
}
pipe_mutex_unlock(mgr->mutex);
FREE(mgr);
}
struct r600_bomgr *r600_bomgr_create(struct radeon *radeon, unsigned usecs)
{
struct r600_bomgr *mgr;
mgr = CALLOC_STRUCT(r600_bomgr);
if (mgr == NULL)
return NULL;
mgr->radeon = radeon;
mgr->usecs = usecs;
LIST_INITHEAD(&mgr->delayed);
mgr->num_delayed = 0;
pipe_mutex_init(mgr->mutex);
return mgr;
}

View File

@@ -30,6 +30,7 @@
#include <sys/ioctl.h>
#include "util/u_inlines.h"
#include "util/u_debug.h"
#include <pipebuffer/pb_bufmgr.h>
#include "r600.h"
#include "r600_priv.h"
#include "r600_drm_public.h"
@@ -134,6 +135,59 @@ static struct radeon *radeon_new(int fd, unsigned device)
fprintf(stderr, "Unknown chipset 0x%04X\n", radeon->device);
return radeon_decref(radeon);
}
switch (radeon->family) {
case CHIP_R600:
case CHIP_RV610:
case CHIP_RV630:
case CHIP_RV670:
case CHIP_RV620:
case CHIP_RV635:
case CHIP_RS780:
case CHIP_RS880:
case CHIP_RV770:
case CHIP_RV730:
case CHIP_RV710:
case CHIP_RV740:
case CHIP_CEDAR:
case CHIP_REDWOOD:
case CHIP_JUNIPER:
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
case CHIP_PALM:
break;
case CHIP_R100:
case CHIP_RV100:
case CHIP_RS100:
case CHIP_RV200:
case CHIP_RS200:
case CHIP_R200:
case CHIP_RV250:
case CHIP_RS300:
case CHIP_RV280:
case CHIP_R300:
case CHIP_R350:
case CHIP_RV350:
case CHIP_RV380:
case CHIP_R420:
case CHIP_R423:
case CHIP_RV410:
case CHIP_RS400:
case CHIP_RS480:
case CHIP_RS600:
case CHIP_RS690:
case CHIP_RS740:
case CHIP_RV515:
case CHIP_R520:
case CHIP_RV530:
case CHIP_RV560:
case CHIP_RV570:
case CHIP_R580:
default:
fprintf(stderr, "%s unknown or unsupported chipset 0x%04X\n",
__func__, radeon->device);
break;
}
/* setup class */
switch (radeon->family) {
case CHIP_R600:
@@ -162,9 +216,6 @@ static struct radeon *radeon_new(int fd, unsigned device)
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
case CHIP_PALM:
case CHIP_BARTS:
case CHIP_TURKS:
case CHIP_CAICOS:
radeon->chip_class = EVERGREEN;
/* set default group bytes, overridden by tiling info ioctl */
radeon->tiling_info.group_bytes = 512;
@@ -179,10 +230,12 @@ static struct radeon *radeon_new(int fd, unsigned device)
if (radeon_drm_get_tiling(radeon))
return NULL;
}
radeon->bomgr = r600_bomgr_create(radeon, 1000000);
if (radeon->bomgr == NULL) {
radeon->kman = radeon_bo_pbmgr_create(radeon);
if (!radeon->kman)
return NULL;
radeon->cman = pb_cache_manager_create(radeon->kman, 1000000);
if (!radeon->cman)
return NULL;
}
return radeon;
}
@@ -199,8 +252,11 @@ struct radeon *radeon_decref(struct radeon *radeon)
return NULL;
}
if (radeon->bomgr)
r600_bomgr_destroy(radeon->bomgr);
if (radeon->cman)
radeon->cman->destroy(radeon->cman);
if (radeon->kman)
radeon->kman->destroy(radeon->kman);
if (radeon->fd >= 0)
drmClose(radeon->fd);

View File

@@ -28,15 +28,16 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <pipe/p_compiler.h>
#include <util/u_inlines.h>
#include <util/u_memory.h>
#include <pipebuffer/pb_bufmgr.h>
#include "xf86drm.h"
#include "radeon_drm.h"
#include "r600_priv.h"
#include "bof.h"
#include "r600.h"
#include "r600d.h"
#include "radeon_drm.h"
#include "bof.h"
#include "pipe/p_compiler.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include <pipebuffer/pb_bufmgr.h>
#include "r600_priv.h"
#define GROUP_FORCE_NEW_BLOCK 0
@@ -49,7 +50,6 @@ int r600_context_init_fence(struct r600_context *ctx)
}
ctx->cfence = r600_bo_map(ctx->radeon, ctx->fence_bo, PB_USAGE_UNSYNCHRONIZED, NULL);
*ctx->cfence = 0;
ctx->radeon->cfence = ctx->cfence;
LIST_INITHEAD(&ctx->fenced_bo);
return 0;
}
@@ -814,7 +814,6 @@ void r600_context_bo_reloc(struct r600_context *ctx, u32 *pm4, struct r600_bo *r
ctx->reloc[ctx->creloc].write_domain = rbo->domains & (RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM);
ctx->reloc[ctx->creloc].flags = 0;
radeon_bo_reference(ctx->radeon, &ctx->bo[ctx->creloc], bo);
rbo->fence = ctx->fence;
ctx->creloc++;
/* set PKT3 to point to proper reloc */
*pm4 = bo->reloc_id;
@@ -837,7 +836,6 @@ void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_stat
/* find relocation */
id = block->pm4_bo_index[id];
r600_bo_reference(ctx->radeon, &block->reloc[id].bo, state->regs[i].bo);
state->regs[i].bo->fence = ctx->fence;
}
if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
block->status |= R600_BLOCK_STATUS_ENABLED;
@@ -877,13 +875,10 @@ static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx
*/
r600_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[0].bo);
r600_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[0].bo);
state->regs[0].bo->fence = ctx->fence;
} else {
/* TEXTURE RESOURCE */
r600_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[2].bo);
r600_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[3].bo);
state->regs[2].bo->fence = ctx->fence;
state->regs[3].bo->fence = ctx->fence;
}
if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
block->status |= R600_BLOCK_STATUS_ENABLED;

View File

@@ -30,24 +30,24 @@
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <util/u_double_list.h>
#include <util/u_inlines.h>
#include <os/os_thread.h>
#include <pipebuffer/pb_bufmgr.h>
#include "util/u_double_list.h"
#include "r600.h"
struct r600_bomgr;
struct radeon {
int fd;
int refcount;
unsigned device;
unsigned family;
enum chip_class chip_class;
struct r600_tiling_info tiling_info;
struct r600_bomgr *bomgr;
unsigned *cfence;
struct pb_manager *kman; /* kernel bo manager */
struct pb_manager *cman; /* cached bo manager */
struct r600_tiling_info tiling_info;
};
struct radeon *r600_new(int fd, unsigned device);
void r600_delete(struct radeon *r600);
struct r600_reg {
unsigned opcode;
unsigned offset_base;
@@ -75,49 +75,25 @@ struct radeon_bo {
struct r600_bo {
struct pipe_reference reference;
struct pb_buffer *pb;
unsigned size;
unsigned tiling_flags;
unsigned kernel_pitch;
unsigned domains;
struct radeon_bo *bo;
unsigned fence;
/* manager data */
struct list_head list;
unsigned manager_id;
unsigned alignment;
unsigned offset;
int64_t start;
int64_t end;
};
struct r600_bomgr {
struct radeon *radeon;
unsigned usecs;
pipe_mutex mutex;
struct list_head delayed;
unsigned num_delayed;
};
/*
* r600_drm.c
*/
struct radeon *r600_new(int fd, unsigned device);
void r600_delete(struct radeon *r600);
/*
* radeon_pciid.c
*/
/* radeon_pciid.c */
unsigned radeon_family_from_device(unsigned device);
/*
* radeon_bo.c
*/
/* radeon_bo.c */
struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
unsigned size, unsigned alignment);
void radeon_bo_reference(struct radeon *radeon, struct radeon_bo **dst,
struct radeon_bo *src);
int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);
int radeon_bo_busy(struct radeon *radeon, struct radeon_bo *bo, uint32_t *domain);
void radeon_bo_pbmgr_flush_maps(struct pb_manager *_mgr);
int radeon_bo_fencelist(struct radeon *radeon, struct radeon_bo **bolist, uint32_t num_bo);
int radeon_bo_get_tiling_flags(struct radeon *radeon,
struct radeon_bo *bo,
@@ -127,9 +103,13 @@ int radeon_bo_get_name(struct radeon *radeon,
struct radeon_bo *bo,
uint32_t *name);
/*
* r600_hw_context.c
*/
/* radeon_bo_pb.c */
struct radeon_bo *radeon_bo_pb_get_bo(struct pb_buffer *_buf);
struct pb_manager *radeon_bo_pbmgr_create(struct radeon *radeon);
struct pb_buffer *radeon_bo_pb_create_buffer_from_handle(struct pb_manager *_mgr,
uint32_t handle);
/* r600_hw_context.c */
int r600_context_init_fence(struct r600_context *ctx);
void r600_context_bo_reloc(struct r600_context *ctx, u32 *pm4, struct r600_bo *rbo);
void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags,
@@ -137,27 +117,14 @@ void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags,
struct r600_bo *r600_context_reg_bo(struct r600_context *ctx, unsigned offset);
int r600_context_add_block(struct r600_context *ctx, const struct r600_reg *reg, unsigned nreg);
/*
* r600_bo.c
*/
void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo);
/* r600_bo.c */
unsigned r600_bo_get_handle(struct r600_bo *bo);
unsigned r600_bo_get_size(struct r600_bo *bo);
static INLINE struct radeon_bo *r600_bo_get_bo(struct r600_bo *bo)
{
return radeon_bo_pb_get_bo(bo->pb);
}
/*
* r600_bomgr.c
*/
struct r600_bomgr *r600_bomgr_create(struct radeon *radeon, unsigned usecs);
void r600_bomgr_destroy(struct r600_bomgr *mgr);
bool r600_bomgr_bo_destroy(struct r600_bomgr *mgr, struct r600_bo *bo);
void r600_bomgr_bo_init(struct r600_bomgr *mgr, struct r600_bo *bo);
struct r600_bo *r600_bomgr_bo_create(struct r600_bomgr *mgr,
unsigned size,
unsigned alignment,
unsigned cfence);
/*
* helpers
*/
#define CTX_RANGE_ID(ctx, offset) (((offset) >> (ctx)->hash_shift) & 255)
#define CTX_BLOCK_ID(ctx, offset) ((offset) & ((1 << (ctx)->hash_shift) - 1))
@@ -205,9 +172,6 @@ static inline void r600_context_block_emit_dirty(struct r600_context *ctx, struc
LIST_DELINIT(&block->list);
}
/*
* radeon_bo.c
*/
static inline int radeon_bo_map(struct radeon *radeon, struct radeon_bo *bo)
{
bo->map_count++;
@@ -220,35 +184,4 @@ static inline void radeon_bo_unmap(struct radeon *radeon, struct radeon_bo *bo)
assert(bo->map_count >= 0);
}
/*
* r600_bo
*/
static inline struct radeon_bo *r600_bo_get_bo(struct r600_bo *bo)
{
return bo->bo;
}
static unsigned inline r600_bo_get_handle(struct r600_bo *bo)
{
return bo->bo->handle;
}
static unsigned inline r600_bo_get_size(struct r600_bo *bo)
{
return bo->size;
}
/*
* fence
*/
static inline bool fence_is_after(unsigned fence, unsigned ofence)
{
/* handle wrap around */
if (fence < 0x80000000 && ofence > 0x80000000)
return TRUE;
if (fence > ofence)
return TRUE;
return FALSE;
}
#endif

View File

@@ -0,0 +1,260 @@
/*
* Copyright 2010 Dave Airlie
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Dave Airlie
*/
#include <util/u_inlines.h>
#include <util/u_memory.h>
#include <util/u_double_list.h>
#include <pipebuffer/pb_buffer.h>
#include <pipebuffer/pb_bufmgr.h>
#include "r600_priv.h"
struct radeon_bo_pb {
struct pb_buffer b;
struct radeon_bo *bo;
struct radeon_bo_pbmgr *mgr;
};
extern const struct pb_vtbl radeon_bo_pb_vtbl;
static INLINE struct radeon_bo_pb *radeon_bo_pb(struct pb_buffer *buf)
{
assert(buf);
assert(buf->vtbl == &radeon_bo_pb_vtbl);
return (struct radeon_bo_pb *)buf;
}
struct radeon_bo_pbmgr {
struct pb_manager b;
struct radeon *radeon;
};
static INLINE struct radeon_bo_pbmgr *radeon_bo_pbmgr(struct pb_manager *mgr)
{
assert(mgr);
return (struct radeon_bo_pbmgr *)mgr;
}
static void radeon_bo_pb_destroy(struct pb_buffer *_buf)
{
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
/* If this buffer is on the list of buffers to unmap,
* do the unmapping now.
*/
radeon_bo_unmap(buf->mgr->radeon, buf->bo);
radeon_bo_reference(buf->mgr->radeon, &buf->bo, NULL);
FREE(buf);
}
static void *
radeon_bo_pb_map_internal(struct pb_buffer *_buf,
unsigned flags, void *ctx)
{
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
struct pipe_context *pctx = ctx;
if (flags & PB_USAGE_UNSYNCHRONIZED) {
if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
}
return buf->bo->data;
}
if (p_atomic_read(&buf->bo->reference.count) > 1) {
if (flags & PB_USAGE_DONTBLOCK) {
return NULL;
}
if (ctx) {
pctx->flush(pctx, 0, NULL);
}
}
if (flags & PB_USAGE_DONTBLOCK) {
uint32_t domain;
if (radeon_bo_busy(buf->mgr->radeon, buf->bo, &domain))
return NULL;
if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
}
goto out;
}
if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
}
if (radeon_bo_wait(buf->mgr->radeon, buf->bo)) {
radeon_bo_unmap(buf->mgr->radeon, buf->bo);
return NULL;
}
out:
return buf->bo->data;
}
static void radeon_bo_pb_unmap_internal(struct pb_buffer *_buf)
{
}
static void
radeon_bo_pb_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset)
{
*base_buf = buf;
*offset = 0;
}
static enum pipe_error
radeon_bo_pb_validate(struct pb_buffer *_buf,
struct pb_validate *vl,
unsigned flags)
{
/* Always pinned */
return PIPE_OK;
}
static void
radeon_bo_pb_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence)
{
}
const struct pb_vtbl radeon_bo_pb_vtbl = {
radeon_bo_pb_destroy,
radeon_bo_pb_map_internal,
radeon_bo_pb_unmap_internal,
radeon_bo_pb_validate,
radeon_bo_pb_fence,
radeon_bo_pb_get_base_buffer,
};
struct pb_buffer *
radeon_bo_pb_create_buffer_from_handle(struct pb_manager *_mgr,
uint32_t handle)
{
struct radeon_bo_pbmgr *mgr = radeon_bo_pbmgr(_mgr);
struct radeon *radeon = mgr->radeon;
struct radeon_bo_pb *bo;
struct radeon_bo *hw_bo;
hw_bo = radeon_bo(radeon, handle, 0, 0);
if (hw_bo == NULL)
return NULL;
bo = CALLOC_STRUCT(radeon_bo_pb);
if (!bo) {
radeon_bo_reference(radeon, &hw_bo, NULL);
return NULL;
}
pipe_reference_init(&bo->b.base.reference, 1);
bo->b.base.alignment = 0;
bo->b.base.usage = PB_USAGE_GPU_WRITE | PB_USAGE_GPU_READ;
bo->b.base.size = hw_bo->size;
bo->b.vtbl = &radeon_bo_pb_vtbl;
bo->mgr = mgr;
bo->bo = hw_bo;
return &bo->b;
}
static struct pb_buffer *
radeon_bo_pb_create_buffer(struct pb_manager *_mgr,
pb_size size,
const struct pb_desc *desc)
{
struct radeon_bo_pbmgr *mgr = radeon_bo_pbmgr(_mgr);
struct radeon *radeon = mgr->radeon;
struct radeon_bo_pb *bo;
bo = CALLOC_STRUCT(radeon_bo_pb);
if (!bo)
goto error1;
pipe_reference_init(&bo->b.base.reference, 1);
bo->b.base.alignment = desc->alignment;
bo->b.base.usage = desc->usage;
bo->b.base.size = size;
bo->b.vtbl = &radeon_bo_pb_vtbl;
bo->mgr = mgr;
bo->bo = radeon_bo(radeon, 0, size, desc->alignment);
if (bo->bo == NULL)
goto error2;
return &bo->b;
error2:
FREE(bo);
error1:
return NULL;
}
static void
radeon_bo_pbmgr_flush(struct pb_manager *mgr)
{
/* NOP */
}
static void
radeon_bo_pbmgr_destroy(struct pb_manager *_mgr)
{
struct radeon_bo_pbmgr *mgr = radeon_bo_pbmgr(_mgr);
FREE(mgr);
}
struct pb_manager *radeon_bo_pbmgr_create(struct radeon *radeon)
{
struct radeon_bo_pbmgr *mgr;
mgr = CALLOC_STRUCT(radeon_bo_pbmgr);
if (!mgr)
return NULL;
mgr->b.destroy = radeon_bo_pbmgr_destroy;
mgr->b.create_buffer = radeon_bo_pb_create_buffer;
mgr->b.flush = radeon_bo_pbmgr_flush;
mgr->radeon = radeon;
return &mgr->b;
}
struct radeon_bo *radeon_bo_pb_get_bo(struct pb_buffer *_buf)
{
struct radeon_bo_pb *buf;
if (_buf->vtbl == &radeon_bo_pb_vtbl) {
buf = radeon_bo_pb(_buf);
return buf->bo;
} else {
struct pb_buffer *base_buf;
pb_size offset;
pb_get_base_buffer(_buf, &base_buf, &offset);
if (base_buf->vtbl == &radeon_bo_pb_vtbl) {
buf = radeon_bo_pb(base_buf);
return buf->bo;
}
}
return NULL;
}

View File

@@ -445,42 +445,6 @@ struct pci_id radeon_pci_id[] = {
{0x1002, 0x9803, CHIP_PALM},
{0x1002, 0x9804, CHIP_PALM},
{0x1002, 0x9805, CHIP_PALM},
{0x1002, 0x6720, CHIP_BARTS},
{0x1002, 0x6721, CHIP_BARTS},
{0x1002, 0x6722, CHIP_BARTS},
{0x1002, 0x6723, CHIP_BARTS},
{0x1002, 0x6724, CHIP_BARTS},
{0x1002, 0x6725, CHIP_BARTS},
{0x1002, 0x6726, CHIP_BARTS},
{0x1002, 0x6727, CHIP_BARTS},
{0x1002, 0x6728, CHIP_BARTS},
{0x1002, 0x6729, CHIP_BARTS},
{0x1002, 0x6738, CHIP_BARTS},
{0x1002, 0x6739, CHIP_BARTS},
{0x1002, 0x6740, CHIP_TURKS},
{0x1002, 0x6741, CHIP_TURKS},
{0x1002, 0x6742, CHIP_TURKS},
{0x1002, 0x6743, CHIP_TURKS},
{0x1002, 0x6744, CHIP_TURKS},
{0x1002, 0x6745, CHIP_TURKS},
{0x1002, 0x6746, CHIP_TURKS},
{0x1002, 0x6747, CHIP_TURKS},
{0x1002, 0x6748, CHIP_TURKS},
{0x1002, 0x6749, CHIP_TURKS},
{0x1002, 0x6750, CHIP_TURKS},
{0x1002, 0x6758, CHIP_TURKS},
{0x1002, 0x6759, CHIP_TURKS},
{0x1002, 0x6760, CHIP_CAICOS},
{0x1002, 0x6761, CHIP_CAICOS},
{0x1002, 0x6762, CHIP_CAICOS},
{0x1002, 0x6763, CHIP_CAICOS},
{0x1002, 0x6764, CHIP_CAICOS},
{0x1002, 0x6765, CHIP_CAICOS},
{0x1002, 0x6766, CHIP_CAICOS},
{0x1002, 0x6767, CHIP_CAICOS},
{0x1002, 0x6768, CHIP_CAICOS},
{0x1002, 0x6770, CHIP_CAICOS},
{0x1002, 0x6779, CHIP_CAICOS},
{0, 0},
};

View File

@@ -0,0 +1,39 @@
ifeq ($(strip $(MESA_BUILD_VMWGFX)),true)
LOCAL_PATH := $(call my-dir)
# from drm/Makefile
C_SOURCES = \
vmw_buffer.c \
vmw_context.c \
vmw_fence.c \
vmw_screen.c \
vmw_screen_dri.c \
vmw_screen_ioctl.c \
vmw_screen_pools.c \
vmw_screen_svga.c \
vmw_surface.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(addprefix drm/, $(C_SOURCES))
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary \
external/mesa/src/gallium/drivers/svga \
external/mesa/src/gallium/drivers/svga/include \
external/drm \
external/drm/include/drm
LOCAL_MODULE := libmesa_winsys_svga
include $(BUILD_STATIC_LIBRARY)
endif # MESA_BUILD_VMWGFX

View File

@@ -46,6 +46,24 @@
#include <errno.h>
#include <unistd.h>
#ifdef PIPE_OS_ANDROID
extern void* __mmap2(void*, size_t, int, int, int, size_t);
#define MMAP2_SHIFT 12
static INLINE void* vmw_mmap(void *addr, size_t size, int prot, int flags, int fd, unsigned long long offset)
{
if ( offset & ((1UL << MMAP2_SHIFT)-1) ) {
errno = EINVAL;
return MAP_FAILED;
}
return __mmap2(addr, size, prot, flags, fd, (size_t)(offset >> MMAP2_SHIFT));
}
#else
#define vmw_mmap(addr, size, prot, flags, fd, offset) mmap(addr, size, prot, flags, fd, offset)
#endif
struct vmw_region
{
SVGAGuestPtr ptr;
@@ -106,7 +124,7 @@ vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws,
VMW_FUNC;
map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED,
map = vmw_mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED,
vws->ioctl.drm_fd, fifo_offset);
if (map == MAP_FAILED) {
@@ -388,7 +406,7 @@ vmw_ioctl_region_map(struct vmw_region *region)
region->ptr.gmrId, region->ptr.offset);
if (region->data == NULL) {
map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
map = vmw_mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
region->drm_fd, region->map_handle);
if (map == MAP_FAILED) {
debug_printf("%s: Map failed.\n", __FUNCTION__);

View File

@@ -0,0 +1,19 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
android/android_sw_winsys.cpp
LOCAL_CFLAGS := \
-fvisibility=hidden \
-Wno-sign-compare
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/gallium/include \
external/mesa/src/gallium/auxiliary
LOCAL_MODULE := libmesa_winsys_sw
include $(BUILD_STATIC_LIBRARY)

View File

@@ -0,0 +1,269 @@
/*
* Mesa 3-D graphics library
* Version: 7.9
*
* Copyright (C) 2010 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.
*
* Authors:
* Chia-I Wu <olv@lunarg.com>
*/
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "util/u_memory.h"
#include "util/u_format.h"
#include "state_tracker/sw_winsys.h"
#include <ui/PixelFormat.h>
#include <private/ui/sw_gralloc_handle.h>
#include <hardware/gralloc.h>
#include "android_sw_winsys.h"
struct android_sw_winsys
{
struct sw_winsys base;
const gralloc_module_t *grmod;
};
struct android_sw_displaytarget
{
buffer_handle_t handle;
int stride;
int width, height, usage;
void *mapped;
};
static INLINE struct android_sw_winsys *
android_sw_winsys(struct sw_winsys *ws)
{
return (struct android_sw_winsys *) ws;
}
static INLINE struct android_sw_displaytarget *
android_sw_displaytarget(struct sw_displaytarget *dt)
{
return (struct android_sw_displaytarget *) dt;
}
namespace android {
static void
android_displaytarget_display(struct sw_winsys *ws,
struct sw_displaytarget *dt,
void *context_private)
{
}
static struct sw_displaytarget *
android_displaytarget_create(struct sw_winsys *ws,
unsigned tex_usage,
enum pipe_format format,
unsigned width, unsigned height,
unsigned alignment,
unsigned *stride)
{
return NULL;
}
static void
android_displaytarget_destroy(struct sw_winsys *ws,
struct sw_displaytarget *dt)
{
struct android_sw_displaytarget *adt = android_sw_displaytarget(dt);
assert(!adt->mapped);
FREE(adt);
}
static void
android_displaytarget_unmap(struct sw_winsys *ws,
struct sw_displaytarget *dt)
{
struct android_sw_winsys *droid = android_sw_winsys(ws);
struct android_sw_displaytarget *adt = android_sw_displaytarget(dt);
if (adt->mapped) {
if (sw_gralloc_handle_t::validate(adt->handle) >= 0) {
adt->mapped = NULL;
}
else {
droid->grmod->unlock(droid->grmod, adt->handle);
adt->mapped = NULL;
}
}
}
static void *
android_displaytarget_map(struct sw_winsys *ws,
struct sw_displaytarget *dt,
unsigned flags)
{
struct android_sw_winsys *droid = android_sw_winsys(ws);
struct android_sw_displaytarget *adt = android_sw_displaytarget(dt);
if (!adt->mapped) {
if (sw_gralloc_handle_t::validate(adt->handle) >= 0) {
const sw_gralloc_handle_t *swhandle =
reinterpret_cast<const sw_gralloc_handle_t *>(adt->handle);
adt->mapped = reinterpret_cast<void *>(swhandle->base);
}
else {
droid->grmod->lock(droid->grmod, adt->handle,
adt->usage, 0, 0, adt->width, adt->height, &adt->mapped);
}
}
return adt->mapped;
}
static struct sw_displaytarget *
android_displaytarget_from_handle(struct sw_winsys *ws,
const struct pipe_resource *templ,
struct winsys_handle *whandle,
unsigned *stride)
{
struct android_winsys_handle *ahandle =
(struct android_winsys_handle *) whandle;
struct android_sw_displaytarget *adt;
adt = CALLOC_STRUCT(android_sw_displaytarget);
if (!adt)
return NULL;
adt->handle = ahandle->handle;
adt->stride = ahandle->stride;
adt->width = templ->width0;
adt->height = templ->height0;
if (templ->usage & PIPE_BIND_RENDER_TARGET)
adt->usage |= GRALLOC_USAGE_HW_RENDER;
if (templ->usage & PIPE_BIND_SAMPLER_VIEW)
adt->usage |= GRALLOC_USAGE_HW_TEXTURE;
if (templ->usage & PIPE_BIND_SCANOUT)
adt->usage |= GRALLOC_USAGE_HW_FB;
if (templ->usage & PIPE_BIND_TRANSFER_READ)
adt->usage |= GRALLOC_USAGE_SW_READ_OFTEN;
if (templ->usage & PIPE_BIND_TRANSFER_WRITE)
adt->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;
if (stride)
*stride = adt->stride;
return reinterpret_cast<struct sw_displaytarget *>(adt);
}
static boolean
android_displaytarget_get_handle(struct sw_winsys *ws,
struct sw_displaytarget *dt,
struct winsys_handle *whandle)
{
return FALSE;
}
static boolean
android_is_displaytarget_format_supported(struct sw_winsys *ws,
unsigned tex_usage,
enum pipe_format format)
{
struct android_sw_winsys *droid = android_sw_winsys(ws);
int fmt;
switch (format) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
fmt = PIXEL_FORMAT_RGBA_8888;
break;
case PIPE_FORMAT_R8G8B8X8_UNORM:
fmt = PIXEL_FORMAT_RGBX_8888;
break;
case PIPE_FORMAT_R8G8B8_UNORM:
fmt = PIXEL_FORMAT_RGB_888;
break;
case PIPE_FORMAT_B5G6R5_UNORM:
fmt = PIXEL_FORMAT_RGB_565;
break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
fmt = PIXEL_FORMAT_BGRA_8888;
break;
case PIPE_FORMAT_A8_UNORM:
fmt = PIXEL_FORMAT_A_8;
break;
case PIPE_FORMAT_L8_UNORM:
fmt = PIXEL_FORMAT_L_8;
break;
case PIPE_FORMAT_L8A8_UNORM:
fmt = PIXEL_FORMAT_LA_88;
break;
default:
fmt = PIXEL_FORMAT_NONE;
break;
}
return (fmt != PIXEL_FORMAT_NONE);
}
static void
android_destroy(struct sw_winsys *ws)
{
struct android_sw_winsys *droid = android_sw_winsys(ws);
FREE(droid);
}
}; /* namespace android */
using namespace android;
struct sw_winsys *
android_create_sw_winsys(void)
{
struct android_sw_winsys *droid;
const hw_module_t *mod;
droid = CALLOC_STRUCT(android_sw_winsys);
if (!droid)
return NULL;
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod)) {
FREE(droid);
return NULL;
}
droid->grmod = (const gralloc_module_t *) mod;
droid->base.destroy = android_destroy;
droid->base.is_displaytarget_format_supported =
android_is_displaytarget_format_supported;
droid->base.displaytarget_create = android_displaytarget_create;
droid->base.displaytarget_destroy = android_displaytarget_destroy;
droid->base.displaytarget_from_handle = android_displaytarget_from_handle;
droid->base.displaytarget_get_handle = android_displaytarget_get_handle;
droid->base.displaytarget_map = android_displaytarget_map;
droid->base.displaytarget_unmap = android_displaytarget_unmap;
droid->base.displaytarget_display = android_displaytarget_display;
return &droid->base;
}

View File

@@ -0,0 +1,49 @@
/*
* Mesa 3-D graphics library
* Version: 7.9
*
* Copyright (C) 2010 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.
*
* Authors:
* Chia-I Wu <olv@lunarg.com>
*/
#ifndef ANDROID_SW_WINSYS
#define ANDROID_SW_WINSYS
#include <sys/cdefs.h>
#include <hardware/gralloc.h>
__BEGIN_DECLS
struct sw_winsys;
struct android_winsys_handle {
buffer_handle_t handle;
int stride;
};
struct sw_winsys *
android_create_sw_winsys(void);
__END_DECLS
#endif /* ANDROID_SW_WINSYS */

96
src/glsl/Android.mk Normal file
View File

@@ -0,0 +1,96 @@
LOCAL_PATH := $(call my-dir)
# from Makefile
LIBGLCPP_SOURCES = \
glcpp/glcpp-lex.c \
glcpp/glcpp-parse.c \
glcpp/pp.c
C_SOURCES = \
$(LIBGLCPP_SOURCES)
CXX_SOURCES = \
ast_expr.cpp \
ast_function.cpp \
ast_to_hir.cpp \
ast_type.cpp \
builtin_function.cpp \
glsl_lexer.cpp \
glsl_parser.cpp \
glsl_parser_extras.cpp \
glsl_types.cpp \
glsl_symbol_table.cpp \
hir_field_selection.cpp \
ir_basic_block.cpp \
ir_clone.cpp \
ir_constant_expression.cpp \
ir.cpp \
ir_expression_flattening.cpp \
ir_function_can_inline.cpp \
ir_function.cpp \
ir_hierarchical_visitor.cpp \
ir_hv_accept.cpp \
ir_import_prototypes.cpp \
ir_print_visitor.cpp \
ir_reader.cpp \
ir_rvalue_visitor.cpp \
ir_set_program_inouts.cpp \
ir_validate.cpp \
ir_variable.cpp \
ir_variable_refcount.cpp \
linker.cpp \
link_functions.cpp \
loop_analysis.cpp \
loop_controls.cpp \
loop_unroll.cpp \
lower_discard.cpp \
lower_if_to_cond_assign.cpp \
lower_instructions.cpp \
lower_jumps.cpp \
lower_mat_op_to_vec.cpp \
lower_noise.cpp \
lower_texture_projection.cpp \
lower_variable_index_to_cond_assign.cpp \
lower_vec_index_to_cond_assign.cpp \
lower_vec_index_to_swizzle.cpp \
lower_vector.cpp \
opt_algebraic.cpp \
opt_constant_folding.cpp \
opt_constant_propagation.cpp \
opt_constant_variable.cpp \
opt_copy_propagation.cpp \
opt_dead_code.cpp \
opt_dead_code_local.cpp \
opt_dead_functions.cpp \
opt_discard_simplification.cpp \
opt_function_inlining.cpp \
opt_if_simplification.cpp \
opt_noop_swizzle.cpp \
opt_redundant_jumps.cpp \
opt_structure_splitting.cpp \
opt_swizzle_swizzle.cpp \
opt_tree_grafting.cpp \
s_expression.cpp
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(C_SOURCES) \
$(CXX_SOURCES)
LOCAL_CFLAGS := \
-DPTHREADS \
-fvisibility=hidden \
-Wno-sign-compare \
-Wno-error=non-virtual-dtor \
-Wno-non-virtual-dtor
LOCAL_C_INCLUDES := \
external/mesa/include \
external/mesa/src/mapi \
external/mesa/src/talloc \
external/mesa/src/mesa
LOCAL_MODULE := libmesa_glsl
include $(BUILD_STATIC_LIBRARY)

View File

@@ -16,7 +16,6 @@ GLCPP_SOURCES = \
glcpp/glcpp.c
C_SOURCES = \
strtod.c \
$(LIBGLCPP_SOURCES)
CXX_SOURCES = \

View File

@@ -76,7 +76,6 @@ sources = [
'opt_swizzle_swizzle.cpp',
'opt_tree_grafting.cpp',
's_expression.cpp',
'strtod.c',
]
glsl = env.ConvenienceLibrary(

View File

@@ -129,6 +129,7 @@ protected:
* be created.
*/
ast_node(void);
virtual ~ast_node() {}
};

View File

@@ -1567,38 +1567,18 @@ ast_expression::hir(exec_list *instructions,
}
}
/* From page 23 (29 of the PDF) of the GLSL 1.30 spec:
*
/* From section 4.1.7 of the GLSL 1.30 spec:
* "Samplers aggregated into arrays within a shader (using square
* brackets [ ]) can only be indexed with integral constant
* expressions [...]."
*
* This restriction was added in GLSL 1.30. Shaders using earlier version
* of the language should not be rejected by the compiler front-end for
* using this construct. This allows useful things such as using a loop
* counter as the index to an array of samplers. If the loop in unrolled,
* the code should compile correctly. Instead, emit a warning.
*/
if (array->type->is_array() &&
array->type->element_type()->is_sampler() &&
const_index == NULL) {
if (state->language_version == 100) {
_mesa_glsl_warning(&loc, state,
"sampler arrays indexed with non-constant "
"expressions is optional in GLSL ES 1.00");
} else if (state->language_version < 130) {
_mesa_glsl_warning(&loc, state,
"sampler arrays indexed with non-constant "
"expressions is forbidden in GLSL 1.30 and "
"later");
} else {
_mesa_glsl_error(&loc, state,
"sampler arrays indexed with non-constant "
"expressions is forbidden in GLSL 1.30 and "
"later");
error_emitted = true;
}
_mesa_glsl_error(&loc, state, "sampler arrays can only be indexed "
"with constant expressions");
error_emitted = true;
}
if (error_emitted)
@@ -2262,17 +2242,6 @@ ast_declarator_list::hir(exec_list *instructions,
if (this->type->qualifier.flags.q.constant)
var->read_only = false;
/* Never emit code to initialize a uniform.
*/
const glsl_type *initializer_type;
if (!this->type->qualifier.flags.q.uniform) {
result = do_assignment(&initializer_instructions, state,
lhs, rhs,
this->get_location());
initializer_type = result->type;
} else
initializer_type = rhs->type;
/* If the declared variable is an unsized array, it must inherrit
* its full type from the initializer. A declaration such as
*
@@ -2287,14 +2256,16 @@ ast_declarator_list::hir(exec_list *instructions,
*
* If the declared variable is not an array, the types must
* already match exactly. As a result, the type assignment
* here can be done unconditionally. For non-uniforms the call
* to do_assignment can change the type of the initializer (via
* the implicit conversion rules). For uniforms the initializer
* must be a constant expression, and the type of that expression
* was validated above.
* here can be done unconditionally.
*/
var->type = initializer_type;
var->type = rhs->type;
/* Never emit code to initialize a uniform.
*/
if (!this->type->qualifier.flags.q.uniform)
result = do_assignment(&initializer_instructions, state,
lhs, rhs,
this->get_location());
var->read_only = temp;
}
}

View File

@@ -3010,26 +3010,40 @@ static const char builtin_smoothstep[] =
" (declare (in) float edge1)\n"
" (declare (in) float x))\n"
" ((declare () float t)\n"
"\n"
" (assign (constant bool (1)) (x) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.0)) (expression float * (constant float (2.0)) (var_ref t))))))))\n"
" (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n"
"\n"
" (signature vec2\n"
" (parameters\n"
" (declare (in) float edge0)\n"
" (declare (in) float edge1)\n"
" (declare (in) vec2 x))\n"
" ((declare () vec2 t)\n"
" (assign (constant bool (1)) (xy) (var_ref t)\n"
" (expression vec2 max\n"
" (expression vec2 min\n"
" (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (declare () vec2 retval)\n"
"\n"
" (assign (constant bool (1)) (x) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t))))))))\n"
" (assign (constant bool (1)) (x) (var_ref retval) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n"
"\n"
" (assign (constant bool (1)) (y) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (assign (constant bool (1)) (y) (var_ref retval) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n"
" (return (var_ref retval))\n"
" ))\n"
"\n"
" (signature vec3\n"
" (parameters\n"
@@ -3037,13 +3051,33 @@ static const char builtin_smoothstep[] =
" (declare (in) float edge1)\n"
" (declare (in) vec3 x))\n"
" ((declare () vec3 t)\n"
" (assign (constant bool (1)) (xyz) (var_ref t)\n"
" (expression vec3 max\n"
" (expression vec3 min\n"
" (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (declare () vec3 retval)\n"
"\n"
" (assign (constant bool (1)) (x) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t))))))))\n"
" (assign (constant bool (1)) (x) (var_ref retval) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n"
"\n"
" (assign (constant bool (1)) (y) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (assign (constant bool (1)) (y) (var_ref retval) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n"
"\n"
" (assign (constant bool (1)) (z) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (assign (constant bool (1)) (z) (var_ref retval) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n"
" (return (var_ref retval))\n"
" ))\n"
"\n"
"\n"
" (signature vec4\n"
@@ -3052,55 +3086,74 @@ static const char builtin_smoothstep[] =
" (declare (in) float edge1)\n"
" (declare (in) vec4 x))\n"
" ((declare () vec4 t)\n"
" (assign (constant bool (1)) (xyzw) (var_ref t)\n"
" (expression vec4 max\n"
" (expression vec4 min\n"
" (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (declare () vec4 retval)\n"
"\n"
" (assign (constant bool (1)) (x) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t))))))))\n"
" (assign (constant bool (1)) (x) (var_ref retval) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n"
"\n"
" (assign (constant bool (1)) (y) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (assign (constant bool (1)) (y) (var_ref retval) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n"
"\n"
" (assign (constant bool (1)) (z) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (assign (constant bool (1)) (z) (var_ref retval) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n"
"\n"
" (assign (constant bool (1)) (w) (var_ref t)\n"
" (expression float max\n"
" (expression float min\n"
" (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (assign (constant bool (1)) (w) (var_ref retval) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n"
" (return (var_ref retval))\n"
" ))\n"
"\n"
" (signature vec2\n"
" (parameters\n"
" (declare (in) vec2 edge0)\n"
" (declare (in) vec2 edge1)\n"
" (declare (in) vec2 x))\n"
" ((declare () vec2 t)\n"
" (assign (constant bool (1)) (xy) (var_ref t)\n"
" (expression vec2 max\n"
" ((return (expression vec2 max\n"
" (expression vec2 min\n"
" (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t))))))))\n"
" (constant vec2 (1.0 1.0)))\n"
" (constant vec2 (0.0 0.0))))))\n"
"\n"
" (signature vec3\n"
" (parameters\n"
" (declare (in) vec3 edge0)\n"
" (declare (in) vec3 edge1)\n"
" (declare (in) vec3 x))\n"
" ((declare () vec3 t)\n"
" (assign (constant bool (1)) (xyz) (var_ref t)\n"
" (expression vec3 max\n"
" ((return (expression vec3 max\n"
" (expression vec3 min\n"
" (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t))))))))\n"
" (constant vec3 (1.0 1.0 1.0)))\n"
" (constant vec3 (0.0 0.0 0.0))))))\n"
"\n"
" (signature vec4\n"
" (parameters\n"
" (declare (in) vec4 edge0)\n"
" (declare (in) vec4 edge1)\n"
" (declare (in) vec4 x))\n"
" ((declare () vec4 t)\n"
" (assign (constant bool (1)) (xyzw) (var_ref t)\n"
" (expression vec4 max\n"
" ((return (expression vec4 max\n"
" (expression vec4 min\n"
" (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))\n"
" (constant float (1.0)))\n"
" (constant float (0.0))))\n"
" (return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t))))))))\n"
" (constant vec4 (1.0 1.0 1.0 1.0)))\n"
" (constant vec4 (0.0 0.0 0.0 0.0))))))\n"
"))\n"
"\n"
""

View File

@@ -5,26 +5,40 @@
(declare (in) float edge1)
(declare (in) float x))
((declare () float t)
(assign (constant bool (1)) (x) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.0)) (expression float * (constant float (2.0)) (var_ref t))))))))
(return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))
(signature vec2
(parameters
(declare (in) float edge0)
(declare (in) float edge1)
(declare (in) vec2 x))
((declare () vec2 t)
(assign (constant bool (1)) (xy) (var_ref t)
(expression vec2 max
(expression vec2 min
(expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(declare () vec2 retval)
(assign (constant bool (1)) (x) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t))))))))
(assign (constant bool (1)) (x) (var_ref retval) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))
(assign (constant bool (1)) (y) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(assign (constant bool (1)) (y) (var_ref retval) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))
(return (var_ref retval))
))
(signature vec3
(parameters
@@ -32,13 +46,33 @@
(declare (in) float edge1)
(declare (in) vec3 x))
((declare () vec3 t)
(assign (constant bool (1)) (xyz) (var_ref t)
(expression vec3 max
(expression vec3 min
(expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(declare () vec3 retval)
(assign (constant bool (1)) (x) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t))))))))
(assign (constant bool (1)) (x) (var_ref retval) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))
(assign (constant bool (1)) (y) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(assign (constant bool (1)) (y) (var_ref retval) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))
(assign (constant bool (1)) (z) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(assign (constant bool (1)) (z) (var_ref retval) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))
(return (var_ref retval))
))
(signature vec4
@@ -47,54 +81,73 @@
(declare (in) float edge1)
(declare (in) vec4 x))
((declare () vec4 t)
(assign (constant bool (1)) (xyzw) (var_ref t)
(expression vec4 max
(expression vec4 min
(expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(declare () vec4 retval)
(assign (constant bool (1)) (x) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t))))))))
(assign (constant bool (1)) (x) (var_ref retval) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))
(assign (constant bool (1)) (y) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(assign (constant bool (1)) (y) (var_ref retval) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))
(assign (constant bool (1)) (z) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(assign (constant bool (1)) (z) (var_ref retval) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))
(assign (constant bool (1)) (w) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(assign (constant bool (1)) (w) (var_ref retval) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))
(return (var_ref retval))
))
(signature vec2
(parameters
(declare (in) vec2 edge0)
(declare (in) vec2 edge1)
(declare (in) vec2 x))
((declare () vec2 t)
(assign (constant bool (1)) (xy) (var_ref t)
(expression vec2 max
((return (expression vec2 max
(expression vec2 min
(expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t))))))))
(constant vec2 (1.0 1.0)))
(constant vec2 (0.0 0.0))))))
(signature vec3
(parameters
(declare (in) vec3 edge0)
(declare (in) vec3 edge1)
(declare (in) vec3 x))
((declare () vec3 t)
(assign (constant bool (1)) (xyz) (var_ref t)
(expression vec3 max
((return (expression vec3 max
(expression vec3 min
(expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t))))))))
(constant vec3 (1.0 1.0 1.0)))
(constant vec3 (0.0 0.0 0.0))))))
(signature vec4
(parameters
(declare (in) vec4 edge0)
(declare (in) vec4 edge1)
(declare (in) vec4 x))
((declare () vec4 t)
(assign (constant bool (1)) (xyzw) (var_ref t)
(expression vec4 max
((return (expression vec4 max
(expression vec4 min
(expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))
(constant float (1.0)))
(constant float (0.0))))
(return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t))))))))
(constant vec4 (1.0 1.0 1.0 1.0)))
(constant vec4 (0.0 0.0 0.0 0.0))))))
))

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,6 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <ctype.h>
#include "strtod.h"
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
@@ -294,23 +293,23 @@ layout {
}
[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
yylval->real = glsl_strtod(yytext, NULL);
yylval->real = strtod(yytext, NULL);
return FLOATCONSTANT;
}
\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
yylval->real = glsl_strtod(yytext, NULL);
yylval->real = strtod(yytext, NULL);
return FLOATCONSTANT;
}
[0-9]+\.([eE][+-]?[0-9]+)?[fF]? {
yylval->real = glsl_strtod(yytext, NULL);
yylval->real = strtod(yytext, NULL);
return FLOATCONSTANT;
}
[0-9]+[eE][+-]?[0-9]+[fF]? {
yylval->real = glsl_strtod(yytext, NULL);
yylval->real = strtod(yytext, NULL);
return FLOATCONSTANT;
}
[0-9]+[fF] {
yylval->real = glsl_strtod(yytext, NULL);
yylval->real = strtod(yytext, NULL);
return FLOATCONSTANT;
}

View File

@@ -131,6 +131,7 @@ protected:
ir_type = ir_type_unset;
type = NULL;
}
virtual ~ir_instruction() {}
};

View File

@@ -77,6 +77,7 @@ enum ir_visitor_status {
class ir_hierarchical_visitor {
public:
ir_hierarchical_visitor();
virtual ~ir_hierarchical_visitor() {}
/**
* \name Visit methods for leaf-node classes

View File

@@ -53,7 +53,7 @@ bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lo
bool do_lower_texture_projection(exec_list *instructions);
bool do_if_simplification(exec_list *instructions);
bool do_discard_simplification(exec_list *instructions);
bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0);
bool do_if_to_cond_assign(exec_list *instructions);
bool do_mat_op_to_vec(exec_list *instructions);
bool do_mod_to_fract(exec_list *instructions);
bool do_noop_swizzle(exec_list *instructions);

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