OSDN Git Service

android-x86/external-swiftshader.git
6 years agoFix memory leak on error.
Nicolas Capens [Fri, 26 Jan 2018 01:35:42 +0000 (01:35 +0000)]
Fix memory leak on error.

Bug chromium:805881

Change-Id: I2729fd81dbf2ac40bcfb5a0781cf57daefc4f75a
Reviewed-on: https://swiftshader-review.googlesource.com/16748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix missing comparison operators.
Nicolas Capens [Fri, 26 Jan 2018 01:24:57 +0000 (01:24 +0000)]
Fix missing comparison operators.

The types can differ for many opcodes where the right-hand side is a
constant, and this assert isn't that useful, so just remove the opcode
checks.

Bug chromium:805881

Change-Id: Ibcbda5123aaeaaf5753732d7cad4b5a3b331e963
Reviewed-on: https://swiftshader-review.googlesource.com/16730
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 checking each cube face for changes.
Nicolas Capens [Fri, 26 Jan 2018 01:19:32 +0000 (01:19 +0000)]
Fix checking each cube face for changes.

Bug chromium:805881

Change-Id: I4b63d6415e87f32cc1402649486b2e4d821db546
Reviewed-on: https://swiftshader-review.googlesource.com/16729
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd missing break in switch.
Nicolas Capens [Fri, 26 Jan 2018 01:14:34 +0000 (01:14 +0000)]
Add missing break in switch.

Also replace some extension enums with core ones.

Bug chromium:805881

Change-Id: I80a9b658fb8dda9c759c4d79b89fbe71b8b91ae1
Reviewed-on: https://swiftshader-review.googlesource.com/16728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoCherry-pick r322885 from LLVM.
Peter Collingbourne [Thu, 18 Jan 2018 20:51:47 +0000 (12:51 -0800)]
Cherry-pick r322885 from LLVM.

This fixes a build issue when building with libc++ on Windows.

Bug: chromium:801780
Change-Id: I8fa84cefa272c2f3b096b2aada793192a47cc0e3
Reviewed-on: https://swiftshader-review.googlesource.com/16468
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Peter Collingbourne <pcc@google.com>
6 years agoDon't define _HAS_EXCEPTIONS to 0 with libc++.
Peter Collingbourne [Thu, 25 Jan 2018 02:42:02 +0000 (18:42 -0800)]
Don't define _HAS_EXCEPTIONS to 0 with libc++.

libc++ uses a predefined macro to control whether to use exceptions, so
defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
breaks libc++ because it depends on MSVC headers that only provide
certain declarations if _HAS_EXCEPTIONS is 1.

Bug: chromium:801780
Change-Id: I0d0c04e55e1e91c3ce7fe90d15b55de0cd7a21ac
Reviewed-on: https://swiftshader-review.googlesource.com/16688
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Peter Collingbourne <pcc@google.com>
6 years agoUNIFORM_BUFFER_OFFSET_ALIGNMENT set to 4
Alexis Hetu [Tue, 23 Jan 2018 22:11:05 +0000 (17:11 -0500)]
UNIFORM_BUFFER_OFFSET_ALIGNMENT set to 4

We previously had UNIFORM_BUFFER_OFFSET_ALIGNMENT set to 1. That
value was arbitrary, and WebGL expects that value to be 4, so I
made the change.

Fixes WebGL 2 test:
deqp/functional/gles3/negativebufferapi.html

Change-Id: I7ab654cce629ac2a5dffc9a9d3bff3c1fb1ec8c7
Reviewed-on: https://swiftshader-review.googlesource.com/16608
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMake it possible to build SwiftShader for Fuchsia.
Sergey Ulanov [Wed, 10 Jan 2018 23:12:42 +0000 (15:12 -0800)]
Make it possible to build SwiftShader for Fuchsia.

With this change SwiftShader is buildable for Fuchsia. Integration with
Mozard for EGL will be implemented in a separate CL.

Bug: chromium:800951
Change-Id: I60160c91aecaa6cdc6b07de688ff54b686613ab3
Reviewed-on: https://swiftshader-review.googlesource.com/16148
Tested-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix texture upload format.
Nicolas Capens [Thu, 18 Jan 2018 05:04:26 +0000 (00:04 -0500)]
Fix texture upload format.

We were using the effective sized internal format as the upload format
of glTexImage*() calls. This caused issues when using e.g.
GL_RGBA16F with GL_RGBA / GL_FLOAT.

