OSDN Git Service

android-x86/external-swiftshader.git
5 years agoPrevent 32-bit numeric overflow on image allocation.
Nicolas Capens [Tue, 8 May 2018 21:20:50 +0000 (17:20 -0400)]
Prevent 32-bit numeric overflow on image allocation.

We assume the pixels of an image can be addressed with a signed 32-bit
offset, including any padding. For a 3D image it's possible to exceed
this without exceeding the per-dimension limits. Lowering the per-
dimension limit so the allocation is always less than 2 GiB makes them
unreasonably small, so instead we must check the total size.

Use 1 GiB as the soft limit in OpenGL.

Bug chromium:835299

Change-Id: I9c5184002c1710e3923b549f8c21e7f6a516e1c7
Reviewed-on: https://swiftshader-review.googlesource.com/18869
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor surface buffer size calculation.
Nicolas Capens [Tue, 8 May 2018 21:20:50 +0000 (17:20 -0400)]
Refactor surface buffer size calculation.

This eliminates the duplication between pitchB() and size(), and
ensures that the latter is the full allocation size.

Bug chromium:835299

Change-Id: Icf555ad497fb3b92fd00e9a3e6ced6810b2d310d
Reviewed-on: https://swiftshader-review.googlesource.com/18789
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRefactor maximum texture dimensions.
Nicolas Capens [Tue, 8 May 2018 20:03:16 +0000 (16:03 -0400)]
Refactor maximum texture dimensions.

OpenGL has separate implementation-defined texture size limits, for
3D textures and array textures. For now just give them the same value.

Bug chromium:835299

Change-Id: Ifaf537511f016e21992388f56598d5ec12a393b8
Reviewed-on: https://swiftshader-review.googlesource.com/18788
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoIgnore glGenerateMipmap for unspecified or zero-sized textures.
Nicolas Capens [Tue, 15 May 2018 20:31:10 +0000 (16:31 -0400)]
Ignore glGenerateMipmap for unspecified or zero-sized textures.

https://gitlab.khronos.org/opengl/API/issues/72 was resolved to treat
these cases as a no-op and not generate an error.

Bug chromium:825545

Change-Id: Ic4cfbc728156bb88a6dc70486ae57c3e12ea43ae
Reviewed-on: https://swiftshader-review.googlesource.com/18870
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix glBlitFramebuffer validation for BGRA8 IOSurfaces
Alexis Hetu [Wed, 16 May 2018 17:03:41 +0000 (13:03 -0400)]
Fix glBlitFramebuffer validation for BGRA8 IOSurfaces

The format comparison for blitting from a multisampled buffer
was not ES2 specific, so the ES3 check was removed. That had
been added to fix blitting to the backbuffer on MacOS, which
is now instead fixed by allowing BGRA8 and RGBA8 to be
accepted interchangeably as draw and read formats.

Fixes dEQP-GLES3.functional.negative_api.buffer.blit_framebuffer_multisample

Change-Id: Id577372791007a780c542b0986378147e1e7bc1b
Reviewed-on: https://swiftshader-review.googlesource.com/18888
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoFixed atan corner case
Alexis Hetu [Tue, 15 May 2018 18:07:19 +0000 (14:07 -0400)]
Fixed atan corner case

atan(0, <negative>) was returning 0 instead of PI. Did a simple
fix in the arctan() function and added an associated unit test.

Change-Id: Idbbdaf099b5104e3aaa2868ca8fd806c6c735981
Reviewed-on: https://swiftshader-review.googlesource.com/18868
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoImplement OES_vertex_array_object.
Krzysztof Kosiński [Fri, 11 May 2018 04:55:05 +0000 (21:55 -0700)]
Implement OES_vertex_array_object.

This extension works the same as OpenGL ES 3.0 vertex arrays, but requires
entry points with the OES suffix.

Change-Id: I82b92bbcec078f88becee6f3b37eb7e8256a1233
Reviewed-on: https://swiftshader-review.googlesource.com/18808
Tested-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRevert part of "Fix Linux build." to fix swiftshader_unittests
Alexis Hetu [Mon, 14 May 2018 12:16:05 +0000 (08:16 -0400)]
Revert part of "Fix Linux build." to fix swiftshader_unittests

The cl "Fix Linux build." broke swiftshader_unittests on Linux and
MacOS. Reverting part of that cl to fix swiftshader_unittests, and
hopefully keep the part of the cl that fixed the build originally.

Change-Id: I3126a12f12ca7337f18c758db16dd3542dcfc226
Reviewed-on: https://swiftshader-review.googlesource.com/18848
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoPitch fix for IO surfaces
Alexis Hetu [Fri, 11 May 2018 19:31:12 +0000 (15:31 -0400)]
Pitch fix for IO surfaces

On MacOS, a Surface constructor receiving the 'pitchPprovided'
parameter wasn't using it for the surface's external pitch,
which was causing an error when using the Image::getPitch()
function, which returns getExternalPitchB(). Image::getPitch()
is used within Image::loadImageData(), which is used by gl
functions like glTexImage2D() and glTexSubImage2D(). Both the
internal and external buffers now use the parameter to solve
this issue.

Bug b/19979104

Change-Id: I9762ed53b535ae9eb052f57ee1ceed8ee87cb29c
Reviewed-on: https://swiftshader-review.googlesource.com/18828
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRectangle texture addressing fix
Alexis Hetu [Tue, 8 May 2018 18:25:40 +0000 (14:25 -0400)]
Rectangle texture addressing fix

Texture rectangle coordinates were clamped in the [0, dim - 1] range,
but should have been sampled in the [0.5, dim - 0.5 range] according
to the spec (a related comment was added in the code).

Also, by having getAddressingModeW() return ADDRESSING_LAYER for
rectangle textures, the 3rd texture coordinate computation will be
skipped entirely, preventing the temporary variable 'fv' from being
overwritten.

Change-Id: I4bbc30b2a2b747eae2f2a1dfb710a986bff7849b
Reviewed-on: https://swiftshader-review.googlesource.com/18768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllocate executable memory backed by named mmaps on Linux.
Ian Rogers [Wed, 14 Feb 2018 23:39:25 +0000 (15:39 -0800)]
Allocate executable memory backed by named mmaps on Linux.

Executable heap memory can confuse profiling tools. Use memfd_create
on Linux, if possible, to create a named anonymous memory region.

Only enabled if LINUX_ENABLE_NAMED_MMAP is defined.

Bug b/73721724

Change-Id: I420711e4f64725ae834ab54264038683e4c445fe
Reviewed-on: https://swiftshader-review.googlesource.com/17208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't flag temporary registers as used samplers.
Nicolas Capens [Fri, 4 May 2018 19:49:53 +0000 (15:49 -0400)]
Don't flag temporary registers as used samplers.

