OSDN Git Service

android-x86/external-swiftshader.git
6 years agoImplement missing depth/stencil formats.
Nicolas Capens [Thu, 14 Dec 2017 03:25:04 +0000 (22:25 -0500)]
Implement missing depth/stencil formats.

Several depth-only formats were implemented using depth+stencil
formats. This resulted in unintended stencil operations happening, as
well as unnecessary allocations and blitting of stencil data.

This change also introduces quad-layout depth+stencil formats for more
efficient rendering.

Note that as before the 'internal' buffer's format also indicates the
presence of a stencil component, even though it only stores the depth
component, while the 'stencil' buffer now has an S8 format or NULL for
a depth-only format.

Change-Id: I245f0cb5a999851e24082f3ab1ea78a5f5956af3
Reviewed-on: https://swiftshader-review.googlesource.com/14988
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDefault drawBuffer/readBuffer for non default Framebuffer
Alexis Hetu [Tue, 12 Dec 2017 21:37:06 +0000 (16:37 -0500)]
Default drawBuffer/readBuffer for non default Framebuffer

drawBuffer and readBuffer default to GL_BACK in the default
Framebuffer, but for all other Framebuffer objects, the
default value should have been GL_COLOR_ATTACHMENT0.

Fixes all failures in dEQP-GLES3.functional.state_query.integers*

Change-Id: I060db67c50561d2678d57de1d7067bd7f8d2a53a
Reviewed-on: https://swiftshader-review.googlesource.com/14948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed GL_VERTEX_ATTRIB_ARRAY_INTEGER queries
Alexis Hetu [Mon, 11 Dec 2017 20:19:36 +0000 (15:19 -0500)]
Fixed GL_VERTEX_ATTRIB_ARRAY_INTEGER queries

Added pureInteger member to VertexAttribute in order
to keep track of whether the attrib was set using
glVertexAttribIPointer or glVertexAttribPointer and
properly return that state when querying
GL_VERTEX_ATTRIB_ARRAY_INTEGER.

Fixes dEQP-GLES3.functional.state_query.shader.vertex_attrib_integer

Change-Id: Ie6cfcd2008f7abb61d457a41124600fe7cea229a
Reviewed-on: https://swiftshader-review.googlesource.com/14828
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed first-class arrays
Alexis Hetu [Mon, 11 Dec 2017 20:23:29 +0000 (15:23 -0500)]
Fixed first-class arrays

The typeSpecifier.array check was doubled inside and outside of
the mShaderVersion check. The typeSpecifier.array check should
only be done when mShaderVersion < 300.

Fixes dEQP-GLES3.functional.state_query.shader.program_active_uniform_types

Change-Id: I2907676c346a9f53d4f8c8da172b7ce0bc7b4083
Reviewed-on: https://swiftshader-review.googlesource.com/14848
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoNew default vertex attribute size
Alexis Hetu [Tue, 12 Dec 2017 13:12:15 +0000 (08:12 -0500)]
New default vertex attribute size

VertexAttribute objects should have a default size of 4.

Fixes dEQP-GLES3.functional.state_query.shader.vertex_attrib_size

Change-Id: I597d2095f7be087f35a4adfb01bb2a3ba5200701
Reviewed-on: https://swiftshader-review.googlesource.com/14928
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoValidate unsized internal formats.
Nicolas Capens [Fri, 8 Dec 2017 18:09:16 +0000 (13:09 -0500)]
Validate unsized internal formats.

If the format and internalformat parameters are the same, only the
combinations in Table 3.3 of the OpenGL ES 3.0 specification are valid.

GL_RGB10_A2 and GL_RGB10_A2UI have GL_UNSIGNED_INT_2_10_10_10_REV type.
GL_OES_vertex_type_10_10_10_2 is a vertex attribute type, part of the
GL_OES_vertex_type_10_10_10_2 extension.

GL_RGB10_A2 internal format is valid for glReadPixels with a
combination of format GL_RGBA and type GL_UNSIGNED_INT_2_10_10_10_REV.

Change-Id: I590b43fcf9f1dc4beee9a64b45fe94fd74388b7a
Reviewed-on: https://swiftshader-review.googlesource.com/14788
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor read buffer access.
Nicolas Capens [Fri, 8 Dec 2017 15:27:39 +0000 (10:27 -0500)]
Refactor read buffer access.

The read buffer state is part of the framebuffer object, so determining
the index is moved to the Framebuffer class. Also make sure GL_NONE is
handled without causing invalid access by using GL_INVALID_INDEX.

Change-Id: I26476024cd8dd820b0e3f53d9c3dd5a7d46c082e
Reviewed-on: https://swiftshader-review.googlesource.com/14748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix missing RG8 blending support.
Nicolas Capens [Fri, 8 Dec 2017 01:46:49 +0000 (20:46 -0500)]
Fix missing RG8 blending support.

Change-Id: I62047cd0bf6c9f066e7a63c1316288d227caa9aa
Reviewed-on: https://swiftshader-review.googlesource.com/14768
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMark libsubzero as vendor
Isaac Chen [Tue, 5 Dec 2017 06:40:44 +0000 (14:40 +0800)]
Mark libsubzero as vendor

Bug: 70191319
Test: $ lunch aosp_arm-userdebug; BOARD_VNDK_VERSION=current m -j
      $ emulator # boot to home screen

Change-Id: Id19a847072f2f0b55184c183647889c1a1b53aef
Reviewed-on: https://swiftshader-review.googlesource.com/14688
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRename version to shaderModel
Alexis Hetu [Wed, 6 Dec 2017 19:49:07 +0000 (14:49 -0500)]
Rename version to shaderModel

In order to avoid creating confusion between shader model and
the actual shader's version, as specified by the #version
token in a glsl shader, version was renamed to shaderModel.

Change-Id: I481b6e3fc43168b504c2f2d9506422a697abc3a2
Reviewed-on: https://swiftshader-review.googlesource.com/14629
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAllow out of bounds coordinates in glBlitFramebuffer
Alexis Hetu [Wed, 29 Nov 2017 19:00:32 +0000 (14:00 -0500)]
Allow out of bounds coordinates in glBlitFramebuffer

Device::stretchRect() now supports out of bounds coordinates.
To avoid linear interpolation errors, source coordinates now
have to be in floating point rather than integer format. Most
changes in this cl are just to accommodate that int->float
change for the source rect.

