OSDN Git Service

android-x86/external-swiftshader.git
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>
6 years agolibGLESv2: compile entry points in the shared library.
Corentin Wallez [Thu, 26 Oct 2017 23:27:22 +0000 (19:27 -0400)]
libGLESv2: compile entry points in the shared library.

Without this the GN shared library doesn't export any of the gl
entry-points making it useless.

Bug swiftshader:86

Change-Id: I97f6acf4204d6e908ad12c89c79d40769dc824a4
Reviewed-on: https://swiftshader-review.googlesource.com/13308
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 more explicit include paths.
Nicolas Capens [Thu, 26 Oct 2017 17:07:10 +0000 (13:07 -0400)]
Use more explicit include paths.

This helps clarify dependencies and simplifies include paths.

Bug swiftshader:86

Change-Id: I564ee420bb9029fa6428e49b63a86d633301bec2
Reviewed-on: https://swiftshader-review.googlesource.com/13288
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoData race fix
Alexis Hetu [Thu, 26 Oct 2017 18:57:17 +0000 (14:57 -0400)]
Data race fix

There's a data race involving threadCount,
so it is now an AtomicInt object.

Also removed unused extern variables.

Bug chromium:778254 chromium:776621

Change-Id: I93174e8f4e5e48f26414ba9c81bb9a2c317dbf73
Reviewed-on: https://swiftshader-review.googlesource.com/13290
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrimitive restart implementation
Alexis Hetu [Wed, 25 Oct 2017 21:25:06 +0000 (17:25 -0400)]
Primitive restart implementation

Wrote a new version of primitive restart
entirely handled by the index data manager.

Passes all primitive_restart dEQP tests

Change-Id: I0ce28764a33300a6625f1c369f95d8d178e1e3c0
Reviewed-on: https://swiftshader-review.googlesource.com/10951
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix rendering to single-channel color buffers.
Nicolas Capens [Wed, 25 Oct 2017 21:18:55 +0000 (17:18 -0400)]
Fix rendering to single-channel color buffers.

Render targets with only a red or alpha component were getting swapped
values within pixel quads at the edge of primitives. Also provide
format mappings for GL_EXT_texture_rg.

Change-Id: Ifb395039fb2958400ab36d5d184d7952d60fa9c6
Reviewed-on: https://swiftshader-review.googlesource.com/13268
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd a stub "vertex routine" fuzzer
Corentin Wallez [Tue, 24 Oct 2017 19:17:18 +0000 (15:17 -0400)]
Add a stub "vertex routine" fuzzer

Bug: swiftshader:86

Change-Id: I351e433123abfaf010e3b1641383054e77dc6383
Reviewed-on: https://swiftshader-review.googlesource.com/13228
Tested-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUpdate the Windows Target Platform Version
Alexis Hetu [Thu, 19 Oct 2017 18:53:33 +0000 (14:53 -0400)]
Update the Windows Target Platform Version

Rather than have to download a previous version (10.0.15063.0),
we can update the solution to the current version (10.0.16299.0).
Built solution in 32b/64b release/debug with no failures.

Change-Id: If19d8f6edcce4bcfac21c005f647ab1619837d16
Reviewed-on: https://swiftshader-review.googlesource.com/13208
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Visual Studio 2017 build of Debug D3D8.
Nicolas Capens [Wed, 11 Oct 2017 03:52:17 +0000 (23:52 -0400)]
Fix Visual Studio 2017 build of Debug D3D8.

Visual Studio 2017 doesn't like configuration elements with empty
content. Remove it to use the default value.

Change-Id: Idc4f281aff145c7e9a143c0a5dbdd54eb4658ee9
Reviewed-on: https://swiftshader-review.googlesource.com/13128
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpgrade SwiftShader solution and projects to Visual Studio 2017.
Nicolas Capens [Wed, 4 Oct 2017 17:39:16 +0000 (13:39 -0400)]
Upgrade SwiftShader solution and projects to Visual Studio 2017.

Chrome now uses Visual Studio 2017 as the default compiler on Windows.
To ensure we maintain compatibility during standalone development, we
should use VS2017 for SwiftShader as well. The 'Community' edition of
Visual Studio 2017 is freely available.