Change-Id: I2dbd7142447c5330eec1895b1a9652ac20f8414a
Reviewed-on: https://swiftshader-review.googlesource.com/16448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBump the major version number.
Nicolas Capens [Wed, 17 Jan 2018 17:45:40 +0000 (12:45 -0500)]
Bump the major version number.

With OpenGL ES 3.0 now fully supported, this will help discern between
older and newer builds.

Change-Id: I2506d09cf8c9bc59e3c60918ce3d758b0f20586a
Reviewed-on: https://swiftshader-review.googlesource.com/16409
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 Android build.
Nicolas Capens [Wed, 17 Jan 2018 17:29:33 +0000 (12:29 -0500)]
Fix Android build.

Linux builds can assume to use X11, except if it's Android.

Change-Id: I1dc11b5fea73f198ea63d39ca924e95c1d150336
Reviewed-on: https://swiftshader-review.googlesource.com/16408
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agocreateDepthStencilSurface stencil fix
Alexis Hetu [Tue, 16 Jan 2018 20:02:03 +0000 (15:02 -0500)]
createDepthStencilSurface stencil fix

Stencil formats were prohibited from createDepthStencilSurface
in debug builds due to an assert, so fixed the assert.

Change-Id: I5777a081371be4f43810de4450b415c55f04a8d7
Reviewed-on: https://swiftshader-review.googlesource.com/16348
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMaximum call stack depth increase
Alexis Hetu [Mon, 15 Jan 2018 21:16:27 +0000 (16:16 -0500)]
Maximum call stack depth increase

dEQP requires a stack depth of at least 33 for all tests to
pass. Since the stack depth in swiftshader is arbitrary and
doesn't actually depend on hardware, the maximum stack depth
was increased from 16 to 64.

Also added a bit of log info to make debugging easier.

Fixes 2 dEQP tests:
dEQP-GLES3.performance.compiler.optimization.function_inlining.32_nested_*

Change-Id: I95ae335977d4eb3b21a54296b7fc5e6019595e66
Reviewed-on: https://swiftshader-review.googlesource.com/16328
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix varying validation.
Nicolas Capens [Thu, 11 Jan 2018 19:46:12 +0000 (14:46 -0500)]
Fix varying validation.

glGetFragDataLocation() should only query fragment output varyings.
Also fix checking for too many varyings.

Change-Id: I0981fb69a28762b6d41a22e0544d63c76510000c
Reviewed-on: https://swiftshader-review.googlesource.com/16209
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoeglWaitClient, eglWaitGL and eglWaitNative implementation
Alexis Hetu [Mon, 15 Jan 2018 20:49:42 +0000 (15:49 -0500)]
eglWaitClient, eglWaitGL and eglWaitNative implementation

Chrome tests apparently require these now, so implement
these to avoid Linux (debug) related crashes.

Change-Id: I603e69eeee166affaf6d456039d75b71d33c3914
Reviewed-on: https://swiftshader-review.googlesource.com/16329
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoGLSL mix implementation
Alexis Hetu [Fri, 12 Jan 2018 16:59:35 +0000 (11:59 -0500)]
GLSL mix implementation

Added mix implementation with a bvec as a 3rd argument,
which is basically a select.

Fixes 18 failures in dEQP-GLES3.

Change-Id: Ifaf4a27e1a25fbaad979a7d26ad4a424631acd08
Reviewed-on: https://swiftshader-review.googlesource.com/16288
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove GL_APPLE_texture_format_BGRA8888 from gl strings
Alexis Hetu [Fri, 12 Jan 2018 15:32:58 +0000 (10:32 -0500)]
Remove GL_APPLE_texture_format_BGRA8888 from gl strings

Exposing "GL_APPLE_texture_format_BGRA8888" fully enables BGRA8 in
Chromium and it seems like SwiftShader isn't properly supporting it
yet, so removing the string for now in order to do the DEPS roll.

Change-Id: I72f57899b820c22ac76a59b0b7a5e3d2a920e2b3
Reviewed-on: https://swiftshader-review.googlesource.com/16268
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoEnable OpenGL ES 3.0 unconditionally.
Nicolas Capens [Thu, 11 Jan 2018 17:53:57 +0000 (12:53 -0500)]
Enable OpenGL ES 3.0 unconditionally.