Fixes all (28) failures in:
dEQP-GLES3.functional.fbo.blit.rect

Change-Id: I8fd017e60b61f2d7d6517b0e648b324be441cddd
Reviewed-on: https://swiftshader-review.googlesource.com/14648
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMinor C++11 code cleanup
Alexis Hetu [Wed, 6 Dec 2017 19:22:10 +0000 (14:22 -0500)]
Minor C++11 code cleanup

Used range-based for loop where it was trivial to do so.
This change should be noop in terms of functionality.

Change-Id: I3d692cc2706f35f5b710e7539fa084365cf28af1
Reviewed-on: https://swiftshader-review.googlesource.com/14628
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRestore support for BGRA formats.
Nicolas Capens [Wed, 6 Dec 2017 18:18:52 +0000 (13:18 -0500)]
Restore support for BGRA formats.

Change-Id: I3a239325ed802e9188839c1c743d45930643c273
Reviewed-on: https://swiftshader-review.googlesource.com/14608
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix initial rbo state.
Nicolas Capens [Tue, 5 Dec 2017 22:28:04 +0000 (17:28 -0500)]
Fix initial rbo state.

Renderbuffer objects are defined to have an initial internalformat of
GL_RGBA4, but the red/green/blue/alpha bits are 0. This inconsistency
is resolved by setting the internalformat to GL_NONE but reporting
GL_RGBA4 when queried.

Change-Id: Ie9a342c05eaa23f81773b37ebb942ca2e5b1addb
Reviewed-on: https://swiftshader-review.googlesource.com/14588
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix framebuffer attachment validation.
Nicolas Capens [Tue, 5 Dec 2017 21:17:39 +0000 (16:17 -0500)]
Fix framebuffer attachment validation.

GL_BACK, GL_DEPTH, and GL_STENCIL are only valid for the default
framebuffer, while GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT,
GL_DEPTH_STENCIL_ATTACHMENT, and GL_COLOR_ATTACHMENTi are only valid
for non-default framebuffer objects.

Also implement the color encoding query.

Change-Id: I153ae9407850a30ed14d9ae145ee3504ba71029a
Reviewed-on: https://swiftshader-review.googlesource.com/14569
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix attribute location binding
Alexis Hetu [Tue, 5 Dec 2017 21:03:51 +0000 (16:03 -0500)]
Fix attribute location binding

- Attribute location aliasing was allowed prior to shader
  version 300, so location aliasing is now possible.
- Attribute binding refers to the linked location of attributes,
  so locations set using glBindAttribLocation() will only be
  returned by glGetAttribLocation() after the program is linked.
  Before that, it will return the location allocated during the
  previous glLinkProgram() call.

In order to do that, an extra map was added.
"linkedAttributeLocation" represents the attributes' location,
as a result of linking a program.
"attributeBinding" represents the attributes' future location,
when the next program linking occurs.

On top of that, the shader's version was not being passed down
from TranslatorASM to es2::Shader, or from es2::Shader to Program,
so this information also needed to be properly transferred.

Fixes all failures in:
dEQP-GLES3.functional.attribute_location*

Change-Id: I4ba7dc7c2f6d444e805cadeb5445f5ff371c3d95
Reviewed-on: https://swiftshader-review.googlesource.com/14568
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUntangle internal & implementation format.
Nicolas Capens [Mon, 4 Dec 2017 21:07:22 +0000 (16:07 -0500)]
Untangle internal & implementation format.

Textures and renderbuffers were storing both the OpenGL internalformat
and the SwiftShader implementation format (i.e. sw::Format). This
change removes the implementation format, only keeping it in the Image
class.

Change-Id: Ie6ac96f6450b9a55ea9b49c6cf4b2c0681e95522
Reviewed-on: https://swiftshader-review.googlesource.com/14528
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix using read color buffer for glReadPixels validation.
Nicolas Capens [Tue, 5 Dec 2017 16:03:08 +0000 (11:03 -0500)]
Fix using read color buffer for glReadPixels validation.

Change-Id: Ib153f6af75c982fae0325a104da3c0a4fc9ee9dc
Reviewed-on: https://swiftshader-review.googlesource.com/14548
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix internalformat handling.
Nicolas Capens [Mon, 4 Dec 2017 16:15:51 +0000 (11:15 -0500)]
Fix internalformat handling.

- Use internalformat parameter if valid, instead of deriving from
  format/type parameters.
- Validate format/type/internalformat parameters in CopyTexSubImage().
- Moved early-out optimizations after validation.
- Removed duplicate validation.
- Use GLint consistently for internalformat parameters.

Change-Id: I377c6bb5381602d13d281f19985aa4f11d201099
Reviewed-on: https://swiftshader-review.googlesource.com/14488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoglGenerateMipmap validation
Alexis Hetu [Wed, 22 Nov 2017 21:44:23 +0000 (16:44 -0500)]
glGenerateMipmap validation

- Added *ALPHA8*/*LUMINANCE8* formats and *_SNORM formats
  to non color renderable formats
- Added a new function IsMipMappable in order to allow
  mipmapping of the *ALPHA8*/*LUMINANCE8* formats

Fixes all (24) failures in:
dEQP-GLES3.functional.texture.mipmap.2d.generate*
dEQP-GLES3.functional.texture.mipmap.cube.generate*

Also fixes WebGL test:
conformance/textures/misc/texture-npot.html

Change-Id: I5f3210094fbc5b2e5bae25c88a5ef4f1ffb69cbd
Reviewed-on: https://swiftshader-review.googlesource.com/14130
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUpdate to number of allowed shader inputs/outputs for OpenGL ES 3
Alexis Hetu [Thu, 1 Oct 2015 18:54:47 +0000 (14:54 -0400)]
Update to number of allowed shader inputs/outputs for OpenGL ES 3

Because of the 3 reserved uniforms used for gl_DepthRange, the
number of uniforms allowed in fragment and vertex shaders was
too small by 3, so their allowed number was increased by 3.

As for attributes and varyings, their numbers needed to be
increased in order to pass all OpenGL ES 3.0 dEQP tests.

Change-Id: I6527334e1503c08281303915654087cbac8089a0
Reviewed-on: https://swiftshader-review.googlesource.com/4034
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix D3D8 compilation.
Nicolas Capens [Fri, 1 Dec 2017 21:31:21 +0000 (16:31 -0500)]
Fix D3D8 compilation.