Bug chromium:683729

Change-Id: I3ed1edaeb9fa786b575202ba5b9c86faf1daa3c0
Reviewed-on: https://swiftshader-review.googlesource.com/13048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDo not assign a location to uniform block members
Alexis Hetu [Fri, 6 Oct 2017 17:23:49 +0000 (13:23 -0400)]
Do not assign a location to uniform block members

Uniform block members do not get a uniform location, since they
cannot be set (or get) through regular glUniform* functions. These
are instead always set using uniform buffers.

Bug chromium:763675,chromium:763698,chromium:771639

Change-Id: Icf65eba3faab420c63f70af66f828a786e3fc446
Reviewed-on: https://swiftshader-review.googlesource.com/13068
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoRename version scripts to linker scripts.
Nicolas Capens [Fri, 6 Oct 2017 15:24:13 +0000 (11:24 -0400)]
Rename version scripts to linker scripts.

Blaze (Bazel) requires linker dependencies to have a .ld, .lds, or
.ldscript extension. Note that version scripts are just the contents of
the VERSION command in (true) linker scripts. However, the gold linker
used by Android does not support implicit linker scripts (which amend
the default linker script), nor the INSERT command. Therefore these
linker scripts are still actually just version scripts.

https://sourceware.org/binutils/docs/ld/VERSION.html

Bug b/67482470

Change-Id: I3bbe25dab6d916376bdc41bb723279ed2ef62fb0
Reviewed-on: https://swiftshader-review.googlesource.com/13108
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 depth clamping during 'very' early depth test.
Nicolas Capens [Thu, 5 Oct 2017 20:05:47 +0000 (16:05 -0400)]
Fix depth clamping during 'very' early depth test.

We perform depth testing before computing scanline invariants, as an
optimization. But it was not taking into account that the
fixed-function depth value may require clamping due to the depth bias.

Bug swiftshader:82

Change-Id: I6f8953f9d060c73b5fe209b8cbad70e7cb7588b4
Reviewed-on: https://swiftshader-review.googlesource.com/13088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoIncrease coverage of Swizzle test in Reactor
Casey Dahlin [Tue, 3 Oct 2017 20:23:11 +0000 (13:23 -0700)]
Increase coverage of Swizzle test in Reactor

Test: Improved test passes
Bug: b/67106219
Change-Id: Iab15a2331a91dffaaeb1627a42d0fb88dfa841d0
Reviewed-on: https://swiftshader-review.googlesource.com/13028
Tested-by: Casey Dahlin <sadmac@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix for 3D texture sampling
Alexis Hetu [Tue, 3 Oct 2017 17:56:07 +0000 (13:56 -0400)]
Fix for 3D texture sampling

3D texture sampling did not support width*height > MAX_USHORT(65535).
Changed for 32 bit integer computation for that multiplication to
solve this issue.

Verified with 3D texture related dEQP tests.

Bug b/26105892 chromium:763382

Change-Id: Ifd07278f6263d000620a0b525c07ed4fcbdcf2e7
Reviewed-on: https://swiftshader-review.googlesource.com/12988
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoEnable use of NEON intrinsics on ARM.
Nicolas Capens [Tue, 3 Oct 2017 18:56:49 +0000 (14:56 -0400)]
Enable use of NEON intrinsics on ARM.

Bug b/37496338
Bug b/37495545
Bug b/37496078
Bug b/37496856
Bug b/37496321
Bug b/37496082

Change-Id: I173a296703fcc1f49810742d95ae6abe7c9bcf01
Reviewed-on: https://swiftshader-review.googlesource.com/12868
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSpill whole vector registers to the stack.
Nicolas Capens [Tue, 3 Oct 2017 18:26:07 +0000 (14:26 -0400)]
Spill whole vector registers to the stack.

Subzero assumes that stores and loads to/from stack memory can take an
immediate offset. This isn't true for sub-vector loads and stores. We
can just use regular full vector loads and stores instead.

Bug b/37496321