We are now passing all of dEQP-GLES3 mustpass tests.

Change-Id: I98a4e57c4cf90a3b193e220e75a97b9657c746e7
Reviewed-on: https://swiftshader-review.googlesource.com/16208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix validation of statically referenced varyings.
Nicolas Capens [Wed, 10 Jan 2018 17:46:52 +0000 (12:46 -0500)]
Fix validation of statically referenced varyings.

Varyings and in/out variables that are passed between shader pipeline
stages are verified to have matching types at link-time, even when only
statically referenced (this includes trivially optimized out branches)
or even just declared.

GLSL ES 3.00 - 4.3.10 Linking of Vertex Outputs and Fragment Inputs

Change-Id: I122b1cdcc4630c86a8ebfb4d4e37f3a7a335afbe
Reviewed-on: https://swiftshader-review.googlesource.com/16070
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 exp2 for integer input.
Nicolas Capens [Thu, 11 Jan 2018 03:34:19 +0000 (22:34 -0500)]
Fix exp2 for integer input.

exp2(x) should be exact for integer values of x. For example exp(1.0)
should produce 2.0.

Change-Id: I9d6d1d388c23e813e09b7b5788c929ff07189357
Reviewed-on: https://swiftshader-review.googlesource.com/16188
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed more BGRA failures
Alexis Hetu [Wed, 10 Jan 2018 22:33:02 +0000 (17:33 -0500)]
Fixed more BGRA failures

BGRA8 was missing from the list of valid internal formats

Change-Id: Id5c08267e04cefaf621edecb963d65a45d40e041
Reviewed-on: https://swiftshader-review.googlesource.com/16128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoExpose GL_APPLE_texture_format_BGRA8888.
Nicolas Capens [Wed, 10 Jan 2018 15:53:33 +0000 (10:53 -0500)]
Expose GL_APPLE_texture_format_BGRA8888.

GL_APPLE_texture_format_BGRA8888 is similar to
GL_EXT_texture_format_BGRA8888 but explicitly mentions texture storage
support for OpenGL ES 3.0. It adds the format as texture-only (i.e.
non-renderable), but GL_EXT_texture_format_BGRA8888 makes it color-
renderable.

Also allow a sized internalformat of GL_BGRA8_EXT. Previously we were
only allowing unsized internalformat GL_BGRA.

Change-Id: Ieb3a4f85847035392445d0a924591f5531e424d9
Reviewed-on: https://swiftshader-review.googlesource.com/16069
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRestore BGRA support
Alexis Hetu [Wed, 10 Jan 2018 15:27:56 +0000 (10:27 -0500)]
Restore BGRA support

BGRA support was removed in recent refactoring, since no dEQP
must pass test required it, but Chrome still requires it.

Change-Id: I638adce7dfeeaf85bb1f6d9889103fb4fde26d96
Reviewed-on: https://swiftshader-review.googlesource.com/16068
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDetect redefinition of function name as variable.
Nicolas Capens [Wed, 10 Jan 2018 02:39:21 +0000 (21:39 -0500)]
Detect redefinition of function name as variable.

We were previously already detecting when a variable name was redefined
as a function, but not the inverse. The fix involves inserting the
unmangled function name into the symbol table.

Change-Id: I0efd1309d45f004c8d1c5ceb864e08c2ebe22f1d
Reviewed-on: https://swiftshader-review.googlesource.com/16048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoBuild fix
Alexis Hetu [Tue, 9 Jan 2018 21:44:59 +0000 (16:44 -0500)]
Build fix

Bug swiftshader:94

Change-Id: I4214270b4ee0dad3f13a8e1556ce0c6366bb045b
Reviewed-on: https://swiftshader-review.googlesource.com/16029
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse exact-at-power-of-two reciprocal for texture projection.
Nicolas Capens [Tue, 9 Jan 2018 21:27:15 +0000 (16:27 -0500)]
Use exact-at-power-of-two reciprocal for texture projection.

Change-Id: I1b3a4bb977ea5d311be6af9b6b8f04235b002dbe
Reviewed-on: https://swiftshader-review.googlesource.com/16028
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 multisample line rasterization.
Nicolas Capens [Tue, 9 Jan 2018 20:34:26 +0000 (15:34 -0500)]
Fix multisample line rasterization.

Multisampled lines should be rasterized as rectangles, even when we
don't support wide lines (i.e. they are one pixel wide).