This fixes a undefined shift if the temporary register has an index
higher than 32 (also, we only have 16 samplers currently). For GLSL
we declare all actual sampler units during ASM output, so we don't
have to rely on analyzing the instructions afterwards (that is only
still relevant for Direct3D 8/9 shaders).

Change-Id: I11a58964d53fcc2c29e0ad923d9a4a4161a545f4
Reviewed-on: https://swiftshader-review.googlesource.com/18748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSkip ignored EGL config attributes.
Nicolas Capens [Wed, 18 Apr 2018 18:46:17 +0000 (14:46 -0400)]
Skip ignored EGL config attributes.

The EGL 1.4 spec description of eglChooseConfig states:
"If EGL_MAX_PBUFFER_WIDTH, EGL_MAX_PBUFFER_HEIGHT, EGL_MAX_PBUFFER_-
PIXELS, or EGL_NATIVE_VISUAL_ID are specified in attrib_list, then they
are ignored"

Change-Id: I9ec90eff692f9759aa54a0a10f1e57f2c244db7f
Reviewed-on: https://swiftshader-review.googlesource.com/18608
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAccept GL_HALF_FLOAT and GL_HALF_FLOAT_OES interchangeably.
Nicolas Capens [Thu, 26 Apr 2018 20:38:05 +0000 (16:38 -0400)]
Accept GL_HALF_FLOAT and GL_HALF_FLOAT_OES interchangeably.

These enums don't have the same value, but this is only because of
desktop OpenGL and OpenGL ES having evolved separately. OpenGL ES 3.0
reconverged to use the enum name and value of desktop OpenGL.

Apps choosing between OpenGL ES 2.0 and 3.0 strictly speaking have to
use different enums, but many drivers already accept either enum so the
apps don't bother to differentiate them. Running them on a driver which
adheres more strictly to the (extension) specs would cause parameter
validation errors.

Additionally, native platform pixel formats such as
HAL_PIXEL_FORMAT_RGBA_FP16 on Android couldn't be mapped to GL_RGBA16F
with GL_HALF_FLOAT component types on an OpenGL ES 2.0 context if the
latter are considered OpenGL ES 3.0 only.

Change-Id: Ib66cba7444fe438c0e4a8a6454460773cf02236d
Reviewed-on: https://swiftshader-review.googlesource.com/18728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Linux build.
Nicolas Capens [Wed, 25 Apr 2018 20:26:17 +0000 (16:26 -0400)]
Fix Linux build.

We don't need protected visibility because we now have a version script
which hides all symbols except the ones we want to export.

Fixes ld linker errors:
 relocation R_X86_64_PC32 against protected symbol `libEGL_swiftshader' can not be used when making a shared object
 relocation R_X86_64_PC32 against protected symbol `libGLESv2_swiftshader' can not be used when making a shared object

Change-Id: I059c4b03f2523bf8caf08180b02a349d3cf7b2f2
Reviewed-on: https://swiftshader-review.googlesource.com/18708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUse the correct constant name for the Android SDK version
Jorge E. Moreira [Wed, 25 Apr 2018 00:05:10 +0000 (17:05 -0700)]
Use the correct constant name for the Android SDK version

Bug b/78194651

Change-Id: Iafe8728a3593b0bd48b9633261df4035d2e94117
Reviewed-on: https://swiftshader-review.googlesource.com/18668
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse override for overridden function
Takuto Ikuta [Wed, 25 Apr 2018 13:57:42 +0000 (22:57 +0900)]
Use override for overridden function

Bug: chromium:428099
Change-Id: Ib070a540a3ef245e2828b277dcdabd5b973322f0
Reviewed-on: https://swiftshader-review.googlesource.com/18688
Tested-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed sampler within struct uniform used as function argument
Alexis Hetu [Tue, 24 Apr 2018 15:13:33 +0000 (11:13 -0400)]
Fixed sampler within struct uniform used as function argument

The sampler was simply not declared in that case, as if the uniform
was unused in the shader, so making sure structures containing
samplers call samplerRegister solves this issue. It was working
properly if the sampler was used anywhere else in the shader, but
failed when the only use in the shader was being passed as an
argument to a function through a containing structure.

Added a unit test since this isn't covered by dEQP.

Fixes 2 WebGL tests:
conformance/glsl/bugs/sampler-array-struct-function-arg.html
conformance/glsl/bugs/sampler-struct-function-arg.html

Change-Id: I81767d7c6415de7aefefecffcc66265d944a94ab
Reviewed-on: https://swiftshader-review.googlesource.com/18628
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoLoad sibling libraries from the same directory
Alexis Hetu [Mon, 16 Apr 2018 19:38:40 +0000 (15:38 -0400)]
Load sibling libraries from the same directory

When libEGL and either libGLESv2 or libGLES_CM are in a different
folder from the executable's folder, libEGL wasn't successfully
finding libGLESv2/libGLES_CM (or vice versa). Since these libraries
are generally in the same folder, using the current library's folder
as a starting location to find another library solves this issue.

Change-Id: Ice9217411de4e269d511549411297b57fc1a4bbb
Reviewed-on: https://swiftshader-review.googlesource.com/18548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement missing EGL surface queries.
Nicolas Capens [Thu, 12 Apr 2018 16:50:21 +0000 (12:50 -0400)]
Implement missing EGL surface queries.

Fixes dEQP-EGL.functional.query_surface.* tests.

Change-Id: I9d0d2dee83140613af24471d350777959ee37565
Reviewed-on: https://swiftshader-review.googlesource.com/18488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRemove unstructured metadata files.
Nicolas Capens [Tue, 17 Apr 2018 18:59:54 +0000 (14:59 -0400)]
Remove unstructured metadata files.

This information is now part of internal structured metadata.

Change-Id: Idb8c1ce256133d9857b96c2a3152e333606f4fbd
Reviewed-on: https://swiftshader-review.googlesource.com/18568
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
6 years agoGuard against clearing null depth/stencil buffers.
Nicolas Capens [Thu, 12 Apr 2018 20:31:32 +0000 (16:31 -0400)]
Guard against clearing null depth/stencil buffers.

Change-Id: Ic0a16ac68582e398a02eef722d52a77a1ebde877
Reviewed-on: https://swiftshader-review.googlesource.com/18508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdded check for temporary register overflow
Alexis Hetu [Mon, 9 Apr 2018 17:47:34 +0000 (13:47 -0400)]
Added check for temporary register overflow

Currently, when overflowing the number of temporary registers
allowed, SwiftShader will crash somewhere in the generated
code. This cl adds an early check to prevent the crash and
instead output an error message to the user.

Bug chromium:814987

Change-Id: Idadda21ee14298662763d986ee1283a5114c1c01
Reviewed-on: https://swiftshader-review.googlesource.com/18388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRelease thread local storage on thread exit.
David Rim [Fri, 6 Apr 2018 08:48:41 +0000 (17:48 +0900)]
Release thread local storage on thread exit.