Change-Id: Iaffd60f8077a4c9d602665421f90a7288ab04050
Reviewed-on: https://swiftshader-review.googlesource.com/13008
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd test for MulAdd in Reactor
Casey Dahlin [Tue, 3 Oct 2017 18:24:01 +0000 (11:24 -0700)]
Add test for MulAdd in Reactor

Test: New test passes
Bug: b/37496078
Change-Id: Ieff1b080bdde3f9c86a0531566c8b08d7cdf24fe
Reviewed-on: https://swiftshader-review.googlesource.com/13009
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Casey Dahlin <sadmac@google.com>
6 years agoOptimize common vector shuffle patterns for ARM32.
Nicolas Capens [Mon, 2 Oct 2017 14:44:03 +0000 (10:44 -0400)]
Optimize common vector shuffle patterns for ARM32.

Use VDUP for replicating a single element.
Use VZIP for interleaving vectors.
Use VMOV Dd, Dm for rearranging quadword vectors.

Bug b/67106219

Change-Id: I0de1457454c1db6d467bf870288b7af7cb59ac09
Reviewed-on: https://chromium-review.googlesource.com/695004
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12968
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix vector packing pseudo-instruction.
Nicolas Capens [Mon, 2 Oct 2017 21:41:13 +0000 (17:41 -0400)]
Fix vector packing pseudo-instruction.

When the first source register is different from the destination
register, but equal to the second source, we need to first narrow
the second source to prevent overwriting data we still need. Similar
when the destination is equal to the first source.

Bug b/37496082

Change-Id: I908a8e125a77ec4bf1eb5eab9e48c6112ee4ca13
Reviewed-on: https://chromium-review.googlesource.com/696032
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12949
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdding support for more format/internalformat combinations
Alexis Hetu [Mon, 2 Oct 2017 19:27:03 +0000 (15:27 -0400)]
Adding support for more format/internalformat combinations

OpenGLES 3.0 allows for more combinations of format/internalformat
for floating point types. These types were already supported, just
not using the combinations added here.

Bug chromium:763384

Change-Id: I146548c2920799c7ea0d5d537d556ba562708147
Reviewed-on: https://swiftshader-review.googlesource.com/12928
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd test for MulHigh in Reactor
Casey Dahlin [Mon, 2 Oct 2017 22:02:02 +0000 (15:02 -0700)]
Add test for MulHigh in Reactor

Test: New tests pass
Bug: b/37496856
Change-Id: Ifae1f802d61a7d51f6e8f5c135e3c8c67be30125
Reviewed-on: https://swiftshader-review.googlesource.com/12950
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Casey Dahlin <sadmac@google.com>
6 years agoFix emulation of Short to Byte saturation.
Nicolas Capens [Mon, 2 Oct 2017 21:32:34 +0000 (17:32 -0400)]
Fix emulation of Short to Byte saturation.

We weren't clamping the value when less than zero.

Bug b/37496082

Change-Id: I3170d14a622f8571f0142dd4ce80f96617c7e0aa
Reviewed-on: https://swiftshader-review.googlesource.com/12948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Casey Dahlin <sadmac@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix vector packing regression.
Nicolas Capens [Mon, 2 Oct 2017 19:26:11 +0000 (15:26 -0400)]
Fix vector packing regression.

When SSE4.1 isn't available, we were infinitely calling PackUnsigned()
recursively.

Bug b/37496082

Change-Id: Ie1fa8150d64740776c5b80baf07d997dde9d51be
Reviewed-on: https://swiftshader-review.googlesource.com/12929
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Casey Dahlin <sadmac@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd test for PackSigned/PackUnsigned in Reactor
Casey Dahlin [Fri, 29 Sep 2017 23:32:32 +0000 (16:32 -0700)]
Add test for PackSigned/PackUnsigned in Reactor

Test: New tests pass
Bug: b/37496082
Change-Id: I4a0aae14318f03b5ce59f12f7542db13270f52ab
Reviewed-on: https://swiftshader-review.googlesource.com/12848
Tested-by: Casey Dahlin <sadmac@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix for integer modulo operations
Alexis Hetu [Mon, 2 Oct 2017 17:48:19 +0000 (13:48 -0400)]
Fix for integer modulo operations