Change-Id: I4960ea7347f826b3af1ff6830ebde46d3065aea9
Reviewed-on: https://swiftshader-review.googlesource.com/16008
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 depth format assert.
Nicolas Capens [Mon, 8 Jan 2018 22:11:37 +0000 (17:11 -0500)]
Fix depth format assert.

Recently added depth formats were not recognized and caused an assert.

Change-Id: Ide1c783f183770d40673051ccd48b3f8e689f8db
Reviewed-on: https://swiftshader-review.googlesource.com/15969
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFiltering fix for out of bounds blit
Alexis Hetu [Tue, 9 Jan 2018 13:31:02 +0000 (08:31 -0500)]
Filtering fix for out of bounds blit

Removed a conversion to integer which was removing all subpixel
precision from coordinates when using clampToEdge.

Passes all out of bounds cases (this cl should only affect these cases).

Fixes:
dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_linear_out_of_bounds_blit_from_default

Change-Id: Id7cef212ea2b739ef22148779dbc1228628e4440
Reviewed-on: https://swiftshader-review.googlesource.com/15988
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix sRGB linear filtering in blitter
Alexis Hetu [Mon, 8 Jan 2018 22:22:15 +0000 (17:22 -0500)]
Fix sRGB linear filtering in blitter

Fixed sRGB filtering by performing the conversion
pre-filtering when appropriate.

Change-Id: Id24898feed7e9a7dadff45431198771af25efed7
Reviewed-on: https://swiftshader-review.googlesource.com/15409
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoStructure field type validation
Alexis Hetu [Fri, 5 Jan 2018 20:48:12 +0000 (15:48 -0500)]
Structure field type validation

Uniforms and varyings structures were simply validating
that both versions in fragment and vertex shaders were
structures, without validating that the fields actually
matched.

All the structures and data required to perform the
validation at link time was added.

Fixes:
dEQP-GLES3.functional.shaders.linkage.uniform.struct.type_conflict_1

Change-Id: Icbf888bbebf4ccf7d27f48cb98d4cd7ea5b42ca3
Reviewed-on: https://swiftshader-review.googlesource.com/15848
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix break statement.
Nicolas Capens [Mon, 8 Jan 2018 17:57:52 +0000 (12:57 -0500)]
Fix break statement.

The break 'depth' was used to indicate the number of if/else execution
enable mask's stack levels we need to discard when jumping from a break
statement to its enclosing switch or loop. However, each switch and
loop resets this depth at the end, which isn't correct for nested loops
and/or switches (note that switches contain if/else statements, and
loops use the same 'enable' masks as if/else).

This can be fixed either by using a stack to keep track of the break
depths of nested switch/loop statements, or by simply not jumping
directly from the break statement to the end of it's enclosing switch
or loop. The latter fix was chosen for this change, which assumes that
that it's uncommon for all vector lanes to become disabled at the break
statement and skip many instructions. An important exception to this is
breaking out of an infinite or long-running loop, but this is handled
by checking the break enable mask as part of the loop condition.

Change-Id: I57d2e03941e855faefd997442931ff8619eca73f
Reviewed-on: https://swiftshader-review.googlesource.com/15968
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 restoring the break execution enable mask.
Nicolas Capens [Mon, 8 Jan 2018 19:09:51 +0000 (14:09 -0500)]
Fix restoring the break execution enable mask.

Switch statements and loops should not reset the execution enable mask
to all lanes at the end, because they can be nested. Instead we can
just restore them to the mask value before the switch/loop.

Change-Id: I4089cbf637c28f39a536de1e68e2e513ead1ec7f
Reviewed-on: https://swiftshader-review.googlesource.com/15908
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 loops with dynamic iteration count.
Nicolas Capens [Sat, 6 Jan 2018 09:28:51 +0000 (04:28 -0500)]
Fix loops with dynamic iteration count.

The 'enable' execution mask for if/else, which is also used by loops,
was not being applied to predicate the instructions within a loop.

Bug b/28710510

Change-Id: Ibd8e962ef60de76ec1c018ca064a791abf214c94
Reviewed-on: https://swiftshader-review.googlesource.com/15948
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 switch statements in loops.
Nicolas Capens [Fri, 5 Jan 2018 20:34:00 +0000 (15:34 -0500)]
Fix switch statements in loops.