Calls to the EGL API from different threads may exit without releasing
their current TLS storage. This patch adds a destructor to release
them if they have not been released already. Prevents memory leakage in
processes where many threads are created.

Bug b/63434079
Bug swiftshader:80

Test: cts-tradefed run commandAndExit  cts -m CtsMediaTestCases -t \
      android.media.cts.DecodeAccuracyTest
Change-Id: I6e94a6d04ce84b884571248ab89b3b1a4e71998b
Reviewed-on: https://swiftshader-review.googlesource.com/18328
Tested-by: David Rim <davidrim@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoChromium build fix
Alexis Hetu [Tue, 10 Apr 2018 14:46:47 +0000 (10:46 -0400)]
Chromium build fix

Adding a getPlane() function in order to not have the "plane" private
member unused, which causes a warning and makes compilation fail.

Change-Id: I3ec08d3439c7e8f3d4314f3b4864d12e9c34d6f4
Reviewed-on: https://swiftshader-review.googlesource.com/18468
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix CMake build
Alexis Hetu [Tue, 10 Apr 2018 14:48:42 +0000 (10:48 -0400)]
Fix CMake build

Added the missing libraries (CoreFoundation
and IOSurface) to the CMakeLists.txt file.

Change-Id: I6db6b3d2396f557296bbf670d152cc421b6727dd
Reviewed-on: https://swiftshader-review.googlesource.com/18469
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix build failure due to missing forward declaration.
Nicolas Capens [Mon, 9 Apr 2018 21:38:12 +0000 (17:38 -0400)]
Fix build failure due to missing forward declaration.

Strict compilation requires symbols used in template functions to have
been declared, which will be enforced in future compilers.

Bug swiftshader:103

Change-Id: Ibfc05011b1a2938e958dfacf6792477362699dc6
Reviewed-on: https://swiftshader-review.googlesource.com/18448
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd -Wno-sentinel that is needed on Android K
Greg Hartman [Sat, 17 Mar 2018 05:46:21 +0000 (22:46 -0700)]
Add -Wno-sentinel that is needed on Android K

Bug b/75229322
Test: Local build of K
Fixes build break ab/4660759
Change-Id: Ib2cb43594b331c4415650517df65e8ccd497f820
Reviewed-on: https://swiftshader-review.googlesource.com/18190
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix makefiles for Andoid K
Greg Hartman [Fri, 16 Mar 2018 18:50:19 +0000 (11:50 -0700)]
Fix makefiles for Andoid K

It's not safe to rely on LOCAL_MODULE_RELATIVE_PATH on all branches

Cleaned up some unnecessary ifdef's

Bug b/75229322
Test: Local build of K
Fixes build break ab/4660124
Change-Id: I48d3400a2109cd5a2cf593e03f9e234f490c8252
Reviewed-on: https://swiftshader-review.googlesource.com/18189
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd work-arounds for missing C++11 features.
Nicolas Capens [Mon, 9 Apr 2018 19:12:15 +0000 (15:12 -0400)]
Add work-arounds for missing C++11 features.

Android versions before M did not have:

std::shared_ptr
std::unique_ptr
std::to_string

This is fixed by extending stlport with custom implementations for
these features. This works by using 'string' and 'memory' header
files in a path searched before stlport itself, in which the new
features are implemented, and including stport's original headers for
all other functionality.

Bug b/75229322

Change-Id: Icd05c072c366381155e086c3f14f805bc4f104d6
Reviewed-on: https://swiftshader-review.googlesource.com/18408
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCorrect confusion between Android O and O MR1
Greg Hartman [Fri, 16 Mar 2018 07:02:23 +0000 (00:02 -0700)]
Correct confusion between Android O and O MR1

libnativebase and liblog_headers didn't exist until O MR1

Bug b/75229322
Test: Local builds K through P DP1
Change-Id: I07361e4ef8a98108536319428741554b937eda1a
Reviewed-on: https://swiftshader-review.googlesource.com/17768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoeglCreatePbufferFromClientBuffer implementation
Alexis Hetu [Tue, 13 Feb 2018 20:02:40 +0000 (15:02 -0500)]
eglCreatePbufferFromClientBuffer implementation

Added support for eglCreatePbufferFromClientBuffer(), using an
IOSurface on MacOS, or just a straight buffer pointer on other
platforms.

Added new unit tests (IOSurfaceClientBufferTest class), which
pass on both Windows and MacOS.

Change-Id: I79a6b420d85fb1f3ae505e0c0067bad2e27510d4
Reviewed-on: https://swiftshader-review.googlesource.com/17168
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoInitialize array size on error.
Nicolas Capens [Mon, 9 Apr 2018 15:53:41 +0000 (11:53 -0400)]
Initialize array size on error.

The array size is set using the value returned by arraySizeErrorCheck,
even when an error occurred, so don't leave it uninitialized.

Bug chromium:801648

Change-Id: If2af27c5f61dca2931796f1681dce61ab6a44341
Reviewed-on: https://swiftshader-review.googlesource.com/18368
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoWebGL test fix for MacOS
Alexis Hetu [Mon, 9 Apr 2018 15:43:58 +0000 (11:43 -0400)]
WebGL test fix for MacOS

On MacOS, the BGRA format is used for framebuffers. Because of that,
copying from the BGRA format must be allowed in the same places the
RGBA format is allowed.

This fixes the following WebGL test on MacOS:
conformance/textures/misc/copy-tex-image-2d-formats.html

Change-Id: I45c6b81a894dd8d55c4ab5cff0cf9ad1a08c8303
Reviewed-on: https://swiftshader-review.googlesource.com/18348
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed buffer offset when primitive restart is enabled
Alexis Hetu [Thu, 5 Apr 2018 19:09:32 +0000 (15:09 -0400)]
Fixed buffer offset when primitive restart is enabled

The data pointer 'buffer->data()' was being used without the
offset applied, which means we were using the wrong part of
the index buffer when primitive restart is enabled. 'indices'
should already contain the properly offset buffer pointer,
so using it directly should work.

Bug chromium:823096

Change-Id: If70634f63d40d8efde9b1336370c1a63b1faa19f
Reviewed-on: https://swiftshader-review.googlesource.com/18268
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoAlso look for sibling libraries in /system
Greg Hartman [Thu, 5 Apr 2018 17:10:34 +0000 (10:10 -0700)]
Also look for sibling libraries in /system

This cleans up a problem that was introduced by
https://swiftshader-review.googlesource.com/17188

LOCAL_VENDOR_MODULE was first supported on O, so when we build
SwiftShader on earlier branches the libraries land in /system.
The fix in the Android.mk files would be complicated and would revert
some of the cleanup, and would cause issues for 64 bit only builds.
While it would be possible to extend the original approach, it just
seems cleaner to check in /system at runtime.

