OSDN Git Service

android-x86/external-swiftshader.git
6 years agoCheck count > 0 not != 0 in Resource acquisition.
Lingfeng Yang [Fri, 22 Dec 2017 17:28:09 +0000 (09:28 -0800)]
Check count > 0 not != 0 in Resource acquisition.

On low-resolution Android Emulator AVDs run with -gpu
swiftshader_indirect, it's possible to run fast enough to see count ==
-1 on Resource acquisition. Check for that.

bug: 70950184

Test: API 27 Chrome is usable on a 480x800 or smaller device
Change-Id: I4f4cf9cd0ab1bc2bce846f0af6ffbbe243bc1a96
Reviewed-on: https://swiftshader-review.googlesource.com/15508
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
6 years agoAllow framebuffer attachment images to have distinct dimensions.
Nicolas Capens [Thu, 21 Dec 2017 20:30:12 +0000 (15:30 -0500)]
Allow framebuffer attachment images to have distinct dimensions.

Unlike OpenGL ES 2.0, 3.0 allows framebuffer attachments to be of
different sizes: "If the attachment sizes are not all identical, the
results of rendering are defined only within the largest area that
can fit in all of the attachments. This area is defined as the
intersection of rectangles having a lower left of (0, 0) and an upper
right of (width, height) for each attachment. Contents of attachments
outside this area are undefined after execution of a rendering command
(as defined in section 2.6)."

Change-Id: Ib75be93650edd7d6a7f3d08d9206830094e3fbd8
Reviewed-on: https://swiftshader-review.googlesource.com/15469
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed flatshading for triangle strip and triangle fan
Alexis Hetu [Thu, 21 Dec 2017 18:52:00 +0000 (13:52 -0500)]
Fixed flatshading for triangle strip and triangle fan

Since OpenGL uses the last vertex, not the leading
vertex, as the vertex used to select the triangle
color, then the last vertex, instead of the first
vertex, has to be consistently incremented for each
triangle in the strip or fan. In order to make this
work, when leadingVertexFirst is true, the first
vertex is consistently the lowest (consistently
incremented) vertex index and when leadingVertexFirst
is false, the last vertex is consistently the highest
vertex index.

Fixes the 2 failures in:
dEQP-GLES3.functional.rasterization.flatshading

Change-Id: Ib2247a219fe8c6725dc141e6860ba2ff521dde8c
Reviewed-on: https://swiftshader-review.googlesource.com/15468
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoClamp unsigned floating-point formats.
Nicolas Capens [Thu, 21 Dec 2017 16:20:54 +0000 (11:20 -0500)]
Clamp unsigned floating-point formats.

GL_R11F_G11F_B10F is a renderable format (in the EXT_color_buffer_float
extension) with unsigned floating-point values, which we implement using
(signed) half- or single-precision floating-point types. So we need to
clamp values to a positive range before writing to them.

Change-Id: Ic21a5b0b33905c0aeab35299fc268158f8c679f9
Reviewed-on: https://swiftshader-review.googlesource.com/15448
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse half-precision for special internal formats.
Nicolas Capens [Wed, 20 Dec 2017 16:07:45 +0000 (11:07 -0500)]
Use half-precision for special internal formats.

This change uses half-precision floating-point implementation formats
for all OpenGL half-precision floating-point formats, as well as the
R11F_G11F_B10F and RGB9_E5 special internal formats.

sw::FORMAT_X16B16G16R16F was implemented for the formats without alpha.

RGB9E5 conversion was optimized to not require powf(2.0, x), and 11-
and 10-bit floating-point formats were optimized to map directly to
16-bit half-precision floating-point.

Change-Id: Ic33f903d01f37394244aec9f53b0e67d1c978764
Reviewed-on: https://swiftshader-review.googlesource.com/15410
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 format mapping for 10F_11F_11F and RGB9_E5.
Nicolas Capens [Wed, 20 Dec 2017 16:07:45 +0000 (11:07 -0500)]
Fix format mapping for 10F_11F_11F and RGB9_E5.

GL_UNSIGNED_INT_10F_11F_11F_REV and GL_UNSIGNED_INT_5_9_9_9_REV were
using sw::FORMAT_A32B32G32R32F as the implementation format, which
resulted in using bad alpha values when it was rendered into.

Change-Id: If29da49a9dc7f7a52d8846417da66f7af929f276
Reviewed-on: https://swiftshader-review.googlesource.com/15408
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed sampler allocation
Alexis Hetu [Wed, 20 Dec 2017 19:49:37 +0000 (14:49 -0500)]
Fixed sampler allocation