Change-Id: I29e493f91df9ebef948b02096421102eb328d545
Reviewed-on: https://swiftshader-review.googlesource.com/14490
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMove draw call early-outs until after validation.
Nicolas Capens [Fri, 1 Dec 2017 19:40:50 +0000 (14:40 -0500)]
Move draw call early-outs until after validation.

Drawing without a current program is not an error and we can early-out,
but not until after other validation which could generate an error has
completed. Validation happening on a valid program happens afterwards
though. Likewise, providing insufficient vertices for even one
primitive results in drawing nothing, but validation still needs to
happen.

Change-Id: I5385ffe352fc38343caa41eb99f5549472da3b4f
Reviewed-on: https://swiftshader-review.googlesource.com/14489
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoProgram related validation
Alexis Hetu [Thu, 30 Nov 2017 20:04:39 +0000 (15:04 -0500)]
Program related validation

Added some validation for uniforms and uniform blocks.

Fixes some failures in (only 1 failure left):
dEQP-GLES3.functional.negative_api.state*

Change-Id: I507c7e8784230f85b0d312d162e5ff82bdbd15ed
Reviewed-on: https://swiftshader-review.googlesource.com/14428
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Ozone compilation.
Nicolas Capens [Fri, 1 Dec 2017 18:12:32 +0000 (13:12 -0500)]
Fix Ozone compilation.

Change-Id: I03a369139b733a75a7790e65afc514b929e32090
Reviewed-on: https://swiftshader-review.googlesource.com/14468
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAllow Predator to find the right component
Alexis Hetu [Fri, 1 Dec 2017 15:50:16 +0000 (10:50 -0500)]
Allow Predator to find the right component

Bug chromium:769026

Change-Id: I059117a0209e3ac13877736abafe3599310f0670
Reviewed-on: https://swiftshader-review.googlesource.com/14448
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement seamless cubemap sampling.
Nicolas Capens [Tue, 28 Nov 2017 20:54:59 +0000 (15:54 -0500)]
Implement seamless cubemap sampling.

The addressing is offset by 1 to account for the border. Note that this
could be avoided by locking at (0, 0) instead of (-1, -1) instead, but
then negative address offsets have to be allowed and this complicates
the subsequent calculations and only unsigned extension from 32-bit to
64-bit is typically for free during memory accesses.

Change-Id: I5fb843401d440a9d77d141782124a9c260765830
Reviewed-on: https://swiftshader-review.googlesource.com/13289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPerform coordinate clamping on border addressing mode.
Nicolas Capens [Tue, 28 Nov 2017 20:52:52 +0000 (15:52 -0500)]
Perform coordinate clamping on border addressing mode.

The border addressing mode should ideally blend with the border color
when using linear filtering. Until we have a border of pixels around
2D textures, we should probably avoid bleeding pixels from the opposite
edge and just clamp the coordinates.

Change-Id: I7afbb629998732b62413e00ba7bcd55340c7b9bb
Reviewed-on: https://swiftshader-review.googlesource.com/14289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpdate cube texture borders when dirty.
Nicolas Capens [Tue, 28 Nov 2017 18:31:35 +0000 (13:31 -0500)]
Update cube texture borders when dirty.

Change-Id: Ic259645ab7950b0b2800964bbfd14f3294de50b1
Reviewed-on: https://swiftshader-review.googlesource.com/14288
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFunctionality to update borders of cube textures.
Alexis Hetu [Tue, 29 Nov 2016 22:17:26 +0000 (17:17 -0500)]
Functionality to update borders of cube textures.

The cube texture borders will be used for linear interpolation, in
order to produce seamless edges.

Change-Id: Idd17c72c6aaf7dcc65188b065ac8ba179b58cc37
Reviewed-on: https://swiftshader-review.googlesource.com/8209
Tested-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd support for borders around textures.
Alexis Hetu [Tue, 29 Nov 2016 22:02:14 +0000 (17:02 -0500)]
Add support for borders around textures.

Borders are required to support seamless cubemap sampling. Subsequent
patches will fill the borders with pixels from adjacent cube faces.

The border is expressed in pixels and is added on all edges,
resulting in an image of dimensions
(width + 2 * border) x (height + 2 * border).
The surface still exposes dimensions of width x height through the API
and points to the same pixel when locked.

Change-Id: I06d5121267ce1a2c50e628490d8690de71bfeb08
Reviewed-on: https://swiftshader-review.googlesource.com/8208
Tested-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor high-precision texture coordinate addressing.
Nicolas Capens [Mon, 27 Nov 2017 20:25:05 +0000 (15:25 -0500)]
Refactor high-precision texture coordinate addressing.

Uses 0, -1 offsets instead of 0, 1 to be able to use it as a
mask. Optimize calculation of the integer coordinates and fraction by
always having xyz1 = xyz0 + 1 (before wrap). Optimize the
clamping/wrapping of the integer coordinates. Skip addressing operation
of the third component for cube sampling (since already projected to
2D face).

Change-Id: If2e7c74aac9ae923a0c1ffc278fcdfec00f216f3
Reviewed-on: https://swiftshader-review.googlesource.com/14269
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix remaining LLVM integer vector comparisons.
Nicolas Capens [Mon, 27 Nov 2017 19:58:53 +0000 (14:58 -0500)]
Fix remaining LLVM integer vector comparisons.

Change-Id: I35cd9c9e4510529a324f6bd3dfd91e56b834cbca
Reviewed-on: https://swiftshader-review.googlesource.com/14268
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCompute cube LOD based on Manhattan distance.
Nicolas Capens [Wed, 22 Nov 2017 20:06:58 +0000 (15:06 -0500)]
Compute cube LOD based on Manhattan distance.

We previously computed the LOD of cube maps using the 3D Euclidean
distance between the intersections of the sampling rays of a quad with
the cube. This underestimates the gradient at the edges where these
rays intersect multiple faces. Instead use the Manhattan distance. This
may overestimate the footprint dimensions, but only leads to slight
blurring instead of aliasing.

Change-Id: I5ddbb39765462b1c55c4143b5806154cbdfe7130
Reviewed-on: https://swiftshader-review.googlesource.com/5173
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCompute implicit derivatives relative to first quad pixel.
Nicolas Capens [Fri, 24 Nov 2017 15:10:22 +0000 (10:10 -0500)]
Compute implicit derivatives relative to first quad pixel.