Bug b/76437145
Test: Local build and boot of Cloud Android N
Change-Id: I86e0363a8cbd7b8f2ba744f14a67dfe457f3725f
Reviewed-on: https://swiftshader-review.googlesource.com/18288
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years ago[ozone] swiftshader ozone
Mustafa Çamurcu [Fri, 23 Mar 2018 20:39:02 +0000 (16:39 -0400)]
[ozone] swiftshader ozone

Windows implementation for FrameBuffer needs priority over Ozone.

When building Chrome for Windows using Ozone, since use_ozone=true,
some required windows definitions don't get defined.

Change-Id: I6b8475c036dc88f7e3cb118a7db286afc75857fe
Reviewed-on: https://swiftshader-review.googlesource.com/17968
Tested-by: Mustafa Çamurcu <camurcu@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoGuard against copying from a zero-sized 3D image.
Nicolas Capens [Thu, 29 Mar 2018 05:16:50 +0000 (01:16 -0400)]
Guard against copying from a zero-sized 3D image.

Bug chromium:825545

Change-Id: I37d6192bf65115938943f45d43e153196a7d569a
Reviewed-on: https://swiftshader-review.googlesource.com/18128
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoExpose surfaceless context extension strings
Alexis Hetu [Thu, 22 Mar 2018 12:29:31 +0000 (08:29 -0400)]
Expose surfaceless context extension strings

It seems like SwiftShader already supports surfaceless contexts properly in
eglMakeCurrent, so we might as well expose the extension strings.

Change-Id: I3c1b85296c46536df9a8bd754856d825307181d0
Reviewed-on: https://swiftshader-review.googlesource.com/17948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRevert "Use official headers to define GL_ARB_texture_rectangle."
Nicolas Capens [Tue, 27 Mar 2018 13:39:37 +0000 (09:39 -0400)]
Revert "Use official headers to define GL_ARB_texture_rectangle."

This reverts commit 9869bedb56822d19c9bfbdb33f6af061da8e6106.

It broke 32-bit builds on Windows because GLsizeiptr and GLintptr are
defined as different types (int vs. long) in gl2.h and glcorearb.h.
See also https://github.com/KhronosGroup/OpenGL-Registry/issues/162

Change-Id: Ia7bd4accb1671529ce6da6849a1df76dceddcdee
Reviewed-on: https://swiftshader-review.googlesource.com/18068
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix missing sized internal formats.
Nicolas Capens [Mon, 26 Mar 2018 14:13:21 +0000 (10:13 -0400)]
Fix missing sized internal formats.

Change-Id: Ifeee2d5c637586e6b843080aaceb446bd0b5af11
Reviewed-on: https://swiftshader-review.googlesource.com/18048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSupport more glCopyTexImage unsized formats.
Nicolas Capens [Thu, 22 Mar 2018 17:22:20 +0000 (13:22 -0400)]
Support more glCopyTexImage unsized formats.

Convert packed types to the next greater non-packed component type.
Specifically, when the red component has fewer than 8 bits, use the
corresponding sized internal format with 8-bit components.

Note that this is still not fully compliant.
The OpenGL ES 3.0 spec section 3.8.5 states that:

If internalformat is unsized, the internal format of the new texel array is determined
by the following rules, applied in order. If an effective internal format exists
that has
1. the same component sizes as,
2. component sizes greater than or equal to, or
3. component sizes smaller than or equal to
those of the source buffer’s effective internal format (for all matching components
in internalformat), that format is chosen for the new image array, and this is also
the new texel array’s effective internal format.

This means that in theory when copying an RGBA4 framebuffer into an RGB
texture, the effective internal format should be RGB565, not RGB8.
However, dEQP does not enforce this, and ANGLE always assumes
UNSIGNED_BYTE components.

Change-Id: Id243b963779108e205c275499ddfb6e041a873d6
Reviewed-on: https://swiftshader-review.googlesource.com/17969
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDon't upload array texture images six times.
Nicolas Capens [Thu, 22 Mar 2018 04:55:23 +0000 (00:55 -0400)]
Don't upload array texture images six times.

Change-Id: I5be0cc629477b6cfb3ede6b4484f067d1c30b0ec
Reviewed-on: https://swiftshader-review.googlesource.com/17929
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoValidate pixel unpack buffer offset.
Nicolas Capens [Thu, 22 Mar 2018 04:44:07 +0000 (00:44 -0400)]
Validate pixel unpack buffer offset.

When a pixel unpack buffer is bound, glTexImage calls interpret the
<pixels> parameter as an offset into the pixel buffer. We weren't
validating that the accessed data falls within the buffer, when taking
the offset into account.

Bug chromium:822976

Change-Id: I3ab23e3b135fd4ad1e55555eec95d584684f5d82
Reviewed-on: https://swiftshader-review.googlesource.com/17928
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUse official headers to define GL_ARB_texture_rectangle.
Nicolas Capens [Wed, 21 Mar 2018 18:25:19 +0000 (14:25 -0400)]
Use official headers to define GL_ARB_texture_rectangle.

Fixing https://github.com/KhronosGroup/OpenGL-Registry/pull/149 enabled
including desktop OpenGL headers without conflicts, so we no longer
have to define enums for ARB extensions ourselves.

Change-Id: Ifa05112f1e1d21bb8a22b83519babbbb3e4d6462
Reviewed-on: https://swiftshader-review.googlesource.com/17909
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpdate OpenGL headers.
Nicolas Capens [Wed, 21 Mar 2018 17:55:23 +0000 (13:55 -0400)]
Update OpenGL headers.

Using revision
https://github.com/KhronosGroup/OpenGL-Registry/commit/6565c242fbdad6258a73f506b0baa61f62edd67c

Change-Id: I0e48ff5d700a2f21c9b52f992e90ca37b9800630
Reviewed-on: https://swiftshader-review.googlesource.com/17908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAllow Blitter::fastClear to directly write to external buffer
Alexis Hetu [Mon, 26 Mar 2018 01:02:17 +0000 (21:02 -0400)]
Allow Blitter::fastClear to directly write to external buffer

When the external buffer is the one that is dirty, avoid a useless
copy from external to internal before fast clearing the buffer by
clearing the external buffer directly.

Change-Id: I469243ba8a2b8617f9a0f8b6e2a089f667b8ae63
Reviewed-on: https://swiftshader-review.googlesource.com/18033
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMultisampled blitter clear fix
Alexis Hetu [Mon, 26 Mar 2018 00:32:22 +0000 (20:32 -0400)]
Multisampled blitter clear fix

When clearing a multisampled buffer, the reactor blitter was only
clearing the first sample. This cl makes the reactor blitter
effectively clear all samples of a multisampled buffer.

Change-Id: I7ce1af401bf537fe85e1c8393a2c57144641ad8e
Reviewed-on: https://swiftshader-review.googlesource.com/18032
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix multisampled line rendering.
Nicolas Capens [Sat, 17 Mar 2018 03:23:06 +0000 (23:23 -0400)]
Fix multisampled line rendering.