Instead of testing for the number of samplers used so far
in the shader, the Program object was checking for the
register index, which could have been larger or equal to
MAX_VERTEX_TEXTURE_IMAGE_UNITS or MAX_TEXTURE_IMAGE_UNITS,
making the shader compilation fail erroneously.

Changed sampler arrays to maps in order to get the sampler
data from the register index.

Change-Id: Iba6cbf0dbbcdbd926f2670af4413710550e341a9
Reviewed-on: https://swiftshader-review.googlesource.com/15428
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix R8_SNORM implementation format.
Nicolas Capens [Tue, 19 Dec 2017 20:36:18 +0000 (15:36 -0500)]
Fix R8_SNORM implementation format.

Change-Id: I68d7dbb445eee85e8a2ff4ac3a6fc6b31c6ea305
Reviewed-on: https://swiftshader-review.googlesource.com/15369
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRename signed normalized formats.
Nicolas Capens [Tue, 19 Dec 2017 20:34:20 +0000 (15:34 -0500)]
Rename signed normalized formats.

Change-Id: I9c01d1a20920ab7e33d979fc69711c7e69113912
Reviewed-on: https://swiftshader-review.googlesource.com/15368
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoOptimize mipmap base level.
Nicolas Capens [Tue, 19 Dec 2017 15:52:14 +0000 (10:52 -0500)]
Optimize mipmap base level.

We can avoid adding the base level to the computed lod by putting the
base level at index 0 of the mipmap array.

Change-Id: I0bdebec3e4d0a3617dea9e3d28fdeb5dae40444b
Reviewed-on: https://swiftshader-review.googlesource.com/15329
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement mipmap base/max level.
Nicolas Capens [Tue, 19 Dec 2017 18:46:29 +0000 (13:46 -0500)]
Implement mipmap base/max level.

Change-Id: I611815fb0dcbba97e67f3c146dffb463f133447e
Reviewed-on: https://swiftshader-review.googlesource.com/15248
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSearch the top level from the base level.
Nicolas Capens [Tue, 19 Dec 2017 18:38:18 +0000 (13:38 -0500)]
Search the top level from the base level.

The 'top' level is the last valid mipmap level nearest to the top of
the pyramid. Start searching for it from the 'base' of the pyramid.

Change-Id: I2d2ea3a1834f6cff2e2d342876d0649205004581
Reviewed-on: https://swiftshader-review.googlesource.com/15348
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse base level for mipmap generation and completeness.
Nicolas Capens [Mon, 18 Dec 2017 20:58:46 +0000 (15:58 -0500)]
Use base level for mipmap generation and completeness.

Change-Id: Ibc557e4843d8106c07ae2f92c9628e10f228b1ae
Reviewed-on: https://swiftshader-review.googlesource.com/15208
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoValidate cube completeness for mipmap generation.
Nicolas Capens [Tue, 19 Dec 2017 15:35:40 +0000 (10:35 -0500)]
Validate cube completeness for mipmap generation.

The OpenGL ES 3.0.5 spec section 3.8.10.5 states: "For cube map
textures an INVALID_OPERATION error is generated if the texture
bound to target is not cube complete".

Change-Id: I4304ecf125528b9406a011a95d7822b1f868ee14
Reviewed-on: https://swiftshader-review.googlesource.com/15328
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed program binary failure
Alexis Hetu [Tue, 19 Dec 2017 15:53:31 +0000 (10:53 -0500)]
Fixed program binary failure

Updated glGetProgramBinary and glProgramBinary in order to properly
reflect that SwiftShader doesn't support any binary format.

Fixes dEQP-GLES3.functional.negative_api.shader.get_program_binary

Change-Id: I068ce7eb7ce824719cecca2fdc651a9e6c14190c
Reviewed-on: https://swiftshader-review.googlesource.com/15330
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Android build.
Nicolas Capens [Tue, 19 Dec 2017 14:40:53 +0000 (09:40 -0500)]
Fix Android build.

Change-Id: If37158efec1555a3b4e14774dff081f284292245
Reviewed-on: https://swiftshader-review.googlesource.com/15308
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Linux build.
Nicolas Capens [Tue, 19 Dec 2017 06:15:35 +0000 (01:15 -0500)]
Fix Linux build.