Previously the derivatives in y were computed using the difference
between the second and fourth pixel in the quad. For consistency with
the x derivative, use the first and third pixel instead. Also, some
shuffling can be eliminated by having the x derivative in the y
component, and the y derivative in the z component.

Change-Id: I985dcd3c5e2c47c10caf020cf5cb79587b3b3aab
Reviewed-on: https://swiftshader-review.googlesource.com/14168
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDrawing without current program is not an error.
Nicolas Capens [Wed, 29 Nov 2017 19:28:31 +0000 (14:28 -0500)]
Drawing without current program is not an error.

The spec states that "If UseProgram is called with program set to zero,
then there is no current program object, and the results of vertex and
fragment shader execution are undefined. However, this is not an
error."

Fixes all failures in:
dEQP-GLES3.functional.negative_api.vertex_array.*

Change-Id: Ia5fbb22a9447b299665db29fc1f564f6de4f202d
Reviewed-on: https://swiftshader-review.googlesource.com/14408
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport 3-component integer formats natively.
Nicolas Capens [Thu, 30 Nov 2017 05:14:57 +0000 (00:14 -0500)]
Support 3-component integer formats natively.

Change-Id: Id48bc7a232c50b753da64cb914e75b5d590ae47d
Reviewed-on: https://swiftshader-review.googlesource.com/14369
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix casting to signed unnormalized integers.
Nicolas Capens [Thu, 30 Nov 2017 05:12:08 +0000 (00:12 -0500)]
Fix casting to signed unnormalized integers.

Change-Id: Ic1e4256bd73281af3e48d0f81ad16ea92a60ce4f
Reviewed-on: https://swiftshader-review.googlesource.com/14368
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix support for NPOT 3D and 2D array textures.
Nicolas Capens [Thu, 30 Nov 2017 02:41:24 +0000 (21:41 -0500)]
Fix support for NPOT 3D and 2D array textures.

The slices of 3D and 2D array textures are not at pitch * height offset
apart when the height is odd, due to allocating 2x2 quads for render
targets. Explicitly use the slice size instead.

Change-Id: Id35f35f21a5b2b199215e2526239bcd459141e2c
Reviewed-on: https://swiftshader-review.googlesource.com/14348
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDisable C++ exceptions in the Windows gn build
Reid Kleckner [Wed, 29 Nov 2017 18:45:53 +0000 (10:45 -0800)]
Disable C++ exceptions in the Windows gn build

This avoids unnecessary destructor cleanups in swiftshader code.  Posix
systems use -fno-exceptions, so this updates the MSVC gn args with the
equivalent, /EHs-c-.

I noticed this while investigating an unrelated issue.

Change-Id: Ic56e7560e7cb7617f8596b3ffda0444122425535
Reviewed-on: https://swiftshader-review.googlesource.com/14308
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Reid Kleckner <rnk@google.com>
6 years agoRemoved error from extraneous matrix packing qualifier
Alexis Hetu [Tue, 28 Nov 2017 14:57:37 +0000 (09:57 -0500)]
Removed error from extraneous matrix packing qualifier

Two minor changes:
1) Structs are allowed to have matrix packing qualifiers
2) Adding an extra matrix packing qualifier shouldn't make
   a shader fail to compile

Change-Id: Icbe0178cb6017854c289db90349a17662e868095
Reviewed-on: https://swiftshader-review.googlesource.com/14228
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdded missing case to ConvertRenderbufferFormat
Alexis Hetu [Tue, 28 Nov 2017 15:12:34 +0000 (10:12 -0500)]
Added missing case to ConvertRenderbufferFormat

GL_DEPTH_COMPONENT24 was missing.
It seems to be in all other functions in this file.

Fixes debug assert in OGLES3ColourGrading

Change-Id: Ifb8fe8dc9248f5acbd9cac3622c3335525711bda
Reviewed-on: https://swiftshader-review.googlesource.com/14248
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoIncreased maximum token size
Alexis Hetu [Tue, 28 Nov 2017 15:02:23 +0000 (10:02 -0500)]
Increased maximum token size

dEQP tests up to 1024 for token length.
Fixes dEQP-GLES3.functional.shaders.uniform_block.valid.long_*

Change-Id: Iba2a79fc210e58e5681dd15a3cece3f8129d4d32
Reviewed-on: https://swiftshader-review.googlesource.com/14229
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdded validation to shader related functions
Alexis Hetu [Wed, 22 Nov 2017 18:27:03 +0000 (13:27 -0500)]
Added validation to shader related functions

- Added uniform block binding validation
- Disallowed setting int uniforms from unsigned
  int specific functions and vice versa.
- Moved early returns from uniform related
  functions further down the functions to allow
  gl errors to be returned
- Added active transform feedback checks
- Fixed some gl error return codes.

Fixes most failures in:
dEQP-GLES3.functional.negative_api.shader*

Change-Id: Id9f914a09dd89fea61728725f8bd828dc7b3f81b
Reviewed-on: https://swiftshader-review.googlesource.com/14128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed glFlushMappedBufferRange validation
Alexis Hetu [Wed, 22 Nov 2017 19:00:37 +0000 (14:00 -0500)]
Fixed glFlushMappedBufferRange validation

Mistook "access" for "usage". Fixed.

Change-Id: I8c61aa9dbc0ebd2a68f4363a1d59f9aae7dbc056
Reviewed-on: https://swiftshader-review.googlesource.com/14129
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFramebuffer related validity checks
Alexis Hetu [Mon, 20 Nov 2017 19:52:03 +0000 (14:52 -0500)]
Framebuffer related validity checks

Added validity checks for RenderbufferStorageMultisample
and BlitFramebuffer, mostly missing checks for using
integer types or depth/stencil framebuffers with
multisampling, which is not allowed.

Fixes all failures in:
dEQP-GLES3.functional.negative_api.buffer*

Change-Id: Ie1db21a3b9f1ca71ed660a2758d43f24846acdf1
Reviewed-on: https://swiftshader-review.googlesource.com/14048
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoglGenerateMipmap validation
Alexis Hetu [Mon, 20 Nov 2017 22:00:39 +0000 (17:00 -0500)]
glGenerateMipmap validation