Switch statements were resetting the 'enable' execution mask stack to
all lanes, which caused us to execute the switch operations even for
lanes that were already done looping.

Change-Id: Ie5a525e8de8d5e61d4c61bcee81bd81fa862d917
Reviewed-on: https://swiftshader-review.googlesource.com/15828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUniform block instance name validation
Alexis Hetu [Fri, 5 Jan 2018 21:17:56 +0000 (16:17 -0500)]
Uniform block instance name validation

This cl adds validation that uniform block instance names aren't
reserved names.

Fixes 2 tests:
dEQP-GLES3.functional.shaders.uniform_block.invalid.invalid_identifier_instance_name_*

Change-Id: I4a39c734cdf4d11ea4221c73c1f639fa2f56921d
Reviewed-on: https://swiftshader-review.googlesource.com/15868
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllow blitting with out of bounds source coordinates
Alexis Hetu [Tue, 19 Dec 2017 20:37:46 +0000 (15:37 -0500)]
Allow blitting with out of bounds source coordinates

Removed early return on source rectangle validation, in order
to allow out of bounds coordinates as an input to the blitter.

Fixes 31 *out_of_bounds* failures in:
dEQP-GLES3.functional.fbo.blit.default_framebuffer

Also fixes 3 scissored blit failures in:
dEQP-GLES3.functional.fragment_ops.scissor

Change-Id: I0751678153aa0fc58bb7aa3a0270c358efb61330
Reviewed-on: https://swiftshader-review.googlesource.com/15388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoError messages for uniform block validation
Alexis Hetu [Thu, 4 Jan 2018 22:39:15 +0000 (17:39 -0500)]
Error messages for uniform block validation

Many error messages related to uniform block validation were missing,
so there was no output message when linking failed.
Also, the rowMajor validation was missing and was also not set properly
when individual block members were overriding this layout qualifier.

Fixes:
dEQP-GLES3.functional.shaders.linkage.uniform.block.layout_qualifier_mismatch_5

Change-Id: I97309c3ead6e541d6cd9054ecfd29d08206de7da
Reviewed-on: https://swiftshader-review.googlesource.com/15808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoVarying interpolation qualifier check
Alexis Hetu [Thu, 4 Jan 2018 16:54:55 +0000 (11:54 -0500)]
Varying interpolation qualifier check

Made sure varyings had the same interpolation qualifier in fragment
shader and vertex shader (either both flat or both smooth ).

Fixes:
dEQP-GLES3.functional.shaders.linkage.varying.rules.interpolation_mismatch_1

Change-Id: I7f68490dc19a3365e492b666acda6f5db91d10ab
Reviewed-on: https://swiftshader-review.googlesource.com/15768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSampler allocation fix
Alexis Hetu [Wed, 3 Jan 2018 21:36:14 +0000 (16:36 -0500)]
Sampler allocation fix

Because samplers can be stored within structures, register
allocation of entire structures within the samplers registers
was pushing sampler indices outside of the allowed limit.
In order to solve this, sampler registers now exclusively
contain samplers, and utility functions to compute sampler
only type size were added to make this possible.

Bug chromium:797264

Change-Id: Ic5a6f09665c39661944444cd736547bce4dff2ab
Reviewed-on: https://swiftshader-review.googlesource.com/15728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement EGL_KHR_get_all_proc_addresses.
Krzysztof Kosiński [Wed, 3 Jan 2018 22:17:52 +0000 (23:17 +0100)]
Implement EGL_KHR_get_all_proc_addresses.

This also improves GetProcAddress performance by using binary search
instead of linear search.

Fixes bug b/20110899

Change-Id: I6c58e17f0580904338e4d806e310cccbec398f28
Reviewed-on: https://swiftshader-review.googlesource.com/15748
Tested-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Chrome build.
Nicolas Capens [Wed, 3 Jan 2018 19:24:15 +0000 (14:24 -0500)]
Fix Chrome build.

Change-Id: I25567211a4603713ad89a1eb58aa3306b11be0ab
Reviewed-on: https://swiftshader-review.googlesource.com/15689
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDon't generate (S)SSE3 instructions in static code.
Nicolas Capens [Wed, 3 Jan 2018 19:06:30 +0000 (14:06 -0500)]
Don't generate (S)SSE3 instructions in static code.

-march=core2 implies support for both the SSE3 and SSSE3 instruction
set extensions. Chrome should run on CPUs with only SSE2 as well.