Change-Id: Ifa2239e897cfa8878a43ce6e51ab731f2b67b7b1
Reviewed-on: https://swiftshader-review.googlesource.com/15288
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix build issues.
Nicolas Capens [Tue, 19 Dec 2017 05:07:50 +0000 (00:07 -0500)]
Fix build issues.

Change-Id: I93171764df5e13a7a5be6a9116e1a5db1ed59ad5
Reviewed-on: https://swiftshader-review.googlesource.com/15268
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse an ordinary map for compatibility with legacy Android.
Nicolas Capens [Mon, 18 Dec 2017 17:40:10 +0000 (12:40 -0500)]
Use an ordinary map for compatibility with legacy Android.

<unordered_map> is not available on Android J-L.

Bug b/28006371

Change-Id: I7e06ebef092a7d3eef217f88e6fb6347c8d40ac1
Reviewed-on: https://swiftshader-review.googlesource.com/15149
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoETC2 RGBA fix
Alexis Hetu [Mon, 18 Dec 2017 22:17:55 +0000 (17:17 -0500)]
ETC2 RGBA fix

Since EAC is no longer decoded to an 8 bit format, but ETC2 alpha
still is, we need to distinguish between the 2. Added an argument
to DecodeBlock for that purpose.

Change-Id: Ied4263cecc43f88609a357437c11f4e43af229b8
Reviewed-on: https://swiftshader-review.googlesource.com/15228
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoconvert_float_int fix
Alexis Hetu [Wed, 13 Dec 2017 12:42:22 +0000 (07:42 -0500)]
convert_float_int fix

The convert_float_int was not scaling the [0,1] value to the full
1.31 fixed-point range before clamping the value.

Fixes all failures in:
dEQP-GLES3.functional.state_query.floats*

Change-Id: Ic558eb45f1f351d3c30a0a5047a1b252edb56bd0
Reviewed-on: https://swiftshader-review.googlesource.com/14968
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement sRGB conversion in the blitter.
Nicolas Capens [Sat, 16 Dec 2017 07:28:02 +0000 (02:28 -0500)]
Implement sRGB conversion in the blitter.

Note that glReadPixels() does not perform sRGB conversion.

Change-Id: I3f9089b79652ce42cb5695d5b6a8ce92d15c27a8
Reviewed-on: https://swiftshader-review.googlesource.com/14492
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 Blitter state.
Nicolas Capens [Sat, 16 Dec 2017 07:06:56 +0000 (02:06 -0500)]
Refactor Blitter state.

Change-Id: Ife3342c64dfc846f8b7722f2e80612fc71f93688
Reviewed-on: https://swiftshader-review.googlesource.com/15128
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement sRGB conversion for the fallback path.
Nicolas Capens [Fri, 1 Dec 2017 21:59:38 +0000 (16:59 -0500)]
Implement sRGB conversion for the fallback path.

Change-Id: Idba9017de6bf92142e2281bdca3cb6c73ea2451d
Reviewed-on: https://swiftshader-review.googlesource.com/14491
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement sRGB texture sampling.
Nicolas Capens [Thu, 14 Dec 2017 18:14:03 +0000 (13:14 -0500)]
Implement sRGB texture sampling.

Previously sRGB data was converted to linear space on upload. This
caused a loss of precision. This change performs the conversion after
texel lookup. Note that we had a code path for performing the
conversion after filtering, but that leads to failures in dEQP and
unacceptable darkening between texels.

Also, glTexSubImage calls can update sRGB textures using a format/type
combination with no indication of the color space, which caused an
unintentional conversion on upload. Likewise we were missing support
for an A2B10G10R10UI implementation format.

Change-Id: Ib10845f628fb2d1849e88d7a9350868cdec32fa2
Reviewed-on: https://swiftshader-review.googlesource.com/15068
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPreprocessor update from ANGLE
Alexis Hetu [Fri, 15 Dec 2017 23:01:07 +0000 (18:01 -0500)]
Preprocessor update from ANGLE

- Updated preprocessor code from Angle revision
  9fc8733187c02470a9eadb6d295348b6d37a2004
- Reran generate_parser.sh (flex 2.6.4, bison (GNU Bison) 3.0.4)
- Made a few trivial changes in src/OpenGL/compiler in order to
  adapt to the new preprocessor code.

Fixes all 24 failures in:
dEQP-GLES3.functional.shaders.preprocessor.*