Integer division already had this modification, to avoid
division by 0, but integer modulo hadn't been modified
to match the other fix, which is now done here.

Bug chromium:763435

Change-Id: I40f4ed9f1c4b5889ddf47abc1bb7c70c21cbd7b8
Reviewed-on: https://swiftshader-review.googlesource.com/12908
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement vector intrinsics for ARM32.
Nicolas Capens [Wed, 27 Sep 2017 19:06:35 +0000 (15:06 -0400)]
Implement vector intrinsics for ARM32.

MultiplyAddPairs is implemented using VMULL+VPADD.
MultiplyHighSigned/Unsigned is implemented using VMULL+VSHRN.
SubVectorLoad/Store is implemented using VLDR/VLD1/VSTR/VST1.
VectorPackSigned/Unsigned is implemented using two VQMOVN.

Bug b/37496078
Bug b/37496856
Bug b/37496321
Bug b/37496082

Change-Id: I141fd901d53da24ce780f503dc7ad17b94fc6ba8
Reviewed-on: https://chromium-review.googlesource.com/693049
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12709
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd test for Unpack in Reactor
Casey Dahlin [Fri, 29 Sep 2017 20:43:18 +0000 (13:43 -0700)]
Add test for Unpack in Reactor

Test: New test passes
Bug: b/67106219
Change-Id: Ib21f73d312d39cf2b3aa15a11d2a207885a58978
Reviewed-on: https://swiftshader-review.googlesource.com/12828
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Casey Dahlin <sadmac@google.com>
6 years agoPrevent division by 0
Alexis Hetu [Wed, 27 Sep 2017 18:43:38 +0000 (14:43 -0400)]
Prevent division by 0

If imageSize is 0, inputPitch may be 0, which would cause a division
by 0. In any case, if imageSize is 0, there's no work to perform, so
we just skip loadCompressedData() entirely in that case.

Bug:765094

Change-Id: Iedc6516ef6d025d24a8827597045cb3b83599e4a
Reviewed-on: https://swiftshader-review.googlesource.com/12648
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoHandle WindowSurface::checkForResize() errors gracefully
Alexis Hetu [Fri, 29 Sep 2017 17:13:14 +0000 (13:13 -0400)]
Handle WindowSurface::checkForResize() errors gracefully

WindowSurface::checkForResize() contained an assert which got
triggered in some tests. In order to avoid this issue, this cl
gracefully handles an invalid window handle.

Change-Id: I6bace88370980e94676d4af9de0d88e561175835
Reviewed-on: https://swiftshader-review.googlesource.com/12808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd tests for AddSat/SubSat in Reactor
Casey Dahlin [Fri, 29 Sep 2017 00:18:41 +0000 (17:18 -0700)]
Add tests for AddSat/SubSat in Reactor

Bug b/37495545

Test: New tests pass
Change-Id: Icc81729d8c65aadccdd685490218d298e671b638
Reviewed-on: https://swiftshader-review.googlesource.com/12768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Casey Dahlin <sadmac@google.com>
6 years agoSupport saturating vector add and subtract on ARM32.
Casey Dahlin [Wed, 28 Jun 2017 20:58:58 +0000 (13:58 -0700)]
Support saturating vector add and subtract on ARM32.

Bug b/37495545

Change-Id: I1d025f894bb7cf08dcaafd950605781633596ab3
Reviewed-on: https://chromium-review.googlesource.com/689098
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12748
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport vector shift by constant for ARM32.
Nicolas Capens [Wed, 27 Sep 2017 18:33:11 +0000 (14:33 -0400)]
Support vector shift by constant for ARM32.

This also fixes the encoding of right shifts with unsigned elements.

Bug b/37496338

Change-Id: I9a1dc91359daea5f4391a137b7f9e03bd941146b
Reviewed-on: https://chromium-review.googlesource.com/688057
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12668
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd intrinsic lowering stubs for ARM.
Nicolas Capens [Tue, 18 Apr 2017 19:14:16 +0000 (15:14 -0400)]
Add intrinsic lowering stubs for ARM.