Can't generate mipmaps if the format is
not color renderable or not filterable.

Change-Id: I919a4c29c17a69c25e018dd4682940eecd4df30e
Reviewed-on: https://swiftshader-review.googlesource.com/14068
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoglCompressedTexSub* validation fixes
Alexis Hetu [Tue, 21 Nov 2017 17:39:41 +0000 (12:39 -0500)]
glCompressedTexSub* validation fixes

- Added imageSize validation checks
- Added ETC2/EAC specific validations

Change-Id: I8671b08caecb7aaff0b42d6843d31738b54d0f5a
Reviewed-on: https://swiftshader-review.googlesource.com/14088
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPixel unpack buffer validation follow up
Alexis Hetu [Fri, 17 Nov 2017 18:15:32 +0000 (13:15 -0500)]
Pixel unpack buffer validation follow up

2 fixes:
- The offset check was removed, as it only affects the pointer
  and not the size
- The modulo check is on the type only and not the entire image size

Change-Id: I8c4b64e845b2fae61959d7c62d2c5dc222249c68
Reviewed-on: https://swiftshader-review.googlesource.com/14009
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed signed/unsigned mismatch
Alexis Hetu [Fri, 17 Nov 2017 15:29:16 +0000 (10:29 -0500)]
Fixed signed/unsigned mismatch

Change-Id: Ibd7a099fa0a25dbddb1733b81101abc82ddd3f4c
Reviewed-on: https://swiftshader-review.googlesource.com/14008
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDepth related fixes
Alexis Hetu [Thu, 16 Nov 2017 20:35:59 +0000 (15:35 -0500)]
Depth related fixes

- Depth output should write to the 1st (Red) channel only
- Depth image load should be clamped in the [0, 1] range

Change-Id: Ic7c3ac09c86d5457ec3c59bf9666e2b168226c5e
Reviewed-on: https://swiftshader-review.googlesource.com/13988
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPixel unpack buffer validation
Alexis Hetu [Wed, 15 Nov 2017 18:01:28 +0000 (13:01 -0500)]
Pixel unpack buffer validation

Added proper validation to make sure the pixel unpack buffer
is both unmapped and large enough, when imageSize is specified.

Change-Id: If6ec764d741bb9d63d38d0656188846c5a9be66d
Reviewed-on: https://swiftshader-review.googlesource.com/13868
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoReduce temporaries used during rvalue evaluation.
Nicolas Capens [Thu, 16 Nov 2017 15:42:20 +0000 (10:42 -0500)]
Reduce temporaries used during rvalue evaluation.

This optimizes evaluation of chained indexing operations by first
looking for an lvalue 'root' node and copying from it directly into the
topmost rvalue, instead of creating potentially many temporaries.

Change-Id: I47cf9b0230bd305695e7b2a44ddc44bc1320b764
Reviewed-on: https://swiftshader-review.googlesource.com/13908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix taking the index into account for write mask.
Nicolas Capens [Thu, 16 Nov 2017 20:28:14 +0000 (15:28 -0500)]
Fix taking the index into account for write mask.

Change-Id: I25251e94680624c8c85698e96a053f518bb2c367
Reviewed-on: https://swiftshader-review.googlesource.com/13968
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoReduce lifetime of address temporary.
Nicolas Capens [Thu, 16 Nov 2017 15:38:19 +0000 (10:38 -0500)]
Reduce lifetime of address temporary.

After traversing the lvalue node tree we're fully done computing the
relative address and emitting any pointer arithmetic that might have
been needed. So the temporary that would have been used for that is no
longer needed.

Change-Id: I0a10bff979128f03544d0f8aa860c29f8867973a
Reviewed-on: https://swiftshader-review.googlesource.com/13948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRefactor lvalue() to return the root node.
Nicolas Capens [Wed, 15 Nov 2017 21:39:47 +0000 (16:39 -0500)]
Refactor lvalue() to return the root node.

This will enable reusing it to determine the root node of rvalues as
well. The only functional change is that struct indexing no longer
overrides the register type. This is of no effect here since lvalue
intermediates already inherited their type from the root node, but for
rvalues the intermediates are considered temporary registers, while
instead the root's type should be used.

Change-Id: I2dbd1b0f8886c3f111a2ed3ef7fe4e9a5b480085
Reviewed-on: https://swiftshader-review.googlesource.com/13930
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't needlessly traverse the left hand side of assignments.
Nicolas Capens [Thu, 9 Nov 2017 16:20:51 +0000 (11:20 -0500)]
Don't needlessly traverse the left hand side of assignments.

Previously we processed assignments in PostVisit, i.e. after both the
left and right side had been traversed. This produces temporaries for
the left hand side, which we don't use since we want to assign to the
lvalue. So instead we can explicitly traverse the right hand side, and
for the left hand side only traverse indirect indexing expressions.

Change-Id: I9ec0596a9c256921b65a9f70428d950959f66aa0
Reviewed-on: https://swiftshader-review.googlesource.com/13630
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDisallow assigning to interface block fields.
Nicolas Capens [Wed, 15 Nov 2017 19:39:15 +0000 (14:39 -0500)]
Disallow assigning to interface block fields.

GLSL ES 3.0 interface blocks always have uniform storage qualification
and thus can't be used as l-value.

Change-Id: Iffe948dccbf2edb28eb1abe52a6f28dc76a1e84b
Reviewed-on: https://swiftshader-review.googlesource.com/13929
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrint uniform buffer registers as cb#[index].
Nicolas Capens [Wed, 15 Nov 2017 19:34:44 +0000 (14:34 -0500)]
Print uniform buffer registers as cb#[index].

This matches Shader Model 4+ assembly syntax and helps debug shader
compilation issues.

Change-Id: Iff2a2991794e13476b99e11d6ac07fdf5d37570b
Reviewed-on: https://swiftshader-review.googlesource.com/13928
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoEliminate integer destination modifier.
Nicolas Capens [Wed, 15 Nov 2017 18:35:47 +0000 (13:35 -0500)]
Eliminate integer destination modifier.

The integer modifier was used to emulate integer arithmetic using
floating-point operations, as was allowed/typical for OpenGL ES 2.0
implementations. Now that we support native 32-bit integer types and
we have separate opcodes for integer operations, it is not longer
needed.