Change-Id: I00d0b511d617ab81a0f57310174e1ba8bf7c22e5
Reviewed-on: https://swiftshader-review.googlesource.com/15109
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed EAC failures
Alexis Hetu [Mon, 18 Dec 2017 20:32:26 +0000 (15:32 -0500)]
Fixed EAC failures

The ETC2 decoder spec has a slight difference with the EAC decoder
spec when it comes to handling the 0 multiplier corner case.

For ETC2, we have (OpenGL ES 3.0 spec, section C.1.3):
"An encoder is not allowed to produce a multiplier of zero, but
 the decoder should still be able to handle also this case (and
 produce 0 x modifier = 0 in that case)."

For EAC, we have (OpenGL ES 3.0 spec, section C.1.5):
"If the multiplier value is zero, we should set the multiplier
 to 1.0/8.0"

In order to take this into account, the EAC decoded output can no
longer be represented by an 8 bit value, but must be represented by
a minimum of 11 bits, as the spec requires. For now, the EAC decoder
decodes EAC into a 32 bit integer format, which then gets converted
to a 32 bit float format internally.

Eventually, it would be possible for the EAC decoder to decode the
image to a signed 16 bit integer internal format, if it was supported.

Fixes all failures in:
dEQP-GLES3.functional.texture.wrap*

Change-Id: I32106383ade56e375229231ff230a2574791caa6
Reviewed-on: https://swiftshader-review.googlesource.com/15188
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix D3D8 build.
Nicolas Capens [Thu, 14 Dec 2017 17:32:51 +0000 (12:32 -0500)]
Fix D3D8 build.

Change-Id: I879eb3c3d9093f769f88bd3a2dcc67f91bd6eb47
Reviewed-on: https://swiftshader-review.googlesource.com/15049
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUpdate Google Test to latest revision.
Nicolas Capens [Thu, 14 Dec 2017 15:49:00 +0000 (10:49 -0500)]
Update Google Test to latest revision.

Fixes (suppresses) Visual Studio 2017 warning (error) about std::tr1.

Change-Id: I3319dfa77d00e81e48ef7ef0ab884e131e9a039e
Reviewed-on: https://swiftshader-review.googlesource.com/15048
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement framebuffer layer support.
Nicolas Capens [Mon, 11 Dec 2017 20:07:53 +0000 (15:07 -0500)]
Implement framebuffer layer support.

This stores the layer as part of the framebuffer object, instead of the
renderbuffer, and passes it to the renderer at draw time.

Change-Id: I947f8a58ba7a119cc9d890659c99e7e05d0d1d91
Reviewed-on: https://swiftshader-review.googlesource.com/14728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement render target layers support.
Nicolas Capens [Mon, 11 Dec 2017 19:45:01 +0000 (14:45 -0500)]
Implement render target layers support.

This adds the ability to render to a specific layer of a 2D array
texture.

Change-Id: I3055d62c9964b2729704785efb068b82eef4f9ce
Reviewed-on: https://swiftshader-review.googlesource.com/14668
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSeparate image depth and samples count.
Nicolas Capens [Mon, 11 Dec 2017 15:06:37 +0000 (10:06 -0500)]
Separate image depth and samples count.

Previously, multisampled images used the 'depth' member of 3D images
or 2D arrays as the number of samples. This caused rendering to a
layer of a 2D array to be interpreted as rendering to a multisampled
render target. This change adds a 'samples' member which is orthogonal
to 'depth'.

Note that write operations put the same color into each of the samples,
while read operations (still) assume multisampled images have been
resolved into the first slice.

Change-Id: Ib33a0cf8194e19fcbb569b0c257ba1e1bd9c4821
Reviewed-on: https://swiftshader-review.googlesource.com/14808
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 blitting of quad layout data.
Nicolas Capens [Wed, 13 Dec 2017 15:42:02 +0000 (10:42 -0500)]
Fix blitting of quad layout data.

The stencil buffer always has a quad layout, and can't be copied using
copyBuffer() even when copying the full buffer, because it copies one
row at a time (i.e. it assumes a linear layout).

Likewise a depth buffer may optionally have a quad layout and copying
the full buffer still doesn't allow using copyBuffer().

To keep maximum performance for the typical case of copying between
equally sized buffers, a new code path it added to copy the entire
slice in one memcpy() call.

Change-Id: I77f60f66e5cdcd7cf0a73d03f3d3485809d7ebe6
Reviewed-on: https://swiftshader-review.googlesource.com/15008
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
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>