Bug swiftshader:99
Bug chromium:820461

Change-Id: I2232c27d57aedff03293b37607f97ead56c056c9
Reviewed-on: https://swiftshader-review.googlesource.com/17808
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMoving Chromium's version of the libraries first
Alexis Hetu [Tue, 20 Mar 2018 18:06:12 +0000 (14:06 -0400)]
Moving Chromium's version of the libraries first

On MacOS, libraries have a couple of minor issues and, as a safety,
let's make sure no other library than the required library is loaded.

Change-Id: I376b77b3cf3f635ff57c12ccde2b9e84d4105adc
Reviewed-on: https://swiftshader-review.googlesource.com/17888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix output directory creation.
Nicolas Capens [Tue, 20 Mar 2018 15:16:09 +0000 (11:16 -0400)]
Fix output directory creation.

Change-Id: Ib6e656a7913cf245c73c096376241f6e1f567b6b
Reviewed-on: https://swiftshader-review.googlesource.com/17869
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSplit output binaries by platform.
Nicolas Capens [Tue, 20 Mar 2018 14:46:14 +0000 (10:46 -0400)]
Split output binaries by platform.

Change-Id: I7388b3f5d17e35e55726797ba40631fd8590fb24
Reviewed-on: https://swiftshader-review.googlesource.com/17868
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Travis CI deploy directory.
Nicolas Capens [Tue, 20 Mar 2018 13:28:12 +0000 (09:28 -0400)]
Fix Travis CI deploy directory.

Change-Id: I501b72e5d33b26075488c0af999713c192c4ac0b
Reviewed-on: https://swiftshader-review.googlesource.com/17848
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd support for RGBA16F external images.
Nicolas Capens [Tue, 20 Mar 2018 03:38:49 +0000 (23:38 -0400)]
Add support for RGBA16F external images.

Bug b/75778024

Change-Id: Idf17c094ef858b3712839ffe335dc943cd0bd084
Reviewed-on: https://swiftshader-review.googlesource.com/17828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpload binaries to Google Cloud Storage.
Nicolas Capens [Fri, 16 Mar 2018 19:19:19 +0000 (15:19 -0400)]
Upload binaries to Google Cloud Storage.

Change-Id: I92c4c203433c8dc92887c5470631926c3cac1d27
Reviewed-on: https://swiftshader-review.googlesource.com/17788
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix glTexSubImage support of half-float extension formats.
Nicolas Capens [Wed, 14 Mar 2018 21:15:39 +0000 (17:15 -0400)]
Fix glTexSubImage support of half-float extension formats.

GL_HALF_FLOAT_OES and GL_HALF_FLOAT have different enum values, and we
weren't handling the case where a half-float texture was already
created (e.g. with an effective internal format of GL_RGBA16F) and then
updated with a glTexSubImage call using GL_HALF_FLOAT_OES type. In
other words, we assumed the OpenGL ES 3.0 sized internal format could
only be used with the OpenGL ES 3.0 half-float type, but this hasn't
been true since we started storing only the effective internal format
for all versions.

Note that GL_OES_texture_half_float, which defines GL_HALF_FLOAT_OES,
does not clarify whether HALF_FLOAT images can be updated using FLOAT,
or vice-versa. We're assuming the equivalent combinations of OpenGL ES
3.0 table 3.3 are valid. That is, FLOAT can be used to update,
HALF_FLOAT, but not the other way around.

Bug b/74609191

Change-Id: Ib8548cd37065820eb59a0943fd39647edc5e9f1b
Reviewed-on: https://swiftshader-review.googlesource.com/17748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoGL_CHROMIUM_color_buffer_float_rgba extension support
Alexis Hetu [Thu, 18 Jan 2018 21:17:54 +0000 (16:17 -0500)]
GL_CHROMIUM_color_buffer_float_rgba extension support

GL_CHROMIUM_color_buffer_float_rgba (OpenGL ES 2.0) is a subset of
GL_EXT_color_buffer_float (OpenGL ES 3.0), which SwiftShader already
supports.

Fixes 1 webgl conformance tests:
conformance/extensions/oes-texture-float.html

Change-Id: Ic1451187db219af74ba41fa7634bd5bcb6fb0b44
Reviewed-on: https://swiftshader-review.googlesource.com/16470
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCheck X11 return status.
Nicolas Capens [Tue, 13 Mar 2018 14:54:18 +0000 (10:54 -0400)]
Check X11 return status.

We weren't checking the return status of an XGetWindowAttributes() call
while checking for a resized window. It appears that it can start to
fail possibly due to an out-of-memory situation or the window being
destroyed before the EGL surface.

Note that the EGL spec does not have a recommendation on how to handle
this situation. Generating EGL_BAD_ALLOC is intended for eglCreate*
call failures, while EGL_BAD_NATIVE_WINDOW appears to be reserved for
calls that take a native window as a parameter. eglSwapBuffers is
neither.

Bug chromium:819481

Change-Id: I270730567b5179ee43b814e8bd017b601dfbe079
Reviewed-on: https://swiftshader-review.googlesource.com/17708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoBuild fix: Unit test code cleanup
Alexis Hetu [Thu, 8 Mar 2018 16:33:17 +0000 (11:33 -0500)]
Build fix: Unit test code cleanup

- Added EXPECT_GLENUM_EQ to solve signed/unsigned comparisons
- Added createProgram and drawQuad utility functions to reduce
  code duplication

Change-Id: I8a62110346de501a1a77ec9688cf06b321385661
Reviewed-on: https://swiftshader-review.googlesource.com/17668
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdded support for sampler2DRect in ESSL3
Alexis Hetu [Fri, 2 Mar 2018 20:10:16 +0000 (15:10 -0500)]
Added support for sampler2DRect in ESSL3

Being able to sample from sampler2DRect using the "texture" function is required for Chromium on Mac.

Change-Id: Iea8970aaec29734a251bcfc19a03223d0ebfbc7e
Reviewed-on: https://swiftshader-review.googlesource.com/17572
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Subzero build on Android.
Nicolas Capens [Wed, 7 Mar 2018 20:19:58 +0000 (15:19 -0500)]
Fix Subzero build on Android.

Change-Id: If560b8b41b869458ff4b3a6a314f389c8e7a22f9
Reviewed-on: https://swiftshader-review.googlesource.com/17648
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse -Werror in Android builds.
Chih-Hung Hsieh [Wed, 11 Oct 2017 21:23:57 +0000 (14:23 -0700)]
Use -Werror in Android builds.

Suppress existing warnings.

Bug b/66996870

Change-Id: I9b78f840638a57c2559ccc4dbc583cc6a6e21c14
Reviewed-on: https://swiftshader-review.googlesource.com/17630
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBuild SwiftShader with BOARD_VNDK_VERSION=current
Jiyong Park [Fri, 8 Sep 2017 01:47:30 +0000 (10:47 +0900)]
Build SwiftShader with BOARD_VNDK_VERSION=current