Change-Id: I89987534c150d2426ac9f9e1e49b66f9deaee560
Reviewed-on: https://swiftshader-review.googlesource.com/13889
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove matrix field selectors.
Nicolas Capens [Thu, 9 Nov 2017 14:49:03 +0000 (09:49 -0500)]
Remove matrix field selectors.

Matrix elements cannot be accessed with dot notation.

Change-Id: I48258428e3fa5ffe9c95a8983516433b98ce233a
Reviewed-on: https://swiftshader-review.googlesource.com/13629
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix glDeleteSync validation
Alexis Hetu [Tue, 14 Nov 2017 22:22:46 +0000 (17:22 -0500)]
Fix glDeleteSync validation

glDeleteSync can only delete an existing FenceSync object.

Change-Id: Ieb78894175235cc97c67ff0324d59bb5d7619918
Reviewed-on: https://swiftshader-review.googlesource.com/13829
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoglVertexAttribPointer validation
Alexis Hetu [Wed, 15 Nov 2017 15:50:10 +0000 (10:50 -0500)]
glVertexAttribPointer validation

GL_INVALID_OPERATION is generated if a non-zero vertex array object
is bound, zero is bound to the GL_ARRAY_BUFFER buffer object binding
point and the pointer argument is not NULL.

Change-Id: I48e73dca96bac2bd0496c202785e46e7d754dc11
Reviewed-on: https://swiftshader-review.googlesource.com/13830
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllow multiple query types simultaneously
Alexis Hetu [Tue, 14 Nov 2017 22:19:42 +0000 (17:19 -0500)]
Allow multiple query types simultaneously

While GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT and
GL_ANY_SAMPLES_PASSED_EXT are mutually exclusive,
they can be used simultaneously with the
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query.

Change-Id: I818cf548c724ef56640b795530c3437e4dbcba98
Reviewed-on: https://swiftshader-review.googlesource.com/13828
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBuffer mapping state validation fixes
Alexis Hetu [Tue, 14 Nov 2017 20:27:00 +0000 (15:27 -0500)]
Buffer mapping state validation fixes

- Can't update an already mapped bufferData
- Can't unmap an unmapped buffer
- Disallowed illegal mapBufferRange flag combinations
- Can't flush buffer if not mapped

Change-Id: I7013f63e5db64c1016f9ce50a43d0629f0a2950e
Reviewed-on: https://swiftshader-review.googlesource.com/13788
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoarcsin/arccos/arctan precision fix
Alexis Hetu [Wed, 8 Nov 2017 18:43:16 +0000 (13:43 -0500)]
arcsin/arccos/arctan precision fix

The dEQP tests for arccos/arcsin/arctan were failing due to
the precision of the arcsin/arccos/arctan approximation being
too low. It is possible to significantly improve this precision
with a few more terms, which is done here.

All arccos/arcsin/arctan dEQP tests pass.

Change-Id: I612551b48bdab03b81b2e72ddb8cd7f8502231c5
Reviewed-on: https://swiftshader-review.googlesource.com/13568
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoHide ASTC support
Alexis Hetu [Tue, 14 Nov 2017 18:22:06 +0000 (13:22 -0500)]
Hide ASTC support

Since we don't expose the ASTC related extension string,
we need to hide support for ASTC related enums. ASTC_SUPPORT
was added to easily re-enable ASTC, should we want to.

Change-Id: I3c65906c4729df8a2efb1a9a78e155bccdc715f9
Reviewed-on: https://swiftshader-review.googlesource.com/13749
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrevent mapped buffers from getting mapped again
Alexis Hetu [Tue, 14 Nov 2017 18:24:37 +0000 (13:24 -0500)]
Prevent mapped buffers from getting mapped again

It is an invalid operation to map an already mapped buffer.

Change-Id: Iba1c2389e5ef9c3114a2415279406ac7f08a0ed6
Reviewed-on: https://swiftshader-review.googlesource.com/13750
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoHigh precision implementation for sin/cos/tan
Alexis Hetu [Tue, 7 Nov 2017 21:04:25 +0000 (16:04 -0500)]
High precision implementation for sin/cos/tan

This implementation allows all dEQP precision test to pass
for sin, cos and tan function tests.

Change-Id: I33a24497dea68ab2de2e65931f50f2dd4298523c
Reviewed-on: https://swiftshader-review.googlesource.com/13555
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFix for glBindTransformFeedback and glDeleteTransformFeedbacks
Alexis Hetu [Tue, 14 Nov 2017 16:06:03 +0000 (11:06 -0500)]
Fix for glBindTransformFeedback and glDeleteTransformFeedbacks

Added proper checks for invalid operations.

Fixes all remaining failures in dEQP-GLES3.functional.lifetime*

Change-Id: Ia91ffdb8ced53f1f787b82ada0de22caf9ee9206
Reviewed-on: https://swiftshader-review.googlesource.com/13748
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrecision fix for inversesqrt.
Alexis Hetu [Mon, 13 Nov 2017 22:31:20 +0000 (17:31 -0500)]
Precision fix for inversesqrt.

Fixes all dEQP failures in inversesqrt and normalize.

Change-Id: Ifd1ac2714fa95bab1c720b65c95a27bbf23ea933
Reviewed-on: https://swiftshader-review.googlesource.com/13728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixes for exp and log functions
Alexis Hetu [Mon, 13 Nov 2017 21:21:11 +0000 (16:21 -0500)]
Fixes for exp and log functions

- Fixed how logarithm2() handles infinity
- Fixed a typo in exponential()

These fixes combined fix all dEQP failures for:
sinh, cosh, pow, exp, log, log2

Change-Id: I2d427892032fc5f75909a5609f606a787b08505a
Reviewed-on: https://swiftshader-review.googlesource.com/13708
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoisnan and isinf implementation
Alexis Hetu [Thu, 9 Nov 2017 20:49:09 +0000 (15:49 -0500)]
isnan and isinf implementation

Added the missing implementation for isinf and isnan.

Change-Id: Ice603956a4ed8ef9515ae8f501b2876ce5fab584
Reviewed-on: https://swiftshader-review.googlesource.com/13608
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't use macro expressions in another macro
Cezary Kulakowski [Thu, 9 Nov 2017 14:37:20 +0000 (15:37 +0100)]
Don't use macro expressions in another macro