Change-Id: I24a2ac536c24732538cc5c7f2aad4e7763989f9e
Reviewed-on: https://chromium-review.googlesource.com/568673
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12690
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUpload pnacl-subzero changes to Gerrit by default
Aaron Gable [Wed, 26 Jul 2017 22:11:04 +0000 (15:11 -0700)]
Upload pnacl-subzero changes to Gerrit by default

R=bradnelson@chromium.org

Bug: 665593
Change-Id: I1b9a5fd31c5e426bd193a32a2feb291eb17af5a6
Reviewed-on: https://chromium-review.googlesource.com/587993
Reviewed-by: Brad Nelson <bradnelson@chromium.org>
Reviewed-on: https://swiftshader-review.googlesource.com/12689
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDo not inline GlobalContext TLS methods.
Lei Zhang [Tue, 23 May 2017 22:08:59 +0000 (15:08 -0700)]
Do not inline GlobalContext TLS methods.

The gold linker thinks that causes an ODR violation.

BUG=chromium:449754
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/2896133003 .

Patch from Lei Zhang <thestig@chromium.org>.

Change-Id: I7f39b1f6e638ad3462b9b462ebdb6348473b9fc5
Reviewed-on: https://swiftshader-review.googlesource.com/12688
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor vector packing.
Nicolas Capens [Wed, 27 Sep 2017 15:47:35 +0000 (11:47 -0400)]
Refactor vector packing.

x86 vector packing instructions always treat the input as having signed
integer components, but can perform signed or unsigned saturation on
the output. In Reactor the Pack() intrinsic has overloads which
differentiate between them based on the signedness of the input, but
this is confusing.

Also simplify emulation of saturating add/subtract.

Bug b/37496082

Change-Id: I0625fff429ffb40f42baf9600c7760d9858b5d89
Reviewed-on: https://swiftshader-review.googlesource.com/12548
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBreak on gtest failures in debug mode.
Nicolas Capens [Wed, 27 Sep 2017 16:56:26 +0000 (12:56 -0400)]
Break on gtest failures in debug mode.

Google Test by default disables breaking into the debugger to be able
to run to completion without interaction. Enable it for debug builds
within Visual Studio.

Change-Id: If36e3d74ab1ec98eefa221761e02a33bd8117151
Reviewed-on: https://swiftshader-review.googlesource.com/12588
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBuild before debugging with Visual Studio Code.
Nicolas Capens [Wed, 27 Sep 2017 14:44:13 +0000 (10:44 -0400)]
Build before debugging with Visual Studio Code.

Call make before launching a debug session. Also move from the 'build'
subdirectory to the 'debug' subdirectory to allow for a separate
release build or other configuration.

Change-Id: I6db00a5bb0a707ebbf9c160897852526a8bb73e1
Reviewed-on: https://swiftshader-review.googlesource.com/12528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix initial framerate and show maximum.
Nicolas Capens [Wed, 27 Sep 2017 14:22:08 +0000 (10:22 -0400)]
Fix initial framerate and show maximum.

We don't start timing until after the first frame finished rendering
and is presented, so the frame count has to be 0 at that point.

Change-Id: Ic242bb5625c6c50694e7625008565ee421859624
Reviewed-on: https://swiftshader-review.googlesource.com/12488
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed crash in Renderer
Alexis Hetu [Wed, 27 Sep 2017 17:15:59 +0000 (13:15 -0400)]
Fixed crash in Renderer

The problem was at line 827, where "(qHead - qSize) % 32" could give
unexpected results if qSize > gHead (which wasn't a problem with
unsigned values). Also removed other % operations which could have
cause some issues.

Change-Id: Ia443e05ce1add3879720e90f7dbac771e712d2ab
Reviewed-on: https://swiftshader-review.googlesource.com/12568
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoLinux build fix
Alexis Hetu [Wed, 27 Sep 2017 14:31:28 +0000 (10:31 -0400)]
Linux build fix

The copy constructor of std::atomic is not allowed, so initialization
through operator= is not allowed. Explicitly using the AtomicInt
constructor to fix this issue.