Also, make use of SSE on x86-32 for floating-point operations, to be
consistent with x86-64, and don't favor any specific architecture for
tuning.

Bug chromium:797763

Change-Id: Ia17428734460ed855f3aa0f83c6d2f6b3775094c
Reviewed-on: https://swiftshader-review.googlesource.com/15688
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 clamping depth output to [0, 1] range.
Nicolas Capens [Tue, 2 Jan 2018 20:55:11 +0000 (15:55 -0500)]
Fix clamping depth output to [0, 1] range.

OpenGL ES 3.0 specifies that "For fixed-point depth buffers, the final
fragment depth written by a fragment shader is first clamped to [0, 1]
and then converted to fixed-point as if it were a window z value (see
section 2.13.1). For floating-point depth buffers, conversion is not
performed but clamping is."

Change-Id: Ic7f22f7e47106aaa86c4916fbbbe23ad9c52e186
Reviewed-on: https://swiftshader-review.googlesource.com/15628
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 perform very early depth test when overridden by shader.
Nicolas Capens [Tue, 2 Jan 2018 20:10:56 +0000 (15:10 -0500)]
Don't perform very early depth test when overridden by shader.

When the pixel shader writes the depth value, we can't use the
interpolated implicit depth to perform a depth buffer test before the
pixel shader executes.

Change-Id: Icf80de50f4aa79f73b43e341c18478e7fd928b8d
Reviewed-on: https://swiftshader-review.googlesource.com/15608
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 initializing LOD for 3D sampling.
Nicolas Capens [Tue, 2 Jan 2018 19:22:23 +0000 (14:22 -0500)]
Fix initializing LOD for 3D sampling.

The LOD value was not being computed for 3D texture sampling when no
mipmapping is done. We still need the LOD in case the minification and
magnification filters differ.

Change-Id: If32d7aaf8a92ace33bcc6ca6f0b60fe33c7e771b
Reviewed-on: https://swiftshader-review.googlesource.com/15588
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoOnly try folding constant array indexing if propagated.
Nicolas Capens [Fri, 22 Dec 2017 22:28:33 +0000 (17:28 -0500)]
Only try folding constant array indexing if propagated.

The array folding logic generated an error when a constant array didn't
have an array of literal constants.

Change-Id: I48f58936cfa7e19e0f4026fb940654f20d9a9d5e
Reviewed-on: https://swiftshader-review.googlesource.com/15551
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllow length() method on any array expression.
Nicolas Capens [Fri, 22 Dec 2017 22:24:20 +0000 (17:24 -0500)]
Allow length() method on any array expression.

GLSL ES 3.00 spec says that length is only allowed on "array names",
but according to
https://bugs.chromium.org/p/angleproject/issues/detail?id=2142 that
was not intended to be interpreted strictly and it has been clarified
in GLSL ES 3.20.

Change-Id: Id8944346908e1c122230fd2f94c9a26cf389498b
Reviewed-on: https://swiftshader-review.googlesource.com/15550
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement support for arrays of constants.
Nicolas Capens [Fri, 22 Dec 2017 13:54:18 +0000 (08:54 -0500)]
Implement support for arrays of constants.

Arrays of constants can be dynamically indexed, so they can't be
propagated by value and handled as literals like other constants.
Instead we store them in the constant register file.

Change-Id: Idcee033d694b20d047c70e2d13974e5a6dce127b
Reviewed-on: https://swiftshader-review.googlesource.com/15488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix using linear layout for depth readback.
Nicolas Capens [Fri, 22 Dec 2017 19:57:05 +0000 (14:57 -0500)]
Fix using linear layout for depth readback.

We were using a quad-layout depth format as the destination format for
glReadPixels calls with GL_DEPTH_COMPONENT / GL_FLOAT format. Upload to
a texture was also affected.

Bug b/64542192

Change-Id: I8ad700bf86737debe3268ec6a3dbd237cd85ea1a
Reviewed-on: https://swiftshader-review.googlesource.com/15548
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRevert "Fixed sampler allocation"
Alexis Hétu [Wed, 3 Jan 2018 13:04:09 +0000 (13:04 +0000)]
Revert "Fixed sampler allocation"

This reverts commit a141a0755a1a463894bbe22990c1d9286e493e0b.

Reason for revert: We need a different solution to fix this issue which doesn't
                   require having a different sampler index and register index.

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