We use icecc to speed up compilation in our project. After this change
https://swiftshader-review.googlesource.com/12308 chromium doesn't
compile via icecc as __has_include(<atomic>) is never expanded to 0 or 1
on icecc host and file <atomic> is not being included. My guess is that
icecc host gets partially expanded code and it's not being passed by
preprocessor again so condition #if __has_include(<atomic>) (expanded
from #if USE_STD_ATOMIC) is never fulfilled.
Bug: chromium:783135
Change-Id: I09cf120c399a794a15dec05d6edd74c7848fc53a
Reviewed-on: https://swiftshader-review.googlesource.com/13588
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Cezary Kulakowski <ckulakowski@opera.com>
6 years agoRefactor FrameBuffer blit/flip source.
Nicolas Capens [Thu, 31 Dec 2015 04:40:45 +0000 (23:40 -0500)]
Refactor FrameBuffer blit/flip source.

Pass a surface to the blit/flip functions, instead of a raw pointer.
This puts the FrameBuffer in control of locking and unlocking.

Change-Id: I55335b3beef8d7083aae7687bd25392964261bde
Reviewed-on: https://swiftshader-review.googlesource.com/4482
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse the source stride for framebuffer blit.
Nicolas Capens [Mon, 28 Dec 2015 16:13:48 +0000 (11:13 -0500)]
Use the source stride for framebuffer blit.

Previously we assumed the source stride (in pixels) to be the width
rounded up to the next multiple of 2. This is currently correct but
may not hold in the future.

Change-Id: I23a79ace66f720398a120b70081d731c2cf1b4c0
Reviewed-on: https://swiftshader-review.googlesource.com/4481
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor FrameBuffer state.
Nicolas Capens [Fri, 11 Aug 2017 19:14:25 +0000 (15:14 -0400)]
Refactor FrameBuffer state.

This mainly groups the state that is used for generating a new blit
routine into a second BlitState structure 'updateState'. It also
allowed for the FrameBuffer's own parameters to not have a 'dest'
prefix. Also, 'locked' was renamed to 'framebuffer', and 'target' to
'renderbuffer'.

Change-Id: I64e26f0b06f9f4419b8ca67e6fbb0dee8272898a
Reviewed-on: https://swiftshader-review.googlesource.com/11510
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDefault to libGLESv2 for EGL surface buffer creation.
Nicolas Capens [Mon, 30 Oct 2017 14:46:56 +0000 (10:46 -0400)]
Default to libGLESv2 for EGL surface buffer creation.

If both libGLES_CM and libGLESv2 are available, we were using the
former for creating the buffers of an EGL surface. The choice is
arbitrary, but it causes confusing issues when an interface changes
and one of the libraries wasn't rebuilt. This is less likely to occur
for libGLESv2.

Change-Id: If0c05d50a141c3782866892694d238332d8211db
Reviewed-on: https://swiftshader-review.googlesource.com/13388
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoWork around Visual Studio bug causing access violation.
Nicolas Capens [Tue, 7 Nov 2017 19:35:38 +0000 (14:35 -0500)]
Work around Visual Studio bug causing access violation.

The Reactor Value resulting from loading the value from the
dereferenced Pointer does not get passed to the Int4 cast constructor
correctly. This happens in 32-bit builds on Visual Studio
2017 (15.3.5), but not in 64-bit builds.

Change-Id: I68e1639ada436c65bb4f3bf9b3ac88d503f10e30
Reviewed-on: https://swiftshader-review.googlesource.com/13554
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement shadow texture depth comparison.
Nicolas Capens [Tue, 7 Nov 2017 18:51:50 +0000 (13:51 -0500)]
Implement shadow texture depth comparison.

Change-Id: I53b7938af132180dcf95312c76790fe761aab35d
Reviewed-on: https://swiftshader-review.googlesource.com/13553
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix cube texture gradient calculation.
Nicolas Capens [Tue, 7 Nov 2017 18:25:09 +0000 (13:25 -0500)]
Fix cube texture gradient calculation.

Cube texture sampling functions which take explicit gradients require
the gradients to divided by the same factor used to project the texture
coordinates onto the cube. Previously we assumed they were already in
the projected coordinate space.

Change-Id: I2825df17bee74b551b8d7491c050b7766653a65c
Reviewed-on: https://swiftshader-review.googlesource.com/13552
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoPass the sampling lod/bias as a separate parameter.
Nicolas Capens [Tue, 7 Nov 2017 18:07:53 +0000 (13:07 -0500)]
Pass the sampling lod/bias as a separate parameter.

This is necessary for cube or 2D array shadow texture sampling
functions which need the fourth texture coordinate component for
depth comparison while also taking a lod or bias parameter.

Change-Id: I1e1399f134e22cecaff97a224df2c13c57ba3a40
Reviewed-on: https://swiftshader-review.googlesource.com/13551
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor sampling functions to use a return value.
Nicolas Capens [Tue, 7 Nov 2017 18:05:20 +0000 (13:05 -0500)]
Refactor sampling functions to use a return value.

Change-Id: Ib62f310abecbc4cdaf6e9300791600f25af0eaf3
Reviewed-on: https://swiftshader-review.googlesource.com/13550
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCreate SamplerCore on demand.
Nicolas Capens [Tue, 7 Nov 2017 14:20:53 +0000 (09:20 -0500)]
Create SamplerCore on demand.

Previously we dynamically allocated an array of SamplerCores. This
isn't necessary and we can just create one as a temporary object where
used. This has the added advantage that we could have Reactor variables
as class members and keep them short-lived.

Change-Id: Ifb2e6edbf275aa793bd7880bd35384e16000007d
Reviewed-on: https://swiftshader-review.googlesource.com/13548
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoPass down the texture compare state.
Nicolas Capens [Mon, 6 Nov 2017 20:29:46 +0000 (15:29 -0500)]
Pass down the texture compare state.

Depth format textures can have a comparison operation performed after
their texels have been sampled.

Change-Id: I49f6bb7fab9765265761144ee8b6b62439beb5a3
Reviewed-on: https://swiftshader-review.googlesource.com/5870
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed Vertex Array Objects
Alexis Hetu [Tue, 7 Nov 2017 16:47:53 +0000 (11:47 -0500)]
Fixed Vertex Array Objects

Fixed glBindVertexArray. The early return was wrong,
binding vertex array 0 is perfectly valid.

All related dEQP tests pass.