This is using cutils/log.h which is deprecated in O (in favor of
log/log.h) and this is causing build error when building with
BOARD_VNDK_VERSION=current set. However, since SwiftShader should be
able to be built with older versions Android some of which don't have
log/log.h, we can't simply change cutils/log.h to log/log.h.

Instead, liblog_headers is added to the header lib dependency (only for
O and beyond) so that log/log.h can be correctly included via
cutils/log.h

Bug b/63135587

Change-Id: I763250e7410025b1dcd7ae210693e3d6bffdb6f1
Reviewed-on: https://swiftshader-review.googlesource.com/17629
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrevent crashing when no current program is set.
Nicolas Capens [Tue, 6 Mar 2018 14:55:35 +0000 (09:55 -0500)]
Prevent crashing when no current program is set.

This fixes a regression caused by
https://swiftshader-review.googlesource.com/14489

Context::applyVertexBuffer() expects a valid program, so we need to
check for it sooner. Not having a current program is not an error and
makes the draw call a no-op, but
dEQP-GLES3.functional.negative_api.vertex_array.* still expects
validation to happen before leaving the function. In particular,
the framebuffer completeness check has to be performed. Note that
ConvertPrimitiveType() should never return an error because we already
check the primitive type in the entry function, sampler validation
can only be done when we have a valid program, and likewise
applyVertexBuffer() requires a program, so these validations can still
happen after the early-out.

Change-Id: I7036ca59d37ea0385f79bf87afd1eeeb9728f7af
Reviewed-on: https://swiftshader-review.googlesource.com/17228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix marking all cube faces as clean after update.
Nicolas Capens [Fri, 2 Mar 2018 17:59:36 +0000 (12:59 -0500)]
Fix marking all cube faces as clean after update.

Change-Id: I85886ea83f4d748dce98d79acff204bf855da1ad
Reviewed-on: https://swiftshader-review.googlesource.com/17569
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRefactor texture binding.
Nicolas Capens [Fri, 2 Mar 2018 17:37:47 +0000 (12:37 -0500)]
Refactor texture binding.

Also remove traces of cube texture support for OpenGL ES 1.1. We don't
support the OES_texture_cube_map extension, and it would be non-trivial
due to requiring reflective texture coordinate generation.

Change-Id: I5c224f925fc9c03053acaf33e126dae4f3ffe4d9
Reviewed-on: https://swiftshader-review.googlesource.com/16750
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor exp2().
Nicolas Capens [Fri, 12 Jan 2018 02:19:34 +0000 (21:19 -0500)]
Refactor exp2().

Change-Id: I491411ba77addcb514944717b19918e4d1b98898
Reviewed-on: https://swiftshader-review.googlesource.com/16228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRelease surface on releaseTexImage
Alexis Hetu [Thu, 1 Mar 2018 19:51:20 +0000 (14:51 -0500)]
Release surface on releaseTexImage

The surface set during bindTexImage should be unset during
releaseTexImage. Failing to do so may keep a dangling pointer
to the surface, which can cause a crash later on (this was hit
during the testing of new unit tests which  will be added soon).

Change-Id: Ic258fff8c880d449add825c5e9185435cc4ea419
Reviewed-on: https://swiftshader-review.googlesource.com/17548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAccept GL_RGB/GL_RGBA for glGetInternalformativ.
Nicolas Capens [Wed, 17 Jan 2018 18:39:58 +0000 (13:39 -0500)]
Accept GL_RGB/GL_RGBA for glGetInternalformativ.

The spec mentions them as color-renderable, but our IsColorRenderable()
function only handles sized internal format, and adding them there
might hide bugs in our renderbuffer implementation since they can only
be constructed using sized internal formats.

dEQP also has a note about this inconsistency, and consequently these
formats are not part of the 'mustpass' set for
dEQP-GLES3.functional.state_query.internal_format.
So it might be a spec oversight.

Change-Id: I08ca3dad4c0b5686536dafd3ade1e855e3968aa0
Reviewed-on: https://swiftshader-review.googlesource.com/16410
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMake swiftshader build files produce libs in correct folders.
Tomasz Wiszkowski [Mon, 12 Feb 2018 17:05:31 +0000 (09:05 -0800)]
Make swiftshader build files produce libs in correct folders.

Current build system assumes single arch targets to be 32bit and produces 64bit libraries
in an incorrect folder.

The change allows build system to determine proper location of the libraries.

Change-Id: Ic95a36f7108fcae8e6f120f0853ee00e9a8926c1
Reviewed-on: https://swiftshader-review.googlesource.com/17188
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRe-implement GL_APPLE_texture_format_BGRA8888.
Nicolas Capens [Tue, 27 Feb 2018 21:45:43 +0000 (16:45 -0500)]
Re-implement GL_APPLE_texture_format_BGRA8888.

GL_APPLE_texture_format_BGRA8888 specifies that when using the BGRA_EXT
format, it "must have an RGBA internal format". Note that
GL_EXT_texture_format_BGRA8888 also allows BGRA_EXT as internalformat.

Change-Id: I27e032054240efe96c32e27ebbdfb3c28213b1d8
Reviewed-on: https://swiftshader-review.googlesource.com/16248
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 floating-point luminance/alpha pixel upload.
Nicolas Capens [Wed, 28 Feb 2018 15:02:07 +0000 (10:02 -0500)]
Fix floating-point luminance/alpha pixel upload.

We were expecting R or RG internal formats, instead of L, A, or LA.

Change-Id: I6ee145341819460dda262b017db6d8105860f49a
Reviewed-on: https://swiftshader-review.googlesource.com/17508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoTexture rectangle related fixes and associated tests
Alexis Hetu [Fri, 2 Feb 2018 22:23:48 +0000 (17:23 -0500)]
Texture rectangle related fixes and associated tests

Imported texture rectangle tests from angle and fixed all
texture rectangle related failures:
- Rectangle textures can be rendered to
- Rectangle textures only support level 0
- Rectangle textures can't be compressed
- glTexStorage2D can no longer create a texture larger
  than the maximum size allowed

Change-Id: I089291c94aad79e244782a8d56dd224c7510d237
Reviewed-on: https://swiftshader-review.googlesource.com/16908
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoUse a relative URL for SwiftConfig.
Nicolas Capens [Wed, 24 Jan 2018 21:33:52 +0000 (21:33 +0000)]
Use a relative URL for SwiftConfig.

This makes it easier to use a different address,
in particular the port.

Also add a missing header for std::max.

Change-Id: I454dd6f4a92b5d8b97625e4cb50796e9f0940009
Reviewed-on: https://swiftshader-review.googlesource.com/16668
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix renderbuffer binding for OpenGL ES 1.1.
Nicolas Capens [Mon, 26 Feb 2018 22:47:06 +0000 (17:47 -0500)]
Fix renderbuffer binding for OpenGL ES 1.1.