Change-Id: If77763e89e0d958d8a4b5a83d5d7bd9e3ba08ff6
Reviewed-on: https://swiftshader-review.googlesource.com/12508
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoProperly initializing image's memory
Alexis Hetu [Mon, 25 Sep 2017 19:56:44 +0000 (15:56 -0400)]
Properly initializing image's memory

MSAN detected uninitialized memory which caused many test failures.
This can be easily fixed by zeroing out the memory before calling
XCreateImage.

Change-Id: I913c818ef38446055af7fd6aa885028e5f3f8bfb
Reviewed-on: https://swiftshader-review.googlesource.com/12388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMore data races fixed
Alexis Hetu [Fri, 22 Sep 2017 21:02:24 +0000 (17:02 -0400)]
More data races fixed

A few more variables were causing possible data races,
so they were changed to AtomicInt variables.

Change-Id: Icf233482528e086fc58f6919232ab2e3f0784689
Reviewed-on: https://swiftshader-review.googlesource.com/12368
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse atomic operations to specify shared memory access order
Alexis Hetu [Wed, 20 Sep 2017 15:24:52 +0000 (11:24 -0400)]
Use atomic operations to specify shared memory access order

TSAN detected many data race errors in the SwiftShader Renderer
class. x86 has a strong memory ordering model which guarantees
that changes are observed in the same order by other threads.
However, C++ does not provide such guarantees unless specified
using atomic operations. In order to fix these, a new AtomicInt
class was added which is a basically a wrapper class for
std::atomic<int> and which only exposes the portion of the API
required by SwiftShader.

Since std::atomic isn't available on older versions of Android,
a fallback class was implemented without using std::atomic, which
is closer to the previous implementation. Both classes appear to
work properly after performing a few dEQP tests. Both also perform
similarly.

A few minor changes were made in order to attempt to reduce the use
of atomic integer operations when possible.

Change-Id: Ife6d3a2b6113346f8f8163b692e79c2a0e03b22f
Reviewed-on: https://swiftshader-review.googlesource.com/12308
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoEnable more checks on Chromium trybots
Alexis Hetu [Wed, 20 Sep 2017 19:55:08 +0000 (15:55 -0400)]
Enable more checks on Chromium trybots

In order to catch errors faster, this change enables asserts on
Chromium trybots.

Change-Id: Ifdc4c9e0ec7d54aa7f6f333d992054c4e0062efe
Reviewed-on: https://swiftshader-review.googlesource.com/12328
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement X11 onscreen framerate counter.
Nicolas Capens [Fri, 15 Sep 2017 18:59:38 +0000 (14:59 -0400)]
Implement X11 onscreen framerate counter.

This FPS counter is disabled by default.

Change-Id: Ida04352dece25a212cb678c9ceca4c31d654f373
Reviewed-on: https://swiftshader-review.googlesource.com/12128
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 implementation format for default renderbuffer.
Nicolas Capens [Mon, 18 Sep 2017 15:33:59 +0000 (11:33 -0400)]
Fix implementation format for default renderbuffer.

The spec defines that the initial state for a newly bound renderbuffer
has a format of RGBA4. However, when querying the number of red/green/
blue/alpha/depth/stencil bits, we should report the actual number of
bits allocated (0), and not assert.

Bug chromium:765912
Bug b/25351344

Change-Id: Icc3eb59e76bcbd6f0f2f16a2a75ace706ae17251
Reviewed-on: https://swiftshader-review.googlesource.com/12148
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 polygon offset depth clamp and units resolution.
Nicolas Capens [Fri, 15 Sep 2017 15:49:31 +0000 (11:49 -0400)]
Fix polygon offset depth clamp and units resolution.

OpenGL requires depth values to be clamped to the [0, 1] range. Due to
frustum clipping already limiting the range, this can only happen when
non-zero polygon offset parameters are active.

Also fix the 'minimum resolvable difference' for the 32-bit floating-
point internal depth format that we use.

Bug swiftshader:82

Change-Id: Ic9ebcac182a2bc81ab51d79cfe0bb451d340bd1e
Reviewed-on: https://swiftshader-review.googlesource.com/12108
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>