Change-Id: Idd0ae745dc15877afb7c7323aab8253fb71e9017
Reviewed-on: https://swiftshader-review.googlesource.com/13549
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoStruct varyings implementation
Alexis Hetu [Thu, 2 Nov 2017 20:00:32 +0000 (16:00 -0400)]
Struct varyings implementation

Varying variables can be structure in OpenGL ES3.
This cl adds support for structure varyings.

Change-Id: I4d1d80c6afed0a86a23b0a467d4764a4e08f133d
Reviewed-on: https://swiftshader-review.googlesource.com/13529
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrevent initializing outline edges to out of bound values
Alexis Hetu [Thu, 2 Nov 2017 14:59:59 +0000 (10:59 -0400)]
Prevent initializing outline edges to out of bound values

When multisampling is enabled, outline edges were getting
initialized to one of the  primitive's X position. If the
primitive was out of bounds, then the default position was
out of bounds, which led to an initial out of bounds memory
access.

Added a clamp to fix the issue.

Bug chromium:779364

Change-Id: I4661f4229ee28a3032c763ed18dde799d3c3926b
Reviewed-on: https://swiftshader-review.googlesource.com/13528
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agotranslator: Add define to disable pool allocation.
Corentin Wallez [Tue, 31 Oct 2017 22:05:38 +0000 (18:05 -0400)]
translator: Add define to disable pool allocation.

This will help ASan find bugs in the translator when fuzzing, by making
separate allocations instead of using suballocations within the pool.

BUG=swiftshader:86

Change-Id: Ic59f7eef2c7985f7bf545d41be956df478331e2d
Reviewed-on: https://swiftshader-review.googlesource.com/13488
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
6 years agoFix Visual Studio warning treated as error.
Nicolas Capens [Tue, 31 Oct 2017 19:36:55 +0000 (15:36 -0400)]
Fix Visual Studio warning treated as error.

Was an implicit narrowing from size_t (64-bit) to unsigned int (32-bit).

Change-Id: I9726d70370d97da1bae2652bbce9db929179a292
Reviewed-on: https://swiftshader-review.googlesource.com/13469
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix pedantic Linux warning treated as error.
Nicolas Capens [Tue, 31 Oct 2017 18:09:52 +0000 (14:09 -0400)]
Fix pedantic Linux warning treated as error.

Unused variable 'entry'.

Change-Id: I115b7d599d871c0f130f72e32618a8ed29776b81
Reviewed-on: https://swiftshader-review.googlesource.com/13468
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoEnable executable code generation and linking.
Nicolas Capens [Tue, 31 Oct 2017 15:22:45 +0000 (11:22 -0400)]
Enable executable code generation and linking.

Bug swiftshader:86

Change-Id: If98cbf93e8b8d41246d9f06503da0752fe968ff8
Reviewed-on: https://swiftshader-review.googlesource.com/13448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix vertex stream count and normalized data layout.
Nicolas Capens [Mon, 30 Oct 2017 20:13:52 +0000 (16:13 -0400)]
Fix vertex stream count and normalized data layout.

Bug swiftshader:86

Change-Id: Ide76f9e7d8c490e5057959e1a7c28dfc7119151a
Reviewed-on: https://swiftshader-review.googlesource.com/13428
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport for gl_MaxDrawBuffers in OpenGL ES 3.0
Alexis Hetu [Mon, 30 Oct 2017 18:21:12 +0000 (14:21 -0400)]
Support for gl_MaxDrawBuffers in OpenGL ES 3.0

gl_MaxDrawBuffers is still available in OpenGL ES 3.0.
It was just a matter of making it part of the common builtins.

Change-Id: Icd3ca9f4f50cba43c345974ef72603800155a573
Reviewed-on: https://swiftshader-review.googlesource.com/13389
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSwitching MacOS to use Subzero
Alexis Hetu [Wed, 2 Aug 2017 21:09:21 +0000 (17:09 -0400)]
Switching MacOS to use Subzero

Currently Windows and Linux already use the Subzero backend, while
MacOS still uses the LLVM backend. This cl switches MacOS to using
the Subzero backend.

Change-Id: Ibc20add93c5f413271832fd1dd7fe7ae00cda9f4
Reviewed-on: https://swiftshader-review.googlesource.com/11213
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agovertex_routine_fuzzer: Get source from `data`
Corentin Wallez [Fri, 27 Oct 2017 21:14:39 +0000 (17:14 -0400)]
vertex_routine_fuzzer: Get source from `data`

BUG=swiftshader:86

Change-Id: Ia57c894170e790cdd1ea2fe3b92bbba7f643ba64
Reviewed-on: https://swiftshader-review.googlesource.com/13368
Tested-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFill vertex routine state for fuzzer.
Nicolas Capens [Fri, 27 Oct 2017 18:36:52 +0000 (14:36 -0400)]
Fill vertex routine state for fuzzer.

Bug swiftshader:86

Change-Id: I8339f3882163daa078ac71034aaf37147e51d725
Reviewed-on: https://swiftshader-review.googlesource.com/13349
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix last stream type enum.
Nicolas Capens [Fri, 27 Oct 2017 18:36:36 +0000 (14:36 -0400)]
Fix last stream type enum.

Change-Id: I119c9bd65624035cbb0afb850b061e140b6a296f
Reviewed-on: https://swiftshader-review.googlesource.com/13348
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix MSVC compilation of the VertexRoutineFuzzer
Corentin Wallez [Fri, 27 Oct 2017 17:40:18 +0000 (13:40 -0400)]
Fix MSVC compilation of the VertexRoutineFuzzer

We should really have these suppressions in a shared config over all
swiftshader.

BUG=swiftshader:86

Change-Id: I1b8fa6342090e78e2338a7d748bcb29911f9e393
Reviewed-on: https://swiftshader-review.googlesource.com/13328
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
6 years agoVertexRoutineFuzzer: Add code able to compile a simple shader
Corentin Wallez [Tue, 24 Oct 2017 20:13:44 +0000 (16:13 -0400)]
VertexRoutineFuzzer: Add code able to compile a simple shader

The fuzzer still needs to parse state and source from `data` before it
can actually be useful.

Bug swiftshader:86

Change-Id: Iafcbce4748b83a4fb9f829e3e8a473d161d3a696
Reviewed-on: https://swiftshader-review.googlesource.com/13249
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>