glBindRenderbufferOES() doesn't require anything except a
non-zero renderbuffer to create a new Renderbuffer object (it is not
required to use GenRenderbuffers before using BindRenderbuffer).
This had been fixed for GLES 3.0 and 2.0, but the same also applies
to GLES 1.1. Note that the Context already properly handles the case
where renderbuffer is zero.

Bug b/25983901

Change-Id: If5e97be8027fca7c97cce5c44d063cd054443700
Reviewed-on: https://swiftshader-review.googlesource.com/17490
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't perform component swizzling on a null texture.
Nicolas Capens [Tue, 27 Feb 2018 18:29:26 +0000 (13:29 -0500)]
Don't perform component swizzling on a null texture.

When sampling from an incomplete texture, the OpenGL spec states that
(0, 0, 0, 1) will be returned to the shader from the texture lookup
function. Swizzling is only described for filtered texture values.

Change-Id: Ie8a02b3b0b9e571fd2f86302e777a4ff985da022
Reviewed-on: https://swiftshader-review.googlesource.com/17488
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 internal format handling for OpenGL ES 1.1.
Nicolas Capens [Mon, 26 Feb 2018 22:47:06 +0000 (17:47 -0500)]
Fix internal format handling for OpenGL ES 1.1.

With the egl::Image class now only storing the sized internal format,
some OpenGL ES 1.1 functionality broke because it was still expecting a
base format.

Change-Id: Ib41e91f371a06b2a09471ea45dd1f8f56b94091f
Reviewed-on: https://swiftshader-review.googlesource.com/17468
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoReplace GL_NONE with GL_NO_ERROR when used as error.
Nicolas Capens [Mon, 26 Feb 2018 22:47:06 +0000 (17:47 -0500)]
Replace GL_NONE with GL_NO_ERROR when used as error.

GL_NONE is primarily a renderbuffer format, and GL_NO_ERROR more
clearly conveys the meaning when used as a validation return code.
Also, GL_NONE is not defined in OpenGL ES 1.1 (but GL_NONE_OES is,
as a renderbuffer format).

Change-Id: Ie1c00009c30c8d2717de15c7e27db295ecd9de1e
Reviewed-on: https://swiftshader-review.googlesource.com/17489
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRestrict multisampling to normalized unsigned and float formats.
Nicolas Capens [Wed, 17 Jan 2018 19:02:55 +0000 (14:02 -0500)]
Restrict multisampling to normalized unsigned and float formats.

Surface::resolve() currently only supports these formats. Also this
change reuses the GetColorComponentType() utility function instead of
using a separate switch. Effectively, signed normalized formats now
return 0 samples.

Change-Id: I839ffa89a63d8e1b0a40913d3b1ad13e2ce0b5a8
Reviewed-on: https://swiftshader-review.googlesource.com/16389
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 texture upload and internalformat handling.
Nicolas Capens [Fri, 23 Feb 2018 01:14:07 +0000 (20:14 -0500)]
Fix texture upload and internalformat handling.

We weren't handling several of the format/type/internalformat combos
from table 3.2 of the OpenGL ES 3.0.5 spec. In particular those where
the format/type of a glTexSubImage2D() call can be used to update
images with an internal format not directly corresponding to it. Some
of these cases were handled using the blitter, but not all GL formats
have a SwiftShader equivalent. Also, the blitter is slower than
specialized C++ pixel transfer code, and the blitter's fallback path is
even slower.

This patch provides specialized pixel rectangle transfer code for each
combination of formats. We also now only store the effective sized
internal format of the images. Validation also happens using the sized
internal format wherever feasible, instead of unsized formats or
SwiftShader formats.

Change-Id: Id55db490002ab8fc2f16f766c43b43f121e5768e
Reviewed-on: https://swiftshader-review.googlesource.com/17429
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 debug macro for returning on assert.
Nicolas Capens [Thu, 22 Feb 2018 21:39:20 +0000 (16:39 -0500)]
Add debug macro for returning on assert.

While in general one should strive to never hit an assert, and thus we
should not worry about what happens in release mode when the condition
is false, there are cases in which it becomes very hard to prove that a
condition will always be true. For instance when another layer is
responsible for validation, but the code experiences a lot of change,
it could inadvertently expose an untested bad edge case which is only
detected much later. For these cases, it is wise to still perform a
less harmful action than just continue.

The ASSERT_OR_RETURN macro will cause a return from the calling
function when the condition is false.

Bug b/73656151

Change-Id: I36953bb5c477ecca67647ae1a7e2fb97e7e4fca6
Reviewed-on: https://swiftshader-review.googlesource.com/17428
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 assert while updating surface buffers.
Nicolas Capens [Thu, 22 Feb 2018 21:13:01 +0000 (16:13 -0500)]
Fix assert while updating surface buffers.

When the external buffer of a surface is dirty, and we're trying to
lock the internal buffer (or vice-versa), an 'update' needs to happen.
This resulted in us locking the internal buffer for writing, thereby
marking it as dirty. This triggered an assert which checks that both
buffers can't be dirty at the same time. Also, in release mode this
could result in redundant updates when the external buffer is locked
again.

We should mark the destination buffer dirty when we're about to make
sure it's up to date, so a new lock type was added which is equivalent
to a write lock but without setting the dirty flag.

Also, we were allocating memory for a 0x0 stencil buffer for each
render target, when there's no stencil component. So return nullptr
when the format is NULL.

Change-Id: Ie7b5528e3eedc3c3efdf8461047e6284b7bdfc84
Reviewed-on: https://swiftshader-review.googlesource.com/16828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix glCopyTexImage support for BGRA color buffers.
Nicolas Capens [Fri, 23 Feb 2018 02:53:39 +0000 (21:53 -0500)]
Fix glCopyTexImage support for BGRA color buffers.

Neither GL_EXT_texture_format_BGRA8888 nor
GL_APPLE_texture_format_BGRA8888 make mention of GL_BGRA_EXT
or GL_BGRA8_EXT being accepted as the internalformat parameter of
glCopyTexImage2D, but there's a reasonable assumption that textures
with BGRA format can be used as the read color buffer.
GL_EXT_texture_format_BGRA8888 does mention that the format is
color-renderable, and GL_APPLE_texture_format_BGRA8888 adds it to table
3.2 (but fails to mention changes to table 3.16).

Bug swiftshader:96

Change-Id: I6d18faeaded73164a2c6af87ae6109fc77825964
Reviewed-on: https://swiftshader-review.googlesource.com/17448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix more warnings treated as errors.
Nicolas Capens [Wed, 14 Feb 2018 19:52:49 +0000 (14:52 -0500)]
Fix more warnings treated as errors.

Fixes building SubzeroTest on Mac.

Change-Id: I8ca1f2ea8101bec496b8e9741c38025ff932b3d6
Reviewed-on: https://swiftshader-review.googlesource.com/17189
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix warnings treated as errors.
Nicolas Capens [Thu, 8 Feb 2018 15:26:10 +0000 (10:26 -0500)]
Fix warnings treated as errors.

Change-Id: I0c186ddd43c28a3f2c49321da23d5db44abe9dbf
Reviewed-on: https://swiftshader-review.googlesource.com/17148
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFuzzer fix
Alexis Hetu [Thu, 8 Feb 2018 14:53:46 +0000 (09:53 -0500)]
Fuzzer fix

Added missing resource initialization in order to prevent getting
"uninitialized value" errors when running the fuzzer.

Change-Id: I342441832a159b79cbf036d7ce87f05fcaf15e8c
Reviewed-on: https://swiftshader-review.googlesource.com/17128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Chromium build.
Nicolas Capens [Wed, 7 Feb 2018 22:18:00 +0000 (17:18 -0500)]
Fix Chromium build.

Change-Id: If8871d9286ef7c4d09fd075ad5c7b707079158dd
Reviewed-on: https://swiftshader-review.googlesource.com/17108
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 of uninitialized value fixed
Alexis Hetu [Wed, 7 Feb 2018 19:17:15 +0000 (14:17 -0500)]
Use of uninitialized value fixed

TParseContext::addConstVectorNode() was returning a
TIntermTyped* variable of the wrong type if a swizzle
was of a different size than the vector's size. When
parseVectorFields() fails, fields.num is reset to 1,
which no longer matches fieldString.size(), so
fieldString.size() should not have been used. To
avoid future errors, the proper type is now set
directly within TParseContext::addConstVectorNode().

Bug chromium:796776

Change-Id: Id5e8d1b94d0a03fcf5ef6f5deeb77581bc070288
Reviewed-on: https://swiftshader-review.googlesource.com/17089
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor pixel storage modes.
Nicolas Capens [Wed, 7 Feb 2018 21:29:06 +0000 (16:29 -0500)]
Refactor pixel storage modes.

Change-Id: Ida0a270c1e0ab0900109b7d3bce90dfee9a01960
Reviewed-on: https://swiftshader-review.googlesource.com/17091
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport loading of multiple compressed texture slices.
Nicolas Capens [Wed, 7 Feb 2018 19:18:52 +0000 (14:18 -0500)]
Support loading of multiple compressed texture slices.

Change-Id: I53def31f6e63a9cf0884715078bbf236f00f3c51
Reviewed-on: https://swiftshader-review.googlesource.com/17090
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 texture pixel upload offsets.
Nicolas Capens [Wed, 7 Feb 2018 04:14:45 +0000 (23:14 -0500)]
Refactor texture pixel upload offsets.

Apply xoffset, yoffset, and zoffset at image buffer lock so we don't
have to pass them down to the row loading functions as parameters.

Change-Id: I055549c80b1b207df4c49f6f59ecfb8286736040
Reviewed-on: https://swiftshader-review.googlesource.com/17068
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove redundant compressed format lookup.
Nicolas Capens [Tue, 6 Feb 2018 21:49:36 +0000 (16:49 -0500)]
Remove redundant compressed format lookup.

glCompressedTexSubImage2D() takes an internalformat parameter which
is already always a sized internal format.

Change-Id: Iaf783e019e08d941053d5f347ee495bdd179f1ce
Reviewed-on: https://swiftshader-review.googlesource.com/17050
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix the source buffer used by CopyTex[Sub]Image.
Nicolas Capens [Tue, 6 Feb 2018 19:44:47 +0000 (14:44 -0500)]
Fix the source buffer used by CopyTex[Sub]Image.

We were passing the framebuffer to the texture's copying method, where
the first render target was used, instead of the read buffer.

Change-Id: I344b4082f675b7e5fc6a73af31a6764ab4d3b6a3
Reviewed-on: https://swiftshader-review.googlesource.com/17049
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFragment output fix
Alexis Hetu [Tue, 6 Feb 2018 15:54:49 +0000 (10:54 -0500)]
Fragment output fix

Allow not specifying a fragment output location.

Change-Id: I76c6e6efdff3161586f5d5422e97731969b9396c
Reviewed-on: https://swiftshader-review.googlesource.com/17028
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor the copy validation matrix.
Nicolas Capens [Mon, 5 Feb 2018 20:04:51 +0000 (15:04 -0500)]
Refactor the copy validation matrix.

We were enumerating the color buffer formats by sized internal format,
which is simplified and made less fragile by retrieving the base
internal format and implementing the spec's validation tables more
directly.

Change-Id: I46d244b9ed738e927b0cb5fe6d1deebf6f0cbae5
Reviewed-on: https://swiftshader-review.googlesource.com/16988
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix using base internal format for CopyTexImage validation.
Nicolas Capens [Mon, 5 Feb 2018 19:18:10 +0000 (14:18 -0500)]
Fix using base internal format for CopyTexImage validation.

Change-Id: Iddd32408b090f00cbae15a76cab064d699f5098b
Reviewed-on: https://swiftshader-review.googlesource.com/16968
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoIn-class initialize all TType members.
Nicolas Capens [Mon, 5 Feb 2018 16:12:10 +0000 (11:12 -0500)]
In-class initialize all TType members.

Also remove default constructors and unused members.

Bug chromium:801648

Change-Id: I822ca1e1569708ca661796ee9252bae68a0a284a
Reviewed-on: https://swiftshader-review.googlesource.com/16948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSwap format/type in image upload.
Nicolas Capens [Tue, 23 Jan 2018 20:32:46 +0000 (20:32 +0000)]
Swap format/type in image upload.

This refactoring makes the code for texture image upload significantly
smaller. It also aligns better with the layout of table 3.2 in the
OpenGL ES 3.0 specification which lists valid format/type combinations.

Custom RGB565 format handling was removed because it corresponds with a
regular 2-byte per pixel memcpy.

Sized internal formats were removed because a recent change fixed not
using the internalformat parameter as upload format.

Change-Id: Ief6c6e60c3d9a734cac241022bc95ffc88d752c8
Reviewed-on: https://swiftshader-review.googlesource.com/16568
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 pixel size calculation from upload format.
Nicolas Capens [Tue, 23 Jan 2018 22:24:22 +0000 (22:24 +0000)]
Fix pixel size calculation from upload format.

We were using the internal format to compute the size of the pixels
provided for texture image upload. They can differ in size from the
format/type combination.

Change-Id: I7f3cd535cdefefc3c7ec4695d35d181b43ae20a4
Reviewed-on: https://swiftshader-review.googlesource.com/16629
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 CopyTexImage format validation.
Nicolas Capens [Fri, 2 Feb 2018 18:25:53 +0000 (13:25 -0500)]
Refactor CopyTexImage format validation.

Deduplicate common functions and remove unsized color buffer formats.

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