diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-14 17:41:05 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:37:36 +0000 |
commit | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch) | |
tree | 6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/third_party/angle | |
parent | 7366110654eec46f21b6824f302356426f48cd74 (diff) | |
download | qtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz |
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/angle')
260 files changed, 13492 insertions, 6089 deletions
diff --git a/chromium/third_party/angle/BUILD.gn b/chromium/third_party/angle/BUILD.gn index 993b562e356..1df81252b20 100644 --- a/chromium/third_party/angle/BUILD.gn +++ b/chromium/third_party/angle/BUILD.gn @@ -116,6 +116,8 @@ static_library("angle_common") { ":debug_annotations_config", "//build/config/compiler:no_chromium_code", ] + + public_deps = [ ":commit_id" ] } static_library("translator_lib") { @@ -222,9 +224,9 @@ config("libANGLE_config") { } if (angle_enable_gl) { defines += [ "ANGLE_ENABLE_OPENGL" ] - } - if (use_x11) { - defines += [ "ANGLE_USE_X11" ] + if (use_x11) { + defines += [ "ANGLE_USE_X11" ] + } } defines += [ "GL_GLEXT_PROTOTYPES", @@ -297,6 +299,15 @@ static_library("libANGLE") { "Xext", ] } + if (is_mac) { + sources += rebase_path(gles_gypi.libangle_gl_cgl_sources, ".", "src") + libs += [ + "Cocoa.framework", + "IOSurface.framework", + "OpenGL.framework", + "QuartzCore.framework", + ] + } } if (is_debug) { @@ -313,7 +324,7 @@ static_library("libANGLE") { ] if (is_win) { - deps += [ ":copy_compiler_dll" ] + data_deps = [ ":copy_compiler_dll" ] } } diff --git a/chromium/third_party/angle/DEPS.chromium b/chromium/third_party/angle/DEPS.chromium new file mode 100644 index 00000000000..a2f33b81359 --- /dev/null +++ b/chromium/third_party/angle/DEPS.chromium @@ -0,0 +1,26 @@ +# This file is used to manage the ANGLE's dependencies in the Chromium src repo. It is +# used by gclient to determine what version of each dependency to check out, and +# where. +# +# These deps are duplicated in ANGLE's DEPS file which we use for the standalone +# build. The dual file setup is necessary because Chromium can only recurse into +# a single file and we do not want to import all of ANGLE's standalone DEPS. +# +# If you make a change to one of these dependencies please also update the +# standalone DEPS file. + +vars = { + 'android_git': 'https://android.googlesource.com', + 'deqp_revision': 'cc0ded6c77267bbb14d21aac358fc5d9690c07f8', +} + +deps_os = { + 'win': { + 'src/third_party/deqp/src': + Var('android_git') + '/platform/external/deqp@' + Var('deqp_revision'), + }, + 'unix': { + 'src/third_party/deqp/src': + Var('android_git') + '/platform/external/deqp@' + Var('deqp_revision'), + } +} diff --git a/chromium/third_party/angle/build/angle_common.gni b/chromium/third_party/angle/build/angle_common.gni index 9d0718b6c0c..a5adc221e4d 100644 --- a/chromium/third_party/angle/build/angle_common.gni +++ b/chromium/third_party/angle/build/angle_common.gni @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/ui.gni") # import the use_x11 variable + angle_enable_d3d9 = false angle_enable_d3d11 = false angle_enable_gl = false @@ -12,11 +14,13 @@ if (is_win) { angle_enable_gl = true import("//build/config/win/visual_studio_version.gni") -} # is_win - -if (is_linux) { +} else if (is_linux && use_x11 && !is_chromeos) { + angle_enable_gl = true +} else if (is_mac) { angle_enable_gl = true } +# TODO(gyp): Probably also want to angle_enable_gl = true if (use_ozone) +# to match gyp. angle_enable_essl = true angle_enable_glsl = true diff --git a/chromium/third_party/angle/build/common_defines.gypi b/chromium/third_party/angle/build/common_defines.gypi index 7e3a503cc62..4a3a429cdcd 100644 --- a/chromium/third_party/angle/build/common_defines.gypi +++ b/chromium/third_party/angle/build/common_defines.gypi @@ -13,6 +13,14 @@ 'angle_build_winrt%': '0', 'angle_build_winphone%': '0', + + # This works like the Ozone GBM platform in Chrome: + # - Generic Buffer Manager (gbm) to allocate buffers + # - EGL_EXT_image_dma_buf_import to render into those buffers via EGLImage + # - Direct Rendering Manager + Kernel Mode Setting to scan out from those buffers + # - EGL_PLATFORM_SURFACELESS because there are no native windows + 'use_ozone%': 0, + 'conditions': [ ['OS=="linux" and use_x11==1 and chromeos==0', { @@ -38,6 +46,10 @@ ], 'conditions': [ + ['use_ozone==1', + { + 'defines': [ 'USE_OZONE' ], + }], ['component=="shared_library"', { 'defines': [ 'COMPONENT_BUILD' ], diff --git a/chromium/third_party/angle/build/standalone.gypi b/chromium/third_party/angle/build/standalone.gypi index 27061b6ece8..f18cc04bb20 100644 --- a/chromium/third_party/angle/build/standalone.gypi +++ b/chromium/third_party/angle/build/standalone.gypi @@ -5,24 +5,25 @@ { 'variables': { - # Assume for the time being that we're never compiling - # standalone ANGLE on Chrome OS. + # chromeos=1 is used in some build configurations to disable GL + # and GLX code because it typically wouldn't build for Chrome OS. + # It does not mean "enable Chrome OS code." 'chromeos': 0, - # Chromium puts the pkg-config command in a variable because - # calling pkg-config directly doesn't work in a sysroot image. - # See Chromium bug 569947 for more information. - # For standalone builds we don't have this problem so we use - # the regular command. - 'pkg-config': 'pkg-config', + # Chrome OS chroot builds need a special pkg-config, so make it possible to change. + 'pkg-config%': 'pkg-config', # Use a nested variable trick to get use_x11 evaluated more # eagerly than other conditional variables. 'variables': { + 'variables': + { + 'use_ozone%': 0, + }, 'conditions': [ - ['OS=="linux"', + ['OS=="linux" and use_ozone==0', { 'use_x11': 1, }, @@ -30,6 +31,9 @@ 'use_x11': 0, }], ], + + # Copy conditionally-set variables out one scope. + 'use_ozone%': '<(use_ozone)', }, # Copy conditionally-set variables out one scope. diff --git a/chromium/third_party/angle/extensions/CHROMIUM_bind_uniform_location.txt b/chromium/third_party/angle/extensions/CHROMIUM_bind_uniform_location.txt new file mode 100644 index 00000000000..adcae6fa6d2 --- /dev/null +++ b/chromium/third_party/angle/extensions/CHROMIUM_bind_uniform_location.txt @@ -0,0 +1,131 @@ +Name + + CHROMIUM_bind_uniform_location + +Name Strings + + GL_CHROMIUM_bind_uniform_location + +Version + + Last Modifed Date: September 8, 2015 + +Dependencies + + OpenGL ES 2.0 is required. + +Overview + + This extension is simlar to glBindAttribLocation but instead + lets you choose a location for a uniform. This allows you + to not have to query the locations of uniforms. + + This allows the client program to know the locations of uniforms + without having to wait for shaders to compile or GLSL programs to + link to query the locations and therefore have no blocking calls + when initializing programs. + +Issues + + If a uniform is an array you can only call glBindUniformLocation + for the location of the first element. Other elements' locations + must be queried if you need them. Often this is not an issue + because you can set all the elements with a single gl call from + the first location. + + Good Example: + + --shader-- + uniform float u_someArray[4]; + + --C-- + GLint location = 123; + glBindUniformLocation(program, location, "u_someArray"); + glLinkProgram(program); + glUseProgram(program); + + // set all 4 floats in u_someArray + float values[] = { 0.1f, 0.2f, 0.3f, 0.4f, }; + glUniform1fv(location, 4, values); + + Bad example 1: + + GLint location = 123; + glBindUniformLocation(program, location, "u_someArray"); + glLinkProgram(program); + glUseProgram(program); + + // set floats in u_someArray one at a time + glUniform1f(location, 0.1f); + glUniform1f(location + 1, 0.2f); // ERROR! math not allowed on locations + + Bad example 2: + + GLint location0 = 123; + GLint location1 = 124; + glBindUniformLocation(program, location0, "u_someArray[0]"); + glBindUniformLocation(program, location1, "u_someArray[1]"); // ERROR! + // not allowed to assign locations to array elements + + If you need to set individual elements of a uniform array you must query the + location of the each element you wish to set. + +New Tokens + + None + +New Procedures and Functions + + void BindUniformLocationCHROMIUM (GLuint program, GLint location, + const GLhchar* name); + + specifes that the uniform variable named <name> in program <program> + should be bound to uniform location <location> when the program is next + linked. If <name> was bound previously, its assigned binding is replaced + with <location>. <name> must be a null terminated string. The error + INVALID_VALUE is generated if <location> is equal or greater than + + (MAX_VERTEX_UNIFORM_VECTORS + MAX_FRAGMENT_UNIFORM_VECTORS) * 4 + + or less than 0. BindUniformLocation has no effect until the program is + linked. In particular, it doesn't modify the bindings of active uniforms + variables in a program that has already been linked. + + The error INVALID_OPERATION is generated if name starts with the reserved + "gl_" prefix. The error INVALID_VALUE is generated if name ends with + an array element expression other than "[0]". + + When a program is linked, any active uniforms without a binding specified + through BindUniformLocation will be automatically be bound to locations by + the GL. Such bindings can be queried using the command + GetUniformLocation. + + BindUniformLocation may be issued before any shader objects are attached + to a program object. Hence it is allowed to bind any name (except a name + starting with "gl_") to an index, including a name that is never used as a + uniform in any shader object. Assigned bindings for uniform variables + that do not exist or are not active are ignored. Using such bindings + behaves as if passed location was -1. + + It is possible for an application to bind more than one uniform name to + the same location. This is referred to as aliasing. This will only work + if only one of the aliased uniforms is active in the executable program, + or if no path through the shader consumes more than one uniform of a set + of uniforms aliased to the same location. If two statically used uniforms + in a program are bound to the name location, link must fail. + +Errors + + None. + +New State + + None. + +Revision History + + 7/20/2012 Documented the extension + 9/8/2015 Require program link to fail if two statically used uniforms + are bound to the same location. + 11/6/2015 Require inactive and non-existing, bound uniform locations + to behave like location -1. diff --git a/chromium/third_party/angle/extensions/CHROMIUM_sync_query.txt b/chromium/third_party/angle/extensions/CHROMIUM_sync_query.txt new file mode 100644 index 00000000000..98763d0a383 --- /dev/null +++ b/chromium/third_party/angle/extensions/CHROMIUM_sync_query.txt @@ -0,0 +1,53 @@ +Name + + CHROMIUM_sync_query + +Name Strings + + GL_CHROMIUM_sync_query + +Version + + Last Modifed Date: April 15, 2014 + +Dependencies + + OpenGL ES 2.0 is required. + + EXT_occlusion_query_boolean is required. + +Overview + + This extension provides a query mechanism that allow for synchronization + between the host CPU and the GPU, which may be accessing the same + resources (typically memory). + + This extension is useful in conjunction with CHROMIUM_map_image to + determine when it is safe to access a mapped image. Once the result of + a COMMANDS_COMPLETED_CHROMIUM query is available, all drawing commands + issued before the query must have finished. This ensures that the memory + corresponding to the issued commands can be safely modified (assuming no + other outstanding drawing commands are issued subsequent to the query). + +New Procedures and Functions + + None. + +Errors + + None. + +New Tokens + + Accepted by the <target> parameter of BeginQueryEXT, EndQueryEXT, + and GetQueryivEXT: + + COMMANDS_COMPLETED_CHROMIUM 0x84F7 + +New State + + None. + +Revision History + + 4/15/2014 Documented the extension diff --git a/chromium/third_party/angle/extensions/EGL_ANGLE_stream_producer_d3d_texture_nv12.txt b/chromium/third_party/angle/extensions/EGL_ANGLE_stream_producer_d3d_texture_nv12.txt new file mode 100644 index 00000000000..86b49e87fc6 --- /dev/null +++ b/chromium/third_party/angle/extensions/EGL_ANGLE_stream_producer_d3d_texture_nv12.txt @@ -0,0 +1,156 @@ +Name + + ANGLE_stream_producer_d3d_texture_nv12 + +Name Strings + + EGL_ANGLE_stream_producer_d3d_texture_nv12 + +Contributors + + Ian Ewell + Geoff Lang + John Bauman + +Contacts + + Geoff Lang, Google (geofflang ‘at’ google.com) + +Status + + Draft + +Version + + Version 1, April 6, 2016 + +Number + + EGL Extension #XXX + +Dependencies + + Requires EGL 1.5. + Requires OpenGL ES 2.0. + + Requires the EGL_KHR_stream extension. + Requires the EGL_NV_stream_consumer_gltexture_yuv extension. + Requires the EGL_ANGLE_device_d3d extension. + +Overview + + This extension allows D3D11 NV12 textures to be inserted into an EGL stream + with the expectation that the stream consumer will be a YUV GL texture + consumer using a two plane configuration (i.e. a Y plane and a UV plane). + This will act as the producer of the stream. + +New procedures and functions + + EGLBoolean eglCreateStreamProducerD3DTextureNV12ANGLE + (EGLDisplay dpy, + EGLStreamKHR stream, + const EGLAttrib *attrib_list) + EGLBoolean eglStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + void *texture, + const EGLAttrib *attrib_list) + +New Tokens + + Accepted as an <attribute> in eglStreamPostD3DTextureNV12ANGLE: + + EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x3AAB + +Replace section "3.10.3.1 No way to connect producer to EGLStream" in the +EGL_KHR_stream extension with this: + + 3.10.3.1 Stream Surface Producer + + Call + + EGLBoolean eglCreateStreamProducerD3DTextureNV12ANGLE( + EGLDisplay dpy, + EGLStreamKHR stream, + const EGLAttrib *attrib_list) + + to create a producer that accepts D3D11 NV12 textures and connect it as the + producer of <stream>. <attrib_list> is used to specify attributes for the + stream producer. Currently there are no attributes to specify, and the + attribute list is used as a placeholder for future additions. + + On failure, eglCreateStreamProducerD3DTextureNV12ANGLE returns EGL_FALSE and + generates an error. + + - EGL_BAD_STATE_KHR is generated if <stream> is not in the state + EGL_STREAM_STATE_CONNECTING_KHR. + + - EGL_BAD_MATCH is generated if <stream> does not have a connected GL + texture YUV consumer that is configured to bind to two OpenGL + textures: one for the Y plane and one for the UV plane. + + - EGL_BAD_STREAM_KHR is generated if <stream> is not a valid EGLStream + generated for <dpy>. + + - EGL_BAD_DISPLAY is generated if <dpy> is not a valid, initialized + display. + +Add a section preceding "3.9.3 Posting Semantics" in the EGL specification: + + 3.9.x Posting to a Stream + + To post a D3D11 NV12 texture to a stream, call + + EGLBoolean eglStreamPostD3DTextureNV12ANGLE( + EGLDisplay dpy, + EGLStreamKHR stream, + void *texture, + const EGLAttrib *attrib_list); + + If <stream> is an appropriately configured stream and <texture> points to a + valid ID3D11Texture2D object of the format DXGI_FORMAT_NV12 that is owned + by the same ID3D11Device that is queried with the EGL_ANGLE_device_d3d + extension, the texture will be posted to the stream and can be bound as one + or more OpenGL texture objects. + + The parameter <attrib_list> allows for per-frame attributes to be specified + along with the texture. The only parameter currently available is + EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, which allows the subresource id of + the texture that will be used to be specified. If this attribute is not + explicitly specified, it will default to the value of 0. + + It is the responsibility of the application to perform any synchronization + between the insertion of the frame into the stream and the use of the + consumer textures output by the stream. The EGL_CONSUMER_LATENCY_USEC_KHR + attribute will have no effect on the function of the implementation of this + extension, but can still be used for communication between components of + the application. + + The implementation will hold a reference to the D3D11 texture object if the + insertion is successful and will release the texture object when a new frame + is inserted or when the stream is destroyed. + + On failure, eglStreamInsertD3DTextureNV12 returns EGL_FALSE and generates an + error. + + - EGL_BAD_STATE is generated if <stream> is not in the state + EGL_STREAM_STATE_EMPTY_KHR, EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR, + or EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR. + + - EGL_BAD_MATCH is generated if the stream is not associated with a + D3D11 NV12 texture producer. + + - EGL_BAD_PARAMETER is generated if <texture> is not owned by the + queried device, is not in the format DXGI_FORMAT_NV12, is not + compatible with the implementation, or if the specified value for + EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE is not a valid subresource id for + the texture. + + - EGL_BAD_STREAM_KHR is generated if <stream> is not a valid EGLStream. + + - EGL_BAD_ATTRIBUTE is generated if an attribute other than + EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE is specified in <attrib_list>. + +Revision History + + #1 (April 6, 2016) Ian Ewell + - initial draft
\ No newline at end of file diff --git a/chromium/third_party/angle/include/EGL/eglext.h b/chromium/third_party/angle/include/EGL/eglext.h index a6a5363de30..fc0a3779b19 100644 --- a/chromium/third_party/angle/include/EGL/eglext.h +++ b/chromium/third_party/angle/include/EGL/eglext.h @@ -556,6 +556,17 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu #define EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE 0x33AA #endif /* EGL_ANGLE_experimental_present_path */ +#ifndef EGL_ANGLE_stream_producer_d3d_texture_nv12 +#define EGL_ANGLE_stream_producer_d3d_texture_nv12 +#define EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x3AAB +typedef EGLBoolean(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERD3DTEXTURENV12ANGLEPROC)(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMPOSTD3DTEXTURENV12ANGLEPROC)(EGLDisplay dpy, EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglCreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_ANGLE_stream_producer_d3d_texture_nv12 */ + #ifndef EGL_ARM_pixmap_multisample_discard #define EGL_ARM_pixmap_multisample_discard 1 #define EGL_DISCARD_SAMPLES_ARM 0x3286 diff --git a/chromium/third_party/angle/include/GLES2/gl2ext.h b/chromium/third_party/angle/include/GLES2/gl2ext.h index 51886a2dcb8..d9083e39a1e 100644 --- a/chromium/third_party/angle/include/GLES2/gl2ext.h +++ b/chromium/third_party/angle/include/GLES2/gl2ext.h @@ -821,6 +821,15 @@ GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GL #endif #endif /* GL_ANGLE_framebuffer_blit */ +#ifndef GL_CHROMIUM_framebuffer_mixed_samples +#define GL_CHROMIUM_frambuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_CHROMIUM 0x9332 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONCHROMIUMPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageModulationCHROMIUM(GLenum components); +#endif +#endif /* GL_CHROMIUM_framebuffer_mixed_samples */ + #ifndef GL_ANGLE_framebuffer_multisample #define GL_ANGLE_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB @@ -1009,6 +1018,11 @@ GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei #define GL_ARM_shader_framebuffer_fetch_depth_stencil 1 #endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */ +#ifndef GL_CHROMIUM_sync_query +#define GL_CHROMIUM_sync_query 1 +#define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7 +#endif /* GL_CHROMIUM_sync_query */ + #ifndef GL_DMP_program_binary #define GL_DMP_program_binary 1 #define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 diff --git a/chromium/third_party/angle/include/GLSLANG/ShaderLang.h b/chromium/third_party/angle/include/GLSLANG/ShaderLang.h index 78f8ef62014..91201540c7d 100644 --- a/chromium/third_party/angle/include/GLSLANG/ShaderLang.h +++ b/chromium/third_party/angle/include/GLSLANG/ShaderLang.h @@ -255,6 +255,7 @@ typedef struct // Set to 1 to enable the extension, else 0. int OES_standard_derivatives; int OES_EGL_image_external; + int NV_EGL_stream_consumer_external; int ARB_texture_rectangle; int EXT_blend_func_extended; int EXT_draw_buffers; diff --git a/chromium/third_party/angle/scripts/bmp_to_nv12.py b/chromium/third_party/angle/scripts/bmp_to_nv12.py new file mode 100644 index 00000000000..facb43e9bf5 --- /dev/null +++ b/chromium/third_party/angle/scripts/bmp_to_nv12.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# +# Copyright 2016 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# bmp_to_nv12.py: +# Script to convert a simple BMP file to an NV12 format. Used to create +# test images for the NV12 texture stream end to end tests + +import sys +import struct + +if len(sys.argv) != 4: + print("Usage: bmp_to_nv12.py input output prefix") + exit(0) + +bmp_file = open(sys.argv[1], "rb") + +magic = bmp_file.read(2) +if (magic != "BM"): + print("Invalid BMP magic") + exit(1) + +file_size, = struct.unpack("I", bmp_file.read(4)) + +# eat reserved bytes +bmp_file.read(4) + +offset, = struct.unpack("I", bmp_file.read(4)) + +headersize, = struct.unpack("I", bmp_file.read(4)) +width, = struct.unpack("i", bmp_file.read(4)) +height, = struct.unpack("i", bmp_file.read(4)) +planes, = struct.unpack("H", bmp_file.read(2)) +bpp, = struct.unpack("H", bmp_file.read(2)) +compression, = struct.unpack("i", bmp_file.read(4)) +image_size, = struct.unpack("i", bmp_file.read(4)) + +if (bpp != 24 or compression != 0): + print("Unsupported BMP file") + bmp_file.close() + exit(1) + +bmp_file.seek(offset, 0) +pixels = bmp_file.read(width * height * 3) +bmp_file.close() + +# convert to YUV 4:4:4 +converted_pixels = bytearray(pixels) +for i in range(0, width * height): + R, = struct.unpack("B", pixels[i*3+2]) + G, = struct.unpack("B", pixels[i*3+1]) + B, = struct.unpack("B", pixels[i*3]) + converted_pixels[i*3] = ((66*R + 129*G + 25*B + 128) >> 8) + 16 + converted_pixels[i*3+1] = ((-38*R - 74*G + 112*B + 128) >> 8) + 128 + converted_pixels[i*3+2] = ((112*R - 94*G - 18*B + 128) >> 8) + 128 + +# downsample to packed UV buffer +uv_buffer = bytearray(width * height / 2) +for i in range(0, width * height / 2, 2): + U1 = converted_pixels[((((i / width) * 2) * width) + (i % width)) * 3 + 1] + U2 = converted_pixels[((((i / width) * 2) * width) + width + (i % width)) * 3 + 1] + V1 = converted_pixels[((((i / width) * 2) * width) + (i % width)) * 3 + 2] + V2 = converted_pixels[((((i / width) * 2) * width) + width + (i % width)) * 3 + 2] + uv_buffer[i] = (U1 + U2) / 2 + uv_buffer[i + 1] = (V1 + V2) / 2 + +# extract the Y buffer +y_buffer = bytearray(width * height) +for i in range(0, width * height): + y_buffer[i] = converted_pixels[i * 3] + +# write out the file as a C header +nv12_file = open(sys.argv[2], "w") +nv12_file.write("// Automatically generated from " + sys.argv[1] + "\n") +nv12_file.write("static const size_t " + sys.argv[3] + "_width = " + str(width) + ";\n") +nv12_file.write("static const size_t " + sys.argv[3] + "_height = " + str(height) + ";\n") +nv12_file.write("static const unsigned char " + sys.argv[3] + "_data[] = \n{") +for i in range(0, width * height): + if (i % 16) == 0: + nv12_file.write("\n ") + nv12_file.write(str(y_buffer[i]) + ",") +for i in range(0, width * height / 2): + if (i % 16) == 0: + nv12_file.write("\n ") + nv12_file.write(str(uv_buffer[i]) + ",") +nv12_file.write("\n};") +nv12_file.close()
\ No newline at end of file diff --git a/chromium/third_party/angle/scripts/perf_test_runner.py b/chromium/third_party/angle/scripts/perf_test_runner.py index eb910fe0d5a..41ae40daada 100644 --- a/chromium/third_party/angle/scripts/perf_test_runner.py +++ b/chromium/third_party/angle/scripts/perf_test_runner.py @@ -26,6 +26,9 @@ perftests_paths = [ ] metric = 'score' +# TODO(jmadill): Linux binaries +binary_name = 'angle_perftests.exe' + scores = [] # Danke to http://stackoverflow.com/a/27758326 @@ -63,13 +66,19 @@ def truncated_mean(data, n): def truncated_stddev(data, n): return pstdev(truncated_list(data, n)) -perftests_path = "" +# Find most recent binary +newest_binary = None +newest_mtime = None -# TODO(jmadill): Linux binaries for path in perftests_paths: - perftests_path = os.path.join(base_path, path, 'angle_perftests.exe') - if os.path.exists(perftests_path): - break + binary_path = os.path.join(base_path, path, binary_name) + binary_mtime = os.path.getmtime(binary_path) + if os.path.exists(binary_path): + if (newest_binary is None) or (binary_mtime > newest_mtime): + newest_binary = binary_path + newest_mtime = binary_mtime + +perftests_path = newest_binary if not os.path.exists(perftests_path): print("Cannot find angle_perftests.exe!") diff --git a/chromium/third_party/angle/scripts/update_canary_angle.py b/chromium/third_party/angle/scripts/update_canary_angle.py new file mode 100644 index 00000000000..a572b87536b --- /dev/null +++ b/chromium/third_party/angle/scripts/update_canary_angle.py @@ -0,0 +1,64 @@ +#!/usr/bin/python +# +# Copyright 2016 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# update_canary_angle.py: +# Helper script that copies Windows ANGLE DLLs into the Canary +# application directory. Much faster than compiling Chrome from +# source. The script checks for the most recent DLLs in a set of +# search paths, and copies that into the most recent Canary +# binary folder. Only works on Windows. + +import sys, os, shutil + +# Set of search paths. +source_paths = [ + os.path.join('..', 'build', 'Debug_x64'), + os.path.join('..', 'build', 'Debug_Win32'), + os.path.join('..', 'build', 'Release_x64'), + os.path.join('..', 'build', 'Release_Win32'), + os.path.join('..', 'out', 'Debug'), + os.path.join('..', 'out', 'Debug_x64'), + os.path.join('..', 'out', 'Release'), + os.path.join('..', 'out', 'Release_x64'), +] + +# Default Canary installation path. +chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application') + +# Find the most recent ANGLE DLLs +binary_name = 'libGLESv2.dll' +newest_folder = None +newest_mtime = None +for path in source_paths: + binary_path = os.path.join(path, binary_name) + if os.path.exists(binary_path): + binary_mtime = os.path.getmtime(binary_path) + if (newest_folder is None) or (binary_mtime > newest_mtime): + newest_folder = path + newest_mtime = binary_mtime + +source_folder = newest_folder + +# Is a folder a chrome binary directory? +def is_chrome_bin(str): + chrome_file = os.path.join(chrome_folder, str) + return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str]) + +sorted_chrome_bins = sorted([folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True) + +dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0]) + +print('Copying DLLs from ' + source_folder + ' to ' + dest_folder + '.') + +# Translator.dll appears if we build in component=shared_library mode. +for dll in ['libGLESv2.dll', 'libEGL.dll', 'translator.dll']: + src = os.path.join(source_folder, dll) + if os.path.exists(src): + # Make a backup of the original unmodified DLLs if they are present. + backup = os.path.join(source_folder, dll + '.backup') + if not os.path.exists(backup): + shutil.copyfile(src, backup) + shutil.copyfile(src, os.path.join(dest_folder, dll)) diff --git a/chromium/third_party/angle/src/angle.gyp b/chromium/third_party/angle/src/angle.gyp index 4421acca162..14ae9676ab9 100644 --- a/chromium/third_party/angle/src/angle.gyp +++ b/chromium/third_party/angle/src/angle.gyp @@ -6,7 +6,6 @@ 'variables': { 'angle_code': 1, - 'angle_post_build_script%': 0, 'angle_gen_path': '<(SHARED_INTERMEDIATE_DIR)/angle', 'angle_id_script_base': 'commit_id.py', 'angle_id_script': '<(angle_gen_path)/<(angle_id_script_base)', @@ -38,6 +37,10 @@ { 'angle_enable_gl%': 1, }], + ['use_ozone==1', + { + 'angle_enable_gl%': 1, + }], ], }, 'includes': @@ -62,6 +65,10 @@ '.', '../include', ], + 'dependencies': + [ + 'commit_id', + ], 'direct_dependent_settings': { 'include_dirs': @@ -240,28 +247,5 @@ }, ], # targets }], - ['angle_post_build_script!=0 and OS=="win"', - { - 'targets': - [ - { - 'target_name': 'post_build', - 'type': 'none', - 'includes': [ '../build/common_defines.gypi', ], - 'dependencies': [ 'libGLESv2', 'libEGL' ], - 'actions': - [ - { - 'action_name': 'ANGLE Post-Build Script', - 'message': 'Running <(angle_post_build_script)...', - 'msvs_cygwin_shell': 0, - 'inputs': [ '<(angle_post_build_script)', '<!@(["python", "<(angle_post_build_script)", "inputs", "<(angle_path)", "<(CONFIGURATION_NAME)", "$(PlatformName)", "<(PRODUCT_DIR)"])' ], - 'outputs': [ '<!@(python <(angle_post_build_script) outputs "<(angle_path)" "<(CONFIGURATION_NAME)" "$(PlatformName)" "<(PRODUCT_DIR)")' ], - 'action': ['python', '<(angle_post_build_script)', 'run', '<(angle_path)', '<(CONFIGURATION_NAME)', '$(PlatformName)', '<(PRODUCT_DIR)'], - }, - ], #actions - }, - ], # targets - }], ] # conditions } diff --git a/chromium/third_party/angle/src/common/utilities.cpp b/chromium/third_party/angle/src/common/utilities.cpp index 2ab913b10ff..9686c7403dd 100644 --- a/chromium/third_party/angle/src/common/utilities.cpp +++ b/chromium/third_party/angle/src/common/utilities.cpp @@ -127,6 +127,7 @@ GLenum VariableComponentType(GLenum type) case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: + case GL_SAMPLER_EXTERNAL_OES: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: @@ -334,6 +335,7 @@ bool IsSamplerType(GLenum type) case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: + case GL_SAMPLER_EXTERNAL_OES: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: @@ -361,6 +363,9 @@ GLenum SamplerTypeToTextureType(GLenum samplerType) case GL_SAMPLER_2D_SHADOW: return GL_TEXTURE_2D; + case GL_SAMPLER_EXTERNAL_OES: + return GL_TEXTURE_EXTERNAL_OES; + case GL_SAMPLER_CUBE: case GL_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_CUBE: diff --git a/chromium/third_party/angle/src/compiler.gypi b/chromium/third_party/angle/src/compiler.gypi index c58891325f6..feb8a0ee723 100644 --- a/chromium/third_party/angle/src/compiler.gypi +++ b/chromium/third_party/angle/src/compiler.gypi @@ -34,6 +34,8 @@ 'compiler/translator/Compiler.cpp', 'compiler/translator/Compiler.h', 'compiler/translator/ConstantUnion.h', + 'compiler/translator/DeferGlobalInitializers.cpp', + 'compiler/translator/DeferGlobalInitializers.h', 'compiler/translator/Diagnostics.cpp', 'compiler/translator/Diagnostics.h', 'compiler/translator/DirectiveHandler.cpp', @@ -182,6 +184,8 @@ 'compiler/translator/SeparateExpressionsReturningArrays.h', 'compiler/translator/StructureHLSL.cpp', 'compiler/translator/StructureHLSL.h', + 'compiler/translator/TextureFunctionHLSL.cpp', + 'compiler/translator/TextureFunctionHLSL.h', 'compiler/translator/TranslatorHLSL.cpp', 'compiler/translator/TranslatorHLSL.h', 'compiler/translator/UnfoldShortCircuitToIf.cpp', diff --git a/chromium/third_party/angle/src/compiler/translator/Compiler.cpp b/chromium/third_party/angle/src/compiler/translator/Compiler.cpp index 77360d23860..66da0c2d6f6 100644 --- a/chromium/third_party/angle/src/compiler/translator/Compiler.cpp +++ b/chromium/third_party/angle/src/compiler/translator/Compiler.cpp @@ -7,6 +7,7 @@ #include "compiler/translator/Cache.h" #include "compiler/translator/Compiler.h" #include "compiler/translator/CallDAG.h" +#include "compiler/translator/DeferGlobalInitializers.h" #include "compiler/translator/ForLoopUnroll.h" #include "compiler/translator/Initialize.h" #include "compiler/translator/InitializeParseContext.h" @@ -376,6 +377,11 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[], RegenerateStructNames gen(symbolTable, shaderVersion); root->traverse(&gen); } + + if (success) + { + DeferGlobalInitializers(root); + } } SetGlobalParseContext(NULL); diff --git a/chromium/third_party/angle/src/compiler/translator/DeferGlobalInitializers.cpp b/chromium/third_party/angle/src/compiler/translator/DeferGlobalInitializers.cpp new file mode 100644 index 00000000000..6904f9401a1 --- /dev/null +++ b/chromium/third_party/angle/src/compiler/translator/DeferGlobalInitializers.cpp @@ -0,0 +1,198 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// DeferGlobalInitializers is an AST traverser that moves global initializers into a function, and +// adds a function call to that function in the beginning of main(). +// This enables initialization of globals with uniforms or non-constant globals, as allowed by +// the WebGL spec. Some initializers referencing non-constants may need to be unfolded into if +// statements in HLSL - this kind of steps should be done after DeferGlobalInitializers is run. +// + +#include "compiler/translator/DeferGlobalInitializers.h" + +#include "compiler/translator/IntermNode.h" +#include "compiler/translator/SymbolTable.h" + +namespace +{ + +void SetInternalFunctionName(TIntermAggregate *functionNode, const char *name) +{ + TString nameStr(name); + nameStr = TFunction::mangleName(nameStr); + TName nameObj(nameStr); + nameObj.setInternal(true); + functionNode->setNameObj(nameObj); +} + +TIntermAggregate *CreateFunctionPrototypeNode(const char *name, const int functionId) +{ + TIntermAggregate *functionNode = new TIntermAggregate(EOpPrototype); + + SetInternalFunctionName(functionNode, name); + TType returnType(EbtVoid); + functionNode->setType(returnType); + functionNode->setFunctionId(functionId); + return functionNode; +} + +TIntermAggregate *CreateFunctionDefinitionNode(const char *name, + TIntermAggregate *functionBody, + const int functionId) +{ + TIntermAggregate *functionNode = new TIntermAggregate(EOpFunction); + TIntermAggregate *paramsNode = new TIntermAggregate(EOpParameters); + functionNode->getSequence()->push_back(paramsNode); + functionNode->getSequence()->push_back(functionBody); + + SetInternalFunctionName(functionNode, name); + TType returnType(EbtVoid); + functionNode->setType(returnType); + functionNode->setFunctionId(functionId); + return functionNode; +} + +TIntermAggregate *CreateFunctionCallNode(const char *name, const int functionId) +{ + TIntermAggregate *functionNode = new TIntermAggregate(EOpFunctionCall); + + functionNode->setUserDefined(); + SetInternalFunctionName(functionNode, name); + TType returnType(EbtVoid); + functionNode->setType(returnType); + functionNode->setFunctionId(functionId); + return functionNode; +} + +class DeferGlobalInitializersTraverser : public TIntermTraverser +{ + public: + DeferGlobalInitializersTraverser(); + + bool visitBinary(Visit visit, TIntermBinary *node) override; + + void insertInitFunction(TIntermNode *root); + + private: + TIntermSequence mDeferredInitializers; +}; + +DeferGlobalInitializersTraverser::DeferGlobalInitializersTraverser() + : TIntermTraverser(true, false, false) +{ +} + +bool DeferGlobalInitializersTraverser::visitBinary(Visit visit, TIntermBinary *node) +{ + if (node->getOp() == EOpInitialize) + { + TIntermSymbol *symbolNode = node->getLeft()->getAsSymbolNode(); + ASSERT(symbolNode); + TIntermTyped *expression = node->getRight(); + + if (mInGlobalScope && (expression->getQualifier() != EvqConst || + (expression->getAsConstantUnion() == nullptr && + !expression->isConstructorWithOnlyConstantUnionParameters()))) + { + // For variables which are not constant, defer their real initialization until + // after we initialize uniforms. + // Deferral is done also in any cases where the variable has not been constant folded, + // since otherwise there's a chance that HLSL output will generate extra statements + // from the initializer expression. + TIntermBinary *deferredInit = new TIntermBinary(EOpAssign); + deferredInit->setLeft(symbolNode->deepCopy()); + deferredInit->setRight(node->getRight()); + deferredInit->setType(node->getType()); + mDeferredInitializers.push_back(deferredInit); + + // Change const global to a regular global if its initialization is deferred. + // This can happen if ANGLE has not been able to fold the constant expression used + // as an initializer. + ASSERT(symbolNode->getQualifier() == EvqConst || + symbolNode->getQualifier() == EvqGlobal); + if (symbolNode->getQualifier() == EvqConst) + { + // All of the siblings in the same declaration need to have consistent qualifiers. + auto *siblings = getParentNode()->getAsAggregate()->getSequence(); + for (TIntermNode *siblingNode : *siblings) + { + TIntermBinary *siblingBinary = siblingNode->getAsBinaryNode(); + if (siblingBinary) + { + ASSERT(siblingBinary->getOp() == EOpInitialize); + siblingBinary->getLeft()->getTypePointer()->setQualifier(EvqGlobal); + } + siblingNode->getAsTyped()->getTypePointer()->setQualifier(EvqGlobal); + } + // This node is one of the siblings. + ASSERT(symbolNode->getQualifier() == EvqGlobal); + } + // Remove the initializer from the global scope and just declare the global instead. + mReplacements.push_back(NodeUpdateEntry(getParentNode(), node, symbolNode, false)); + } + } + return false; +} + +void DeferGlobalInitializersTraverser::insertInitFunction(TIntermNode *root) +{ + if (mDeferredInitializers.empty()) + { + return; + } + const int initFunctionId = TSymbolTable::nextUniqueId(); + TIntermAggregate *rootAgg = root->getAsAggregate(); + ASSERT(rootAgg != nullptr && rootAgg->getOp() == EOpSequence); + + const char *functionName = "initializeDeferredGlobals"; + + // Add function prototype to the beginning of the shader + TIntermAggregate *functionPrototypeNode = + CreateFunctionPrototypeNode(functionName, initFunctionId); + rootAgg->getSequence()->insert(rootAgg->getSequence()->begin(), functionPrototypeNode); + + // Add function definition to the end of the shader + TIntermAggregate *functionBodyNode = new TIntermAggregate(EOpSequence); + TIntermSequence *functionBody = functionBodyNode->getSequence(); + for (const auto &deferredInit : mDeferredInitializers) + { + functionBody->push_back(deferredInit); + } + TIntermAggregate *functionDefinition = + CreateFunctionDefinitionNode(functionName, functionBodyNode, initFunctionId); + rootAgg->getSequence()->push_back(functionDefinition); + + // Insert call into main function + for (TIntermNode *node : *rootAgg->getSequence()) + { + TIntermAggregate *nodeAgg = node->getAsAggregate(); + if (nodeAgg != nullptr && nodeAgg->getOp() == EOpFunction && + TFunction::unmangleName(nodeAgg->getName()) == "main") + { + TIntermAggregate *functionCallNode = + CreateFunctionCallNode(functionName, initFunctionId); + + TIntermNode *mainBody = nodeAgg->getSequence()->back(); + TIntermAggregate *mainBodyAgg = mainBody->getAsAggregate(); + ASSERT(mainBodyAgg != nullptr && mainBodyAgg->getOp() == EOpSequence); + mainBodyAgg->getSequence()->insert(mainBodyAgg->getSequence()->begin(), + functionCallNode); + } + } +} + +} // namespace + +void DeferGlobalInitializers(TIntermNode *root) +{ + DeferGlobalInitializersTraverser traverser; + root->traverse(&traverser); + + // Replace the initializers of the global variables. + traverser.updateTree(); + + // Add the function with initialization and the call to that. + traverser.insertInitFunction(root); +} diff --git a/chromium/third_party/angle/src/compiler/translator/DeferGlobalInitializers.h b/chromium/third_party/angle/src/compiler/translator/DeferGlobalInitializers.h new file mode 100644 index 00000000000..14f25539c3b --- /dev/null +++ b/chromium/third_party/angle/src/compiler/translator/DeferGlobalInitializers.h @@ -0,0 +1,20 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// DeferGlobalInitializers is an AST traverser that moves global initializers into a function, and +// adds a function call to that function in the beginning of main(). +// This enables initialization of globals with uniforms or non-constant globals, as allowed by +// the WebGL spec. Some initializers referencing non-constants may need to be unfolded into if +// statements in HLSL - this kind of steps should be done after DeferGlobalInitializers is run. +// + +#ifndef COMPILER_TRANSLATOR_DEFERGLOBALINITIALIZERS_H_ +#define COMPILER_TRANSLATOR_DEFERGLOBALINITIALIZERS_H_ + +class TIntermNode; + +void DeferGlobalInitializers(TIntermNode *root); + +#endif // COMPILER_TRANSLATOR_DEFERGLOBALINITIALIZERS_H_ diff --git a/chromium/third_party/angle/src/compiler/translator/Initialize.cpp b/chromium/third_party/angle/src/compiler/translator/Initialize.cpp index 410d6df9029..ff35d20691a 100644 --- a/chromium/third_party/angle/src/compiler/translator/Initialize.cpp +++ b/chromium/third_party/angle/src/compiler/translator/Initialize.cpp @@ -233,7 +233,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3); - if (resources.OES_EGL_image_external) + if (resources.OES_EGL_image_external || resources.NV_EGL_stream_consumer_external) { const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); @@ -594,6 +594,8 @@ void InitExtensionBehavior(const ShBuiltInResources& resources, extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; if (resources.OES_EGL_image_external) extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; + if (resources.NV_EGL_stream_consumer_external) + extBehavior["GL_NV_EGL_stream_consumer_external"] = EBhUndefined; if (resources.ARB_texture_rectangle) extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined; if (resources.EXT_blend_func_extended) diff --git a/chromium/third_party/angle/src/compiler/translator/IntermNode.cpp b/chromium/third_party/angle/src/compiler/translator/IntermNode.cpp index 2a928600889..fad6214ff13 100644 --- a/chromium/third_party/angle/src/compiler/translator/IntermNode.cpp +++ b/chromium/third_party/angle/src/compiler/translator/IntermNode.cpp @@ -351,6 +351,21 @@ TIntermTyped::TIntermTyped(const TIntermTyped &node) : TIntermNode(), mType(node mLine = node.mLine; } +bool TIntermTyped::isConstructorWithOnlyConstantUnionParameters() +{ + TIntermAggregate *constructor = getAsAggregate(); + if (!constructor || !constructor->isConstructor()) + { + return false; + } + for (TIntermNode *&node : *constructor->getSequence()) + { + if (!node->getAsConstantUnion()) + return false; + } + return true; +} + TIntermConstantUnion::TIntermConstantUnion(const TIntermConstantUnion &node) : TIntermTyped(node) { mUnionArrayPointer = node.mUnionArrayPointer; diff --git a/chromium/third_party/angle/src/compiler/translator/IntermNode.h b/chromium/third_party/angle/src/compiler/translator/IntermNode.h index 32ac97ffa7b..58c8c74379e 100644 --- a/chromium/third_party/angle/src/compiler/translator/IntermNode.h +++ b/chromium/third_party/angle/src/compiler/translator/IntermNode.h @@ -155,6 +155,8 @@ class TIntermTyped : public TIntermNode int getArraySize() const { return mType.getArraySize(); } + bool isConstructorWithOnlyConstantUnionParameters(); + protected: TType mType; @@ -486,12 +488,15 @@ class TIntermAggregate : public TIntermOperator TIntermAggregate() : TIntermOperator(EOpNull), mUserDefined(false), + mFunctionId(0), mUseEmulatedFunction(false), mGotPrecisionFromChildren(false) { } TIntermAggregate(TOperator op) : TIntermOperator(op), + mUserDefined(false), + mFunctionId(0), mUseEmulatedFunction(false), mGotPrecisionFromChildren(false) { @@ -673,6 +678,7 @@ class TIntermTraverser : angle::NonCopyable postVisit(postVisit), mDepth(0), mMaxDepth(0), + mInGlobalScope(true), mTemporaryIndex(nullptr) { } @@ -767,6 +773,8 @@ class TIntermTraverser : angle::NonCopyable // All the nodes from root to the current node's parent during traversing. TVector<TIntermNode *> mPath; + bool mInGlobalScope; + // To replace a single node with another on the parent node struct NodeUpdateEntry { diff --git a/chromium/third_party/angle/src/compiler/translator/IntermTraverse.cpp b/chromium/third_party/angle/src/compiler/translator/IntermTraverse.cpp index 7b588ca5a31..b785c40f14a 100644 --- a/chromium/third_party/angle/src/compiler/translator/IntermTraverse.cpp +++ b/chromium/third_party/angle/src/compiler/translator/IntermTraverse.cpp @@ -390,6 +390,8 @@ void TIntermTraverser::traverseAggregate(TIntermAggregate *node) if (node->getOp() == EOpSequence) pushParentBlock(node); + else if (node->getOp() == EOpFunction) + mInGlobalScope = false; for (auto *child : *sequence) { @@ -406,6 +408,8 @@ void TIntermTraverser::traverseAggregate(TIntermAggregate *node) if (node->getOp() == EOpSequence) popParentBlock(); + else if (node->getOp() == EOpFunction) + mInGlobalScope = true; decrementDepth(); } @@ -481,6 +485,8 @@ void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node) { if (node->getOp() == EOpSequence) pushParentBlock(node); + else if (node->getOp() == EOpFunction) + mInGlobalScope = false; // Find the built-in function corresponding to this op so that we can determine the // in/out qualifiers of its parameters. @@ -533,6 +539,8 @@ void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node) if (node->getOp() == EOpSequence) popParentBlock(); + else if (node->getOp() == EOpFunction) + mInGlobalScope = true; } decrementDepth(); diff --git a/chromium/third_party/angle/src/compiler/translator/OutputHLSL.cpp b/chromium/third_party/angle/src/compiler/translator/OutputHLSL.cpp index 231b0f7c93a..3badefd5a51 100644 --- a/chromium/third_party/angle/src/compiler/translator/OutputHLSL.cpp +++ b/chromium/third_party/angle/src/compiler/translator/OutputHLSL.cpp @@ -21,6 +21,7 @@ #include "compiler/translator/RemoveSwitchFallThrough.h" #include "compiler/translator/SearchSymbol.h" #include "compiler/translator/StructureHLSL.h" +#include "compiler/translator/TextureFunctionHLSL.h" #include "compiler/translator/TranslatorHLSL.h" #include "compiler/translator/UniformHLSL.h" #include "compiler/translator/UtilsHLSL.h" @@ -79,60 +80,6 @@ const TConstantUnion *WriteConstantUnionArray(TInfoSinkBase &out, namespace sh { -TString OutputHLSL::TextureFunction::name() const -{ - TString name = "gl_texture"; - - // We need to include full the sampler type in the function name to make the signature unique - // on D3D11, where samplers are passed to texture functions as indices. - name += TextureTypeSuffix(this->sampler); - - if (proj) - { - name += "Proj"; - } - - if (offset) - { - name += "Offset"; - } - - switch(method) - { - case IMPLICIT: break; - case BIAS: break; // Extra parameter makes the signature unique - case LOD: name += "Lod"; break; - case LOD0: name += "Lod0"; break; - case LOD0BIAS: name += "Lod0"; break; // Extra parameter makes the signature unique - case SIZE: name += "Size"; break; - case FETCH: name += "Fetch"; break; - case GRAD: name += "Grad"; break; - default: UNREACHABLE(); - } - - return name + "("; -} - -bool OutputHLSL::TextureFunction::operator<(const TextureFunction &rhs) const -{ - if (sampler < rhs.sampler) return true; - if (sampler > rhs.sampler) return false; - - if (coords < rhs.coords) return true; - if (coords > rhs.coords) return false; - - if (!proj && rhs.proj) return true; - if (proj && !rhs.proj) return false; - - if (!offset && rhs.offset) return true; - if (offset && !rhs.offset) return false; - - if (method < rhs.method) return true; - if (method > rhs.method) return false; - - return false; -} - OutputHLSL::OutputHLSL(sh::GLenum shaderType, int shaderVersion, const TExtensionBehavior &extensionBehavior, const char *sourcePath, ShShaderOutput outputType, @@ -175,6 +122,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType, int shaderVersion, mStructureHLSL = new StructureHLSL; mUniformHLSL = new UniformHLSL(mStructureHLSL, outputType, uniforms); + mTextureFunctionHLSL = new TextureFunctionHLSL; if (mOutputType == SH_HLSL_3_0_OUTPUT) { @@ -192,6 +140,7 @@ OutputHLSL::~OutputHLSL() { SafeDelete(mStructureHLSL); SafeDelete(mUniformHLSL); + SafeDelete(mTextureFunctionHLSL); for (auto &eqFunction : mStructEqualityFunctions) { SafeDelete(eqFunction); @@ -223,10 +172,6 @@ void OutputHLSL::output(TIntermNode *treeRoot, TInfoSinkBase &objSink) mInfoSinkStack.pop(); mInfoSinkStack.push(&mFooter); - if (!mDeferredGlobalInitializers.empty()) - { - writeDeferredGlobalInitializers(mFooter); - } mInfoSinkStack.pop(); mInfoSinkStack.push(&mHeader); @@ -660,729 +605,7 @@ void OutputHLSL::header(TInfoSinkBase &out, const BuiltInFunctionEmulator *built } } - for (TextureFunctionSet::const_iterator textureFunction = mUsesTexture.begin(); textureFunction != mUsesTexture.end(); textureFunction++) - { - // Return type - if (textureFunction->method == TextureFunction::SIZE) - { - switch(textureFunction->sampler) - { - case EbtSampler2D: out << "int2 "; break; - case EbtSampler3D: out << "int3 "; break; - case EbtSamplerCube: out << "int2 "; break; - case EbtSampler2DArray: out << "int3 "; break; - case EbtISampler2D: out << "int2 "; break; - case EbtISampler3D: out << "int3 "; break; - case EbtISamplerCube: out << "int2 "; break; - case EbtISampler2DArray: out << "int3 "; break; - case EbtUSampler2D: out << "int2 "; break; - case EbtUSampler3D: out << "int3 "; break; - case EbtUSamplerCube: out << "int2 "; break; - case EbtUSampler2DArray: out << "int3 "; break; - case EbtSampler2DShadow: out << "int2 "; break; - case EbtSamplerCubeShadow: out << "int2 "; break; - case EbtSampler2DArrayShadow: out << "int3 "; break; - default: UNREACHABLE(); - } - } - else // Sampling function - { - switch(textureFunction->sampler) - { - case EbtSampler2D: out << "float4 "; break; - case EbtSampler3D: out << "float4 "; break; - case EbtSamplerCube: out << "float4 "; break; - case EbtSampler2DArray: out << "float4 "; break; - case EbtISampler2D: out << "int4 "; break; - case EbtISampler3D: out << "int4 "; break; - case EbtISamplerCube: out << "int4 "; break; - case EbtISampler2DArray: out << "int4 "; break; - case EbtUSampler2D: out << "uint4 "; break; - case EbtUSampler3D: out << "uint4 "; break; - case EbtUSamplerCube: out << "uint4 "; break; - case EbtUSampler2DArray: out << "uint4 "; break; - case EbtSampler2DShadow: out << "float "; break; - case EbtSamplerCubeShadow: out << "float "; break; - case EbtSampler2DArrayShadow: out << "float "; break; - default: UNREACHABLE(); - } - } - - // Function name - out << textureFunction->name(); - - // Argument list - int hlslCoords = 4; - - if (mOutputType == SH_HLSL_3_0_OUTPUT) - { - switch(textureFunction->sampler) - { - case EbtSampler2D: out << "sampler2D s"; hlslCoords = 2; break; - case EbtSamplerCube: out << "samplerCUBE s"; hlslCoords = 3; break; - default: UNREACHABLE(); - } - - switch(textureFunction->method) - { - case TextureFunction::IMPLICIT: break; - case TextureFunction::BIAS: hlslCoords = 4; break; - case TextureFunction::LOD: hlslCoords = 4; break; - case TextureFunction::LOD0: hlslCoords = 4; break; - case TextureFunction::LOD0BIAS: hlslCoords = 4; break; - default: UNREACHABLE(); - } - } - else - { - hlslCoords = HLSLTextureCoordsCount(textureFunction->sampler); - if (mOutputType == SH_HLSL_4_0_FL9_3_OUTPUT) - { - out << TextureString(textureFunction->sampler) << " x, " - << SamplerString(textureFunction->sampler) << " s"; - } - else - { - ASSERT(mOutputType == SH_HLSL_4_1_OUTPUT); - out << "const uint samplerIndex"; - } - } - - if (textureFunction->method == TextureFunction::FETCH) // Integer coordinates - { - switch(textureFunction->coords) - { - case 2: out << ", int2 t"; break; - case 3: out << ", int3 t"; break; - default: UNREACHABLE(); - } - } - else // Floating-point coordinates (except textureSize) - { - switch(textureFunction->coords) - { - case 1: out << ", int lod"; break; // textureSize() - case 2: out << ", float2 t"; break; - case 3: out << ", float3 t"; break; - case 4: out << ", float4 t"; break; - default: UNREACHABLE(); - } - } - - if (textureFunction->method == TextureFunction::GRAD) - { - switch(textureFunction->sampler) - { - case EbtSampler2D: - case EbtISampler2D: - case EbtUSampler2D: - case EbtSampler2DArray: - case EbtISampler2DArray: - case EbtUSampler2DArray: - case EbtSampler2DShadow: - case EbtSampler2DArrayShadow: - out << ", float2 ddx, float2 ddy"; - break; - case EbtSampler3D: - case EbtISampler3D: - case EbtUSampler3D: - case EbtSamplerCube: - case EbtISamplerCube: - case EbtUSamplerCube: - case EbtSamplerCubeShadow: - out << ", float3 ddx, float3 ddy"; - break; - default: UNREACHABLE(); - } - } - - switch(textureFunction->method) - { - case TextureFunction::IMPLICIT: break; - case TextureFunction::BIAS: break; // Comes after the offset parameter - case TextureFunction::LOD: out << ", float lod"; break; - case TextureFunction::LOD0: break; - case TextureFunction::LOD0BIAS: break; // Comes after the offset parameter - case TextureFunction::SIZE: break; - case TextureFunction::FETCH: out << ", int mip"; break; - case TextureFunction::GRAD: break; - default: UNREACHABLE(); - } - - if (textureFunction->offset) - { - switch(textureFunction->sampler) - { - case EbtSampler2D: out << ", int2 offset"; break; - case EbtSampler3D: out << ", int3 offset"; break; - case EbtSampler2DArray: out << ", int2 offset"; break; - case EbtISampler2D: out << ", int2 offset"; break; - case EbtISampler3D: out << ", int3 offset"; break; - case EbtISampler2DArray: out << ", int2 offset"; break; - case EbtUSampler2D: out << ", int2 offset"; break; - case EbtUSampler3D: out << ", int3 offset"; break; - case EbtUSampler2DArray: out << ", int2 offset"; break; - case EbtSampler2DShadow: out << ", int2 offset"; break; - case EbtSampler2DArrayShadow: out << ", int2 offset"; break; - default: UNREACHABLE(); - } - } - - if (textureFunction->method == TextureFunction::BIAS || - textureFunction->method == TextureFunction::LOD0BIAS) - { - out << ", float bias"; - } - - out << ")\n" - "{\n"; - - // In some cases we use a variable to store the texture/sampler objects, but to work around - // a D3D11 compiler bug related to discard inside a loop that is conditional on texture - // sampling we need to call the function directly on a reference to the array. The bug was - // found using dEQP-GLES3.functional.shaders.discard*loop_texture* tests. - TString textureReference("x"); - TString samplerReference("s"); - if (mOutputType == SH_HLSL_4_1_OUTPUT) - { - TString suffix = TextureGroupSuffix(textureFunction->sampler); - if (TextureGroup(textureFunction->sampler) == HLSL_TEXTURE_2D) - { - textureReference = TString("textures") + suffix + "[samplerIndex]"; - samplerReference = TString("samplers") + suffix + "[samplerIndex]"; - } - else - { - out << " const uint textureIndex = samplerIndex - textureIndexOffset" << suffix - << ";\n"; - textureReference = TString("textures") + suffix + "[textureIndex]"; - out << " const uint samplerArrayIndex = samplerIndex - samplerIndexOffset" - << suffix << ";\n"; - samplerReference = TString("samplers") + suffix + "[samplerArrayIndex]"; - } - } - - if (textureFunction->method == TextureFunction::SIZE) - { - out << "int baseLevel = samplerMetadata[samplerIndex].x;\n"; - if (IsSampler2D(textureFunction->sampler) || IsSamplerCube(textureFunction->sampler)) - { - if (IsSamplerArray(textureFunction->sampler) || - (IsIntegerSampler(textureFunction->sampler) && - IsSamplerCube(textureFunction->sampler))) - { - out << " uint width; uint height; uint layers; uint numberOfLevels;\n" - << " " << textureReference << ".GetDimensions(baseLevel + lod, width, " - "height, layers, numberOfLevels);\n"; - } - else - { - out << " uint width; uint height; uint numberOfLevels;\n" - << " " << textureReference - << ".GetDimensions(baseLevel + lod, width, height, numberOfLevels);\n"; - } - } - else if (IsSampler3D(textureFunction->sampler)) - { - out << " uint width; uint height; uint depth; uint numberOfLevels;\n" - << " " << textureReference - << ".GetDimensions(baseLevel + lod, width, height, depth, numberOfLevels);\n"; - } - else UNREACHABLE(); - - switch(textureFunction->sampler) - { - case EbtSampler2D: out << " return int2(width, height);"; break; - case EbtSampler3D: out << " return int3(width, height, depth);"; break; - case EbtSamplerCube: out << " return int2(width, height);"; break; - case EbtSampler2DArray: out << " return int3(width, height, layers);"; break; - case EbtISampler2D: out << " return int2(width, height);"; break; - case EbtISampler3D: out << " return int3(width, height, depth);"; break; - case EbtISamplerCube: out << " return int2(width, height);"; break; - case EbtISampler2DArray: out << " return int3(width, height, layers);"; break; - case EbtUSampler2D: out << " return int2(width, height);"; break; - case EbtUSampler3D: out << " return int3(width, height, depth);"; break; - case EbtUSamplerCube: out << " return int2(width, height);"; break; - case EbtUSampler2DArray: out << " return int3(width, height, layers);"; break; - case EbtSampler2DShadow: out << " return int2(width, height);"; break; - case EbtSamplerCubeShadow: out << " return int2(width, height);"; break; - case EbtSampler2DArrayShadow: out << " return int3(width, height, layers);"; break; - default: UNREACHABLE(); - } - } - else - { - TString texCoordX("t.x"); - TString texCoordY("t.y"); - TString texCoordZ("t.z"); - TString proj = ""; - - if (textureFunction->proj) - { - switch (textureFunction->coords) - { - case 3: - proj = " / t.z"; - break; - case 4: - proj = " / t.w"; - break; - default: - UNREACHABLE(); - } - if (proj != "") - { - texCoordX = "(" + texCoordX + proj + ")"; - texCoordY = "(" + texCoordY + proj + ")"; - texCoordZ = "(" + texCoordZ + proj + ")"; - } - } - - if (IsIntegerSampler(textureFunction->sampler) && IsSamplerCube(textureFunction->sampler)) - { - out << " float width; float height; float layers; float levels;\n"; - - out << " uint mip = 0;\n"; - - out << " " << textureReference - << ".GetDimensions(mip, width, height, layers, levels);\n"; - - out << " bool xMajor = abs(t.x) > abs(t.y) && abs(t.x) > abs(t.z);\n"; - out << " bool yMajor = abs(t.y) > abs(t.z) && abs(t.y) > abs(t.x);\n"; - out << " bool zMajor = abs(t.z) > abs(t.x) && abs(t.z) > abs(t.y);\n"; - out << " bool negative = (xMajor && t.x < 0.0f) || (yMajor && t.y < 0.0f) || (zMajor && t.z < 0.0f);\n"; - - // FACE_POSITIVE_X = 000b - // FACE_NEGATIVE_X = 001b - // FACE_POSITIVE_Y = 010b - // FACE_NEGATIVE_Y = 011b - // FACE_POSITIVE_Z = 100b - // FACE_NEGATIVE_Z = 101b - out << " int face = (int)negative + (int)yMajor * 2 + (int)zMajor * 4;\n"; - - out << " float u = xMajor ? -t.z : (yMajor && t.y < 0.0f ? -t.x : t.x);\n"; - out << " float v = yMajor ? t.z : (negative ? t.y : -t.y);\n"; - out << " float m = xMajor ? t.x : (yMajor ? t.y : t.z);\n"; - - out << " t.x = (u * 0.5f / m) + 0.5f;\n"; - out << " t.y = (v * 0.5f / m) + 0.5f;\n"; - - // Mip level computation. - if (textureFunction->method == TextureFunction::IMPLICIT) - { - out << " float2 tSized = float2(t.x * width, t.y * height);\n" - " float2 dx = ddx(tSized);\n" - " float2 dy = ddy(tSized);\n" - " float lod = 0.5f * log2(max(dot(dx, dx), dot(dy, dy)));\n" - " mip = uint(min(max(round(lod), 0), levels - 1));\n" - << " " << textureReference - << ".GetDimensions(mip, width, height, layers, levels);\n"; - } - - // Convert from normalized floating-point to integer - texCoordX = "int(floor(width * frac(" + texCoordX + ")))"; - texCoordY = "int(floor(height * frac(" + texCoordY + ")))"; - texCoordZ = "face"; - } - else if (IsIntegerSampler(textureFunction->sampler) && - textureFunction->method != TextureFunction::FETCH) - { - if (IsSampler2D(textureFunction->sampler)) - { - if (IsSamplerArray(textureFunction->sampler)) - { - out << " float width; float height; float layers; float levels;\n"; - - if (textureFunction->method == TextureFunction::LOD0) - { - out << " uint mip = 0;\n"; - } - else if (textureFunction->method == TextureFunction::LOD0BIAS) - { - out << " uint mip = bias;\n"; - } - else - { - - out << " " << textureReference - << ".GetDimensions(0, width, height, layers, levels);\n"; - if (textureFunction->method == TextureFunction::IMPLICIT || - textureFunction->method == TextureFunction::BIAS) - { - out << " float2 tSized = float2(t.x * width, t.y * height);\n" - " float dx = length(ddx(tSized));\n" - " float dy = length(ddy(tSized));\n" - " float lod = log2(max(dx, dy));\n"; - - if (textureFunction->method == TextureFunction::BIAS) - { - out << " lod += bias;\n"; - } - } - else if (textureFunction->method == TextureFunction::GRAD) - { - out << " float lod = log2(max(length(ddx), length(ddy)));\n"; - } - - out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; - } - - out << " " << textureReference - << ".GetDimensions(mip, width, height, layers, levels);\n"; - } - else - { - out << " float width; float height; float levels;\n"; - - if (textureFunction->method == TextureFunction::LOD0) - { - out << " uint mip = 0;\n"; - } - else if (textureFunction->method == TextureFunction::LOD0BIAS) - { - out << " uint mip = bias;\n"; - } - else - { - out << " " << textureReference - << ".GetDimensions(0, width, height, levels);\n"; - - if (textureFunction->method == TextureFunction::IMPLICIT || - textureFunction->method == TextureFunction::BIAS) - { - out << " float2 tSized = float2(t.x * width, t.y * height);\n" - " float dx = length(ddx(tSized));\n" - " float dy = length(ddy(tSized));\n" - " float lod = log2(max(dx, dy));\n"; - - if (textureFunction->method == TextureFunction::BIAS) - { - out << " lod += bias;\n"; - } - } - else if (textureFunction->method == TextureFunction::GRAD) - { - out << " float lod = log2(max(length(ddx), length(ddy)));\n"; - } - - out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; - } - - out << " " << textureReference - << ".GetDimensions(mip, width, height, levels);\n"; - } - } - else if (IsSampler3D(textureFunction->sampler)) - { - out << " float width; float height; float depth; float levels;\n"; - - if (textureFunction->method == TextureFunction::LOD0) - { - out << " uint mip = 0;\n"; - } - else if (textureFunction->method == TextureFunction::LOD0BIAS) - { - out << " uint mip = bias;\n"; - } - else - { - out << " " << textureReference - << ".GetDimensions(0, width, height, depth, levels);\n"; - - if (textureFunction->method == TextureFunction::IMPLICIT || - textureFunction->method == TextureFunction::BIAS) - { - out << " float3 tSized = float3(t.x * width, t.y * height, t.z * " - "depth);\n" - " float dx = length(ddx(tSized));\n" - " float dy = length(ddy(tSized));\n" - " float lod = log2(max(dx, dy));\n"; - - if (textureFunction->method == TextureFunction::BIAS) - { - out << " lod += bias;\n"; - } - } - else if (textureFunction->method == TextureFunction::GRAD) - { - out << " float lod = log2(max(length(ddx), length(ddy)));\n"; - } - - out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; - } - - out << " " << textureReference - << ".GetDimensions(mip, width, height, depth, levels);\n"; - } - else UNREACHABLE(); - - // Convert from normalized floating-point to integer - texCoordX = "int(floor(width * frac(" + texCoordX + ")))"; - texCoordY = "int(floor(height * frac(" + texCoordY + ")))"; - - if (IsSamplerArray(textureFunction->sampler)) - { - texCoordZ = "int(max(0, min(layers - 1, floor(0.5 + t.z))))"; - } - else if (!IsSamplerCube(textureFunction->sampler) && - !IsSampler2D(textureFunction->sampler)) - { - texCoordZ = "int(floor(depth * frac(" + texCoordZ + ")))"; - } - } - - out << " return "; - - // HLSL intrinsic - if (mOutputType == SH_HLSL_3_0_OUTPUT) - { - switch(textureFunction->sampler) - { - case EbtSampler2D: out << "tex2D"; break; - case EbtSamplerCube: out << "texCUBE"; break; - default: UNREACHABLE(); - } - - switch(textureFunction->method) - { - case TextureFunction::IMPLICIT: - out << "(" << samplerReference << ", "; - break; - case TextureFunction::BIAS: - out << "bias(" << samplerReference << ", "; - break; - case TextureFunction::LOD: - out << "lod(" << samplerReference << ", "; - break; - case TextureFunction::LOD0: - out << "lod(" << samplerReference << ", "; - break; - case TextureFunction::LOD0BIAS: - out << "lod(" << samplerReference << ", "; - break; - default: UNREACHABLE(); - } - } - else if (mOutputType == SH_HLSL_4_1_OUTPUT || mOutputType == SH_HLSL_4_0_FL9_3_OUTPUT) - { - if (textureFunction->method == TextureFunction::GRAD) - { - if (IsIntegerSampler(textureFunction->sampler)) - { - out << "" << textureReference << ".Load("; - } - else if (IsShadowSampler(textureFunction->sampler)) - { - out << "" << textureReference << ".SampleCmpLevelZero(" << samplerReference - << ", "; - } - else - { - out << "" << textureReference << ".SampleGrad(" << samplerReference << ", "; - } - } - else if (IsIntegerSampler(textureFunction->sampler) || - textureFunction->method == TextureFunction::FETCH) - { - out << "" << textureReference << ".Load("; - } - else if (IsShadowSampler(textureFunction->sampler)) - { - switch(textureFunction->method) - { - case TextureFunction::IMPLICIT: - out << "" << textureReference << ".SampleCmp(" << samplerReference - << ", "; - break; - case TextureFunction::BIAS: - out << "" << textureReference << ".SampleCmp(" << samplerReference - << ", "; - break; - case TextureFunction::LOD: - out << "" << textureReference << ".SampleCmp(" << samplerReference - << ", "; - break; - case TextureFunction::LOD0: - out << "" << textureReference << ".SampleCmpLevelZero(" - << samplerReference << ", "; - break; - case TextureFunction::LOD0BIAS: - out << "" << textureReference << ".SampleCmpLevelZero(" - << samplerReference << ", "; - break; - default: UNREACHABLE(); - } - } - else - { - switch(textureFunction->method) - { - case TextureFunction::IMPLICIT: - out << "" << textureReference << ".Sample(" << samplerReference << ", "; - break; - case TextureFunction::BIAS: - out << "" << textureReference << ".SampleBias(" << samplerReference - << ", "; - break; - case TextureFunction::LOD: - out << "" << textureReference << ".SampleLevel(" << samplerReference - << ", "; - break; - case TextureFunction::LOD0: - out << "" << textureReference << ".SampleLevel(" << samplerReference - << ", "; - break; - case TextureFunction::LOD0BIAS: - out << "" << textureReference << ".SampleLevel(" << samplerReference - << ", "; - break; - default: UNREACHABLE(); - } - } - } - else UNREACHABLE(); - - if (IsIntegerSampler(textureFunction->sampler) || - textureFunction->method == TextureFunction::FETCH) - { - switch(hlslCoords) - { - case 2: out << "int3("; break; - case 3: out << "int4("; break; - default: UNREACHABLE(); - } - } - else - { - switch(hlslCoords) - { - case 2: out << "float2("; break; - case 3: out << "float3("; break; - case 4: out << "float4("; break; - default: UNREACHABLE(); - } - } - - out << texCoordX << ", " << texCoordY; - - if (mOutputType == SH_HLSL_3_0_OUTPUT) - { - if (hlslCoords >= 3) - { - if (textureFunction->coords < 3) - { - out << ", 0"; - } - else - { - out << ", t.z" << proj; - } - } - - if (hlslCoords == 4) - { - switch(textureFunction->method) - { - case TextureFunction::BIAS: out << ", bias"; break; - case TextureFunction::LOD: out << ", lod"; break; - case TextureFunction::LOD0: out << ", 0"; break; - case TextureFunction::LOD0BIAS: out << ", bias"; break; - default: UNREACHABLE(); - } - } - - out << "));\n"; - } - else if (mOutputType == SH_HLSL_4_1_OUTPUT || mOutputType == SH_HLSL_4_0_FL9_3_OUTPUT) - { - if (hlslCoords >= 3) - { - ASSERT(!IsIntegerSampler(textureFunction->sampler) || - !IsSamplerCube(textureFunction->sampler) || texCoordZ == "face"); - out << ", " << texCoordZ; - } - - if (textureFunction->method == TextureFunction::GRAD) - { - if (IsIntegerSampler(textureFunction->sampler)) - { - out << ", mip)"; - } - else if (IsShadowSampler(textureFunction->sampler)) - { - // Compare value - if (textureFunction->proj) - { - // According to ESSL 3.00.4 sec 8.8 p95 on textureProj: - // The resulting third component of P' in the shadow forms is used as Dref - out << "), t.z" << proj; - } - else - { - switch(textureFunction->coords) - { - case 3: out << "), t.z"; break; - case 4: out << "), t.w"; break; - default: UNREACHABLE(); - } - } - } - else - { - out << "), ddx, ddy"; - } - } - else if (IsIntegerSampler(textureFunction->sampler) || - textureFunction->method == TextureFunction::FETCH) - { - out << ", mip)"; - } - else if (IsShadowSampler(textureFunction->sampler)) - { - // Compare value - if (textureFunction->proj) - { - // According to ESSL 3.00.4 sec 8.8 p95 on textureProj: - // The resulting third component of P' in the shadow forms is used as Dref - out << "), t.z" << proj; - } - else - { - switch(textureFunction->coords) - { - case 3: out << "), t.z"; break; - case 4: out << "), t.w"; break; - default: UNREACHABLE(); - } - } - } - else - { - switch(textureFunction->method) - { - case TextureFunction::IMPLICIT: out << ")"; break; - case TextureFunction::BIAS: out << "), bias"; break; - case TextureFunction::LOD: out << "), lod"; break; - case TextureFunction::LOD0: out << "), 0"; break; - case TextureFunction::LOD0BIAS: out << "), bias"; break; - default: UNREACHABLE(); - } - } - - if (textureFunction->offset) - { - out << ", offset"; - } - - out << ");"; - } - else UNREACHABLE(); - } - - out << "\n" - "}\n" - "\n"; - } + mTextureFunctionHLSL->textureFunctionHeader(out, mOutputType); if (mUsesFragCoord) { @@ -1659,29 +882,18 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) case EOpInitialize: if (visit == PreVisit) { - // GLSL allows to write things like "float x = x;" where a new variable x is defined - // and the value of an existing variable x is assigned. HLSL uses C semantics (the - // new variable is created before the assignment is evaluated), so we need to convert - // this to "float t = x, x = t;". - TIntermSymbol *symbolNode = node->getLeft()->getAsSymbolNode(); ASSERT(symbolNode); TIntermTyped *expression = node->getRight(); - // TODO (jmadill): do a 'deep' scan to know if an expression is statically const - if (symbolNode->getQualifier() == EvqGlobal && expression->getQualifier() != EvqConst) - { - // For variables which are not constant, defer their real initialization until - // after we initialize uniforms. - TIntermBinary *deferredInit = new TIntermBinary(EOpAssign); - deferredInit->setLeft(node->getLeft()); - deferredInit->setRight(node->getRight()); - deferredInit->setType(node->getType()); - mDeferredGlobalInitializers.push_back(deferredInit); - const TString &initString = initializer(node->getType()); - node->setRight(new TIntermRaw(node->getType(), initString)); - } - else if (writeSameSymbolInitializer(out, symbolNode, expression)) + // Global initializers must be constant at this point. + ASSERT(symbolNode->getQualifier() != EvqGlobal || canWriteAsHLSLLiteral(expression)); + + // GLSL allows to write things like "float x = x;" where a new variable x is defined + // and the value of an existing variable x is assigned. HLSL uses C semantics (the + // new variable is created before the assignment is evaluated), so we need to convert + // this to "float t = x, x = t;". + if (writeSameSymbolInitializer(out, symbolNode, expression)) { // Skip initializing the rest of the expression return false; @@ -2469,121 +1681,10 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) { TString name = TFunction::unmangleName(node->getNameObj().getString()); TBasicType samplerType = (*arguments)[0]->getAsTyped()->getType().getBasicType(); - - TextureFunction textureFunction; - textureFunction.sampler = samplerType; - textureFunction.coords = (*arguments)[1]->getAsTyped()->getNominalSize(); - textureFunction.method = TextureFunction::IMPLICIT; - textureFunction.proj = false; - textureFunction.offset = false; - - if (name == "texture2D" || name == "textureCube" || name == "texture") - { - textureFunction.method = TextureFunction::IMPLICIT; - } - else if (name == "texture2DProj" || name == "textureProj") - { - textureFunction.method = TextureFunction::IMPLICIT; - textureFunction.proj = true; - } - else if (name == "texture2DLod" || name == "textureCubeLod" || name == "textureLod" || - name == "texture2DLodEXT" || name == "textureCubeLodEXT") - { - textureFunction.method = TextureFunction::LOD; - } - else if (name == "texture2DProjLod" || name == "textureProjLod" || name == "texture2DProjLodEXT") - { - textureFunction.method = TextureFunction::LOD; - textureFunction.proj = true; - } - else if (name == "textureSize") - { - textureFunction.method = TextureFunction::SIZE; - } - else if (name == "textureOffset") - { - textureFunction.method = TextureFunction::IMPLICIT; - textureFunction.offset = true; - } - else if (name == "textureProjOffset") - { - textureFunction.method = TextureFunction::IMPLICIT; - textureFunction.offset = true; - textureFunction.proj = true; - } - else if (name == "textureLodOffset") - { - textureFunction.method = TextureFunction::LOD; - textureFunction.offset = true; - } - else if (name == "textureProjLodOffset") - { - textureFunction.method = TextureFunction::LOD; - textureFunction.proj = true; - textureFunction.offset = true; - } - else if (name == "texelFetch") - { - textureFunction.method = TextureFunction::FETCH; - } - else if (name == "texelFetchOffset") - { - textureFunction.method = TextureFunction::FETCH; - textureFunction.offset = true; - } - else if (name == "textureGrad" || name == "texture2DGradEXT") - { - textureFunction.method = TextureFunction::GRAD; - } - else if (name == "textureGradOffset") - { - textureFunction.method = TextureFunction::GRAD; - textureFunction.offset = true; - } - else if (name == "textureProjGrad" || name == "texture2DProjGradEXT" || name == "textureCubeGradEXT") - { - textureFunction.method = TextureFunction::GRAD; - textureFunction.proj = true; - } - else if (name == "textureProjGradOffset") - { - textureFunction.method = TextureFunction::GRAD; - textureFunction.proj = true; - textureFunction.offset = true; - } - else UNREACHABLE(); - - if (textureFunction.method == TextureFunction::IMPLICIT) // Could require lod 0 or have a bias argument - { - unsigned int mandatoryArgumentCount = 2; // All functions have sampler and coordinate arguments - - if (textureFunction.offset) - { - mandatoryArgumentCount++; - } - - bool bias = (arguments->size() > mandatoryArgumentCount); // Bias argument is optional - - if (lod0 || mShaderType == GL_VERTEX_SHADER) - { - if (bias) - { - textureFunction.method = TextureFunction::LOD0BIAS; - } - else - { - textureFunction.method = TextureFunction::LOD0; - } - } - else if (bias) - { - textureFunction.method = TextureFunction::BIAS; - } - } - - mUsesTexture.insert(textureFunction); - - out << textureFunction.name(); + int coords = (*arguments)[1]->getAsTyped()->getNominalSize(); + TString textureFunctionName = mTextureFunctionHLSL->useTextureFunction( + name, samplerType, coords, arguments->size(), lod0, mShaderType); + out << textureFunctionName << "("; } for (TIntermSequence::iterator arg = arguments->begin(); arg != arguments->end(); arg++) @@ -2878,13 +1979,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) TInfoSinkBase &out = getInfoSink(); ASSERT(!node->usesTernaryOperator()); - - if (!mInsideFunction) - { - // This is part of unfolded global initialization. - mDeferredGlobalInitializers.push_back(node); - return false; - } + ASSERT(mInsideFunction); // D3D errors when there is a gradient operation in a loop in an unflattened if. if (mShaderType == GL_FRAGMENT_SHADER && mCurrentFunctionMetadata->hasGradientLoop(node)) @@ -3557,22 +2652,8 @@ bool OutputHLSL::canWriteAsHLSLLiteral(TIntermTyped *expression) { // We support writing constant unions and constructors that only take constant unions as // parameters as HLSL literals. - if (expression->getAsConstantUnion()) - { - return true; - } - if (expression->getQualifier() != EvqConst || !expression->getAsAggregate() || - !expression->getAsAggregate()->isConstructor()) - { - return false; - } - TIntermAggregate *constructor = expression->getAsAggregate(); - for (TIntermNode *&node : *constructor->getSequence()) - { - if (!node->getAsConstantUnion()) - return false; - } - return true; + return expression->getAsConstantUnion() || + expression->isConstructorWithOnlyConstantUnionParameters(); } bool OutputHLSL::writeConstantInitialization(TInfoSinkBase &out, @@ -3615,47 +2696,6 @@ bool OutputHLSL::writeConstantInitialization(TInfoSinkBase &out, return false; } -void OutputHLSL::writeDeferredGlobalInitializers(TInfoSinkBase &out) -{ - out << "#define ANGLE_USES_DEFERRED_INIT\n" - << "\n" - << "void initializeDeferredGlobals()\n" - << "{\n"; - - for (const auto &deferredGlobal : mDeferredGlobalInitializers) - { - TIntermBinary *binary = deferredGlobal->getAsBinaryNode(); - TIntermSelection *selection = deferredGlobal->getAsSelectionNode(); - if (binary != nullptr) - { - TIntermSymbol *symbol = binary->getLeft()->getAsSymbolNode(); - TIntermTyped *expression = binary->getRight(); - ASSERT(symbol); - ASSERT(symbol->getQualifier() == EvqGlobal && expression->getQualifier() != EvqConst); - - out << " " << Decorate(symbol->getSymbol()) << " = "; - - if (!writeSameSymbolInitializer(out, symbol, expression)) - { - ASSERT(mInfoSinkStack.top() == &out); - expression->traverse(this); - } - out << ";\n"; - } - else if (selection != nullptr) - { - writeSelection(out, selection); - } - else - { - UNREACHABLE(); - } - } - - out << "}\n" - << "\n"; -} - TString OutputHLSL::addStructEqualityFunction(const TStructure &structure) { const TFieldList &fields = structure.fields(); diff --git a/chromium/third_party/angle/src/compiler/translator/OutputHLSL.h b/chromium/third_party/angle/src/compiler/translator/OutputHLSL.h index efdf7b2b0b7..e5204e419d9 100644 --- a/chromium/third_party/angle/src/compiler/translator/OutputHLSL.h +++ b/chromium/third_party/angle/src/compiler/translator/OutputHLSL.h @@ -8,7 +8,6 @@ #define COMPILER_TRANSLATOR_OUTPUTHLSL_H_ #include <list> -#include <set> #include <map> #include <stack> @@ -21,8 +20,9 @@ class BuiltInFunctionEmulator; namespace sh { -class UnfoldShortCircuit; class StructureHLSL; +class TextureFunctionHLSL; +class UnfoldShortCircuit; class UniformHLSL; typedef std::map<TString, TIntermSymbol*> ReferencedSymbols; @@ -139,36 +139,9 @@ class OutputHLSL : public TIntermTraverser StructureHLSL *mStructureHLSL; UniformHLSL *mUniformHLSL; - - struct TextureFunction - { - enum Method - { - IMPLICIT, // Mipmap LOD determined implicitly (standard lookup) - BIAS, - LOD, - LOD0, - LOD0BIAS, - SIZE, // textureSize() - FETCH, - GRAD - }; - - TBasicType sampler; - int coords; - bool proj; - bool offset; - Method method; - - TString name() const; - - bool operator<(const TextureFunction &rhs) const; - }; - - typedef std::set<TextureFunction> TextureFunctionSet; + TextureFunctionHLSL *mTextureFunctionHLSL; // Parameters determining what goes in the header output - TextureFunctionSet mUsesTexture; bool mUsesFragColor; bool mUsesFragData; bool mUsesDepthRange; @@ -203,11 +176,6 @@ class OutputHLSL : public TIntermTraverser std::map<TIntermTyped*, TString> mFlaggedStructMappedNames; std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames; - // Some initializers may have been unfolded into if statements, thus we can't evaluate all initializers - // at global static scope in HLSL. Instead, we can initialize these static globals inside a helper function. - // This also enables initialization of globals with uniforms. - TIntermSequence mDeferredGlobalInitializers; - struct HelperFunction { TString functionName; diff --git a/chromium/third_party/angle/src/compiler/translator/TextureFunctionHLSL.cpp b/chromium/third_party/angle/src/compiler/translator/TextureFunctionHLSL.cpp new file mode 100644 index 00000000000..b859310acb0 --- /dev/null +++ b/chromium/third_party/angle/src/compiler/translator/TextureFunctionHLSL.cpp @@ -0,0 +1,1293 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// TextureFunctionHLSL: Class for writing implementations of ESSL texture functions into HLSL +// output. Some of the implementations are straightforward and just call the HLSL equivalent of the +// ESSL texture function, others do more work to emulate ESSL texture sampling or size query +// behavior. +// + +#include "compiler/translator/TextureFunctionHLSL.h" + +#include "compiler/translator/UtilsHLSL.h" + +namespace sh +{ + +namespace +{ + +void OutputIntTexCoordWrap(TInfoSinkBase &out, + const char *wrapMode, + const char *size, + const TString &texCoord, + const TString &texCoordOffset, + const char *texCoordOutName) +{ + // GLES 3.0.4 table 3.22 specifies how the wrap modes work. We don't use the formulas verbatim + // but rather use equivalent formulas that map better to HLSL. + out << "int " << texCoordOutName << ";\n"; + out << "float " << texCoordOutName << "Offset = " << texCoord << " + float(" << texCoordOffset + << ") / " << size << ";\n"; + + // CLAMP_TO_EDGE + out << "if (" << wrapMode << " == 1)\n"; + out << "{\n"; + out << " " << texCoordOutName << " = clamp(int(floor(" << size << " * " << texCoordOutName + << "Offset)), 0, int(" << size << ") - 1);\n"; + out << "}\n"; + + // MIRRORED_REPEAT + out << "else if (" << wrapMode << " == 3)\n"; + out << "{\n"; + out << " float coordWrapped = 1.0 - abs(frac(abs(" << texCoordOutName + << "Offset) * 0.5) * 2.0 - 1.0);\n"; + out << " " << texCoordOutName << " = int(floor(" << size << " * coordWrapped));\n"; + out << "}\n"; + + // REPEAT + out << "else\n"; + out << "{\n"; + out << " " << texCoordOutName << " = int(floor(" << size << " * frac(" << texCoordOutName + << "Offset)));\n"; + out << "}\n"; +} + +void OutputIntTexCoordWraps(TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + TString *texCoordX, + TString *texCoordY, + TString *texCoordZ) +{ + // Convert from normalized floating-point to integer + out << "int wrapS = samplerMetadata[samplerIndex].wrapModes & 0x3;\n"; + if (textureFunction.offset) + { + OutputIntTexCoordWrap(out, "wrapS", "width", *texCoordX, "offset.x", "tix"); + } + else + { + OutputIntTexCoordWrap(out, "wrapS", "width", *texCoordX, "0", "tix"); + } + *texCoordX = "tix"; + out << "int wrapT = (samplerMetadata[samplerIndex].wrapModes >> 2) & 0x3;\n"; + if (textureFunction.offset) + { + OutputIntTexCoordWrap(out, "wrapT", "height", *texCoordY, "offset.y", "tiy"); + } + else + { + OutputIntTexCoordWrap(out, "wrapT", "height", *texCoordY, "0", "tiy"); + } + *texCoordY = "tiy"; + + if (IsSamplerArray(textureFunction.sampler)) + { + *texCoordZ = "int(max(0, min(layers - 1, floor(0.5 + t.z))))"; + } + else if (!IsSamplerCube(textureFunction.sampler) && !IsSampler2D(textureFunction.sampler)) + { + out << "int wrapR = (samplerMetadata[samplerIndex].wrapModes >> 4) & 0x3;\n"; + if (textureFunction.offset) + { + OutputIntTexCoordWrap(out, "wrapR", "depth", *texCoordZ, "offset.z", "tiz"); + } + else + { + OutputIntTexCoordWrap(out, "wrapR", "depth", *texCoordZ, "0", "tiz"); + } + *texCoordZ = "tiz"; + } +} + +void OutputHLSL4SampleFunctionPrefix(TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + const TString &textureReference, + const TString &samplerReference) +{ + out << textureReference; + if (IsIntegerSampler(textureFunction.sampler) || + textureFunction.method == TextureFunctionHLSL::TextureFunction::FETCH) + { + out << ".Load("; + return; + } + + if (IsShadowSampler(textureFunction.sampler)) + { + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::IMPLICIT: + case TextureFunctionHLSL::TextureFunction::BIAS: + case TextureFunctionHLSL::TextureFunction::LOD: + out << ".SampleCmp("; + break; + case TextureFunctionHLSL::TextureFunction::LOD0: + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + case TextureFunctionHLSL::TextureFunction::GRAD: + out << ".SampleCmpLevelZero("; + break; + default: + UNREACHABLE(); + } + } + else + { + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::IMPLICIT: + out << ".Sample("; + break; + case TextureFunctionHLSL::TextureFunction::BIAS: + out << ".SampleBias("; + break; + case TextureFunctionHLSL::TextureFunction::LOD: + case TextureFunctionHLSL::TextureFunction::LOD0: + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + out << ".SampleLevel("; + break; + case TextureFunctionHLSL::TextureFunction::GRAD: + out << ".SampleGrad("; + break; + default: + UNREACHABLE(); + } + } + out << samplerReference << ", "; +} + +const char *GetSamplerCoordinateTypeString( + const TextureFunctionHLSL::TextureFunction &textureFunction, + int hlslCoords) +{ + if (IsIntegerSampler(textureFunction.sampler) || + textureFunction.method == TextureFunctionHLSL::TextureFunction::FETCH) + { + switch (hlslCoords) + { + case 2: + return "int3"; + case 3: + return "int4"; + default: + UNREACHABLE(); + } + } + else + { + switch (hlslCoords) + { + case 2: + return "float2"; + case 3: + return "float3"; + case 4: + return "float4"; + default: + UNREACHABLE(); + } + } + return ""; +} + +int GetHLSLCoordCount(const TextureFunctionHLSL::TextureFunction &textureFunction, + ShShaderOutput outputType) +{ + if (outputType == SH_HLSL_3_0_OUTPUT) + { + int hlslCoords = 2; + switch (textureFunction.sampler) + { + case EbtSampler2D: + hlslCoords = 2; + break; + case EbtSamplerCube: + hlslCoords = 3; + break; + default: + UNREACHABLE(); + } + + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::IMPLICIT: + return hlslCoords; + case TextureFunctionHLSL::TextureFunction::BIAS: + case TextureFunctionHLSL::TextureFunction::LOD: + case TextureFunctionHLSL::TextureFunction::LOD0: + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + return 4; + default: + UNREACHABLE(); + } + } + else + { + switch (textureFunction.sampler) + { + case EbtSampler2D: + return 2; + case EbtSampler3D: + return 3; + case EbtSamplerCube: + return 3; + case EbtSampler2DArray: + return 3; + case EbtSamplerExternalOES: + return 2; + case EbtISampler2D: + return 2; + case EbtISampler3D: + return 3; + case EbtISamplerCube: + return 3; + case EbtISampler2DArray: + return 3; + case EbtUSampler2D: + return 2; + case EbtUSampler3D: + return 3; + case EbtUSamplerCube: + return 3; + case EbtUSampler2DArray: + return 3; + case EbtSampler2DShadow: + return 2; + case EbtSamplerCubeShadow: + return 3; + case EbtSampler2DArrayShadow: + return 3; + default: + UNREACHABLE(); + } + } + return 0; +} + +void OutputTextureFunctionArgumentList(TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + const ShShaderOutput outputType) +{ + if (outputType == SH_HLSL_3_0_OUTPUT) + { + switch (textureFunction.sampler) + { + case EbtSampler2D: + out << "sampler2D s"; + break; + case EbtSamplerCube: + out << "samplerCUBE s"; + break; + default: + UNREACHABLE(); + } + } + else + { + if (outputType == SH_HLSL_4_0_FL9_3_OUTPUT) + { + out << TextureString(textureFunction.sampler) << " x, " + << SamplerString(textureFunction.sampler) << " s"; + } + else + { + ASSERT(outputType == SH_HLSL_4_1_OUTPUT); + out << "const uint samplerIndex"; + } + } + + if (textureFunction.method == + TextureFunctionHLSL::TextureFunction::FETCH) // Integer coordinates + { + switch (textureFunction.coords) + { + case 2: + out << ", int2 t"; + break; + case 3: + out << ", int3 t"; + break; + default: + UNREACHABLE(); + } + } + else // Floating-point coordinates (except textureSize) + { + switch (textureFunction.coords) + { + case 1: + out << ", int lod"; + break; // textureSize() + case 2: + out << ", float2 t"; + break; + case 3: + out << ", float3 t"; + break; + case 4: + out << ", float4 t"; + break; + default: + UNREACHABLE(); + } + } + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + switch (textureFunction.sampler) + { + case EbtSampler2D: + case EbtISampler2D: + case EbtUSampler2D: + case EbtSampler2DArray: + case EbtISampler2DArray: + case EbtUSampler2DArray: + case EbtSampler2DShadow: + case EbtSampler2DArrayShadow: + case EbtSamplerExternalOES: + out << ", float2 ddx, float2 ddy"; + break; + case EbtSampler3D: + case EbtISampler3D: + case EbtUSampler3D: + case EbtSamplerCube: + case EbtISamplerCube: + case EbtUSamplerCube: + case EbtSamplerCubeShadow: + out << ", float3 ddx, float3 ddy"; + break; + default: + UNREACHABLE(); + } + } + + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::IMPLICIT: + break; + case TextureFunctionHLSL::TextureFunction::BIAS: + break; // Comes after the offset parameter + case TextureFunctionHLSL::TextureFunction::LOD: + out << ", float lod"; + break; + case TextureFunctionHLSL::TextureFunction::LOD0: + break; + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + break; // Comes after the offset parameter + case TextureFunctionHLSL::TextureFunction::SIZE: + break; + case TextureFunctionHLSL::TextureFunction::FETCH: + out << ", int mip"; + break; + case TextureFunctionHLSL::TextureFunction::GRAD: + break; + default: + UNREACHABLE(); + } + + if (textureFunction.offset) + { + switch (textureFunction.sampler) + { + case EbtSampler2D: + out << ", int2 offset"; + break; + case EbtSampler3D: + out << ", int3 offset"; + break; + case EbtSampler2DArray: + out << ", int2 offset"; + break; + case EbtISampler2D: + out << ", int2 offset"; + break; + case EbtISampler3D: + out << ", int3 offset"; + break; + case EbtISampler2DArray: + out << ", int2 offset"; + break; + case EbtUSampler2D: + out << ", int2 offset"; + break; + case EbtUSampler3D: + out << ", int3 offset"; + break; + case EbtUSampler2DArray: + out << ", int2 offset"; + break; + case EbtSampler2DShadow: + out << ", int2 offset"; + break; + case EbtSampler2DArrayShadow: + out << ", int2 offset"; + break; + case EbtSamplerExternalOES: + out << ", int2 offset"; + default: + UNREACHABLE(); + } + } + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS || + textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0BIAS) + { + out << ", float bias"; + } +} + +void GetTextureReference(TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + const ShShaderOutput outputType, + TString *textureReference, + TString *samplerReference) +{ + if (outputType == SH_HLSL_4_1_OUTPUT) + { + TString suffix = TextureGroupSuffix(textureFunction.sampler); + if (TextureGroup(textureFunction.sampler) == HLSL_TEXTURE_2D) + { + *textureReference = TString("textures") + suffix + "[samplerIndex]"; + *samplerReference = TString("samplers") + suffix + "[samplerIndex]"; + } + else + { + out << " const uint textureIndex = samplerIndex - textureIndexOffset" << suffix + << ";\n"; + *textureReference = TString("textures") + suffix + "[textureIndex]"; + out << " const uint samplerArrayIndex = samplerIndex - samplerIndexOffset" << suffix + << ";\n"; + *samplerReference = TString("samplers") + suffix + "[samplerArrayIndex]"; + } + } + else + { + *textureReference = "x"; + *samplerReference = "s"; + } +} + +void OutputTextureSizeFunctionBody(TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + const TString &textureReference) +{ + out << "int baseLevel = samplerMetadata[samplerIndex].baseLevel;\n"; + if (IsSampler3D(textureFunction.sampler) || IsSamplerArray(textureFunction.sampler) || + (IsIntegerSampler(textureFunction.sampler) && IsSamplerCube(textureFunction.sampler))) + { + // "depth" stores either the number of layers in an array texture or 3D depth + out << " uint width; uint height; uint depth; uint numberOfLevels;\n" + << " " << textureReference + << ".GetDimensions(baseLevel + lod, width, height, depth, numberOfLevels);\n"; + } + else if (IsSampler2D(textureFunction.sampler) || IsSamplerCube(textureFunction.sampler)) + { + out << " uint width; uint height; uint numberOfLevels;\n" + << " " << textureReference + << ".GetDimensions(baseLevel + lod, width, height, numberOfLevels);\n"; + } + else + UNREACHABLE(); + + if (strcmp(textureFunction.getReturnType(), "int3") == 0) + { + out << " return int3(width, height, depth);"; + } + else + { + out << " return int2(width, height);"; + } +} + +void ProjectTextureCoordinates(const TextureFunctionHLSL::TextureFunction &textureFunction, + TString *texCoordX, + TString *texCoordY, + TString *texCoordZ) +{ + if (textureFunction.proj) + { + TString proj(""); + switch (textureFunction.coords) + { + case 3: + proj = " / t.z"; + break; + case 4: + proj = " / t.w"; + break; + default: + UNREACHABLE(); + } + *texCoordX = "(" + *texCoordX + proj + ")"; + *texCoordY = "(" + *texCoordY + proj + ")"; + *texCoordZ = "(" + *texCoordZ + proj + ")"; + } +} + +void OutputIntegerTextureSampleFunctionComputations( + TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + const ShShaderOutput outputType, + const TString &textureReference, + TString *texCoordX, + TString *texCoordY, + TString *texCoordZ) +{ + if (!IsIntegerSampler(textureFunction.sampler)) + { + return; + } + if (IsSamplerCube(textureFunction.sampler)) + { + out << " float width; float height; float layers; float levels;\n"; + + out << " uint mip = 0;\n"; + + out << " " << textureReference + << ".GetDimensions(mip, width, height, layers, levels);\n"; + + out << " bool xMajor = abs(t.x) > abs(t.y) && abs(t.x) > abs(t.z);\n"; + out << " bool yMajor = abs(t.y) > abs(t.z) && abs(t.y) > abs(t.x);\n"; + out << " bool zMajor = abs(t.z) > abs(t.x) && abs(t.z) > abs(t.y);\n"; + out << " bool negative = (xMajor && t.x < 0.0f) || (yMajor && t.y < 0.0f) || " + "(zMajor && t.z < 0.0f);\n"; + + // FACE_POSITIVE_X = 000b + // FACE_NEGATIVE_X = 001b + // FACE_POSITIVE_Y = 010b + // FACE_NEGATIVE_Y = 011b + // FACE_POSITIVE_Z = 100b + // FACE_NEGATIVE_Z = 101b + out << " int face = (int)negative + (int)yMajor * 2 + (int)zMajor * 4;\n"; + + out << " float u = xMajor ? -t.z : (yMajor && t.y < 0.0f ? -t.x : t.x);\n"; + out << " float v = yMajor ? t.z : (negative ? t.y : -t.y);\n"; + out << " float m = xMajor ? t.x : (yMajor ? t.y : t.z);\n"; + + out << " t.x = (u * 0.5f / m) + 0.5f;\n"; + out << " t.y = (v * 0.5f / m) + 0.5f;\n"; + + // Mip level computation. + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::IMPLICIT || + textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD || + textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::IMPLICIT) + { + out << " float2 tSized = float2(t.x * width, t.y * height);\n" + " float2 dx = ddx(tSized);\n" + " float2 dy = ddy(tSized);\n" + " float lod = 0.5f * log2(max(dot(dx, dx), dot(dy, dy)));\n"; + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + // ESSL 3.00.6 spec section 8.8: "For the cube version, the partial + // derivatives of P are assumed to be in the coordinate system used before + // texture coordinates are projected onto the appropriate cube face." + // ddx[0] and ddy[0] are the derivatives of t.x passed into the function + // ddx[1] and ddy[1] are the derivatives of t.y passed into the function + // ddx[2] and ddy[2] are the derivatives of t.z passed into the function + // Determine the derivatives of u, v and m + out << " float dudx = xMajor ? ddx[2] : (yMajor && t.y < 0.0f ? -ddx[0] " + ": ddx[0]);\n" + " float dudy = xMajor ? ddy[2] : (yMajor && t.y < 0.0f ? -ddy[0] " + ": ddy[0]);\n" + " float dvdx = yMajor ? ddx[2] : (negative ? ddx[1] : -ddx[1]);\n" + " float dvdy = yMajor ? ddy[2] : (negative ? ddy[1] : -ddy[1]);\n" + " float dmdx = xMajor ? ddx[0] : (yMajor ? ddx[1] : ddx[2]);\n" + " float dmdy = xMajor ? ddy[0] : (yMajor ? ddy[1] : ddy[2]);\n"; + // Now determine the derivatives of the face coordinates, using the + // derivatives calculated above. + // d / dx (u(x) * 0.5 / m(x) + 0.5) + // = 0.5 * (m(x) * u'(x) - u(x) * m'(x)) / m(x)^2 + out << " float dfacexdx = 0.5f * (m * dudx - u * dmdx) / (m * m);\n" + " float dfaceydx = 0.5f * (m * dvdx - v * dmdx) / (m * m);\n" + " float dfacexdy = 0.5f * (m * dudy - u * dmdy) / (m * m);\n" + " float dfaceydy = 0.5f * (m * dvdy - v * dmdy) / (m * m);\n" + " float2 sizeVec = float2(width, height);\n" + " float2 faceddx = float2(dfacexdx, dfaceydx) * sizeVec;\n" + " float2 faceddy = float2(dfacexdy, dfaceydy) * sizeVec;\n"; + // Optimization: instead of: log2(max(length(faceddx), length(faceddy))) + // we compute: log2(max(length(faceddx)^2, length(faceddy)^2)) / 2 + out << " float lengthfaceddx2 = dot(faceddx, faceddx);\n" + " float lengthfaceddy2 = dot(faceddy, faceddy);\n" + " float lod = log2(max(lengthfaceddx2, lengthfaceddy2)) * 0.5f;\n"; + } + out << " mip = uint(min(max(round(lod), 0), levels - 1));\n" + << " " << textureReference + << ".GetDimensions(mip, width, height, layers, levels);\n"; + } + + // Convert from normalized floating-point to integer + *texCoordX = "int(floor(width * frac(" + *texCoordX + ")))"; + *texCoordY = "int(floor(height * frac(" + *texCoordY + ")))"; + *texCoordZ = "face"; + } + else if (textureFunction.method != TextureFunctionHLSL::TextureFunction::FETCH) + { + if (IsSampler2D(textureFunction.sampler)) + { + if (IsSamplerArray(textureFunction.sampler)) + { + out << " float width; float height; float layers; float levels;\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0) + { + out << " uint mip = 0;\n"; + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0BIAS) + { + out << " uint mip = bias;\n"; + } + else + { + + out << " " << textureReference + << ".GetDimensions(0, width, height, layers, levels);\n"; + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::IMPLICIT || + textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS) + { + out << " float2 tSized = float2(t.x * width, t.y * height);\n" + " float dx = length(ddx(tSized));\n" + " float dy = length(ddy(tSized));\n" + " float lod = log2(max(dx, dy));\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS) + { + out << " lod += bias;\n"; + } + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + out << " float2 sizeVec = float2(width, height);\n" + " float2 sizeDdx = ddx * sizeVec;\n" + " float2 sizeDdy = ddy * sizeVec;\n" + " float lod = log2(max(dot(sizeDdx, sizeDdx), " + "dot(sizeDdy, sizeDdy))) * 0.5f;\n"; + } + + out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; + } + + out << " " << textureReference + << ".GetDimensions(mip, width, height, layers, levels);\n"; + } + else + { + out << " float width; float height; float levels;\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0) + { + out << " uint mip = 0;\n"; + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0BIAS) + { + out << " uint mip = bias;\n"; + } + else + { + out << " " << textureReference + << ".GetDimensions(0, width, height, levels);\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::IMPLICIT || + textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS) + { + out << " float2 tSized = float2(t.x * width, t.y * height);\n" + " float dx = length(ddx(tSized));\n" + " float dy = length(ddy(tSized));\n" + " float lod = log2(max(dx, dy));\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS) + { + out << " lod += bias;\n"; + } + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + out << " float2 sizeVec = float2(width, height);\n" + " float2 sizeDdx = ddx * sizeVec;\n" + " float2 sizeDdy = ddy * sizeVec;\n" + " float lod = log2(max(dot(sizeDdx, sizeDdx), " + "dot(sizeDdy, sizeDdy))) * 0.5f;\n"; + } + + out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; + } + + out << " " << textureReference + << ".GetDimensions(mip, width, height, levels);\n"; + } + } + else if (IsSampler3D(textureFunction.sampler)) + { + out << " float width; float height; float depth; float levels;\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0) + { + out << " uint mip = 0;\n"; + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::LOD0BIAS) + { + out << " uint mip = bias;\n"; + } + else + { + out << " " << textureReference + << ".GetDimensions(0, width, height, depth, levels);\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::IMPLICIT || + textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS) + { + out << " float3 tSized = float3(t.x * width, t.y * height, t.z * depth);\n" + " float dx = length(ddx(tSized));\n" + " float dy = length(ddy(tSized));\n" + " float lod = log2(max(dx, dy));\n"; + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::BIAS) + { + out << " lod += bias;\n"; + } + } + else if (textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + out << " float3 sizeVec = float3(width, height, depth);\n" + " float3 sizeDdx = ddx * sizeVec;\n" + " float3 sizeDdy = ddy * sizeVec;\n" + " float lod = log2(max(dot(sizeDdx, sizeDdx), dot(sizeDdy, " + "sizeDdy))) * 0.5f;\n"; + } + + out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; + } + + out << " " << textureReference + << ".GetDimensions(mip, width, height, depth, levels);\n"; + } + else + UNREACHABLE(); + + OutputIntTexCoordWraps(out, textureFunction, texCoordX, texCoordY, texCoordZ); + } +} + +void OutputTextureSampleFunctionReturnStatement( + TInfoSinkBase &out, + const TextureFunctionHLSL::TextureFunction &textureFunction, + const ShShaderOutput outputType, + const TString &textureReference, + const TString &samplerReference, + const TString &texCoordX, + const TString &texCoordY, + const TString &texCoordZ) +{ + out << " return "; + + // HLSL intrinsic + if (outputType == SH_HLSL_3_0_OUTPUT) + { + switch (textureFunction.sampler) + { + case EbtSampler2D: + out << "tex2D"; + break; + case EbtSamplerCube: + out << "texCUBE"; + break; + default: + UNREACHABLE(); + } + + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::IMPLICIT: + out << "(" << samplerReference << ", "; + break; + case TextureFunctionHLSL::TextureFunction::BIAS: + out << "bias(" << samplerReference << ", "; + break; + case TextureFunctionHLSL::TextureFunction::LOD: + out << "lod(" << samplerReference << ", "; + break; + case TextureFunctionHLSL::TextureFunction::LOD0: + out << "lod(" << samplerReference << ", "; + break; + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + out << "lod(" << samplerReference << ", "; + break; + default: + UNREACHABLE(); + } + } + else if (outputType == SH_HLSL_4_1_OUTPUT || outputType == SH_HLSL_4_0_FL9_3_OUTPUT) + { + OutputHLSL4SampleFunctionPrefix(out, textureFunction, textureReference, samplerReference); + } + else + UNREACHABLE(); + + const int hlslCoords = GetHLSLCoordCount(textureFunction, outputType); + + out << GetSamplerCoordinateTypeString(textureFunction, hlslCoords) << "(" << texCoordX << ", " + << texCoordY; + + if (outputType == SH_HLSL_3_0_OUTPUT) + { + if (hlslCoords >= 3) + { + if (textureFunction.coords < 3) + { + out << ", 0"; + } + else + { + out << ", " << texCoordZ; + } + } + + if (hlslCoords == 4) + { + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::BIAS: + out << ", bias"; + break; + case TextureFunctionHLSL::TextureFunction::LOD: + out << ", lod"; + break; + case TextureFunctionHLSL::TextureFunction::LOD0: + out << ", 0"; + break; + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + out << ", bias"; + break; + default: + UNREACHABLE(); + } + } + + out << ")"; + } + else if (outputType == SH_HLSL_4_1_OUTPUT || outputType == SH_HLSL_4_0_FL9_3_OUTPUT) + { + if (hlslCoords >= 3) + { + ASSERT(!IsIntegerSampler(textureFunction.sampler) || + !IsSamplerCube(textureFunction.sampler) || texCoordZ == "face"); + out << ", " << texCoordZ; + } + + if (textureFunction.method == TextureFunctionHLSL::TextureFunction::GRAD) + { + if (IsIntegerSampler(textureFunction.sampler)) + { + out << ", mip)"; + } + else if (IsShadowSampler(textureFunction.sampler)) + { + // Compare value + if (textureFunction.proj) + { + // According to ESSL 3.00.4 sec 8.8 p95 on textureProj: + // The resulting third component of P' in the shadow forms is used as + // Dref + out << "), " << texCoordZ; + } + else + { + switch (textureFunction.coords) + { + case 3: + out << "), t.z"; + break; + case 4: + out << "), t.w"; + break; + default: + UNREACHABLE(); + } + } + } + else + { + out << "), ddx, ddy"; + } + } + else if (IsIntegerSampler(textureFunction.sampler) || + textureFunction.method == TextureFunctionHLSL::TextureFunction::FETCH) + { + out << ", mip)"; + } + else if (IsShadowSampler(textureFunction.sampler)) + { + // Compare value + if (textureFunction.proj) + { + // According to ESSL 3.00.4 sec 8.8 p95 on textureProj: + // The resulting third component of P' in the shadow forms is used as Dref + out << "), " << texCoordZ; + } + else + { + switch (textureFunction.coords) + { + case 3: + out << "), t.z"; + break; + case 4: + out << "), t.w"; + break; + default: + UNREACHABLE(); + } + } + } + else + { + switch (textureFunction.method) + { + case TextureFunctionHLSL::TextureFunction::IMPLICIT: + out << ")"; + break; + case TextureFunctionHLSL::TextureFunction::BIAS: + out << "), bias"; + break; + case TextureFunctionHLSL::TextureFunction::LOD: + out << "), lod"; + break; + case TextureFunctionHLSL::TextureFunction::LOD0: + out << "), 0"; + break; + case TextureFunctionHLSL::TextureFunction::LOD0BIAS: + out << "), bias"; + break; + default: + UNREACHABLE(); + } + } + + if (textureFunction.offset && + (!IsIntegerSampler(textureFunction.sampler) || + textureFunction.method == TextureFunctionHLSL::TextureFunction::FETCH)) + { + out << ", offset"; + } + } + else + UNREACHABLE(); + + out << ");\n"; // Close the sample function call and return statement +} + +} // Anonymous namespace + +TString TextureFunctionHLSL::TextureFunction::name() const +{ + TString name = "gl_texture"; + + // We need to include full the sampler type in the function name to make the signature unique + // on D3D11, where samplers are passed to texture functions as indices. + name += TextureTypeSuffix(this->sampler); + + if (proj) + { + name += "Proj"; + } + + if (offset) + { + name += "Offset"; + } + + switch (method) + { + case IMPLICIT: + break; + case BIAS: + break; // Extra parameter makes the signature unique + case LOD: + name += "Lod"; + break; + case LOD0: + name += "Lod0"; + break; + case LOD0BIAS: + name += "Lod0"; + break; // Extra parameter makes the signature unique + case SIZE: + name += "Size"; + break; + case FETCH: + name += "Fetch"; + break; + case GRAD: + name += "Grad"; + break; + default: + UNREACHABLE(); + } + + return name; +} + +const char *TextureFunctionHLSL::TextureFunction::getReturnType() const +{ + if (method == TextureFunction::SIZE) + { + switch (sampler) + { + case EbtSampler2D: + case EbtISampler2D: + case EbtUSampler2D: + case EbtSampler2DShadow: + case EbtSamplerCube: + case EbtISamplerCube: + case EbtUSamplerCube: + case EbtSamplerCubeShadow: + case EbtSamplerExternalOES: + return "int2"; + case EbtSampler3D: + case EbtISampler3D: + case EbtUSampler3D: + case EbtSampler2DArray: + case EbtISampler2DArray: + case EbtUSampler2DArray: + case EbtSampler2DArrayShadow: + return "int3"; + default: + UNREACHABLE(); + } + } + else // Sampling function + { + switch (sampler) + { + case EbtSampler2D: + case EbtSampler3D: + case EbtSamplerCube: + case EbtSampler2DArray: + case EbtSamplerExternalOES: + return "float4"; + case EbtISampler2D: + case EbtISampler3D: + case EbtISamplerCube: + case EbtISampler2DArray: + return "int4"; + case EbtUSampler2D: + case EbtUSampler3D: + case EbtUSamplerCube: + case EbtUSampler2DArray: + return "uint4"; + case EbtSampler2DShadow: + case EbtSamplerCubeShadow: + case EbtSampler2DArrayShadow: + return "float"; + default: + UNREACHABLE(); + } + } + return ""; +} + +bool TextureFunctionHLSL::TextureFunction::operator<(const TextureFunction &rhs) const +{ + if (sampler < rhs.sampler) + return true; + if (sampler > rhs.sampler) + return false; + + if (coords < rhs.coords) + return true; + if (coords > rhs.coords) + return false; + + if (!proj && rhs.proj) + return true; + if (proj && !rhs.proj) + return false; + + if (!offset && rhs.offset) + return true; + if (offset && !rhs.offset) + return false; + + if (method < rhs.method) + return true; + if (method > rhs.method) + return false; + + return false; +} + +TString TextureFunctionHLSL::useTextureFunction(const TString &name, + TBasicType samplerType, + int coords, + size_t argumentCount, + bool lod0, + sh::GLenum shaderType) +{ + TextureFunction textureFunction; + textureFunction.sampler = samplerType; + textureFunction.coords = coords; + textureFunction.method = TextureFunction::IMPLICIT; + textureFunction.proj = false; + textureFunction.offset = false; + + if (name == "texture2D" || name == "textureCube" || name == "texture") + { + textureFunction.method = TextureFunction::IMPLICIT; + } + else if (name == "texture2DProj" || name == "textureProj") + { + textureFunction.method = TextureFunction::IMPLICIT; + textureFunction.proj = true; + } + else if (name == "texture2DLod" || name == "textureCubeLod" || name == "textureLod" || + name == "texture2DLodEXT" || name == "textureCubeLodEXT") + { + textureFunction.method = TextureFunction::LOD; + } + else if (name == "texture2DProjLod" || name == "textureProjLod" || + name == "texture2DProjLodEXT") + { + textureFunction.method = TextureFunction::LOD; + textureFunction.proj = true; + } + else if (name == "textureSize") + { + textureFunction.method = TextureFunction::SIZE; + } + else if (name == "textureOffset") + { + textureFunction.method = TextureFunction::IMPLICIT; + textureFunction.offset = true; + } + else if (name == "textureProjOffset") + { + textureFunction.method = TextureFunction::IMPLICIT; + textureFunction.offset = true; + textureFunction.proj = true; + } + else if (name == "textureLodOffset") + { + textureFunction.method = TextureFunction::LOD; + textureFunction.offset = true; + } + else if (name == "textureProjLodOffset") + { + textureFunction.method = TextureFunction::LOD; + textureFunction.proj = true; + textureFunction.offset = true; + } + else if (name == "texelFetch") + { + textureFunction.method = TextureFunction::FETCH; + } + else if (name == "texelFetchOffset") + { + textureFunction.method = TextureFunction::FETCH; + textureFunction.offset = true; + } + else if (name == "textureGrad" || name == "texture2DGradEXT") + { + textureFunction.method = TextureFunction::GRAD; + } + else if (name == "textureGradOffset") + { + textureFunction.method = TextureFunction::GRAD; + textureFunction.offset = true; + } + else if (name == "textureProjGrad" || name == "texture2DProjGradEXT" || + name == "textureCubeGradEXT") + { + textureFunction.method = TextureFunction::GRAD; + textureFunction.proj = true; + } + else if (name == "textureProjGradOffset") + { + textureFunction.method = TextureFunction::GRAD; + textureFunction.proj = true; + textureFunction.offset = true; + } + else + UNREACHABLE(); + + if (textureFunction.method == + TextureFunction::IMPLICIT) // Could require lod 0 or have a bias argument + { + size_t mandatoryArgumentCount = 2; // All functions have sampler and coordinate arguments + + if (textureFunction.offset) + { + mandatoryArgumentCount++; + } + + bool bias = (argumentCount > mandatoryArgumentCount); // Bias argument is optional + + if (lod0 || shaderType == GL_VERTEX_SHADER) + { + if (bias) + { + textureFunction.method = TextureFunction::LOD0BIAS; + } + else + { + textureFunction.method = TextureFunction::LOD0; + } + } + else if (bias) + { + textureFunction.method = TextureFunction::BIAS; + } + } + + mUsesTexture.insert(textureFunction); + return textureFunction.name(); +} + +void TextureFunctionHLSL::textureFunctionHeader(TInfoSinkBase &out, const ShShaderOutput outputType) +{ + for (const TextureFunction &textureFunction : mUsesTexture) + { + // Function header + out << textureFunction.getReturnType() << " " << textureFunction.name() << "("; + + OutputTextureFunctionArgumentList(out, textureFunction, outputType); + + out << ")\n" + "{\n"; + + // In some cases we use a variable to store the texture/sampler objects, but to work around + // a D3D11 compiler bug related to discard inside a loop that is conditional on texture + // sampling we need to call the function directly on references to the texture and sampler + // arrays. The bug was found using dEQP-GLES3.functional.shaders.discard*loop_texture* + // tests. + TString textureReference; + TString samplerReference; + GetTextureReference(out, textureFunction, outputType, &textureReference, &samplerReference); + + if (textureFunction.method == TextureFunction::SIZE) + { + OutputTextureSizeFunctionBody(out, textureFunction, textureReference); + } + else + { + TString texCoordX("t.x"); + TString texCoordY("t.y"); + TString texCoordZ("t.z"); + ProjectTextureCoordinates(textureFunction, &texCoordX, &texCoordY, &texCoordZ); + OutputIntegerTextureSampleFunctionComputations(out, textureFunction, outputType, + textureReference, &texCoordX, &texCoordY, + &texCoordZ); + OutputTextureSampleFunctionReturnStatement(out, textureFunction, outputType, + textureReference, samplerReference, + texCoordX, texCoordY, texCoordZ); + } + + out << "}\n" + "\n"; + } +} + +} // namespace sh diff --git a/chromium/third_party/angle/src/compiler/translator/TextureFunctionHLSL.h b/chromium/third_party/angle/src/compiler/translator/TextureFunctionHLSL.h new file mode 100644 index 00000000000..6c8ce3130f5 --- /dev/null +++ b/chromium/third_party/angle/src/compiler/translator/TextureFunctionHLSL.h @@ -0,0 +1,74 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// TextureFunctionHLSL: Class for writing implementations of ESSL texture functions into HLSL +// output. Some of the implementations are straightforward and just call the HLSL equivalent of the +// ESSL texture function, others do more work to emulate ESSL texture sampling or size query +// behavior. +// + +#ifndef COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_ +#define COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_ + +#include <set> + +#include "compiler/translator/BaseTypes.h" +#include "compiler/translator/Common.h" +#include "compiler/translator/InfoSink.h" +#include "GLSLANG/ShaderLang.h" + +namespace sh +{ + +class TextureFunctionHLSL final : angle::NonCopyable +{ + public: + struct TextureFunction + { + // See ESSL 3.00.6 section 8.8 for reference about what the different methods below do. + enum Method + { + IMPLICIT, // Mipmap LOD determined implicitly (standard lookup) + BIAS, + LOD, + LOD0, + LOD0BIAS, + SIZE, // textureSize() + FETCH, + GRAD + }; + + TString name() const; + + bool operator<(const TextureFunction &rhs) const; + + const char *getReturnType() const; + + TBasicType sampler; + int coords; + bool proj; + bool offset; + Method method; + }; + + // Returns the name of the texture function implementation to call. + // The name that's passed in is the name of the GLSL texture function that it should implement. + TString useTextureFunction(const TString &name, + TBasicType samplerType, + int coords, + size_t argumentCount, + bool lod0, + sh::GLenum shaderType); + + void textureFunctionHeader(TInfoSinkBase &out, const ShShaderOutput outputType); + + private: + typedef std::set<TextureFunction> TextureFunctionSet; + TextureFunctionSet mUsesTexture; +}; + +} // namespace sh + +#endif // COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_ diff --git a/chromium/third_party/angle/src/compiler/translator/UniformHLSL.cpp b/chromium/third_party/angle/src/compiler/translator/UniformHLSL.cpp index 37e4def039e..24d7760cb3a 100644 --- a/chromium/third_party/angle/src/compiler/translator/UniformHLSL.cpp +++ b/chromium/third_party/angle/src/compiler/translator/UniformHLSL.cpp @@ -337,8 +337,15 @@ void UniformHLSL::samplerMetadataUniforms(TInfoSinkBase &out, const char *reg) // If mSamplerRegister is 0 the shader doesn't use any textures. if (mSamplerRegister > 0) { - out << " int4 samplerMetadata[" << mSamplerRegister << "] : packoffset(" << reg - << ");\n"; + out << " struct SamplerMetadata\n" + " {\n" + " int baseLevel;\n" + " int internalFormatBits;\n" + " int wrapModes;\n" + " int padding;\n" + " };\n" + " SamplerMetadata samplerMetadata[" + << mSamplerRegister << "] : packoffset(" << reg << ");\n"; } } diff --git a/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.cpp b/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.cpp index 9c07631ef86..b3a065f19f8 100644 --- a/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.cpp +++ b/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.cpp @@ -181,11 +181,6 @@ TString TextureTypeSuffix(const TBasicType type) TString DecorateUniform(const TName &name, const TType &type) { - if (type.getBasicType() == EbtSamplerExternalOES) - { - return "ex_" + name.getString(); - } - return DecorateIfNeeded(name); } @@ -396,46 +391,6 @@ TString QualifierString(TQualifier qualifier) return ""; } -int HLSLTextureCoordsCount(const TBasicType samplerType) -{ - switch (samplerType) - { - case EbtSampler2D: - return 2; - case EbtSampler3D: - return 3; - case EbtSamplerCube: - return 3; - case EbtSampler2DArray: - return 3; - case EbtISampler2D: - return 2; - case EbtISampler3D: - return 3; - case EbtISamplerCube: - return 3; - case EbtISampler2DArray: - return 3; - case EbtUSampler2D: - return 2; - case EbtUSampler3D: - return 3; - case EbtUSamplerCube: - return 3; - case EbtUSampler2DArray: - return 3; - case EbtSampler2DShadow: - return 2; - case EbtSamplerCubeShadow: - return 3; - case EbtSampler2DArrayShadow: - return 3; - default: - UNREACHABLE(); - } - return 0; -} - TString DisambiguateFunctionName(const TIntermSequence *parameters) { TString disambiguatingString; diff --git a/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.h b/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.h index 387ab8232a6..748b3513e69 100644 --- a/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.h +++ b/chromium/third_party/angle/src/compiler/translator/UtilsHLSL.h @@ -73,7 +73,6 @@ TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMa bool useStd140Packing); TString InterpolationString(TQualifier qualifier); TString QualifierString(TQualifier qualifier); -int HLSLTextureCoordsCount(const TBasicType samplerType); // Parameters may need to be included in function names to disambiguate between overloaded // functions. TString DisambiguateFunctionName(const TIntermSequence *parameters); diff --git a/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.cpp b/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.cpp index cd37aeacd11..29ca68d9cab 100644 --- a/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.cpp +++ b/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.cpp @@ -34,10 +34,10 @@ void ValidateOutputs::visitSymbol(TIntermSymbol *symbol) TString name = symbol->getSymbol(); TQualifier qualifier = symbol->getQualifier(); - if (mVisitedSymbols.count(name) == 1) + if (mVisitedSymbols.count(name.c_str()) == 1) return; - mVisitedSymbols.insert(name); + mVisitedSymbols.insert(name.c_str()); if (qualifier == EvqFragmentOut) { diff --git a/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.h b/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.h index 06f63994cdf..0122ca25fe3 100644 --- a/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.h +++ b/chromium/third_party/angle/src/compiler/translator/ValidateOutputs.h @@ -30,7 +30,7 @@ class ValidateOutputs : public TIntermTraverser typedef std::vector<TIntermSymbol *> OutputVector; OutputVector mOutputs; OutputVector mUnspecifiedLocationOutputs; - std::set<TString> mVisitedSymbols; + std::set<std::string> mVisitedSymbols; }; #endif // COMPILER_TRANSLATOR_VALIDATEOUTPUTS_H_ diff --git a/chromium/third_party/angle/src/compiler/translator/glslang.l b/chromium/third_party/angle/src/compiler/translator/glslang.l index d09358dd8ab..a4a296121dd 100644 --- a/chromium/third_party/angle/src/compiler/translator/glslang.l +++ b/chromium/third_party/angle/src/compiler/translator/glslang.l @@ -390,6 +390,11 @@ O [0-7] return FIELD_SELECTION; } <FIELDS>[ \t\v\f\r] {} +<FIELDS>. { + yyextra->error(*yylloc, "Illegal character at fieldname start", yytext, ""); + yyextra->recover(); + return 0; +} [ \t\v\n\f\r] { } <*><<EOF>> { yyterminate(); } diff --git a/chromium/third_party/angle/src/compiler/translator/glslang.y b/chromium/third_party/angle/src/compiler/translator/glslang.y index aba27063115..c5a4b9f05af 100644 --- a/chromium/third_party/angle/src/compiler/translator/glslang.y +++ b/chromium/third_party/angle/src/compiler/translator/glslang.y @@ -1246,7 +1246,8 @@ type_specifier_nonarray $$.setBasic(EbtSampler2DArrayShadow, qual, @1); } | SAMPLER_EXTERNAL_OES { - if (!context->supportsExtension("GL_OES_EGL_image_external")) { + if (!context->supportsExtension("GL_OES_EGL_image_external") && + !context->supportsExtension("GL_NV_EGL_stream_consumer_external")) { context->error(@1, "unsupported type", "samplerExternalOES"); context->recover(); } diff --git a/chromium/third_party/angle/src/compiler/translator/glslang_lex.cpp b/chromium/third_party/angle/src/compiler/translator/glslang_lex.cpp index 35aa6ea0fa2..ff6c2d6b1cc 100644 --- a/chromium/third_party/angle/src/compiler/translator/glslang_lex.cpp +++ b/chromium/third_party/angle/src/compiler/translator/glslang_lex.cpp @@ -400,8 +400,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 239 -#define YY_END_OF_BUFFER 240 +#define YY_NUM_RULES 240 +#define YY_END_OF_BUFFER 241 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -409,98 +409,98 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[819] = +static yyconst flex_int16_t yy_accept[820] = { 0, - 0, 0, 0, 0, 240, 238, 237, 237, 222, 228, + 0, 0, 0, 0, 241, 239, 238, 238, 222, 228, 233, 217, 218, 226, 225, 214, 223, 221, 227, 180, 180, 215, 211, 229, 216, 230, 234, 177, 219, 220, 232, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 212, 231, 213, 224, 236, 239, 235, 208, 194, - 213, 202, 197, 192, 200, 190, 201, 191, 186, 193, - 185, 179, 180, 0, 183, 0, 220, 212, 219, 209, - 205, 207, 206, 210, 177, 198, 204, 177, 177, 177, - 177, 177, 177, 177, 177, 177, 177, 177, 177, 12, - + 177, 212, 231, 213, 224, 237, 236, 240, 235, 208, + 194, 213, 202, 197, 192, 200, 190, 201, 191, 186, + 193, 185, 179, 180, 0, 183, 0, 220, 212, 219, + 209, 205, 207, 206, 210, 177, 198, 204, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 15, 177, 177, 23, 177, 177, 177, + + 12, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 15, 177, 177, 23, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 199, 203, 235, 0, 189, 185, 0, 188, 182, 0, - 184, 178, 195, 196, 177, 136, 177, 177, 177, 177, + 177, 199, 203, 235, 0, 189, 185, 0, 188, 182, + 0, 184, 178, 195, 196, 177, 136, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 177, 177, 177, 177, 13, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 13, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 27, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 24, 177, 177, 177, 177, 177, 177, 177, + 177, 27, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 24, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 177, 177, 0, 186, 0, - 185, 187, 181, 177, 177, 177, 30, 177, 177, 18, - 174, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 16, 139, 177, 177, 177, 177, 21, 177, 177, - 143, 155, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 152, 4, 35, 36, 37, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 0, 186, + 0, 185, 187, 181, 177, 177, 177, 30, 177, 177, + 18, 174, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 16, 139, 177, 177, 177, 177, 21, 177, + 177, 143, 155, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 152, 4, 35, 36, 37, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 142, 31, 177, 177, 28, 177, 177, - 177, 177, 177, 177, 177, 47, 48, 49, 29, 177, - 177, 177, 177, 177, 177, 10, 53, 54, 55, 177, - 137, 177, 177, 7, 177, 177, 177, 177, 164, 165, - 166, 177, 32, 177, 156, 26, 167, 168, 169, 2, - 161, 162, 163, 177, 177, 177, 25, 159, 177, 177, - 177, 50, 51, 52, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 86, 177, 177, 177, 177, - - 177, 177, 177, 153, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 138, 177, 177, 176, 56, - 57, 58, 177, 177, 14, 177, 91, 177, 177, 177, - 177, 89, 177, 177, 177, 154, 149, 92, 177, 177, - 177, 177, 177, 177, 144, 177, 177, 177, 78, 38, - 41, 43, 42, 39, 45, 44, 46, 40, 177, 177, - 177, 177, 160, 135, 177, 177, 147, 177, 177, 177, - 34, 87, 173, 22, 148, 77, 177, 158, 17, 177, - 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 19, 33, 177, 177, 177, 177, 177, - - 177, 93, 94, 95, 177, 177, 177, 177, 177, 3, + 177, 177, 177, 177, 142, 31, 177, 177, 28, 177, + 177, 177, 177, 177, 177, 177, 47, 48, 49, 29, + 177, 177, 177, 177, 177, 177, 10, 53, 54, 55, + 177, 137, 177, 177, 7, 177, 177, 177, 177, 164, + 165, 166, 177, 32, 177, 156, 26, 167, 168, 169, + 2, 161, 162, 163, 177, 177, 177, 25, 159, 177, + 177, 177, 50, 51, 52, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 86, 177, 177, 177, + + 177, 177, 177, 177, 153, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 138, 177, 177, 176, + 56, 57, 58, 177, 177, 14, 177, 91, 177, 177, + 177, 177, 89, 177, 177, 177, 154, 149, 92, 177, + 177, 177, 177, 177, 177, 144, 177, 177, 177, 78, + 38, 41, 43, 42, 39, 45, 44, 46, 40, 177, + 177, 177, 177, 160, 135, 177, 177, 147, 177, 177, + 177, 34, 87, 173, 22, 148, 77, 177, 158, 17, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 140, 177, 177, 177, 177, 177, 8, 177, 177, - 9, 177, 177, 177, 177, 20, 79, 11, 150, 97, - 98, 99, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 145, 177, 177, 177, 81, 83, - 80, 177, 177, 177, 177, 177, 177, 177, 141, 101, - 102, 103, 177, 177, 157, 177, 146, 177, 177, 6, - 177, 177, 177, 177, 177, 177, 177, 177, 177, 96, - 151, 1, 177, 177, 177, 177, 177, 175, 177, 90, - - 5, 170, 59, 62, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 177, 177, 82, 177, 177, - 177, 177, 100, 177, 177, 177, 177, 177, 120, 66, - 67, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 88, 177, 177, 177, 104, 122, - 70, 71, 177, 177, 84, 177, 177, 177, 177, 177, - 177, 177, 115, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 129, 177, 177, 177, 177, 60, 177, + 177, 177, 177, 177, 19, 33, 177, 177, 177, 177, + + 177, 177, 93, 94, 95, 177, 177, 177, 177, 177, + 3, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 140, 177, 177, 177, 177, 177, 8, 177, + 177, 9, 177, 177, 177, 177, 20, 79, 11, 150, + 97, 98, 99, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 145, 177, 177, 177, 81, + 83, 80, 177, 177, 177, 177, 177, 177, 177, 141, + 101, 102, 103, 177, 177, 157, 177, 146, 177, 177, + 6, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 96, 151, 1, 177, 177, 177, 177, 177, 175, 177, + + 90, 5, 170, 59, 62, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 82, 177, + 177, 177, 177, 100, 177, 177, 177, 177, 177, 120, + 66, 67, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 88, 177, 177, 177, 104, + 122, 70, 71, 177, 177, 84, 177, 177, 177, 177, + 177, 177, 177, 115, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 129, 177, 177, 177, 177, 60, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 116, 105, 177, 106, 177, 177, 177, 130, 177, - - 177, 68, 177, 177, 177, 177, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 117, 177, 177, 131, 177, - 177, 72, 107, 108, 177, 111, 177, 112, 177, 177, - 177, 177, 177, 85, 177, 177, 177, 177, 64, 177, - 63, 126, 177, 177, 109, 110, 177, 177, 177, 177, - 177, 177, 177, 177, 177, 177, 124, 127, 118, 177, - 65, 177, 177, 177, 177, 177, 177, 177, 177, 125, - 128, 177, 177, 121, 69, 177, 177, 171, 177, 177, - 177, 74, 177, 177, 123, 73, 177, 177, 177, 177, - 177, 177, 132, 177, 177, 177, 177, 177, 177, 133, - - 177, 177, 177, 75, 177, 134, 113, 114, 177, 177, - 177, 61, 177, 177, 172, 119, 76, 0 + 177, 177, 116, 105, 177, 106, 177, 177, 177, 130, + + 177, 177, 68, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 117, 177, 177, 131, + 177, 177, 72, 107, 108, 177, 111, 177, 112, 177, + 177, 177, 177, 177, 85, 177, 177, 177, 177, 64, + 177, 63, 126, 177, 177, 109, 110, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 124, 127, 118, + 177, 65, 177, 177, 177, 177, 177, 177, 177, 177, + 125, 128, 177, 177, 121, 69, 177, 177, 171, 177, + 177, 177, 74, 177, 177, 123, 73, 177, 177, 177, + 177, 177, 177, 132, 177, 177, 177, 177, 177, 177, + + 133, 177, 177, 177, 75, 177, 134, 113, 114, 177, + 177, 177, 61, 177, 177, 172, 119, 76, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -547,194 +547,194 @@ static yyconst flex_int32_t yy_meta[73] = 1, 1 } ; -static yyconst flex_int16_t yy_base[824] = +static yyconst flex_int16_t yy_base[825] = { 0, 0, 0, 72, 0, 1016, 1017, 1017, 1017, 990, 120, 141, 1017, 1017, 989, 138, 1017, 137, 135, 988, 154, 208, 986, 1017, 154, 986, 132, 1017, 0, 1017, 1017, 139, 130, 123, 140, 147, 133, 177, 952, 186, 151, 139, 116, 161, 946, 173, 959, 193, 199, 208, 215, - 108, 1017, 184, 1017, 1017, 1017, 1017, 0, 1017, 1017, - 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 230, 1017, - 235, 235, 0, 271, 1017, 0, 1017, 1017, 1017, 982, - 1017, 1017, 1017, 981, 0, 1017, 1017, 943, 948, 152, - 945, 953, 952, 939, 942, 953, 243, 947, 935, 932, - - 945, 932, 929, 929, 935, 147, 248, 929, 939, 925, - 931, 934, 935, 0, 927, 937, 249, 936, 931, 912, - 177, 916, 929, 920, 184, 913, 250, 925, 927, 257, - 916, 913, 902, 911, 249, 257, 915, 911, 913, 902, - 905, 196, 217, 269, 914, 902, 914, 262, 907, 906, - 1017, 1017, 0, 311, 1017, 292, 328, 1017, 1017, 335, - 342, 257, 1017, 1017, 905, 0, 901, 896, 900, 909, - 906, 315, 890, 890, 901, 893, 215, 903, 900, 900, - 898, 895, 887, 893, 880, 878, 890, 876, 892, 0, - 889, 877, 884, 881, 885, 886, 879, 876, 865, 864, - - 877, 880, 868, 876, 864, 870, 861, 316, 866, 869, - 860, 867, 856, 860, 851, 865, 864, 855, 861, 307, - 845, 848, 846, 856, 846, 841, 839, 841, 851, 837, - 839, 836, 847, 846, 849, 831, 316, 839, 835, 833, - 842, 821, 353, 839, 841, 830, 822, 363, 370, 378, - 389, 1017, 1017, 819, 829, 828, 0, 826, 383, 0, - 0, 819, 817, 817, 818, 813, 821, 810, 827, 816, - 394, 0, 0, 810, 820, 819, 819, 0, 804, 397, - 0, 0, 806, 400, 813, 814, 805, 799, 798, 799, - 798, 798, 406, 793, 0, 0, 789, 788, 787, 789, - - 790, 795, 789, 785, 798, 793, 793, 791, 790, 784, - 778, 780, 779, 783, 775, 778, 773, 781, 786, 774, - 771, 783, 774, 0, 0, 780, 776, 0, 768, 768, - 773, 764, 771, 409, 768, 0, 0, 0, 0, 758, - 770, 769, 768, 769, 769, 0, 0, 0, 0, 756, - 0, 764, 755, 0, 754, 755, 749, 759, 0, 0, - 0, 750, 0, 746, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 756, 413, 755, 0, 0, 753, 749, - 746, 0, 0, 0, 738, 415, 418, 427, 743, 739, - 744, 735, 733, 746, 731, 0, 731, 744, 733, 729, - - 735, 730, 737, 0, 735, 732, 736, 720, 718, 721, - 727, 733, 728, 727, 715, 0, 717, 718, 0, 0, - 0, 0, 715, 718, 0, 712, 0, 725, 705, 714, - 709, 0, 702, 702, 715, 0, 717, 0, 431, 730, - 729, 728, 695, 694, 0, 711, 710, 705, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 694, 707, - 694, 691, 0, 0, 696, 695, 0, 692, 699, 698, - 0, 684, 0, 0, 0, 0, 681, 0, 0, 680, - 691, 434, 684, 690, 689, 686, 681, 678, 671, 671, - 684, 669, 681, 0, 0, 674, 697, 696, 695, 662, - - 661, 427, 428, 0, 673, 676, 674, 663, 659, 0, - 671, 668, 667, 657, 656, 646, 663, 649, 441, 657, - 660, 0, 677, 676, 675, 642, 641, 0, 655, 642, - 0, 652, 645, 646, 649, 0, 0, 0, 0, 669, - 668, 0, 645, 648, 633, 640, 631, 638, 639, 639, - 638, 624, 451, 636, 0, 637, 626, 625, 0, 0, - 0, 650, 649, 648, 615, 614, 610, 618, 0, 646, - 645, 0, 622, 625, 0, 458, 0, 603, 612, 0, - 608, 607, 616, 616, 604, 618, 602, 616, 611, 0, - 0, 0, 628, 627, 626, 593, 592, 0, 592, 0, - - 0, 434, 454, 616, 602, 605, 588, 600, 588, 587, - 596, 596, 613, 612, 611, 578, 577, 0, 577, 578, - 577, 587, 0, 590, 586, 588, 584, 571, 602, 449, - 0, 579, 582, 574, 566, 573, 564, 585, 573, 569, - 571, 569, 569, 568, 0, 556, 555, 565, 0, 585, - 462, 0, 562, 565, 0, 565, 564, 548, 540, 548, - 538, 546, 0, 543, 542, 563, 551, 549, 549, 533, - 536, 550, 534, 565, 545, 546, 543, 540, 550, 527, - 541, 540, 524, 523, 522, 543, 531, 529, 529, 510, - 509, 0, 537, 509, 535, 507, 511, 510, 541, 521, - - 518, 0, 517, 520, 516, 518, 502, 499, 512, 497, - 498, 505, 499, 488, 487, 0, 493, 492, 523, 503, - 500, 0, 0, 0, 496, 0, 495, 0, 501, 500, - 484, 481, 482, 0, 474, 482, 472, 478, 499, 478, - 0, 0, 490, 489, 0, 0, 488, 487, 471, 468, - 469, 483, 482, 459, 458, 464, 0, 0, 485, 457, - 483, 475, 467, 453, 132, 161, 177, 215, 245, 0, - 0, 288, 289, 0, 0, 294, 315, 0, 316, 306, - 331, 0, 363, 402, 0, 0, 395, 383, 395, 387, - 433, 434, 0, 435, 420, 461, 427, 430, 431, 0, - - 450, 452, 443, 0, 464, 0, 0, 0, 445, 446, - 440, 0, 441, 442, 0, 0, 0, 1017, 506, 509, - 512, 513, 514 + 108, 1017, 184, 1017, 1017, 1017, 1017, 1017, 0, 1017, + 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 230, + 1017, 235, 235, 0, 271, 1017, 0, 1017, 1017, 1017, + 982, 1017, 1017, 1017, 981, 0, 1017, 1017, 943, 948, + 152, 945, 953, 952, 939, 942, 953, 243, 947, 935, + + 932, 945, 932, 929, 929, 935, 147, 248, 929, 939, + 925, 931, 934, 935, 0, 927, 937, 249, 936, 931, + 912, 177, 916, 929, 920, 184, 913, 250, 925, 927, + 257, 916, 913, 902, 911, 249, 257, 915, 911, 913, + 902, 905, 196, 217, 269, 914, 902, 914, 262, 907, + 906, 1017, 1017, 0, 311, 1017, 292, 328, 1017, 1017, + 335, 342, 257, 1017, 1017, 905, 0, 901, 896, 900, + 909, 906, 315, 890, 890, 901, 893, 215, 903, 900, + 900, 898, 895, 887, 893, 880, 878, 890, 876, 892, + 0, 889, 877, 884, 881, 885, 886, 879, 876, 865, + + 864, 877, 880, 868, 876, 864, 870, 861, 316, 866, + 869, 860, 867, 856, 860, 851, 865, 864, 855, 861, + 307, 845, 848, 846, 856, 846, 841, 839, 841, 851, + 837, 839, 836, 847, 846, 849, 831, 316, 839, 835, + 833, 842, 821, 353, 839, 841, 830, 822, 363, 370, + 378, 389, 1017, 1017, 819, 829, 828, 0, 826, 383, + 0, 0, 819, 817, 817, 818, 813, 821, 810, 827, + 816, 394, 0, 0, 810, 820, 819, 819, 0, 804, + 397, 0, 0, 806, 400, 813, 814, 805, 799, 798, + 799, 798, 798, 406, 793, 0, 0, 789, 788, 787, + + 789, 790, 795, 789, 785, 798, 793, 793, 791, 790, + 784, 778, 780, 779, 783, 775, 778, 773, 781, 786, + 774, 771, 783, 774, 0, 0, 780, 776, 0, 768, + 768, 773, 764, 771, 409, 768, 0, 0, 0, 0, + 758, 770, 769, 768, 769, 769, 0, 0, 0, 0, + 756, 0, 764, 755, 0, 754, 755, 749, 759, 0, + 0, 0, 750, 0, 746, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 756, 413, 755, 0, 0, 753, + 749, 746, 0, 0, 0, 738, 415, 418, 427, 743, + 739, 744, 735, 733, 746, 731, 0, 731, 744, 733, + + 729, 735, 730, 737, 0, 735, 732, 736, 720, 718, + 721, 727, 733, 728, 727, 715, 0, 717, 718, 0, + 0, 0, 0, 715, 718, 0, 712, 0, 725, 705, + 714, 709, 0, 702, 702, 715, 0, 717, 0, 431, + 730, 729, 728, 695, 694, 0, 711, 710, 705, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 694, + 707, 694, 691, 0, 0, 696, 695, 0, 692, 699, + 698, 0, 684, 0, 0, 0, 0, 681, 0, 0, + 680, 691, 434, 684, 690, 689, 686, 681, 678, 671, + 671, 684, 669, 681, 0, 0, 674, 697, 696, 695, + + 662, 661, 427, 428, 0, 673, 676, 674, 663, 659, + 0, 671, 668, 667, 657, 656, 646, 663, 649, 441, + 657, 660, 0, 677, 676, 675, 642, 641, 0, 655, + 642, 0, 652, 645, 646, 649, 0, 0, 0, 0, + 669, 668, 0, 645, 648, 633, 640, 631, 638, 639, + 639, 638, 624, 451, 636, 0, 637, 626, 625, 0, + 0, 0, 650, 649, 648, 615, 614, 610, 618, 0, + 646, 645, 0, 622, 625, 0, 458, 0, 603, 612, + 0, 608, 607, 616, 616, 604, 618, 602, 616, 611, + 0, 0, 0, 628, 627, 626, 593, 592, 0, 592, + + 0, 0, 434, 454, 616, 602, 605, 588, 600, 588, + 587, 596, 596, 613, 612, 611, 578, 577, 0, 577, + 578, 577, 587, 0, 590, 586, 588, 584, 571, 602, + 449, 0, 579, 582, 574, 566, 573, 564, 585, 573, + 569, 571, 569, 569, 568, 0, 556, 555, 565, 0, + 585, 462, 0, 562, 565, 0, 565, 564, 548, 540, + 548, 538, 546, 0, 543, 542, 563, 551, 549, 549, + 533, 536, 550, 534, 565, 545, 546, 543, 540, 550, + 527, 541, 540, 524, 523, 522, 543, 531, 529, 529, + 510, 509, 0, 537, 509, 535, 507, 511, 510, 541, + + 521, 518, 0, 517, 520, 516, 518, 502, 499, 512, + 497, 498, 505, 499, 488, 487, 0, 493, 492, 523, + 503, 500, 0, 0, 0, 496, 0, 495, 0, 501, + 500, 484, 481, 482, 0, 474, 482, 472, 478, 499, + 478, 0, 0, 490, 489, 0, 0, 488, 487, 471, + 468, 469, 483, 482, 459, 458, 464, 0, 0, 485, + 457, 483, 475, 467, 453, 132, 161, 177, 215, 245, + 0, 0, 288, 289, 0, 0, 294, 315, 0, 316, + 306, 331, 0, 363, 402, 0, 0, 395, 383, 395, + 387, 433, 434, 0, 435, 420, 461, 427, 430, 431, + + 0, 450, 452, 443, 0, 464, 0, 0, 0, 445, + 446, 440, 0, 441, 442, 0, 0, 0, 1017, 506, + 509, 512, 513, 514 } ; -static yyconst flex_int16_t yy_def[824] = +static yyconst flex_int16_t yy_def[825] = { 0, - 818, 1, 818, 3, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 819, 818, 818, - 818, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 818, 818, 818, 818, 818, 818, 820, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 821, 818, - 822, 20, 21, 818, 818, 823, 818, 818, 818, 818, - 818, 818, 818, 818, 819, 818, 818, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 818, 818, 820, 818, 818, 822, 818, 818, 818, 818, - 818, 823, 818, 818, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 818, 818, 818, - 818, 818, 818, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 819, 819, 0, 818, 818, - 818, 818, 818 + 819, 1, 819, 3, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 820, 819, 819, + 819, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 819, 819, 819, 819, 819, 819, 819, 821, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 822, + 819, 823, 20, 21, 819, 819, 824, 819, 819, 819, + 819, 819, 819, 819, 819, 820, 819, 819, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 819, 819, 821, 819, 819, 823, 819, 819, 819, + 819, 819, 824, 819, 819, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 819, 819, + 819, 819, 819, 819, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + + 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, + 820, 820, 820, 820, 820, 820, 820, 820, 0, 819, + 819, 819, 819, 819 } ; static yyconst flex_int16_t yy_nxt[1090] = @@ -746,118 +746,118 @@ static yyconst flex_int16_t yy_nxt[1090] = 29, 30, 31, 28, 32, 33, 34, 35, 36, 37, 38, 39, 40, 28, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 28, 28, 28, 52, 53, - 54, 55, 6, 56, 57, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 58, - - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 6, 6, 6, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, - 6, 6, 6, 6, 60, 61, 62, 65, 67, 69, - 69, 69, 69, 69, 69, 69, 83, 84, 78, 149, - 122, 68, 66, 86, 123, 63, 71, 150, 72, 72, - 72, 72, 72, 72, 73, 79, 88, 80, 81, 783, - 91, 87, 92, 120, 94, 74, 93, 102, 95, 103, - 89, 90, 75, 76, 96, 98, 121, 97, 104, 99, - - 114, 186, 74, 115, 100, 124, 116, 117, 151, 167, - 101, 118, 187, 168, 119, 784, 75, 127, 125, 76, - 71, 105, 73, 73, 73, 73, 73, 73, 73, 106, - 111, 107, 128, 206, 108, 129, 211, 131, 112, 74, - 109, 207, 212, 785, 132, 133, 75, 138, 134, 113, - 139, 235, 236, 152, 135, 136, 74, 137, 140, 146, - 142, 154, 155, 147, 143, 141, 157, 158, 144, 237, - 75, 145, 148, 159, 818, 266, 267, 238, 154, 155, - 160, 786, 160, 157, 158, 161, 161, 161, 161, 161, - 161, 161, 188, 226, 175, 253, 214, 159, 176, 177, - - 818, 219, 228, 198, 787, 189, 199, 200, 227, 215, - 201, 216, 202, 239, 244, 229, 245, 220, 221, 253, - 248, 240, 248, 157, 158, 249, 249, 249, 249, 249, - 249, 249, 297, 298, 299, 788, 789, 250, 790, 250, - 157, 158, 251, 251, 251, 251, 251, 251, 251, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 260, 311, 329, 791, 792, 312, 336, - 337, 338, 793, 330, 252, 794, 261, 249, 249, 249, - 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, - 249, 252, 251, 251, 251, 251, 251, 251, 251, 347, - - 348, 349, 155, 251, 251, 251, 251, 251, 251, 251, - 359, 360, 361, 367, 368, 369, 371, 372, 373, 155, - 795, 158, 382, 383, 384, 420, 421, 422, 440, 441, - 442, 450, 451, 452, 453, 454, 455, 796, 158, 797, - 798, 443, 444, 456, 457, 458, 497, 498, 499, 523, - 524, 525, 799, 800, 545, 547, 562, 563, 564, 500, - 501, 635, 526, 527, 546, 548, 593, 594, 595, 565, - 566, 636, 567, 613, 614, 615, 665, 801, 802, 596, - 597, 637, 803, 666, 804, 667, 616, 617, 638, 685, - 639, 640, 805, 806, 807, 808, 686, 809, 687, 810, - - 811, 812, 813, 814, 815, 816, 817, 85, 85, 85, - 153, 153, 153, 69, 156, 162, 162, 782, 781, 780, - 779, 778, 777, 776, 775, 774, 773, 772, 771, 770, - 769, 768, 767, 766, 765, 764, 763, 762, 761, 760, - 759, 758, 757, 756, 755, 754, 753, 752, 751, 750, - 749, 748, 747, 746, 745, 744, 743, 742, 741, 740, - 739, 738, 737, 736, 735, 734, 733, 732, 731, 730, - 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, - 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, - 709, 708, 707, 706, 705, 704, 703, 702, 701, 700, - - 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, - 689, 688, 684, 683, 682, 681, 680, 679, 678, 677, - 676, 675, 674, 673, 672, 671, 670, 669, 668, 664, - 663, 662, 661, 660, 659, 658, 657, 656, 655, 654, - 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, - 643, 642, 641, 634, 633, 632, 631, 630, 629, 628, - 627, 626, 625, 624, 623, 622, 621, 620, 619, 618, - 612, 611, 610, 609, 608, 607, 606, 605, 604, 603, - 602, 601, 600, 599, 598, 592, 591, 590, 589, 588, - 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, - - 577, 576, 575, 574, 573, 572, 571, 570, 569, 568, - 561, 560, 559, 558, 557, 556, 555, 554, 553, 552, - 551, 550, 549, 544, 543, 542, 541, 540, 539, 538, - 537, 536, 535, 534, 533, 532, 531, 530, 529, 528, - 522, 521, 520, 519, 518, 517, 516, 515, 514, 513, - 512, 511, 510, 509, 508, 507, 506, 505, 504, 503, - 502, 496, 495, 494, 493, 492, 491, 490, 489, 488, - 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, - 477, 476, 475, 474, 473, 472, 471, 470, 469, 468, - 467, 466, 465, 464, 463, 462, 461, 460, 459, 449, - - 448, 447, 446, 445, 439, 438, 437, 436, 435, 434, - 433, 432, 431, 430, 429, 428, 427, 426, 425, 424, - 423, 419, 418, 417, 416, 415, 414, 413, 412, 411, - 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, - 400, 399, 398, 397, 396, 395, 394, 393, 392, 391, - 390, 389, 388, 387, 386, 385, 381, 380, 379, 378, - 377, 376, 375, 374, 370, 366, 365, 364, 363, 362, - 358, 357, 356, 355, 354, 353, 352, 351, 350, 346, - 345, 344, 343, 342, 341, 340, 339, 335, 334, 333, - 332, 331, 328, 327, 326, 325, 324, 323, 322, 321, - - 320, 319, 318, 317, 316, 315, 314, 313, 310, 309, - 308, 307, 306, 305, 304, 303, 302, 301, 300, 296, - 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, - 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, - 275, 274, 273, 272, 271, 270, 269, 268, 265, 264, - 263, 262, 259, 258, 257, 256, 255, 254, 247, 246, - 243, 242, 241, 234, 233, 232, 231, 230, 225, 224, - 223, 222, 218, 217, 213, 210, 209, 208, 205, 204, - 203, 197, 196, 195, 194, 193, 192, 191, 190, 185, - 184, 183, 182, 181, 180, 179, 178, 174, 173, 172, - - 171, 170, 169, 166, 165, 164, 163, 130, 126, 110, - 82, 77, 70, 64, 59, 818, 5, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818 + 54, 55, 56, 57, 58, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 59, + + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 56, 56, 56, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 56, 56, 56, 56, 61, 62, 63, 66, 68, 70, + 70, 70, 70, 70, 70, 70, 84, 85, 79, 150, + 123, 69, 67, 87, 124, 64, 72, 151, 73, 73, + 73, 73, 73, 73, 74, 80, 89, 81, 82, 784, + 92, 88, 93, 121, 95, 75, 94, 103, 96, 104, + 90, 91, 76, 77, 97, 99, 122, 98, 105, 100, + + 115, 187, 75, 116, 101, 125, 117, 118, 152, 168, + 102, 119, 188, 169, 120, 785, 76, 128, 126, 77, + 72, 106, 74, 74, 74, 74, 74, 74, 74, 107, + 112, 108, 129, 207, 109, 130, 212, 132, 113, 75, + 110, 208, 213, 786, 133, 134, 76, 139, 135, 114, + 140, 236, 237, 153, 136, 137, 75, 138, 141, 147, + 143, 155, 156, 148, 144, 142, 158, 159, 145, 238, + 76, 146, 149, 160, 819, 267, 268, 239, 155, 156, + 161, 787, 161, 158, 159, 162, 162, 162, 162, 162, + 162, 162, 189, 227, 176, 254, 215, 160, 177, 178, + + 819, 220, 229, 199, 788, 190, 200, 201, 228, 216, + 202, 217, 203, 240, 245, 230, 246, 221, 222, 254, + 249, 241, 249, 158, 159, 250, 250, 250, 250, 250, + 250, 250, 298, 299, 300, 789, 790, 251, 791, 251, + 158, 159, 252, 252, 252, 252, 252, 252, 252, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 261, 312, 330, 792, 793, 313, 337, + 338, 339, 794, 331, 253, 795, 262, 250, 250, 250, + 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, + 250, 253, 252, 252, 252, 252, 252, 252, 252, 348, + + 349, 350, 156, 252, 252, 252, 252, 252, 252, 252, + 360, 361, 362, 368, 369, 370, 372, 373, 374, 156, + 796, 159, 383, 384, 385, 421, 422, 423, 441, 442, + 443, 451, 452, 453, 454, 455, 456, 797, 159, 798, + 799, 444, 445, 457, 458, 459, 498, 499, 500, 524, + 525, 526, 800, 801, 546, 548, 563, 564, 565, 501, + 502, 636, 527, 528, 547, 549, 594, 595, 596, 566, + 567, 637, 568, 614, 615, 616, 666, 802, 803, 597, + 598, 638, 804, 667, 805, 668, 617, 618, 639, 686, + 640, 641, 806, 807, 808, 809, 687, 810, 688, 811, + + 812, 813, 814, 815, 816, 817, 818, 86, 86, 86, + 154, 154, 154, 70, 157, 163, 163, 783, 782, 781, + 780, 779, 778, 777, 776, 775, 774, 773, 772, 771, + 770, 769, 768, 767, 766, 765, 764, 763, 762, 761, + 760, 759, 758, 757, 756, 755, 754, 753, 752, 751, + 750, 749, 748, 747, 746, 745, 744, 743, 742, 741, + 740, 739, 738, 737, 736, 735, 734, 733, 732, 731, + 730, 729, 728, 727, 726, 725, 724, 723, 722, 721, + 720, 719, 718, 717, 716, 715, 714, 713, 712, 711, + 710, 709, 708, 707, 706, 705, 704, 703, 702, 701, + + 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, + 690, 689, 685, 684, 683, 682, 681, 680, 679, 678, + 677, 676, 675, 674, 673, 672, 671, 670, 669, 665, + 664, 663, 662, 661, 660, 659, 658, 657, 656, 655, + 654, 653, 652, 651, 650, 649, 648, 647, 646, 645, + 644, 643, 642, 635, 634, 633, 632, 631, 630, 629, + 628, 627, 626, 625, 624, 623, 622, 621, 620, 619, + 613, 612, 611, 610, 609, 608, 607, 606, 605, 604, + 603, 602, 601, 600, 599, 593, 592, 591, 590, 589, + 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, + + 578, 577, 576, 575, 574, 573, 572, 571, 570, 569, + 562, 561, 560, 559, 558, 557, 556, 555, 554, 553, + 552, 551, 550, 545, 544, 543, 542, 541, 540, 539, + 538, 537, 536, 535, 534, 533, 532, 531, 530, 529, + 523, 522, 521, 520, 519, 518, 517, 516, 515, 514, + 513, 512, 511, 510, 509, 508, 507, 506, 505, 504, + 503, 497, 496, 495, 494, 493, 492, 491, 490, 489, + 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, + 478, 477, 476, 475, 474, 473, 472, 471, 470, 469, + 468, 467, 466, 465, 464, 463, 462, 461, 460, 450, + + 449, 448, 447, 446, 440, 439, 438, 437, 436, 435, + 434, 433, 432, 431, 430, 429, 428, 427, 426, 425, + 424, 420, 419, 418, 417, 416, 415, 414, 413, 412, + 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, + 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, + 391, 390, 389, 388, 387, 386, 382, 381, 380, 379, + 378, 377, 376, 375, 371, 367, 366, 365, 364, 363, + 359, 358, 357, 356, 355, 354, 353, 352, 351, 347, + 346, 345, 344, 343, 342, 341, 340, 336, 335, 334, + 333, 332, 329, 328, 327, 326, 325, 324, 323, 322, + + 321, 320, 319, 318, 317, 316, 315, 314, 311, 310, + 309, 308, 307, 306, 305, 304, 303, 302, 301, 297, + 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, + 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, + 276, 275, 274, 273, 272, 271, 270, 269, 266, 265, + 264, 263, 260, 259, 258, 257, 256, 255, 248, 247, + 244, 243, 242, 235, 234, 233, 232, 231, 226, 225, + 224, 223, 219, 218, 214, 211, 210, 209, 206, 205, + 204, 198, 197, 196, 195, 194, 193, 192, 191, 186, + 185, 184, 183, 182, 181, 180, 179, 175, 174, 173, + + 172, 171, 170, 167, 166, 165, 164, 131, 127, 111, + 83, 78, 71, 65, 60, 819, 5, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819 } ; static yyconst flex_int16_t yy_chk[1090] = @@ -880,111 +880,111 @@ static yyconst flex_int16_t yy_chk[1090] = 3, 3, 3, 3, 10, 10, 11, 15, 17, 18, 18, 18, 18, 18, 18, 18, 26, 26, 24, 51, 42, 17, 15, 31, 42, 11, 20, 51, 20, 20, - 20, 20, 20, 20, 20, 24, 32, 24, 24, 765, + 20, 20, 20, 20, 20, 24, 32, 24, 24, 766, 33, 31, 33, 41, 34, 20, 33, 36, 34, 36, 32, 32, 20, 20, 34, 35, 41, 34, 36, 35, - 40, 106, 20, 40, 35, 43, 40, 40, 53, 90, - 35, 40, 106, 90, 40, 766, 20, 45, 43, 20, + 40, 107, 20, 40, 35, 43, 40, 40, 53, 91, + 35, 40, 107, 91, 40, 767, 20, 45, 43, 20, 21, 37, 21, 21, 21, 21, 21, 21, 21, 37, - 39, 37, 45, 121, 37, 45, 125, 47, 39, 21, - 37, 121, 125, 767, 47, 47, 21, 48, 47, 39, - 48, 142, 142, 53, 47, 47, 21, 47, 48, 50, - 49, 69, 69, 50, 49, 48, 71, 71, 49, 143, - 21, 49, 50, 72, 72, 177, 177, 143, 69, 69, - 74, 768, 74, 71, 71, 74, 74, 74, 74, 74, - 74, 74, 107, 135, 97, 162, 127, 72, 97, 97, - - 72, 130, 136, 117, 769, 107, 117, 117, 135, 127, - 117, 127, 117, 144, 148, 136, 148, 130, 130, 162, - 154, 144, 154, 156, 156, 154, 154, 154, 154, 154, - 154, 154, 208, 208, 208, 772, 773, 157, 776, 157, - 156, 156, 157, 157, 157, 157, 157, 157, 157, 160, - 160, 160, 160, 160, 160, 160, 161, 161, 161, 161, - 161, 161, 161, 172, 220, 237, 777, 779, 220, 243, - 243, 243, 780, 237, 161, 781, 172, 248, 248, 248, - 248, 248, 248, 248, 249, 249, 249, 249, 249, 249, - 249, 161, 250, 250, 250, 250, 250, 250, 250, 259, - - 259, 259, 249, 251, 251, 251, 251, 251, 251, 251, - 271, 271, 271, 280, 280, 280, 284, 284, 284, 249, - 783, 251, 293, 293, 293, 334, 334, 334, 375, 375, - 375, 386, 386, 386, 387, 387, 387, 784, 251, 787, - 788, 375, 375, 388, 388, 388, 439, 439, 439, 482, - 482, 482, 789, 790, 502, 503, 519, 519, 519, 439, - 439, 602, 482, 482, 502, 503, 553, 553, 553, 519, - 519, 602, 519, 576, 576, 576, 630, 791, 792, 553, - 553, 603, 794, 630, 795, 630, 576, 576, 603, 651, - 603, 603, 796, 797, 798, 799, 651, 801, 651, 802, - - 803, 805, 809, 810, 811, 813, 814, 819, 819, 819, - 820, 820, 820, 821, 822, 823, 823, 764, 763, 762, - 761, 760, 759, 756, 755, 754, 753, 752, 751, 750, - 749, 748, 747, 744, 743, 740, 739, 738, 737, 736, - 735, 733, 732, 731, 730, 729, 727, 725, 721, 720, - 719, 718, 717, 715, 714, 713, 712, 711, 710, 709, - 708, 707, 706, 705, 704, 703, 701, 700, 699, 698, - 697, 696, 695, 694, 693, 691, 690, 689, 688, 687, - 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, - 676, 675, 674, 673, 672, 671, 670, 669, 668, 667, - - 666, 665, 664, 662, 661, 660, 659, 658, 657, 656, - 654, 653, 650, 648, 647, 646, 644, 643, 642, 641, - 640, 639, 638, 637, 636, 635, 634, 633, 632, 629, - 628, 627, 626, 625, 624, 622, 621, 620, 619, 617, - 616, 615, 614, 613, 612, 611, 610, 609, 608, 607, - 606, 605, 604, 599, 597, 596, 595, 594, 593, 589, - 588, 587, 586, 585, 584, 583, 582, 581, 579, 578, - 574, 573, 571, 570, 568, 567, 566, 565, 564, 563, - 562, 558, 557, 556, 554, 552, 551, 550, 549, 548, - 547, 546, 545, 544, 543, 541, 540, 535, 534, 533, - - 532, 530, 529, 527, 526, 525, 524, 523, 521, 520, - 518, 517, 516, 515, 514, 513, 512, 511, 509, 508, - 507, 506, 505, 501, 500, 499, 498, 497, 496, 493, - 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, - 481, 480, 477, 472, 470, 469, 468, 466, 465, 462, - 461, 460, 459, 448, 447, 446, 444, 443, 442, 441, - 440, 437, 435, 434, 433, 431, 430, 429, 428, 426, - 424, 423, 418, 417, 415, 414, 413, 412, 411, 410, - 409, 408, 407, 406, 405, 403, 402, 401, 400, 399, - 398, 397, 395, 394, 393, 392, 391, 390, 389, 385, - - 381, 380, 379, 376, 374, 364, 362, 358, 357, 356, - 355, 353, 352, 350, 345, 344, 343, 342, 341, 340, - 335, 333, 332, 331, 330, 329, 327, 326, 323, 322, - 321, 320, 319, 318, 317, 316, 315, 314, 313, 312, - 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, - 301, 300, 299, 298, 297, 294, 292, 291, 290, 289, - 288, 287, 286, 285, 283, 279, 277, 276, 275, 274, - 270, 269, 268, 267, 266, 265, 264, 263, 262, 258, - 256, 255, 254, 247, 246, 245, 244, 242, 241, 240, - 239, 238, 236, 235, 234, 233, 232, 231, 230, 229, - - 228, 227, 226, 225, 224, 223, 222, 221, 219, 218, - 217, 216, 215, 214, 213, 212, 211, 210, 209, 207, - 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, - 196, 195, 194, 193, 192, 191, 189, 188, 187, 186, - 185, 184, 183, 182, 181, 180, 179, 178, 176, 175, - 174, 173, 171, 170, 169, 168, 167, 165, 150, 149, - 147, 146, 145, 141, 140, 139, 138, 137, 134, 133, - 132, 131, 129, 128, 126, 124, 123, 122, 120, 119, - 118, 116, 115, 113, 112, 111, 110, 109, 108, 105, - 104, 103, 102, 101, 100, 99, 98, 96, 95, 94, - - 93, 92, 91, 89, 88, 84, 80, 46, 44, 38, - 25, 22, 19, 14, 9, 5, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818, 818, - 818, 818, 818, 818, 818, 818, 818, 818, 818 + 39, 37, 45, 122, 37, 45, 126, 47, 39, 21, + 37, 122, 126, 768, 47, 47, 21, 48, 47, 39, + 48, 143, 143, 53, 47, 47, 21, 47, 48, 50, + 49, 70, 70, 50, 49, 48, 72, 72, 49, 144, + 21, 49, 50, 73, 73, 178, 178, 144, 70, 70, + 75, 769, 75, 72, 72, 75, 75, 75, 75, 75, + 75, 75, 108, 136, 98, 163, 128, 73, 98, 98, + + 73, 131, 137, 118, 770, 108, 118, 118, 136, 128, + 118, 128, 118, 145, 149, 137, 149, 131, 131, 163, + 155, 145, 155, 157, 157, 155, 155, 155, 155, 155, + 155, 155, 209, 209, 209, 773, 774, 158, 777, 158, + 157, 157, 158, 158, 158, 158, 158, 158, 158, 161, + 161, 161, 161, 161, 161, 161, 162, 162, 162, 162, + 162, 162, 162, 173, 221, 238, 778, 780, 221, 244, + 244, 244, 781, 238, 162, 782, 173, 249, 249, 249, + 249, 249, 249, 249, 250, 250, 250, 250, 250, 250, + 250, 162, 251, 251, 251, 251, 251, 251, 251, 260, + + 260, 260, 250, 252, 252, 252, 252, 252, 252, 252, + 272, 272, 272, 281, 281, 281, 285, 285, 285, 250, + 784, 252, 294, 294, 294, 335, 335, 335, 376, 376, + 376, 387, 387, 387, 388, 388, 388, 785, 252, 788, + 789, 376, 376, 389, 389, 389, 440, 440, 440, 483, + 483, 483, 790, 791, 503, 504, 520, 520, 520, 440, + 440, 603, 483, 483, 503, 504, 554, 554, 554, 520, + 520, 603, 520, 577, 577, 577, 631, 792, 793, 554, + 554, 604, 795, 631, 796, 631, 577, 577, 604, 652, + 604, 604, 797, 798, 799, 800, 652, 802, 652, 803, + + 804, 806, 810, 811, 812, 814, 815, 820, 820, 820, + 821, 821, 821, 822, 823, 824, 824, 765, 764, 763, + 762, 761, 760, 757, 756, 755, 754, 753, 752, 751, + 750, 749, 748, 745, 744, 741, 740, 739, 738, 737, + 736, 734, 733, 732, 731, 730, 728, 726, 722, 721, + 720, 719, 718, 716, 715, 714, 713, 712, 711, 710, + 709, 708, 707, 706, 705, 704, 702, 701, 700, 699, + 698, 697, 696, 695, 694, 692, 691, 690, 689, 688, + 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, + 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, + + 667, 666, 665, 663, 662, 661, 660, 659, 658, 657, + 655, 654, 651, 649, 648, 647, 645, 644, 643, 642, + 641, 640, 639, 638, 637, 636, 635, 634, 633, 630, + 629, 628, 627, 626, 625, 623, 622, 621, 620, 618, + 617, 616, 615, 614, 613, 612, 611, 610, 609, 608, + 607, 606, 605, 600, 598, 597, 596, 595, 594, 590, + 589, 588, 587, 586, 585, 584, 583, 582, 580, 579, + 575, 574, 572, 571, 569, 568, 567, 566, 565, 564, + 563, 559, 558, 557, 555, 553, 552, 551, 550, 549, + 548, 547, 546, 545, 544, 542, 541, 536, 535, 534, + + 533, 531, 530, 528, 527, 526, 525, 524, 522, 521, + 519, 518, 517, 516, 515, 514, 513, 512, 510, 509, + 508, 507, 506, 502, 501, 500, 499, 498, 497, 494, + 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, + 482, 481, 478, 473, 471, 470, 469, 467, 466, 463, + 462, 461, 460, 449, 448, 447, 445, 444, 443, 442, + 441, 438, 436, 435, 434, 432, 431, 430, 429, 427, + 425, 424, 419, 418, 416, 415, 414, 413, 412, 411, + 410, 409, 408, 407, 406, 404, 403, 402, 401, 400, + 399, 398, 396, 395, 394, 393, 392, 391, 390, 386, + + 382, 381, 380, 377, 375, 365, 363, 359, 358, 357, + 356, 354, 353, 351, 346, 345, 344, 343, 342, 341, + 336, 334, 333, 332, 331, 330, 328, 327, 324, 323, + 322, 321, 320, 319, 318, 317, 316, 315, 314, 313, + 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, + 302, 301, 300, 299, 298, 295, 293, 292, 291, 290, + 289, 288, 287, 286, 284, 280, 278, 277, 276, 275, + 271, 270, 269, 268, 267, 266, 265, 264, 263, 259, + 257, 256, 255, 248, 247, 246, 245, 243, 242, 241, + 240, 239, 237, 236, 235, 234, 233, 232, 231, 230, + + 229, 228, 227, 226, 225, 224, 223, 222, 220, 219, + 218, 217, 216, 215, 214, 213, 212, 211, 210, 208, + 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, + 197, 196, 195, 194, 193, 192, 190, 189, 188, 187, + 186, 185, 184, 183, 182, 181, 180, 179, 177, 176, + 175, 174, 172, 171, 170, 169, 168, 166, 151, 150, + 148, 147, 146, 142, 141, 140, 139, 138, 135, 134, + 133, 132, 130, 129, 127, 125, 124, 123, 121, 120, + 119, 117, 116, 114, 113, 112, 111, 110, 109, 106, + 105, 104, 103, 102, 101, 100, 99, 97, 96, 95, + + 94, 93, 92, 90, 89, 85, 81, 46, 44, 38, + 25, 22, 19, 14, 9, 5, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819, 819, + 819, 819, 819, 819, 819, 819, 819, 819, 819 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[240] = +static yyconst flex_int32_t yy_rule_can_match_eol[241] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -997,8 +997,8 @@ static yyconst flex_int32_t yy_rule_can_match_eol[240] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - }; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -1350,13 +1350,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 819 ) + if ( yy_current_state >= 820 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 818 ); + while ( yy_current_state != 819 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -2072,7 +2072,15 @@ YY_RULE_SETUP {} YY_BREAK case 237: -/* rule 237 can match eol */ +YY_RULE_SETUP +{ + yyextra->error(*yylloc, "Illegal character at fieldname start", yytext, ""); + yyextra->recover(); + return 0; +} + YY_BREAK +case 238: +/* rule 238 can match eol */ YY_RULE_SETUP { } YY_BREAK @@ -2080,11 +2088,11 @@ case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(FIELDS): { yyterminate(); } YY_BREAK -case 238: +case 239: YY_RULE_SETUP { assert(false); return 0; } YY_BREAK -case 239: +case 240: YY_RULE_SETUP ECHO; YY_BREAK @@ -2381,7 +2389,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 819 ) + if ( yy_current_state >= 820 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2410,11 +2418,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 819 ) + if ( yy_current_state >= 820 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 818); + yy_is_jam = (yy_current_state == 819); (void)yyg; return yy_is_jam ? 0 : yy_current_state; diff --git a/chromium/third_party/angle/src/compiler/translator/glslang_tab.cpp b/chromium/third_party/angle/src/compiler/translator/glslang_tab.cpp index 8b4fbd2a231..3337f85321f 100644 --- a/chromium/third_party/angle/src/compiler/translator/glslang_tab.cpp +++ b/chromium/third_party/angle/src/compiler/translator/glslang_tab.cpp @@ -4199,7 +4199,9 @@ yyreduce: case 201: { - if (!context->supportsExtension("GL_OES_EGL_image_external")) { + if (!context->supportsExtension("GL_OES_EGL_image_external") && + !context->supportsExtension("GL_NV_EGL_stream_consumer_external")) + { context->error((yylsp[0]), "unsupported type", "samplerExternalOES"); context->recover(); } diff --git a/chromium/third_party/angle/src/libANGLE/AttributeMap.cpp b/chromium/third_party/angle/src/libANGLE/AttributeMap.cpp index 11d474e9712..2adcc7a26e6 100644 --- a/chromium/third_party/angle/src/libANGLE/AttributeMap.cpp +++ b/chromium/third_party/angle/src/libANGLE/AttributeMap.cpp @@ -29,6 +29,17 @@ EGLAttrib AttributeMap::get(EGLAttrib key, EGLAttrib defaultValue) const return (mAttributes.find(key) != mAttributes.end()) ? iter->second : defaultValue; } +EGLint AttributeMap::getAsInt(EGLAttrib key, EGLint defaultValue) const +{ + return static_cast<EGLint>( + get(static_cast<EGLAttrib>(key), static_cast<EGLAttrib>(defaultValue))); +} + +bool AttributeMap::isEmpty() const +{ + return mAttributes.empty(); +} + AttributeMap::const_iterator AttributeMap::begin() const { return mAttributes.begin(); diff --git a/chromium/third_party/angle/src/libANGLE/AttributeMap.h b/chromium/third_party/angle/src/libANGLE/AttributeMap.h index 1f659d7a02c..874b9eb20db 100644 --- a/chromium/third_party/angle/src/libANGLE/AttributeMap.h +++ b/chromium/third_party/angle/src/libANGLE/AttributeMap.h @@ -23,6 +23,8 @@ class AttributeMap final void insert(EGLAttrib key, EGLAttrib value); bool contains(EGLAttrib key) const; EGLAttrib get(EGLAttrib key, EGLAttrib defaultValue) const; + EGLint getAsInt(EGLAttrib key, EGLint defaultValue) const; + bool isEmpty() const; typedef std::map<EGLAttrib, EGLAttrib>::const_iterator const_iterator; diff --git a/chromium/third_party/angle/src/libANGLE/Buffer.cpp b/chromium/third_party/angle/src/libANGLE/Buffer.cpp index 589735c5a83..3523b32ac75 100644 --- a/chromium/third_party/angle/src/libANGLE/Buffer.cpp +++ b/chromium/third_party/angle/src/libANGLE/Buffer.cpp @@ -10,7 +10,6 @@ #include "libANGLE/Buffer.h" #include "libANGLE/renderer/BufferImpl.h" -#include "libANGLE/renderer/Renderer.h" namespace gl { @@ -193,4 +192,4 @@ Error Buffer::getIndexRange(GLenum type, return Error(GL_NO_ERROR); } -} +} // namespace gl diff --git a/chromium/third_party/angle/src/libANGLE/Caps.cpp b/chromium/third_party/angle/src/libANGLE/Caps.cpp index 9bd3bb2f270..d3d36d3c6db 100644 --- a/chromium/third_party/angle/src/libANGLE/Caps.cpp +++ b/chromium/third_party/angle/src/libANGLE/Caps.cpp @@ -158,7 +158,11 @@ Extensions::Extensions() maxLabelLength(0), noError(false), lossyETCDecode(false), - colorBufferFloat(false) + bindUniformLocation(false), + syncQuery(false), + colorBufferFloat(false), + multisampleCompatibility(false), + framebufferMixedSamples(false) { } @@ -167,69 +171,73 @@ std::vector<std::string> Extensions::getStrings() const std::vector<std::string> extensionStrings; // clang-format off - // | Extension name | Supported flag | Output vector | - InsertExtensionString("GL_OES_element_index_uint", elementIndexUint, &extensionStrings); - InsertExtensionString("GL_OES_packed_depth_stencil", packedDepthStencil, &extensionStrings); - InsertExtensionString("GL_OES_get_program_binary", getProgramBinary, &extensionStrings); - InsertExtensionString("GL_OES_rgb8_rgba8", rgb8rgba8, &extensionStrings); - InsertExtensionString("GL_EXT_texture_format_BGRA8888", textureFormatBGRA8888, &extensionStrings); - InsertExtensionString("GL_EXT_read_format_bgra", readFormatBGRA, &extensionStrings); - InsertExtensionString("GL_NV_pixel_buffer_object", pixelBufferObject, &extensionStrings); - InsertExtensionString("GL_OES_mapbuffer", mapBuffer, &extensionStrings); - InsertExtensionString("GL_EXT_map_buffer_range", mapBufferRange, &extensionStrings); - InsertExtensionString("GL_EXT_color_buffer_half_float", colorBufferHalfFloat, &extensionStrings); - InsertExtensionString("GL_OES_texture_half_float", textureHalfFloat, &extensionStrings); - InsertExtensionString("GL_OES_texture_half_float_linear", textureHalfFloatLinear, &extensionStrings); - InsertExtensionString("GL_OES_texture_float", textureFloat, &extensionStrings); - InsertExtensionString("GL_OES_texture_float_linear", textureFloatLinear, &extensionStrings); - InsertExtensionString("GL_EXT_texture_rg", textureRG, &extensionStrings); - InsertExtensionString("GL_EXT_texture_compression_dxt1", textureCompressionDXT1, &extensionStrings); - InsertExtensionString("GL_ANGLE_texture_compression_dxt3", textureCompressionDXT3, &extensionStrings); - InsertExtensionString("GL_ANGLE_texture_compression_dxt5", textureCompressionDXT5, &extensionStrings); - InsertExtensionString("GL_KHR_texture_compression_astc_hdr", textureCompressionASTCHDR, &extensionStrings); - InsertExtensionString("GL_KHR_texture_compression_astc_ldr", textureCompressionASTCLDR, &extensionStrings); - InsertExtensionString("GL_OES_compressed_ETC1_RGB8_texture", compressedETC1RGB8Texture, &extensionStrings); - InsertExtensionString("GL_EXT_sRGB", sRGB, &extensionStrings); - InsertExtensionString("GL_ANGLE_depth_texture", depthTextures, &extensionStrings); - InsertExtensionString("GL_OES_depth32", depth32, &extensionStrings); - InsertExtensionString("GL_EXT_texture_storage", textureStorage, &extensionStrings); - InsertExtensionString("GL_OES_texture_npot", textureNPOT, &extensionStrings); - InsertExtensionString("GL_EXT_draw_buffers", drawBuffers, &extensionStrings); - InsertExtensionString("GL_EXT_texture_filter_anisotropic", textureFilterAnisotropic, &extensionStrings); - InsertExtensionString("GL_EXT_occlusion_query_boolean", occlusionQueryBoolean, &extensionStrings); - InsertExtensionString("GL_NV_fence", fence, &extensionStrings); - InsertExtensionString("GL_ANGLE_timer_query", timerQuery, &extensionStrings); - InsertExtensionString("GL_EXT_disjoint_timer_query", disjointTimerQuery, &extensionStrings); - InsertExtensionString("GL_EXT_robustness", robustness, &extensionStrings); - InsertExtensionString("GL_EXT_blend_minmax", blendMinMax, &extensionStrings); - InsertExtensionString("GL_ANGLE_framebuffer_blit", framebufferBlit, &extensionStrings); - InsertExtensionString("GL_ANGLE_framebuffer_multisample", framebufferMultisample, &extensionStrings); - InsertExtensionString("GL_ANGLE_instanced_arrays", instancedArrays, &extensionStrings); - InsertExtensionString("GL_ANGLE_pack_reverse_row_order", packReverseRowOrder, &extensionStrings); - InsertExtensionString("GL_OES_standard_derivatives", standardDerivatives, &extensionStrings); - InsertExtensionString("GL_EXT_shader_texture_lod", shaderTextureLOD, &extensionStrings); - InsertExtensionString("GL_NV_shader_framebuffer_fetch", NVshaderFramebufferFetch, &extensionStrings); - InsertExtensionString("GL_ARM_shader_framebuffer_fetch", ARMshaderFramebufferFetch, &extensionStrings); - InsertExtensionString("GL_EXT_shader_framebuffer_fetch", shaderFramebufferFetch, &extensionStrings); - InsertExtensionString("GL_EXT_frag_depth", fragDepth, &extensionStrings); - InsertExtensionString("GL_ANGLE_texture_usage", textureUsage, &extensionStrings); - InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings); - InsertExtensionString("GL_OES_fbo_render_mipmap", fboRenderMipmap, &extensionStrings); - InsertExtensionString("GL_EXT_discard_framebuffer", discardFramebuffer, &extensionStrings); - InsertExtensionString("GL_EXT_debug_marker", debugMarker, &extensionStrings); - InsertExtensionString("GL_OES_EGL_image", eglImage, &extensionStrings); - InsertExtensionString("GL_OES_EGL_image_external", eglImageExternal, &extensionStrings); - InsertExtensionString("GL_OES_EGL_image_external_essl3", eglImageExternalEssl3, &extensionStrings); - InsertExtensionString("GL_NV_EGL_stream_consumer_external", eglStreamConsumerExternal, &extensionStrings); - InsertExtensionString("GL_EXT_unpack_subimage", unpackSubimage, &extensionStrings); - InsertExtensionString("GL_NV_pack_subimage", packSubimage, &extensionStrings); - InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings); - InsertExtensionString("GL_OES_vertex_array_object", vertexArrayObject, &extensionStrings); - InsertExtensionString("GL_KHR_debug", debug, &extensionStrings); + // | Extension name | Supported flag | Output vector | + InsertExtensionString("GL_OES_element_index_uint", elementIndexUint, &extensionStrings); + InsertExtensionString("GL_OES_packed_depth_stencil", packedDepthStencil, &extensionStrings); + InsertExtensionString("GL_OES_get_program_binary", getProgramBinary, &extensionStrings); + InsertExtensionString("GL_OES_rgb8_rgba8", rgb8rgba8, &extensionStrings); + InsertExtensionString("GL_EXT_texture_format_BGRA8888", textureFormatBGRA8888, &extensionStrings); + InsertExtensionString("GL_EXT_read_format_bgra", readFormatBGRA, &extensionStrings); + InsertExtensionString("GL_NV_pixel_buffer_object", pixelBufferObject, &extensionStrings); + InsertExtensionString("GL_OES_mapbuffer", mapBuffer, &extensionStrings); + InsertExtensionString("GL_EXT_map_buffer_range", mapBufferRange, &extensionStrings); + InsertExtensionString("GL_EXT_color_buffer_half_float", colorBufferHalfFloat, &extensionStrings); + InsertExtensionString("GL_OES_texture_half_float", textureHalfFloat, &extensionStrings); + InsertExtensionString("GL_OES_texture_half_float_linear", textureHalfFloatLinear, &extensionStrings); + InsertExtensionString("GL_OES_texture_float", textureFloat, &extensionStrings); + InsertExtensionString("GL_OES_texture_float_linear", textureFloatLinear, &extensionStrings); + InsertExtensionString("GL_EXT_texture_rg", textureRG, &extensionStrings); + InsertExtensionString("GL_EXT_texture_compression_dxt1", textureCompressionDXT1, &extensionStrings); + InsertExtensionString("GL_ANGLE_texture_compression_dxt3", textureCompressionDXT3, &extensionStrings); + InsertExtensionString("GL_ANGLE_texture_compression_dxt5", textureCompressionDXT5, &extensionStrings); + InsertExtensionString("GL_KHR_texture_compression_astc_hdr", textureCompressionASTCHDR, &extensionStrings); + InsertExtensionString("GL_KHR_texture_compression_astc_ldr", textureCompressionASTCLDR, &extensionStrings); + InsertExtensionString("GL_OES_compressed_ETC1_RGB8_texture", compressedETC1RGB8Texture, &extensionStrings); + InsertExtensionString("GL_EXT_sRGB", sRGB, &extensionStrings); + InsertExtensionString("GL_ANGLE_depth_texture", depthTextures, &extensionStrings); + InsertExtensionString("GL_OES_depth32", depth32, &extensionStrings); + InsertExtensionString("GL_EXT_texture_storage", textureStorage, &extensionStrings); + InsertExtensionString("GL_OES_texture_npot", textureNPOT, &extensionStrings); + InsertExtensionString("GL_EXT_draw_buffers", drawBuffers, &extensionStrings); + InsertExtensionString("GL_EXT_texture_filter_anisotropic", textureFilterAnisotropic, &extensionStrings); + InsertExtensionString("GL_EXT_occlusion_query_boolean", occlusionQueryBoolean, &extensionStrings); + InsertExtensionString("GL_NV_fence", fence, &extensionStrings); + InsertExtensionString("GL_ANGLE_timer_query", timerQuery, &extensionStrings); + InsertExtensionString("GL_EXT_disjoint_timer_query", disjointTimerQuery, &extensionStrings); + InsertExtensionString("GL_EXT_robustness", robustness, &extensionStrings); + InsertExtensionString("GL_EXT_blend_minmax", blendMinMax, &extensionStrings); + InsertExtensionString("GL_ANGLE_framebuffer_blit", framebufferBlit, &extensionStrings); + InsertExtensionString("GL_ANGLE_framebuffer_multisample", framebufferMultisample, &extensionStrings); + InsertExtensionString("GL_ANGLE_instanced_arrays", instancedArrays, &extensionStrings); + InsertExtensionString("GL_ANGLE_pack_reverse_row_order", packReverseRowOrder, &extensionStrings); + InsertExtensionString("GL_OES_standard_derivatives", standardDerivatives, &extensionStrings); + InsertExtensionString("GL_EXT_shader_texture_lod", shaderTextureLOD, &extensionStrings); + InsertExtensionString("GL_NV_shader_framebuffer_fetch", NVshaderFramebufferFetch, &extensionStrings); + InsertExtensionString("GL_ARM_shader_framebuffer_fetch", ARMshaderFramebufferFetch, &extensionStrings); + InsertExtensionString("GL_EXT_shader_framebuffer_fetch", shaderFramebufferFetch, &extensionStrings); + InsertExtensionString("GL_EXT_frag_depth", fragDepth, &extensionStrings); + InsertExtensionString("GL_ANGLE_texture_usage", textureUsage, &extensionStrings); + InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings); + InsertExtensionString("GL_OES_fbo_render_mipmap", fboRenderMipmap, &extensionStrings); + InsertExtensionString("GL_EXT_discard_framebuffer", discardFramebuffer, &extensionStrings); + InsertExtensionString("GL_EXT_debug_marker", debugMarker, &extensionStrings); + InsertExtensionString("GL_OES_EGL_image", eglImage, &extensionStrings); + InsertExtensionString("GL_OES_EGL_image_external", eglImageExternal, &extensionStrings); + InsertExtensionString("GL_OES_EGL_image_external_essl3", eglImageExternalEssl3, &extensionStrings); + InsertExtensionString("GL_NV_EGL_stream_consumer_external", eglStreamConsumerExternal, &extensionStrings); + InsertExtensionString("GL_EXT_unpack_subimage", unpackSubimage, &extensionStrings); + InsertExtensionString("GL_NV_pack_subimage", packSubimage, &extensionStrings); + InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings); + InsertExtensionString("GL_OES_vertex_array_object", vertexArrayObject, &extensionStrings); + InsertExtensionString("GL_KHR_debug", debug, &extensionStrings); // TODO(jmadill): Enable this when complete. //InsertExtensionString("GL_KHR_no_error", noError, &extensionStrings); - InsertExtensionString("GL_ANGLE_lossy_etc_decode", lossyETCDecode, &extensionStrings); + InsertExtensionString("GL_ANGLE_lossy_etc_decode", lossyETCDecode, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_bind_uniform_location", bindUniformLocation, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_sync_query", syncQuery, &extensionStrings); + InsertExtensionString("GL_EXT_multisample_compatibility", multisampleCompatibility, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_framebuffer_mixed_samples", framebufferMixedSamples, &extensionStrings); // clang-format on return extensionStrings; @@ -640,7 +648,8 @@ DisplayExtensions::DisplayExtensions() createContextNoError(false), stream(false), streamConsumerGLTexture(false), - streamConsumerGLTextureYUV(false) + streamConsumerGLTextureYUV(false), + streamProducerD3DTextureNV12(false) { } @@ -673,6 +682,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const InsertExtensionString("EGL_KHR_stream_consumer_gltexture", streamConsumerGLTexture, &extensionStrings); InsertExtensionString("EGL_NV_stream_consumer_gltexture_yuv", streamConsumerGLTextureYUV, &extensionStrings); InsertExtensionString("EGL_ANGLE_flexible_surface_compatibility", flexibleSurfaceCompatibility, &extensionStrings); + InsertExtensionString("EGL_ANGLE_stream_producer_d3d_texture_nv12", streamProducerD3DTextureNV12, &extensionStrings); // TODO(jmadill): Enable this when complete. //InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings); // clang-format on diff --git a/chromium/third_party/angle/src/libANGLE/Caps.h b/chromium/third_party/angle/src/libANGLE/Caps.h index 186d668986d..9088dad1e47 100644 --- a/chromium/third_party/angle/src/libANGLE/Caps.h +++ b/chromium/third_party/angle/src/libANGLE/Caps.h @@ -281,10 +281,23 @@ struct Extensions // GL_ANGLE_lossy_etc_decode bool lossyETCDecode; + // GL_CHROMIUM_bind_uniform_location + bool bindUniformLocation; + + // GL_CHROMIUM_sync_query + bool syncQuery; + // ES3 Extension support // GL_EXT_color_buffer_float bool colorBufferFloat; + + // GL_EXT_multisample_compatibility. + // written against ES 3.1 but can apply to earlier versions. + bool multisampleCompatibility; + + // GL_CHROMIUM_framebuffer_mixed_samples + bool framebufferMixedSamples; }; struct Limitations @@ -494,6 +507,9 @@ struct DisplayExtensions // EGL_NV_stream_consumer_gltexture_yuv bool streamConsumerGLTextureYUV; + + // EGL_ANGLE_stream_producer_d3d_texture_nv12 + bool streamProducerD3DTextureNV12; }; struct DeviceExtensions diff --git a/chromium/third_party/angle/src/libANGLE/Compiler.cpp b/chromium/third_party/angle/src/libANGLE/Compiler.cpp index 348c41bef33..15e094ea35a 100644 --- a/chromium/third_party/angle/src/libANGLE/Compiler.cpp +++ b/chromium/third_party/angle/src/libANGLE/Compiler.cpp @@ -9,9 +9,9 @@ #include "libANGLE/Compiler.h" #include "common/debug.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/renderer/CompilerImpl.h" -#include "libANGLE/renderer/ImplFactory.h" +#include "libANGLE/renderer/GLImplFactory.h" namespace gl { @@ -25,7 +25,7 @@ size_t activeCompilerHandles = 0; } // anonymous namespace -Compiler::Compiler(rx::ImplFactory *implFactory, const gl::Data &data) +Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &data) : mImplementation(implFactory->createCompiler()), mSpec(data.clientVersion > 2 ? SH_GLES3_SPEC : SH_GLES2_SPEC), mOutputType(mImplementation->getTranslatorOutputType()), @@ -52,6 +52,7 @@ Compiler::Compiler(rx::ImplFactory *implFactory, const gl::Data &data) mResources.EXT_shader_texture_lod = extensions.shaderTextureLOD; // TODO: disabled until the extension is actually supported. mResources.OES_EGL_image_external = 0; + mResources.NV_EGL_stream_consumer_external = extensions.eglStreamConsumerExternal; // TODO: use shader precision caps to determine if high precision is supported? mResources.FragmentPrecisionHigh = 1; mResources.EXT_frag_depth = extensions.fragDepth; diff --git a/chromium/third_party/angle/src/libANGLE/Compiler.h b/chromium/third_party/angle/src/libANGLE/Compiler.h index 8634e39a453..d254a17918e 100644 --- a/chromium/third_party/angle/src/libANGLE/Compiler.h +++ b/chromium/third_party/angle/src/libANGLE/Compiler.h @@ -16,17 +16,17 @@ namespace rx { class CompilerImpl; -class ImplFactory; +class GLImplFactory; } namespace gl { -struct Data; +struct ContextState; class Compiler final : angle::NonCopyable { public: - Compiler(rx::ImplFactory *implFactory, const Data &data); + Compiler(rx::GLImplFactory *implFactory, const ContextState &data); ~Compiler(); Error release(); diff --git a/chromium/third_party/angle/src/libANGLE/Context.cpp b/chromium/third_party/angle/src/libANGLE/Context.cpp index dcb6b21bb1b..f662f48e6a8 100644 --- a/chromium/third_party/angle/src/libANGLE/Context.cpp +++ b/chromium/third_party/angle/src/libANGLE/Context.cpp @@ -31,7 +31,8 @@ #include "libANGLE/VertexArray.h" #include "libANGLE/formatutils.h" #include "libANGLE/validationES.h" -#include "libANGLE/renderer/Renderer.h" +#include "libANGLE/renderer/ContextImpl.h" +#include "libANGLE/renderer/EGLImplFactory.h" namespace { @@ -121,9 +122,9 @@ bool GetNoError(const egl::AttributeMap &attribs) namespace gl { -Context::Context(const egl::Config *config, +Context::Context(rx::EGLImplFactory *implFactory, + const egl::Config *config, const Context *shareContext, - rx::Renderer *renderer, const egl::AttributeMap &attribs) : ValidationContext(GetClientVersion(attribs), mState, @@ -133,8 +134,8 @@ Context::Context(const egl::Config *config, nullptr, mLimitations, GetNoError(attribs)), + mImplementation(implFactory->createContext(getData())), mCompiler(nullptr), - mRenderer(renderer), mClientVersion(GetClientVersion(attribs)), mConfig(config), mClientType(EGL_OPENGL_ES_API), @@ -154,14 +155,14 @@ Context::Context(const egl::Config *config, mFenceNVHandleAllocator.setBaseHandle(0); - if (shareContext != NULL) + if (shareContext != nullptr) { mResourceManager = shareContext->mResourceManager; mResourceManager->addRef(); } else { - mResourceManager = new ResourceManager(mRenderer); + mResourceManager = new ResourceManager(); } mData.resourceManager = mResourceManager; @@ -172,22 +173,29 @@ Context::Context(const egl::Config *config, // In order that access to these initial textures not be lost, they are treated as texture // objects all of whose names are 0. - Texture *zeroTexture2D = new Texture(mRenderer->createTexture(GL_TEXTURE_2D), 0, GL_TEXTURE_2D); + Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, GL_TEXTURE_2D); mZeroTextures[GL_TEXTURE_2D].set(zeroTexture2D); - Texture *zeroTextureCube = new Texture(mRenderer->createTexture(GL_TEXTURE_CUBE_MAP), 0, GL_TEXTURE_CUBE_MAP); + Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, GL_TEXTURE_CUBE_MAP); mZeroTextures[GL_TEXTURE_CUBE_MAP].set(zeroTextureCube); if (mClientVersion >= 3) { // TODO: These could also be enabled via extension - Texture *zeroTexture3D = new Texture(mRenderer->createTexture(GL_TEXTURE_3D), 0, GL_TEXTURE_3D); + Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, GL_TEXTURE_3D); mZeroTextures[GL_TEXTURE_3D].set(zeroTexture3D); - Texture *zeroTexture2DArray = new Texture(mRenderer->createTexture(GL_TEXTURE_2D_ARRAY), 0, GL_TEXTURE_2D_ARRAY); + Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, GL_TEXTURE_2D_ARRAY); mZeroTextures[GL_TEXTURE_2D_ARRAY].set(zeroTexture2DArray); } + if (mExtensions.eglImageExternal || mExtensions.eglStreamConsumerExternal) + { + Texture *zeroTextureExternal = + new Texture(mImplementation.get(), 0, GL_TEXTURE_EXTERNAL_OES); + mZeroTextures[GL_TEXTURE_EXTERNAL_OES].set(zeroTextureExternal); + } + mState.initializeZeroTextures(mZeroTextures); bindVertexArray(0); @@ -216,7 +224,7 @@ Context::Context(const egl::Config *config, bindTransformFeedback(0); } - mCompiler = new Compiler(mRenderer, getData()); + mCompiler = new Compiler(mImplementation.get(), getData()); // Initialize dirty bit masks // TODO(jmadill): additional ES3 state @@ -226,6 +234,7 @@ Context::Context(const egl::Config *config, mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_IMAGES); mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_ROWS); mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_PIXELS); + mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); // No dirty objects. // Readpixels uses the pack state and read FBO @@ -234,6 +243,7 @@ Context::Context(const egl::Config *config, mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_ROW_LENGTH); mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_SKIP_ROWS); mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_SKIP_PIXELS); + mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); @@ -253,6 +263,8 @@ Context::Context(const egl::Config *config, mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); + + handleError(mImplementation->initialize()); } Context::~Context() @@ -354,7 +366,7 @@ void Context::makeCurrent(egl::Surface *surface) } // Notify the renderer of a context switch - mRenderer->onMakeCurrent(getData()); + mImplementation->onMakeCurrent(getData()); } void Context::releaseSurface() @@ -399,12 +411,13 @@ GLuint Context::createBuffer() GLuint Context::createProgram() { - return mResourceManager->createProgram(); + return mResourceManager->createProgram(mImplementation.get()); } GLuint Context::createShader(GLenum type) { - return mResourceManager->createShader(mRenderer->getRendererLimitations(), type); + return mResourceManager->createShader(mImplementation.get(), + mImplementation->getNativeLimitations(), type); } GLuint Context::createTexture() @@ -419,7 +432,7 @@ GLuint Context::createRenderbuffer() GLsync Context::createFenceSync() { - GLuint handle = mResourceManager->createFenceSync(); + GLuint handle = mResourceManager->createFenceSync(mImplementation.get()); return reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); } @@ -457,7 +470,7 @@ GLuint Context::createFenceNV() { GLuint handle = mFenceNVHandleAllocator.allocate(); - mFenceNVMap[handle] = new FenceNV(mRenderer->createFenceNV()); + mFenceNVMap[handle] = new FenceNV(mImplementation->createFenceNV()); return handle; } @@ -694,13 +707,13 @@ bool Context::isSampler(GLuint samplerName) const void Context::bindArrayBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setArrayBufferBinding(buffer); } void Context::bindElementArrayBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.getVertexArray()->setElementArrayBuffer(buffer); } @@ -714,7 +727,7 @@ void Context::bindTexture(GLenum target, GLuint handle) } else { - texture = mResourceManager->checkTextureAllocation(handle, target); + texture = mResourceManager->checkTextureAllocation(mImplementation.get(), handle, target); } ASSERT(texture); @@ -735,7 +748,8 @@ void Context::bindDrawFramebuffer(GLuint framebufferHandle) void Context::bindRenderbuffer(GLuint renderbufferHandle) { - Renderbuffer *renderbuffer = mResourceManager->checkRenderbufferAllocation(renderbufferHandle); + Renderbuffer *renderbuffer = + mResourceManager->checkRenderbufferAllocation(mImplementation.get(), renderbufferHandle); mState.setRenderbufferBinding(renderbuffer); } @@ -748,13 +762,14 @@ void Context::bindVertexArray(GLuint vertexArrayHandle) void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) { ASSERT(textureUnit < mCaps.maxCombinedTextureImageUnits); - Sampler *sampler = mResourceManager->checkSamplerAllocation(samplerHandle); + Sampler *sampler = + mResourceManager->checkSamplerAllocation(mImplementation.get(), samplerHandle); mState.setSamplerBinding(textureUnit, sampler); } void Context::bindGenericUniformBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setGenericUniformBufferBinding(buffer); } @@ -763,13 +778,13 @@ void Context::bindIndexedUniformBuffer(GLuint bufferHandle, GLintptr offset, GLsizeiptr size) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setIndexedUniformBufferBinding(index, buffer, offset, size); } void Context::bindGenericTransformFeedbackBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.getCurrentTransformFeedback()->bindGenericBuffer(buffer); } @@ -778,31 +793,31 @@ void Context::bindIndexedTransformFeedbackBuffer(GLuint bufferHandle, GLintptr offset, GLsizeiptr size) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.getCurrentTransformFeedback()->bindIndexedBuffer(index, buffer, offset, size); } void Context::bindCopyReadBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setCopyReadBufferBinding(buffer); } void Context::bindCopyWriteBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setCopyWriteBufferBinding(buffer); } void Context::bindPixelPackBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setPixelPackBufferBinding(buffer); } void Context::bindPixelUnpackBuffer(GLuint bufferHandle) { - Buffer *buffer = mResourceManager->checkBufferAllocation(bufferHandle); + Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); mState.setPixelUnpackBufferBinding(buffer); } @@ -939,7 +954,7 @@ Query *Context::getQuery(unsigned int handle, bool create, GLenum type) { if (!query->second && create) { - query->second = new Query(mRenderer->createQuery(type), handle); + query->second = new Query(mImplementation->createQuery(type), handle); query->second->addRef(); } return query->second; @@ -954,7 +969,7 @@ Query *Context::getQuery(GLuint handle) const Texture *Context::getTargetTexture(GLenum target) const { - ASSERT(ValidTextureTarget(this, target)); + ASSERT(ValidTextureTarget(this, target) || ValidTextureExternalTarget(this, target)); return mState.getTargetTexture(target); } @@ -1097,7 +1112,7 @@ void Context::getIntegerv(GLenum pname, GLint *params) // GL_EXT_disjoint_timer_query case GL_GPU_DISJOINT_EXT: - *params = mRenderer->getGPUDisjoint(); + *params = mImplementation->getGPUDisjoint(); break; default: @@ -1130,7 +1145,7 @@ void Context::getInteger64v(GLenum pname, GLint64 *params) // GL_EXT_disjoint_timer_query case GL_TIMESTAMP_EXT: - *params = mRenderer->getTimestamp(); + *params = mImplementation->getTimestamp(); break; default: UNREACHABLE(); @@ -1368,6 +1383,14 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu *type = GL_INT; *numParams = 1; return true; + case GL_COVERAGE_MODULATION_CHROMIUM: + if (!mExtensions.framebufferMixedSamples) + { + return false; + } + *type = GL_INT; + *numParams = 1; + return true; } if (mExtensions.debug) @@ -1393,6 +1416,18 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu } } + if (mExtensions.multisampleCompatibility) + { + switch (pname) + { + case GL_MULTISAMPLE_EXT: + case GL_SAMPLE_ALPHA_TO_ONE_EXT: + *type = GL_BOOL; + *numParams = 1; + return true; + } + } + // Check for ES3.0+ parameter names which are also exposed as ES2 extensions switch (pname) { @@ -1546,29 +1581,19 @@ bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned Error Context::drawArrays(GLenum mode, GLint first, GLsizei count) { syncRendererState(); - Error error = mRenderer->drawArrays(getData(), mode, first, count); - if (error.isError()) - { - return error; - } - + ANGLE_TRY(mImplementation->drawArrays(mode, first, count)); MarkTransformFeedbackBufferUsage(mState.getCurrentTransformFeedback()); - return Error(GL_NO_ERROR); + return NoError(); } Error Context::drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) { syncRendererState(); - Error error = mRenderer->drawArraysInstanced(getData(), mode, first, count, instanceCount); - if (error.isError()) - { - return error; - } - + ANGLE_TRY(mImplementation->drawArraysInstanced(mode, first, count, instanceCount)); MarkTransformFeedbackBufferUsage(mState.getCurrentTransformFeedback()); - return Error(GL_NO_ERROR); + return NoError(); } Error Context::drawElements(GLenum mode, @@ -1578,7 +1603,7 @@ Error Context::drawElements(GLenum mode, const IndexRange &indexRange) { syncRendererState(); - return mRenderer->drawElements(getData(), mode, count, type, indices, indexRange); + return mImplementation->drawElements(mode, count, type, indices, indexRange); } Error Context::drawElementsInstanced(GLenum mode, @@ -1589,8 +1614,8 @@ Error Context::drawElementsInstanced(GLenum mode, const IndexRange &indexRange) { syncRendererState(); - return mRenderer->drawElementsInstanced(getData(), mode, count, type, indices, instances, - indexRange); + return mImplementation->drawElementsInstanced(mode, count, type, indices, instances, + indexRange); } Error Context::drawRangeElements(GLenum mode, @@ -1602,39 +1627,52 @@ Error Context::drawRangeElements(GLenum mode, const IndexRange &indexRange) { syncRendererState(); - return mRenderer->drawRangeElements(getData(), mode, start, end, count, type, indices, - indexRange); + return mImplementation->drawRangeElements(mode, start, end, count, type, indices, indexRange); } Error Context::flush() { - return mRenderer->flush(); + return mImplementation->flush(); } Error Context::finish() { - return mRenderer->finish(); + return mImplementation->finish(); } void Context::insertEventMarker(GLsizei length, const char *marker) { - ASSERT(mRenderer); - mRenderer->insertEventMarker(length, marker); + ASSERT(mImplementation); + mImplementation->insertEventMarker(length, marker); } void Context::pushGroupMarker(GLsizei length, const char *marker) { - ASSERT(mRenderer); - mRenderer->pushGroupMarker(length, marker); + ASSERT(mImplementation); + mImplementation->pushGroupMarker(length, marker); } void Context::popGroupMarker() { - ASSERT(mRenderer); - mRenderer->popGroupMarker(); + ASSERT(mImplementation); + mImplementation->popGroupMarker(); } -void Context::recordError(const Error &error) +void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) +{ + Program *programObject = getProgram(program); + ASSERT(programObject); + + programObject->bindUniformLocation(location, name); +} + +void Context::setCoverageModulation(GLenum components) +{ + mState.setCoverageModulation(components); +} + + +void Context::handleError(const Error &error) { if (error.isError()) { @@ -1672,9 +1710,9 @@ GLenum Context::getResetStatus() { // mResetStatus will be set by the markContextLost callback // in the case a notification is sent - if (mRenderer->testDeviceLost()) + if (mImplementation->testDeviceLost()) { - mRenderer->notifyDeviceLost(); + mImplementation->notifyDeviceLost(); } } @@ -1684,7 +1722,7 @@ GLenum Context::getResetStatus() { ASSERT(mContextLost); - if (mRenderer->testDeviceResettable()) + if (mImplementation->testDeviceResettable()) { mResetStatus = GL_NO_ERROR; } @@ -1731,7 +1769,8 @@ VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) VertexArray *vertexArray = getVertexArray(vertexArrayHandle); if (!vertexArray) { - vertexArray = new VertexArray(mRenderer, vertexArrayHandle, MAX_VERTEX_ATTRIBS); + vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle, MAX_VERTEX_ATTRIBS); + mVertexArrayMap[vertexArrayHandle] = vertexArray; } @@ -1744,7 +1783,8 @@ TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFee TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); if (!transformFeedback) { - transformFeedback = new TransformFeedback(mRenderer, transformFeedbackHandle, mCaps); + transformFeedback = + new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mCaps); transformFeedback->addRef(); mTransformFeedbackMap[transformFeedbackHandle] = transformFeedback; } @@ -1759,7 +1799,7 @@ Framebuffer *Context::checkFramebufferAllocation(GLuint framebuffer) bool neverCreated = framebufferIt == mFramebufferMap.end(); if (neverCreated || framebufferIt->second == nullptr) { - Framebuffer *newFBO = new Framebuffer(mCaps, mRenderer, framebuffer); + Framebuffer *newFBO = new Framebuffer(mCaps, mImplementation.get(), framebuffer); if (neverCreated) { mFramebufferHandleAllocator.reserve(framebuffer); @@ -1848,7 +1888,17 @@ void Context::detachVertexArray(GLuint vertexArray) void Context::detachTransformFeedback(GLuint transformFeedback) { - mState.detachTransformFeedback(transformFeedback); + // Transform feedback detachment is handled by Context, because 0 is a valid + // transform feedback, and a pointer to it must be passed from Context to State at + // binding time. + + // The OpenGL specification doesn't mention what should happen when the currently bound + // transform feedback object is deleted. Since it is a container object, we treat it like + // VAOs and FBOs and set the current bound transform feedback back to 0. + if (mState.removeTransformFeedbackBinding(transformFeedback)) + { + bindTransformFeedback(0); + } } void Context::detachSampler(GLuint sampler) @@ -1863,7 +1913,7 @@ void Context::setVertexAttribDivisor(GLuint index, GLuint divisor) void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) { - mResourceManager->checkSamplerAllocation(sampler); + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); Sampler *samplerObject = getSampler(sampler); ASSERT(samplerObject); @@ -1888,7 +1938,7 @@ void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) { - mResourceManager->checkSamplerAllocation(sampler); + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); Sampler *samplerObject = getSampler(sampler); ASSERT(samplerObject); @@ -1913,7 +1963,7 @@ void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname) { - mResourceManager->checkSamplerAllocation(sampler); + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); Sampler *samplerObject = getSampler(sampler); ASSERT(samplerObject); @@ -1938,7 +1988,7 @@ GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname) GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname) { - mResourceManager->checkSamplerAllocation(sampler); + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); Sampler *samplerObject = getSampler(sampler); ASSERT(samplerObject); @@ -1974,7 +2024,7 @@ void Context::initRendererString() { std::ostringstream rendererString; rendererString << "ANGLE ("; - rendererString << mRenderer->getRendererDescription(); + rendererString << mImplementation->getRendererDescription(); rendererString << ")"; mRendererString = MakeStaticString(rendererString.str()); @@ -2032,11 +2082,11 @@ bool Context::hasActiveTransformFeedback(GLuint program) const void Context::initCaps(GLuint clientVersion) { - mCaps = mRenderer->getRendererCaps(); + mCaps = mImplementation->getNativeCaps(); - mExtensions = mRenderer->getRendererExtensions(); + mExtensions = mImplementation->getNativeExtensions(); - mLimitations = mRenderer->getRendererLimitations(); + mLimitations = mImplementation->getNativeLimitations(); if (clientVersion < 3) { @@ -2066,7 +2116,7 @@ void Context::initCaps(GLuint clientVersion) mCaps.compressedTextureFormats.clear(); - const TextureCapsMap &rendererFormats = mRenderer->getRendererTextureCaps(); + const TextureCapsMap &rendererFormats = mImplementation->getNativeTextureCaps(); for (TextureCapsMap::const_iterator i = rendererFormats.begin(); i != rendererFormats.end(); i++) { GLenum format = i->first; @@ -2102,7 +2152,7 @@ void Context::initCaps(GLuint clientVersion) void Context::syncRendererState() { const State::DirtyBits &dirtyBits = mState.getDirtyBits(); - mRenderer->syncState(mState, dirtyBits); + mImplementation->syncState(mState, dirtyBits); mState.clearDirtyBits(); mState.syncDirtyObjects(); } @@ -2111,7 +2161,7 @@ void Context::syncRendererState(const State::DirtyBits &bitMask, const State::DirtyObjects &objectMask) { const State::DirtyBits &dirtyBits = (mState.getDirtyBits() & bitMask); - mRenderer->syncState(mState, dirtyBits); + mImplementation->syncState(mState, dirtyBits); mState.clearDirtyBits(dirtyBits); mState.syncDirtyObjects(objectMask); @@ -2128,9 +2178,6 @@ void Context::blitFramebuffer(GLint srcX0, GLbitfield mask, GLenum filter) { - Framebuffer *readFramebuffer = mState.getReadFramebuffer(); - ASSERT(readFramebuffer); - Framebuffer *drawFramebuffer = mState.getDrawFramebuffer(); ASSERT(drawFramebuffer); @@ -2139,56 +2186,34 @@ void Context::blitFramebuffer(GLint srcX0, syncStateForBlit(); - Error error = drawFramebuffer->blit(mState, srcArea, dstArea, mask, filter, readFramebuffer); - if (error.isError()) - { - recordError(error); - return; - } + handleError(drawFramebuffer->blit(mImplementation.get(), srcArea, dstArea, mask, filter)); } void Context::clear(GLbitfield mask) { syncStateForClear(); - - Error error = mState.getDrawFramebuffer()->clear(mData, mask); - if (error.isError()) - { - recordError(error); - } + handleError(mState.getDrawFramebuffer()->clear(mImplementation.get(), mask)); } void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) { syncStateForClear(); - - Error error = mState.getDrawFramebuffer()->clearBufferfv(mData, buffer, drawbuffer, values); - if (error.isError()) - { - recordError(error); - } + handleError(mState.getDrawFramebuffer()->clearBufferfv(mImplementation.get(), buffer, + drawbuffer, values)); } void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) { syncStateForClear(); - - Error error = mState.getDrawFramebuffer()->clearBufferuiv(mData, buffer, drawbuffer, values); - if (error.isError()) - { - recordError(error); - } + handleError(mState.getDrawFramebuffer()->clearBufferuiv(mImplementation.get(), buffer, + drawbuffer, values)); } void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) { syncStateForClear(); - - Error error = mState.getDrawFramebuffer()->clearBufferiv(mData, buffer, drawbuffer, values); - if (error.isError()) - { - recordError(error); - } + handleError(mState.getDrawFramebuffer()->clearBufferiv(mImplementation.get(), buffer, + drawbuffer, values)); } void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) @@ -2204,12 +2229,8 @@ void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLin } syncStateForClear(); - - Error error = framebufferObject->clearBufferfi(mData, buffer, drawbuffer, depth, stencil); - if (error.isError()) - { - recordError(error); - } + handleError(framebufferObject->clearBufferfi(mImplementation.get(), buffer, drawbuffer, depth, + stencil)); } void Context::readPixels(GLint x, @@ -2226,11 +2247,7 @@ void Context::readPixels(GLint x, ASSERT(framebufferObject); Rectangle area(x, y, width, height); - Error error = framebufferObject->readPixels(mState, area, format, type, pixels); - if (error.isError()) - { - recordError(error); - } + handleError(framebufferObject->readPixels(mImplementation.get(), area, format, type, pixels)); } void Context::copyTexImage2D(GLenum target, @@ -2250,11 +2267,7 @@ void Context::copyTexImage2D(GLenum target, const Framebuffer *framebuffer = mState.getReadFramebuffer(); Texture *texture = getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); - Error error = texture->copyImage(target, level, sourceArea, internalformat, framebuffer); - if (error.isError()) - { - recordError(error); - } + handleError(texture->copyImage(target, level, sourceArea, internalformat, framebuffer)); } void Context::copyTexSubImage2D(GLenum target, @@ -2275,11 +2288,7 @@ void Context::copyTexSubImage2D(GLenum target, const Framebuffer *framebuffer = mState.getReadFramebuffer(); Texture *texture = getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); - Error error = texture->copySubImage(target, level, destOffset, sourceArea, framebuffer); - if (error.isError()) - { - recordError(error); - } + handleError(texture->copySubImage(target, level, destOffset, sourceArea, framebuffer)); } void Context::copyTexSubImage3D(GLenum target, @@ -2300,11 +2309,7 @@ void Context::copyTexSubImage3D(GLenum target, const Framebuffer *framebuffer = mState.getReadFramebuffer(); Texture *texture = getTargetTexture(target); - Error error = texture->copySubImage(target, level, destOffset, sourceArea, framebuffer); - if (error.isError()) - { - recordError(error); - } + handleError(texture->copySubImage(target, level, destOffset, sourceArea, framebuffer)); } void Context::framebufferTexture2D(GLenum target, @@ -2424,11 +2429,7 @@ void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GL // The specification isn't clear what should be done when the framebuffer isn't complete. // We leave it up to the framebuffer implementation to decide what to do. - Error error = framebuffer->discard(numAttachments, attachments); - if (error.isError()) - { - recordError(error); - } + handleError(framebuffer->discard(numAttachments, attachments)); } void Context::invalidateFramebuffer(GLenum target, @@ -2441,15 +2442,12 @@ void Context::invalidateFramebuffer(GLenum target, Framebuffer *framebuffer = mState.getTargetFramebuffer(target); ASSERT(framebuffer); - if (framebuffer->checkStatus(mData) == GL_FRAMEBUFFER_COMPLETE) + if (framebuffer->checkStatus(mData) != GL_FRAMEBUFFER_COMPLETE) { - Error error = framebuffer->invalidate(numAttachments, attachments); - if (error.isError()) - { - recordError(error); - return; - } + return; } + + handleError(framebuffer->invalidate(numAttachments, attachments)); } void Context::invalidateSubFramebuffer(GLenum target, @@ -2466,16 +2464,13 @@ void Context::invalidateSubFramebuffer(GLenum target, Framebuffer *framebuffer = mState.getTargetFramebuffer(target); ASSERT(framebuffer); - if (framebuffer->checkStatus(mData) == GL_FRAMEBUFFER_COMPLETE) + if (framebuffer->checkStatus(mData) != GL_FRAMEBUFFER_COMPLETE) { - Rectangle area(x, y, width, height); - Error error = framebuffer->invalidateSub(numAttachments, attachments, area); - if (error.isError()) - { - recordError(error); - return; - } + return; } + + Rectangle area(x, y, width, height); + handleError(framebuffer->invalidateSub(numAttachments, attachments, area)); } void Context::texImage2D(GLenum target, @@ -2493,12 +2488,8 @@ void Context::texImage2D(GLenum target, Extents size(width, height, 1); Texture *texture = getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); - Error error = texture->setImage(mState.getUnpackState(), target, level, internalformat, size, - format, type, reinterpret_cast<const uint8_t *>(pixels)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setImage(mState.getUnpackState(), target, level, internalformat, size, + format, type, reinterpret_cast<const uint8_t *>(pixels))); } void Context::texImage3D(GLenum target, @@ -2516,12 +2507,8 @@ void Context::texImage3D(GLenum target, Extents size(width, height, depth); Texture *texture = getTargetTexture(target); - Error error = texture->setImage(mState.getUnpackState(), target, level, internalformat, size, - format, type, reinterpret_cast<const uint8_t *>(pixels)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setImage(mState.getUnpackState(), target, level, internalformat, size, + format, type, reinterpret_cast<const uint8_t *>(pixels))); } void Context::texSubImage2D(GLenum target, @@ -2545,12 +2532,8 @@ void Context::texSubImage2D(GLenum target, Box area(xoffset, yoffset, 0, width, height, 1); Texture *texture = getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); - Error error = texture->setSubImage(mState.getUnpackState(), target, level, area, format, type, - reinterpret_cast<const uint8_t *>(pixels)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setSubImage(mState.getUnpackState(), target, level, area, format, type, + reinterpret_cast<const uint8_t *>(pixels))); } void Context::texSubImage3D(GLenum target, @@ -2575,12 +2558,8 @@ void Context::texSubImage3D(GLenum target, Box area(xoffset, yoffset, zoffset, width, height, depth); Texture *texture = getTargetTexture(target); - Error error = texture->setSubImage(mState.getUnpackState(), target, level, area, format, type, - reinterpret_cast<const uint8_t *>(pixels)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setSubImage(mState.getUnpackState(), target, level, area, format, type, + reinterpret_cast<const uint8_t *>(pixels))); } void Context::compressedTexImage2D(GLenum target, @@ -2597,13 +2576,9 @@ void Context::compressedTexImage2D(GLenum target, Extents size(width, height, 1); Texture *texture = getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); - Error error = - texture->setCompressedImage(mState.getUnpackState(), target, level, internalformat, size, - imageSize, reinterpret_cast<const uint8_t *>(data)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setCompressedImage(mState.getUnpackState(), target, level, internalformat, + size, imageSize, + reinterpret_cast<const uint8_t *>(data))); } void Context::compressedTexImage3D(GLenum target, @@ -2620,13 +2595,9 @@ void Context::compressedTexImage3D(GLenum target, Extents size(width, height, depth); Texture *texture = getTargetTexture(target); - Error error = - texture->setCompressedImage(mState.getUnpackState(), target, level, internalformat, size, - imageSize, reinterpret_cast<const uint8_t *>(data)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setCompressedImage(mState.getUnpackState(), target, level, internalformat, + size, imageSize, + reinterpret_cast<const uint8_t *>(data))); } void Context::compressedTexSubImage2D(GLenum target, @@ -2644,13 +2615,8 @@ void Context::compressedTexSubImage2D(GLenum target, Box area(xoffset, yoffset, 0, width, height, 1); Texture *texture = getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); - Error error = - texture->setCompressedSubImage(mState.getUnpackState(), target, level, area, format, - imageSize, reinterpret_cast<const uint8_t *>(data)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setCompressedSubImage(mState.getUnpackState(), target, level, area, format, + imageSize, reinterpret_cast<const uint8_t *>(data))); } void Context::compressedTexSubImage3D(GLenum target, @@ -2675,13 +2641,8 @@ void Context::compressedTexSubImage3D(GLenum target, Box area(xoffset, yoffset, zoffset, width, height, depth); Texture *texture = getTargetTexture(target); - Error error = - texture->setCompressedSubImage(mState.getUnpackState(), target, level, area, format, - imageSize, reinterpret_cast<const uint8_t *>(data)); - if (error.isError()) - { - recordError(error); - } + handleError(texture->setCompressedSubImage(mState.getUnpackState(), target, level, area, format, + imageSize, reinterpret_cast<const uint8_t *>(data))); } void Context::getBufferPointerv(GLenum target, GLenum /*pname*/, void **params) @@ -2707,7 +2668,7 @@ GLvoid *Context::mapBuffer(GLenum target, GLenum access) Error error = buffer->map(access); if (error.isError()) { - recordError(error); + handleError(error); return nullptr; } @@ -2723,7 +2684,7 @@ GLboolean Context::unmapBuffer(GLenum target) Error error = buffer->unmap(&result); if (error.isError()) { - recordError(error); + handleError(error); return GL_FALSE; } @@ -2741,7 +2702,7 @@ GLvoid *Context::mapBufferRange(GLenum target, Error error = buffer->mapRange(offset, length, access); if (error.isError()) { - recordError(error); + handleError(error); return nullptr; } diff --git a/chromium/third_party/angle/src/libANGLE/Context.h b/chromium/third_party/angle/src/libANGLE/Context.h index 3dbbda79e7f..9defad364f3 100644 --- a/chromium/third_party/angle/src/libANGLE/Context.h +++ b/chromium/third_party/angle/src/libANGLE/Context.h @@ -18,7 +18,7 @@ #include "libANGLE/RefCountObject.h" #include "libANGLE/Caps.h" #include "libANGLE/Constants.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/Error.h" #include "libANGLE/HandleAllocator.h" #include "libANGLE/VertexAttribute.h" @@ -26,7 +26,8 @@ namespace rx { -class Renderer; +class ContextImpl; +class EGLImplFactory; } namespace egl @@ -57,9 +58,9 @@ class TransformFeedback; class Context final : public ValidationContext { public: - Context(const egl::Config *config, + Context(rx::EGLImplFactory *implFactory, + const egl::Config *config, const Context *shareContext, - rx::Renderer *renderer, const egl::AttributeMap &attribs); virtual ~Context(); @@ -386,7 +387,12 @@ class Context final : public ValidationContext void pushGroupMarker(GLsizei length, const char *marker); void popGroupMarker(); - void recordError(const Error &error) override; + void bindUniformLocation(GLuint program, GLint location, const GLchar *name); + + // CHROMIUM_framebuffer_mixed_samples + void setCoverageModulation(GLenum components); + + void handleError(const Error &error) override; GLenum getError(); GLenum getResetStatus(); @@ -402,9 +408,8 @@ class Context final : public ValidationContext const std::string &getExtensionString(size_t idx) const; size_t getExtensionStringCount() const; - rx::Renderer *getRenderer() { return mRenderer; } - State &getState() { return mState; } + rx::ContextImpl *getImplementation() const { return mImplementation.get(); } private: void syncRendererState(); @@ -430,6 +435,8 @@ class Context final : public ValidationContext void initCaps(GLuint clientVersion); + std::unique_ptr<rx::ContextImpl> mImplementation; + // Caps to use for validation Caps mCaps; TextureCapsMap mTextureCaps; @@ -439,7 +446,6 @@ class Context final : public ValidationContext // Shader compiler Compiler *mCompiler; - rx::Renderer *const mRenderer; State mState; int mClientVersion; diff --git a/chromium/third_party/angle/src/libANGLE/Data.cpp b/chromium/third_party/angle/src/libANGLE/ContextState.cpp index 83f04b5a0b5..ef2f0c034f2 100644 --- a/chromium/third_party/angle/src/libANGLE/Data.cpp +++ b/chromium/third_party/angle/src/libANGLE/ContextState.cpp @@ -6,20 +6,20 @@ // Data.cpp: Container class for all GL relevant state, caps and objects -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/ResourceManager.h" namespace gl { -Data::Data(uintptr_t contextIn, - GLint clientVersionIn, - const State &stateIn, - const Caps &capsIn, - const TextureCapsMap &textureCapsIn, - const Extensions &extensionsIn, - const ResourceManager *resourceManagerIn, - const Limitations &limitationsIn) +ContextState::ContextState(uintptr_t contextIn, + GLint clientVersionIn, + const State &stateIn, + const Caps &capsIn, + const TextureCapsMap &textureCapsIn, + const Extensions &extensionsIn, + const ResourceManager *resourceManagerIn, + const Limitations &limitationsIn) : context(contextIn), clientVersion(clientVersionIn), state(&stateIn), @@ -28,9 +28,10 @@ Data::Data(uintptr_t contextIn, extensions(&extensionsIn), resourceManager(resourceManagerIn), limitations(&limitationsIn) -{} +{ +} -Data::~Data() +ContextState::~ContextState() { } diff --git a/chromium/third_party/angle/src/libANGLE/Data.h b/chromium/third_party/angle/src/libANGLE/ContextState.h index f7230d74bcb..1ce2bfc06b1 100644 --- a/chromium/third_party/angle/src/libANGLE/Data.h +++ b/chromium/third_party/angle/src/libANGLE/ContextState.h @@ -4,10 +4,10 @@ // found in the LICENSE file. // -// Data.h: Container class for all GL relevant state, caps and objects +// ContextState: Container class for all GL context state, caps and objects. -#ifndef LIBANGLE_DATA_H_ -#define LIBANGLE_DATA_H_ +#ifndef LIBANGLE_CONTEXTSTATE_H_ +#define LIBANGLE_CONTEXTSTATE_H_ #include "common/angleutils.h" #include "libANGLE/State.h" @@ -15,18 +15,18 @@ namespace gl { -struct Data final : public angle::NonCopyable +struct ContextState final : public angle::NonCopyable { public: - Data(uintptr_t context, - GLint clientVersion, - const State &state, - const Caps &caps, - const TextureCapsMap &textureCaps, - const Extensions &extensions, - const ResourceManager *resourceManager, - const Limitations &limitations); - ~Data(); + ContextState(uintptr_t context, + GLint clientVersion, + const State &state, + const Caps &caps, + const TextureCapsMap &textureCaps, + const Extensions &extensions, + const ResourceManager *resourceManager, + const Limitations &limitations); + ~ContextState(); uintptr_t context; GLint clientVersion; @@ -51,9 +51,9 @@ class ValidationContext : angle::NonCopyable bool skipValidation); virtual ~ValidationContext() {} - virtual void recordError(const Error &error) = 0; + virtual void handleError(const Error &error) = 0; - const Data &getData() const { return mData; } + const ContextState &getData() const { return mData; } int getClientVersion() const { return mData.clientVersion; } const State &getState() const { return *mData.state; } const Caps &getCaps() const { return *mData.caps; } @@ -63,10 +63,9 @@ class ValidationContext : angle::NonCopyable bool skipValidation() const { return mSkipValidation; } protected: - Data mData; + ContextState mData; bool mSkipValidation; }; - } -#endif // LIBANGLE_DATA_H_ +#endif // LIBANGLE_CONTEXTSTATE_H_ diff --git a/chromium/third_party/angle/src/libANGLE/Display.cpp b/chromium/third_party/angle/src/libANGLE/Display.cpp index c94dff21ead..93dcba3e6a4 100644 --- a/chromium/third_party/angle/src/libANGLE/Display.cpp +++ b/chromium/third_party/angle/src/libANGLE/Display.cpp @@ -44,6 +44,8 @@ # include "libANGLE/renderer/gl/glx/DisplayGLX.h" # elif defined(ANGLE_PLATFORM_APPLE) # include "libANGLE/renderer/gl/cgl/DisplayCGL.h" +# elif defined(ANGLE_USE_OZONE) +# include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h" # else # error Unsupported OpenGL platform. # endif @@ -146,6 +148,8 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) impl = new rx::DisplayGLX(); #elif defined(ANGLE_PLATFORM_APPLE) impl = new rx::DisplayCGL(); +#elif defined(ANGLE_USE_OZONE) + impl = new rx::DisplayOzone(); #else // No display available UNREACHABLE(); @@ -170,6 +174,9 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) impl = new rx::DisplayGLX(); #elif defined(ANGLE_PLATFORM_APPLE) impl = new rx::DisplayCGL(); +#elif defined(ANGLE_USE_OZONE) + // This might work but has never been tried, so disallow for now. + impl = nullptr; #else #error Unsupported OpenGL platform. #endif @@ -184,6 +191,8 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) impl = new rx::DisplayWGL(); #elif defined(ANGLE_USE_X11) impl = new rx::DisplayGLX(); +#elif defined(ANGLE_USE_OZONE) + impl = new rx::DisplayOzone(); #else // No GLES support on this platform, fail display creation. impl = nullptr; @@ -711,10 +720,7 @@ Error Display::createStream(const AttributeMap &attribs, Stream **outStream) { ASSERT(isInitialized()); - rx::StreamImpl *streamImpl = mImplementation->createStream(attribs); - ASSERT(streamImpl != nullptr); - - Stream *stream = new Stream(streamImpl, attribs); + Stream *stream = new Stream(this, attribs); ASSERT(stream != nullptr); mStreamSet.insert(stream); @@ -732,15 +738,10 @@ Error Display::createContext(const Config *configuration, gl::Context *shareCont if (mImplementation->testDeviceLost()) { - Error error = restoreLostDevice(); - if (error.isError()) - { - return error; - } + ANGLE_TRY(restoreLostDevice()); } - gl::Context *context = *outContext = - mImplementation->createContext(configuration, shareContext, attribs); + gl::Context *context = new gl::Context(mImplementation, configuration, shareContext, attribs); ASSERT(context != nullptr); mContextSet.insert(context); diff --git a/chromium/third_party/angle/src/libANGLE/Display.h b/chromium/third_party/angle/src/libANGLE/Display.h index 339fa594420..a926ed6a4e0 100644 --- a/chromium/third_party/angle/src/libANGLE/Display.h +++ b/chromium/third_party/angle/src/libANGLE/Display.h @@ -18,7 +18,6 @@ #include "libANGLE/Caps.h" #include "libANGLE/Config.h" #include "libANGLE/AttributeMap.h" -#include "libANGLE/renderer/Renderer.h" namespace gl { diff --git a/chromium/third_party/angle/src/libANGLE/Fence.cpp b/chromium/third_party/angle/src/libANGLE/Fence.cpp index ff32f4bbe9a..e5f3ba69a2f 100644 --- a/chromium/third_party/angle/src/libANGLE/Fence.cpp +++ b/chromium/third_party/angle/src/libANGLE/Fence.cpp @@ -9,12 +9,11 @@ #include "libANGLE/Fence.h" +#include "angle_gl.h" + +#include "common/utilities.h" #include "libANGLE/renderer/FenceNVImpl.h" #include "libANGLE/renderer/FenceSyncImpl.h" -#include "libANGLE/renderer/Renderer.h" -#include "common/utilities.h" - -#include "angle_gl.h" namespace gl { diff --git a/chromium/third_party/angle/src/libANGLE/Framebuffer.cpp b/chromium/third_party/angle/src/libANGLE/Framebuffer.cpp index 28b7cabf9e7..071b7188ba0 100644 --- a/chromium/third_party/angle/src/libANGLE/Framebuffer.cpp +++ b/chromium/third_party/angle/src/libANGLE/Framebuffer.cpp @@ -18,8 +18,9 @@ #include "libANGLE/Surface.h" #include "libANGLE/Texture.h" #include "libANGLE/formatutils.h" +#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/FramebufferImpl.h" -#include "libANGLE/renderer/ImplFactory.h" +#include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/RenderbufferImpl.h" #include "libANGLE/renderer/SurfaceImpl.h" @@ -39,7 +40,7 @@ void DetachMatchingAttachment(FramebufferAttachment *attachment, GLenum matchTyp } } -Framebuffer::Data::Data() +FramebufferState::FramebufferState() : mLabel(), mColorAttachments(1), mDrawBufferStates(1, GL_NONE), @@ -48,7 +49,7 @@ Framebuffer::Data::Data() mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT; } -Framebuffer::Data::Data(const Caps &caps) +FramebufferState::FramebufferState(const Caps &caps) : mLabel(), mColorAttachments(caps.maxColorAttachments), mDrawBufferStates(caps.maxDrawBuffers, GL_NONE), @@ -58,16 +59,16 @@ Framebuffer::Data::Data(const Caps &caps) mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT; } -Framebuffer::Data::~Data() +FramebufferState::~FramebufferState() { } -const std::string &Framebuffer::Data::getLabel() +const std::string &FramebufferState::getLabel() { return mLabel; } -const FramebufferAttachment *Framebuffer::Data::getReadAttachment() const +const FramebufferAttachment *FramebufferState::getReadAttachment() const { ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15)); size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0)); @@ -75,7 +76,7 @@ const FramebufferAttachment *Framebuffer::Data::getReadAttachment() const return mColorAttachments[readIndex].isAttached() ? &mColorAttachments[readIndex] : nullptr; } -const FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const +const FramebufferAttachment *FramebufferState::getFirstColorAttachment() const { for (const FramebufferAttachment &colorAttachment : mColorAttachments) { @@ -88,7 +89,7 @@ const FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const return nullptr; } -const FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() const +const FramebufferAttachment *FramebufferState::getDepthOrStencilAttachment() const { if (mDepthAttachment.isAttached()) { @@ -101,7 +102,7 @@ const FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() co return nullptr; } -const FramebufferAttachment *Framebuffer::Data::getColorAttachment(size_t colorAttachment) const +const FramebufferAttachment *FramebufferState::getColorAttachment(size_t colorAttachment) const { ASSERT(colorAttachment < mColorAttachments.size()); return mColorAttachments[colorAttachment].isAttached() ? @@ -109,17 +110,17 @@ const FramebufferAttachment *Framebuffer::Data::getColorAttachment(size_t colorA nullptr; } -const FramebufferAttachment *Framebuffer::Data::getDepthAttachment() const +const FramebufferAttachment *FramebufferState::getDepthAttachment() const { return mDepthAttachment.isAttached() ? &mDepthAttachment : nullptr; } -const FramebufferAttachment *Framebuffer::Data::getStencilAttachment() const +const FramebufferAttachment *FramebufferState::getStencilAttachment() const { return mStencilAttachment.isAttached() ? &mStencilAttachment : nullptr; } -const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() const +const FramebufferAttachment *FramebufferState::getDepthStencilAttachment() const { // A valid depth-stencil attachment has the same resource bound to both the // depth and stencil attachment points. @@ -133,7 +134,7 @@ const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() cons return nullptr; } -bool Framebuffer::Data::attachmentsHaveSameDimensions() const +bool FramebufferState::attachmentsHaveSameDimensions() const { Optional<Extents> attachmentSize; @@ -169,15 +170,15 @@ bool Framebuffer::Data::attachmentsHaveSameDimensions() const return !hasMismatchedSize(mStencilAttachment); } -Framebuffer::Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id) - : mData(caps), mImpl(factory->createFramebuffer(mData)), mId(id) +Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id) + : mState(caps), mImpl(factory->createFramebuffer(mState)), mId(id) { ASSERT(mId != 0); ASSERT(mImpl != nullptr); } Framebuffer::Framebuffer(rx::SurfaceImpl *surface) - : mData(), mImpl(surface->createDefaultFramebuffer(mData)), mId(0) + : mState(), mImpl(surface->createDefaultFramebuffer(mState)), mId(0) { ASSERT(mImpl != nullptr); } @@ -189,12 +190,12 @@ Framebuffer::~Framebuffer() void Framebuffer::setLabel(const std::string &label) { - mData.mLabel = label; + mState.mLabel = label; } const std::string &Framebuffer::getLabel() const { - return mData.mLabel; + return mState.mLabel; } void Framebuffer::detachTexture(GLuint textureId) @@ -209,61 +210,61 @@ void Framebuffer::detachRenderbuffer(GLuint renderbufferId) void Framebuffer::detachResourceById(GLenum resourceType, GLuint resourceId) { - for (auto &colorAttachment : mData.mColorAttachments) + for (auto &colorAttachment : mState.mColorAttachments) { DetachMatchingAttachment(&colorAttachment, resourceType, resourceId); } - DetachMatchingAttachment(&mData.mDepthAttachment, resourceType, resourceId); - DetachMatchingAttachment(&mData.mStencilAttachment, resourceType, resourceId); + DetachMatchingAttachment(&mState.mDepthAttachment, resourceType, resourceId); + DetachMatchingAttachment(&mState.mStencilAttachment, resourceType, resourceId); } const FramebufferAttachment *Framebuffer::getColorbuffer(size_t colorAttachment) const { - return mData.getColorAttachment(colorAttachment); + return mState.getColorAttachment(colorAttachment); } const FramebufferAttachment *Framebuffer::getDepthbuffer() const { - return mData.getDepthAttachment(); + return mState.getDepthAttachment(); } const FramebufferAttachment *Framebuffer::getStencilbuffer() const { - return mData.getStencilAttachment(); + return mState.getStencilAttachment(); } const FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const { - return mData.getDepthStencilAttachment(); + return mState.getDepthStencilAttachment(); } const FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const { - return mData.getDepthOrStencilAttachment(); + return mState.getDepthOrStencilAttachment(); } const FramebufferAttachment *Framebuffer::getReadColorbuffer() const { - return mData.getReadAttachment(); + return mState.getReadAttachment(); } GLenum Framebuffer::getReadColorbufferType() const { - const FramebufferAttachment *readAttachment = mData.getReadAttachment(); + const FramebufferAttachment *readAttachment = mState.getReadAttachment(); return (readAttachment != nullptr ? readAttachment->type() : GL_NONE); } const FramebufferAttachment *Framebuffer::getFirstColorbuffer() const { - return mData.getFirstColorAttachment(); + return mState.getFirstColorAttachment(); } const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const { if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15) { - return mData.getColorAttachment(attachment - GL_COLOR_ATTACHMENT0); + return mState.getColorAttachment(attachment - GL_COLOR_ATTACHMENT0); } else { @@ -271,13 +272,13 @@ const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const { case GL_COLOR: case GL_BACK: - return mData.getColorAttachment(0); + return mState.getColorAttachment(0); case GL_DEPTH: case GL_DEPTH_ATTACHMENT: - return mData.getDepthAttachment(); + return mState.getDepthAttachment(); case GL_STENCIL: case GL_STENCIL_ATTACHMENT: - return mData.getStencilAttachment(); + return mState.getStencilAttachment(); case GL_DEPTH_STENCIL: case GL_DEPTH_STENCIL_ATTACHMENT: return getDepthStencilBuffer(); @@ -290,23 +291,23 @@ const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const size_t Framebuffer::getDrawbufferStateCount() const { - return mData.mDrawBufferStates.size(); + return mState.mDrawBufferStates.size(); } GLenum Framebuffer::getDrawBufferState(size_t drawBuffer) const { - ASSERT(drawBuffer < mData.mDrawBufferStates.size()); - return mData.mDrawBufferStates[drawBuffer]; + ASSERT(drawBuffer < mState.mDrawBufferStates.size()); + return mState.mDrawBufferStates[drawBuffer]; } const std::vector<GLenum> &Framebuffer::getDrawBufferStates() const { - return mData.getDrawBufferStates(); + return mState.getDrawBufferStates(); } void Framebuffer::setDrawBuffers(size_t count, const GLenum *buffers) { - auto &drawStates = mData.mDrawBufferStates; + auto &drawStates = mState.mDrawBufferStates; ASSERT(count <= drawStates.size()); std::copy(buffers, buffers + count, drawStates.begin()); @@ -316,14 +317,14 @@ void Framebuffer::setDrawBuffers(size_t count, const GLenum *buffers) const FramebufferAttachment *Framebuffer::getDrawBuffer(size_t drawBuffer) const { - ASSERT(drawBuffer < mData.mDrawBufferStates.size()); - if (mData.mDrawBufferStates[drawBuffer] != GL_NONE) + ASSERT(drawBuffer < mState.mDrawBufferStates.size()); + if (mState.mDrawBufferStates[drawBuffer] != GL_NONE) { // ES3 spec: "If the GL is bound to a draw framebuffer object, the ith buffer listed in bufs // must be COLOR_ATTACHMENTi or NONE" - ASSERT(mData.mDrawBufferStates[drawBuffer] == GL_COLOR_ATTACHMENT0 + drawBuffer || - (drawBuffer == 0 && mData.mDrawBufferStates[drawBuffer] == GL_BACK)); - return getAttachment(mData.mDrawBufferStates[drawBuffer]); + ASSERT(mState.mDrawBufferStates[drawBuffer] == GL_COLOR_ATTACHMENT0 + drawBuffer || + (drawBuffer == 0 && mState.mDrawBufferStates[drawBuffer] == GL_BACK)); + return getAttachment(mState.mDrawBufferStates[drawBuffer]); } else { @@ -333,7 +334,7 @@ const FramebufferAttachment *Framebuffer::getDrawBuffer(size_t drawBuffer) const bool Framebuffer::hasEnabledDrawBuffer() const { - for (size_t drawbufferIdx = 0; drawbufferIdx < mData.mDrawBufferStates.size(); ++drawbufferIdx) + for (size_t drawbufferIdx = 0; drawbufferIdx < mState.mDrawBufferStates.size(); ++drawbufferIdx) { if (getDrawBuffer(drawbufferIdx) != nullptr) { @@ -346,36 +347,37 @@ bool Framebuffer::hasEnabledDrawBuffer() const GLenum Framebuffer::getReadBufferState() const { - return mData.mReadBufferState; + return mState.mReadBufferState; } void Framebuffer::setReadBuffer(GLenum buffer) { ASSERT(buffer == GL_BACK || buffer == GL_NONE || (buffer >= GL_COLOR_ATTACHMENT0 && - (buffer - GL_COLOR_ATTACHMENT0) < mData.mColorAttachments.size())); - mData.mReadBufferState = buffer; + (buffer - GL_COLOR_ATTACHMENT0) < mState.mColorAttachments.size())); + mState.mReadBufferState = buffer; mDirtyBits.set(DIRTY_BIT_READ_BUFFER); } size_t Framebuffer::getNumColorBuffers() const { - return mData.mColorAttachments.size(); + return mState.mColorAttachments.size(); } bool Framebuffer::hasDepth() const { - return (mData.mDepthAttachment.isAttached() && mData.mDepthAttachment.getDepthSize() > 0); + return (mState.mDepthAttachment.isAttached() && mState.mDepthAttachment.getDepthSize() > 0); } bool Framebuffer::hasStencil() const { - return (mData.mStencilAttachment.isAttached() && mData.mStencilAttachment.getStencilSize() > 0); + return (mState.mStencilAttachment.isAttached() && + mState.mStencilAttachment.getStencilSize() > 0); } bool Framebuffer::usingExtendedDrawBuffers() const { - for (size_t drawbufferIdx = 1; drawbufferIdx < mData.mDrawBufferStates.size(); ++drawbufferIdx) + for (size_t drawbufferIdx = 1; drawbufferIdx < mState.mDrawBufferStates.size(); ++drawbufferIdx) { if (getDrawBuffer(drawbufferIdx) != nullptr) { @@ -386,7 +388,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const return false; } -GLenum Framebuffer::checkStatus(const gl::Data &data) const +GLenum Framebuffer::checkStatus(const ContextState &data) const { // The default framebuffer *must* always be complete, though it may not be // subject to the same rules as application FBOs. ie, it could have 0x0 size. @@ -399,7 +401,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const int samples = -1; bool missingAttachment = true; - for (const FramebufferAttachment &colorAttachment : mData.mColorAttachments) + for (const FramebufferAttachment &colorAttachment : mState.mColorAttachments) { if (colorAttachment.isAttached()) { @@ -476,7 +478,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const } } - const FramebufferAttachment &depthAttachment = mData.mDepthAttachment; + const FramebufferAttachment &depthAttachment = mState.mDepthAttachment; if (depthAttachment.isAttached()) { const Extents &size = depthAttachment.getSize(); @@ -521,11 +523,21 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const } else if (samples != depthAttachment.getSamples()) { - return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; + // CHROMIUM_framebuffer_mixed_samples allows a framebuffer to be + // considered complete when its depth or stencil samples are a + // multiple of the number of color samples. + const bool mixedSamples = data.extensions->framebufferMixedSamples; + if (!mixedSamples) + return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; + + const int colorSamples = samples ? samples : 1; + const int depthSamples = depthAttachment.getSamples(); + if ((depthSamples % colorSamples) != 0) + return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; } } - const FramebufferAttachment &stencilAttachment = mData.mStencilAttachment; + const FramebufferAttachment &stencilAttachment = mState.mStencilAttachment; if (stencilAttachment.isAttached()) { const Extents &size = stencilAttachment.getSize(); @@ -571,7 +583,22 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const } else if (samples != stencilAttachment.getSamples()) { - return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; + // see the comments in depth attachment check. + const bool mixedSamples = data.extensions->framebufferMixedSamples; + if (!mixedSamples) + return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; + + const int colorSamples = samples ? samples : 1; + const int stencilSamples = stencilAttachment.getSamples(); + if ((stencilSamples % colorSamples) != 0) + return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; + } + + // Starting from ES 3.0 stencil and depth, if present, should be the same image + if (data.clientVersion >= 3 && depthAttachment.isAttached() && + stencilAttachment != depthAttachment) + { + return GL_FRAMEBUFFER_UNSUPPORTED; } } @@ -583,7 +610,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const // In ES 2.0, all color attachments must have the same width and height. // In ES 3.0, there is no such restriction. - if (data.clientVersion < 3 && !mData.attachmentsHaveSameDimensions()) + if (data.clientVersion < 3 && !mState.attachmentsHaveSameDimensions()) { return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } @@ -612,67 +639,67 @@ Error Framebuffer::invalidateSub(size_t count, const GLenum *attachments, const return mImpl->invalidateSub(count, attachments, area); } -Error Framebuffer::clear(const gl::Data &data, GLbitfield mask) +Error Framebuffer::clear(rx::ContextImpl *context, GLbitfield mask) { - if (data.state->isRasterizerDiscardEnabled()) + if (context->getState().isRasterizerDiscardEnabled()) { return gl::Error(GL_NO_ERROR); } - return mImpl->clear(data, mask); + return mImpl->clear(context, mask); } -Error Framebuffer::clearBufferfv(const gl::Data &data, +Error Framebuffer::clearBufferfv(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLfloat *values) { - if (data.state->isRasterizerDiscardEnabled()) + if (context->getState().isRasterizerDiscardEnabled()) { return gl::Error(GL_NO_ERROR); } - return mImpl->clearBufferfv(data, buffer, drawbuffer, values); + return mImpl->clearBufferfv(context, buffer, drawbuffer, values); } -Error Framebuffer::clearBufferuiv(const gl::Data &data, +Error Framebuffer::clearBufferuiv(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLuint *values) { - if (data.state->isRasterizerDiscardEnabled()) + if (context->getState().isRasterizerDiscardEnabled()) { return gl::Error(GL_NO_ERROR); } - return mImpl->clearBufferuiv(data, buffer, drawbuffer, values); + return mImpl->clearBufferuiv(context, buffer, drawbuffer, values); } -Error Framebuffer::clearBufferiv(const gl::Data &data, +Error Framebuffer::clearBufferiv(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLint *values) { - if (data.state->isRasterizerDiscardEnabled()) + if (context->getState().isRasterizerDiscardEnabled()) { return gl::Error(GL_NO_ERROR); } - return mImpl->clearBufferiv(data, buffer, drawbuffer, values); + return mImpl->clearBufferiv(context, buffer, drawbuffer, values); } -Error Framebuffer::clearBufferfi(const gl::Data &data, +Error Framebuffer::clearBufferfi(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) { - if (data.state->isRasterizerDiscardEnabled()) + if (context->getState().isRasterizerDiscardEnabled()) { return gl::Error(GL_NO_ERROR); } - return mImpl->clearBufferfi(data, buffer, drawbuffer, depth, stencil); + return mImpl->clearBufferfi(context, buffer, drawbuffer, depth, stencil); } GLenum Framebuffer::getImplementationColorReadFormat() const @@ -685,19 +712,19 @@ GLenum Framebuffer::getImplementationColorReadType() const return mImpl->getImplementationColorReadType(); } -Error Framebuffer::readPixels(const State &state, +Error Framebuffer::readPixels(rx::ContextImpl *context, const Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const { - Error error = mImpl->readPixels(state, area, format, type, pixels); + Error error = mImpl->readPixels(context, area, format, type, pixels); if (error.isError()) { return error; } - Buffer *unpackBuffer = state.getUnpackState().pixelBuffer.get(); + Buffer *unpackBuffer = context->getState().getUnpackState().pixelBuffer.get(); if (unpackBuffer) { unpackBuffer->onPixelUnpack(); @@ -706,23 +733,22 @@ Error Framebuffer::readPixels(const State &state, return Error(GL_NO_ERROR); } -Error Framebuffer::blit(const State &state, +Error Framebuffer::blit(rx::ContextImpl *context, const Rectangle &sourceArea, const Rectangle &destArea, GLbitfield mask, - GLenum filter, - const Framebuffer *sourceFramebuffer) + GLenum filter) { - return mImpl->blit(state, sourceArea, destArea, mask, filter, sourceFramebuffer); + return mImpl->blit(context, sourceArea, destArea, mask, filter); } -int Framebuffer::getSamples(const gl::Data &data) const +int Framebuffer::getSamples(const ContextState &data) const { if (checkStatus(data) == GL_FRAMEBUFFER_COMPLETE) { // for a complete framebuffer, all attachments must have the same sample count // in this case return the first nonzero sample size - for (const FramebufferAttachment &colorAttachment : mData.mColorAttachments) + for (const FramebufferAttachment &colorAttachment : mState.mColorAttachments) { if (colorAttachment.isAttached()) { @@ -736,7 +762,7 @@ int Framebuffer::getSamples(const gl::Data &data) const bool Framebuffer::hasValidDepthStencil() const { - return mData.getDepthStencilAttachment() != nullptr; + return mState.getDepthStencilAttachment() != nullptr; } void Framebuffer::setAttachment(GLenum type, @@ -760,8 +786,8 @@ void Framebuffer::setAttachment(GLenum type, } } - mData.mDepthAttachment.attach(type, binding, textureIndex, attachmentObj); - mData.mStencilAttachment.attach(type, binding, textureIndex, attachmentObj); + mState.mDepthAttachment.attach(type, binding, textureIndex, attachmentObj); + mState.mStencilAttachment.attach(type, binding, textureIndex, attachmentObj); mDirtyBits.set(DIRTY_BIT_DEPTH_ATTACHMENT); mDirtyBits.set(DIRTY_BIT_STENCIL_ATTACHMENT); } @@ -771,23 +797,23 @@ void Framebuffer::setAttachment(GLenum type, { case GL_DEPTH: case GL_DEPTH_ATTACHMENT: - mData.mDepthAttachment.attach(type, binding, textureIndex, resource); + mState.mDepthAttachment.attach(type, binding, textureIndex, resource); mDirtyBits.set(DIRTY_BIT_DEPTH_ATTACHMENT); break; case GL_STENCIL: case GL_STENCIL_ATTACHMENT: - mData.mStencilAttachment.attach(type, binding, textureIndex, resource); + mState.mStencilAttachment.attach(type, binding, textureIndex, resource); mDirtyBits.set(DIRTY_BIT_STENCIL_ATTACHMENT); break; case GL_BACK: - mData.mColorAttachments[0].attach(type, binding, textureIndex, resource); + mState.mColorAttachments[0].attach(type, binding, textureIndex, resource); mDirtyBits.set(DIRTY_BIT_COLOR_ATTACHMENT_0); break; default: { size_t colorIndex = binding - GL_COLOR_ATTACHMENT0; - ASSERT(colorIndex < mData.mColorAttachments.size()); - mData.mColorAttachments[colorIndex].attach(type, binding, textureIndex, resource); + ASSERT(colorIndex < mState.mColorAttachments.size()); + mState.mColorAttachments[colorIndex].attach(type, binding, textureIndex, resource); mDirtyBits.set(DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex); } break; diff --git a/chromium/third_party/angle/src/libANGLE/Framebuffer.h b/chromium/third_party/angle/src/libANGLE/Framebuffer.h index 9c48b77d3a9..aa4952832dd 100644 --- a/chromium/third_party/angle/src/libANGLE/Framebuffer.h +++ b/chromium/third_party/angle/src/libANGLE/Framebuffer.h @@ -21,7 +21,8 @@ namespace rx { -class ImplFactory; +class ContextImpl; +class GLImplFactory; class FramebufferImpl; class RenderbufferImpl; class SurfaceImpl; @@ -35,57 +36,60 @@ class Surface; namespace gl { class Context; +class Framebuffer; class Renderbuffer; class State; class Texture; class TextureCapsMap; struct Caps; -struct Data; +struct ContextState; struct Extensions; struct ImageIndex; struct Rectangle; -class Framebuffer final : public LabeledObject +class FramebufferState final : angle::NonCopyable { public: - - class Data final : angle::NonCopyable + FramebufferState(); + explicit FramebufferState(const Caps &caps); + ~FramebufferState(); + + const std::string &getLabel(); + + const FramebufferAttachment *getReadAttachment() const; + const FramebufferAttachment *getFirstColorAttachment() const; + const FramebufferAttachment *getDepthOrStencilAttachment() const; + const FramebufferAttachment *getColorAttachment(size_t colorAttachment) const; + const FramebufferAttachment *getDepthAttachment() const; + const FramebufferAttachment *getStencilAttachment() const; + const FramebufferAttachment *getDepthStencilAttachment() const; + + const std::vector<GLenum> &getDrawBufferStates() const { return mDrawBufferStates; } + GLenum getReadBufferState() const { return mReadBufferState; } + const std::vector<FramebufferAttachment> &getColorAttachments() const { - public: - explicit Data(); - explicit Data(const Caps &caps); - ~Data(); - - const std::string &getLabel(); + return mColorAttachments; + } - const FramebufferAttachment *getReadAttachment() const; - const FramebufferAttachment *getFirstColorAttachment() const; - const FramebufferAttachment *getDepthOrStencilAttachment() const; - const FramebufferAttachment *getColorAttachment(size_t colorAttachment) const; - const FramebufferAttachment *getDepthAttachment() const; - const FramebufferAttachment *getStencilAttachment() const; - const FramebufferAttachment *getDepthStencilAttachment() const; + bool attachmentsHaveSameDimensions() const; - const std::vector<GLenum> &getDrawBufferStates() const { return mDrawBufferStates; } - GLenum getReadBufferState() const { return mReadBufferState; } - const std::vector<FramebufferAttachment> &getColorAttachments() const { return mColorAttachments; } + private: + friend class Framebuffer; - bool attachmentsHaveSameDimensions() const; + std::string mLabel; - private: - friend class Framebuffer; + std::vector<FramebufferAttachment> mColorAttachments; + FramebufferAttachment mDepthAttachment; + FramebufferAttachment mStencilAttachment; - std::string mLabel; - - std::vector<FramebufferAttachment> mColorAttachments; - FramebufferAttachment mDepthAttachment; - FramebufferAttachment mStencilAttachment; - - std::vector<GLenum> mDrawBufferStates; - GLenum mReadBufferState; - }; + std::vector<GLenum> mDrawBufferStates; + GLenum mReadBufferState; +}; - Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id); +class Framebuffer final : public LabeledObject +{ + public: + Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id); Framebuffer(rx::SurfaceImpl *surface); virtual ~Framebuffer(); @@ -130,27 +134,30 @@ class Framebuffer final : public LabeledObject size_t getNumColorBuffers() const; bool hasDepth() const; bool hasStencil() const; - int getSamples(const gl::Data &data) const; + int getSamples(const ContextState &data) const; bool usingExtendedDrawBuffers() const; - GLenum checkStatus(const gl::Data &data) const; + GLenum checkStatus(const ContextState &data) const; bool hasValidDepthStencil() const; Error discard(size_t count, const GLenum *attachments); Error invalidate(size_t count, const GLenum *attachments); Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area); - Error clear(const gl::Data &data, GLbitfield mask); - Error clearBufferfv(const gl::Data &data, + Error clear(rx::ContextImpl *context, GLbitfield mask); + Error clearBufferfv(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLfloat *values); - Error clearBufferuiv(const gl::Data &data, + Error clearBufferuiv(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLuint *values); - Error clearBufferiv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLint *values); - Error clearBufferfi(const gl::Data &data, + Error clearBufferiv(rx::ContextImpl *context, + GLenum buffer, + GLint drawbuffer, + const GLint *values); + Error clearBufferfi(rx::ContextImpl *context, GLenum buffer, GLint drawbuffer, GLfloat depth, @@ -158,18 +165,17 @@ class Framebuffer final : public LabeledObject GLenum getImplementationColorReadFormat() const; GLenum getImplementationColorReadType() const; - Error readPixels(const gl::State &state, + Error readPixels(rx::ContextImpl *context, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const; - Error blit(const State &state, + Error blit(rx::ContextImpl *context, const Rectangle &sourceArea, const Rectangle &destArea, GLbitfield mask, - GLenum filter, - const Framebuffer *sourceFramebuffer); + GLenum filter); enum DirtyBitType { @@ -192,7 +198,7 @@ class Framebuffer final : public LabeledObject protected: void detachResourceById(GLenum resourceType, GLuint resourceId); - Data mData; + FramebufferState mState; rx::FramebufferImpl *mImpl; GLuint mId; diff --git a/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.cpp b/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.cpp index 352a326c230..649295af8a7 100644 --- a/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.cpp +++ b/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.cpp @@ -205,4 +205,24 @@ const egl::Surface *FramebufferAttachment::getSurface() const return rx::GetAs<egl::Surface>(mResource); } +bool FramebufferAttachment::operator==(const FramebufferAttachment &other) const +{ + if (mResource != other.mResource || mType != other.mType) + { + return false; + } + + if (mType == GL_TEXTURE && getTextureImageIndex() != other.getTextureImageIndex()) + { + return false; + } + + return true; +} + +bool FramebufferAttachment::operator!=(const FramebufferAttachment &other) const +{ + return !(*this == other); +} + } diff --git a/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.h b/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.h index 33196f5c61f..8bdd918c1f8 100644 --- a/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.h +++ b/chromium/third_party/angle/src/libANGLE/FramebufferAttachment.h @@ -136,6 +136,9 @@ class FramebufferAttachment final return error; } + bool operator==(const FramebufferAttachment &other) const; + bool operator!=(const FramebufferAttachment &other) const; + private: gl::Error getRenderTarget(rx::FramebufferAttachmentRenderTarget **rtOut) const; diff --git a/chromium/third_party/angle/src/libANGLE/ImageIndex.cpp b/chromium/third_party/angle/src/libANGLE/ImageIndex.cpp index c84e7c5d65b..9eb641ccfb8 100644 --- a/chromium/third_party/angle/src/libANGLE/ImageIndex.cpp +++ b/chromium/third_party/angle/src/libANGLE/ImageIndex.cpp @@ -78,6 +78,16 @@ bool ImageIndex::operator<(const ImageIndex &other) const } } +bool ImageIndex::operator==(const ImageIndex &other) const +{ + return (type == other.type) && (mipIndex == other.mipIndex) && (layerIndex == other.layerIndex); +} + +bool ImageIndex::operator!=(const ImageIndex &other) const +{ + return !(*this == other); +} + ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn) : type(typeIn), mipIndex(mipIndexIn), diff --git a/chromium/third_party/angle/src/libANGLE/ImageIndex.h b/chromium/third_party/angle/src/libANGLE/ImageIndex.h index b527c7c8ab4..6f96b40032b 100644 --- a/chromium/third_party/angle/src/libANGLE/ImageIndex.h +++ b/chromium/third_party/angle/src/libANGLE/ImageIndex.h @@ -40,6 +40,8 @@ struct ImageIndex static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1); bool operator<(const ImageIndex &other) const; + bool operator==(const ImageIndex &other) const; + bool operator!=(const ImageIndex &other) const; private: friend class ImageIndexIterator; diff --git a/chromium/third_party/angle/src/libANGLE/Image_unittest.cpp b/chromium/third_party/angle/src/libANGLE/Image_unittest.cpp index 9c89be0e09e..0978ac67840 100644 --- a/chromium/third_party/angle/src/libANGLE/Image_unittest.cpp +++ b/chromium/third_party/angle/src/libANGLE/Image_unittest.cpp @@ -14,8 +14,10 @@ #include "libANGLE/renderer/ImageImpl_mock.h" #include "libANGLE/renderer/TextureImpl_mock.h" #include "libANGLE/renderer/RenderbufferImpl_mock.h" +#include "tests/angle_unittests_utils.h" using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; namespace angle @@ -23,9 +25,11 @@ namespace angle // Verify ref counts are maintained between images and their siblings when objects are deleted TEST(ImageTest, RefCounting) { + NiceMock<rx::MockGLFactory> mockFactory; // Create a texture and an EGL image that uses the texture as its source rx::MockTextureImpl *textureImpl = new rx::MockTextureImpl(); - gl::Texture *texture = new gl::Texture(textureImpl, 1, GL_TEXTURE_2D); + EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl)); + gl::Texture *texture = new gl::Texture(&mockFactory, 1, GL_TEXTURE_2D); texture->addRef(); rx::MockImageImpl *imageImpl = new rx::MockImageImpl(); @@ -82,9 +86,11 @@ TEST(ImageTest, RefCounting) // Verify that respecifiying textures releases references to the Image. TEST(ImageTest, RespecificationReleasesReferences) { + NiceMock<rx::MockGLFactory> mockFactory; // Create a texture and an EGL image that uses the texture as its source rx::MockTextureImpl *textureImpl = new rx::MockTextureImpl(); - gl::Texture *texture = new gl::Texture(textureImpl, 1, GL_TEXTURE_2D); + EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl)); + gl::Texture *texture = new gl::Texture(&mockFactory, 1, GL_TEXTURE_2D); texture->addRef(); gl::PixelUnpackState defaultUnpackState; diff --git a/chromium/third_party/angle/src/libANGLE/Program.cpp b/chromium/third_party/angle/src/libANGLE/Program.cpp index b4aa8dcb0a3..58b47117a2c 100644 --- a/chromium/third_party/angle/src/libANGLE/Program.cpp +++ b/chromium/third_party/angle/src/libANGLE/Program.cpp @@ -17,12 +17,13 @@ #include "common/utilities.h" #include "common/version.h" #include "compiler/translator/blocklayout.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/ResourceManager.h" #include "libANGLE/features.h" -#include "libANGLE/renderer/Renderer.h" +#include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/ProgramImpl.h" #include "libANGLE/queryconversions.h" +#include "libANGLE/Uniform.h" namespace gl { @@ -138,14 +139,6 @@ bool UniformInList(const std::vector<LinkedUniform> &list, const std::string &na const char *const g_fakepath = "C:\\fakepath"; -AttributeBindings::AttributeBindings() -{ -} - -AttributeBindings::~AttributeBindings() -{ -} - InfoLog::InfoLog() { } @@ -208,21 +201,39 @@ void InfoLog::reset() { } -VariableLocation::VariableLocation() - : name(), - element(0), - index(0) +VariableLocation::VariableLocation() : name(), element(0), index(0), used(false), ignored(false) +{ +} + +VariableLocation::VariableLocation(const std::string &name, + unsigned int element, + unsigned int index) + : name(name), element(element), index(index), used(true), ignored(false) +{ +} + +void Program::Bindings::bindLocation(GLuint index, const std::string &name) +{ + mBindings[name] = index; +} + +int Program::Bindings::getBinding(const std::string &name) const { + auto iter = mBindings.find(name); + return (iter != mBindings.end()) ? iter->second : -1; } -VariableLocation::VariableLocation(const std::string &name, unsigned int element, unsigned int index) - : name(name), - element(element), - index(index) +Program::Bindings::const_iterator Program::Bindings::begin() const { + return mBindings.begin(); } -Program::Data::Data() +Program::Bindings::const_iterator Program::Bindings::end() const +{ + return mBindings.end(); +} + +ProgramState::ProgramState() : mLabel(), mAttachedFragmentShader(nullptr), mAttachedVertexShader(nullptr), @@ -231,7 +242,7 @@ Program::Data::Data() { } -Program::Data::~Data() +ProgramState::~ProgramState() { if (mAttachedVertexShader != nullptr) { @@ -244,12 +255,12 @@ Program::Data::~Data() } } -const std::string &Program::Data::getLabel() +const std::string &ProgramState::getLabel() { return mLabel; } -const LinkedUniform *Program::Data::getUniformByName(const std::string &name) const +const LinkedUniform *ProgramState::getUniformByName(const std::string &name) const { for (const LinkedUniform &linkedUniform : mUniforms) { @@ -262,7 +273,7 @@ const LinkedUniform *Program::Data::getUniformByName(const std::string &name) co return nullptr; } -GLint Program::Data::getUniformLocation(const std::string &name) const +GLint ProgramState::getUniformLocation(const std::string &name) const { size_t subscript = GL_INVALID_INDEX; std::string baseName = gl::ParseUniformName(name, &subscript); @@ -270,14 +281,29 @@ GLint Program::Data::getUniformLocation(const std::string &name) const for (size_t location = 0; location < mUniformLocations.size(); ++location) { const VariableLocation &uniformLocation = mUniformLocations[location]; - const LinkedUniform &uniform = mUniforms[uniformLocation.index]; + if (!uniformLocation.used) + { + continue; + } + + const LinkedUniform &uniform = mUniforms[uniformLocation.index]; if (uniform.name == baseName) { - if ((uniform.isArray() && uniformLocation.element == subscript) || - (subscript == GL_INVALID_INDEX)) + if (uniform.isArray()) { - return static_cast<GLint>(location); + if (uniformLocation.element == subscript || + (uniformLocation.element == 0 && subscript == GL_INVALID_INDEX)) + { + return static_cast<GLint>(location); + } + } + else + { + if (subscript == GL_INVALID_INDEX) + { + return static_cast<GLint>(location); + } } } } @@ -285,7 +311,7 @@ GLint Program::Data::getUniformLocation(const std::string &name) const return -1; } -GLuint Program::Data::getUniformIndex(const std::string &name) const +GLuint ProgramState::getUniformIndex(const std::string &name) const { size_t subscript = GL_INVALID_INDEX; std::string baseName = gl::ParseUniformName(name, &subscript); @@ -311,8 +337,8 @@ GLuint Program::Data::getUniformIndex(const std::string &name) const return GL_INVALID_INDEX; } -Program::Program(rx::ImplFactory *factory, ResourceManager *manager, GLuint handle) - : mProgram(factory->createProgram(mData)), +Program::Program(rx::GLImplFactory *factory, ResourceManager *manager, GLuint handle) + : mProgram(factory->createProgram(mState)), mValidated(false), mLinked(false), mDeleteStatus(false), @@ -336,35 +362,35 @@ Program::~Program() void Program::setLabel(const std::string &label) { - mData.mLabel = label; + mState.mLabel = label; } const std::string &Program::getLabel() const { - return mData.mLabel; + return mState.mLabel; } bool Program::attachShader(Shader *shader) { if (shader->getType() == GL_VERTEX_SHADER) { - if (mData.mAttachedVertexShader) + if (mState.mAttachedVertexShader) { return false; } - mData.mAttachedVertexShader = shader; - mData.mAttachedVertexShader->addRef(); + mState.mAttachedVertexShader = shader; + mState.mAttachedVertexShader->addRef(); } else if (shader->getType() == GL_FRAGMENT_SHADER) { - if (mData.mAttachedFragmentShader) + if (mState.mAttachedFragmentShader) { return false; } - mData.mAttachedFragmentShader = shader; - mData.mAttachedFragmentShader->addRef(); + mState.mAttachedFragmentShader = shader; + mState.mAttachedFragmentShader->addRef(); } else UNREACHABLE(); @@ -375,23 +401,23 @@ bool Program::detachShader(Shader *shader) { if (shader->getType() == GL_VERTEX_SHADER) { - if (mData.mAttachedVertexShader != shader) + if (mState.mAttachedVertexShader != shader) { return false; } shader->release(); - mData.mAttachedVertexShader = nullptr; + mState.mAttachedVertexShader = nullptr; } else if (shader->getType() == GL_FRAGMENT_SHADER) { - if (mData.mAttachedFragmentShader != shader) + if (mState.mAttachedFragmentShader != shader) { return false; } shader->release(); - mData.mAttachedFragmentShader = nullptr; + mState.mAttachedFragmentShader = nullptr; } else UNREACHABLE(); @@ -400,60 +426,53 @@ bool Program::detachShader(Shader *shader) int Program::getAttachedShadersCount() const { - return (mData.mAttachedVertexShader ? 1 : 0) + (mData.mAttachedFragmentShader ? 1 : 0); + return (mState.mAttachedVertexShader ? 1 : 0) + (mState.mAttachedFragmentShader ? 1 : 0); } -void AttributeBindings::bindAttributeLocation(GLuint index, const char *name) +void Program::bindAttributeLocation(GLuint index, const char *name) { - if (index < MAX_VERTEX_ATTRIBS) - { - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - mAttributeBinding[i].erase(name); - } - - mAttributeBinding[index].insert(name); - } + mAttributeBindings.bindLocation(index, name); } -void Program::bindAttributeLocation(GLuint index, const char *name) +void Program::bindUniformLocation(GLuint index, const char *name) { - mAttributeBindings.bindAttributeLocation(index, name); + // Bind the base uniform name only since array indices other than 0 cannot be bound + mUniformBindings.bindLocation(index, ParseUniformName(name, nullptr)); } // Links the HLSL code of the vertex and pixel shader by matching up their varyings, // compiling them into binaries, determining the attribute mappings, and collecting // a list of uniforms -Error Program::link(const gl::Data &data) +Error Program::link(const ContextState &data) { unlink(false); mInfoLog.reset(); resetUniformBlockBindings(); - if (!mData.mAttachedFragmentShader || !mData.mAttachedFragmentShader->isCompiled()) + if (!mState.mAttachedFragmentShader || !mState.mAttachedFragmentShader->isCompiled()) { return Error(GL_NO_ERROR); } - ASSERT(mData.mAttachedFragmentShader->getType() == GL_FRAGMENT_SHADER); + ASSERT(mState.mAttachedFragmentShader->getType() == GL_FRAGMENT_SHADER); - if (!mData.mAttachedVertexShader || !mData.mAttachedVertexShader->isCompiled()) + if (!mState.mAttachedVertexShader || !mState.mAttachedVertexShader->isCompiled()) { return Error(GL_NO_ERROR); } - ASSERT(mData.mAttachedVertexShader->getType() == GL_VERTEX_SHADER); + ASSERT(mState.mAttachedVertexShader->getType() == GL_VERTEX_SHADER); - if (!linkAttributes(data, mInfoLog, mAttributeBindings, mData.mAttachedVertexShader)) + if (!linkAttributes(data, mInfoLog, mAttributeBindings, mState.mAttachedVertexShader)) { return Error(GL_NO_ERROR); } - if (!linkVaryings(mInfoLog, mData.mAttachedVertexShader, mData.mAttachedFragmentShader)) + if (!linkVaryings(mInfoLog, mState.mAttachedVertexShader, mState.mAttachedFragmentShader)) { return Error(GL_NO_ERROR); } - if (!linkUniforms(mInfoLog, *data.caps)) + if (!linkUniforms(mInfoLog, *data.caps, mUniformBindings)) { return Error(GL_NO_ERROR); } @@ -485,44 +504,31 @@ Error Program::link(const gl::Data &data) return gl::Error(GL_NO_ERROR); } -int AttributeBindings::getAttributeBinding(const std::string &name) const -{ - for (int location = 0; location < MAX_VERTEX_ATTRIBS; location++) - { - if (mAttributeBinding[location].find(name) != mAttributeBinding[location].end()) - { - return location; - } - } - - return -1; -} - // Returns the program object to an unlinked state, before re-linking, or at destruction void Program::unlink(bool destroy) { if (destroy) // Object being destructed { - if (mData.mAttachedFragmentShader) + if (mState.mAttachedFragmentShader) { - mData.mAttachedFragmentShader->release(); - mData.mAttachedFragmentShader = nullptr; + mState.mAttachedFragmentShader->release(); + mState.mAttachedFragmentShader = nullptr; } - if (mData.mAttachedVertexShader) + if (mState.mAttachedVertexShader) { - mData.mAttachedVertexShader->release(); - mData.mAttachedVertexShader = nullptr; + mState.mAttachedVertexShader->release(); + mState.mAttachedVertexShader = nullptr; } } - mData.mAttributes.clear(); - mData.mActiveAttribLocationsMask.reset(); - mData.mTransformFeedbackVaryingVars.clear(); - mData.mUniforms.clear(); - mData.mUniformLocations.clear(); - mData.mUniformBlocks.clear(); - mData.mOutputVariables.clear(); + mState.mAttributes.clear(); + mState.mActiveAttribLocationsMask.reset(); + mState.mTransformFeedbackVaryingVars.clear(); + mState.mUniforms.clear(); + mState.mUniformLocations.clear(); + mState.mUniformBlocks.clear(); + mState.mOutputVariables.clear(); mValidated = false; @@ -568,20 +574,20 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt static_assert(MAX_VERTEX_ATTRIBS <= sizeof(unsigned long) * 8, "Too many vertex attribs for mask"); - mData.mActiveAttribLocationsMask = stream.readInt<unsigned long>(); + mState.mActiveAttribLocationsMask = stream.readInt<unsigned long>(); unsigned int attribCount = stream.readInt<unsigned int>(); - ASSERT(mData.mAttributes.empty()); + ASSERT(mState.mAttributes.empty()); for (unsigned int attribIndex = 0; attribIndex < attribCount; ++attribIndex) { sh::Attribute attrib; LoadShaderVar(&stream, &attrib); attrib.location = stream.readInt<int>(); - mData.mAttributes.push_back(attrib); + mState.mAttributes.push_back(attrib); } unsigned int uniformCount = stream.readInt<unsigned int>(); - ASSERT(mData.mUniforms.empty()); + ASSERT(mState.mUniforms.empty()); for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex) { LinkedUniform uniform; @@ -593,11 +599,11 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt uniform.blockInfo.matrixStride = stream.readInt<int>(); uniform.blockInfo.isRowMajorMatrix = stream.readBool(); - mData.mUniforms.push_back(uniform); + mState.mUniforms.push_back(uniform); } const unsigned int uniformIndexCount = stream.readInt<unsigned int>(); - ASSERT(mData.mUniformLocations.empty()); + ASSERT(mState.mUniformLocations.empty()); for (unsigned int uniformIndexIndex = 0; uniformIndexIndex < uniformIndexCount; uniformIndexIndex++) { @@ -605,12 +611,14 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt stream.readString(&variable.name); stream.readInt(&variable.element); stream.readInt(&variable.index); + stream.readBool(&variable.used); + stream.readBool(&variable.ignored); - mData.mUniformLocations.push_back(variable); + mState.mUniformLocations.push_back(variable); } unsigned int uniformBlockCount = stream.readInt<unsigned int>(); - ASSERT(mData.mUniformBlocks.empty()); + ASSERT(mState.mUniformBlocks.empty()); for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; ++uniformBlockIndex) { @@ -628,11 +636,11 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt uniformBlock.memberUniformIndexes.push_back(stream.readInt<unsigned int>()); } - mData.mUniformBlocks.push_back(uniformBlock); + mState.mUniformBlocks.push_back(uniformBlock); } unsigned int transformFeedbackVaryingCount = stream.readInt<unsigned int>(); - ASSERT(mData.mTransformFeedbackVaryingVars.empty()); + ASSERT(mState.mTransformFeedbackVaryingVars.empty()); for (unsigned int transformFeedbackVaryingIndex = 0; transformFeedbackVaryingIndex < transformFeedbackVaryingCount; ++transformFeedbackVaryingIndex) @@ -642,10 +650,10 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt stream.readInt(&varying.type); stream.readString(&varying.name); - mData.mTransformFeedbackVaryingVars.push_back(varying); + mState.mTransformFeedbackVaryingVars.push_back(varying); } - stream.readInt(&mData.mTransformFeedbackBufferMode); + stream.readInt(&mState.mTransformFeedbackBufferMode); unsigned int outputVarCount = stream.readInt<unsigned int>(); for (unsigned int outputIndex = 0; outputIndex < outputVarCount; ++outputIndex) @@ -655,7 +663,7 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt stream.readInt(&locationData.element); stream.readInt(&locationData.index); stream.readString(&locationData.name); - mData.mOutputVariables[locationIndex] = locationData; + mState.mOutputVariables[locationIndex] = locationData; } stream.readInt(&mSamplerUniformRange.start); @@ -685,17 +693,17 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G stream.writeInt(ANGLE_MINOR_VERSION); stream.writeBytes(reinterpret_cast<const unsigned char*>(ANGLE_COMMIT_HASH), ANGLE_COMMIT_HASH_SIZE); - stream.writeInt(mData.mActiveAttribLocationsMask.to_ulong()); + stream.writeInt(mState.mActiveAttribLocationsMask.to_ulong()); - stream.writeInt(mData.mAttributes.size()); - for (const sh::Attribute &attrib : mData.mAttributes) + stream.writeInt(mState.mAttributes.size()); + for (const sh::Attribute &attrib : mState.mAttributes) { WriteShaderVar(&stream, attrib); stream.writeInt(attrib.location); } - stream.writeInt(mData.mUniforms.size()); - for (const gl::LinkedUniform &uniform : mData.mUniforms) + stream.writeInt(mState.mUniforms.size()); + for (const gl::LinkedUniform &uniform : mState.mUniforms) { WriteShaderVar(&stream, uniform); @@ -708,16 +716,18 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G stream.writeInt(uniform.blockInfo.isRowMajorMatrix); } - stream.writeInt(mData.mUniformLocations.size()); - for (const auto &variable : mData.mUniformLocations) + stream.writeInt(mState.mUniformLocations.size()); + for (const auto &variable : mState.mUniformLocations) { stream.writeString(variable.name); stream.writeInt(variable.element); stream.writeInt(variable.index); + stream.writeInt(variable.used); + stream.writeInt(variable.ignored); } - stream.writeInt(mData.mUniformBlocks.size()); - for (const UniformBlock &uniformBlock : mData.mUniformBlocks) + stream.writeInt(mState.mUniformBlocks.size()); + for (const UniformBlock &uniformBlock : mState.mUniformBlocks) { stream.writeString(uniformBlock.name); stream.writeInt(uniformBlock.isArray); @@ -734,18 +744,18 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G } } - stream.writeInt(mData.mTransformFeedbackVaryingVars.size()); - for (const sh::Varying &varying : mData.mTransformFeedbackVaryingVars) + stream.writeInt(mState.mTransformFeedbackVaryingVars.size()); + for (const sh::Varying &varying : mState.mTransformFeedbackVaryingVars) { stream.writeInt(varying.arraySize); stream.writeInt(varying.type); stream.writeString(varying.name); } - stream.writeInt(mData.mTransformFeedbackBufferMode); + stream.writeInt(mState.mTransformFeedbackBufferMode); - stream.writeInt(mData.mOutputVariables.size()); - for (const auto &outputPair : mData.mOutputVariables) + stream.writeInt(mState.mOutputVariables.size()); + for (const auto &outputPair : mState.mOutputVariables) { stream.writeInt(outputPair.first); stream.writeInt(outputPair.second.element); @@ -763,7 +773,7 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G } GLsizei streamLength = static_cast<GLsizei>(stream.length()); - const void *streamData = stream.data(); + const void *streamState = stream.data(); if (streamLength > bufSize) { @@ -782,7 +792,7 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G { char *ptr = reinterpret_cast<char*>(binary); - memcpy(ptr, streamData, streamLength); + memcpy(ptr, streamState, streamLength); ptr += streamLength; ASSERT(ptr - streamLength == binary); @@ -812,12 +822,12 @@ void Program::setBinaryRetrievableHint(bool retrievable) { // TODO(jmadill) : replace with dirty bits mProgram->setBinaryRetrievableHint(retrievable); - mData.mBinaryRetrieveableHint = retrievable; + mState.mBinaryRetrieveableHint = retrievable; } bool Program::getBinaryRetrievableHint() const { - return mData.mBinaryRetrieveableHint; + return mState.mBinaryRetrieveableHint; } void Program::release() @@ -854,20 +864,20 @@ void Program::getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shade { int total = 0; - if (mData.mAttachedVertexShader) + if (mState.mAttachedVertexShader) { if (total < maxCount) { - shaders[total] = mData.mAttachedVertexShader->getHandle(); + shaders[total] = mState.mAttachedVertexShader->getHandle(); total++; } } - if (mData.mAttachedFragmentShader) + if (mState.mAttachedFragmentShader) { if (total < maxCount) { - shaders[total] = mData.mAttachedFragmentShader->getHandle(); + shaders[total] = mState.mAttachedFragmentShader->getHandle(); total++; } } @@ -880,7 +890,7 @@ void Program::getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shade GLuint Program::getAttributeLocation(const std::string &name) const { - for (const sh::Attribute &attribute : mData.mAttributes) + for (const sh::Attribute &attribute : mState.mAttributes) { if (attribute.name == name && attribute.staticUse) { @@ -893,8 +903,8 @@ GLuint Program::getAttributeLocation(const std::string &name) const bool Program::isAttribLocationActive(size_t attribLocation) const { - ASSERT(attribLocation < mData.mActiveAttribLocationsMask.size()); - return mData.mActiveAttribLocationsMask[attribLocation]; + ASSERT(attribLocation < mState.mActiveAttribLocationsMask.size()); + return mState.mActiveAttribLocationsMask[attribLocation]; } void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) @@ -918,7 +928,7 @@ void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, size_t attributeIndex = 0; - for (const sh::Attribute &attribute : mData.mAttributes) + for (const sh::Attribute &attribute : mState.mAttributes) { // Skip over inactive attributes if (attribute.staticUse) @@ -931,8 +941,8 @@ void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, } } - ASSERT(index == attributeIndex && attributeIndex < mData.mAttributes.size()); - const sh::Attribute &attrib = mData.mAttributes[attributeIndex]; + ASSERT(index == attributeIndex && attributeIndex < mState.mAttributes.size()); + const sh::Attribute &attrib = mState.mAttributes[attributeIndex]; if (bufsize > 0) { @@ -961,7 +971,7 @@ GLint Program::getActiveAttributeCount() const GLint count = 0; - for (const sh::Attribute &attrib : mData.mAttributes) + for (const sh::Attribute &attrib : mState.mAttributes) { count += (attrib.staticUse ? 1 : 0); } @@ -978,7 +988,7 @@ GLint Program::getActiveAttributeMaxLength() const size_t maxLength = 0; - for (const sh::Attribute &attrib : mData.mAttributes) + for (const sh::Attribute &attrib : mState.mAttributes) { if (attrib.staticUse) { @@ -993,7 +1003,7 @@ GLint Program::getFragDataLocation(const std::string &name) const { std::string baseName(name); unsigned int arrayIndex = ParseAndStripArrayIndex(&baseName); - for (auto outputPair : mData.mOutputVariables) + for (auto outputPair : mState.mOutputVariables) { const VariableLocation &outputVariable = outputPair.second; if (outputVariable.name == baseName && (arrayIndex == GL_INVALID_INDEX || arrayIndex == outputVariable.element)) @@ -1014,8 +1024,8 @@ void Program::getActiveUniform(GLuint index, if (mLinked) { // index must be smaller than getActiveUniformCount() - ASSERT(index < mData.mUniforms.size()); - const LinkedUniform &uniform = mData.mUniforms[index]; + ASSERT(index < mState.mUniforms.size()); + const LinkedUniform &uniform = mState.mUniforms[index]; if (bufsize > 0) { @@ -1058,7 +1068,7 @@ GLint Program::getActiveUniformCount() const { if (mLinked) { - return static_cast<GLint>(mData.mUniforms.size()); + return static_cast<GLint>(mState.mUniforms.size()); } else { @@ -1072,7 +1082,7 @@ GLint Program::getActiveUniformMaxLength() const if (mLinked) { - for (const LinkedUniform &uniform : mData.mUniforms) + for (const LinkedUniform &uniform : mState.mUniforms) { if (!uniform.name.empty()) { @@ -1091,8 +1101,8 @@ GLint Program::getActiveUniformMaxLength() const GLint Program::getActiveUniformi(GLuint index, GLenum pname) const { - ASSERT(static_cast<size_t>(index) < mData.mUniforms.size()); - const gl::LinkedUniform &uniform = mData.mUniforms[index]; + ASSERT(static_cast<size_t>(index) < mState.mUniforms.size()); + const gl::LinkedUniform &uniform = mState.mUniforms[index]; switch (pname) { case GL_UNIFORM_TYPE: return static_cast<GLint>(uniform.type); @@ -1112,24 +1122,34 @@ GLint Program::getActiveUniformi(GLuint index, GLenum pname) const bool Program::isValidUniformLocation(GLint location) const { - ASSERT(rx::IsIntegerCastSafe<GLint>(mData.mUniformLocations.size())); - return (location >= 0 && static_cast<size_t>(location) < mData.mUniformLocations.size()); + ASSERT(rx::IsIntegerCastSafe<GLint>(mState.mUniformLocations.size())); + return (location >= 0 && static_cast<size_t>(location) < mState.mUniformLocations.size() && + mState.mUniformLocations[static_cast<size_t>(location)].used); +} + +bool Program::isIgnoredUniformLocation(GLint location) const +{ + // Location is ignored if it is -1 or it was bound but non-existant in the shader or optimized + // out + return location == -1 || + (location >= 0 && static_cast<size_t>(location) < mState.mUniformLocations.size() && + mState.mUniformLocations[static_cast<size_t>(location)].ignored); } const LinkedUniform &Program::getUniformByLocation(GLint location) const { - ASSERT(location >= 0 && static_cast<size_t>(location) < mData.mUniformLocations.size()); - return mData.mUniforms[mData.mUniformLocations[location].index]; + ASSERT(location >= 0 && static_cast<size_t>(location) < mState.mUniformLocations.size()); + return mState.mUniforms[mState.mUniformLocations[location].index]; } GLint Program::getUniformLocation(const std::string &name) const { - return mData.getUniformLocation(name); + return mState.getUniformLocation(name); } GLuint Program::getUniformIndex(const std::string &name) const { - return mData.getUniformIndex(name); + return mState.getUniformIndex(name); } void Program::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) @@ -1321,7 +1341,7 @@ bool Program::validateSamplers(InfoLog *infoLog, const Caps &caps) for (unsigned int samplerIndex = mSamplerUniformRange.start; samplerIndex < mSamplerUniformRange.end; ++samplerIndex) { - const LinkedUniform &uniform = mData.mUniforms[samplerIndex]; + const LinkedUniform &uniform = mState.mUniforms[samplerIndex]; ASSERT(uniform.isSampler()); if (!uniform.staticUse) @@ -1380,15 +1400,16 @@ bool Program::isValidated() const GLuint Program::getActiveUniformBlockCount() const { - return static_cast<GLuint>(mData.mUniformBlocks.size()); + return static_cast<GLuint>(mState.mUniformBlocks.size()); } void Program::getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const { - ASSERT(uniformBlockIndex < - mData.mUniformBlocks.size()); // index must be smaller than getActiveUniformBlockCount() + ASSERT( + uniformBlockIndex < + mState.mUniformBlocks.size()); // index must be smaller than getActiveUniformBlockCount() - const UniformBlock &uniformBlock = mData.mUniformBlocks[uniformBlockIndex]; + const UniformBlock &uniformBlock = mState.mUniformBlocks[uniformBlockIndex]; if (bufSize > 0) { @@ -1411,10 +1432,11 @@ void Program::getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSiz void Program::getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const { - ASSERT(uniformBlockIndex < - mData.mUniformBlocks.size()); // index must be smaller than getActiveUniformBlockCount() + ASSERT( + uniformBlockIndex < + mState.mUniformBlocks.size()); // index must be smaller than getActiveUniformBlockCount() - const UniformBlock &uniformBlock = mData.mUniformBlocks[uniformBlockIndex]; + const UniformBlock &uniformBlock = mState.mUniformBlocks[uniformBlockIndex]; switch (pname) { @@ -1452,10 +1474,10 @@ GLint Program::getActiveUniformBlockMaxLength() const if (mLinked) { - unsigned int numUniformBlocks = static_cast<unsigned int>(mData.mUniformBlocks.size()); + unsigned int numUniformBlocks = static_cast<unsigned int>(mState.mUniformBlocks.size()); for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++) { - const UniformBlock &uniformBlock = mData.mUniformBlocks[uniformBlockIndex]; + const UniformBlock &uniformBlock = mState.mUniformBlocks[uniformBlockIndex]; if (!uniformBlock.name.empty()) { const int length = static_cast<int>(uniformBlock.name.length()) + 1; @@ -1476,10 +1498,10 @@ GLuint Program::getUniformBlockIndex(const std::string &name) const size_t subscript = GL_INVALID_INDEX; std::string baseName = gl::ParseUniformName(name, &subscript); - unsigned int numUniformBlocks = static_cast<unsigned int>(mData.mUniformBlocks.size()); + unsigned int numUniformBlocks = static_cast<unsigned int>(mState.mUniformBlocks.size()); for (unsigned int blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++) { - const gl::UniformBlock &uniformBlock = mData.mUniformBlocks[blockIndex]; + const gl::UniformBlock &uniformBlock = mState.mUniformBlocks[blockIndex]; if (uniformBlock.name == baseName) { const bool arrayElementZero = @@ -1497,47 +1519,47 @@ GLuint Program::getUniformBlockIndex(const std::string &name) const const UniformBlock &Program::getUniformBlockByIndex(GLuint index) const { - ASSERT(index < static_cast<GLuint>(mData.mUniformBlocks.size())); - return mData.mUniformBlocks[index]; + ASSERT(index < static_cast<GLuint>(mState.mUniformBlocks.size())); + return mState.mUniformBlocks[index]; } void Program::bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding) { - mData.mUniformBlockBindings[uniformBlockIndex] = uniformBlockBinding; + mState.mUniformBlockBindings[uniformBlockIndex] = uniformBlockBinding; mProgram->setUniformBlockBinding(uniformBlockIndex, uniformBlockBinding); } GLuint Program::getUniformBlockBinding(GLuint uniformBlockIndex) const { - return mData.getUniformBlockBinding(uniformBlockIndex); + return mState.getUniformBlockBinding(uniformBlockIndex); } void Program::resetUniformBlockBindings() { for (unsigned int blockId = 0; blockId < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; blockId++) { - mData.mUniformBlockBindings[blockId] = 0; + mState.mUniformBlockBindings[blockId] = 0; } - mData.mActiveUniformBlockBindings.reset(); + mState.mActiveUniformBlockBindings.reset(); } void Program::setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode) { - mData.mTransformFeedbackVaryingNames.resize(count); + mState.mTransformFeedbackVaryingNames.resize(count); for (GLsizei i = 0; i < count; i++) { - mData.mTransformFeedbackVaryingNames[i] = varyings[i]; + mState.mTransformFeedbackVaryingNames[i] = varyings[i]; } - mData.mTransformFeedbackBufferMode = bufferMode; + mState.mTransformFeedbackBufferMode = bufferMode; } void Program::getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const { if (mLinked) { - ASSERT(index < mData.mTransformFeedbackVaryingVars.size()); - const sh::Varying &varying = mData.mTransformFeedbackVaryingVars[index]; + ASSERT(index < mState.mTransformFeedbackVaryingVars.size()); + const sh::Varying &varying = mState.mTransformFeedbackVaryingVars[index]; GLsizei lastNameIdx = std::min(bufSize - 1, static_cast<GLsizei>(varying.name.length())); if (length) { @@ -1563,7 +1585,7 @@ GLsizei Program::getTransformFeedbackVaryingCount() const { if (mLinked) { - return static_cast<GLsizei>(mData.mTransformFeedbackVaryingVars.size()); + return static_cast<GLsizei>(mState.mTransformFeedbackVaryingVars.size()); } else { @@ -1576,7 +1598,7 @@ GLsizei Program::getTransformFeedbackVaryingMaxLength() const if (mLinked) { GLsizei maxSize = 0; - for (const sh::Varying &varying : mData.mTransformFeedbackVaryingVars) + for (const sh::Varying &varying : mState.mTransformFeedbackVaryingVars) { maxSize = std::max(maxSize, static_cast<GLsizei>(varying.name.length() + 1)); } @@ -1591,7 +1613,7 @@ GLsizei Program::getTransformFeedbackVaryingMaxLength() const GLenum Program::getTransformFeedbackBufferMode() const { - return mData.mTransformFeedbackBufferMode; + return mState.mTransformFeedbackBufferMode; } // static @@ -1640,10 +1662,13 @@ bool Program::linkVaryings(InfoLog &infoLog, return true; } -bool Program::linkUniforms(gl::InfoLog &infoLog, const gl::Caps &caps) +bool Program::linkUniforms(gl::InfoLog &infoLog, + const gl::Caps &caps, + const Bindings &uniformBindings) { - const std::vector<sh::Uniform> &vertexUniforms = mData.mAttachedVertexShader->getUniforms(); - const std::vector<sh::Uniform> &fragmentUniforms = mData.mAttachedFragmentShader->getUniforms(); + const std::vector<sh::Uniform> &vertexUniforms = mState.mAttachedVertexShader->getUniforms(); + const std::vector<sh::Uniform> &fragmentUniforms = + mState.mAttachedFragmentShader->getUniforms(); // Check that uniforms defined in the vertex and fragment shaders are identical std::map<std::string, LinkedUniform> linkedUniforms; @@ -1674,27 +1699,105 @@ bool Program::linkUniforms(gl::InfoLog &infoLog, const gl::Caps &caps) return false; } - indexUniforms(); + if (!indexUniforms(infoLog, caps, uniformBindings)) + { + return false; + } return true; } -void Program::indexUniforms() +bool Program::indexUniforms(gl::InfoLog &infoLog, + const gl::Caps &caps, + const Bindings &uniformBindings) { - for (size_t uniformIndex = 0; uniformIndex < mData.mUniforms.size(); uniformIndex++) + // Uniforms awaiting a location + std::vector<VariableLocation> unboundUniforms; + std::map<GLuint, VariableLocation> boundUniforms; + int maxUniformLocation = -1; + + // Gather bound and unbound uniforms + for (size_t uniformIndex = 0; uniformIndex < mState.mUniforms.size(); uniformIndex++) { - const gl::LinkedUniform &uniform = mData.mUniforms[uniformIndex]; + const gl::LinkedUniform &uniform = mState.mUniforms[uniformIndex]; + + if (uniform.isBuiltIn()) + { + continue; + } + + int bindingLocation = uniformBindings.getBinding(uniform.name); + + // Verify that this location isn't bound twice + if (bindingLocation != -1 && boundUniforms.find(bindingLocation) != boundUniforms.end()) + { + infoLog << "Multiple uniforms bound to location " << bindingLocation << "."; + return false; + } for (unsigned int arrayIndex = 0; arrayIndex < uniform.elementCount(); arrayIndex++) { - if (!uniform.isBuiltIn()) + VariableLocation location(uniform.name, arrayIndex, + static_cast<unsigned int>(uniformIndex)); + + if (arrayIndex == 0 && bindingLocation != -1) { - // Assign in-order uniform locations - mData.mUniformLocations.push_back(gl::VariableLocation( - uniform.name, arrayIndex, static_cast<unsigned int>(uniformIndex))); + boundUniforms[bindingLocation] = location; + maxUniformLocation = std::max(maxUniformLocation, bindingLocation); } + else + { + unboundUniforms.push_back(location); + } + } + } + + // Gather the reserved bindings, ones that are bound but not referenced. Other uniforms should + // not be assigned to those locations. + std::set<GLuint> reservedLocations; + for (const auto &binding : uniformBindings) + { + GLuint location = binding.second; + if (boundUniforms.find(location) == boundUniforms.end()) + { + reservedLocations.insert(location); + maxUniformLocation = std::max(maxUniformLocation, static_cast<int>(location)); } } + + // Make enough space for all uniforms, bound and unbound + mState.mUniformLocations.resize( + std::max(unboundUniforms.size() + boundUniforms.size() + reservedLocations.size(), + static_cast<size_t>(maxUniformLocation + 1))); + + // Assign bound uniforms + for (const auto &boundUniform : boundUniforms) + { + mState.mUniformLocations[boundUniform.first] = boundUniform.second; + } + + // Assign reserved uniforms + for (const auto &reservedLocation : reservedLocations) + { + mState.mUniformLocations[reservedLocation].ignored = true; + } + + // Assign unbound uniforms + size_t nextUniformLocation = 0; + for (const auto &unboundUniform : unboundUniforms) + { + while (mState.mUniformLocations[nextUniformLocation].used || + mState.mUniformLocations[nextUniformLocation].ignored) + { + nextUniformLocation++; + } + + ASSERT(nextUniformLocation < mState.mUniformLocations.size()); + mState.mUniformLocations[nextUniformLocation] = unboundUniform; + nextUniformLocation++; + } + + return true; } bool Program::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform) @@ -1715,17 +1818,17 @@ bool Program::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::stri } // Determines the mapping between GL attributes and Direct3D 9 vertex stream usage indices -bool Program::linkAttributes(const gl::Data &data, +bool Program::linkAttributes(const ContextState &data, InfoLog &infoLog, - const AttributeBindings &attributeBindings, + const Bindings &attributeBindings, const Shader *vertexShader) { unsigned int usedLocations = 0; - mData.mAttributes = vertexShader->getActiveAttributes(); + mState.mAttributes = vertexShader->getActiveAttributes(); GLuint maxAttribs = data.caps->maxVertexAttributes; // TODO(jmadill): handle aliasing robustly - if (mData.mAttributes.size() > maxAttribs) + if (mState.mAttributes.size() > maxAttribs) { infoLog << "Too many vertex attributes."; return false; @@ -1734,12 +1837,12 @@ bool Program::linkAttributes(const gl::Data &data, std::vector<sh::Attribute *> usedAttribMap(data.caps->maxVertexAttributes, nullptr); // Link attributes that have a binding location - for (sh::Attribute &attribute : mData.mAttributes) + for (sh::Attribute &attribute : mState.mAttributes) { // TODO(jmadill): do staticUse filtering step here, or not at all ASSERT(attribute.staticUse); - int bindingLocation = attributeBindings.getAttributeBinding(attribute.name); + int bindingLocation = attributeBindings.getBinding(attribute.name); if (attribute.location == -1 && bindingLocation != -1) { attribute.location = bindingLocation; @@ -1786,7 +1889,7 @@ bool Program::linkAttributes(const gl::Data &data, } // Link attributes that don't have a binding location - for (sh::Attribute &attribute : mData.mAttributes) + for (sh::Attribute &attribute : mState.mAttributes) { ASSERT(attribute.staticUse); @@ -1806,7 +1909,7 @@ bool Program::linkAttributes(const gl::Data &data, } } - for (const sh::Attribute &attribute : mData.mAttributes) + for (const sh::Attribute &attribute : mState.mAttributes) { ASSERT(attribute.staticUse); ASSERT(attribute.location != -1); @@ -1814,7 +1917,7 @@ bool Program::linkAttributes(const gl::Data &data, for (int r = 0; r < regs; r++) { - mData.mActiveAttribLocationsMask.set(attribute.location + r); + mState.mActiveAttribLocationsMask.set(attribute.location + r); } } @@ -1823,8 +1926,8 @@ bool Program::linkAttributes(const gl::Data &data, bool Program::linkUniformBlocks(InfoLog &infoLog, const Caps &caps) { - const Shader &vertexShader = *mData.mAttachedVertexShader; - const Shader &fragmentShader = *mData.mAttachedFragmentShader; + const Shader &vertexShader = *mState.mAttachedVertexShader; + const Shader &fragmentShader = *mState.mAttachedFragmentShader; const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks = vertexShader.getInterfaceBlocks(); const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks = fragmentShader.getInterfaceBlocks(); @@ -2017,7 +2120,7 @@ bool Program::linkValidateTransformFeedback(InfoLog &infoLog, std::set<std::string> uniqueNames; - for (const std::string &tfVaryingName : mData.mTransformFeedbackVaryingNames) + for (const std::string &tfVaryingName : mState.mTransformFeedbackVaryingNames) { bool found = false; for (const sh::Varying *varying : varyings) @@ -2040,7 +2143,7 @@ bool Program::linkValidateTransformFeedback(InfoLog &infoLog, // TODO(jmadill): Investigate implementation limits on D3D11 size_t componentCount = gl::VariableComponentCount(varying->type); - if (mData.mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS && + if (mState.mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS && componentCount > caps.maxTransformFeedbackSeparateComponents) { infoLog << "Transform feedback varying's " << varying->name << " components (" @@ -2066,7 +2169,7 @@ bool Program::linkValidateTransformFeedback(InfoLog &infoLog, UNUSED_ASSERTION_VARIABLE(found); } - if (mData.mTransformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS && + if (mState.mTransformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS && totalComponents > caps.maxTransformFeedbackInterleavedComponents) { infoLog << "Transform feedback varying total components (" << totalComponents @@ -2081,14 +2184,14 @@ bool Program::linkValidateTransformFeedback(InfoLog &infoLog, void Program::gatherTransformFeedbackVaryings(const std::vector<const sh::Varying *> &varyings) { // Gather the linked varyings that are used for transform feedback, they should all exist. - mData.mTransformFeedbackVaryingVars.clear(); - for (const std::string &tfVaryingName : mData.mTransformFeedbackVaryingNames) + mState.mTransformFeedbackVaryingVars.clear(); + for (const std::string &tfVaryingName : mState.mTransformFeedbackVaryingNames) { for (const sh::Varying *varying : varyings) { if (tfVaryingName == varying->name) { - mData.mTransformFeedbackVaryingVars.push_back(*varying); + mState.mTransformFeedbackVaryingVars.push_back(*varying); break; } } @@ -2100,7 +2203,7 @@ std::vector<const sh::Varying *> Program::getMergedVaryings() const std::set<std::string> uniqueNames; std::vector<const sh::Varying *> varyings; - for (const sh::Varying &varying : mData.mAttachedVertexShader->getVaryings()) + for (const sh::Varying &varying : mState.mAttachedVertexShader->getVaryings()) { if (uniqueNames.count(varying.name) == 0) { @@ -2109,7 +2212,7 @@ std::vector<const sh::Varying *> Program::getMergedVaryings() const } } - for (const sh::Varying &varying : mData.mAttachedFragmentShader->getVaryings()) + for (const sh::Varying &varying : mState.mAttachedFragmentShader->getVaryings()) { if (uniqueNames.count(varying.name) == 0) { @@ -2123,7 +2226,7 @@ std::vector<const sh::Varying *> Program::getMergedVaryings() const void Program::linkOutputVariables() { - const Shader *fragmentShader = mData.mAttachedFragmentShader; + const Shader *fragmentShader = mState.mAttachedFragmentShader; ASSERT(fragmentShader != nullptr); // Skip this step for GLES2 shaders. @@ -2152,9 +2255,9 @@ void Program::linkOutputVariables() elementIndex++) { const int location = baseLocation + elementIndex; - ASSERT(mData.mOutputVariables.count(location) == 0); + ASSERT(mState.mOutputVariables.count(location) == 0); unsigned int element = outputVariable.isArray() ? elementIndex : GL_INVALID_INDEX; - mData.mOutputVariables[location] = + mState.mOutputVariables[location] = VariableLocation(outputVariable.name, element, outputVariableIndex); } } @@ -2162,7 +2265,7 @@ void Program::linkOutputVariables() bool Program::flattenUniformsAndCheckCaps(const Caps &caps, InfoLog &infoLog) { - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); + const gl::Shader *vertexShader = mState.getAttachedVertexShader(); VectorAndSamplerCount vsCounts; std::vector<LinkedUniform> samplerUniforms; @@ -2189,7 +2292,7 @@ bool Program::flattenUniformsAndCheckCaps(const Caps &caps, InfoLog &infoLog) return false; } - const gl::Shader *fragmentShader = mData.getAttachedFragmentShader(); + const gl::Shader *fragmentShader = mState.getAttachedFragmentShader(); VectorAndSamplerCount fsCounts; for (const sh::Uniform &uniform : fragmentShader->getUniforms()) @@ -2214,11 +2317,11 @@ bool Program::flattenUniformsAndCheckCaps(const Caps &caps, InfoLog &infoLog) return false; } - mSamplerUniformRange.start = static_cast<unsigned int>(mData.mUniforms.size()); + mSamplerUniformRange.start = static_cast<unsigned int>(mState.mUniforms.size()); mSamplerUniformRange.end = mSamplerUniformRange.start + static_cast<unsigned int>(samplerUniforms.size()); - mData.mUniforms.insert(mData.mUniforms.end(), samplerUniforms.begin(), samplerUniforms.end()); + mState.mUniforms.insert(mState.mUniforms.end(), samplerUniforms.begin(), samplerUniforms.end()); return true; } @@ -2249,7 +2352,8 @@ Program::VectorAndSamplerCount Program::flattenUniform(const sh::ShaderVariable // Not a struct bool isSampler = IsSamplerType(uniform.type); - if (!UniformInList(mData.getUniforms(), fullName) && !UniformInList(*samplerUniforms, fullName)) + if (!UniformInList(mState.getUniforms(), fullName) && + !UniformInList(*samplerUniforms, fullName)) { gl::LinkedUniform linkedUniform(uniform.type, uniform.precision, fullName, uniform.arraySize, -1, @@ -2263,7 +2367,7 @@ Program::VectorAndSamplerCount Program::flattenUniform(const sh::ShaderVariable } else { - mData.mUniforms.push_back(linkedUniform); + mState.mUniforms.push_back(linkedUniform); } } @@ -2282,9 +2386,9 @@ void Program::gatherInterfaceBlockInfo() { std::set<std::string> visitedList; - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); + const gl::Shader *vertexShader = mState.getAttachedVertexShader(); - ASSERT(mData.mUniformBlocks.empty()); + ASSERT(mState.mUniformBlocks.empty()); for (const sh::InterfaceBlock &vertexBlock : vertexShader->getInterfaceBlocks()) { // Only 'packed' blocks are allowed to be considered inacive. @@ -2298,7 +2402,7 @@ void Program::gatherInterfaceBlockInfo() visitedList.insert(vertexBlock.name); } - const gl::Shader *fragmentShader = mData.getAttachedFragmentShader(); + const gl::Shader *fragmentShader = mState.getAttachedFragmentShader(); for (const sh::InterfaceBlock &fragmentBlock : fragmentShader->getInterfaceBlocks()) { @@ -2308,7 +2412,7 @@ void Program::gatherInterfaceBlockInfo() if (visitedList.count(fragmentBlock.name) > 0) { - for (gl::UniformBlock &block : mData.mUniformBlocks) + for (gl::UniformBlock &block : mState.mUniformBlocks) { if (block.name == fragmentBlock.name) { @@ -2356,14 +2460,14 @@ void Program::defineUniformBlockMembers(const std::vector<VarT> &fields, // Since block uniforms have no location, we don't need to store them in the uniform // locations list. - mData.mUniforms.push_back(newUniform); + mState.mUniforms.push_back(newUniform); } } } void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenum shaderType) { - int blockIndex = static_cast<int>(mData.mUniformBlocks.size()); + int blockIndex = static_cast<int>(mState.mUniformBlocks.size()); size_t blockSize = 0; // Don't define this block at all if it's not active in the implementation. @@ -2374,9 +2478,9 @@ void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenu // Track the first and last uniform index to determine the range of active uniforms in the // block. - size_t firstBlockUniformIndex = mData.mUniforms.size(); + size_t firstBlockUniformIndex = mState.mUniforms.size(); defineUniformBlockMembers(interfaceBlock.fields, interfaceBlock.fieldPrefix(), blockIndex); - size_t lastBlockUniformIndex = mData.mUniforms.size(); + size_t lastBlockUniformIndex = mState.mUniforms.size(); std::vector<unsigned int> blockUniformIndexes; for (size_t blockUniformIndex = firstBlockUniformIndex; @@ -2411,7 +2515,7 @@ void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenu ASSERT(blockElementSize == blockSize); block.dataSize = static_cast<unsigned int>(blockElementSize); - mData.mUniformBlocks.push_back(block); + mState.mUniformBlocks.push_back(block); } } else @@ -2430,15 +2534,15 @@ void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenu } block.dataSize = static_cast<unsigned int>(blockSize); - mData.mUniformBlocks.push_back(block); + mState.mUniformBlocks.push_back(block); } } template <typename T> void Program::setUniformInternal(GLint location, GLsizei count, const T *v) { - const VariableLocation &locationInfo = mData.mUniformLocations[location]; - LinkedUniform *linkedUniform = &mData.mUniforms[locationInfo.index]; + const VariableLocation &locationInfo = mState.mUniformLocations[location]; + LinkedUniform *linkedUniform = &mState.mUniforms[locationInfo.index]; uint8_t *destPointer = linkedUniform->getDataPtrToElement(locationInfo.element); if (VariableComponentType(linkedUniform->type) == GL_BOOL) @@ -2476,8 +2580,8 @@ void Program::setMatrixUniformInternal(GLint location, } // Perform a transposing copy. - const VariableLocation &locationInfo = mData.mUniformLocations[location]; - LinkedUniform *linkedUniform = &mData.mUniforms[locationInfo.index]; + const VariableLocation &locationInfo = mState.mUniformLocations[location]; + LinkedUniform *linkedUniform = &mState.mUniforms[locationInfo.index]; T *destPtr = reinterpret_cast<T *>(linkedUniform->getDataPtrToElement(locationInfo.element)); for (GLsizei element = 0; element < count; ++element) { @@ -2496,8 +2600,8 @@ void Program::setMatrixUniformInternal(GLint location, template <typename DestT> void Program::getUniformInternal(GLint location, DestT *dataOut) const { - const VariableLocation &locationInfo = mData.mUniformLocations[location]; - const LinkedUniform &uniform = mData.mUniforms[locationInfo.index]; + const VariableLocation &locationInfo = mState.mUniformLocations[location]; + const LinkedUniform &uniform = mState.mUniforms[locationInfo.index]; const uint8_t *srcPointer = uniform.getDataPtrToElement(locationInfo.element); diff --git a/chromium/third_party/angle/src/libANGLE/Program.h b/chromium/third_party/angle/src/libANGLE/Program.h index f885ad1694b..0942c12ce7e 100644 --- a/chromium/third_party/angle/src/libANGLE/Program.h +++ b/chromium/third_party/angle/src/libANGLE/Program.h @@ -30,7 +30,7 @@ namespace rx { -class ImplFactory; +class GLImplFactory; class ProgramImpl; struct TranslatedAttribute; } @@ -38,11 +38,10 @@ struct TranslatedAttribute; namespace gl { struct Caps; -struct Data; +struct ContextState; class ResourceManager; class Shader; class InfoLog; -class AttributeBindings; class Buffer; class Framebuffer; struct UniformBlock; @@ -50,19 +49,6 @@ struct LinkedUniform; extern const char * const g_fakepath; -class AttributeBindings -{ - public: - AttributeBindings(); - ~AttributeBindings(); - - void bindAttributeLocation(GLuint index, const char *name); - int getAttributeBinding(const std::string &name) const; - - private: - std::set<std::string> mAttributeBinding[MAX_VERTEX_ATTRIBS]; -}; - class InfoLog : angle::NonCopyable { public: @@ -142,89 +128,90 @@ struct VariableLocation std::string name; unsigned int element; unsigned int index; + + // If this is a valid uniform location + bool used; + + // If this location was bound to an unreferenced uniform. Setting data on this uniform is a + // no-op. + bool ignored; }; -class Program final : angle::NonCopyable, public LabeledObject +class ProgramState final : angle::NonCopyable { public: - class Data final : angle::NonCopyable - { - public: - Data(); - ~Data(); + ProgramState(); + ~ProgramState(); - const std::string &getLabel(); + const std::string &getLabel(); - const Shader *getAttachedVertexShader() const { return mAttachedVertexShader; } - const Shader *getAttachedFragmentShader() const { return mAttachedFragmentShader; } - const std::vector<std::string> &getTransformFeedbackVaryingNames() const - { - return mTransformFeedbackVaryingNames; - } - GLint getTransformFeedbackBufferMode() const { return mTransformFeedbackBufferMode; } - GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const - { - ASSERT(uniformBlockIndex < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS); - return mUniformBlockBindings[uniformBlockIndex]; - } - const UniformBlockBindingMask &getActiveUniformBlockBindingsMask() const - { - return mActiveUniformBlockBindings; - } - const std::vector<sh::Attribute> &getAttributes() const { return mAttributes; } - const AttributesMask &getActiveAttribLocationsMask() const - { - return mActiveAttribLocationsMask; - } - const std::map<int, VariableLocation> &getOutputVariables() const - { - return mOutputVariables; - } - const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; } - const std::vector<VariableLocation> &getUniformLocations() const - { - return mUniformLocations; - } - const std::vector<UniformBlock> &getUniformBlocks() const { return mUniformBlocks; } + const Shader *getAttachedVertexShader() const { return mAttachedVertexShader; } + const Shader *getAttachedFragmentShader() const { return mAttachedFragmentShader; } + const std::vector<std::string> &getTransformFeedbackVaryingNames() const + { + return mTransformFeedbackVaryingNames; + } + GLint getTransformFeedbackBufferMode() const { return mTransformFeedbackBufferMode; } + GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const + { + ASSERT(uniformBlockIndex < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS); + return mUniformBlockBindings[uniformBlockIndex]; + } + const UniformBlockBindingMask &getActiveUniformBlockBindingsMask() const + { + return mActiveUniformBlockBindings; + } + const std::vector<sh::Attribute> &getAttributes() const { return mAttributes; } + const AttributesMask &getActiveAttribLocationsMask() const + { + return mActiveAttribLocationsMask; + } + const std::map<int, VariableLocation> &getOutputVariables() const { return mOutputVariables; } + const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; } + const std::vector<VariableLocation> &getUniformLocations() const { return mUniformLocations; } + const std::vector<UniformBlock> &getUniformBlocks() const { return mUniformBlocks; } - const LinkedUniform *getUniformByName(const std::string &name) const; - GLint getUniformLocation(const std::string &name) const; - GLuint getUniformIndex(const std::string &name) const; + const LinkedUniform *getUniformByName(const std::string &name) const; + GLint getUniformLocation(const std::string &name) const; + GLuint getUniformIndex(const std::string &name) const; - private: - friend class Program; + private: + friend class Program; - std::string mLabel; + std::string mLabel; - Shader *mAttachedFragmentShader; - Shader *mAttachedVertexShader; + Shader *mAttachedFragmentShader; + Shader *mAttachedVertexShader; - std::vector<std::string> mTransformFeedbackVaryingNames; - std::vector<sh::Varying> mTransformFeedbackVaryingVars; - GLenum mTransformFeedbackBufferMode; + std::vector<std::string> mTransformFeedbackVaryingNames; + std::vector<sh::Varying> mTransformFeedbackVaryingVars; + GLenum mTransformFeedbackBufferMode; - GLuint mUniformBlockBindings[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS]; - UniformBlockBindingMask mActiveUniformBlockBindings; + GLuint mUniformBlockBindings[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS]; + UniformBlockBindingMask mActiveUniformBlockBindings; - std::vector<sh::Attribute> mAttributes; - std::bitset<MAX_VERTEX_ATTRIBS> mActiveAttribLocationsMask; + std::vector<sh::Attribute> mAttributes; + std::bitset<MAX_VERTEX_ATTRIBS> mActiveAttribLocationsMask; - // Uniforms are sorted in order: - // 1. Non-sampler uniforms - // 2. Sampler uniforms - // 3. Uniform block uniforms - // This makes sampler validation easier, since we don't need a separate list. - std::vector<LinkedUniform> mUniforms; - std::vector<VariableLocation> mUniformLocations; - std::vector<UniformBlock> mUniformBlocks; + // Uniforms are sorted in order: + // 1. Non-sampler uniforms + // 2. Sampler uniforms + // 3. Uniform block uniforms + // This makes sampler validation easier, since we don't need a separate list. + std::vector<LinkedUniform> mUniforms; + std::vector<VariableLocation> mUniformLocations; + std::vector<UniformBlock> mUniformBlocks; - // TODO(jmadill): use unordered/hash map when available - std::map<int, VariableLocation> mOutputVariables; + // TODO(jmadill): use unordered/hash map when available + std::map<int, VariableLocation> mOutputVariables; - bool mBinaryRetrieveableHint; - }; + bool mBinaryRetrieveableHint; +}; - Program(rx::ImplFactory *factory, ResourceManager *manager, GLuint handle); +class Program final : angle::NonCopyable, public LabeledObject +{ + public: + Program(rx::GLImplFactory *factory, ResourceManager *manager, GLuint handle); ~Program(); GLuint id() const { return mHandle; } @@ -240,8 +227,9 @@ class Program final : angle::NonCopyable, public LabeledObject int getAttachedShadersCount() const; void bindAttributeLocation(GLuint index, const char *name); + void bindUniformLocation(GLuint index, const char *name); - Error link(const gl::Data &data); + Error link(const ContextState &data); bool isLinked() const; Error loadBinary(GLenum binaryFormat, const void *binary, GLsizei length); @@ -260,7 +248,7 @@ class Program final : angle::NonCopyable, public LabeledObject void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); GLint getActiveAttributeCount() const; GLint getActiveAttributeMaxLength() const; - const std::vector<sh::Attribute> &getAttributes() const { return mData.mAttributes; } + const std::vector<sh::Attribute> &getAttributes() const { return mState.mAttributes; } GLint getFragDataLocation(const std::string &name) const; @@ -274,6 +262,7 @@ class Program final : angle::NonCopyable, public LabeledObject GLint getActiveUniformMaxLength() const; GLint getActiveUniformi(GLuint index, GLenum pname) const; bool isValidUniformLocation(GLint location) const; + bool isIgnoredUniformLocation(GLint location) const; const LinkedUniform &getUniformByLocation(GLint location) const; GLint getUniformLocation(const std::string &name) const; @@ -337,23 +326,37 @@ class Program final : angle::NonCopyable, public LabeledObject const AttributesMask &getActiveAttribLocationsMask() const { - return mData.mActiveAttribLocationsMask; + return mState.mActiveAttribLocationsMask; } private: + class Bindings final : angle::NonCopyable + { + public: + void bindLocation(GLuint index, const std::string &name); + int getBinding(const std::string &name) const; + + typedef std::unordered_map<std::string, GLuint>::const_iterator const_iterator; + const_iterator begin() const; + const_iterator end() const; + + private: + std::unordered_map<std::string, GLuint> mBindings; + }; + void unlink(bool destroy = false); void resetUniformBlockBindings(); - bool linkAttributes(const gl::Data &data, + bool linkAttributes(const ContextState &data, InfoLog &infoLog, - const AttributeBindings &attributeBindings, + const Bindings &attributeBindings, const Shader *vertexShader); bool linkUniformBlocks(InfoLog &infoLog, const Caps &caps); static bool linkVaryings(InfoLog &infoLog, const Shader *vertexShader, const Shader *fragmentShader); - bool linkUniforms(gl::InfoLog &infoLog, const gl::Caps &caps); - void indexUniforms(); + bool linkUniforms(gl::InfoLog &infoLog, const gl::Caps &caps, const Bindings &uniformBindings); + bool indexUniforms(gl::InfoLog &infoLog, const gl::Caps &caps, const Bindings &uniformBindings); bool areMatchingInterfaceBlocks(gl::InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock); @@ -415,12 +418,13 @@ class Program final : angle::NonCopyable, public LabeledObject template <typename DestT> void getUniformInternal(GLint location, DestT *dataOut) const; - Data mData; + ProgramState mState; rx::ProgramImpl *mProgram; bool mValidated; - AttributeBindings mAttributeBindings; + Bindings mAttributeBindings; + Bindings mUniformBindings; bool mLinked; bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use diff --git a/chromium/third_party/angle/src/libANGLE/Program_unittest.cpp b/chromium/third_party/angle/src/libANGLE/Program_unittest.cpp index 78b9a80d094..6d99f00195e 100644 --- a/chromium/third_party/angle/src/libANGLE/Program_unittest.cpp +++ b/chromium/third_party/angle/src/libANGLE/Program_unittest.cpp @@ -8,7 +8,6 @@ #include <gtest/gtest.h> -#include "tests/angle_unittests_utils.h" #include "libANGLE/Program.h" using namespace gl; diff --git a/chromium/third_party/angle/src/libANGLE/ResourceManager.cpp b/chromium/third_party/angle/src/libANGLE/ResourceManager.cpp index 3872d39f9b6..7fb71097c02 100644 --- a/chromium/third_party/angle/src/libANGLE/ResourceManager.cpp +++ b/chromium/third_party/angle/src/libANGLE/ResourceManager.cpp @@ -10,19 +10,17 @@ #include "libANGLE/ResourceManager.h" #include "libANGLE/Buffer.h" +#include "libANGLE/Fence.h" #include "libANGLE/Program.h" #include "libANGLE/Renderbuffer.h" +#include "libANGLE/Sampler.h" #include "libANGLE/Shader.h" #include "libANGLE/Texture.h" -#include "libANGLE/Sampler.h" -#include "libANGLE/Fence.h" -#include "libANGLE/renderer/Renderer.h" +#include "libANGLE/renderer/GLImplFactory.h" namespace gl { -ResourceManager::ResourceManager(rx::ImplFactory *factory) - : mFactory(factory), - mRefCount(1) +ResourceManager::ResourceManager() : mRefCount(1) { } @@ -88,13 +86,15 @@ GLuint ResourceManager::createBuffer() } // Returns an unused shader/program name -GLuint ResourceManager::createShader(const gl::Limitations &rendererLimitations, GLenum type) +GLuint ResourceManager::createShader(rx::GLImplFactory *factory, + const gl::Limitations &rendererLimitations, + GLenum type) { GLuint handle = mProgramShaderHandleAllocator.allocate(); if (type == GL_VERTEX_SHADER || type == GL_FRAGMENT_SHADER) { - mShaderMap[handle] = new Shader(this, mFactory, rendererLimitations, type, handle); + mShaderMap[handle] = new Shader(this, factory, rendererLimitations, type, handle); } else UNREACHABLE(); @@ -102,11 +102,11 @@ GLuint ResourceManager::createShader(const gl::Limitations &rendererLimitations, } // Returns an unused program/shader name -GLuint ResourceManager::createProgram() +GLuint ResourceManager::createProgram(rx::GLImplFactory *factory) { GLuint handle = mProgramShaderHandleAllocator.allocate(); - mProgramMap[handle] = new Program(mFactory, this, handle); + mProgramMap[handle] = new Program(factory, this, handle); return handle; } @@ -142,11 +142,11 @@ GLuint ResourceManager::createSampler() } // Returns the next unused fence name, and allocates the fence -GLuint ResourceManager::createFenceSync() +GLuint ResourceManager::createFenceSync(rx::GLImplFactory *factory) { GLuint handle = mFenceSyncHandleAllocator.allocate(); - FenceSync *fenceSync = new FenceSync(mFactory->createFenceSync(), handle); + FenceSync *fenceSync = new FenceSync(factory->createFenceSync(), handle); fenceSync->addRef(); mFenceSyncMap[handle] = fenceSync; @@ -357,7 +357,7 @@ void ResourceManager::setRenderbuffer(GLuint handle, Renderbuffer *buffer) mRenderbufferMap[handle] = buffer; } -Buffer *ResourceManager::checkBufferAllocation(GLuint handle) +Buffer *ResourceManager::checkBufferAllocation(rx::GLImplFactory *factory, GLuint handle) { if (handle == 0) { @@ -372,7 +372,7 @@ Buffer *ResourceManager::checkBufferAllocation(GLuint handle) return bufferMapIt->second; } - Buffer *buffer = new Buffer(mFactory->createBuffer(), handle); + Buffer *buffer = new Buffer(factory->createBuffer(), handle); buffer->addRef(); if (handleAllocated) @@ -388,7 +388,9 @@ Buffer *ResourceManager::checkBufferAllocation(GLuint handle) return buffer; } -Texture *ResourceManager::checkTextureAllocation(GLuint handle, GLenum type) +Texture *ResourceManager::checkTextureAllocation(rx::GLImplFactory *factory, + GLuint handle, + GLenum type) { if (handle == 0) { @@ -403,7 +405,7 @@ Texture *ResourceManager::checkTextureAllocation(GLuint handle, GLenum type) return textureMapIt->second; } - Texture *texture = new Texture(mFactory->createTexture(type), handle, type); + Texture *texture = new Texture(factory, handle, type); texture->addRef(); if (handleAllocated) @@ -419,7 +421,8 @@ Texture *ResourceManager::checkTextureAllocation(GLuint handle, GLenum type) return texture; } -Renderbuffer *ResourceManager::checkRenderbufferAllocation(GLuint handle) +Renderbuffer *ResourceManager::checkRenderbufferAllocation(rx::GLImplFactory *factory, + GLuint handle) { if (handle == 0) { @@ -434,7 +437,7 @@ Renderbuffer *ResourceManager::checkRenderbufferAllocation(GLuint handle) return renderbufferMapIt->second; } - Renderbuffer *renderbuffer = new Renderbuffer(mFactory->createRenderbuffer(), handle); + Renderbuffer *renderbuffer = new Renderbuffer(factory->createRenderbuffer(), handle); renderbuffer->addRef(); if (handleAllocated) @@ -450,7 +453,7 @@ Renderbuffer *ResourceManager::checkRenderbufferAllocation(GLuint handle) return renderbuffer; } -Sampler *ResourceManager::checkSamplerAllocation(GLuint samplerHandle) +Sampler *ResourceManager::checkSamplerAllocation(rx::GLImplFactory *factory, GLuint samplerHandle) { // Samplers cannot be created via Bind if (samplerHandle == 0) @@ -462,7 +465,7 @@ Sampler *ResourceManager::checkSamplerAllocation(GLuint samplerHandle) if (!sampler) { - sampler = new Sampler(mFactory, samplerHandle); + sampler = new Sampler(factory, samplerHandle); mSamplerMap[samplerHandle] = sampler; sampler->addRef(); } diff --git a/chromium/third_party/angle/src/libANGLE/ResourceManager.h b/chromium/third_party/angle/src/libANGLE/ResourceManager.h index 4845e398048..90013156353 100644 --- a/chromium/third_party/angle/src/libANGLE/ResourceManager.h +++ b/chromium/third_party/angle/src/libANGLE/ResourceManager.h @@ -17,13 +17,12 @@ namespace rx { -class ImplFactory; +class GLImplFactory; } namespace gl { class Buffer; -struct Data; class FenceSync; struct Limitations; class Program; @@ -35,19 +34,21 @@ class Texture; class ResourceManager : angle::NonCopyable { public: - explicit ResourceManager(rx::ImplFactory *factory); + ResourceManager(); ~ResourceManager(); void addRef(); void release(); GLuint createBuffer(); - GLuint createShader(const gl::Limitations &rendererLimitations, GLenum type); - GLuint createProgram(); + GLuint createShader(rx::GLImplFactory *factory, + const gl::Limitations &rendererLimitations, + GLenum type); + GLuint createProgram(rx::GLImplFactory *factory); GLuint createTexture(); GLuint createRenderbuffer(); GLuint createSampler(); - GLuint createFenceSync(); + GLuint createFenceSync(rx::GLImplFactory *factory); void deleteBuffer(GLuint buffer); void deleteShader(GLuint shader); @@ -67,17 +68,17 @@ class ResourceManager : angle::NonCopyable void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer); - Buffer *checkBufferAllocation(GLuint handle); - Texture *checkTextureAllocation(GLuint handle, GLenum type); - Renderbuffer *checkRenderbufferAllocation(GLuint handle); - Sampler *checkSamplerAllocation(GLuint samplerHandle); + Buffer *checkBufferAllocation(rx::GLImplFactory *factory, GLuint handle); + Texture *checkTextureAllocation(rx::GLImplFactory *factory, GLuint handle, GLenum type); + Renderbuffer *checkRenderbufferAllocation(rx::GLImplFactory *factory, GLuint handle); + Sampler *checkSamplerAllocation(rx::GLImplFactory *factory, GLuint samplerHandle); bool isSampler(GLuint sampler); private: void createTextureInternal(GLuint handle); - rx::ImplFactory *mFactory; + ; std::size_t mRefCount; ResourceMap<Buffer> mBufferMap; diff --git a/chromium/third_party/angle/src/libANGLE/ResourceManager_unittest.cpp b/chromium/third_party/angle/src/libANGLE/ResourceManager_unittest.cpp index d6ddeaf86af..ded2dc5389c 100644 --- a/chromium/third_party/angle/src/libANGLE/ResourceManager_unittest.cpp +++ b/chromium/third_party/angle/src/libANGLE/ResourceManager_unittest.cpp @@ -9,29 +9,23 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include "tests/angle_unittests_utils.h" #include "libANGLE/ResourceManager.h" +#include "tests/angle_unittests_utils.h" using namespace rx; using namespace gl; -namespace -{ +using ::testing::_; -class MockFactory : public NullFactory +namespace { - public: - MOCK_METHOD0(createBuffer, BufferImpl*()); - MOCK_METHOD1(createTexture, TextureImpl*(GLenum)); - MOCK_METHOD0(createRenderbuffer, RenderbufferImpl*()); -}; class ResourceManagerTest : public testing::Test { protected: void SetUp() override { - mResourceManager = new ResourceManager(&mMockFactory); + mResourceManager = new ResourceManager(); } void TearDown() override @@ -39,15 +33,15 @@ class ResourceManagerTest : public testing::Test SafeDelete(mResourceManager); } - MockFactory mMockFactory; + MockGLFactory mMockFactory; ResourceManager *mResourceManager; }; TEST_F(ResourceManagerTest, ReallocateBoundTexture) { - EXPECT_CALL(mMockFactory, createTexture(GL_TEXTURE_2D)).Times(1).RetiresOnSaturation(); + EXPECT_CALL(mMockFactory, createTexture(_)).Times(1).RetiresOnSaturation(); - mResourceManager->checkTextureAllocation(1, GL_TEXTURE_2D); + mResourceManager->checkTextureAllocation(&mMockFactory, 1, GL_TEXTURE_2D); GLuint newTexture = mResourceManager->createTexture(); EXPECT_NE(1u, newTexture); } @@ -56,7 +50,7 @@ TEST_F(ResourceManagerTest, ReallocateBoundBuffer) { EXPECT_CALL(mMockFactory, createBuffer()).Times(1).RetiresOnSaturation(); - mResourceManager->checkBufferAllocation(1); + mResourceManager->checkBufferAllocation(&mMockFactory, 1); GLuint newBuffer = mResourceManager->createBuffer(); EXPECT_NE(1u, newBuffer); } @@ -65,9 +59,9 @@ TEST_F(ResourceManagerTest, ReallocateBoundRenderbuffer) { EXPECT_CALL(mMockFactory, createRenderbuffer()).Times(1).RetiresOnSaturation(); - mResourceManager->checkRenderbufferAllocation(1); + mResourceManager->checkRenderbufferAllocation(&mMockFactory, 1); GLuint newRenderbuffer = mResourceManager->createRenderbuffer(); EXPECT_NE(1u, newRenderbuffer); } -} +} // anonymous namespace diff --git a/chromium/third_party/angle/src/libANGLE/Sampler.cpp b/chromium/third_party/angle/src/libANGLE/Sampler.cpp index d8d606a46f6..dc1d7c94a88 100644 --- a/chromium/third_party/angle/src/libANGLE/Sampler.cpp +++ b/chromium/third_party/angle/src/libANGLE/Sampler.cpp @@ -9,13 +9,13 @@ #include "libANGLE/Sampler.h" #include "libANGLE/angletypes.h" -#include "libANGLE/renderer/ImplFactory.h" +#include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/SamplerImpl.h" namespace gl { -Sampler::Sampler(rx::ImplFactory *factory, GLuint id) +Sampler::Sampler(rx::GLImplFactory *factory, GLuint id) : RefCountObject(id), mImpl(factory->createSampler()), mLabel(), mSamplerState() { } diff --git a/chromium/third_party/angle/src/libANGLE/Sampler.h b/chromium/third_party/angle/src/libANGLE/Sampler.h index a40b1655fc4..f950bc04e34 100644 --- a/chromium/third_party/angle/src/libANGLE/Sampler.h +++ b/chromium/third_party/angle/src/libANGLE/Sampler.h @@ -16,7 +16,7 @@ namespace rx { -class ImplFactory; +class GLImplFactory; class SamplerImpl; } @@ -26,7 +26,7 @@ namespace gl class Sampler final : public RefCountObject, public LabeledObject { public: - Sampler(rx::ImplFactory *factory, GLuint id); + Sampler(rx::GLImplFactory *factory, GLuint id); ~Sampler() override; void setLabel(const std::string &label) override; diff --git a/chromium/third_party/angle/src/libANGLE/Shader.cpp b/chromium/third_party/angle/src/libANGLE/Shader.cpp index bbe9077fc92..bf0f742cb18 100644 --- a/chromium/third_party/angle/src/libANGLE/Shader.cpp +++ b/chromium/third_party/angle/src/libANGLE/Shader.cpp @@ -14,9 +14,10 @@ #include "common/utilities.h" #include "GLSLANG/ShaderLang.h" +#include "libANGLE/Caps.h" #include "libANGLE/Compiler.h" #include "libANGLE/Constants.h" -#include "libANGLE/renderer/Renderer.h" +#include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/ShaderImpl.h" #include "libANGLE/ResourceManager.h" @@ -72,21 +73,21 @@ bool CompareShaderVar(const sh::ShaderVariable &x, const sh::ShaderVariable &y) return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type); } -Shader::Data::Data(GLenum shaderType) : mLabel(), mShaderType(shaderType), mShaderVersion(100) +ShaderState::ShaderState(GLenum shaderType) : mLabel(), mShaderType(shaderType), mShaderVersion(100) { } -Shader::Data::~Data() +ShaderState::~ShaderState() { } Shader::Shader(ResourceManager *manager, - rx::ImplFactory *implFactory, + rx::GLImplFactory *implFactory, const gl::Limitations &rendererLimitations, GLenum type, GLuint handle) - : mData(type), - mImplementation(implFactory->createShader(mData)), + : mState(type), + mImplementation(implFactory->createShader(mState)), mRendererLimitations(rendererLimitations), mHandle(handle), mType(type), @@ -105,12 +106,12 @@ Shader::~Shader() void Shader::setLabel(const std::string &label) { - mData.mLabel = label; + mState.mLabel = label; } const std::string &Shader::getLabel() const { - return mData.mLabel; + return mState.mLabel; } GLuint Shader::getHandle() const @@ -134,7 +135,7 @@ void Shader::setSource(GLsizei count, const char *const *string, const GLint *le } } - mData.mSource = stream.str(); + mState.mSource = stream.str(); } int Shader::getInfoLogLength() const @@ -167,17 +168,17 @@ void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const int Shader::getSourceLength() const { - return mData.mSource.empty() ? 0 : (static_cast<int>(mData.mSource.length()) + 1); + return mState.mSource.empty() ? 0 : (static_cast<int>(mState.mSource.length()) + 1); } int Shader::getTranslatedSourceLength() const { - if (mData.mTranslatedSource.empty()) + if (mState.mTranslatedSource.empty()) { return 0; } - return (static_cast<int>(mData.mTranslatedSource.length()) + 1); + return (static_cast<int>(mState.mTranslatedSource.length()) + 1); } int Shader::getTranslatedSourceWithDebugInfoLength() const @@ -211,12 +212,12 @@ void Shader::getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei * void Shader::getSource(GLsizei bufSize, GLsizei *length, char *buffer) const { - getSourceImpl(mData.mSource, bufSize, length, buffer); + getSourceImpl(mState.mSource, bufSize, length, buffer); } void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const { - getSourceImpl(mData.mTranslatedSource, bufSize, length, buffer); + getSourceImpl(mState.mTranslatedSource, bufSize, length, buffer); } void Shader::getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const @@ -227,16 +228,16 @@ void Shader::getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, void Shader::compile(Compiler *compiler) { - mData.mTranslatedSource.clear(); + mState.mTranslatedSource.clear(); mInfoLog.clear(); - mData.mShaderVersion = 100; - mData.mVaryings.clear(); - mData.mUniforms.clear(); - mData.mInterfaceBlocks.clear(); - mData.mActiveAttributes.clear(); - mData.mActiveOutputVariables.clear(); + mState.mShaderVersion = 100; + mState.mVaryings.clear(); + mState.mUniforms.clear(); + mState.mInterfaceBlocks.clear(); + mState.mActiveAttributes.clear(); + mState.mActiveOutputVariables.clear(); - ShHandle compilerHandle = compiler->getCompilerHandle(mData.mShaderType); + ShHandle compilerHandle = compiler->getCompilerHandle(mState.mShaderType); std::stringstream sourceStream; @@ -274,7 +275,7 @@ void Shader::compile(Compiler *compiler) return; } - mData.mTranslatedSource = ShGetObjectCode(compilerHandle); + mState.mTranslatedSource = ShGetObjectCode(compilerHandle); #ifndef NDEBUG // Prefix translated shader with commented out un-translated shader. @@ -286,40 +287,40 @@ void Shader::compile(Compiler *compiler) size_t curPos = 0; while (curPos != std::string::npos) { - size_t nextLine = mData.mSource.find("\n", curPos); + size_t nextLine = mState.mSource.find("\n", curPos); size_t len = (nextLine == std::string::npos) ? std::string::npos : (nextLine - curPos + 1); - shaderStream << "// " << mData.mSource.substr(curPos, len); + shaderStream << "// " << mState.mSource.substr(curPos, len); curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1); } shaderStream << "\n\n"; - shaderStream << mData.mTranslatedSource; - mData.mTranslatedSource = shaderStream.str(); + shaderStream << mState.mTranslatedSource; + mState.mTranslatedSource = shaderStream.str(); #endif // Gather the shader information - mData.mShaderVersion = ShGetShaderVersion(compilerHandle); + mState.mShaderVersion = ShGetShaderVersion(compilerHandle); - mData.mVaryings = GetShaderVariables(ShGetVaryings(compilerHandle)); - mData.mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle)); - mData.mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle)); + mState.mVaryings = GetShaderVariables(ShGetVaryings(compilerHandle)); + mState.mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle)); + mState.mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle)); - if (mData.mShaderType == GL_VERTEX_SHADER) + if (mState.mShaderType == GL_VERTEX_SHADER) { - mData.mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle)); + mState.mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle)); } else { - ASSERT(mData.mShaderType == GL_FRAGMENT_SHADER); + ASSERT(mState.mShaderType == GL_FRAGMENT_SHADER); // TODO(jmadill): Figure out why we only sort in the FS, and if we need to. - std::sort(mData.mVaryings.begin(), mData.mVaryings.end(), CompareShaderVar); - mData.mActiveOutputVariables = + std::sort(mState.mVaryings.begin(), mState.mVaryings.end(), CompareShaderVar); + mState.mActiveOutputVariables = GetActiveShaderVariables(ShGetOutputVariables(compilerHandle)); } - ASSERT(!mData.mTranslatedSource.empty()); + ASSERT(!mState.mTranslatedSource.empty()); mCompiled = mImplementation->postTranslateCompile(compiler, &mInfoLog); } @@ -356,39 +357,39 @@ void Shader::flagForDeletion() int Shader::getShaderVersion() const { - return mData.mShaderVersion; + return mState.mShaderVersion; } const std::vector<sh::Varying> &Shader::getVaryings() const { - return mData.getVaryings(); + return mState.getVaryings(); } const std::vector<sh::Uniform> &Shader::getUniforms() const { - return mData.getUniforms(); + return mState.getUniforms(); } const std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks() const { - return mData.getInterfaceBlocks(); + return mState.getInterfaceBlocks(); } const std::vector<sh::Attribute> &Shader::getActiveAttributes() const { - return mData.getActiveAttributes(); + return mState.getActiveAttributes(); } const std::vector<sh::OutputVariable> &Shader::getActiveOutputVariables() const { - return mData.getActiveOutputVariables(); + return mState.getActiveOutputVariables(); } int Shader::getSemanticIndex(const std::string &attributeName) const { if (!attributeName.empty()) { - const auto &activeAttributes = mData.getActiveAttributes(); + const auto &activeAttributes = mState.getActiveAttributes(); int semanticIndex = 0; for (size_t attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++) diff --git a/chromium/third_party/angle/src/libANGLE/Shader.h b/chromium/third_party/angle/src/libANGLE/Shader.h index 997977c87bb..108edb87b29 100644 --- a/chromium/third_party/angle/src/libANGLE/Shader.h +++ b/chromium/third_party/angle/src/libANGLE/Shader.h @@ -25,7 +25,7 @@ namespace rx { -class ImplFactory; +class GLImplFactory; class ShaderImpl; class ShaderSh; } @@ -33,58 +33,55 @@ class ShaderSh; namespace gl { class Compiler; +struct ContextState; struct Limitations; class ResourceManager; -struct Data; -class Shader final : angle::NonCopyable, public LabeledObject +class ShaderState final : angle::NonCopyable { public: - class Data final : angle::NonCopyable + ShaderState(GLenum shaderType); + ~ShaderState(); + + const std::string &getLabel() const { return mLabel; } + + const std::string &getSource() const { return mSource; } + const std::string &getTranslatedSource() const { return mTranslatedSource; } + + GLenum getShaderType() const { return mShaderType; } + int getShaderVersion() const { return mShaderVersion; } + + const std::vector<sh::Varying> &getVaryings() const { return mVaryings; } + const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; } + const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; } + const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; } + const std::vector<sh::OutputVariable> &getActiveOutputVariables() const { - public: - Data(GLenum shaderType); - ~Data(); - - const std::string &getLabel() const { return mLabel; } - - const std::string &getSource() const { return mSource; } - const std::string &getTranslatedSource() const { return mTranslatedSource; } - - GLenum getShaderType() const { return mShaderType; } - int getShaderVersion() const { return mShaderVersion; } - - const std::vector<sh::Varying> &getVaryings() const { return mVaryings; } - const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; } - const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const - { - return mInterfaceBlocks; - } - const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; } - const std::vector<sh::OutputVariable> &getActiveOutputVariables() const - { - return mActiveOutputVariables; - } - - private: - friend class Shader; - - std::string mLabel; - - GLenum mShaderType; - int mShaderVersion; - std::string mTranslatedSource; - std::string mSource; - - std::vector<sh::Varying> mVaryings; - std::vector<sh::Uniform> mUniforms; - std::vector<sh::InterfaceBlock> mInterfaceBlocks; - std::vector<sh::Attribute> mActiveAttributes; - std::vector<sh::OutputVariable> mActiveOutputVariables; - }; + return mActiveOutputVariables; + } + + private: + friend class Shader; + std::string mLabel; + + GLenum mShaderType; + int mShaderVersion; + std::string mTranslatedSource; + std::string mSource; + + std::vector<sh::Varying> mVaryings; + std::vector<sh::Uniform> mUniforms; + std::vector<sh::InterfaceBlock> mInterfaceBlocks; + std::vector<sh::Attribute> mActiveAttributes; + std::vector<sh::OutputVariable> mActiveOutputVariables; +}; + +class Shader final : angle::NonCopyable, public LabeledObject +{ + public: Shader(ResourceManager *manager, - rx::ImplFactory *implFactory, + rx::GLImplFactory *implFactory, const gl::Limitations &rendererLimitations, GLenum type, GLuint handle); @@ -107,7 +104,7 @@ class Shader final : angle::NonCopyable, public LabeledObject void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const; int getTranslatedSourceLength() const; int getTranslatedSourceWithDebugInfoLength() const; - const std::string &getTranslatedSource() const { return mData.getTranslatedSource(); } + const std::string &getTranslatedSource() const { return mState.getTranslatedSource(); } void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const; void getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const; @@ -133,7 +130,7 @@ class Shader final : angle::NonCopyable, public LabeledObject private: static void getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei *length, char *buffer); - Data mData; + ShaderState mState; rx::ShaderImpl *mImplementation; const gl::Limitations &mRendererLimitations; const GLuint mHandle; diff --git a/chromium/third_party/angle/src/libANGLE/State.cpp b/chromium/third_party/angle/src/libANGLE/State.cpp index bee54568f5f..33be79ceeba 100644 --- a/chromium/third_party/angle/src/libANGLE/State.cpp +++ b/chromium/third_party/angle/src/libANGLE/State.cpp @@ -42,7 +42,9 @@ State::State() mProgram(nullptr), mVertexArray(nullptr), mActiveSampler(0), - mPrimitiveRestart(false) + mPrimitiveRestart(false), + mMultiSampling(false), + mSampleAlphaToOne(false) { } @@ -148,6 +150,10 @@ void State::initialize(const Caps &caps, mSamplerTextures[GL_TEXTURE_2D_ARRAY].resize(caps.maxCombinedTextureImageUnits); mSamplerTextures[GL_TEXTURE_3D].resize(caps.maxCombinedTextureImageUnits); } + if (extensions.eglImageExternal || extensions.eglStreamConsumerExternal) + { + mSamplerTextures[GL_TEXTURE_EXTERNAL_OES].resize(caps.maxCombinedTextureImageUnits); + } mSamplers.resize(caps.maxCombinedTextureImageUnits); @@ -155,6 +161,7 @@ void State::initialize(const Caps &caps, mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(nullptr); mActiveQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(nullptr); mActiveQueries[GL_TIME_ELAPSED_EXT].set(nullptr); + mActiveQueries[GL_COMMANDS_COMPLETED_CHROMIUM].set(nullptr); mProgram = nullptr; @@ -165,6 +172,14 @@ void State::initialize(const Caps &caps, mDebug.setOutputEnabled(debug); mDebug.setMaxLoggedMessages(extensions.maxDebugLoggedMessages); + + if (extensions.framebufferMultisample) + { + mMultiSampling = true; + mSampleAlphaToOne = false; + } + + mCoverageModulation = GL_NONE; } void State::reset() @@ -499,6 +514,28 @@ bool State::getSampleCoverageInvert() const return mSampleCoverageInvert; } +void State::setSampleAlphaToOne(bool enabled) +{ + mSampleAlphaToOne = enabled; + mDirtyBits.set(DIRTY_BIT_SAMPLE_ALPHA_TO_ONE); +} + +bool State::isSampleAlphaToOneEnabled() const +{ + return mSampleAlphaToOne; +} + +void State::setMultisampling(bool enabled) +{ + mMultiSampling = enabled; + mDirtyBits.set(DIRTY_BIT_MULTISAMPLING); +} + +bool State::isMultisamplingEnabled() const +{ + return mMultiSampling; +} + bool State::isScissorTestEnabled() const { return mScissorTest; @@ -550,6 +587,8 @@ void State::setEnableFeature(GLenum feature, bool enabled) { switch (feature) { + case GL_MULTISAMPLE_EXT: setMultisampling(enabled); break; + case GL_SAMPLE_ALPHA_TO_ONE_EXT: setSampleAlphaToOne(enabled); break; case GL_CULL_FACE: setCullFace(enabled); break; case GL_POLYGON_OFFSET_FILL: setPolygonOffsetFill(enabled); break; case GL_SAMPLE_ALPHA_TO_COVERAGE: setSampleAlphaToCoverage(enabled); break; @@ -575,6 +614,8 @@ bool State::getEnableFeature(GLenum feature) { switch (feature) { + case GL_MULTISAMPLE_EXT: return isMultisamplingEnabled(); + case GL_SAMPLE_ALPHA_TO_ONE_EXT: return isSampleAlphaToOneEnabled(); case GL_CULL_FACE: return isCullFaceEnabled(); case GL_POLYGON_OFFSET_FILL: return isPolygonOffsetFillEnabled(); case GL_SAMPLE_ALPHA_TO_COVERAGE: return isSampleAlphaToCoverageEnabled(); @@ -681,10 +722,10 @@ void State::detachTexture(const TextureMap &zeroTextures, GLuint texture) // If a texture object is deleted, it is as if all texture units which are bound to that texture object are // rebound to texture object zero - for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++) + for (auto &bindingVec : mSamplerTextures) { - GLenum textureType = bindingVec->first; - TextureBindingVector &textureVector = bindingVec->second; + GLenum textureType = bindingVec.first; + TextureBindingVector &textureVector = bindingVec.second; for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++) { BindingPointer<Texture> &binding = textureVector[textureIdx]; @@ -967,19 +1008,23 @@ bool State::isTransformFeedbackActiveUnpaused() const return curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused(); } -void State::detachTransformFeedback(GLuint transformFeedback) +bool State::removeTransformFeedbackBinding(GLuint transformFeedback) { if (mTransformFeedback.id() == transformFeedback) { - mTransformFeedback.set(NULL); + mTransformFeedback.set(nullptr); + return true; } + + return false; } -bool State::isQueryActive() const +bool State::isQueryActive(GLenum type) const { for (auto &iter : mActiveQueries) { - if (iter.second.get() != NULL) + Query *query = iter.second.get(); + if (query != nullptr && query->getType() == type) { return true; } @@ -1061,11 +1106,13 @@ void State::setCopyWriteBufferBinding(Buffer *buffer) void State::setPixelPackBufferBinding(Buffer *buffer) { mPack.pixelBuffer.set(buffer); + mDirtyBits.set(DIRTY_BIT_PACK_BUFFER_BINDING); } void State::setPixelUnpackBufferBinding(Buffer *buffer) { mUnpack.pixelBuffer.set(buffer); + mDirtyBits.set(DIRTY_BIT_UNPACK_BUFFER_BINDING); } Buffer *State::getTargetBuffer(GLenum target) const @@ -1314,6 +1361,17 @@ Debug &State::getDebug() return mDebug; } +void State::setCoverageModulation(GLenum components) +{ + mCoverageModulation = components; + mDirtyBits.set(DIRTY_BIT_COVERAGE_MODULATION); +} + +GLenum State::getCoverageModulation() const +{ + return mCoverageModulation; +} + void State::getBooleanv(GLenum pname, GLboolean *params) { switch (pname) @@ -1349,6 +1407,12 @@ void State::getBooleanv(GLenum pname, GLboolean *params) case GL_DEBUG_OUTPUT: *params = mDebug.isOutputEnabled() ? GL_TRUE : GL_FALSE; break; + case GL_MULTISAMPLE_EXT: + *params = mMultiSampling; + break; + case GL_SAMPLE_ALPHA_TO_ONE_EXT: + *params = mSampleAlphaToOne; + break; default: UNREACHABLE(); break; @@ -1384,13 +1448,21 @@ void State::getFloatv(GLenum pname, GLfloat *params) params[2] = mBlendColor.blue; params[3] = mBlendColor.alpha; break; + case GL_MULTISAMPLE_EXT: + *params = static_cast<GLfloat>(mMultiSampling); + break; + case GL_SAMPLE_ALPHA_TO_ONE_EXT: + *params = static_cast<GLfloat>(mSampleAlphaToOne); + case GL_COVERAGE_MODULATION_CHROMIUM: + params[0] = static_cast<GLfloat>(mCoverageModulation); + break; default: UNREACHABLE(); break; } } -void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params) +void State::getIntegerv(const ContextState &data, GLenum pname, GLint *params) { if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) { @@ -1622,6 +1694,14 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params) case GL_DEBUG_GROUP_STACK_DEPTH: *params = static_cast<GLint>(mDebug.getGroupStackDepth()); break; + case GL_MULTISAMPLE_EXT: + *params = static_cast<GLint>(mMultiSampling); + break; + case GL_SAMPLE_ALPHA_TO_ONE_EXT: + *params = static_cast<GLint>(mSampleAlphaToOne); + case GL_COVERAGE_MODULATION_CHROMIUM: + *params = static_cast<GLint>(mCoverageModulation); + break; default: UNREACHABLE(); break; diff --git a/chromium/third_party/angle/src/libANGLE/State.h b/chromium/third_party/angle/src/libANGLE/State.h index 465643208c1..75caaeb591a 100644 --- a/chromium/third_party/angle/src/libANGLE/State.h +++ b/chromium/third_party/angle/src/libANGLE/State.h @@ -29,7 +29,6 @@ class Query; class VertexArray; class Context; struct Caps; -struct Data; typedef std::map<GLenum, BindingPointer<Texture>> TextureMap; @@ -119,6 +118,12 @@ class State : angle::NonCopyable GLclampf getSampleCoverageValue() const; bool getSampleCoverageInvert() const; + // Multisampling/alpha to one manipulation. + void setSampleAlphaToOne(bool enabled); + bool isSampleAlphaToOneEnabled() const; + void setMultisampling(bool enabled); + bool isMultisamplingEnabled() const; + // Scissor test state toggle & query bool isScissorTestEnabled() const; void setScissorTest(bool enabled); @@ -192,10 +197,10 @@ class State : angle::NonCopyable void setTransformFeedbackBinding(TransformFeedback *transformFeedback); TransformFeedback *getCurrentTransformFeedback() const; bool isTransformFeedbackActiveUnpaused() const; - void detachTransformFeedback(GLuint transformFeedback); + bool removeTransformFeedbackBinding(GLuint transformFeedback); // Query binding manipulation - bool isQueryActive() const; + bool isQueryActive(GLenum type) const; bool isQueryActive(Query *query) const; void setActiveQuery(GLenum target, Query *query); GLuint getActiveQueryId(GLenum target) const; @@ -269,10 +274,14 @@ class State : angle::NonCopyable const Debug &getDebug() const; Debug &getDebug(); + // CHROMIUM_framebuffer_mixed_samples coverage modulation + void setCoverageModulation(GLenum components); + GLenum getCoverageModulation() const; + // State query functions void getBooleanv(GLenum pname, GLboolean *params); void getFloatv(GLenum pname, GLfloat *params); - void getIntegerv(const gl::Data &data, GLenum pname, GLint *params); + void getIntegerv(const ContextState &data, GLenum pname, GLint *params); void getPointerv(GLenum pname, void **params) const; bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data); bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data); @@ -320,11 +329,13 @@ class State : angle::NonCopyable DIRTY_BIT_UNPACK_SKIP_IMAGES, DIRTY_BIT_UNPACK_SKIP_ROWS, DIRTY_BIT_UNPACK_SKIP_PIXELS, + DIRTY_BIT_UNPACK_BUFFER_BINDING, DIRTY_BIT_PACK_ALIGNMENT, DIRTY_BIT_PACK_REVERSE_ROW_ORDER, DIRTY_BIT_PACK_ROW_LENGTH, DIRTY_BIT_PACK_SKIP_ROWS, DIRTY_BIT_PACK_SKIP_PIXELS, + DIRTY_BIT_PACK_BUFFER_BINDING, DIRTY_BIT_DITHER_ENABLED, DIRTY_BIT_GENERATE_MIPMAP_HINT, DIRTY_BIT_SHADER_DERIVATIVE_HINT, @@ -333,6 +344,9 @@ class State : angle::NonCopyable DIRTY_BIT_RENDERBUFFER_BINDING, DIRTY_BIT_VERTEX_ARRAY_BINDING, DIRTY_BIT_PROGRAM_BINDING, + DIRTY_BIT_MULTISAMPLING, + DIRTY_BIT_SAMPLE_ALPHA_TO_ONE, + DIRTY_BIT_COVERAGE_MODULATION, // CHROMIUM_framebuffer_mixed_samples DIRTY_BIT_CURRENT_VALUE_0, DIRTY_BIT_CURRENT_VALUE_MAX = DIRTY_BIT_CURRENT_VALUE_0 + MAX_VERTEX_ATTRIBS, DIRTY_BIT_INVALID = DIRTY_BIT_CURRENT_VALUE_MAX, @@ -435,6 +449,11 @@ class State : angle::NonCopyable Debug mDebug; + bool mMultiSampling; + bool mSampleAlphaToOne; + + GLenum mCoverageModulation; + DirtyBits mDirtyBits; DirtyObjects mDirtyObjects; }; diff --git a/chromium/third_party/angle/src/libANGLE/Stream.cpp b/chromium/third_party/angle/src/libANGLE/Stream.cpp index c6d4109e15c..17eb84b9db0 100644 --- a/chromium/third_party/angle/src/libANGLE/Stream.cpp +++ b/chromium/third_party/angle/src/libANGLE/Stream.cpp @@ -17,25 +17,42 @@ #include "common/platform.h" #include "common/utilities.h" #include "libANGLE/Context.h" -#include "libANGLE/renderer/StreamImpl.h" +#include "libANGLE/Display.h" +#include "libANGLE/renderer/DisplayImpl.h" +#include "libANGLE/renderer/StreamProducerImpl.h" namespace egl { -Stream::Stream(rx::StreamImpl *impl, const AttributeMap &attribs) - : mImplementation(impl), +Stream::Stream(Display *display, const AttributeMap &attribs) + : mDisplay(display), + mProducerImplementation(nullptr), mState(EGL_STREAM_STATE_CREATED_KHR), mProducerFrame(0), mConsumerFrame(0), - mConsumerLatency(static_cast<EGLint>(attribs.get(EGL_CONSUMER_LATENCY_USEC_KHR, 0))), - mConsumerAcquireTimeout( - static_cast<EGLint>(attribs.get(EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR, 0))) + mConsumerLatency(attribs.getAsInt(EGL_CONSUMER_LATENCY_USEC_KHR, 0)), + mConsumerAcquireTimeout(attribs.getAsInt(EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR, 0)), + mPlaneCount(0), + mConsumerType(ConsumerType::NoConsumer), + mProducerType(ProducerType::NoProducer) { + for (auto &plane : mPlanes) + { + plane.textureUnit = -1; + plane.texture = nullptr; + } } Stream::~Stream() { - SafeDelete(mImplementation); + SafeDelete(mProducerImplementation); + for (auto &plane : mPlanes) + { + if (plane.texture != nullptr) + { + plane.texture->releaseStream(); + } + } } void Stream::setConsumerLatency(EGLint latency) @@ -73,4 +90,181 @@ EGLint Stream::getConsumerAcquireTimeout() const return mConsumerAcquireTimeout; } +Stream::ProducerType Stream::getProducerType() const +{ + return mProducerType; +} + +Stream::ConsumerType Stream::getConsumerType() const +{ + return mConsumerType; +} + +EGLint Stream::getPlaneCount() const +{ + return mPlaneCount; +} + +rx::StreamProducerImpl *Stream::getImplementation() +{ + return mProducerImplementation; +} + +Error Stream::createConsumerGLTextureExternal(const AttributeMap &attributes, gl::Context *context) +{ + ASSERT(mState == EGL_STREAM_STATE_CREATED_KHR); + ASSERT(mConsumerType == ConsumerType::NoConsumer); + ASSERT(mProducerType == ProducerType::NoProducer); + ASSERT(context != nullptr); + + EGLenum bufferType = attributes.getAsInt(EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER); + if (bufferType == EGL_RGB_BUFFER) + { + mPlanes[0].texture = context->getState().getTargetTexture(GL_TEXTURE_EXTERNAL_OES); + ASSERT(mPlanes[0].texture != nullptr); + mPlanes[0].texture->bindStream(this); + mConsumerType = ConsumerType::GLTextureRGB; + mPlaneCount = 1; + } + else + { + mPlaneCount = attributes.getAsInt(EGL_YUV_NUMBER_OF_PLANES_EXT, 2); + ASSERT(mPlaneCount <= 3); + for (EGLint i = 0; i < mPlaneCount; i++) + { + // Fetch all the textures + mPlanes[i].textureUnit = attributes.getAsInt(EGL_YUV_PLANE0_TEXTURE_UNIT_NV + i, -1); + if (mPlanes[i].textureUnit != EGL_NONE) + { + mPlanes[i].texture = context->getState().getSamplerTexture(mPlanes[i].textureUnit, + GL_TEXTURE_EXTERNAL_OES); + ASSERT(mPlanes[i].texture != nullptr); + } + } + + // Bind them to the stream + for (EGLint i = 0; i < mPlaneCount; i++) + { + if (mPlanes[i].textureUnit != EGL_NONE) + { + mPlanes[i].texture->bindStream(this); + } + } + mConsumerType = ConsumerType::GLTextureYUV; + } + + mContext = context; + mState = EGL_STREAM_STATE_CONNECTING_KHR; + + return Error(EGL_SUCCESS); +} + +Error Stream::createProducerD3D11TextureNV12(const AttributeMap &attributes) +{ + ASSERT(mState == EGL_STREAM_STATE_CONNECTING_KHR); + ASSERT(mConsumerType == ConsumerType::GLTextureYUV); + ASSERT(mProducerType == ProducerType::NoProducer); + ASSERT(mPlaneCount == 2); + + mProducerImplementation = mDisplay->getImplementation()->createStreamProducerD3DTextureNV12( + mConsumerType, attributes); + mProducerType = ProducerType::D3D11TextureNV12; + mState = EGL_STREAM_STATE_EMPTY_KHR; + + return Error(EGL_SUCCESS); +} + +// Called when the consumer of this stream starts using the stream +Error Stream::consumerAcquire() +{ + ASSERT(mState == EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR || + mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR); + ASSERT(mConsumerType == ConsumerType::GLTextureRGB || + mConsumerType == ConsumerType::GLTextureYUV); + ASSERT(mProducerType == ProducerType::D3D11TextureNV12); + + mState = EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR; + mConsumerFrame++; + + // Bind the planes to the gl textures + for (int i = 0; i < mPlaneCount; i++) + { + if (mPlanes[i].texture != nullptr) + { + mPlanes[i].texture->acquireImageFromStream( + mProducerImplementation->getGLFrameDescription(i)); + } + } + + return Error(EGL_SUCCESS); +} + +Error Stream::consumerRelease() +{ + ASSERT(mState == EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR || + mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR); + ASSERT(mConsumerType == ConsumerType::GLTextureRGB || + mConsumerType == ConsumerType::GLTextureYUV); + ASSERT(mProducerType == ProducerType::D3D11TextureNV12); + + // Release the images + for (int i = 0; i < mPlaneCount; i++) + { + if (mPlanes[i].texture != nullptr) + { + mPlanes[i].texture->releaseImageFromStream(); + } + } + + return Error(EGL_SUCCESS); +} + +bool Stream::isConsumerBoundToContext(const gl::Context *context) const +{ + ASSERT(context != nullptr); + return (context == mContext); +} + +Error Stream::validateD3D11NV12Texture(void *texture) const +{ + ASSERT(mConsumerType == ConsumerType::GLTextureRGB || + mConsumerType == ConsumerType::GLTextureYUV); + ASSERT(mProducerType == ProducerType::D3D11TextureNV12); + ASSERT(mProducerImplementation != nullptr); + + return mProducerImplementation->validateD3DNV12Texture(texture); +} + +Error Stream::postD3D11NV12Texture(void *texture, const AttributeMap &attributes) +{ + ASSERT(mConsumerType == ConsumerType::GLTextureRGB || + mConsumerType == ConsumerType::GLTextureYUV); + ASSERT(mProducerType == ProducerType::D3D11TextureNV12); + + mProducerImplementation->postD3DNV12Texture(texture, attributes); + mProducerFrame++; + + mState = EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR; + + return Error(EGL_SUCCESS); +} + +// This is called when a texture object associated with this stream is destroyed. Even if multiple +// textures are bound, one being destroyed invalidates the stream, so all the remaining textures +// will be released and the stream will be invalidated. +void Stream::releaseTextures() +{ + for (auto &plane : mPlanes) + { + if (plane.texture != nullptr) + { + plane.texture->releaseStream(); + plane.texture = nullptr; + } + } + mConsumerType = ConsumerType::NoConsumer; + mProducerType = ProducerType::NoProducer; + mState = EGL_STREAM_STATE_DISCONNECTED_KHR; +} + } // namespace egl diff --git a/chromium/third_party/angle/src/libANGLE/Stream.h b/chromium/third_party/angle/src/libANGLE/Stream.h index c92ff4e4e6c..799e3269066 100644 --- a/chromium/third_party/angle/src/libANGLE/Stream.h +++ b/chromium/third_party/angle/src/libANGLE/Stream.h @@ -10,6 +10,8 @@ #ifndef LIBANGLE_STREAM_H_ #define LIBANGLE_STREAM_H_ +#include <array> + #include <EGL/egl.h> #include <EGL/eglext.h> @@ -18,18 +20,48 @@ namespace rx { -class StreamImpl; +class StreamProducerImpl; +} + +namespace gl +{ +class Context; +class Texture; } namespace egl { +class Display; +class Error; class Stream final : angle::NonCopyable { public: - Stream(rx::StreamImpl *impl, const AttributeMap &attribs); + Stream(Display *display, const AttributeMap &attribs); ~Stream(); + enum class ConsumerType + { + NoConsumer, + GLTextureRGB, + GLTextureYUV, + }; + + enum class ProducerType + { + NoProducer, + D3D11TextureNV12, + }; + + // A GL texture interpretation of a part of a producer frame. For use with GL texture consumers + struct GLTextureDescription + { + unsigned int width; + unsigned int height; + unsigned int internalFormat; + unsigned int mipLevels; + }; + EGLenum getState() const; void setConsumerLatency(EGLint latency); @@ -41,9 +73,42 @@ class Stream final : angle::NonCopyable void setConsumerAcquireTimeout(EGLint timeout); EGLint getConsumerAcquireTimeout() const; + ConsumerType getConsumerType() const; + ProducerType getProducerType() const; + + EGLint getPlaneCount() const; + + rx::StreamProducerImpl *getImplementation(); + + // Consumer creation methods + Error createConsumerGLTextureExternal(const AttributeMap &attributes, gl::Context *context); + + // Producer creation methods + Error createProducerD3D11TextureNV12(const AttributeMap &attributes); + + // Consumer methods + Error consumerAcquire(); + Error consumerRelease(); + + // Some consumers are bound to GL contexts. This validates that a given context is bound to the + // stream's consumer + bool isConsumerBoundToContext(const gl::Context *context) const; + + // Producer methods + Error validateD3D11NV12Texture(void *texture) const; + Error postD3D11NV12Texture(void *texture, const AttributeMap &attributes); + private: - // Implementation - rx::StreamImpl *mImplementation; + // Associated display + Display *mDisplay; + + // Producer Implementation + rx::StreamProducerImpl *mProducerImplementation; + + // Associated GL context. Note that this is a weak pointer used for validation purposes only, + // and should never be arbitrarily dereferenced without knowing the context still exists as it + // can become dangling at any time. + gl::Context *mContext; // EGL defined attributes EGLint mState; @@ -53,6 +118,24 @@ class Stream final : angle::NonCopyable // EGL gltexture consumer attributes EGLint mConsumerAcquireTimeout; + + // EGL gltexture yuv consumer attributes + EGLint mPlaneCount; + struct PlaneTexture + { + EGLint textureUnit; + gl::Texture *texture; + }; + // Texture units and textures for all the planes + std::array<PlaneTexture, 3> mPlanes; + + // Consumer and producer types + ConsumerType mConsumerType; + ProducerType mProducerType; + + // ANGLE-only method, used internally + friend class gl::Texture; + void releaseTextures(); }; } // namespace egl diff --git a/chromium/third_party/angle/src/libANGLE/Surface_unittest.cpp b/chromium/third_party/angle/src/libANGLE/Surface_unittest.cpp index 2f40d7d3d37..fb2b825ad9b 100644 --- a/chromium/third_party/angle/src/libANGLE/Surface_unittest.cpp +++ b/chromium/third_party/angle/src/libANGLE/Surface_unittest.cpp @@ -9,7 +9,7 @@ #include "libANGLE/angletypes.h" #include "libANGLE/AttributeMap.h" #include "libANGLE/Config.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/State.h" #include "libANGLE/Surface.h" #include "libANGLE/renderer/FramebufferImpl_mock.h" @@ -26,8 +26,7 @@ class MockSurfaceImpl : public rx::SurfaceImpl virtual ~MockSurfaceImpl() { destroy(); } MOCK_METHOD0(initialize, egl::Error()); - MOCK_METHOD1(createDefaultFramebuffer, - rx::FramebufferImpl *(const gl::Framebuffer::Data &data)); + MOCK_METHOD1(createDefaultFramebuffer, rx::FramebufferImpl *(const gl::FramebufferState &data)); MOCK_METHOD0(swap, egl::Error()); MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint)); MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**)); diff --git a/chromium/third_party/angle/src/libANGLE/Texture.cpp b/chromium/third_party/angle/src/libANGLE/Texture.cpp index 702ea599803..7b8aef80943 100644 --- a/chromium/third_party/angle/src/libANGLE/Texture.cpp +++ b/chromium/third_party/angle/src/libANGLE/Texture.cpp @@ -12,14 +12,32 @@ #include "common/utilities.h" #include "libANGLE/Config.h" #include "libANGLE/Context.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/Image.h" #include "libANGLE/Surface.h" #include "libANGLE/formatutils.h" +#include "libANGLE/renderer/GLImplFactory.h" +#include "libANGLE/renderer/TextureImpl.h" namespace gl { +namespace +{ +bool IsPointSampled(const gl::SamplerState &samplerState) +{ + return (samplerState.magFilter == GL_NEAREST && + (samplerState.minFilter == GL_NEAREST || + samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST)); +} + +size_t GetImageDescIndex(GLenum target, size_t level) +{ + return IsCubeMapTextureTarget(target) ? ((level * 6) + CubeMapTextureTargetToLayerIndex(target)) + : level; +} +} // namespace + bool IsMipmapFiltered(const gl::SamplerState &samplerState) { switch (samplerState.minFilter) @@ -37,25 +55,63 @@ bool IsMipmapFiltered(const gl::SamplerState &samplerState) } } -bool IsPointSampled(const gl::SamplerState &samplerState) +TextureState::TextureState(GLenum target) + : target(target), + swizzleRed(GL_RED), + swizzleGreen(GL_GREEN), + swizzleBlue(GL_BLUE), + swizzleAlpha(GL_ALPHA), + samplerState(), + baseLevel(0), + maxLevel(1000), + immutableFormat(false), + immutableLevels(0), + usage(GL_NONE) +{ +} + +bool TextureState::swizzleRequired() const { - return (samplerState.magFilter == GL_NEAREST && (samplerState.minFilter == GL_NEAREST || samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST)); + return swizzleRed != GL_RED || swizzleGreen != GL_GREEN || swizzleBlue != GL_BLUE || + swizzleAlpha != GL_ALPHA; } -static size_t GetImageDescIndex(GLenum target, size_t level) +GLuint TextureState::getEffectiveBaseLevel() const { - return IsCubeMapTextureTarget(target) ? ((level * 6) + CubeMapTextureTargetToLayerIndex(target)) : level; + if (immutableFormat) + { + // GLES 3.0.4 section 3.8.10 + return std::min(baseLevel, immutableLevels - 1); + } + // Some classes use the effective base level to index arrays with level data. By clamping the + // effective base level to max levels these arrays need just one extra item to store properties + // that should be returned for all out-of-range base level values, instead of needing special + // handling for out-of-range base levels. + return std::min(baseLevel, static_cast<GLuint>(gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)); +} + +GLuint TextureState::getEffectiveMaxLevel() const +{ + if (immutableFormat) + { + // GLES 3.0.4 section 3.8.10 + GLuint clampedMaxLevel = std::max(maxLevel, getEffectiveBaseLevel()); + clampedMaxLevel = std::min(clampedMaxLevel, immutableLevels - 1); + return clampedMaxLevel; + } + return maxLevel; } -Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target) +Texture::Texture(rx::GLImplFactory *factory, GLuint id, GLenum target) : egl::ImageSibling(id), - mTexture(impl), + mState(target), + mTexture(factory->createTexture(mState)), mLabel(), - mTextureState(), - mTarget(target), - mImageDescs(IMPLEMENTATION_MAX_TEXTURE_LEVELS * (target == GL_TEXTURE_CUBE_MAP ? 6 : 1)), + mImageDescs((IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) * + (target == GL_TEXTURE_CUBE_MAP ? 6 : 1)), mCompletenessCache(), - mBoundSurface(NULL) + mBoundSurface(nullptr), + mBoundStream(nullptr) { } @@ -64,7 +120,12 @@ Texture::~Texture() if (mBoundSurface) { mBoundSurface->releaseTexImage(EGL_BACK_BUFFER); - mBoundSurface = NULL; + mBoundSurface = nullptr; + } + if (mBoundStream) + { + mBoundStream->releaseTextures(); + mBoundStream = nullptr; } SafeDelete(mTexture); } @@ -81,227 +142,241 @@ const std::string &Texture::getLabel() const GLenum Texture::getTarget() const { - return mTarget; + return mState.target; } void Texture::setSwizzleRed(GLenum swizzleRed) { - mTextureState.swizzleRed = swizzleRed; + mState.swizzleRed = swizzleRed; } GLenum Texture::getSwizzleRed() const { - return mTextureState.swizzleRed; + return mState.swizzleRed; } void Texture::setSwizzleGreen(GLenum swizzleGreen) { - mTextureState.swizzleGreen = swizzleGreen; + mState.swizzleGreen = swizzleGreen; } GLenum Texture::getSwizzleGreen() const { - return mTextureState.swizzleGreen; + return mState.swizzleGreen; } void Texture::setSwizzleBlue(GLenum swizzleBlue) { - mTextureState.swizzleBlue = swizzleBlue; + mState.swizzleBlue = swizzleBlue; } GLenum Texture::getSwizzleBlue() const { - return mTextureState.swizzleBlue; + return mState.swizzleBlue; } void Texture::setSwizzleAlpha(GLenum swizzleAlpha) { - mTextureState.swizzleAlpha = swizzleAlpha; + mState.swizzleAlpha = swizzleAlpha; } GLenum Texture::getSwizzleAlpha() const { - return mTextureState.swizzleAlpha; + return mState.swizzleAlpha; } void Texture::setMinFilter(GLenum minFilter) { - mTextureState.samplerState.minFilter = minFilter; + mState.samplerState.minFilter = minFilter; } GLenum Texture::getMinFilter() const { - return mTextureState.samplerState.minFilter; + return mState.samplerState.minFilter; } void Texture::setMagFilter(GLenum magFilter) { - mTextureState.samplerState.magFilter = magFilter; + mState.samplerState.magFilter = magFilter; } GLenum Texture::getMagFilter() const { - return mTextureState.samplerState.magFilter; + return mState.samplerState.magFilter; } void Texture::setWrapS(GLenum wrapS) { - mTextureState.samplerState.wrapS = wrapS; + mState.samplerState.wrapS = wrapS; } GLenum Texture::getWrapS() const { - return mTextureState.samplerState.wrapS; + return mState.samplerState.wrapS; } void Texture::setWrapT(GLenum wrapT) { - mTextureState.samplerState.wrapT = wrapT; + mState.samplerState.wrapT = wrapT; } GLenum Texture::getWrapT() const { - return mTextureState.samplerState.wrapT; + return mState.samplerState.wrapT; } void Texture::setWrapR(GLenum wrapR) { - mTextureState.samplerState.wrapR = wrapR; + mState.samplerState.wrapR = wrapR; } GLenum Texture::getWrapR() const { - return mTextureState.samplerState.wrapR; + return mState.samplerState.wrapR; } void Texture::setMaxAnisotropy(float maxAnisotropy) { - mTextureState.samplerState.maxAnisotropy = maxAnisotropy; + mState.samplerState.maxAnisotropy = maxAnisotropy; } float Texture::getMaxAnisotropy() const { - return mTextureState.samplerState.maxAnisotropy; + return mState.samplerState.maxAnisotropy; } void Texture::setMinLod(GLfloat minLod) { - mTextureState.samplerState.minLod = minLod; + mState.samplerState.minLod = minLod; } GLfloat Texture::getMinLod() const { - return mTextureState.samplerState.minLod; + return mState.samplerState.minLod; } void Texture::setMaxLod(GLfloat maxLod) { - mTextureState.samplerState.maxLod = maxLod; + mState.samplerState.maxLod = maxLod; } GLfloat Texture::getMaxLod() const { - return mTextureState.samplerState.maxLod; + return mState.samplerState.maxLod; } void Texture::setCompareMode(GLenum compareMode) { - mTextureState.samplerState.compareMode = compareMode; + mState.samplerState.compareMode = compareMode; } GLenum Texture::getCompareMode() const { - return mTextureState.samplerState.compareMode; + return mState.samplerState.compareMode; } void Texture::setCompareFunc(GLenum compareFunc) { - mTextureState.samplerState.compareFunc = compareFunc; + mState.samplerState.compareFunc = compareFunc; } GLenum Texture::getCompareFunc() const { - return mTextureState.samplerState.compareFunc; + return mState.samplerState.compareFunc; } const SamplerState &Texture::getSamplerState() const { - return mTextureState.samplerState; + return mState.samplerState; } void Texture::setBaseLevel(GLuint baseLevel) { - mTextureState.baseLevel = baseLevel; + if (mState.baseLevel != baseLevel) + { + mState.baseLevel = baseLevel; + mCompletenessCache.cacheValid = false; + mTexture->setBaseLevel(mState.getEffectiveBaseLevel()); + } } GLuint Texture::getBaseLevel() const { - return mTextureState.baseLevel; + return mState.baseLevel; } void Texture::setMaxLevel(GLuint maxLevel) { - mTextureState.maxLevel = maxLevel; + if (mState.maxLevel != maxLevel) + { + mState.maxLevel = maxLevel; + mCompletenessCache.cacheValid = false; + } } GLuint Texture::getMaxLevel() const { - return mTextureState.maxLevel; + return mState.maxLevel; } bool Texture::getImmutableFormat() const { - return mTextureState.immutableFormat; + return mState.immutableFormat; } GLuint Texture::getImmutableLevels() const { - return mTextureState.immutableLevels; + return mState.immutableLevels; } void Texture::setUsage(GLenum usage) { - mTextureState.usage = usage; + mState.usage = usage; getImplementation()->setUsage(usage); } GLenum Texture::getUsage() const { - return mTextureState.usage; + return mState.usage; } const TextureState &Texture::getTextureState() const { - return mTextureState; + return mState; } size_t Texture::getWidth(GLenum target, size_t level) const { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return getImageDesc(target, level).size.width; } size_t Texture::getHeight(GLenum target, size_t level) const { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return getImageDesc(target, level).size.height; } size_t Texture::getDepth(GLenum target, size_t level) const { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return getImageDesc(target, level).size.depth; } GLenum Texture::getInternalFormat(GLenum target, size_t level) const { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return getImageDesc(target, level).internalFormat; } -bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &data) const +bool Texture::isSamplerComplete(const SamplerState &samplerState, const ContextState &data) const { - const ImageDesc &baseImageDesc = getImageDesc(getBaseImageTarget(), mTextureState.baseLevel); + const ImageDesc &baseImageDesc = + getImageDesc(getBaseImageTarget(), mState.getEffectiveBaseLevel()); const TextureCaps &textureCaps = data.textureCaps->get(baseImageDesc.internalFormat); if (!mCompletenessCache.cacheValid || mCompletenessCache.samplerState != samplerState || @@ -327,7 +402,7 @@ bool Texture::isMipmapComplete() const // Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. bool Texture::isCubeComplete() const { - ASSERT(mTarget == GL_TEXTURE_CUBE_MAP); + ASSERT(mState.target == GL_TEXTURE_CUBE_MAP); const ImageDesc &baseImageDesc = getImageDesc(FirstCubeMapTextureTarget, 0); if (baseImageDesc.size.width == 0 || baseImageDesc.size.width != baseImageDesc.size.height) @@ -352,7 +427,7 @@ bool Texture::isCubeComplete() const size_t Texture::getMipCompleteLevels() const { const ImageDesc &baseImageDesc = getImageDesc(getBaseImageTarget(), 0); - if (mTarget == GL_TEXTURE_3D) + if (mState.target == GL_TEXTURE_3D) { const int maxDim = std::max(std::max(baseImageDesc.size.width, baseImageDesc.size.height), baseImageDesc.size.depth); @@ -369,6 +444,11 @@ egl::Surface *Texture::getBoundSurface() const return mBoundSurface; } +egl::Stream *Texture::getBoundStream() const +{ + return mBoundStream; +} + Error Texture::setImage(const PixelUnpackState &unpackState, GLenum target, size_t level, @@ -378,7 +458,8 @@ Error Texture::setImage(const PixelUnpackState &unpackState, GLenum type, const uint8_t *pixels) { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); // Release from previous calls to eglBindTexImage, to avoid calling the Impl after releaseTexImageInternal(); @@ -404,7 +485,8 @@ Error Texture::setSubImage(const PixelUnpackState &unpackState, GLenum type, const uint8_t *pixels) { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return mTexture->setSubImage(target, level, area, format, type, unpackState, pixels); } @@ -416,7 +498,8 @@ Error Texture::setCompressedImage(const PixelUnpackState &unpackState, size_t imageSize, const uint8_t *pixels) { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); // Release from previous calls to eglBindTexImage, to avoid calling the Impl after releaseTexImageInternal(); @@ -442,7 +525,8 @@ Error Texture::setCompressedSubImage(const PixelUnpackState &unpackState, size_t imageSize, const uint8_t *pixels) { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return mTexture->setCompressedSubImage(target, level, area, format, unpackState, imageSize, pixels); @@ -451,7 +535,8 @@ Error Texture::setCompressedSubImage(const PixelUnpackState &unpackState, Error Texture::copyImage(GLenum target, size_t level, const Rectangle &sourceArea, GLenum internalFormat, const Framebuffer *source) { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); // Release from previous calls to eglBindTexImage, to avoid calling the Impl after releaseTexImageInternal(); @@ -472,14 +557,15 @@ Error Texture::copyImage(GLenum target, size_t level, const Rectangle &sourceAre Error Texture::copySubImage(GLenum target, size_t level, const Offset &destOffset, const Rectangle &sourceArea, const Framebuffer *source) { - ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); + ASSERT(target == mState.target || + (mState.target == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); return mTexture->copySubImage(target, level, destOffset, sourceArea, source); } Error Texture::setStorage(GLenum target, size_t levels, GLenum internalFormat, const Extents &size) { - ASSERT(target == mTarget); + ASSERT(target == mState.target); // Release from previous calls to eglBindTexImage, to avoid calling the Impl after releaseTexImageInternal(); @@ -491,8 +577,8 @@ Error Texture::setStorage(GLenum target, size_t levels, GLenum internalFormat, c return error; } - mTextureState.immutableFormat = true; - mTextureState.immutableLevels = static_cast<GLuint>(levels); + mState.immutableFormat = true; + mState.immutableLevels = static_cast<GLuint>(levels); clearImageDescs(); setImageDescChain(levels, size, internalFormat); @@ -511,7 +597,7 @@ Error Texture::generateMipmaps() orphanImages(); } - Error error = mTexture->generateMipmaps(mTextureState); + Error error = mTexture->generateMipmaps(); if (error.isError()) { return error; @@ -530,11 +616,11 @@ void Texture::setImageDescChain(size_t levels, Extents baseSize, GLenum sizedInt { Extents levelSize( std::max<int>(baseSize.width >> level, 1), std::max<int>(baseSize.height >> level, 1), - (mTarget == GL_TEXTURE_2D_ARRAY) ? baseSize.depth - : std::max<int>(baseSize.depth >> level, 1)); + (mState.target == GL_TEXTURE_2D_ARRAY) ? baseSize.depth + : std::max<int>(baseSize.depth >> level, 1)); ImageDesc levelInfo(levelSize, sizedInternalFormat); - if (mTarget == GL_TEXTURE_CUBE_MAP) + if (mState.target == GL_TEXTURE_CUBE_MAP) { for (GLenum face = FirstCubeMapTextureTarget; face <= LastCubeMapTextureTarget; face++) { @@ -543,7 +629,7 @@ void Texture::setImageDescChain(size_t levels, Extents baseSize, GLenum sizedInt } else { - setImageDesc(mTarget, level, levelInfo); + setImageDesc(mState.target, level, levelInfo); } } } @@ -601,10 +687,10 @@ void Texture::bindTexImageFromSurface(egl::Surface *surface) mBoundSurface = surface; // Set the image info to the size and format of the surface - ASSERT(mTarget == GL_TEXTURE_2D); + ASSERT(mState.target == GL_TEXTURE_2D); Extents size(surface->getWidth(), surface->getHeight(), 1); ImageDesc desc(size, surface->getConfig()->renderTargetFormat); - setImageDesc(mTarget, 0, desc); + setImageDesc(mState.target, 0, desc); } void Texture::releaseTexImageFromSurface() @@ -614,8 +700,44 @@ void Texture::releaseTexImageFromSurface() mTexture->releaseTexImage(); // Erase the image info for level 0 - ASSERT(mTarget == GL_TEXTURE_2D); - clearImageDesc(mTarget, 0); + ASSERT(mState.target == GL_TEXTURE_2D); + clearImageDesc(mState.target, 0); +} + +void Texture::bindStream(egl::Stream *stream) +{ + ASSERT(stream); + + // It should not be possible to bind a texture already bound to another stream + ASSERT(mBoundStream == nullptr); + + mBoundStream = stream; + + ASSERT(mState.target == GL_TEXTURE_EXTERNAL_OES); +} + +void Texture::releaseStream() +{ + ASSERT(mBoundStream); + mBoundStream = nullptr; +} + +void Texture::acquireImageFromStream(const egl::Stream::GLTextureDescription &desc) +{ + ASSERT(mBoundStream != nullptr); + mTexture->setImageExternal(mState.target, mBoundStream, desc); + + Extents size(desc.width, desc.height, 1); + setImageDesc(mState.target, 0, ImageDesc(size, desc.internalFormat)); +} + +void Texture::releaseImageFromStream() +{ + ASSERT(mBoundStream != nullptr); + mTexture->setImageExternal(mState.target, nullptr, egl::Stream::GLTextureDescription()); + + // Set to incomplete + clearImageDesc(mState.target, 0); } void Texture::releaseTexImageInternal() @@ -632,7 +754,7 @@ void Texture::releaseTexImageInternal() Error Texture::setEGLImageTarget(GLenum target, egl::Image *imageTarget) { - ASSERT(target == mTarget); + ASSERT(target == mState.target); ASSERT(target == GL_TEXTURE_2D); // Release from previous calls to eglBindTexImage, to avoid calling the Impl after @@ -660,18 +782,28 @@ Error Texture::setEGLImageTarget(GLenum target, egl::Image *imageTarget) GLenum Texture::getBaseImageTarget() const { - return mTarget == GL_TEXTURE_CUBE_MAP ? FirstCubeMapTextureTarget : mTarget; + return mState.target == GL_TEXTURE_CUBE_MAP ? FirstCubeMapTextureTarget : mState.target; } -bool Texture::computeSamplerCompleteness(const SamplerState &samplerState, const Data &data) const +bool Texture::computeSamplerCompleteness(const SamplerState &samplerState, + const ContextState &data) const { - const ImageDesc &baseImageDesc = getImageDesc(getBaseImageTarget(), mTextureState.baseLevel); + if (mState.baseLevel > mState.maxLevel) + { + return false; + } + const ImageDesc &baseImageDesc = + getImageDesc(getBaseImageTarget(), mState.getEffectiveBaseLevel()); if (baseImageDesc.size.width == 0 || baseImageDesc.size.height == 0 || baseImageDesc.size.depth == 0) { return false; } + // The cases where the texture is incomplete because base level is out of range should be + // handled by the above condition. + ASSERT(mState.baseLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS || mState.immutableFormat); - if (mTarget == GL_TEXTURE_CUBE_MAP && baseImageDesc.size.width != baseImageDesc.size.height) + if (mState.target == GL_TEXTURE_CUBE_MAP && + baseImageDesc.size.width != baseImageDesc.size.height) { return false; } @@ -709,7 +841,7 @@ bool Texture::computeSamplerCompleteness(const SamplerState &samplerState, const } else { - if (mTarget == GL_TEXTURE_CUBE_MAP && !isCubeComplete()) + if (mState.target == GL_TEXTURE_CUBE_MAP && !isCubeComplete()) { return false; } @@ -740,11 +872,11 @@ bool Texture::computeMipmapCompleteness() const { size_t expectedMipLevels = getMipCompleteLevels(); - size_t maxLevel = std::min<size_t>(expectedMipLevels, mTextureState.maxLevel + 1); + size_t maxLevel = std::min<size_t>(expectedMipLevels, mState.maxLevel + 1); - for (size_t level = mTextureState.baseLevel; level < maxLevel; level++) + for (size_t level = mState.getEffectiveBaseLevel(); level < maxLevel; level++) { - if (mTarget == GL_TEXTURE_CUBE_MAP) + if (mState.target == GL_TEXTURE_CUBE_MAP) { for (GLenum face = FirstCubeMapTextureTarget; face <= LastCubeMapTextureTarget; face++) { @@ -756,7 +888,7 @@ bool Texture::computeMipmapCompleteness() const } else { - if (!computeLevelCompleteness(mTarget, level)) + if (!computeLevelCompleteness(mState.target, level)) { return false; } @@ -770,12 +902,13 @@ bool Texture::computeLevelCompleteness(GLenum target, size_t level) const { ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS); - if (mTextureState.immutableFormat) + if (mState.immutableFormat) { return true; } - const ImageDesc &baseImageDesc = getImageDesc(getBaseImageTarget(), mTextureState.baseLevel); + const ImageDesc &baseImageDesc = + getImageDesc(getBaseImageTarget(), mState.getEffectiveBaseLevel()); if (baseImageDesc.size.width == 0 || baseImageDesc.size.height == 0 || baseImageDesc.size.depth == 0) { return false; @@ -793,8 +926,8 @@ bool Texture::computeLevelCompleteness(GLenum target, size_t level) const return false; } - ASSERT(level >= mTextureState.baseLevel); - const size_t relativeLevel = level - mTextureState.baseLevel; + ASSERT(level >= mState.getEffectiveBaseLevel()); + const size_t relativeLevel = level - mState.getEffectiveBaseLevel(); if (levelImageDesc.size.width != std::max(1, baseImageDesc.size.width >> relativeLevel)) { return false; @@ -805,14 +938,14 @@ bool Texture::computeLevelCompleteness(GLenum target, size_t level) const return false; } - if (mTarget == GL_TEXTURE_3D) + if (mState.target == GL_TEXTURE_3D) { if (levelImageDesc.size.depth != std::max(1, baseImageDesc.size.depth >> relativeLevel)) { return false; } } - else if (mTarget == GL_TEXTURE_2D_ARRAY) + else if (mState.target == GL_TEXTURE_2D_ARRAY) { if (levelImageDesc.size.depth != baseImageDesc.size.depth) { @@ -863,4 +996,9 @@ GLuint Texture::getId() const { return id(); } + +rx::FramebufferAttachmentObjectImpl *Texture::getAttachmentImpl() const +{ + return mTexture; +} } diff --git a/chromium/third_party/angle/src/libANGLE/Texture.h b/chromium/third_party/angle/src/libANGLE/Texture.h index f6cddf14ca3..37083270389 100644 --- a/chromium/third_party/angle/src/libANGLE/Texture.h +++ b/chromium/third_party/angle/src/libANGLE/Texture.h @@ -20,27 +20,67 @@ #include "libANGLE/Error.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/Image.h" +#include "libANGLE/Stream.h" #include "libANGLE/angletypes.h" -#include "libANGLE/renderer/TextureImpl.h" namespace egl { class Surface; +class Stream; +} + +namespace rx +{ +class GLImplFactory; +class TextureImpl; } namespace gl { +struct ContextState; class Framebuffer; -struct Data; bool IsMipmapFiltered(const SamplerState &samplerState); +// State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec. +struct TextureState final : public angle::NonCopyable +{ + TextureState(GLenum target); + + bool swizzleRequired() const; + GLuint getEffectiveBaseLevel() const; + GLuint getEffectiveMaxLevel() const; + + // TODO(jmadill): Make the data members here private. + + const GLenum target; + + GLenum swizzleRed; + GLenum swizzleGreen; + GLenum swizzleBlue; + GLenum swizzleAlpha; + + SamplerState samplerState; + + GLuint baseLevel; + GLuint maxLevel; + + bool immutableFormat; + GLuint immutableLevels; + + // From GL_ANGLE_texture_usage + GLenum usage; +}; + +bool operator==(const TextureState &a, const TextureState &b); +bool operator!=(const TextureState &a, const TextureState &b); + class Texture final : public egl::ImageSibling, public FramebufferAttachmentObject, public LabeledObject { public: - Texture(rx::TextureImpl *impl, GLuint id, GLenum target); + Texture(rx::GLImplFactory *factory, GLuint id, GLenum target); ~Texture() override; void setLabel(const std::string &label) override; @@ -112,7 +152,7 @@ class Texture final : public egl::ImageSibling, size_t getDepth(GLenum target, size_t level) const; GLenum getInternalFormat(GLenum target, size_t level) const; - bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const; + bool isSamplerComplete(const SamplerState &samplerState, const ContextState &data) const; bool isMipmapComplete() const; bool isCubeComplete() const; size_t getMipCompleteLevels() const; @@ -166,6 +206,7 @@ class Texture final : public egl::ImageSibling, Error generateMipmaps(); egl::Surface *getBoundSurface() const; + egl::Stream *getBoundStream() const; rx::TextureImpl *getImplementation() { return mTexture; } const rx::TextureImpl *getImplementation() const { return mTexture; } @@ -180,21 +221,25 @@ class Texture final : public egl::ImageSibling, GLuint getId() const override; private: - rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mTexture; } + rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override; // ANGLE-only method, used internally friend class egl::Surface; void bindTexImageFromSurface(egl::Surface *surface); void releaseTexImageFromSurface(); + // ANGLE-only methods, used internally + friend class egl::Stream; + void bindStream(egl::Stream *stream); + void releaseStream(); + void acquireImageFromStream(const egl::Stream::GLTextureDescription &desc); + void releaseImageFromStream(); + + TextureState mState; rx::TextureImpl *mTexture; std::string mLabel; - TextureState mTextureState; - - GLenum mTarget; - struct ImageDesc { Extents size; @@ -206,7 +251,8 @@ class Texture final : public egl::ImageSibling, GLenum getBaseImageTarget() const; - bool computeSamplerCompleteness(const SamplerState &samplerState, const Data &data) const; + bool computeSamplerCompleteness(const SamplerState &samplerState, + const ContextState &data) const; bool computeMipmapCompleteness() const; bool computeLevelCompleteness(GLenum target, size_t level) const; @@ -238,8 +284,22 @@ class Texture final : public egl::ImageSibling, mutable SamplerCompletenessCache mCompletenessCache; egl::Surface *mBoundSurface; + egl::Stream *mBoundStream; }; +inline bool operator==(const TextureState &a, const TextureState &b) +{ + return a.swizzleRed == b.swizzleRed && a.swizzleGreen == b.swizzleGreen && + a.swizzleBlue == b.swizzleBlue && a.swizzleAlpha == b.swizzleAlpha && + a.samplerState == b.samplerState && a.baseLevel == b.baseLevel && + a.maxLevel == b.maxLevel && a.immutableFormat == b.immutableFormat && + a.immutableLevels == b.immutableLevels && a.usage == b.usage; +} + +inline bool operator!=(const TextureState &a, const TextureState &b) +{ + return !(a == b); +} } #endif // LIBANGLE_TEXTURE_H_ diff --git a/chromium/third_party/angle/src/libANGLE/TransformFeedback.cpp b/chromium/third_party/angle/src/libANGLE/TransformFeedback.cpp index 6ee17006c32..22341547446 100644 --- a/chromium/third_party/angle/src/libANGLE/TransformFeedback.cpp +++ b/chromium/third_party/angle/src/libANGLE/TransformFeedback.cpp @@ -8,14 +8,15 @@ #include "libANGLE/Buffer.h" #include "libANGLE/Caps.h" +#include "libANGLE/ContextState.h" #include "libANGLE/Program.h" -#include "libANGLE/renderer/ImplFactory.h" +#include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/TransformFeedbackImpl.h" namespace gl { -TransformFeedback::TransformFeedback(rx::ImplFactory *implFactory, GLuint id, const Caps &caps) +TransformFeedback::TransformFeedback(rx::GLImplFactory *implFactory, GLuint id, const Caps &caps) : RefCountObject(id), mImplementation(implFactory->createTransformFeedback()), mLabel(), diff --git a/chromium/third_party/angle/src/libANGLE/TransformFeedback.h b/chromium/third_party/angle/src/libANGLE/TransformFeedback.h index 9e8af2e337c..c120710a25b 100644 --- a/chromium/third_party/angle/src/libANGLE/TransformFeedback.h +++ b/chromium/third_party/angle/src/libANGLE/TransformFeedback.h @@ -16,7 +16,7 @@ namespace rx { -class ImplFactory; +class GLImplFactory; class TransformFeedbackImpl; } @@ -29,7 +29,7 @@ class Program; class TransformFeedback final : public RefCountObject, public LabeledObject { public: - TransformFeedback(rx::ImplFactory *implFactory, GLuint id, const Caps &caps); + TransformFeedback(rx::GLImplFactory *implFactory, GLuint id, const Caps &caps); virtual ~TransformFeedback(); void setLabel(const std::string &label) override; diff --git a/chromium/third_party/angle/src/libANGLE/TransformFeedback_unittest.cpp b/chromium/third_party/angle/src/libANGLE/TransformFeedback_unittest.cpp index 56d02e2621c..d173686ea20 100644 --- a/chromium/third_party/angle/src/libANGLE/TransformFeedback_unittest.cpp +++ b/chromium/third_party/angle/src/libANGLE/TransformFeedback_unittest.cpp @@ -20,12 +20,6 @@ using ::testing::SetArgumentPointee; namespace { -class MockFactory : public rx::NullFactory -{ - public: - MOCK_METHOD0(createTransformFeedback, rx::TransformFeedbackImpl *()); -}; - class TransformFeedbackTest : public testing::Test { protected: @@ -59,7 +53,7 @@ class TransformFeedbackTest : public testing::Test testing::Mock::VerifyAndClear(mImpl); } - MockFactory mMockFactory; + rx::MockGLFactory mMockFactory; rx::MockTransformFeedbackImpl* mImpl; gl::TransformFeedback* mFeedback; gl::Caps mCaps; diff --git a/chromium/third_party/angle/src/libANGLE/VertexArray.cpp b/chromium/third_party/angle/src/libANGLE/VertexArray.cpp index a1ca19a5d73..0b8fcb63df8 100644 --- a/chromium/third_party/angle/src/libANGLE/VertexArray.cpp +++ b/chromium/third_party/angle/src/libANGLE/VertexArray.cpp @@ -8,18 +8,18 @@ #include "libANGLE/VertexArray.h" #include "libANGLE/Buffer.h" -#include "libANGLE/renderer/ImplFactory.h" +#include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/VertexArrayImpl.h" namespace gl { -VertexArray::Data::Data(size_t maxAttribs) +VertexArrayState::VertexArrayState(size_t maxAttribs) : mLabel(), mVertexAttributes(maxAttribs), mMaxEnabledAttribute(0) { } -VertexArray::Data::~Data() +VertexArrayState::~VertexArrayState() { for (size_t i = 0; i < getMaxAttribs(); i++) { @@ -28,8 +28,8 @@ VertexArray::Data::~Data() mElementArrayBuffer.set(nullptr); } -VertexArray::VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs) - : mId(id), mData(maxAttribs), mVertexArray(factory->createVertexArray(mData)) +VertexArray::VertexArray(rx::GLImplFactory *factory, GLuint id, size_t maxAttribs) + : mId(id), mState(maxAttribs), mVertexArray(factory->createVertexArray(mState)) { } @@ -45,60 +45,60 @@ GLuint VertexArray::id() const void VertexArray::setLabel(const std::string &label) { - mData.mLabel = label; + mState.mLabel = label; } const std::string &VertexArray::getLabel() const { - return mData.mLabel; + return mState.mLabel; } void VertexArray::detachBuffer(GLuint bufferName) { for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++) { - if (mData.mVertexAttributes[attribute].buffer.id() == bufferName) + if (mState.mVertexAttributes[attribute].buffer.id() == bufferName) { - mData.mVertexAttributes[attribute].buffer.set(nullptr); + mState.mVertexAttributes[attribute].buffer.set(nullptr); } } - if (mData.mElementArrayBuffer.id() == bufferName) + if (mState.mElementArrayBuffer.id() == bufferName) { - mData.mElementArrayBuffer.set(nullptr); + mState.mElementArrayBuffer.set(nullptr); } } const VertexAttribute &VertexArray::getVertexAttribute(size_t attributeIndex) const { ASSERT(attributeIndex < getMaxAttribs()); - return mData.mVertexAttributes[attributeIndex]; + return mState.mVertexAttributes[attributeIndex]; } void VertexArray::setVertexAttribDivisor(size_t index, GLuint divisor) { ASSERT(index < getMaxAttribs()); - mData.mVertexAttributes[index].divisor = divisor; + mState.mVertexAttributes[index].divisor = divisor; mDirtyBits.set(DIRTY_BIT_ATTRIB_0_DIVISOR + index); } void VertexArray::enableAttribute(size_t attributeIndex, bool enabledState) { ASSERT(attributeIndex < getMaxAttribs()); - mData.mVertexAttributes[attributeIndex].enabled = enabledState; + mState.mVertexAttributes[attributeIndex].enabled = enabledState; mDirtyBits.set(DIRTY_BIT_ATTRIB_0_ENABLED + attributeIndex); // Update state cache if (enabledState) { - mData.mMaxEnabledAttribute = std::max(attributeIndex + 1, mData.mMaxEnabledAttribute); + mState.mMaxEnabledAttribute = std::max(attributeIndex + 1, mState.mMaxEnabledAttribute); } - else if (mData.mMaxEnabledAttribute == attributeIndex + 1) + else if (mState.mMaxEnabledAttribute == attributeIndex + 1) { - while (mData.mMaxEnabledAttribute > 0 && - !mData.mVertexAttributes[mData.mMaxEnabledAttribute - 1].enabled) + while (mState.mMaxEnabledAttribute > 0 && + !mState.mVertexAttributes[mState.mMaxEnabledAttribute - 1].enabled) { - --mData.mMaxEnabledAttribute; + --mState.mMaxEnabledAttribute; } } } @@ -108,7 +108,7 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff { ASSERT(attributeIndex < getMaxAttribs()); - VertexAttribute *attrib = &mData.mVertexAttributes[attributeIndex]; + VertexAttribute *attrib = &mState.mVertexAttributes[attributeIndex]; attrib->buffer.set(boundBuffer); attrib->size = size; @@ -122,7 +122,7 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff void VertexArray::setElementArrayBuffer(Buffer *buffer) { - mData.mElementArrayBuffer.set(buffer); + mState.mElementArrayBuffer.set(buffer); mDirtyBits.set(DIRTY_BIT_ELEMENT_ARRAY_BUFFER); } diff --git a/chromium/third_party/angle/src/libANGLE/VertexArray.h b/chromium/third_party/angle/src/libANGLE/VertexArray.h index fe262fde3b0..da660e040c9 100644 --- a/chromium/third_party/angle/src/libANGLE/VertexArray.h +++ b/chromium/third_party/angle/src/libANGLE/VertexArray.h @@ -23,7 +23,7 @@ namespace rx { -class ImplFactory; +class GLImplFactory; class VertexArrayImpl; } @@ -31,10 +31,35 @@ namespace gl { class Buffer; +class VertexArrayState final : public angle::NonCopyable +{ + public: + explicit VertexArrayState(size_t maxAttribs); + ~VertexArrayState(); + + const std::string &getLabel() const { return mLabel; } + + const BindingPointer<Buffer> &getElementArrayBuffer() const { return mElementArrayBuffer; } + size_t getMaxAttribs() const { return mVertexAttributes.size(); } + size_t getMaxEnabledAttribute() const { return mMaxEnabledAttribute; } + const std::vector<VertexAttribute> &getVertexAttributes() const { return mVertexAttributes; } + const VertexAttribute &getVertexAttribute(size_t index) const + { + return mVertexAttributes[index]; + } + + private: + friend class VertexArray; + std::string mLabel; + std::vector<VertexAttribute> mVertexAttributes; + BindingPointer<Buffer> mElementArrayBuffer; + size_t mMaxEnabledAttribute; +}; + class VertexArray final : public LabeledObject { public: - VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs); + VertexArray(rx::GLImplFactory *factory, GLuint id, size_t maxAttribs); ~VertexArray(); GLuint id() const; @@ -52,39 +77,20 @@ class VertexArray final : public LabeledObject void setElementArrayBuffer(Buffer *buffer); - const BindingPointer<Buffer> &getElementArrayBuffer() const { return mData.getElementArrayBuffer(); } - size_t getMaxAttribs() const { return mData.getVertexAttributes().size(); } - const std::vector<VertexAttribute> &getVertexAttributes() const { return mData.getVertexAttributes(); } + const BindingPointer<Buffer> &getElementArrayBuffer() const + { + return mState.getElementArrayBuffer(); + } + size_t getMaxAttribs() const { return mState.getVertexAttributes().size(); } + const std::vector<VertexAttribute> &getVertexAttributes() const + { + return mState.getVertexAttributes(); + } rx::VertexArrayImpl *getImplementation() { return mVertexArray; } const rx::VertexArrayImpl *getImplementation() const { return mVertexArray; } - size_t getMaxEnabledAttribute() const { return mData.getMaxEnabledAttribute(); } - - class Data final : public angle::NonCopyable - { - public: - explicit Data(size_t maxAttribs); - ~Data(); - - const std::string &getLabel() const { return mLabel; } - - const BindingPointer<Buffer> &getElementArrayBuffer() const { return mElementArrayBuffer; } - size_t getMaxAttribs() const { return mVertexAttributes.size(); } - size_t getMaxEnabledAttribute() const { return mMaxEnabledAttribute; } - const std::vector<VertexAttribute> &getVertexAttributes() const { return mVertexAttributes; } - const VertexAttribute &getVertexAttribute(size_t index) const - { - return mVertexAttributes[index]; - } - - private: - friend class VertexArray; - std::string mLabel; - std::vector<VertexAttribute> mVertexAttributes; - BindingPointer<Buffer> mElementArrayBuffer; - size_t mMaxEnabledAttribute; - }; + size_t getMaxEnabledAttribute() const { return mState.getMaxEnabledAttribute(); } enum DirtyBitType { @@ -114,7 +120,7 @@ class VertexArray final : public LabeledObject private: GLuint mId; - Data mData; + VertexArrayState mState; DirtyBits mDirtyBits; rx::VertexArrayImpl *mVertexArray; diff --git a/chromium/third_party/angle/src/libANGLE/angletypes.cpp b/chromium/third_party/angle/src/libANGLE/angletypes.cpp index dd06d41216a..3a636c9e453 100644 --- a/chromium/third_party/angle/src/libANGLE/angletypes.cpp +++ b/chromium/third_party/angle/src/libANGLE/angletypes.cpp @@ -53,26 +53,6 @@ SamplerState::SamplerState() { } -TextureState::TextureState() - : swizzleRed(GL_RED), - swizzleGreen(GL_GREEN), - swizzleBlue(GL_BLUE), - swizzleAlpha(GL_ALPHA), - samplerState(), - baseLevel(0), - maxLevel(1000), - immutableFormat(false), - immutableLevels(0), - usage(GL_NONE) -{ -} - -bool TextureState::swizzleRequired() const -{ - return swizzleRed != GL_RED || swizzleGreen != GL_GREEN || - swizzleBlue != GL_BLUE || swizzleAlpha != GL_ALPHA; -} - static void MinMax(int a, int b, int *minimum, int *maximum) { if (a < b) diff --git a/chromium/third_party/angle/src/libANGLE/angletypes.h b/chromium/third_party/angle/src/libANGLE/angletypes.h index 0842be3a65f..0cd533ebe74 100644 --- a/chromium/third_party/angle/src/libANGLE/angletypes.h +++ b/chromium/third_party/angle/src/libANGLE/angletypes.h @@ -215,33 +215,6 @@ struct SamplerState bool operator==(const SamplerState &a, const SamplerState &b); bool operator!=(const SamplerState &a, const SamplerState &b); -// State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec. -struct TextureState -{ - TextureState(); - - GLenum swizzleRed; - GLenum swizzleGreen; - GLenum swizzleBlue; - GLenum swizzleAlpha; - - SamplerState samplerState; - - GLuint baseLevel; - GLuint maxLevel; - - bool immutableFormat; - GLuint immutableLevels; - - // From GL_ANGLE_texture_usage - GLenum usage; - - bool swizzleRequired() const; -}; - -bool operator==(const TextureState &a, const TextureState &b); -bool operator!=(const TextureState &a, const TextureState &b); - struct PixelUnpackState { BindingPointer<Buffer> pixelBuffer; diff --git a/chromium/third_party/angle/src/libANGLE/angletypes.inl b/chromium/third_party/angle/src/libANGLE/angletypes.inl index d51bcaaa789..f14a9b624d8 100644 --- a/chromium/third_party/angle/src/libANGLE/angletypes.inl +++ b/chromium/third_party/angle/src/libANGLE/angletypes.inl @@ -56,23 +56,4 @@ inline bool operator!=(const SamplerState &a, const SamplerState &b) return !(a == b); } -inline bool operator==(const TextureState &a, const TextureState &b) -{ - return a.swizzleRed == b.swizzleRed && - a.swizzleGreen == b.swizzleGreen && - a.swizzleBlue == b.swizzleBlue && - a.swizzleAlpha == b.swizzleAlpha && - a.samplerState == b.samplerState && - a.baseLevel == b.baseLevel && - a.maxLevel == b.maxLevel && - a.immutableFormat == b.immutableFormat && - a.immutableLevels == b.immutableLevels && - a.usage == b.usage; -} - -inline bool operator!=(const TextureState &a, const TextureState &b) -{ - return !(a == b); -} - } diff --git a/chromium/third_party/angle/src/libANGLE/formatutils.cpp b/chromium/third_party/angle/src/libANGLE/formatutils.cpp index 3a4df126c5f..c9b2aba669f 100644 --- a/chromium/third_party/angle/src/libANGLE/formatutils.cpp +++ b/chromium/third_party/angle/src/libANGLE/formatutils.cpp @@ -10,7 +10,6 @@ #include "libANGLE/formatutils.h" #include "libANGLE/Context.h" #include "libANGLE/Framebuffer.h" -#include "libANGLE/renderer/Renderer.h" namespace gl { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/ContextImpl.cpp b/chromium/third_party/angle/src/libANGLE/renderer/ContextImpl.cpp new file mode 100644 index 00000000000..e02b5a76541 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/ContextImpl.cpp @@ -0,0 +1,23 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// ContextImpl: +// Implementation-specific functionality associated with a GL Context. +// + +#include "libANGLE/renderer/ContextImpl.h" + +namespace rx +{ + +ContextImpl::ContextImpl(const gl::ContextState &state) : mState(state) +{ +} + +ContextImpl::~ContextImpl() +{ +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/ContextImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/ContextImpl.h new file mode 100644 index 00000000000..3d1f3cc0b8f --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/ContextImpl.h @@ -0,0 +1,102 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// ContextImpl: +// Implementation-specific functionality associated with a GL Context. +// + +#ifndef LIBANGLE_RENDERER_CONTEXTIMPL_H_ +#define LIBANGLE_RENDERER_CONTEXTIMPL_H_ + +#include "common/angleutils.h" +#include "libANGLE/ContextState.h" +#include "libANGLE/renderer/GLImplFactory.h" + +namespace rx +{ +class ContextImpl : public GLImplFactory +{ + public: + ContextImpl(const gl::ContextState &state); + virtual ~ContextImpl(); + + virtual gl::Error initialize() = 0; + + const gl::ContextState &getContextState() { return mState; } + int getClientVersion() const { return mState.clientVersion; } + const gl::State &getState() const { return *mState.state; } + const gl::Caps &getCaps() const { return *mState.caps; } + const gl::TextureCapsMap &getTextureCaps() const { return *mState.textureCaps; } + const gl::Extensions &getExtensions() const { return *mState.extensions; } + const gl::Limitations &getLimitations() const { return *mState.limitations; } + + // Flush and finish. + virtual gl::Error flush() = 0; + virtual gl::Error finish() = 0; + + // Drawing methods. + virtual gl::Error drawArrays(GLenum mode, GLint first, GLsizei count) = 0; + virtual gl::Error drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) = 0; + + virtual gl::Error drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) = 0; + virtual gl::Error drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) = 0; + virtual gl::Error drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) = 0; + + // TODO(jmadill): Investigate proper impl methods for this. + virtual void notifyDeviceLost() = 0; + virtual bool isDeviceLost() const = 0; + virtual bool testDeviceLost() = 0; + virtual bool testDeviceResettable() = 0; + + // Vendor and description strings. + virtual std::string getVendorString() const = 0; + virtual std::string getRendererDescription() const = 0; + + // Debug markers. + virtual void insertEventMarker(GLsizei length, const char *marker) = 0; + virtual void pushGroupMarker(GLsizei length, const char *marker) = 0; + virtual void popGroupMarker() = 0; + + // State sync with dirty bits. + virtual void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) = 0; + + // Disjoint timer queries + virtual GLint getGPUDisjoint() = 0; + virtual GLint64 getTimestamp() = 0; + + // Context switching + virtual void onMakeCurrent(const gl::ContextState &data) = 0; + + // Native capabilities, unmodified by gl::Context. + virtual const gl::Caps &getNativeCaps() const = 0; + virtual const gl::TextureCapsMap &getNativeTextureCaps() const = 0; + virtual const gl::Extensions &getNativeExtensions() const = 0; + virtual const gl::Limitations &getNativeLimitations() const = 0; + + protected: + const gl::ContextState &mState; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_CONTEXTIMPL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/DisplayImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/DisplayImpl.h index dabe964ed80..8ef47ed164a 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/DisplayImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/DisplayImpl.h @@ -13,7 +13,8 @@ #include "libANGLE/Caps.h" #include "libANGLE/Config.h" #include "libANGLE/Error.h" -#include "libANGLE/renderer/Renderer.h" +#include "libANGLE/renderer/EGLImplFactory.h" +#include "libANGLE/Stream.h" #include <set> #include <vector> @@ -38,9 +39,9 @@ class SurfaceImpl; class ImageImpl; struct ConfigDesc; class DeviceImpl; -class StreamImpl; +class StreamProducerImpl; -class DisplayImpl : angle::NonCopyable +class DisplayImpl : public EGLImplFactory { public: DisplayImpl(); @@ -49,28 +50,6 @@ class DisplayImpl : angle::NonCopyable virtual egl::Error initialize(egl::Display *display) = 0; virtual void terminate() = 0; - virtual SurfaceImpl *createWindowSurface(const egl::Config *configuration, - EGLNativeWindowType window, - const egl::AttributeMap &attribs) = 0; - virtual SurfaceImpl *createPbufferSurface(const egl::Config *configuration, - const egl::AttributeMap &attribs) = 0; - virtual SurfaceImpl *createPbufferFromClientBuffer(const egl::Config *configuration, - EGLClientBuffer shareHandle, - const egl::AttributeMap &attribs) = 0; - virtual SurfaceImpl *createPixmapSurface(const egl::Config *configuration, - NativePixmapType nativePixmap, - const egl::AttributeMap &attribs) = 0; - - virtual ImageImpl *createImage(EGLenum target, - egl::ImageSibling *buffer, - const egl::AttributeMap &attribs) = 0; - - virtual gl::Context *createContext(const egl::Config *config, - const gl::Context *shareContext, - const egl::AttributeMap &attribs) = 0; - - virtual StreamImpl *createStream(const egl::AttributeMap &attribs) = 0; - virtual egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) = 0; virtual egl::ConfigSet generateConfigs() const = 0; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/EGLImplFactory.h b/chromium/third_party/angle/src/libANGLE/renderer/EGLImplFactory.h new file mode 100644 index 00000000000..15b139c0b1c --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/EGLImplFactory.h @@ -0,0 +1,65 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// EGLImplFactory.h: +// Factory interface for EGL Impl objects. +// + +#ifndef LIBANGLE_RENDERER_EGLIMPLFACTORY_H_ +#define LIBANGLE_RENDERER_EGLIMPLFACTORY_H_ + +#include "libANGLE/Stream.h" + +namespace egl +{ +class AttributeMap; +struct Config; +class ImageSibling; +} + +namespace gl +{ +class Context; +struct ContextState; +} + +namespace rx +{ +class ContextImpl; +class ImageImpl; +class SurfaceImpl; + +class EGLImplFactory : angle::NonCopyable +{ + public: + EGLImplFactory() {} + virtual ~EGLImplFactory() {} + + virtual SurfaceImpl *createWindowSurface(const egl::Config *configuration, + EGLNativeWindowType window, + const egl::AttributeMap &attribs) = 0; + virtual SurfaceImpl *createPbufferSurface(const egl::Config *configuration, + const egl::AttributeMap &attribs) = 0; + virtual SurfaceImpl *createPbufferFromClientBuffer(const egl::Config *configuration, + EGLClientBuffer shareHandle, + const egl::AttributeMap &attribs) = 0; + virtual SurfaceImpl *createPixmapSurface(const egl::Config *configuration, + NativePixmapType nativePixmap, + const egl::AttributeMap &attribs) = 0; + + virtual ImageImpl *createImage(EGLenum target, + egl::ImageSibling *buffer, + const egl::AttributeMap &attribs) = 0; + + virtual ContextImpl *createContext(const gl::ContextState &state) = 0; + + virtual StreamProducerImpl *createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) = 0; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_EGLIMPLFACTORY_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl.h index 680122d0edb..a61dbba535e 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl.h @@ -28,27 +28,27 @@ namespace rx class FramebufferImpl : angle::NonCopyable { public: - explicit FramebufferImpl(const gl::Framebuffer::Data &data) : mData(data) { } + explicit FramebufferImpl(const gl::FramebufferState &state) : mState(state) {} virtual ~FramebufferImpl() { } virtual gl::Error discard(size_t count, const GLenum *attachments) = 0; virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0; virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0; - virtual gl::Error clear(const gl::Data &data, GLbitfield mask) = 0; - virtual gl::Error clearBufferfv(const gl::Data &data, + virtual gl::Error clear(ContextImpl *context, GLbitfield mask) = 0; + virtual gl::Error clearBufferfv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLfloat *values) = 0; - virtual gl::Error clearBufferuiv(const gl::Data &data, + virtual gl::Error clearBufferuiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLuint *values) = 0; - virtual gl::Error clearBufferiv(const gl::Data &data, + virtual gl::Error clearBufferiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLint *values) = 0; - virtual gl::Error clearBufferfi(const gl::Data &data, + virtual gl::Error clearBufferfi(ContextImpl *context, GLenum buffer, GLint drawbuffer, GLfloat depth, @@ -56,19 +56,26 @@ class FramebufferImpl : angle::NonCopyable virtual GLenum getImplementationColorReadFormat() const = 0; virtual GLenum getImplementationColorReadType() const = 0; - virtual gl::Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const = 0; - - virtual gl::Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, - GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) = 0; + virtual gl::Error readPixels(ContextImpl *context, + const gl::Rectangle &area, + GLenum format, + GLenum type, + GLvoid *pixels) const = 0; + + virtual gl::Error blit(ContextImpl *context, + const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + GLbitfield mask, + GLenum filter) = 0; virtual bool checkStatus() const = 0; virtual void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) = 0; - const gl::Framebuffer::Data &getData() const { return mData; } + const gl::FramebufferState &getState() const { return mState; } protected: - const gl::Framebuffer::Data &mData; + const gl::FramebufferState &mState; }; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl_mock.h b/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl_mock.h index 57c95342d7e..9bf93db9734 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl_mock.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/FramebufferImpl_mock.h @@ -20,32 +20,27 @@ namespace rx class MockFramebufferImpl : public rx::FramebufferImpl { public: - MockFramebufferImpl() : rx::FramebufferImpl(gl::Framebuffer::Data()) {} + MockFramebufferImpl() : rx::FramebufferImpl(gl::FramebufferState()) {} virtual ~MockFramebufferImpl() { destroy(); } MOCK_METHOD2(discard, gl::Error(size_t, const GLenum *)); MOCK_METHOD2(invalidate, gl::Error(size_t, const GLenum *)); MOCK_METHOD3(invalidateSub, gl::Error(size_t, const GLenum *, const gl::Rectangle &)); - MOCK_METHOD2(clear, gl::Error(const gl::Data &, GLbitfield)); - MOCK_METHOD4(clearBufferfv, gl::Error(const gl::Data &, GLenum, GLint, const GLfloat *)); - MOCK_METHOD4(clearBufferuiv, gl::Error(const gl::Data &, GLenum, GLint, const GLuint *)); - MOCK_METHOD4(clearBufferiv, gl::Error(const gl::Data &, GLenum, GLint, const GLint *)); - MOCK_METHOD5(clearBufferfi, gl::Error(const gl::Data &, GLenum, GLint, GLfloat, GLint)); + MOCK_METHOD2(clear, gl::Error(ContextImpl *, GLbitfield)); + MOCK_METHOD4(clearBufferfv, gl::Error(ContextImpl *, GLenum, GLint, const GLfloat *)); + MOCK_METHOD4(clearBufferuiv, gl::Error(ContextImpl *, GLenum, GLint, const GLuint *)); + MOCK_METHOD4(clearBufferiv, gl::Error(ContextImpl *, GLenum, GLint, const GLint *)); + MOCK_METHOD5(clearBufferfi, gl::Error(ContextImpl *, GLenum, GLint, GLfloat, GLint)); MOCK_CONST_METHOD0(getImplementationColorReadFormat, GLenum()); MOCK_CONST_METHOD0(getImplementationColorReadType, GLenum()); - MOCK_CONST_METHOD5( - readPixels, - gl::Error(const gl::State &, const gl::Rectangle &, GLenum, GLenum, GLvoid *)); - - MOCK_METHOD6(blit, - gl::Error(const gl::State &, - const gl::Rectangle &, - const gl::Rectangle &, - GLbitfield, - GLenum, - const gl::Framebuffer *)); + MOCK_CONST_METHOD5(readPixels, + gl::Error(ContextImpl *, const gl::Rectangle &, GLenum, GLenum, GLvoid *)); + + MOCK_METHOD5( + blit, + gl::Error(ContextImpl *, const gl::Rectangle &, const gl::Rectangle &, GLbitfield, GLenum)); MOCK_CONST_METHOD0(checkStatus, bool()); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/ImplFactory.h b/chromium/third_party/angle/src/libANGLE/renderer/GLImplFactory.h index 8e3e4af27a9..adf8e424456 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/ImplFactory.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/GLImplFactory.h @@ -3,22 +3,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// ImplFactory.h: -// Factory interface for Impl objects. +// GLImplFactory.h: +// Factory interface for OpenGL ES Impl objects. // -#ifndef LIBANGLE_RENDERER_IMPLFACTORY_H_ -#define LIBANGLE_RENDERER_IMPLFACTORY_H_ +#ifndef LIBANGLE_RENDERER_GLIMPLFACTORY_H_ +#define LIBANGLE_RENDERER_GLIMPLFACTORY_H_ #include "libANGLE/Framebuffer.h" #include "libANGLE/Program.h" #include "libANGLE/Shader.h" #include "libANGLE/VertexArray.h" +namespace gl +{ +struct ContextState; +} + namespace rx { class BufferImpl; class CompilerImpl; +class ContextImpl; class FenceNVImpl; class FenceSyncImpl; class FramebufferImpl; @@ -30,24 +36,23 @@ class ShaderImpl; class TextureImpl; class TransformFeedbackImpl; class VertexArrayImpl; -class StreamImpl; -class ImplFactory : angle::NonCopyable +class GLImplFactory : angle::NonCopyable { public: - ImplFactory() {} - virtual ~ImplFactory() {} + GLImplFactory() {} + virtual ~GLImplFactory() {} // Shader creation virtual CompilerImpl *createCompiler() = 0; - virtual ShaderImpl *createShader(const gl::Shader::Data &data) = 0; - virtual ProgramImpl *createProgram(const gl::Program::Data &data) = 0; + virtual ShaderImpl *createShader(const gl::ShaderState &data) = 0; + virtual ProgramImpl *createProgram(const gl::ProgramState &data) = 0; // Framebuffer creation - virtual FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) = 0; + virtual FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) = 0; // Texture creation - virtual TextureImpl *createTexture(GLenum target) = 0; + virtual TextureImpl *createTexture(const gl::TextureState &state) = 0; // Renderbuffer creation virtual RenderbufferImpl *createRenderbuffer() = 0; @@ -56,7 +61,7 @@ class ImplFactory : angle::NonCopyable virtual BufferImpl *createBuffer() = 0; // Vertex Array creation - virtual VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) = 0; + virtual VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) = 0; // Query and Fence creation virtual QueryImpl *createQuery(GLenum type) = 0; @@ -70,6 +75,6 @@ class ImplFactory : angle::NonCopyable virtual SamplerImpl *createSampler() = 0; }; -} +} // namespace rx -#endif // LIBANGLE_RENDERER_IMPLFACTORY_H_ +#endif // LIBANGLE_RENDERER_GLIMPLFACTORY_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl.h index 1e688045a1b..12c4a3ca8c0 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl.h @@ -14,10 +14,14 @@ #include "libANGLE/Constants.h" #include "libANGLE/Program.h" #include "libANGLE/Shader.h" -#include "libANGLE/renderer/Renderer.h" #include <map> +namespace sh +{ +struct BlockMemberInfo; +} + namespace rx { @@ -32,14 +36,14 @@ struct LinkResult class ProgramImpl : angle::NonCopyable { public: - ProgramImpl(const gl::Program::Data &data) : mData(data) {} + ProgramImpl(const gl::ProgramState &state) : mState(state) {} virtual ~ProgramImpl() {} virtual LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) = 0; virtual gl::Error save(gl::BinaryOutputStream *stream) = 0; virtual void setBinaryRetrievableHint(bool retrievable) = 0; - virtual LinkResult link(const gl::Data &data, gl::InfoLog &infoLog) = 0; + virtual LinkResult link(const gl::ContextState &data, gl::InfoLog &infoLog) = 0; virtual GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) = 0; virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0; @@ -77,7 +81,7 @@ class ProgramImpl : angle::NonCopyable sh::BlockMemberInfo *memberInfoOut) const = 0; protected: - const gl::Program::Data &mData; + const gl::ProgramState &mState; }; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl_mock.h b/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl_mock.h index d6aa238f649..94fc7ab0d8d 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl_mock.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/ProgramImpl_mock.h @@ -20,14 +20,14 @@ namespace rx class MockProgramImpl : public rx::ProgramImpl { public: - MockProgramImpl() : ProgramImpl(gl::Program::Data()) {} + MockProgramImpl() : ProgramImpl(gl::ProgramState()) {} virtual ~MockProgramImpl() { destroy(); } MOCK_METHOD2(load, LinkResult(gl::InfoLog &, gl::BinaryInputStream *)); MOCK_METHOD1(save, gl::Error(gl::BinaryOutputStream *)); MOCK_METHOD1(setBinaryRetrievableHint, void(bool)); - MOCK_METHOD2(link, LinkResult(const gl::Data &, gl::InfoLog &)); + MOCK_METHOD2(link, LinkResult(const gl::ContextState &, gl::InfoLog &)); MOCK_METHOD2(validate, GLboolean(const gl::Caps &, gl::InfoLog *)); MOCK_METHOD3(setUniform1fv, void(GLint, GLsizei, const GLfloat *)); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/Renderer.cpp b/chromium/third_party/angle/src/libANGLE/renderer/Renderer.cpp deleted file mode 100644 index f3f7f55bb97..00000000000 --- a/chromium/third_party/angle/src/libANGLE/renderer/Renderer.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances. - -#include "common/utilities.h" -#include "libANGLE/AttributeMap.h" -#include "libANGLE/renderer/Renderer.h" - -#include <EGL/eglext.h> - -namespace rx -{ -Renderer::Renderer() : mCapsInitialized(false) -{ -} - -Renderer::~Renderer() -{ -} - -void Renderer::ensureCapsInitialized() const -{ - if (!mCapsInitialized) - { - generateCaps(&mCaps, &mTextureCaps, &mExtensions, &mLimitations); - mCapsInitialized = true; - } -} - -const gl::Caps &Renderer::getRendererCaps() const -{ - ensureCapsInitialized(); - - return mCaps; -} - -const gl::TextureCapsMap &Renderer::getRendererTextureCaps() const -{ - ensureCapsInitialized(); - - return mTextureCaps; -} - -const gl::Extensions &Renderer::getRendererExtensions() const -{ - ensureCapsInitialized(); - - return mExtensions; -} - -const gl::Limitations &Renderer::getRendererLimitations() const -{ - ensureCapsInitialized(); - - return mLimitations; -} - -} diff --git a/chromium/third_party/angle/src/libANGLE/renderer/Renderer.h b/chromium/third_party/angle/src/libANGLE/renderer/Renderer.h deleted file mode 100644 index d0da2b140c4..00000000000 --- a/chromium/third_party/angle/src/libANGLE/renderer/Renderer.h +++ /dev/null @@ -1,121 +0,0 @@ -// -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// Renderer.h: Defines a back-end specific class that hides the details of the -// implementation-specific renderer. - -#ifndef LIBANGLE_RENDERER_RENDERER_H_ -#define LIBANGLE_RENDERER_RENDERER_H_ - -#include "libANGLE/Caps.h" -#include "libANGLE/Error.h" -#include "libANGLE/Framebuffer.h" -#include "libANGLE/State.h" -#include "libANGLE/Uniform.h" -#include "libANGLE/angletypes.h" -#include "libANGLE/renderer/ImplFactory.h" -#include "common/mathutil.h" - -#include <stdint.h> - -#include <EGL/egl.h> - -namespace egl -{ -class AttributeMap; -class Display; -class Surface; -} - -namespace rx -{ -struct TranslatedIndexData; -struct SourceIndexData; -struct WorkaroundsD3D; -class DisplayImpl; - -class Renderer : public ImplFactory -{ - public: - Renderer(); - virtual ~Renderer(); - - virtual gl::Error flush() = 0; - virtual gl::Error finish() = 0; - - virtual gl::Error drawArrays(const gl::Data &data, GLenum mode, GLint first, GLsizei count) = 0; - virtual gl::Error drawArraysInstanced(const gl::Data &data, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instanceCount) = 0; - - virtual gl::Error drawElements(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) = 0; - virtual gl::Error drawElementsInstanced(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange) = 0; - virtual gl::Error drawRangeElements(const gl::Data &data, - GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) = 0; - - // lost device - //TODO(jmadill): investigate if this stuff is necessary in GL - virtual void notifyDeviceLost() = 0; - virtual bool isDeviceLost() const = 0; - virtual bool testDeviceLost() = 0; - virtual bool testDeviceResettable() = 0; - - virtual std::string getVendorString() const = 0; - virtual std::string getRendererDescription() const = 0; - - virtual void insertEventMarker(GLsizei length, const char *marker) = 0; - virtual void pushGroupMarker(GLsizei length, const char *marker) = 0; - virtual void popGroupMarker() = 0; - - virtual void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) = 0; - - // Disjoint timer queries - virtual GLint getGPUDisjoint() = 0; - virtual GLint64 getTimestamp() = 0; - - // Context switching - virtual void onMakeCurrent(const gl::Data &data) = 0; - - // Renderer capabilities - const gl::Caps &getRendererCaps() const; - const gl::TextureCapsMap &getRendererTextureCaps() const; - const gl::Extensions &getRendererExtensions() const; - const gl::Limitations &getRendererLimitations() const; - - private: - void ensureCapsInitialized() const; - virtual void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, - gl::Extensions *outExtensions, - gl::Limitations *outLimitations) const = 0; - - mutable bool mCapsInitialized; - mutable gl::Caps mCaps; - mutable gl::TextureCapsMap mTextureCaps; - mutable gl::Extensions mExtensions; - mutable gl::Limitations mLimitations; -}; - -} -#endif // LIBANGLE_RENDERER_RENDERER_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/ShaderImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/ShaderImpl.h index 5a466377a53..2ade19a06b1 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/ShaderImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/ShaderImpl.h @@ -18,7 +18,7 @@ namespace rx class ShaderImpl : angle::NonCopyable { public: - ShaderImpl(const gl::Shader::Data &data) : mData(data) {} + ShaderImpl(const gl::ShaderState &data) : mData(data) {} virtual ~ShaderImpl() { } // Returns additional ShCompile options. @@ -29,10 +29,10 @@ class ShaderImpl : angle::NonCopyable virtual std::string getDebugInfo() const = 0; - const gl::Shader::Data &getData() const { return mData; } + const gl::ShaderState &getData() const { return mData; } protected: - const gl::Shader::Data &mData; + const gl::ShaderState &mData; }; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/StreamImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/StreamImpl.h deleted file mode 100644 index cf0b8169ed0..00000000000 --- a/chromium/third_party/angle/src/libANGLE/renderer/StreamImpl.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// StreamImpl.h: Defines the abstract rx::StreamImpl class. - -#ifndef LIBANGLE_RENDERER_STREAMIMPL_H_ -#define LIBANGLE_RENDERER_STREAMIMPL_H_ - -#include "common/angleutils.h" - -namespace rx -{ - -class StreamImpl : angle::NonCopyable -{ - public: - explicit StreamImpl() {} - virtual ~StreamImpl() {} -}; -} // namespace rx - -#endif // LIBANGLE_RENDERER_STREAMIMPL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/StreamProducerImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/StreamProducerImpl.h new file mode 100644 index 00000000000..1915bf75d3e --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/StreamProducerImpl.h @@ -0,0 +1,39 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// StreamProducerImpl.h: Defines the abstract rx::StreamProducerImpl class. + +#ifndef LIBANGLE_RENDERER_STREAMPRODUCERIMPL_H_ +#define LIBANGLE_RENDERER_STREAMPRODUCERIMPL_H_ + +#include "common/angleutils.h" +#include "libANGLE/Stream.h" + +namespace rx +{ + +class StreamProducerImpl : angle::NonCopyable +{ + public: + explicit StreamProducerImpl() {} + virtual ~StreamProducerImpl() {} + + // Validates the ability for the producer to accept an arbitrary pointer to a frame. All + // pointers should be validated through this function before being used to produce a frame. + virtual egl::Error validateD3DNV12Texture(void *pointer) const = 0; + + // Constructs a frame from an arbitrary external pointer that points to producer specific frame + // data. Replaces the internal frame with the new one. + virtual void postD3DNV12Texture(void *pointer, const egl::AttributeMap &attributes) = 0; + + // Returns an OpenGL texture interpretation of some frame attributes for the purpose of + // constructing an OpenGL texture from a frame. Depending on the producer and consumer, some + // frames may have multiple "planes" with different OpenGL texture representations. + virtual egl::Stream::GLTextureDescription getGLFrameDescription(int planeIndex) = 0; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_STREAMPRODUCERIMPL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.cpp b/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.cpp index 36f5fdca3fe..586ee1d00a1 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.cpp @@ -19,4 +19,4 @@ SurfaceImpl::~SurfaceImpl() { } -} +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.h index 32125d542c4..f12b5e6f45b 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/SurfaceImpl.h @@ -11,9 +11,13 @@ #include "common/angleutils.h" #include "libANGLE/Error.h" -#include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" +namespace gl +{ +class FramebufferState; +} + namespace egl { class Display; @@ -22,7 +26,6 @@ struct Config; namespace rx { - class FramebufferImpl; class SurfaceImpl : public FramebufferAttachmentObjectImpl @@ -32,7 +35,7 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl virtual ~SurfaceImpl(); virtual egl::Error initialize() = 0; - virtual FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) = 0; + virtual FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) = 0; virtual egl::Error swap() = 0; virtual egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) = 0; virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl.h index ad4ec8d830b..5f1ba3131d3 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl.h @@ -16,6 +16,7 @@ #include "libANGLE/Error.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/ImageIndex.h" +#include "libANGLE/Stream.h" namespace egl { @@ -40,7 +41,7 @@ namespace rx class TextureImpl : public FramebufferAttachmentObjectImpl { public: - TextureImpl() {} + TextureImpl(const gl::TextureState &state) : mState(state) {} virtual ~TextureImpl() {} virtual void setUsage(GLenum usage) = 0; @@ -64,10 +65,19 @@ class TextureImpl : public FramebufferAttachmentObjectImpl virtual gl::Error setEGLImageTarget(GLenum target, egl::Image *image) = 0; - virtual gl::Error generateMipmaps(const gl::TextureState &textureState) = 0; + virtual gl::Error setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) = 0; + + virtual gl::Error generateMipmaps() = 0; + + virtual void setBaseLevel(GLuint baseLevel) = 0; virtual void bindTexImage(egl::Surface *surface) = 0; virtual void releaseTexImage() = 0; + + protected: + const gl::TextureState &mState; }; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl_mock.h b/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl_mock.h index 3eb43f00337..a114d5df9c3 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl_mock.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/TextureImpl_mock.h @@ -19,6 +19,7 @@ namespace rx class MockTextureImpl : public TextureImpl { public: + MockTextureImpl() : TextureImpl(gl::TextureState(GL_TEXTURE_2D)) {} virtual ~MockTextureImpl() { destructor(); } MOCK_METHOD1(setUsage, void(GLenum)); MOCK_METHOD8(setImage, gl::Error(GLenum, size_t, GLenum, const gl::Extents &, GLenum, GLenum, const gl::PixelUnpackState &, const uint8_t *)); @@ -28,13 +29,17 @@ class MockTextureImpl : public TextureImpl MOCK_METHOD5(copyImage, gl::Error(GLenum, size_t, const gl::Rectangle &, GLenum, const gl::Framebuffer *)); MOCK_METHOD5(copySubImage, gl::Error(GLenum, size_t, const gl::Offset &, const gl::Rectangle &, const gl::Framebuffer *)); MOCK_METHOD4(setStorage, gl::Error(GLenum, size_t, GLenum, const gl::Extents &)); + MOCK_METHOD3(setImageExternal, + gl::Error(GLenum, egl::Stream *, const egl::Stream::GLTextureDescription &)); MOCK_METHOD2(setEGLImageTarget, gl::Error(GLenum, egl::Image *)); - MOCK_METHOD1(generateMipmaps, gl::Error(const gl::TextureState &)); + MOCK_METHOD0(generateMipmaps, gl::Error()); MOCK_METHOD1(bindTexImage, void(egl::Surface *)); MOCK_METHOD0(releaseTexImage, void(void)); MOCK_METHOD2(getAttachmentRenderTarget, gl::Error(const gl::FramebufferAttachment::Target &, FramebufferAttachmentRenderTarget **)); + MOCK_METHOD1(setBaseLevel, void(GLuint)); + MOCK_METHOD0(destructor, void()); }; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/VertexArrayImpl.h b/chromium/third_party/angle/src/libANGLE/renderer/VertexArrayImpl.h index 13617c7ecb5..b1be3691ade 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/VertexArrayImpl.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/VertexArrayImpl.h @@ -19,11 +19,11 @@ namespace rx class VertexArrayImpl : angle::NonCopyable { public: - VertexArrayImpl(const gl::VertexArray::Data &data) : mData(data) { } + VertexArrayImpl(const gl::VertexArrayState &data) : mData(data) {} virtual ~VertexArrayImpl() { } virtual void syncState(const gl::VertexArray::DirtyBits &dirtyBits) {} protected: - const gl::VertexArray::Data &mData; + const gl::VertexArrayState &mData; }; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp index 3b9debe8bcb..1f66e10839b 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp @@ -168,33 +168,14 @@ SurfaceImpl *DisplayD3D::createWindowSurface(const egl::Config *configuration, const egl::AttributeMap &attribs) { ASSERT(mRenderer != nullptr); - - EGLint width = static_cast<EGLint>(attribs.get(EGL_WIDTH, 0)); - EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0)); - EGLint fixedSize = static_cast<EGLint>(attribs.get(EGL_FIXED_SIZE_ANGLE, EGL_FALSE)); - EGLint orientation = static_cast<EGLint>(attribs.get(EGL_SURFACE_ORIENTATION_ANGLE, 0)); - EGLint directComposition = - static_cast<EGLint>(attribs.get(EGL_DIRECT_COMPOSITION_ANGLE, EGL_FALSE)); - - if (!fixedSize) - { - width = -1; - height = -1; - } - - return SurfaceD3D::createFromWindow(mRenderer, mDisplay, configuration, window, fixedSize, - directComposition, width, height, orientation); + return SurfaceD3D::createFromWindow(mRenderer, mDisplay, configuration, window, attribs); } SurfaceImpl *DisplayD3D::createPbufferSurface(const egl::Config *configuration, const egl::AttributeMap &attribs) { ASSERT(mRenderer != nullptr); - - EGLint width = static_cast<EGLint>(attribs.get(EGL_WIDTH, 0)); - EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0)); - - return SurfaceD3D::createOffscreen(mRenderer, mDisplay, configuration, nullptr, width, height); + return SurfaceD3D::createOffscreen(mRenderer, mDisplay, configuration, nullptr, attribs); } SurfaceImpl *DisplayD3D::createPbufferFromClientBuffer(const egl::Config *configuration, @@ -202,12 +183,7 @@ SurfaceImpl *DisplayD3D::createPbufferFromClientBuffer(const egl::Config *config const egl::AttributeMap &attribs) { ASSERT(mRenderer != nullptr); - - EGLint width = static_cast<EGLint>(attribs.get(EGL_WIDTH, 0)); - EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0)); - - return SurfaceD3D::createOffscreen( - mRenderer, mDisplay, configuration, shareHandle, width, height); + return SurfaceD3D::createOffscreen(mRenderer, mDisplay, configuration, shareHandle, attribs); } SurfaceImpl *DisplayD3D::createPixmapSurface(const egl::Config *configuration, @@ -230,18 +206,18 @@ egl::Error DisplayD3D::getDevice(DeviceImpl **device) return mRenderer->getEGLDevice(device); } -gl::Context *DisplayD3D::createContext(const egl::Config *config, - const gl::Context *shareContext, - const egl::AttributeMap &attribs) +ContextImpl *DisplayD3D::createContext(const gl::ContextState &state) { ASSERT(mRenderer != nullptr); - return new gl::Context(config, shareContext, mRenderer, attribs); + return mRenderer->createContext(state); } -StreamImpl *DisplayD3D::createStream(const egl::AttributeMap &attribs) +StreamProducerImpl *DisplayD3D::createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) { ASSERT(mRenderer != nullptr); - return mRenderer->createStream(attribs); + return mRenderer->createStreamProducerD3DTextureNV12(consumerType, attribs); } egl::Error DisplayD3D::makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) @@ -253,12 +229,7 @@ egl::Error DisplayD3D::initialize(egl::Display *display) { ASSERT(mRenderer == nullptr && display != nullptr); mDisplay = display; - egl::Error error = CreateRendererD3D(display, &mRenderer); - if (error.isError()) - { - return error; - } - + ANGLE_TRY(CreateRendererD3D(display, &mRenderer)); return egl::Error(EGL_SUCCESS); } @@ -320,7 +291,7 @@ egl::Error DisplayD3D::restoreLostDevice() bool DisplayD3D::isValidNativeWindow(EGLNativeWindowType window) const { - return NativeWindow::isValidNativeWindow(window); + return mRenderer->isValidNativeWindow(window); } void DisplayD3D::generateExtensions(egl::DisplayExtensions *outExtensions) const @@ -344,7 +315,7 @@ void DisplayD3D::generateCaps(egl::Caps *outCaps) const // Display must be initialized to generate caps ASSERT(mRenderer != nullptr); - outCaps->textureNPOT = mRenderer->getRendererExtensions().textureNPOT; + outCaps->textureNPOT = mRenderer->getNativeExtensions().textureNPOT; } egl::Error DisplayD3D::waitClient() const @@ -360,4 +331,4 @@ egl::Error DisplayD3D::waitNative(EGLint engine, // Unimplemented as it is a noop on D3D return egl::Error(EGL_SUCCESS); } -} +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.h index c54eac58b07..8379814e364 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DisplayD3D.h @@ -41,11 +41,11 @@ class DisplayD3D : public DisplayImpl egl::ImageSibling *buffer, const egl::AttributeMap &attribs) override; - gl::Context *createContext(const egl::Config *config, - const gl::Context *shareContext, - const egl::AttributeMap &attribs) override; + ContextImpl *createContext(const gl::ContextState &state) override; - StreamImpl *createStream(const egl::AttributeMap &attribs) override; + StreamProducerImpl *createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) override; egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp index acb2744b5e1..1cb2e335edc 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp @@ -395,15 +395,15 @@ void DynamicHLSL::generateVaryingLinkHLSL(ShaderType shaderType, linkStream << " float gl_PointSize : " << builtins.glPointSize.str() << ";\n"; } - // Do this after glPointSize, to potentially combine gl_PointCoord and gl_PointSize into the + // Do this after gl_PointSize, to potentially combine gl_PointCoord and gl_PointSize into the // same register. generateVaryingHLSL(varyingPacking, linkStream); linkStream << "};\n"; } -bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, - const gl::Program::Data &programData, +bool DynamicHLSL::generateShaderLinkHLSL(const gl::ContextState &data, + const gl::ProgramState &programData, const ProgramD3DMetadata &programMetadata, const VaryingPacking &varyingPacking, std::string *pixelHLSL, @@ -412,7 +412,6 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, ASSERT(pixelHLSL->empty() && vertexHLSL->empty()); const gl::Shader *vertexShaderGL = programData.getAttachedVertexShader(); - const ShaderD3D *vertexShader = GetImplAs<ShaderD3D>(vertexShaderGL); const gl::Shader *fragmentShaderGL = programData.getAttachedFragmentShader(); const ShaderD3D *fragmentShader = GetImplAs<ShaderD3D>(fragmentShaderGL); const int shaderModel = mRenderer->getMajorShaderModel(); @@ -451,12 +450,6 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, << "{\n" << " initAttributes(input);\n"; - if (vertexShader->usesDeferredInit()) - { - vertexStream << "\n" - << " initializeDeferredGlobals();\n"; - } - vertexStream << "\n" << " gl_main();\n" << "\n" @@ -771,12 +764,6 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, pixelStream << ";\n"; } - if (fragmentShader->usesDeferredInit()) - { - pixelStream << "\n" - << " initializeDeferredGlobals();\n"; - } - pixelStream << "\n" << " gl_main();\n" << "\n" @@ -838,8 +825,8 @@ std::string DynamicHLSL::generateGeometryShaderPreamble(const VaryingPacking &va } std::string DynamicHLSL::generateGeometryShaderHLSL(gl::PrimitiveType primitiveType, - const gl::Data &data, - const gl::Program::Data &programData, + const gl::ContextState &data, + const gl::ProgramState &programData, const bool useViewScale, const std::string &preambleString) const { @@ -1042,8 +1029,8 @@ std::string DynamicHLSL::generateAttributeConversionHLSL( return attribString; } -void DynamicHLSL::getPixelShaderOutputKey(const gl::Data &data, - const gl::Program::Data &programData, +void DynamicHLSL::getPixelShaderOutputKey(const gl::ContextState &data, + const gl::ProgramState &programData, const ProgramD3DMetadata &metadata, std::vector<PixelShaderOutputVariable> *outPixelShaderKey) { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.h index 69d941c06a0..98e6384e2d1 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/DynamicHLSL.h @@ -30,7 +30,6 @@ namespace gl class InfoLog; struct VariableLocation; struct VertexAttribute; -struct Data; } namespace rx @@ -62,8 +61,8 @@ class DynamicHLSL : angle::NonCopyable const std::vector<PixelShaderOutputVariable> &outputVariables, bool usesFragDepth, const std::vector<GLenum> &outputLayout) const; - bool generateShaderLinkHLSL(const gl::Data &data, - const gl::Program::Data &programData, + bool generateShaderLinkHLSL(const gl::ContextState &data, + const gl::ProgramState &programData, const ProgramD3DMetadata &programMetadata, const VaryingPacking &varyingPacking, std::string *pixelHLSL, @@ -72,13 +71,13 @@ class DynamicHLSL : angle::NonCopyable std::string generateGeometryShaderPreamble(const VaryingPacking &varyingPacking) const; std::string generateGeometryShaderHLSL(gl::PrimitiveType primitiveType, - const gl::Data &data, - const gl::Program::Data &programData, + const gl::ContextState &data, + const gl::ProgramState &programData, const bool useViewScale, const std::string &preambleString) const; - void getPixelShaderOutputKey(const gl::Data &data, - const gl::Program::Data &programData, + void getPixelShaderOutputKey(const gl::ContextState &data, + const gl::ProgramState &programData, const ProgramD3DMetadata &metadata, std::vector<PixelShaderOutputVariable> *outPixelShaderKey); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp index 82967aced0f..f038a59de8a 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp @@ -13,6 +13,7 @@ #include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/Surface.h" +#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RenderbufferD3D.h" #include "libANGLE/renderer/d3d/RenderTargetD3D.h" @@ -85,7 +86,7 @@ ClearParameters GetClearParameters(const gl::State &state, GLbitfield mask) } -FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer) +FramebufferD3D::FramebufferD3D(const gl::FramebufferState &data, RendererD3D *renderer) : FramebufferImpl(data), mRenderer(renderer) { } @@ -94,20 +95,19 @@ FramebufferD3D::~FramebufferD3D() { } -gl::Error FramebufferD3D::clear(const gl::Data &data, GLbitfield mask) +gl::Error FramebufferD3D::clear(ContextImpl *context, GLbitfield mask) { - const gl::State &state = *data.state; - ClearParameters clearParams = GetClearParameters(state, mask); - return clear(data, clearParams); + ClearParameters clearParams = GetClearParameters(context->getState(), mask); + return clearImpl(context, clearParams); } -gl::Error FramebufferD3D::clearBufferfv(const gl::Data &data, +gl::Error FramebufferD3D::clearBufferfv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLfloat *values) { // glClearBufferfv can be called to clear the color buffer or depth buffer - ClearParameters clearParams = GetClearParameters(*data.state, 0); + ClearParameters clearParams = GetClearParameters(context->getState(), 0); if (buffer == GL_COLOR) { @@ -125,16 +125,16 @@ gl::Error FramebufferD3D::clearBufferfv(const gl::Data &data, clearParams.depthClearValue = values[0]; } - return clear(data, clearParams); + return clearImpl(context, clearParams); } -gl::Error FramebufferD3D::clearBufferuiv(const gl::Data &data, +gl::Error FramebufferD3D::clearBufferuiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLuint *values) { // glClearBufferuiv can only be called to clear a color buffer - ClearParameters clearParams = GetClearParameters(*data.state, 0); + ClearParameters clearParams = GetClearParameters(context->getState(), 0); for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++) { clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i)); @@ -142,16 +142,16 @@ gl::Error FramebufferD3D::clearBufferuiv(const gl::Data &data, clearParams.colorUIClearValue = gl::ColorUI(values[0], values[1], values[2], values[3]); clearParams.colorClearType = GL_UNSIGNED_INT; - return clear(data, clearParams); + return clearImpl(context, clearParams); } -gl::Error FramebufferD3D::clearBufferiv(const gl::Data &data, +gl::Error FramebufferD3D::clearBufferiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLint *values) { // glClearBufferiv can be called to clear the color buffer or stencil buffer - ClearParameters clearParams = GetClearParameters(*data.state, 0); + ClearParameters clearParams = GetClearParameters(context->getState(), 0); if (buffer == GL_COLOR) { @@ -169,28 +169,28 @@ gl::Error FramebufferD3D::clearBufferiv(const gl::Data &data, clearParams.stencilClearValue = values[1]; } - return clear(data, clearParams); + return clearImpl(context, clearParams); } -gl::Error FramebufferD3D::clearBufferfi(const gl::Data &data, +gl::Error FramebufferD3D::clearBufferfi(ContextImpl *context, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) { // glClearBufferfi can only be called to clear a depth stencil buffer - ClearParameters clearParams = GetClearParameters(*data.state, 0); + ClearParameters clearParams = GetClearParameters(context->getState(), 0); clearParams.clearDepth = true; clearParams.depthClearValue = depth; clearParams.clearStencil = true; clearParams.stencilClearValue = stencil; - return clear(data, clearParams); + return clearImpl(context, clearParams); } GLenum FramebufferD3D::getImplementationColorReadFormat() const { - const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment(); + const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment(); if (readAttachment == nullptr) { @@ -212,7 +212,7 @@ GLenum FramebufferD3D::getImplementationColorReadFormat() const GLenum FramebufferD3D::getImplementationColorReadType() const { - const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment(); + const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment(); if (readAttachment == nullptr) { @@ -232,9 +232,13 @@ GLenum FramebufferD3D::getImplementationColorReadType() const return implementationFormatInfo.type; } -gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const +gl::Error FramebufferD3D::readPixels(ContextImpl *context, + const gl::Rectangle &area, + GLenum format, + GLenum type, + GLvoid *pixels) const { - const gl::PixelPackState &packState = state.getPackState(); + const gl::PixelPackState &packState = context->getState().getPackState(); GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type); const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); @@ -247,38 +251,41 @@ gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes); } -gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, - GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) +gl::Error FramebufferD3D::blit(ContextImpl *context, + const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + GLbitfield mask, + GLenum filter) { + const auto &glState = context->getState(); + const gl::Framebuffer *sourceFramebuffer = glState.getReadFramebuffer(); bool blitRenderTarget = false; - if ((mask & GL_COLOR_BUFFER_BIT) && - sourceFramebuffer->getReadColorbuffer() != nullptr && - mData.getFirstColorAttachment() != nullptr) + if ((mask & GL_COLOR_BUFFER_BIT) && sourceFramebuffer->getReadColorbuffer() != nullptr && + mState.getFirstColorAttachment() != nullptr) { blitRenderTarget = true; } bool blitStencil = false; - if ((mask & GL_STENCIL_BUFFER_BIT) && - sourceFramebuffer->getStencilbuffer() != nullptr && - mData.getStencilAttachment() != nullptr) + if ((mask & GL_STENCIL_BUFFER_BIT) && sourceFramebuffer->getStencilbuffer() != nullptr && + mState.getStencilAttachment() != nullptr) { blitStencil = true; } bool blitDepth = false; - if ((mask & GL_DEPTH_BUFFER_BIT) && - sourceFramebuffer->getDepthbuffer() != nullptr && - mData.getDepthAttachment() != nullptr) + if ((mask & GL_DEPTH_BUFFER_BIT) && sourceFramebuffer->getDepthbuffer() != nullptr && + mState.getDepthAttachment() != nullptr) { blitDepth = true; } if (blitRenderTarget || blitDepth || blitStencil) { - const gl::Rectangle *scissor = state.isScissorTestEnabled() ? &state.getScissor() : NULL; - gl::Error error = blit(sourceArea, destArea, scissor, blitRenderTarget, blitDepth, blitStencil, - filter, sourceFramebuffer); + const gl::Rectangle *scissor = + glState.isScissorTestEnabled() ? &glState.getScissor() : nullptr; + gl::Error error = blitImpl(sourceArea, destArea, scissor, blitRenderTarget, blitDepth, + blitStencil, filter, sourceFramebuffer); if (error.isError()) { return error; @@ -292,14 +299,14 @@ bool FramebufferD3D::checkStatus() const { // if we have both a depth and stencil buffer, they must refer to the same object // since we only support packed_depth_stencil and not separate depth and stencil - if (mData.getDepthAttachment() != nullptr && mData.getStencilAttachment() != nullptr && - mData.getDepthStencilAttachment() == nullptr) + if (mState.getDepthAttachment() != nullptr && mState.getStencilAttachment() != nullptr && + mState.getDepthStencilAttachment() == nullptr) { return false; } // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness - const auto &colorAttachments = mData.getColorAttachments(); + const auto &colorAttachments = mState.getColorAttachments(); for (size_t colorAttachment = 0; colorAttachment < colorAttachments.size(); colorAttachment++) { const gl::FramebufferAttachment &attachment = colorAttachments[colorAttachment]; @@ -319,7 +326,7 @@ bool FramebufferD3D::checkStatus() const } // D3D requires all render targets to have the same dimensions. - if (!mData.attachmentsHaveSameDimensions()) + if (!mState.attachmentsHaveSameDimensions()) { return false; } @@ -354,8 +361,8 @@ void FramebufferD3D::syncState(const gl::Framebuffer::DirtyBits &dirtyBits) // Does not actually free memory gl::AttachmentList colorAttachmentsForRender; - const auto &colorAttachments = mData.getColorAttachments(); - const auto &drawBufferStates = mData.getDrawBufferStates(); + const auto &colorAttachments = mState.getColorAttachments(); + const auto &drawBufferStates = mState.getDrawBufferStates(); const auto &workarounds = mRenderer->getWorkarounds(); for (size_t attachmentIndex = 0; attachmentIndex < colorAttachments.size(); ++attachmentIndex) diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.h index eb839c4364c..b2524d537b2 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/FramebufferD3D.h @@ -57,23 +57,23 @@ struct ClearParameters class FramebufferD3D : public FramebufferImpl { public: - FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer); + FramebufferD3D(const gl::FramebufferState &data, RendererD3D *renderer); virtual ~FramebufferD3D(); - gl::Error clear(const gl::Data &data, GLbitfield mask) override; - gl::Error clearBufferfv(const gl::Data &data, + gl::Error clear(ContextImpl *impl, GLbitfield mask) override; + gl::Error clearBufferfv(ContextImpl *impl, GLenum buffer, GLint drawbuffer, const GLfloat *values) override; - gl::Error clearBufferuiv(const gl::Data &data, + gl::Error clearBufferuiv(ContextImpl *impl, GLenum buffer, GLint drawbuffer, const GLuint *values) override; - gl::Error clearBufferiv(const gl::Data &data, + gl::Error clearBufferiv(ContextImpl *impl, GLenum buffer, GLint drawbuffer, const GLint *values) override; - gl::Error clearBufferfi(const gl::Data &data, + gl::Error clearBufferfi(ContextImpl *impl, GLenum buffer, GLint drawbuffer, GLfloat depth, @@ -81,10 +81,17 @@ class FramebufferD3D : public FramebufferImpl GLenum getImplementationColorReadFormat() const override; GLenum getImplementationColorReadType() const override; - gl::Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const override; - - gl::Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, - GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) override; + gl::Error readPixels(ContextImpl *impl, + const gl::Rectangle &area, + GLenum format, + GLenum type, + GLvoid *pixels) const override; + + gl::Error blit(ContextImpl *impl, + const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + GLbitfield mask, + GLenum filter) override; bool checkStatus() const override; @@ -93,7 +100,7 @@ class FramebufferD3D : public FramebufferImpl const gl::AttachmentList &getColorAttachmentsForRender() const; private: - virtual gl::Error clear(const gl::Data &data, const ClearParameters &clearParams) = 0; + virtual gl::Error clearImpl(ContextImpl *impl, const ClearParameters &clearParams) = 0; virtual gl::Error readPixelsImpl(const gl::Rectangle &area, GLenum format, @@ -102,9 +109,14 @@ class FramebufferD3D : public FramebufferImpl const gl::PixelPackState &pack, uint8_t *pixels) const = 0; - virtual gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, - bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, - const gl::Framebuffer *sourceFramebuffer) = 0; + virtual gl::Error blitImpl(const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + const gl::Rectangle *scissor, + bool blitRenderTarget, + bool blitDepth, + bool blitStencil, + GLenum filter, + const gl::Framebuffer *sourceFramebuffer) = 0; virtual GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const = 0; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/NativeWindowD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/NativeWindowD3D.cpp new file mode 100644 index 00000000000..113bad647c7 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/NativeWindowD3D.cpp @@ -0,0 +1,23 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindowD3D.cpp: Defines NativeWindowD3D, a class for managing and performing operations on +// an EGLNativeWindowType for the D3D renderers. + +#include "libANGLE/renderer/d3d/NativeWindowD3D.h" + +namespace rx +{ + +NativeWindowD3D::NativeWindowD3D(EGLNativeWindowType window) : mWindow(window) +{ +} + +NativeWindowD3D::~NativeWindowD3D() +{ +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/NativeWindowD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/NativeWindowD3D.h new file mode 100644 index 00000000000..365448488d5 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/NativeWindowD3D.h @@ -0,0 +1,38 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindowD3D.h: Defines NativeWindowD3D, a class for managing and performing operations on an +// EGLNativeWindowType for the D3D renderers. + +#ifndef LIBANGLE_RENDERER_D3D_NATIVEWINDOWD3D_H_ +#define LIBANGLE_RENDERER_D3D_NATIVEWINDOWD3D_H_ + +#include "common/debug.h" +#include "common/platform.h" + +#include <EGL/eglplatform.h> +#include "libANGLE/Config.h" + +namespace rx +{ +class NativeWindowD3D : angle::NonCopyable +{ + public: + NativeWindowD3D(EGLNativeWindowType window); + virtual ~NativeWindowD3D(); + + virtual bool initialize() = 0; + virtual bool getClientRect(LPRECT rect) const = 0; + virtual bool isIconic() const = 0; + + inline EGLNativeWindowType getNativeWindow() const { return mWindow; } + + private: + EGLNativeWindowType mWindow; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_NATIVEWINDOWD3D_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp index b8514ff47c6..027f7b76e43 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp @@ -13,6 +13,7 @@ #include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/Program.h" +#include "libANGLE/Uniform.h" #include "libANGLE/VertexArray.h" #include "libANGLE/features.h" #include "libANGLE/renderer/d3d/DynamicHLSL.h" @@ -396,12 +397,12 @@ int ProgramD3DMetadata::getRendererMajorShaderModel() const return mRendererMajorShaderModel; } -bool ProgramD3DMetadata::usesBroadcast(const gl::Data &data) const +bool ProgramD3DMetadata::usesBroadcast(const gl::ContextState &data) const { return (mFragmentShader->usesFragColor() && data.clientVersion < 3); } -bool ProgramD3DMetadata::usesFragDepth(const gl::Program::Data &programData) const +bool ProgramD3DMetadata::usesFragDepth() const { return mFragmentShader->usesFragDepth(); } @@ -560,8 +561,8 @@ ProgramD3D::Sampler::Sampler() : active(false), logicalTextureUnit(0), textureTy unsigned int ProgramD3D::mCurrentSerial = 1; -ProgramD3D::ProgramD3D(const gl::Program::Data &data, RendererD3D *renderer) - : ProgramImpl(data), +ProgramD3D::ProgramD3D(const gl::ProgramState &state, RendererD3D *renderer) + : ProgramImpl(state), mRenderer(renderer), mDynamicHLSL(NULL), mGeometryExecutables(gl::PRIMITIVE_TYPE_MAX, nullptr), @@ -784,7 +785,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) return LinkResult(false, gl::Error(GL_NO_ERROR)); } - const auto &linkedUniforms = mData.getUniforms(); + const auto &linkedUniforms = mState.getUniforms(); ASSERT(mD3DUniforms.empty()); for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; uniformIndex++) { @@ -873,7 +874,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) gl::Error error = mRenderer->loadExecutable( vertexShaderFunction, vertexShaderSize, SHADER_VERTEX, mStreamOutVaryings, - (mData.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), &shaderExecutable); + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), &shaderExecutable); if (error.isError()) { return LinkResult(false, error); @@ -912,7 +913,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) gl::Error error = mRenderer->loadExecutable( pixelShaderFunction, pixelShaderSize, SHADER_PIXEL, mStreamOutVaryings, - (mData.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), &shaderExecutable); + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), &shaderExecutable); if (error.isError()) { return LinkResult(false, error); @@ -941,7 +942,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) } const unsigned char *geometryShaderFunction = binary + stream->offset(); - bool splitAttribs = (mData.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS); + bool splitAttribs = (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS); gl::Error error = mRenderer->loadExecutable( geometryShaderFunction, geometryShaderSize, SHADER_GEOMETRY, mStreamOutVaryings, @@ -1161,7 +1162,7 @@ gl::Error ProgramD3D::getPixelExecutableForOutputLayout(const std::vector<GLenum gl::Error error = mRenderer->compileToExecutable( *currentInfoLog, finalPixelHLSL, SHADER_PIXEL, mStreamOutVaryings, - (mData.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), mPixelWorkarounds, + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), mPixelWorkarounds, &pixelExecutable); if (error.isError()) { @@ -1200,7 +1201,7 @@ gl::Error ProgramD3D::getVertexExecutableForInputLayout(const gl::InputLayout &i // Generate new dynamic layout with attribute conversions std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout( - mVertexHLSL, inputLayout, mData.getAttributes()); + mVertexHLSL, inputLayout, mState.getAttributes()); // Generate new vertex executable ShaderExecutableD3D *vertexExecutable = NULL; @@ -1210,7 +1211,7 @@ gl::Error ProgramD3D::getVertexExecutableForInputLayout(const gl::InputLayout &i gl::Error error = mRenderer->compileToExecutable( *currentInfoLog, finalVertexHLSL, SHADER_VERTEX, mStreamOutVaryings, - (mData.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), mVertexWorkarounds, + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), mVertexWorkarounds, &vertexExecutable); if (error.isError()) { @@ -1233,7 +1234,7 @@ gl::Error ProgramD3D::getVertexExecutableForInputLayout(const gl::InputLayout &i return gl::Error(GL_NO_ERROR); } -gl::Error ProgramD3D::getGeometryExecutableForPrimitiveType(const gl::Data &data, +gl::Error ProgramD3D::getGeometryExecutableForPrimitiveType(const gl::ContextState &data, GLenum drawMode, ShaderExecutableD3D **outExecutable, gl::InfoLog *infoLog) @@ -1261,7 +1262,7 @@ gl::Error ProgramD3D::getGeometryExecutableForPrimitiveType(const gl::Data &data } std::string geometryHLSL = mDynamicHLSL->generateGeometryShaderHLSL( - geometryShaderType, data, mData, mRenderer->presentPathFastEnabled(), + geometryShaderType, data, mState, mRenderer->presentPathFastEnabled(), mGeometryShaderPreamble); gl::InfoLog tempInfoLog; @@ -1269,7 +1270,7 @@ gl::Error ProgramD3D::getGeometryExecutableForPrimitiveType(const gl::Data &data gl::Error error = mRenderer->compileToExecutable( *currentInfoLog, geometryHLSL, SHADER_GEOMETRY, mStreamOutVaryings, - (mData.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), D3DCompilerWorkarounds(), + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), D3DCompilerWorkarounds(), &mGeometryExecutables[geometryShaderType]); if (!infoLog && error.isError()) @@ -1286,10 +1287,10 @@ gl::Error ProgramD3D::getGeometryExecutableForPrimitiveType(const gl::Data &data return error; } -LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoLog &infoLog) +LinkResult ProgramD3D::compileProgramExecutables(const gl::ContextState &data, gl::InfoLog &infoLog) { const gl::InputLayout &defaultInputLayout = - GetDefaultInputLayoutFromShader(mData.getAttachedVertexShader()); + GetDefaultInputLayoutFromShader(mState.getAttachedVertexShader()); ShaderExecutableD3D *defaultVertexExecutable = NULL; gl::Error error = getVertexExecutableForInputLayout(defaultInputLayout, &defaultVertexExecutable, &infoLog); @@ -1314,7 +1315,7 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL getGeometryExecutableForPrimitiveType(data, GL_POINTS, &pointGS, &infoLog); } - const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader()); + const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mState.getAttachedVertexShader()); if (usesGeometryShader(GL_POINTS) && pointGS) { @@ -1334,7 +1335,7 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL if (defaultPixelExecutable) { const ShaderD3D *fragmentShaderD3D = - GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader()); + GetImplAs<ShaderD3D>(mState.getAttachedFragmentShader()); fragmentShaderD3D->appendDebugInfo(defaultPixelExecutable->getDebugInfo()); } @@ -1343,12 +1344,12 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL return LinkResult(linkSuccess, gl::Error(GL_NO_ERROR)); } -LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog) +LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) { reset(); - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); - const gl::Shader *fragmentShader = mData.getAttachedFragmentShader(); + const gl::Shader *vertexShader = mState.getAttachedVertexShader(); + const gl::Shader *fragmentShader = mState.getAttachedFragmentShader(); const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(vertexShader); const ShaderD3D *fragmentShaderD3D = GetImplAs<ShaderD3D>(fragmentShader); @@ -1359,7 +1360,7 @@ LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog) vertexShaderD3D->generateWorkarounds(&mVertexWorkarounds); fragmentShaderD3D->generateWorkarounds(&mPixelWorkarounds); - if (mRenderer->getRendererLimitations().noFrontFacingSupport) + if (mRenderer->getNativeLimitations().noFrontFacingSupport) { if (fragmentShaderD3D->usesFrontFacing()) { @@ -1369,12 +1370,12 @@ LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog) } std::vector<PackedVarying> packedVaryings = - MergeVaryings(*vertexShader, *fragmentShader, mData.getTransformFeedbackVaryingNames()); + MergeVaryings(*vertexShader, *fragmentShader, mState.getTransformFeedbackVaryingNames()); // Map the varyings to the register file VaryingPacking varyingPacking(data.caps->maxVaryingVectors); if (!varyingPacking.packVaryings(infoLog, packedVaryings, - mData.getTransformFeedbackVaryingNames())) + mState.getTransformFeedbackVaryingNames())) { return LinkResult(false, gl::Error(GL_NO_ERROR)); } @@ -1403,15 +1404,15 @@ LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog) return LinkResult(false, gl::Error(GL_NO_ERROR)); } - if (!mDynamicHLSL->generateShaderLinkHLSL(data, mData, metadata, varyingPacking, &mPixelHLSL, + if (!mDynamicHLSL->generateShaderLinkHLSL(data, mState, metadata, varyingPacking, &mPixelHLSL, &mVertexHLSL)) { return LinkResult(false, gl::Error(GL_NO_ERROR)); } mUsesPointSize = vertexShaderD3D->usesPointSize(); - mDynamicHLSL->getPixelShaderOutputKey(data, mData, metadata, &mPixelShaderKey); - mUsesFragDepth = metadata.usesFragDepth(mData); + mDynamicHLSL->getPixelShaderOutputKey(data, mState, metadata, &mPixelShaderKey); + mUsesFragDepth = metadata.usesFragDepth(); // Cache if we use flat shading mUsesFlatInterpolation = false; @@ -1456,7 +1457,7 @@ GLboolean ProgramD3D::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLo void ProgramD3D::initUniformBlockInfo() { - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); + const gl::Shader *vertexShader = mState.getAttachedVertexShader(); for (const sh::InterfaceBlock &vertexBlock : vertexShader->getInterfaceBlocks()) { @@ -1470,7 +1471,7 @@ void ProgramD3D::initUniformBlockInfo() mBlockDataSizes[vertexBlock.name] = dataSize; } - const gl::Shader *fragmentShader = mData.getAttachedFragmentShader(); + const gl::Shader *fragmentShader = mState.getAttachedFragmentShader(); for (const sh::InterfaceBlock &fragmentBlock : fragmentShader->getInterfaceBlocks()) { @@ -1490,10 +1491,10 @@ void ProgramD3D::assignUniformBlockRegisters() mD3DUniformBlocks.clear(); // Assign registers and update sizes. - const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader()); - const ShaderD3D *fragmentShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader()); + const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mState.getAttachedVertexShader()); + const ShaderD3D *fragmentShaderD3D = GetImplAs<ShaderD3D>(mState.getAttachedFragmentShader()); - for (const gl::UniformBlock &uniformBlock : mData.getUniformBlocks()) + for (const gl::UniformBlock &uniformBlock : mState.getUniformBlocks()) { unsigned int uniformBlockElement = uniformBlock.isArray ? uniformBlock.arrayElement : 0; @@ -1561,9 +1562,9 @@ gl::Error ProgramD3D::applyUniforms(GLenum drawMode) return gl::Error(GL_NO_ERROR); } -gl::Error ProgramD3D::applyUniformBuffers(const gl::Data &data) +gl::Error ProgramD3D::applyUniformBuffers(const gl::ContextState &data) { - if (mData.getUniformBlocks().empty()) + if (mState.getUniformBlocks().empty()) { return gl::Error(GL_NO_ERROR); } @@ -1584,7 +1585,7 @@ gl::Error ProgramD3D::applyUniformBuffers(const gl::Data &data) uniformBlockIndex++) { const D3DUniformBlock &uniformBlock = mD3DUniformBlocks[uniformBlockIndex]; - GLuint blockBinding = mData.getUniformBlockBinding(uniformBlockIndex); + GLuint blockBinding = mState.getUniformBlockBinding(uniformBlockIndex); // Unnecessary to apply an unreferenced standard or shared UBO if (!uniformBlock.vertexStaticUse() && !uniformBlock.fragmentStaticUse()) @@ -1772,7 +1773,7 @@ void ProgramD3D::setUniformBlockBinding(GLuint /*uniformBlockIndex*/, void ProgramD3D::defineUniformsAndAssignRegisters() { D3DUniformMap uniformMap; - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); + const gl::Shader *vertexShader = mState.getAttachedVertexShader(); for (const sh::Uniform &vertexUniform : vertexShader->getUniforms()) { @@ -1782,7 +1783,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters() } } - const gl::Shader *fragmentShader = mData.getAttachedFragmentShader(); + const gl::Shader *fragmentShader = mState.getAttachedFragmentShader(); for (const sh::Uniform &fragmentUniform : fragmentShader->getUniforms()) { if (fragmentUniform.staticUse) @@ -1792,7 +1793,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters() } // Initialize the D3DUniform list to mirror the indexing of the GL layer. - for (const gl::LinkedUniform &glUniform : mData.getUniforms()) + for (const gl::LinkedUniform &glUniform : mState.getUniforms()) { if (!glUniform.isInDefaultBlock()) continue; @@ -1936,7 +1937,7 @@ void ProgramD3D::setUniform(GLint location, GLsizei countIn, const T *v, GLenum D3DUniform *targetUniform = getD3DUniformFromLocation(location); unsigned int elementCount = targetUniform->elementCount(); - unsigned int arrayElement = mData.getUniformLocations()[location].element; + unsigned int arrayElement = mState.getUniformLocations()[location].element; unsigned int count = std::min(elementCount - arrayElement, static_cast<unsigned int>(countIn)); if (targetUniform->type == targetUniformType) @@ -2016,7 +2017,7 @@ void ProgramD3D::setUniformMatrixfv(GLint location, D3DUniform *targetUniform = getD3DUniformFromLocation(location); unsigned int elementCount = targetUniform->elementCount(); - unsigned int arrayElement = mData.getUniformLocations()[location].element; + unsigned int arrayElement = mState.getUniformLocations()[location].element; unsigned int count = std::min(elementCount - arrayElement, static_cast<unsigned int>(countIn)); const unsigned int targetMatrixStride = (4 * rows); @@ -2079,8 +2080,8 @@ void ProgramD3D::assignAllSamplerRegisters() void ProgramD3D::assignSamplerRegisters(D3DUniform *d3dUniform) { ASSERT(d3dUniform->isSampler()); - const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader()); - const ShaderD3D *fragmentShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader()); + const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mState.getAttachedVertexShader()); + const ShaderD3D *fragmentShaderD3D = GetImplAs<ShaderD3D>(mState.getAttachedFragmentShader()); ASSERT(vertexShaderD3D->hasUniform(d3dUniform) || fragmentShaderD3D->hasUniform(d3dUniform)); if (vertexShaderD3D->hasUniform(d3dUniform)) { @@ -2171,11 +2172,11 @@ unsigned int ProgramD3D::issueSerial() void ProgramD3D::initAttribLocationsToD3DSemantic() { - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); + const gl::Shader *vertexShader = mState.getAttachedVertexShader(); ASSERT(vertexShader != nullptr); // Init semantic index - for (const sh::Attribute &attribute : mData.getAttributes()) + for (const sh::Attribute &attribute : mState.getAttributes()) { int d3dSemantic = vertexShader->getSemanticIndex(attribute.name); int regCount = gl::VariableRegisterCount(attribute.type); @@ -2192,7 +2193,7 @@ void ProgramD3D::updateCachedInputLayout(const gl::State &state) mCachedInputLayout.clear(); const auto &vertexAttributes = state.getVertexArray()->getVertexAttributes(); - for (unsigned int locationIndex : angle::IterateBitSet(mData.getActiveAttribLocationsMask())) + for (unsigned int locationIndex : angle::IterateBitSet(mState.getActiveAttribLocationsMask())) { int d3dSemantic = mAttribLocationToD3DSemantic[locationIndex]; @@ -2219,7 +2220,7 @@ void ProgramD3D::gatherTransformFeedbackVaryings(const VaryingPacking &varyingPa // Gather the linked varyings that are used for transform feedback, they should all exist. mStreamOutVaryings.clear(); - const auto &tfVaryingNames = mData.getTransformFeedbackVaryingNames(); + const auto &tfVaryingNames = mState.getTransformFeedbackVaryingNames(); for (unsigned int outputSlot = 0; outputSlot < static_cast<unsigned int>(tfVaryingNames.size()); ++outputSlot) { @@ -2276,7 +2277,7 @@ void ProgramD3D::gatherTransformFeedbackVaryings(const VaryingPacking &varyingPa D3DUniform *ProgramD3D::getD3DUniformFromLocation(GLint location) { - return mD3DUniforms[mData.getUniformLocations()[location].index]; + return mD3DUniforms[mState.getUniformLocations()[location].index]; } bool ProgramD3D::getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.h index c83f701e610..18bc1eb2502 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ProgramD3D.h @@ -108,8 +108,8 @@ class ProgramD3DMetadata : angle::NonCopyable const ShaderD3D *fragmentShader); int getRendererMajorShaderModel() const; - bool usesBroadcast(const gl::Data &data) const; - bool usesFragDepth(const gl::Program::Data &programData) const; + bool usesBroadcast(const gl::ContextState &data) const; + bool usesFragDepth() const; bool usesPointCoord() const; bool usesFragCoord() const; bool usesPointSize() const; @@ -134,7 +134,7 @@ class ProgramD3DMetadata : angle::NonCopyable class ProgramD3D : public ProgramImpl { public: - ProgramD3D(const gl::Program::Data &data, RendererD3D *renderer); + ProgramD3D(const gl::ProgramState &data, RendererD3D *renderer); virtual ~ProgramD3D(); const std::vector<PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; } @@ -163,12 +163,12 @@ class ProgramD3D : public ProgramImpl gl::Error getVertexExecutableForInputLayout(const gl::InputLayout &inputLayout, ShaderExecutableD3D **outExectuable, gl::InfoLog *infoLog); - gl::Error getGeometryExecutableForPrimitiveType(const gl::Data &data, + gl::Error getGeometryExecutableForPrimitiveType(const gl::ContextState &data, GLenum drawMode, ShaderExecutableD3D **outExecutable, gl::InfoLog *infoLog); - LinkResult link(const gl::Data &data, gl::InfoLog &infoLog) override; + LinkResult link(const gl::ContextState &data, gl::InfoLog &infoLog) override; GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override; bool getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const override; @@ -177,7 +177,7 @@ class ProgramD3D : public ProgramImpl void initializeUniformStorage(); gl::Error applyUniforms(GLenum drawMode); - gl::Error applyUniformBuffers(const gl::Data &data); + gl::Error applyUniformBuffers(const gl::ContextState &data); void dirtyAllUniforms(); void setUniform1fv(GLint location, GLsizei count, const GLfloat *v); @@ -340,7 +340,7 @@ class ProgramD3D : public ProgramImpl const GLfloat *value, GLenum targetUniformType); - LinkResult compileProgramExecutables(const gl::Data &data, gl::InfoLog &infoLog); + LinkResult compileProgramExecutables(const gl::ContextState &data, gl::InfoLog &infoLog); void gatherTransformFeedbackVaryings(const VaryingPacking &varyings); D3DUniform *getD3DUniformByName(const std::string &name); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp index 991801a0917..9ad447fae19 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp @@ -48,7 +48,7 @@ gl::Error RenderbufferD3D::setStorageMultisample(size_t samples, GLenum internal // the specified storage. // Because ES 3.0 already knows the exact number of supported samples, it would already have been // validated and generated GL_INVALID_VALUE. - const gl::TextureCaps &formatCaps = mRenderer->getRendererTextureCaps().get(creationFormat); + const gl::TextureCaps &formatCaps = mRenderer->getNativeTextureCaps().get(creationFormat); if (samples > formatCaps.getMaxSamples()) { return gl::Error(GL_OUT_OF_MEMORY, "Renderbuffer format does not support %u samples, %u is the maximum.", diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.cpp index da86a49569f..b98fb470c79 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.cpp @@ -15,6 +15,7 @@ #include "libANGLE/formatutils.h" #include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" +#include "libANGLE/renderer/TextureImpl.h" #include "libANGLE/renderer/d3d/BufferD3D.h" #include "libANGLE/renderer/d3d/DeviceD3D.h" #include "libANGLE/renderer/d3d/DisplayD3D.h" @@ -42,6 +43,7 @@ RendererD3D::RendererD3D(egl::Display *display) mDeviceLost(false), mAnnotator(nullptr), mPresentPathFastEnabled(false), + mCapsInitialized(false), mScratchMemoryBufferResetCounter(0), mWorkaroundsInitialized(false), mDisjoint(false) @@ -69,147 +71,7 @@ void RendererD3D::cleanup() } } -SamplerImpl *RendererD3D::createSampler() -{ - return new SamplerD3D(); -} - -gl::Error RendererD3D::drawArrays(const gl::Data &data, GLenum mode, GLint first, GLsizei count) -{ - return genericDrawArrays(data, mode, first, count, 0); -} - -gl::Error RendererD3D::drawArraysInstanced(const gl::Data &data, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instanceCount) -{ - return genericDrawArrays(data, mode, first, count, instanceCount); -} - -gl::Error RendererD3D::drawElements(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) -{ - return genericDrawElements(data, mode, count, type, indices, 0, indexRange); -} - -gl::Error RendererD3D::drawElementsInstanced(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange) -{ - return genericDrawElements(data, mode, count, type, indices, instances, indexRange); -} - -gl::Error RendererD3D::drawRangeElements(const gl::Data &data, - GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) -{ - return genericDrawElements(data, mode, count, type, indices, 0, indexRange); -} - -gl::Error RendererD3D::genericDrawElements(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange) -{ - gl::Program *program = data.state->getProgram(); - ASSERT(program != nullptr); - ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); - bool usesPointSize = programD3D->usesPointSize(); - - programD3D->updateSamplerMapping(); - - ANGLE_TRY(generateSwizzles(data)); - - if (!applyPrimitiveType(mode, count, usesPointSize)) - { - return gl::NoError(); - } - - ANGLE_TRY(updateState(data, mode)); - - TranslatedIndexData indexInfo; - indexInfo.indexRange = indexRange; - - ANGLE_TRY(applyIndexBuffer(data, indices, count, mode, type, &indexInfo)); - - applyTransformFeedbackBuffers(*data.state); - // Transform feedback is not allowed for DrawElements, this error should have been caught at the API validation - // layer. - ASSERT(!data.state->isTransformFeedbackActiveUnpaused()); - - size_t vertexCount = indexInfo.indexRange.vertexCount(); - ANGLE_TRY(applyVertexBuffer(*data.state, mode, static_cast<GLsizei>(indexInfo.indexRange.start), - static_cast<GLsizei>(vertexCount), instances, &indexInfo)); - ANGLE_TRY(applyTextures(data)); - ANGLE_TRY(applyShaders(data, mode)); - ANGLE_TRY(programD3D->applyUniformBuffers(data)); - - if (!skipDraw(data, mode)) - { - ANGLE_TRY(drawElementsImpl(data, indexInfo, mode, count, type, indices, instances)); - } - - return gl::NoError(); -} - -gl::Error RendererD3D::genericDrawArrays(const gl::Data &data, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instances) -{ - gl::Program *program = data.state->getProgram(); - ASSERT(program != nullptr); - ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); - bool usesPointSize = programD3D->usesPointSize(); - - programD3D->updateSamplerMapping(); - - ANGLE_TRY(generateSwizzles(data)); - if (!applyPrimitiveType(mode, count, usesPointSize)) - { - return gl::NoError(); - } - - ANGLE_TRY(updateState(data, mode)); - ANGLE_TRY(applyTransformFeedbackBuffers(*data.state)); - ANGLE_TRY(applyVertexBuffer(*data.state, mode, first, count, instances, nullptr)); - ANGLE_TRY(applyTextures(data)); - ANGLE_TRY(applyShaders(data, mode)); - ANGLE_TRY(programD3D->applyUniformBuffers(data)); - - if (!skipDraw(data, mode)) - { - ANGLE_TRY(drawArraysImpl(data, mode, first, count, instances)); - - if (data.state->isTransformFeedbackActiveUnpaused()) - { - ANGLE_TRY(markTransformFeedbackUsage(data)); - } - } - - return gl::NoError(); -} - -gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType type) +gl::Error RendererD3D::generateSwizzles(const gl::ContextState &data, gl::SamplerType type) { ProgramD3D *programD3D = GetImplAs<ProgramD3D>(data.state->getProgram()); @@ -233,14 +95,14 @@ gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType ty return gl::NoError(); } -gl::Error RendererD3D::generateSwizzles(const gl::Data &data) +gl::Error RendererD3D::generateSwizzles(const gl::ContextState &data) { ANGLE_TRY(generateSwizzles(data, gl::SAMPLER_VERTEX)); ANGLE_TRY(generateSwizzles(data, gl::SAMPLER_PIXEL)); return gl::NoError(); } -unsigned int RendererD3D::GetBlendSampleMask(const gl::Data &data, int samples) +unsigned int RendererD3D::GetBlendSampleMask(const gl::ContextState &data, int samples) { unsigned int mask = 0; if (data.state->isSampleCoverageEnabled()) @@ -277,7 +139,7 @@ unsigned int RendererD3D::GetBlendSampleMask(const gl::Data &data, int samples) } // Applies the shaders and shader constants to the Direct3D device -gl::Error RendererD3D::applyShaders(const gl::Data &data, GLenum drawMode) +gl::Error RendererD3D::applyShaders(const gl::ContextState &data, GLenum drawMode) { gl::Program *program = data.state->getProgram(); ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); @@ -292,8 +154,11 @@ gl::Error RendererD3D::applyShaders(const gl::Data &data, GLenum drawMode) // looks up the corresponding OpenGL texture image unit and texture type, // and sets the texture and its addressing/filtering state (or NULL when inactive). // Sampler mapping needs to be up-to-date on the program object before this is called. -gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shaderType, - const FramebufferTextureArray &framebufferTextures, size_t framebufferTextureCount) +gl::Error RendererD3D::applyTextures(GLImplFactory *implFactory, + const gl::ContextState &data, + gl::SamplerType shaderType, + const FramebufferTextureArray &framebufferTextures, + size_t framebufferTextureCount) { ProgramD3D *programD3D = GetImplAs<ProgramD3D>(data.state->getProgram()); @@ -325,7 +190,7 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shade else { // Texture is not sampler complete or it is in use by the framebuffer. Bind the incomplete texture. - gl::Texture *incompleteTexture = getIncompleteTexture(textureType); + gl::Texture *incompleteTexture = getIncompleteTexture(implFactory, textureType); ANGLE_TRY(setSamplerState(shaderType, samplerIndex, incompleteTexture, incompleteTexture->getSamplerState())); @@ -347,17 +212,19 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shade return gl::NoError(); } -gl::Error RendererD3D::applyTextures(const gl::Data &data) +gl::Error RendererD3D::applyTextures(GLImplFactory *implFactory, const gl::ContextState &data) { FramebufferTextureArray framebufferTextures; size_t framebufferSerialCount = getBoundFramebufferTextures(data, &framebufferTextures); - ANGLE_TRY(applyTextures(data, gl::SAMPLER_VERTEX, framebufferTextures, framebufferSerialCount)); - ANGLE_TRY(applyTextures(data, gl::SAMPLER_PIXEL, framebufferTextures, framebufferSerialCount)); + ANGLE_TRY(applyTextures(implFactory, data, gl::SAMPLER_VERTEX, framebufferTextures, + framebufferSerialCount)); + ANGLE_TRY(applyTextures(implFactory, data, gl::SAMPLER_PIXEL, framebufferTextures, + framebufferSerialCount)); return gl::NoError(); } -bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode) +bool RendererD3D::skipDraw(const gl::ContextState &data, GLenum drawMode) { const gl::State &state = *data.state; @@ -389,7 +256,7 @@ bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode) return false; } -gl::Error RendererD3D::markTransformFeedbackUsage(const gl::Data &data) +gl::Error RendererD3D::markTransformFeedbackUsage(const gl::ContextState &data) { const gl::TransformFeedback *transformFeedback = data.state->getCurrentTransformFeedback(); for (size_t i = 0; i < transformFeedback->getIndexedBufferCount(); i++) @@ -405,7 +272,8 @@ gl::Error RendererD3D::markTransformFeedbackUsage(const gl::Data &data) return gl::NoError(); } -size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray) +size_t RendererD3D::getBoundFramebufferTextures(const gl::ContextState &data, + FramebufferTextureArray *outTextureArray) { size_t textureCount = 0; @@ -430,7 +298,7 @@ size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, Framebuffe return textureCount; } -gl::Texture *RendererD3D::getIncompleteTexture(GLenum type) +gl::Texture *RendererD3D::getIncompleteTexture(GLImplFactory *implFactory, GLenum type) { if (mIncompleteTextures.find(type) == mIncompleteTextures.end()) { @@ -439,11 +307,13 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLenum type) const gl::PixelUnpackState unpack(1, 0); const gl::Box area(0, 0, 0, 1, 1, 1); + // If a texture is external use a 2D texture for the incomplete texture + GLenum createType = (type == GL_TEXTURE_EXTERNAL_OES) ? GL_TEXTURE_2D : type; + // Skip the API layer to avoid needing to pass the Context and mess with dirty bits. gl::Texture *t = - new gl::Texture(createTexture(type), std::numeric_limits<GLuint>::max(), type); - t->setStorage(type, 1, GL_RGBA8, colorSize); - + new gl::Texture(implFactory, std::numeric_limits<GLuint>::max(), createType); + t->setStorage(createType, 1, GL_RGBA8, colorSize); if (type == GL_TEXTURE_CUBE_MAP) { for (GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; face++) @@ -454,10 +324,9 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLenum type) } else { - t->getImplementation()->setSubImage(type, 0, area, GL_RGBA8, GL_UNSIGNED_BYTE, unpack, + t->getImplementation()->setSubImage(createType, 0, area, GL_RGBA8, GL_UNSIGNED_BYTE, unpack, color); } - mIncompleteTextures[type].set(t); } @@ -567,10 +436,6 @@ GLint64 RendererD3D::getTimestamp() return 0; } -void RendererD3D::onMakeCurrent(const gl::Data &data) -{ -} - void RendererD3D::initializeDebugAnnotator() { createAnnotator(); @@ -583,4 +448,38 @@ gl::DebugAnnotator *RendererD3D::getAnnotator() ASSERT(mAnnotator); return mAnnotator; } + +void RendererD3D::ensureCapsInitialized() const +{ + if (!mCapsInitialized) + { + generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations); + mCapsInitialized = true; + } +} + +const gl::Caps &RendererD3D::getNativeCaps() const +{ + ensureCapsInitialized(); + return mNativeCaps; +} + +const gl::TextureCapsMap &RendererD3D::getNativeTextureCaps() const +{ + ensureCapsInitialized(); + return mNativeTextureCaps; +} + +const gl::Extensions &RendererD3D::getNativeExtensions() const +{ + ensureCapsInitialized(); + return mNativeExtensions; +} + +const gl::Limitations &RendererD3D::getNativeLimitations() const +{ + ensureCapsInitialized(); + return mNativeLimitations; +} + } // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.h index b21c7e85cbf..c227e254b16 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/RendererD3D.h @@ -11,14 +11,12 @@ #include "common/debug.h" #include "common/MemoryBuffer.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/Device.h" #include "libANGLE/formatutils.h" -#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/d3d/VertexDataManager.h" #include "libANGLE/renderer/d3d/formatutilsD3D.h" #include "libANGLE/renderer/d3d/WorkaroundsD3D.h" -#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" //FIXME(jmadill): std::array is currently prohibited by Chromium style guide #include <array> @@ -31,6 +29,7 @@ class ConfigSet; namespace gl { class DebugAnnotator; +class FramebufferState; class InfoLog; class Texture; struct LinkedVarying; @@ -38,17 +37,21 @@ struct LinkedVarying; namespace rx { +class ContextImpl; struct D3DUniform; struct D3DVarying; class DeviceD3D; class EGLImageD3D; +class FramebufferImpl; class ImageD3D; class IndexBuffer; +class NativeWindowD3D; class ProgramD3D; class RenderTargetD3D; class ShaderExecutableD3D; class SwapChainD3D; class TextureStorage; +struct TranslatedIndexData; class UniformStorageD3D; class VertexBuffer; @@ -76,7 +79,7 @@ enum RendererClass }; // Useful for unit testing -class BufferFactoryD3D +class BufferFactoryD3D : angle::NonCopyable { public: BufferFactoryD3D() {} @@ -96,7 +99,7 @@ class BufferFactoryD3D using AttribIndexArray = std::array<int, gl::MAX_VERTEX_ATTRIBS>; -class RendererD3D : public Renderer, public BufferFactoryD3D +class RendererD3D : public BufferFactoryD3D { public: explicit RendererD3D(egl::Display *display); @@ -107,39 +110,11 @@ class RendererD3D : public Renderer, public BufferFactoryD3D virtual egl::ConfigSet generateConfigs() const = 0; virtual void generateDisplayExtensions(egl::DisplayExtensions *outExtensions) const = 0; - gl::Error drawArrays(const gl::Data &data, GLenum mode, GLint first, GLsizei count) override; - gl::Error drawArraysInstanced(const gl::Data &data, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instanceCount) override; - - gl::Error drawElements(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) override; - gl::Error drawElementsInstanced(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange) override; - gl::Error drawRangeElements(const gl::Data &data, - GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) override; - - bool isDeviceLost() const override; - std::string getVendorString() const override; - - SamplerImpl *createSampler() override; + virtual ContextImpl *createContext(const gl::ContextState &state) = 0; + + bool isDeviceLost() const; + virtual bool testDeviceLost() = 0; + std::string getVendorString() const; virtual int getMinorShaderModel() const = 0; virtual std::string getShaderModelSuffix() const = 0; @@ -147,7 +122,12 @@ class RendererD3D : public Renderer, public BufferFactoryD3D // Direct3D Specific methods virtual DeviceIdentifier getAdapterIdentifier() const = 0; - virtual SwapChainD3D *createSwapChain(NativeWindow nativeWindow, + virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0; + virtual NativeWindowD3D *createNativeWindow(EGLNativeWindowType window, + const egl::Config *config, + const egl::AttributeMap &attribs) const = 0; + + virtual SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, @@ -157,30 +137,13 @@ class RendererD3D : public Renderer, public BufferFactoryD3D virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler) = 0; virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0; - virtual gl::Error setUniformBuffers(const gl::Data &data, + virtual gl::Error setUniformBuffers(const gl::ContextState &data, const std::vector<GLint> &vertexUniformBuffers, const std::vector<GLint> &fragmentUniformBuffers) = 0; - virtual gl::Error updateState(const gl::Data &data, GLenum drawMode) = 0; - - virtual gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) = 0; virtual gl::Error applyUniforms(const ProgramD3D &programD3D, GLenum drawMode, const std::vector<D3DUniform *> &uniformArray) = 0; - virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize) = 0; - virtual gl::Error applyVertexBuffer(const gl::State &state, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instances, - TranslatedIndexData *indexInfo) = 0; - virtual gl::Error applyIndexBuffer(const gl::Data &data, - const GLvoid *indices, - GLsizei count, - GLenum mode, - GLenum type, - TranslatedIndexData *indexInfo) = 0; - virtual gl::Error applyTransformFeedbackBuffers(const gl::State &state) = 0; virtual unsigned int getReservedVertexUniformVectors() const = 0; virtual unsigned int getReservedFragmentUniformVectors() const = 0; @@ -228,6 +191,9 @@ class RendererD3D : public Renderer, public BufferFactoryD3D const gl::TextureState &textureState) = 0; virtual TextureStorage *createTextureStorage2D(SwapChainD3D *swapChain) = 0; virtual TextureStorage *createTextureStorageEGLImage(EGLImageD3D *eglImage) = 0; + virtual TextureStorage *createTextureStorageExternal( + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) = 0; virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly) = 0; virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels, bool hintLevelZeroOnly) = 0; virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) = 0; @@ -239,7 +205,7 @@ class RendererD3D : public Renderer, public BufferFactoryD3D GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0; // Device lost - void notifyDeviceLost() override; + void notifyDeviceLost(); virtual bool resetDevice() = 0; virtual RendererClass getRendererClass() const = 0; virtual void *getD3DDevice() = 0; @@ -247,16 +213,14 @@ class RendererD3D : public Renderer, public BufferFactoryD3D gl::Error getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer **bufferOut); // EXT_debug_marker - void insertEventMarker(GLsizei length, const char *marker) override; - void pushGroupMarker(GLsizei length, const char *marker) override; - void popGroupMarker() override; + void insertEventMarker(GLsizei length, const char *marker); + void pushGroupMarker(GLsizei length, const char *marker); + void popGroupMarker(); void setGPUDisjoint(); - GLint getGPUDisjoint() override; - GLint64 getTimestamp() override; - - void onMakeCurrent(const gl::Data &data) override; + GLint getGPUDisjoint(); + GLint64 getTimestamp(); // In D3D11, faster than calling setTexture a jillion times virtual gl::Error clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd) = 0; @@ -266,19 +230,39 @@ class RendererD3D : public Renderer, public BufferFactoryD3D bool presentPathFastEnabled() const { return mPresentPathFastEnabled; } // Stream creation - virtual StreamImpl *createStream(const egl::AttributeMap &attribs) = 0; + virtual StreamProducerImpl *createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) = 0; + + const gl::Caps &getNativeCaps() const; + const gl::TextureCapsMap &getNativeTextureCaps() const; + const gl::Extensions &getNativeExtensions() const; + const gl::Limitations &getNativeLimitations() const; + + // Necessary hack for default framebuffers in D3D. + virtual FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) = 0; protected: virtual bool getLUID(LUID *adapterLuid) const = 0; - virtual gl::Error applyShadersImpl(const gl::Data &data, GLenum drawMode) = 0; + virtual gl::Error applyShadersImpl(const gl::ContextState &data, GLenum drawMode) = 0; + virtual void generateCaps(gl::Caps *outCaps, + gl::TextureCapsMap *outTextureCaps, + gl::Extensions *outExtensions, + gl::Limitations *outLimitations) const = 0; void cleanup(); virtual void createAnnotator() = 0; - static unsigned int GetBlendSampleMask(const gl::Data &data, int samples); + static unsigned int GetBlendSampleMask(const gl::ContextState &data, int samples); // dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state. + gl::Error generateSwizzles(const gl::ContextState &data); + gl::Error applyShaders(const gl::ContextState &data, GLenum drawMode); + gl::Error applyTextures(GLImplFactory *implFactory, const gl::ContextState &data); + bool skipDraw(const gl::ContextState &data, GLenum drawMode); + gl::Error markTransformFeedbackUsage(const gl::ContextState &data); + egl::Display *mDisplay; bool mDeviceLost; @@ -288,26 +272,14 @@ class RendererD3D : public Renderer, public BufferFactoryD3D bool mPresentPathFastEnabled; private: - gl::Error genericDrawArrays(const gl::Data &data, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instances); - - gl::Error genericDrawElements(const gl::Data &data, - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange); - - virtual gl::Error drawArraysImpl(const gl::Data &data, + void ensureCapsInitialized() const; + + virtual gl::Error drawArraysImpl(const gl::ContextState &data, GLenum mode, GLint startVertex, GLsizei count, GLsizei instances) = 0; - virtual gl::Error drawElementsImpl(const gl::Data &data, + virtual gl::Error drawElementsImpl(const gl::ContextState &data, const TranslatedIndexData &indexInfo, GLenum mode, GLsizei count, @@ -315,28 +287,31 @@ class RendererD3D : public Renderer, public BufferFactoryD3D const GLvoid *indices, GLsizei instances) = 0; - //FIXME(jmadill): std::array is currently prohibited by Chromium style guide typedef std::array<gl::Texture*, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureArray; - gl::Error generateSwizzles(const gl::Data &data, gl::SamplerType type); - gl::Error generateSwizzles(const gl::Data &data); + gl::Error generateSwizzles(const gl::ContextState &data, gl::SamplerType type); - gl::Error applyState(const gl::Data &data, GLenum drawMode); - gl::Error applyShaders(const gl::Data &data, GLenum drawMode); - gl::Error applyTextures(const gl::Data &data, gl::SamplerType shaderType, - const FramebufferTextureArray &framebufferTextures, size_t framebufferTextureCount); - gl::Error applyTextures(const gl::Data &data); + gl::Error applyState(const gl::ContextState &data, GLenum drawMode); + gl::Error applyTextures(GLImplFactory *implFactory, + const gl::ContextState &data, + gl::SamplerType shaderType, + const FramebufferTextureArray &framebufferTextures, + size_t framebufferTextureCount); - bool skipDraw(const gl::Data &data, GLenum drawMode); - gl::Error markTransformFeedbackUsage(const gl::Data &data); - - size_t getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray); - gl::Texture *getIncompleteTexture(GLenum type); + size_t getBoundFramebufferTextures(const gl::ContextState &data, + FramebufferTextureArray *outTextureArray); + gl::Texture *getIncompleteTexture(GLImplFactory *implFactory, GLenum type); gl::DebugAnnotator *getAnnotator(); virtual WorkaroundsD3D generateWorkarounds() const = 0; + mutable bool mCapsInitialized; + mutable gl::Caps mNativeCaps; + mutable gl::TextureCapsMap mNativeTextureCaps; + mutable gl::Extensions mNativeExtensions; + mutable gl::Limitations mNativeLimitations; + gl::TextureMap mIncompleteTextures; MemoryBuffer mScratchMemoryBuffer; unsigned int mScratchMemoryBufferResetCounter; @@ -347,6 +322,6 @@ class RendererD3D : public Renderer, public BufferFactoryD3D bool mDisjoint; }; -} +} // namespace rx #endif // LIBANGLE_RENDERER_D3D_RENDERERD3D_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp index 923118ba350..2e0d56ce357 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp @@ -40,7 +40,7 @@ const char *GetShaderTypeString(GLenum type) namespace rx { -ShaderD3D::ShaderD3D(const gl::Shader::Data &data) : ShaderImpl(data) +ShaderD3D::ShaderD3D(const gl::ShaderState &data) : ShaderImpl(data) { uncompile(); } @@ -72,7 +72,6 @@ void ShaderD3D::uncompile() mUsesFragDepth = false; mUsesDiscardRewriting = false; mUsesNestedBreak = false; - mUsesDeferredInit = false; mRequiresIEEEStrictCompiling = false; mDebugInfo.clear(); @@ -171,7 +170,6 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo mUsesDiscardRewriting = translatedSource.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos; mUsesNestedBreak = translatedSource.find("ANGLE_USES_NESTED_BREAK") != std::string::npos; - mUsesDeferredInit = translatedSource.find("ANGLE_USES_DEFERRED_INIT") != std::string::npos; mRequiresIEEEStrictCompiling = translatedSource.find("ANGLE_REQUIRES_IEEE_STRICT_COMPILING") != std::string::npos; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.h index 6077089c246..8346d2dc627 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/ShaderD3D.h @@ -23,7 +23,7 @@ struct D3DUniform; class ShaderD3D : public ShaderImpl { public: - ShaderD3D(const gl::Shader::Data &data); + ShaderD3D(const gl::ShaderState &data); virtual ~ShaderD3D(); // ShaderImpl implementation @@ -55,7 +55,6 @@ class ShaderD3D : public ShaderImpl bool usesPointCoord() const { return mUsesPointCoord; } bool usesDepthRange() const { return mUsesDepthRange; } bool usesFragDepth() const { return mUsesFragDepth; } - bool usesDeferredInit() const { return mUsesDeferredInit; } ShShaderOutput getCompilerOutputType() const; @@ -71,7 +70,6 @@ class ShaderD3D : public ShaderImpl bool mUsesFragDepth; bool mUsesDiscardRewriting; bool mUsesNestedBreak; - bool mUsesDeferredInit; bool mRequiresIEEEStrictCompiling; ShShaderOutput mCompilerOutputType; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp index 93f69904a3d..e21d631c33c 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp @@ -21,57 +21,58 @@ namespace rx { -SurfaceD3D *SurfaceD3D::createOffscreen(RendererD3D *renderer, egl::Display *display, const egl::Config *config, EGLClientBuffer shareHandle, - EGLint width, EGLint height) -{ - return new SurfaceD3D(renderer, display, config, width, height, EGL_TRUE, 0, EGL_FALSE, - shareHandle, NULL); -} - SurfaceD3D *SurfaceD3D::createFromWindow(RendererD3D *renderer, egl::Display *display, const egl::Config *config, EGLNativeWindowType window, - EGLint fixedSize, - EGLint directComposition, - EGLint width, - EGLint height, - EGLint orientation) + const egl::AttributeMap &attribs) +{ + return new SurfaceD3D(renderer, display, config, window, static_cast<EGLClientBuffer>(0), + attribs); +} + +SurfaceD3D *SurfaceD3D::createOffscreen(RendererD3D *renderer, + egl::Display *display, + const egl::Config *config, + EGLClientBuffer shareHandle, + const egl::AttributeMap &attribs) { - return new SurfaceD3D(renderer, display, config, width, height, fixedSize, orientation, - directComposition, static_cast<EGLClientBuffer>(0), window); + return new SurfaceD3D(renderer, display, config, static_cast<EGLNativeWindowType>(0), + shareHandle, attribs); } SurfaceD3D::SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl::Config *config, - EGLint width, - EGLint height, - EGLint fixedSize, - EGLint orientation, - EGLint directComposition, + EGLNativeWindowType window, EGLClientBuffer shareHandle, - EGLNativeWindowType window) + const egl::AttributeMap &attribs) : SurfaceImpl(), mRenderer(renderer), mDisplay(display), - mFixedSize(fixedSize == EGL_TRUE), - mOrientation(orientation), + mFixedSize(window == nullptr || attribs.get(EGL_FIXED_SIZE_ANGLE, EGL_FALSE) == EGL_TRUE), + mOrientation(static_cast<EGLint>(attribs.get(EGL_SURFACE_ORIENTATION_ANGLE, 0))), mRenderTargetFormat(config->renderTargetFormat), mDepthStencilFormat(config->depthStencilFormat), mSwapChain(nullptr), mSwapIntervalDirty(true), - mNativeWindow(window, config, directComposition == EGL_TRUE), - mWidth(width), - mHeight(height), + mNativeWindow(renderer->createNativeWindow(window, config, attribs)), + mWidth(static_cast<EGLint>(attribs.get(EGL_WIDTH, 0))), + mHeight(static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0))), mSwapInterval(1), mShareHandle(reinterpret_cast<HANDLE *>(shareHandle)) { + if (window != nullptr && !mFixedSize) + { + mWidth = -1; + mHeight = -1; + } } SurfaceD3D::~SurfaceD3D() { releaseSwapChain(); + SafeDelete(mNativeWindow); } void SurfaceD3D::releaseSwapChain() @@ -81,9 +82,9 @@ void SurfaceD3D::releaseSwapChain() egl::Error SurfaceD3D::initialize() { - if (mNativeWindow.getNativeWindow()) + if (mNativeWindow->getNativeWindow()) { - if (!mNativeWindow.initialize()) + if (!mNativeWindow->initialize()) { return egl::Error(EGL_BAD_SURFACE); } @@ -98,9 +99,9 @@ egl::Error SurfaceD3D::initialize() return egl::Error(EGL_SUCCESS); } -FramebufferImpl *SurfaceD3D::createDefaultFramebuffer(const gl::Framebuffer::Data &data) +FramebufferImpl *SurfaceD3D::createDefaultFramebuffer(const gl::FramebufferState &data) { - return mRenderer->createFramebuffer(data); + return mRenderer->createDefaultFramebuffer(data); } egl::Error SurfaceD3D::bindTexImage(gl::Texture *, EGLint) @@ -123,7 +124,7 @@ egl::Error SurfaceD3D::resetSwapChain() if (!mFixedSize) { RECT windowRect; - if (!mNativeWindow.getClientRect(&windowRect)) + if (!mNativeWindow->getClientRect(&windowRect)) { ASSERT(false); @@ -247,11 +248,11 @@ bool SurfaceD3D::checkForOutOfDateSwapChain() int clientWidth = getWidth(); int clientHeight = getHeight(); bool sizeDirty = false; - if (!mFixedSize && !mNativeWindow.isIconic()) + if (!mFixedSize && !mNativeWindow->isIconic()) { // The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized // because that's not a useful size to render to. - if (!mNativeWindow.getClientRect(&client)) + if (!mNativeWindow->getClientRect(&client)) { ASSERT(false); return false; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h index b925bfc8cc7..255ca5ff7ee 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h @@ -10,7 +10,7 @@ #define LIBANGLE_RENDERER_D3D_SURFACED3D_H_ #include "libANGLE/renderer/SurfaceImpl.h" -#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" +#include "libANGLE/renderer/d3d/NativeWindowD3D.h" namespace egl { @@ -29,18 +29,17 @@ class SurfaceD3D : public SurfaceImpl egl::Display *display, const egl::Config *config, EGLNativeWindowType window, - EGLint fixedSize, - EGLint directComposition, - EGLint width, - EGLint height, - EGLint orientation); - static SurfaceD3D *createOffscreen(RendererD3D *renderer, egl::Display *display, const egl::Config *config, - EGLClientBuffer shareHandle, EGLint width, EGLint height); + const egl::AttributeMap &attribs); + static SurfaceD3D *createOffscreen(RendererD3D *renderer, + egl::Display *display, + const egl::Config *config, + EGLClientBuffer shareHandle, + const egl::AttributeMap &attribs); ~SurfaceD3D() override; void releaseSwapChain(); egl::Error initialize() override; - FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override; + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; egl::Error swap() override; egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override; @@ -70,13 +69,9 @@ class SurfaceD3D : public SurfaceImpl SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl::Config *config, - EGLint width, - EGLint height, - EGLint fixedSize, - EGLint orientation, - EGLint directComposition, + EGLNativeWindowType window, EGLClientBuffer shareHandle, - EGLNativeWindowType window); + const egl::AttributeMap &attribs); egl::Error swapRect(EGLint x, EGLint y, EGLint width, EGLint height); egl::Error resetSwapChain(int backbufferWidth, int backbufferHeight); @@ -94,7 +89,7 @@ class SurfaceD3D : public SurfaceImpl SwapChainD3D *mSwapChain; bool mSwapIntervalDirty; - NativeWindow mNativeWindow; // Handler for the Window that the surface is created for. + NativeWindowD3D *mNativeWindow; // Handler for the Window that the surface is created for. EGLint mWidth; EGLint mHeight; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h index 1ef6611f8a9..71602b76641 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h @@ -16,9 +16,6 @@ #include "common/angleutils.h" #include "common/platform.h" -// TODO: move out of D3D11 -#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" - #if !defined(ANGLE_FORCE_VSYNC_OFF) #define ANGLE_FORCE_VSYNC_OFF 0 #endif @@ -30,8 +27,10 @@ class RenderTargetD3D; class SwapChainD3D : angle::NonCopyable { public: - SwapChainD3D(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) - : mNativeWindow(nativeWindow), mOffscreenRenderTargetFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat), mShareHandle(shareHandle) + SwapChainD3D(HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) + : mOffscreenRenderTargetFormat(backBufferFormat), + mDepthBufferFormat(depthBufferFormat), + mShareHandle(shareHandle) { } @@ -52,7 +51,6 @@ class SwapChainD3D : angle::NonCopyable virtual void *getKeyedMutex() = 0; protected: - rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for. const GLenum mOffscreenRenderTargetFormat; const GLenum mDepthBufferFormat; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp index 430576b3186..728bc9b8efc 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp @@ -75,12 +75,14 @@ bool IsRenderTargetUsage(GLenum usage) } -TextureD3D::TextureD3D(RendererD3D *renderer) - : mRenderer(renderer), +TextureD3D::TextureD3D(const gl::TextureState &state, RendererD3D *renderer) + : TextureImpl(state), + mRenderer(renderer), mUsage(GL_NONE), mDirtyImages(true), mImmutable(false), - mTexStorage(NULL) + mTexStorage(nullptr), + mBaseLevel(0) { } @@ -112,6 +114,21 @@ gl::Error TextureD3D::getNativeTexture(TextureStorage **outStorage) return gl::Error(GL_NO_ERROR); } +GLint TextureD3D::getLevelZeroWidth() const +{ + return getBaseLevelWidth() << mBaseLevel; +} + +GLint TextureD3D::getLevelZeroHeight() const +{ + return getBaseLevelHeight() << mBaseLevel; +} + +GLint TextureD3D::getLevelZeroDepth() const +{ + return getBaseLevelDepth(); +} + GLint TextureD3D::getBaseLevelWidth() const { const ImageD3D *baseImage = getBaseLevelImage(); @@ -345,7 +362,8 @@ gl::Error TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const GLint TextureD3D::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const { - if ((gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) || mRenderer->getRendererExtensions().textureNPOT) + if ((gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) || + mRenderer->getNativeExtensions().textureNPOT) { // Maximum number of levels return gl::log2(std::max(std::max(width, height), depth)) + 1; @@ -359,7 +377,9 @@ GLint TextureD3D::creationLevels(GLsizei width, GLsizei height, GLsizei depth) c int TextureD3D::mipLevels() const { - return gl::log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1; + return gl::log2( + std::max(std::max(getLevelZeroWidth(), getLevelZeroHeight()), getLevelZeroDepth())) + + 1; } TextureStorage *TextureD3D::getStorage() @@ -370,10 +390,23 @@ TextureStorage *TextureD3D::getStorage() ImageD3D *TextureD3D::getBaseLevelImage() const { - return getImage(getImageIndex(0, 0)); + if (mBaseLevel >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) + { + return nullptr; + } + return getImage(getImageIndex(mBaseLevel, 0)); +} + +gl::Error TextureD3D::setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) +{ + // Only external images can accept external textures + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); } -gl::Error TextureD3D::generateMipmaps(const gl::TextureState &textureState) +gl::Error TextureD3D::generateMipmaps() { GLint mipCount = mipLevels(); @@ -411,7 +444,7 @@ gl::Error TextureD3D::generateMipmaps(const gl::TextureState &textureState) } // Generate the mipmap chain using the ad-hoc DirectX function. - error = mRenderer->generateMipmapsUsingD3D(mTexStorage, textureState); + error = mRenderer->generateMipmapsUsingD3D(mTexStorage, mState); if (error.isError()) { return error; @@ -435,7 +468,7 @@ gl::Error TextureD3D::generateMipmapsUsingImages() GLint mipCount = mipLevels(); // We know that all layers have the same dimension, for the texture to be complete - GLint layerCount = static_cast<GLint>(getLayerCount(0)); + GLint layerCount = static_cast<GLint>(getLayerCount(getBaseLevel())); // When making mipmaps with the setData workaround enabled, the texture storage has // the image data already. For non-render-target storage, we have to pull it out into @@ -531,7 +564,7 @@ bool TextureD3D::isBaseImageZeroSize() const return true; } - if (baseImage->getTarget() == GL_TEXTURE_2D_ARRAY && getLayerCount(0) <= 0) + if (baseImage->getTarget() == GL_TEXTURE_2D_ARRAY && getLayerCount(getBaseLevel()) <= 0) { return true; } @@ -612,8 +645,31 @@ gl::Error TextureD3D::getAttachmentRenderTarget(const gl::FramebufferAttachment: return error; } -TextureD3D_2D::TextureD3D_2D(RendererD3D *renderer) - : TextureD3D(renderer) +void TextureD3D::setBaseLevel(GLuint baseLevel) +{ + const int oldStorageWidth = std::max(1, getLevelZeroWidth()); + const int oldStorageHeight = std::max(1, getLevelZeroHeight()); + const int oldStorageDepth = std::max(1, getLevelZeroDepth()); + const int oldStorageFormat = getBaseLevelInternalFormat(); + mBaseLevel = baseLevel; + + // When the base level changes, the texture storage might not be valid anymore, since it could + // have been created based on the dimensions of the previous specified level range. + const int newStorageWidth = std::max(1, getLevelZeroWidth()); + const int newStorageHeight = std::max(1, getLevelZeroHeight()); + const int newStorageDepth = std::max(1, getLevelZeroDepth()); + const int newStorageFormat = getBaseLevelInternalFormat(); + if (mTexStorage && + (newStorageWidth != oldStorageWidth || newStorageHeight != oldStorageHeight || + newStorageDepth != oldStorageDepth || newStorageFormat != oldStorageFormat)) + { + markAllImagesDirty(); + SafeDelete(mTexStorage); + } +} + +TextureD3D_2D::TextureD3D_2D(const gl::TextureState &state, RendererD3D *renderer) + : TextureD3D(state, renderer) { mEGLImageTarget = false; for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i) @@ -1016,9 +1072,8 @@ void TextureD3D_2D::initMipmapsImages() int levelCount = mipLevels(); for (int level = 1; level < levelCount; level++) { - gl::Extents levelSize(std::max(getBaseLevelWidth() >> level, 1), - std::max(getBaseLevelHeight() >> level, 1), - 1); + gl::Extents levelSize(std::max(getLevelZeroWidth() >> level, 1), + std::max(getLevelZeroHeight() >> level, 1), 1); redefineImage(level, getBaseLevelInternalFormat(), levelSize, false); } @@ -1056,10 +1111,8 @@ bool TextureD3D_2D::isLevelComplete(int level) const return true; } - const ImageD3D *baseImage = getBaseLevelImage(); - - GLsizei width = baseImage->getWidth(); - GLsizei height = baseImage->getHeight(); + GLsizei width = getLevelZeroWidth(); + GLsizei height = getLevelZeroHeight(); if (width <= 0 || height <= 0) { @@ -1067,15 +1120,15 @@ bool TextureD3D_2D::isLevelComplete(int level) const } // The base image level is complete if the width and height are positive - if (level == 0) + if (level == static_cast<int>(getBaseLevel())) { return true; } - ASSERT(level >= 1 && level <= (int)ArraySize(mImageArray) && mImageArray[level] != NULL); + ASSERT(level >= 0 && level <= (int)ArraySize(mImageArray) && mImageArray[level] != nullptr); ImageD3D *image = mImageArray[level]; - if (image->getInternalFormat() != baseImage->getInternalFormat()) + if (image->getInternalFormat() != getBaseLevelInternalFormat()) { return false; } @@ -1108,7 +1161,7 @@ gl::Error TextureD3D_2D::initializeStorage(bool renderTarget) } // do not attempt to create storage for nonexistant data - if (!isLevelComplete(0)) + if (!isLevelComplete(getBaseLevel())) { return gl::Error(GL_NO_ERROR); } @@ -1143,8 +1196,8 @@ gl::Error TextureD3D_2D::initializeStorage(bool renderTarget) gl::Error TextureD3D_2D::createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const { - GLsizei width = getBaseLevelWidth(); - GLsizei height = getBaseLevelHeight(); + GLsizei width = getLevelZeroWidth(); + GLsizei height = getLevelZeroHeight(); GLenum internalFormat = getBaseLevelInternalFormat(); ASSERT(width > 0 && height > 0); @@ -1238,8 +1291,8 @@ void TextureD3D_2D::redefineImage(size_t level, ASSERT(size.depth == 1); // If there currently is a corresponding storage texture image, it has these parameters - const int storageWidth = std::max(1, getBaseLevelWidth() >> level); - const int storageHeight = std::max(1, getBaseLevelHeight() >> level); + const int storageWidth = std::max(1, getLevelZeroWidth() >> level); + const int storageHeight = std::max(1, getLevelZeroHeight() >> level); const GLenum storageFormat = getBaseLevelInternalFormat(); mImageArray[level]->redefine(GL_TEXTURE_2D, internalformat, size, forceRelease); @@ -1261,13 +1314,8 @@ void TextureD3D_2D::redefineImage(size_t level, size.height != storageHeight || internalformat != storageFormat) // Discard mismatched storage { - for (size_t i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) - { - mImageArray[i]->markDirty(); - } - + markAllImagesDirty(); SafeDelete(mTexStorage); - mDirtyImages = true; } } @@ -1292,8 +1340,17 @@ bool TextureD3D_2D::isValidIndex(const gl::ImageIndex &index) const index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount()); } -TextureD3D_Cube::TextureD3D_Cube(RendererD3D *renderer) - : TextureD3D(renderer) +void TextureD3D_2D::markAllImagesDirty() +{ + for (size_t i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) + { + mImageArray[i]->markDirty(); + } + mDirtyImages = true; +} + +TextureD3D_Cube::TextureD3D_Cube(const gl::TextureState &state, RendererD3D *renderer) + : TextureD3D(state, renderer) { for (int i = 0; i < 6; i++) { @@ -1579,7 +1636,7 @@ bool TextureD3D_Cube::isCubeComplete() const for (int faceIndex = 1; faceIndex < 6; faceIndex++) { - const ImageD3D &faceBaseImage = *mImageArray[faceIndex][0]; + const ImageD3D &faceBaseImage = *mImageArray[faceIndex][getBaseLevel()]; if (faceBaseImage.getWidth() != baseWidth || faceBaseImage.getHeight() != baseHeight || @@ -1647,7 +1704,7 @@ gl::Error TextureD3D_Cube::initializeStorage(bool renderTarget) } // do not attempt to create storage for nonexistant data - if (!isFaceLevelComplete(0, 0)) + if (!isFaceLevelComplete(0, getBaseLevel())) { return gl::Error(GL_NO_ERROR); } @@ -1682,7 +1739,7 @@ gl::Error TextureD3D_Cube::initializeStorage(bool renderTarget) gl::Error TextureD3D_Cube::createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const { - GLsizei size = getBaseLevelWidth(); + GLsizei size = getLevelZeroWidth(); ASSERT(size > 0); @@ -1763,16 +1820,21 @@ bool TextureD3D_Cube::isValidFaceLevel(int faceIndex, int level) const bool TextureD3D_Cube::isFaceLevelComplete(int faceIndex, int level) const { - ASSERT(level >= 0 && faceIndex < 6 && level < (int)ArraySize(mImageArray[faceIndex]) && mImageArray[faceIndex][level] != NULL); + if (getBaseLevel() >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) + { + return false; + } + ASSERT(level >= 0 && faceIndex < 6 && level < (int)ArraySize(mImageArray[faceIndex]) && + mImageArray[faceIndex][level] != nullptr); if (isImmutable()) { return true; } - int baseSize = getBaseLevelWidth(); + int levelZeroSize = getLevelZeroWidth(); - if (baseSize <= 0) + if (levelZeroSize <= 0) { return false; } @@ -1793,7 +1855,7 @@ bool TextureD3D_Cube::isFaceLevelComplete(int faceIndex, int level) const return false; } - if (faceLevelImage->getWidth() != std::max(1, baseSize >> level)) + if (faceLevelImage->getWidth() != std::max(1, levelZeroSize >> level)) { return false; } @@ -1829,8 +1891,8 @@ gl::Error TextureD3D_Cube::updateStorageFaceLevel(int faceIndex, int level) void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalformat, const gl::Extents &size) { // If there currently is a corresponding storage texture image, it has these parameters - const int storageWidth = std::max(1, getBaseLevelWidth() >> level); - const int storageHeight = std::max(1, getBaseLevelHeight() >> level); + const int storageWidth = std::max(1, getLevelZeroWidth() >> level); + const int storageHeight = std::max(1, getLevelZeroHeight() >> level); const GLenum storageFormat = getBaseLevelInternalFormat(); mImageArray[faceIndex][level]->redefine(GL_TEXTURE_CUBE_MAP, internalformat, size, false); @@ -1844,17 +1906,8 @@ void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalf size.height != storageHeight || internalformat != storageFormat) // Discard mismatched storage { - for (int dirtyLevel = 0; dirtyLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; dirtyLevel++) - { - for (int dirtyFace = 0; dirtyFace < 6; dirtyFace++) - { - mImageArray[dirtyFace][dirtyLevel]->markDirty(); - } - } - + markAllImagesDirty(); SafeDelete(mTexStorage); - - mDirtyImages = true; } } } @@ -1876,8 +1929,20 @@ bool TextureD3D_Cube::isValidIndex(const gl::ImageIndex &index) const index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount()); } -TextureD3D_3D::TextureD3D_3D(RendererD3D *renderer) - : TextureD3D(renderer) +void TextureD3D_Cube::markAllImagesDirty() +{ + for (int dirtyLevel = 0; dirtyLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; dirtyLevel++) + { + for (int dirtyFace = 0; dirtyFace < 6; dirtyFace++) + { + mImageArray[dirtyFace][dirtyLevel]->markDirty(); + } + } + mDirtyImages = true; +} + +TextureD3D_3D::TextureD3D_3D(const gl::TextureState &state, RendererD3D *renderer) + : TextureD3D(state, renderer) { for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i) { @@ -1982,7 +2047,7 @@ gl::Error TextureD3D_3D::setImage(GLenum target, gl::ImageIndex index = gl::ImageIndex::Make3D(level); // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer - if (isFastUnpackable(unpack, sizedInternalFormat) && !size.empty()) + if (isFastUnpackable(unpack, sizedInternalFormat) && !size.empty() && isLevelComplete(level)) { // Will try to create RT storage if it does not exist RenderTargetD3D *destRenderTarget = NULL; @@ -2032,7 +2097,7 @@ gl::Error TextureD3D_3D::setSubImage(GLenum target, gl::ImageIndex index = gl::ImageIndex::Make3D(level); // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer - if (isFastUnpackable(unpack, getInternalFormat(level))) + if (isFastUnpackable(unpack, getInternalFormat(level)) && isLevelComplete(level)) { RenderTargetD3D *destRenderTarget = NULL; gl::Error error = getRenderTarget(index, &destRenderTarget); @@ -2200,9 +2265,9 @@ void TextureD3D_3D::initMipmapsImages() int levelCount = mipLevels(); for (int level = 1; level < levelCount; level++) { - gl::Extents levelSize(std::max(getBaseLevelWidth() >> level, 1), - std::max(getBaseLevelHeight() >> level, 1), - std::max(getBaseLevelDepth() >> level, 1)); + gl::Extents levelSize(std::max(getLevelZeroWidth() >> level, 1), + std::max(getLevelZeroHeight() >> level, 1), + std::max(getLevelZeroDepth() >> level, 1)); redefineImage(level, getBaseLevelInternalFormat(), levelSize); } } @@ -2245,7 +2310,7 @@ gl::Error TextureD3D_3D::initializeStorage(bool renderTarget) } // do not attempt to create storage for nonexistant data - if (!isLevelComplete(0)) + if (!isLevelComplete(getBaseLevel())) { return gl::Error(GL_NO_ERROR); } @@ -2280,9 +2345,9 @@ gl::Error TextureD3D_3D::initializeStorage(bool renderTarget) gl::Error TextureD3D_3D::createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const { - GLsizei width = getBaseLevelWidth(); - GLsizei height = getBaseLevelHeight(); - GLsizei depth = getBaseLevelDepth(); + GLsizei width = getLevelZeroWidth(); + GLsizei height = getLevelZeroHeight(); + GLsizei depth = getLevelZeroDepth(); GLenum internalFormat = getBaseLevelInternalFormat(); ASSERT(width > 0 && height > 0 && depth > 0); @@ -2341,16 +2406,16 @@ bool TextureD3D_3D::isLevelComplete(int level) const return true; } - GLsizei width = getBaseLevelWidth(); - GLsizei height = getBaseLevelHeight(); - GLsizei depth = getBaseLevelDepth(); + GLsizei width = getLevelZeroWidth(); + GLsizei height = getLevelZeroHeight(); + GLsizei depth = getLevelZeroDepth(); if (width <= 0 || height <= 0 || depth <= 0) { return false; } - if (level == 0) + if (level == static_cast<int>(getBaseLevel())) { return true; } @@ -2407,15 +2472,15 @@ gl::Error TextureD3D_3D::updateStorageLevel(int level) void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, const gl::Extents &size) { // If there currently is a corresponding storage texture image, it has these parameters - const int storageWidth = std::max(1, getBaseLevelWidth() >> level); - const int storageHeight = std::max(1, getBaseLevelHeight() >> level); - const int storageDepth = std::max(1, getBaseLevelDepth() >> level); - const GLenum storageFormat = getBaseLevelInternalFormat(); + const int storageWidth = std::max(1, getLevelZeroWidth() >> level); + const int storageHeight = std::max(1, getLevelZeroHeight() >> level); + const int storageDepth = std::max(1, getLevelZeroDepth() >> level); mImageArray[level]->redefine(GL_TEXTURE_3D, internalformat, size, false); if (mTexStorage) { + const GLenum storageFormat = getBaseLevelInternalFormat(); const int storageLevels = mTexStorage->getLevelCount(); if ((level >= storageLevels && storageLevels != 0) || @@ -2424,13 +2489,8 @@ void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, const gl:: size.depth != storageDepth || internalformat != storageFormat) // Discard mismatched storage { - for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) - { - mImageArray[i]->markDirty(); - } - + markAllImagesDirty(); SafeDelete(mTexStorage); - mDirtyImages = true; } } } @@ -2453,8 +2513,22 @@ bool TextureD3D_3D::isValidIndex(const gl::ImageIndex &index) const index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount()); } -TextureD3D_2DArray::TextureD3D_2DArray(RendererD3D *renderer) - : TextureD3D(renderer) +void TextureD3D_3D::markAllImagesDirty() +{ + for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) + { + mImageArray[i]->markDirty(); + } + mDirtyImages = true; +} + +GLint TextureD3D_3D::getLevelZeroDepth() const +{ + return getBaseLevelDepth() << getBaseLevel(); +} + +TextureD3D_2DArray::TextureD3D_2DArray(const gl::TextureState &state, RendererD3D *renderer) + : TextureD3D(state, renderer) { for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++level) { @@ -2699,8 +2773,10 @@ gl::Error TextureD3D_2DArray::copySubImage(GLenum target, return error; } - error = mRenderer->copyImage2DArray(source, sourceArea, gl::GetInternalFormatInfo(getInternalFormat(0)).format, - destOffset, mTexStorage, level); + error = mRenderer->copyImage2DArray( + source, sourceArea, + gl::GetInternalFormatInfo(getInternalFormat(getBaseLevel())).format, destOffset, + mTexStorage, level); if (error.isError()) { return error; @@ -2775,9 +2851,9 @@ void TextureD3D_2DArray::releaseTexImage() void TextureD3D_2DArray::initMipmapsImages() { - int baseWidth = getBaseLevelWidth(); - int baseHeight = getBaseLevelHeight(); - int baseDepth = getLayerCount(0); + int baseWidth = getLevelZeroWidth(); + int baseHeight = getLevelZeroHeight(); + int baseDepth = getLayerCount(getBaseLevel()); GLenum baseFormat = getBaseLevelInternalFormat(); // Purge array levels 1 through q and reset them to represent the generated mipmap levels. @@ -2818,7 +2894,7 @@ gl::Error TextureD3D_2DArray::initializeStorage(bool renderTarget) } // do not attempt to create storage for nonexistant data - if (!isLevelComplete(0)) + if (!isLevelComplete(getBaseLevel())) { return gl::Error(GL_NO_ERROR); } @@ -2853,9 +2929,9 @@ gl::Error TextureD3D_2DArray::initializeStorage(bool renderTarget) gl::Error TextureD3D_2DArray::createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const { - GLsizei width = getBaseLevelWidth(); - GLsizei height = getBaseLevelHeight(); - GLsizei depth = getLayerCount(0); + GLsizei width = getLevelZeroWidth(); + GLsizei height = getLevelZeroHeight(); + GLsizei depth = getLayerCount(getBaseLevel()); GLenum internalFormat = getBaseLevelInternalFormat(); ASSERT(width > 0 && height > 0 && depth > 0); @@ -2914,21 +2990,29 @@ bool TextureD3D_2DArray::isLevelComplete(int level) const return true; } - GLsizei width = getBaseLevelWidth(); - GLsizei height = getBaseLevelHeight(); - GLsizei layers = getLayerCount(0); + GLsizei width = getLevelZeroWidth(); + GLsizei height = getLevelZeroHeight(); - if (width <= 0 || height <= 0 || layers <= 0) + if (width <= 0 || height <= 0) { return false; } - if (level == 0) + // Layers check needs to happen after the above checks, otherwise out-of-range base level may be + // queried. + GLsizei layers = getLayerCount(getBaseLevel()); + + if (layers <= 0) + { + return false; + } + + if (level == static_cast<int>(getBaseLevel())) { return true; } - if (getInternalFormat(level) != getInternalFormat(0)) + if (getInternalFormat(level) != getInternalFormat(getBaseLevel())) { return false; } @@ -2996,10 +3080,14 @@ void TextureD3D_2DArray::deleteImages() void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, const gl::Extents &size) { // If there currently is a corresponding storage texture image, it has these parameters - const int storageWidth = std::max(1, getBaseLevelWidth() >> level); - const int storageHeight = std::max(1, getBaseLevelHeight() >> level); - const int storageDepth = getLayerCount(0); - const GLenum storageFormat = getBaseLevelInternalFormat(); + const int storageWidth = std::max(1, getLevelZeroWidth() >> level); + const int storageHeight = std::max(1, getLevelZeroHeight() >> level); + const GLuint baseLevel = getBaseLevel(); + int storageDepth = 0; + if (baseLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) + { + storageDepth = getLayerCount(baseLevel); + } // Only reallocate the layers if the size doesn't match if (size.depth != mLayerCounts[level]) @@ -3032,6 +3120,7 @@ void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, const if (mTexStorage) { + const GLenum storageFormat = getBaseLevelInternalFormat(); const int storageLevels = mTexStorage->getLevelCount(); if ((level >= storageLevels && storageLevels != 0) || @@ -3040,17 +3129,8 @@ void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, const size.depth != storageDepth || internalformat != storageFormat) // Discard mismatched storage { - for (int dirtyLevel = 0; dirtyLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; dirtyLevel++) - { - for (int dirtyLayer = 0; dirtyLayer < mLayerCounts[dirtyLevel]; dirtyLayer++) - { - mImageArray[dirtyLevel][dirtyLayer]->markDirty(); - } - } - - delete mTexStorage; - mTexStorage = NULL; - mDirtyImages = true; + markAllImagesDirty(); + SafeDelete(mTexStorage); } } } @@ -3083,4 +3163,268 @@ bool TextureD3D_2DArray::isValidIndex(const gl::ImageIndex &index) const return (!index.hasLayer() || (index.layerIndex >= 0 && index.layerIndex < mLayerCounts[index.mipIndex])); } +void TextureD3D_2DArray::markAllImagesDirty() +{ + for (int dirtyLevel = 0; dirtyLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; dirtyLevel++) + { + for (int dirtyLayer = 0; dirtyLayer < mLayerCounts[dirtyLevel]; dirtyLayer++) + { + mImageArray[dirtyLevel][dirtyLayer]->markDirty(); + } + } + mDirtyImages = true; +} + +TextureD3D_External::TextureD3D_External(const gl::TextureState &state, RendererD3D *renderer) + : TextureD3D(state, renderer) +{ + mImage = renderer->createImage(); +} + +TextureD3D_External::~TextureD3D_External() +{ + SafeDelete(mImage); + SafeDelete(mTexStorage); +} + +ImageD3D *TextureD3D_External::getImage(const gl::ImageIndex &index) const +{ + // External images only have one mipmap level + ASSERT(index.type == GL_TEXTURE_EXTERNAL_OES); + ASSERT(index.mipIndex == 0); + return mImage; +} + +GLsizei TextureD3D_External::getLayerCount(int level) const +{ + return 1; +} + +GLsizei TextureD3D_External::getWidth(GLint level) const +{ + ASSERT(level == 0); + return mImage->getWidth(); +} + +GLsizei TextureD3D_External::getHeight(GLint level) const +{ + ASSERT(level == 0); + return mImage->getHeight(); +} + +GLenum TextureD3D_External::getInternalFormat(GLint level) const +{ + ASSERT(level == 0); + return mImage->getInternalFormat(); +} + +bool TextureD3D_External::isDepth(GLint level) const +{ + return false; +} + +gl::Error TextureD3D_External::setImage(GLenum target, + size_t imageLevel, + GLenum internalFormat, + const gl::Extents &size, + GLenum format, + GLenum type, + const gl::PixelUnpackState &unpack, + const uint8_t *pixels) +{ + // Image setting is not supported for external images + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::setSubImage(GLenum target, + size_t imageLevel, + const gl::Box &area, + GLenum format, + GLenum type, + const gl::PixelUnpackState &unpack, + const uint8_t *pixels) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::setCompressedImage(GLenum target, + size_t imageLevel, + GLenum internalFormat, + const gl::Extents &size, + const gl::PixelUnpackState &unpack, + size_t imageSize, + const uint8_t *pixels) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::setCompressedSubImage(GLenum target, + size_t level, + const gl::Box &area, + GLenum format, + const gl::PixelUnpackState &unpack, + size_t imageSize, + const uint8_t *pixels) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::copyImage(GLenum target, + size_t imageLevel, + const gl::Rectangle &sourceArea, + GLenum internalFormat, + const gl::Framebuffer *source) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::copySubImage(GLenum target, + size_t imageLevel, + const gl::Offset &destOffset, + const gl::Rectangle &sourceArea, + const gl::Framebuffer *source) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::setStorage(GLenum target, + size_t levels, + GLenum internalFormat, + const gl::Extents &size) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureD3D_External::setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) +{ + ASSERT(target == GL_TEXTURE_EXTERNAL_OES); + + // If the strean is null, the external image is unbound and we release the storage + if (stream == nullptr) + { + SafeDelete(mTexStorage); + mTexStorage = nullptr; + } + else + { + SafeDelete(mTexStorage); + mTexStorage = mRenderer->createTextureStorageExternal(stream, desc); + } + + return gl::Error(GL_NO_ERROR); +} + +void TextureD3D_External::bindTexImage(egl::Surface *surface) +{ + UNREACHABLE(); +} + +void TextureD3D_External::releaseTexImage() +{ + UNREACHABLE(); +} + +gl::Error TextureD3D_External::setEGLImageTarget(GLenum target, egl::Image *image) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +void TextureD3D_External::initMipmapsImages() +{ + UNREACHABLE(); +} + +gl::Error TextureD3D_External::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) +{ + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +bool TextureD3D_External::isValidLevel(int level) const +{ + return (level == 0); +} + +bool TextureD3D_External::isLevelComplete(int level) const +{ + return (level == 0) ? (mTexStorage != nullptr) : false; +} + +bool TextureD3D_External::isImageComplete(const gl::ImageIndex &index) const +{ + return isLevelComplete(index.mipIndex); +} + +gl::Error TextureD3D_External::initializeStorage(bool renderTarget) +{ + // Texture storage is created when an external image is bound + ASSERT(mTexStorage); + return gl::Error(GL_NO_ERROR); +} + +gl::Error TextureD3D_External::createCompleteStorage(bool renderTarget, + TextureStorage **outTexStorage) const +{ + UNREACHABLE(); + return gl::Error(GL_NO_ERROR); +} + +gl::Error TextureD3D_External::setCompleteTexStorage(TextureStorage *newCompleteTexStorage) +{ + UNREACHABLE(); + return gl::Error(GL_NO_ERROR); +} + +gl::Error TextureD3D_External::updateStorage() +{ + // Texture storage does not need to be updated since it is already loaded with the latest + // external image + ASSERT(mTexStorage); + return gl::Error(GL_NO_ERROR); +} + +gl::Error TextureD3D_External::updateStorageLevel(int level) +{ + UNREACHABLE(); + return gl::Error(GL_NO_ERROR); +} + +void TextureD3D_External::redefineImage(size_t level, + GLenum internalformat, + const gl::Extents &size, + bool forceRelease) +{ + UNREACHABLE(); +} + +gl::ImageIndexIterator TextureD3D_External::imageIterator() const +{ + return gl::ImageIndexIterator::Make2D(0, mTexStorage->getLevelCount()); +} + +gl::ImageIndex TextureD3D_External::getImageIndex(GLint mip, GLint /*layer*/) const +{ + // "layer" does not apply to 2D Textures. + return gl::ImageIndex::Make2D(mip); +} + +bool TextureD3D_External::isValidIndex(const gl::ImageIndex &index) const +{ + return (mTexStorage && index.type == GL_TEXTURE_EXTERNAL_OES && index.mipIndex == 0); +} + +void TextureD3D_External::markAllImagesDirty() +{ + UNREACHABLE(); +} } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.h index 1d5faee7030..412d738e951 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/TextureD3D.h @@ -12,6 +12,7 @@ #include "libANGLE/renderer/TextureImpl.h" #include "libANGLE/angletypes.h" #include "libANGLE/Constants.h" +#include "libANGLE/Stream.h" namespace gl { @@ -29,7 +30,7 @@ class TextureStorage; class TextureD3D : public TextureImpl { public: - TextureD3D(RendererD3D *renderer); + TextureD3D(const gl::TextureState &data, RendererD3D *renderer); virtual ~TextureD3D(); gl::Error getNativeTexture(TextureStorage **outStorage); @@ -43,7 +44,6 @@ class TextureD3D : public TextureImpl GLint getBaseLevelWidth() const; GLint getBaseLevelHeight() const; - GLint getBaseLevelDepth() const; GLenum getBaseLevelInternalFormat() const; bool isImmutable() const { return mImmutable; } @@ -58,13 +58,18 @@ class TextureD3D : public TextureImpl virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const = 0; virtual bool isValidIndex(const gl::ImageIndex &index) const = 0; - gl::Error generateMipmaps(const gl::TextureState &textureState) override; + virtual gl::Error setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) override; + gl::Error generateMipmaps() override; TextureStorage *getStorage(); ImageD3D *getBaseLevelImage() const; gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, FramebufferAttachmentRenderTarget **rtOut) override; + void setBaseLevel(GLuint baseLevel) override; + protected: gl::Error setImageImpl(const gl::ImageIndex &index, GLenum type, @@ -83,6 +88,10 @@ class TextureD3D : public TextureImpl gl::Error fastUnpackPixels(const gl::PixelUnpackState &unpack, const uint8_t *pixels, const gl::Box &destArea, GLenum sizedInternalFormat, GLenum type, RenderTargetD3D *destRenderTarget); + GLint getLevelZeroWidth() const; + GLint getLevelZeroHeight() const; + virtual GLint getLevelZeroDepth() const; + GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const; int mipLevels() const; virtual void initMipmapsImages() = 0; @@ -96,6 +105,12 @@ class TextureD3D : public TextureImpl virtual gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage) = 0; gl::Error commitRegion(const gl::ImageIndex &index, const gl::Box ®ion); + GLuint getBaseLevel() const { return mBaseLevel; }; + + virtual void markAllImagesDirty() = 0; + + GLint getBaseLevelDepth() const; + RendererD3D *mRenderer; GLenum mUsage; @@ -113,12 +128,14 @@ class TextureD3D : public TextureImpl bool shouldUseSetData(const ImageD3D *image) const; gl::Error generateMipmapsUsingImages(); + + GLuint mBaseLevel; }; class TextureD3D_2D : public TextureD3D { public: - TextureD3D_2D(RendererD3D *renderer); + TextureD3D_2D(const gl::TextureState &data, RendererD3D *renderer); virtual ~TextureD3D_2D(); virtual ImageD3D *getImage(int level, int layer) const; @@ -158,6 +175,9 @@ class TextureD3D_2D : public TextureD3D virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const; virtual bool isValidIndex(const gl::ImageIndex &index) const; + protected: + void markAllImagesDirty() override; + private: virtual gl::Error initializeStorage(bool renderTarget); virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const; @@ -184,7 +204,7 @@ class TextureD3D_2D : public TextureD3D class TextureD3D_Cube : public TextureD3D { public: - TextureD3D_Cube(RendererD3D *renderer); + TextureD3D_Cube(const gl::TextureState &data, RendererD3D *renderer); virtual ~TextureD3D_Cube(); virtual ImageD3D *getImage(int level, int layer) const; @@ -226,6 +246,9 @@ class TextureD3D_Cube : public TextureD3D virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const; virtual bool isValidIndex(const gl::ImageIndex &index) const; + protected: + void markAllImagesDirty() override; + private: virtual gl::Error initializeStorage(bool renderTarget); virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const; @@ -248,7 +271,7 @@ class TextureD3D_Cube : public TextureD3D class TextureD3D_3D : public TextureD3D { public: - TextureD3D_3D(RendererD3D *renderer); + TextureD3D_3D(const gl::TextureState &data, RendererD3D *renderer); virtual ~TextureD3D_3D(); virtual ImageD3D *getImage(int level, int layer) const; @@ -289,6 +312,10 @@ class TextureD3D_3D : public TextureD3D virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const; virtual bool isValidIndex(const gl::ImageIndex &index) const; + protected: + void markAllImagesDirty() override; + GLint getLevelZeroDepth() const override; + private: virtual gl::Error initializeStorage(bool renderTarget); virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const; @@ -310,7 +337,7 @@ class TextureD3D_3D : public TextureD3D class TextureD3D_2DArray : public TextureD3D { public: - TextureD3D_2DArray(RendererD3D *renderer); + TextureD3D_2DArray(const gl::TextureState &data, RendererD3D *renderer); virtual ~TextureD3D_2DArray(); virtual ImageD3D *getImage(int level, int layer) const; @@ -350,6 +377,9 @@ class TextureD3D_2DArray : public TextureD3D virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const; virtual bool isValidIndex(const gl::ImageIndex &index) const; + protected: + void markAllImagesDirty() override; + private: virtual gl::Error initializeStorage(bool renderTarget); virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const; @@ -374,6 +404,107 @@ class TextureD3D_2DArray : public TextureD3D ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; }; +class TextureD3D_External : public TextureD3D +{ + public: + TextureD3D_External(const gl::TextureState &data, RendererD3D *renderer); + ~TextureD3D_External() override; + + ImageD3D *getImage(const gl::ImageIndex &index) const override; + GLsizei getLayerCount(int level) const override; + + GLsizei getWidth(GLint level) const; + GLsizei getHeight(GLint level) const; + GLenum getInternalFormat(GLint level) const; + bool isDepth(GLint level) const; + + gl::Error setImage(GLenum target, + size_t level, + GLenum internalFormat, + const gl::Extents &size, + GLenum format, + GLenum type, + const gl::PixelUnpackState &unpack, + const uint8_t *pixels) override; + gl::Error setSubImage(GLenum target, + size_t level, + const gl::Box &area, + GLenum format, + GLenum type, + const gl::PixelUnpackState &unpack, + const uint8_t *pixels) override; + + gl::Error setCompressedImage(GLenum target, + size_t level, + GLenum internalFormat, + const gl::Extents &size, + const gl::PixelUnpackState &unpack, + size_t imageSize, + const uint8_t *pixels) override; + gl::Error setCompressedSubImage(GLenum target, + size_t level, + const gl::Box &area, + GLenum format, + const gl::PixelUnpackState &unpack, + size_t imageSize, + const uint8_t *pixels) override; + + gl::Error copyImage(GLenum target, + size_t level, + const gl::Rectangle &sourceArea, + GLenum internalFormat, + const gl::Framebuffer *source) override; + gl::Error copySubImage(GLenum target, + size_t level, + const gl::Offset &destOffset, + const gl::Rectangle &sourceArea, + const gl::Framebuffer *source) override; + + gl::Error setStorage(GLenum target, + size_t levels, + GLenum internalFormat, + const gl::Extents &size) override; + + gl::Error setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) override; + + void bindTexImage(egl::Surface *surface) override; + void releaseTexImage() override; + + gl::Error setEGLImageTarget(GLenum target, egl::Image *image) override; + + gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) override; + + gl::ImageIndexIterator imageIterator() const override; + gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; + bool isValidIndex(const gl::ImageIndex &index) const override; + + protected: + void markAllImagesDirty() override; + + private: + gl::Error initializeStorage(bool renderTarget) override; + gl::Error createCompleteStorage(bool renderTarget, + TextureStorage **outTexStorage) const override; + gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage) override; + + gl::Error updateStorage() override; + void initMipmapsImages() override; + + bool isValidLevel(int level) const; + bool isLevelComplete(int level) const; + bool isImageComplete(const gl::ImageIndex &index) const override; + + gl::Error updateStorageLevel(int level); + + void redefineImage(size_t level, + GLenum internalformat, + const gl::Extents &size, + bool forceRelease); + + ImageD3D *mImage; +}; } #endif // LIBANGLE_RENDERER_D3D_TEXTURED3D_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp index 0598fb1a03b..b908b9842d8 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp @@ -289,7 +289,7 @@ gl::Error Blit11::initResources() vbDesc.ByteWidth = static_cast<unsigned int>(std::max(sizeof(d3d11::PositionLayerTexCoord3DVertex), sizeof(d3d11::PositionTexCoordVertex)) * - 6 * mRenderer->getRendererCaps().max3DTextureSize); + 6 * mRenderer->getNativeCaps().max3DTextureSize); vbDesc.Usage = D3D11_USAGE_DYNAMIC; vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp index 038753e3dca..c3603831b78 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp @@ -270,7 +270,8 @@ Buffer11::Buffer11(Renderer11 *renderer) mBufferStorages(BUFFER_USAGE_COUNT, nullptr), mConstantBufferStorageAdditionalSize(0), mMaxConstantBufferLruCount(0), - mReadUsageCount(0) + mReadUsageCount(0), + mSystemMemoryDeallocThreshold(0) { } @@ -491,21 +492,40 @@ gl::Error Buffer11::markTransformFeedbackUsage() return gl::NoError(); } +void Buffer11::updateSystemMemoryDeallocThreshold() +{ + // The following strategy was tuned on the Oort online benchmark (http://oortonline.gl/) + // as well as a custom microbenchmark (IndexConversionPerfTest.Run/index_range_d3d11) + + // First readback: 8 unmodified uses before we free system memory. + // After that, double the threshold each time until we reach the max. + if (mSystemMemoryDeallocThreshold == 0) + { + mSystemMemoryDeallocThreshold = 8; + } + else if (IsUnsignedMultiplicationSafe(mSystemMemoryDeallocThreshold, 2u)) + { + mSystemMemoryDeallocThreshold *= 2u; + } + else + { + mSystemMemoryDeallocThreshold = std::numeric_limits<unsigned int>::max(); + } +} + gl::Error Buffer11::markBufferUsage() { mReadUsageCount++; // Free the system memory storage if we decide it isn't being used very often. - const unsigned int usageLimit = 5; - - BufferStorage *&sysMemUsage = mBufferStorages[BUFFER_USAGE_SYSTEM_MEMORY]; - if (mReadUsageCount > usageLimit && sysMemUsage != nullptr) + BufferStorage *&sysMemStorage = mBufferStorages[BUFFER_USAGE_SYSTEM_MEMORY]; + if (sysMemStorage != nullptr && mReadUsageCount > mSystemMemoryDeallocThreshold) { BufferStorage *latestStorage = nullptr; ANGLE_TRY_RESULT(getLatestBufferStorage(), latestStorage); - if (latestStorage != sysMemUsage) + if (latestStorage != sysMemStorage) { - SafeDelete(sysMemUsage); + SafeDelete(sysMemStorage); } } @@ -652,14 +672,17 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getBufferStorage(BufferUs return newStorage; } -Buffer11::BufferStorage *Buffer11::allocateStorage(BufferUsage usage) const +Buffer11::BufferStorage *Buffer11::allocateStorage(BufferUsage usage) { switch (usage) { case BUFFER_USAGE_PIXEL_PACK: return new PackStorage(mRenderer); case BUFFER_USAGE_SYSTEM_MEMORY: + { + updateSystemMemoryDeallocThreshold(); return new SystemMemoryStorage(mRenderer); + } case BUFFER_USAGE_EMULATED_INDEXED_VERTEX: return new EmulatedIndexedStorage(mRenderer); case BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK: @@ -1047,7 +1070,7 @@ void Buffer11::NativeStorage::fillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, bufferDesc->ByteWidth = roundUp(bufferDesc->ByteWidth, 16u); bufferDesc->ByteWidth = std::min<UINT>(bufferDesc->ByteWidth, - static_cast<UINT>(renderer->getRendererCaps().maxUniformBlockSize)); + static_cast<UINT>(renderer->getNativeCaps().maxUniformBlockSize)); break; default: diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h index db73ca436a5..3b966b713ce 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h @@ -129,7 +129,8 @@ class Buffer11 : public BufferD3D gl::ErrorOrResult<BufferStorage *> getConstantBufferRangeStorage(GLintptr offset, GLsizeiptr size); - BufferStorage *allocateStorage(BufferUsage usage) const; + BufferStorage *allocateStorage(BufferUsage usage); + void updateSystemMemoryDeallocThreshold(); Renderer11 *mRenderer; size_t mSize; @@ -150,6 +151,7 @@ class Buffer11 : public BufferD3D std::map<DXGI_FORMAT, BufferSRVPair> mBufferResourceViews; unsigned int mReadUsageCount; + unsigned int mSystemMemoryDeallocThreshold; NotificationSet mStaticBufferDirtyCallbacks; NotificationSet mDirectBufferDirtyCallbacks; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp index da70970aa84..369797ac5f5 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp @@ -196,7 +196,8 @@ Clear11::~Clear11() SafeRelease(mRasterizerState); } -gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl::Framebuffer::Data &fboData) +gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, + const gl::FramebufferState &fboData) { const auto &colorAttachments = fboData.getColorAttachments(); const auto &drawBufferStates = fboData.getDrawBufferStates(); @@ -434,7 +435,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl // be a compatible clear type. // Bind all the render targets which need clearing - ASSERT(maskedClearRenderTargets.size() <= mRenderer->getRendererCaps().maxDrawBuffers); + ASSERT(maskedClearRenderTargets.size() <= mRenderer->getNativeCaps().maxDrawBuffers); std::vector<ID3D11RenderTargetView*> rtvs(maskedClearRenderTargets.size()); for (unsigned int i = 0; i < maskedClearRenderTargets.size(); i++) { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.h index 3ff73c85d16..1594027ec6f 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.h @@ -30,7 +30,8 @@ class Clear11 : angle::NonCopyable ~Clear11(); // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied. - gl::Error clearFramebuffer(const ClearParameters &clearParams, const gl::Framebuffer::Data &fboData); + gl::Error clearFramebuffer(const ClearParameters &clearParams, + const gl::FramebufferState &fboData); private: struct MaskedRenderTarget diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp new file mode 100644 index 00000000000..800eedfe400 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp @@ -0,0 +1,271 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Context11: +// D3D11-specific functionality associated with a GL Context. +// + +#include "libANGLE/renderer/d3d/d3d11/Context11.h" + +#include "libANGLE/renderer/d3d/CompilerD3D.h" +#include "libANGLE/renderer/d3d/ShaderD3D.h" +#include "libANGLE/renderer/d3d/ProgramD3D.h" +#include "libANGLE/renderer/d3d/RenderbufferD3D.h" +#include "libANGLE/renderer/d3d/SamplerD3D.h" +#include "libANGLE/renderer/d3d/TextureD3D.h" +#include "libANGLE/renderer/d3d/TransformFeedbackD3D.h" +#include "libANGLE/renderer/d3d/d3d11/Buffer11.h" +#include "libANGLE/renderer/d3d/d3d11/Fence11.h" +#include "libANGLE/renderer/d3d/d3d11/Framebuffer11.h" +#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" +#include "libANGLE/renderer/d3d/d3d11/StateManager11.h" +#include "libANGLE/renderer/d3d/d3d11/VertexArray11.h" + +namespace rx +{ + +Context11::Context11(const gl::ContextState &state, Renderer11 *renderer) + : ContextImpl(state), mRenderer(renderer) +{ +} + +Context11::~Context11() +{ +} + +gl::Error Context11::initialize() +{ + return gl::NoError(); +} + +CompilerImpl *Context11::createCompiler() +{ + if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3) + { + return new CompilerD3D(SH_HLSL_4_0_FL9_3_OUTPUT); + } + else + { + return new CompilerD3D(SH_HLSL_4_1_OUTPUT); + } +} + +ShaderImpl *Context11::createShader(const gl::ShaderState &data) +{ + return new ShaderD3D(data); +} + +ProgramImpl *Context11::createProgram(const gl::ProgramState &data) +{ + return new ProgramD3D(data, mRenderer); +} + +FramebufferImpl *Context11::createFramebuffer(const gl::FramebufferState &data) +{ + return new Framebuffer11(data, mRenderer); +} + +TextureImpl *Context11::createTexture(const gl::TextureState &state) +{ + switch (state.target) + { + case GL_TEXTURE_2D: + return new TextureD3D_2D(state, mRenderer); + case GL_TEXTURE_CUBE_MAP: + return new TextureD3D_Cube(state, mRenderer); + case GL_TEXTURE_3D: + return new TextureD3D_3D(state, mRenderer); + case GL_TEXTURE_2D_ARRAY: + return new TextureD3D_2DArray(state, mRenderer); + case GL_TEXTURE_EXTERNAL_OES: + return new TextureD3D_External(state, mRenderer); + default: + UNREACHABLE(); + } + + return nullptr; +} + +RenderbufferImpl *Context11::createRenderbuffer() +{ + return new RenderbufferD3D(mRenderer); +} + +BufferImpl *Context11::createBuffer() +{ + Buffer11 *buffer = new Buffer11(mRenderer); + mRenderer->onBufferCreate(buffer); + return buffer; +} + +VertexArrayImpl *Context11::createVertexArray(const gl::VertexArrayState &data) +{ + return new VertexArray11(data); +} + +QueryImpl *Context11::createQuery(GLenum type) +{ + return new Query11(mRenderer, type); +} + +FenceNVImpl *Context11::createFenceNV() +{ + return new FenceNV11(mRenderer); +} + +FenceSyncImpl *Context11::createFenceSync() +{ + return new FenceSync11(mRenderer); +} + +TransformFeedbackImpl *Context11::createTransformFeedback() +{ + return new TransformFeedbackD3D(); +} + +SamplerImpl *Context11::createSampler() +{ + return new SamplerD3D(); +} + +gl::Error Context11::flush() +{ + return mRenderer->flush(); +} + +gl::Error Context11::finish() +{ + return mRenderer->finish(); +} + +gl::Error Context11::drawArrays(GLenum mode, GLint first, GLsizei count) +{ + return mRenderer->genericDrawArrays(this, mode, first, count, 0); +} + +gl::Error Context11::drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) +{ + return mRenderer->genericDrawArrays(this, mode, first, count, instanceCount); +} + +gl::Error Context11::drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) +{ + return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); +} + +gl::Error Context11::drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) +{ + return mRenderer->genericDrawElements(this, mode, count, type, indices, instances, indexRange); +} + +gl::Error Context11::drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) +{ + return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); +} + +void Context11::notifyDeviceLost() +{ + mRenderer->notifyDeviceLost(); +} + +bool Context11::isDeviceLost() const +{ + return mRenderer->isDeviceLost(); +} + +bool Context11::testDeviceLost() +{ + return mRenderer->testDeviceLost(); +} + +bool Context11::testDeviceResettable() +{ + return mRenderer->testDeviceResettable(); +} + +std::string Context11::getVendorString() const +{ + return mRenderer->getVendorString(); +} + +std::string Context11::getRendererDescription() const +{ + return mRenderer->getRendererDescription(); +} + +void Context11::insertEventMarker(GLsizei length, const char *marker) +{ + mRenderer->insertEventMarker(length, marker); +} + +void Context11::pushGroupMarker(GLsizei length, const char *marker) +{ + mRenderer->pushGroupMarker(length, marker); +} + +void Context11::popGroupMarker() +{ + mRenderer->popGroupMarker(); +} + +void Context11::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) +{ + mRenderer->getStateManager()->syncState(state, dirtyBits); +} + +GLint Context11::getGPUDisjoint() +{ + return mRenderer->getGPUDisjoint(); +} + +GLint64 Context11::getTimestamp() +{ + return mRenderer->getTimestamp(); +} + +void Context11::onMakeCurrent(const gl::ContextState &data) +{ + mRenderer->getStateManager()->onMakeCurrent(data); +} + +const gl::Caps &Context11::getNativeCaps() const +{ + return mRenderer->getNativeCaps(); +} + +const gl::TextureCapsMap &Context11::getNativeTextureCaps() const +{ + return mRenderer->getNativeTextureCaps(); +} + +const gl::Extensions &Context11::getNativeExtensions() const +{ + return mRenderer->getNativeExtensions(); +} + +const gl::Limitations &Context11::getNativeLimitations() const +{ + return mRenderer->getNativeLimitations(); +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h new file mode 100644 index 00000000000..2ee3576669a --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h @@ -0,0 +1,127 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Context11: +// D3D11-specific functionality associated with a GL Context. +// + +#ifndef LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_ +#define LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_ + +#include "libANGLE/renderer/ContextImpl.h" + +namespace rx +{ +class Renderer11; + +class Context11 : public ContextImpl +{ + public: + Context11(const gl::ContextState &state, Renderer11 *renderer); + ~Context11() override; + + gl::Error initialize() override; + + // Shader creation + CompilerImpl *createCompiler() override; + ShaderImpl *createShader(const gl::ShaderState &data) override; + ProgramImpl *createProgram(const gl::ProgramState &data) override; + + // Framebuffer creation + FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; + + // Texture creation + TextureImpl *createTexture(const gl::TextureState &state) override; + + // Renderbuffer creation + RenderbufferImpl *createRenderbuffer() override; + + // Buffer creation + BufferImpl *createBuffer() override; + + // Vertex Array creation + VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; + + // Query and Fence creation + QueryImpl *createQuery(GLenum type) override; + FenceNVImpl *createFenceNV() override; + FenceSyncImpl *createFenceSync() override; + + // Transform Feedback creation + TransformFeedbackImpl *createTransformFeedback() override; + + // Sampler object creation + SamplerImpl *createSampler() override; + + // Flush and finish. + gl::Error flush() override; + gl::Error finish() override; + + // Drawing methods. + gl::Error drawArrays(GLenum mode, GLint first, GLsizei count) override; + gl::Error drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) override; + + gl::Error drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) override; + gl::Error drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) override; + gl::Error drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) override; + + // TODO(jmadill): Investigate proper impl methods for this. + void notifyDeviceLost() override; + bool isDeviceLost() const override; + bool testDeviceLost() override; + bool testDeviceResettable() override; + + // Vendor and description strings. + std::string getVendorString() const override; + std::string getRendererDescription() const override; + + // Debug markers. + void insertEventMarker(GLsizei length, const char *marker) override; + void pushGroupMarker(GLsizei length, const char *marker) override; + void popGroupMarker() override; + + // State sync with dirty bits. + void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override; + + // Disjoint timer queries + GLint getGPUDisjoint() override; + GLint64 getTimestamp() override; + + // Context switching + void onMakeCurrent(const gl::ContextState &data) override; + + // Caps queries + const gl::Caps &getNativeCaps() const override; + const gl::TextureCapsMap &getNativeTextureCaps() const override; + const gl::Extensions &getNativeExtensions() const override; + const gl::Limitations &getNativeLimitations() const override; + + Renderer11 *getRenderer() const { return mRenderer; } + + private: + Renderer11 *mRenderer; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp index 70963bf7f49..0d26f9029a2 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp @@ -80,7 +80,7 @@ void UpdateCachedRenderTarget(const gl::FramebufferAttachment *attachment, } } // anonymous namespace -Framebuffer11::Framebuffer11(const gl::Framebuffer::Data &data, Renderer11 *renderer) +Framebuffer11::Framebuffer11(const gl::FramebufferState &data, Renderer11 *renderer) : FramebufferD3D(data, renderer), mRenderer(renderer), mCachedDepthStencilRenderTarget(nullptr) { ASSERT(mRenderer != nullptr); @@ -117,7 +117,7 @@ Framebuffer11::~Framebuffer11() gl::Error Framebuffer11::invalidateSwizzles() const { - for (const auto &colorAttachment : mData.getColorAttachments()) + for (const auto &colorAttachment : mState.getColorAttachments()) { if (colorAttachment.isAttached()) { @@ -129,13 +129,13 @@ gl::Error Framebuffer11::invalidateSwizzles() const } } - gl::Error error = InvalidateAttachmentSwizzles(mData.getDepthAttachment()); + gl::Error error = InvalidateAttachmentSwizzles(mState.getDepthAttachment()); if (error.isError()) { return error; } - error = InvalidateAttachmentSwizzles(mData.getStencilAttachment()); + error = InvalidateAttachmentSwizzles(mState.getStencilAttachment()); if (error.isError()) { return error; @@ -144,12 +144,12 @@ gl::Error Framebuffer11::invalidateSwizzles() const return gl::Error(GL_NO_ERROR); } -gl::Error Framebuffer11::clear(const gl::Data &data, const ClearParameters &clearParams) +gl::Error Framebuffer11::clearImpl(ContextImpl *context, const ClearParameters &clearParams) { Clear11 *clearer = mRenderer->getClearer(); gl::Error error(GL_NO_ERROR); - const gl::FramebufferAttachment *colorAttachment = mData.getFirstColorAttachment(); + const gl::FramebufferAttachment *colorAttachment = mState.getFirstColorAttachment(); if (clearParams.scissorEnabled == true && colorAttachment != nullptr && UsePresentPathFast(mRenderer, colorAttachment)) { @@ -161,11 +161,11 @@ gl::Error Framebuffer11::clear(const gl::Data &data, const ClearParameters &clea presentPathFastClearParams.scissor.y = framebufferSize.height - presentPathFastClearParams.scissor.y - presentPathFastClearParams.scissor.height; - error = clearer->clearFramebuffer(presentPathFastClearParams, mData); + error = clearer->clearFramebuffer(presentPathFastClearParams, mState); } else { - error = clearer->clearFramebuffer(clearParams, mData); + error = clearer->clearFramebuffer(clearParams, mState); } if (error.isError()) @@ -242,9 +242,9 @@ gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments, colorAttachmentID = attachments[i] - GL_COLOR_ATTACHMENT0; } - if (mData.getColorAttachment(static_cast<unsigned int>(colorAttachmentID))) + if (mState.getColorAttachment(static_cast<unsigned int>(colorAttachmentID))) { - error = mData.getColorAttachment(static_cast<unsigned int>(colorAttachmentID)) + error = mState.getColorAttachment(static_cast<unsigned int>(colorAttachmentID)) ->getRenderTarget(&renderTarget); if (error.isError()) { @@ -275,7 +275,7 @@ gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments, discardDepth = foundDepth; // Don't bother discarding the stencil buffer if the depth buffer will already do it - discardStencil = foundStencil && (!discardDepth || mData.getDepthAttachment() == nullptr); + discardStencil = foundStencil && (!discardDepth || mState.getDepthAttachment() == nullptr); } else { @@ -283,17 +283,18 @@ gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments, // attachments list does not include DEPTH_STENCIL_ATTACHMENT or both DEPTH_ATTACHMENT and // STENCIL_ATTACHMENT, then only the specified portion of every pixel in the subregion of pixels // of the DEPTH_STENCIL buffer may be invalidated, and the other portion must be preserved. - discardDepth = (foundDepth && foundStencil) || (foundDepth && (mData.getStencilAttachment() == nullptr)); - discardStencil = (foundStencil && (mData.getDepthAttachment() == nullptr)); + discardDepth = (foundDepth && foundStencil) || + (foundDepth && (mState.getStencilAttachment() == nullptr)); + discardStencil = (foundStencil && (mState.getDepthAttachment() == nullptr)); } - if (discardDepth && mData.getDepthAttachment()) + if (discardDepth && mState.getDepthAttachment()) { RenderTarget11 *renderTarget = nullptr; ID3D11View *depthView = nullptr; gl::Error error(GL_NO_ERROR); - error = mData.getDepthAttachment()->getRenderTarget(&renderTarget); + error = mState.getDepthAttachment()->getRenderTarget(&renderTarget); if (error.isError()) { return error; @@ -307,13 +308,13 @@ gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments, } } - if (discardStencil && mData.getStencilAttachment()) + if (discardStencil && mState.getStencilAttachment()) { RenderTarget11 *renderTarget = nullptr; ID3D11View *stencilView = nullptr; gl::Error error(GL_NO_ERROR); - error = mData.getStencilAttachment()->getRenderTarget(&renderTarget); + error = mState.getStencilAttachment()->getRenderTarget(&renderTarget); if (error.isError()) { return error; @@ -343,7 +344,7 @@ gl::Error Framebuffer11::readPixelsImpl(const gl::Rectangle &area, const gl::PixelPackState &pack, uint8_t *pixels) const { - const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment(); + const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment(); ASSERT(readAttachment); gl::Buffer *packBuffer = pack.pixelBuffer.get(); @@ -367,9 +368,14 @@ gl::Error Framebuffer11::readPixelsImpl(const gl::Rectangle &area, static_cast<GLuint>(outputPitch), pack, pixels); } -gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, - bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, - const gl::Framebuffer *sourceFramebuffer) +gl::Error Framebuffer11::blitImpl(const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + const gl::Rectangle *scissor, + bool blitRenderTarget, + bool blitDepth, + bool blitStencil, + GLenum filter, + const gl::Framebuffer *sourceFramebuffer) { if (blitRenderTarget) { @@ -384,8 +390,8 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang } ASSERT(readRenderTarget); - const auto &colorAttachments = mData.getColorAttachments(); - const auto &drawBufferStates = mData.getDrawBufferStates(); + const auto &colorAttachments = mState.getColorAttachments(); + const auto &drawBufferStates = mState.getDrawBufferStates(); for (size_t colorAttachment = 0; colorAttachment < colorAttachments.size(); colorAttachment++) { @@ -444,7 +450,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang } ASSERT(readRenderTarget); - const gl::FramebufferAttachment *drawBuffer = mData.getDepthOrStencilAttachment(); + const gl::FramebufferAttachment *drawBuffer = mState.getDepthOrStencilAttachment(); ASSERT(drawBuffer); RenderTargetD3D *drawRenderTarget = nullptr; @@ -480,14 +486,14 @@ GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTargetD3D *rende void Framebuffer11::updateColorRenderTarget(size_t colorIndex) { - UpdateCachedRenderTarget(mData.getColorAttachment(colorIndex), + UpdateCachedRenderTarget(mState.getColorAttachment(colorIndex), mCachedColorRenderTargets[colorIndex], mColorRenderTargetsDirty[colorIndex]); } void Framebuffer11::updateDepthStencilRenderTarget() { - UpdateCachedRenderTarget(mData.getDepthOrStencilAttachment(), mCachedDepthStencilRenderTarget, + UpdateCachedRenderTarget(mState.getDepthOrStencilAttachment(), mCachedDepthStencilRenderTarget, mDepthStencilRenderTargetDirty); } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h index 0f0cbd6f095..0cf07da22db 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h @@ -19,7 +19,7 @@ class Renderer11; class Framebuffer11 : public FramebufferD3D { public: - Framebuffer11(const gl::Framebuffer::Data &data, Renderer11 *renderer); + Framebuffer11(const gl::FramebufferState &data, Renderer11 *renderer); virtual ~Framebuffer11(); gl::Error discard(size_t count, const GLenum *attachments) override; @@ -48,7 +48,7 @@ class Framebuffer11 : public FramebufferD3D void syncInternalState() const; private: - gl::Error clear(const gl::Data &data, const ClearParameters &clearParams) override; + gl::Error clearImpl(ContextImpl *context, const ClearParameters &clearParams) override; gl::Error readPixelsImpl(const gl::Rectangle &area, GLenum format, @@ -57,9 +57,14 @@ class Framebuffer11 : public FramebufferD3D const gl::PixelPackState &pack, uint8_t *pixels) const override; - gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, - bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, - const gl::Framebuffer *sourceFramebuffer) override; + gl::Error blitImpl(const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + const gl::Rectangle *scissor, + bool blitRenderTarget, + bool blitDepth, + bool blitStencil, + GLenum filter, + const gl::Framebuffer *sourceFramebuffer) override; gl::Error invalidateBase(size_t count, const GLenum *attachments, bool useEXTBehavior) const; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp index 02ae26de646..89d5dc67676 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp @@ -13,6 +13,7 @@ #include "common/utilities.h" #include "libANGLE/Program.h" #include "libANGLE/VertexAttribute.h" +#include "libANGLE/VertexArray.h" #include "libANGLE/renderer/d3d/IndexDataManager.h" #include "libANGLE/renderer/d3d/ProgramD3D.h" #include "libANGLE/renderer/d3d/VertexDataManager.h" diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h deleted file mode 100644 index f28ce4f8275..00000000000 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h +++ /dev/null @@ -1,91 +0,0 @@ -// -// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// NativeWindow.h: Defines NativeWindow, a class for managing and -// performing operations on an EGLNativeWindowType. -// It is used for HWND (Desktop Windows) and IInspectable objects -//(Windows Store Applications). - -#ifndef LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW_H_ -#define LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW_H_ - -#include "common/debug.h" -#include "common/platform.h" - -#include <EGL/eglplatform.h> -#include "libANGLE/Config.h" - -// DXGISwapChain and DXGIFactory are typedef'd to specific required -// types. The HWND NativeWindow implementation requires IDXGISwapChain -// and IDXGIFactory and the Windows Store NativeWindow -// implementation requires IDXGISwapChain1 and IDXGIFactory2. -#if defined(ANGLE_ENABLE_WINDOWS_STORE) -typedef IDXGISwapChain1 DXGISwapChain; -typedef IDXGIFactory2 DXGIFactory; - -#include <wrl.h> -#include <wrl/wrappers/corewrappers.h> -#include <windows.applicationmodel.core.h> -#include <memory> - -namespace rx -{ -class InspectableNativeWindow; -} - -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; - -#else -typedef IDXGISwapChain DXGISwapChain; -typedef IDXGIFactory DXGIFactory; -#endif - -typedef interface IDCompositionDevice IDCompositionDevice; -typedef interface IDCompositionTarget IDCompositionTarget; -typedef interface IDCompositionVisual IDCompositionVisual; - -namespace rx -{ - -class NativeWindow -{ - public: - explicit NativeWindow(EGLNativeWindowType window, - const egl::Config *config, - bool directComposition); - - ~NativeWindow(); - bool initialize(); - bool getClientRect(LPRECT rect); - bool isIconic(); - static bool isValidNativeWindow(EGLNativeWindowType window); - - HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory, - DXGI_FORMAT format, UINT width, UINT height, - DXGISwapChain** swapChain); - - inline EGLNativeWindowType getNativeWindow() const { return mWindow; } - - void commitChange(); - - private: - EGLNativeWindowType mWindow; - - bool mDirectComposition; - IDCompositionDevice *mDevice; - IDCompositionTarget *mCompositionTarget; - IDCompositionVisual *mVisual; - const egl::Config *mConfig; -#if defined(ANGLE_ENABLE_WINDOWS_STORE) - std::shared_ptr<InspectableNativeWindow> mImpl; -#endif - -}; - -} - -#endif // LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow11.h new file mode 100644 index 00000000000..aad2ca71a59 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow11.h @@ -0,0 +1,37 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindow11.h: Defines NativeWindow11, a class for managing and performing operations on an +// EGLNativeWindowType for the D3D11 renderer. + +#ifndef LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW11_H_ +#define LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW11_H_ + +#include "common/debug.h" +#include "common/platform.h" + +#include "libANGLE/Config.h" +#include "libANGLE/renderer/d3d/NativeWindowD3D.h" + +namespace rx +{ + +class NativeWindow11 : public NativeWindowD3D +{ + public: + NativeWindow11(EGLNativeWindowType window) : NativeWindowD3D(window) {} + + virtual HRESULT createSwapChain(ID3D11Device *device, + IDXGIFactory *factory, + DXGI_FORMAT format, + UINT width, + UINT height, + IDXGISwapChain **swapChain) = 0; + virtual void commitChange() = 0; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW11_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp index dad5f8ca72c..861950d8750 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp @@ -33,6 +33,9 @@ GLuint64 MergeQueryResults(GLenum type, GLuint64 currentResult, GLuint64 newResu case GL_TIMESTAMP_EXT: return newResult; + case GL_COMMANDS_COMPLETED_CHROMIUM: + return newResult; + default: UNREACHABLE(); return 0; @@ -142,9 +145,10 @@ gl::Error Query11::pause() if (mActiveQuery->query != nullptr) { ID3D11DeviceContext *context = mRenderer->getDeviceContext(); + GLenum queryType = getType(); // If we are doing time elapsed query the end timestamp - if (getType() == GL_TIME_ELAPSED_EXT) + if (queryType == GL_TIME_ELAPSED_EXT) { context->End(mActiveQuery->endTimestamp); } @@ -168,8 +172,11 @@ gl::Error Query11::resume() return error; } + GLenum queryType = getType(); + D3D11_QUERY d3dQueryType = gl_d3d11::ConvertQueryType(queryType); + D3D11_QUERY_DESC queryDesc; - queryDesc.Query = gl_d3d11::ConvertQueryType(getType()); + queryDesc.Query = d3dQueryType; queryDesc.MiscFlags = 0; ID3D11Device *device = mRenderer->getDevice(); @@ -182,7 +189,7 @@ gl::Error Query11::resume() } // If we are doing time elapsed we also need a query to actually query the timestamp - if (getType() == GL_TIME_ELAPSED_EXT) + if (queryType == GL_TIME_ELAPSED_EXT) { D3D11_QUERY_DESC desc; desc.Query = D3D11_QUERY_TIMESTAMP; @@ -203,10 +210,13 @@ gl::Error Query11::resume() ID3D11DeviceContext *context = mRenderer->getDeviceContext(); - context->Begin(mActiveQuery->query); + if (d3dQueryType != D3D11_QUERY_EVENT) + { + context->Begin(mActiveQuery->query); + } // If we are doing time elapsed, query the begin timestamp - if (getType() == GL_TIME_ELAPSED_EXT) + if (queryType == GL_TIME_ELAPSED_EXT) { context->End(mActiveQuery->beginTimestamp); } @@ -358,6 +368,28 @@ gl::Error Query11::testQuery(QueryState *queryState) } break; + case GL_COMMANDS_COMPLETED_CHROMIUM: + { + ASSERT(queryState->query); + BOOL completed = 0; + HRESULT result = + context->GetData(queryState->query, &completed, sizeof(completed), 0); + if (FAILED(result)) + { + return gl::Error(GL_OUT_OF_MEMORY, + "Failed to get the data of an internal query, result: 0x%X.", + result); + } + + if (result == S_OK) + { + queryState->finished = true; + ASSERT(completed == TRUE); + mResult = (completed == TRUE) ? GL_TRUE : GL_FALSE; + } + } + break; + default: UNREACHABLE(); break; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 424aa27ca04..5b7988bfb78 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -25,6 +25,7 @@ #include "libANGLE/renderer/d3d/d3d11/Blit11.h" #include "libANGLE/renderer/d3d/d3d11/Buffer11.h" #include "libANGLE/renderer/d3d/d3d11/Clear11.h" +#include "libANGLE/renderer/d3d/d3d11/Context11.h" #include "libANGLE/renderer/d3d/d3d11/dxgi_support_table.h" #include "libANGLE/renderer/d3d/d3d11/Fence11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h" @@ -36,7 +37,7 @@ #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/ShaderExecutable11.h" -#include "libANGLE/renderer/d3d/d3d11/Stream11.h" +#include "libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h" #include "libANGLE/renderer/d3d/d3d11/SwapChain11.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/TextureStorage11.h" @@ -58,6 +59,12 @@ #include "libANGLE/Surface.h" #include "third_party/trace_event/trace_event.h" +#ifdef ANGLE_ENABLE_WINDOWS_STORE +#include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h" +#else +#include "libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h" +#endif + // Include the D3D9 debug annotator header for use by the desktop D3D11 renderer // because the D3D11 interface method ID3DUserDefinedAnnotation::GetStatus // doesn't work with the Graphics Diagnostics tools in Visual Studio 2013. @@ -362,6 +369,22 @@ void GetTriFanIndices(const GLvoid *indices, } } +int GetWrapBits(GLenum wrap) +{ + switch (wrap) + { + case GL_CLAMP_TO_EDGE: + return 0x1; + case GL_REPEAT: + return 0x2; + case GL_MIRRORED_REPEAT: + return 0x3; + default: + UNREACHABLE(); + return 0; + } +} + } // anonymous namespace Renderer11::Renderer11(egl::Display *display) @@ -802,7 +825,7 @@ void Renderer11::initializeDevice() ASSERT(!mPixelTransfer); mPixelTransfer = new PixelTransfer11(this); - const gl::Caps &rendererCaps = getRendererCaps(); + const gl::Caps &rendererCaps = getNativeCaps(); mStateManager.initialize(rendererCaps); @@ -903,8 +926,8 @@ egl::ConfigSet Renderer11::generateConfigs() const GL_DEPTH_COMPONENT16, }; - const gl::Caps &rendererCaps = getRendererCaps(); - const gl::TextureCapsMap &rendererTextureCaps = getRendererTextureCaps(); + const gl::Caps &rendererCaps = getNativeCaps(); + const gl::TextureCapsMap &rendererTextureCaps = getNativeTextureCaps(); const EGLint optimalSurfaceOrientation = mPresentPathFastEnabled ? 0 : EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE; @@ -1026,7 +1049,14 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions outExtensions->glTextureCubemapImage = true; outExtensions->glRenderbufferImage = true; - outExtensions->stream = true; + outExtensions->stream = true; + outExtensions->streamConsumerGLTexture = true; + outExtensions->streamConsumerGLTextureYUV = true; + // Not all D3D11 devices support NV12 textures + if (getNV12TextureSupport()) + { + outExtensions->streamProducerD3DTextureNV12 = true; + } outExtensions->flexibleSurfaceCompatibility = true; outExtensions->directComposition = !!mDCompModule; @@ -1081,26 +1111,37 @@ gl::Error Renderer11::finish() return gl::Error(GL_NO_ERROR); } -SwapChainD3D *Renderer11::createSwapChain(NativeWindow nativeWindow, +bool Renderer11::isValidNativeWindow(EGLNativeWindowType window) const +{ +#ifdef ANGLE_ENABLE_WINDOWS_STORE + return NativeWindow11WinRT::IsValidNativeWindow(window); +#else + return NativeWindow11Win32::IsValidNativeWindow(window); +#endif +} + +NativeWindowD3D *Renderer11::createNativeWindow(EGLNativeWindowType window, + const egl::Config *config, + const egl::AttributeMap &attribs) const +{ +#ifdef ANGLE_ENABLE_WINDOWS_STORE + UNUSED_VARIABLE(attribs); + return new NativeWindow11WinRT(window, config->alphaSize > 0); +#else + return new NativeWindow11Win32( + window, config->alphaSize > 0, + attribs.get(EGL_DIRECT_COMPOSITION_ANGLE, EGL_FALSE) == EGL_TRUE); +#endif +} + +SwapChainD3D *Renderer11::createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) { - return new SwapChain11(this, nativeWindow, shareHandle, backBufferFormat, depthBufferFormat, - orientation); -} - -CompilerImpl *Renderer11::createCompiler() -{ - if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3) - { - return new CompilerD3D(SH_HLSL_4_0_FL9_3_OUTPUT); - } - else - { - return new CompilerD3D(SH_HLSL_4_1_OUTPUT); - } + return new SwapChain11(this, GetAs<NativeWindow11>(nativeWindow), shareHandle, backBufferFormat, + depthBufferFormat, orientation); } void *Renderer11::getD3DDevice() @@ -1164,7 +1205,7 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, if (type == gl::SAMPLER_PIXEL) { - ASSERT(static_cast<unsigned int>(index) < getRendererCaps().maxTextureImageUnits); + ASSERT(static_cast<unsigned int>(index) < getNativeCaps().maxTextureImageUnits); if (mForceSetPixelSamplerStates[index] || memcmp(&samplerState, &mCurPixelSamplerStates[index], sizeof(gl::SamplerState)) != 0) @@ -1188,7 +1229,7 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, } else if (type == gl::SAMPLER_VERTEX) { - ASSERT(static_cast<unsigned int>(index) < getRendererCaps().maxVertexTextureImageUnits); + ASSERT(static_cast<unsigned int>(index) < getNativeCaps().maxVertexTextureImageUnits); if (mForceSetVertexSamplerStates[index] || memcmp(&samplerState, &mCurVertexSamplerStates[index], sizeof(gl::SamplerState)) != 0) @@ -1213,8 +1254,7 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, else UNREACHABLE(); ASSERT(metadata != nullptr); - metadata->update(index, texture->getBaseLevel(), - texture->getInternalFormat(texture->getTarget(), texture->getBaseLevel())); + metadata->update(index, *texture); return gl::Error(GL_NO_ERROR); } @@ -1239,15 +1279,7 @@ gl::Error Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *t TextureStorage11 *storage11 = GetAs<TextureStorage11>(texStorage); - // Make sure to add the level offset for our tiny compressed texture workaround - gl::TextureState textureState = texture->getTextureState(); - textureState.baseLevel += storage11->getTopLevel(); - - error = storage11->getSRV(textureState, &textureSRV); - if (error.isError()) - { - return error; - } + ANGLE_TRY(storage11->getSRV(texture->getTextureState(), &textureSRV)); // If we get NULL back from getSRV here, something went wrong in the texture class and we're unexpectedly // missing the shader resource view @@ -1256,15 +1288,17 @@ gl::Error Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *t textureImpl->resetDirty(); } - ASSERT((type == gl::SAMPLER_PIXEL && static_cast<unsigned int>(index) < getRendererCaps().maxTextureImageUnits) || - (type == gl::SAMPLER_VERTEX && static_cast<unsigned int>(index) < getRendererCaps().maxVertexTextureImageUnits)); + ASSERT((type == gl::SAMPLER_PIXEL && + static_cast<unsigned int>(index) < getNativeCaps().maxTextureImageUnits) || + (type == gl::SAMPLER_VERTEX && + static_cast<unsigned int>(index) < getNativeCaps().maxVertexTextureImageUnits)); mStateManager.setShaderResource(type, index, textureSRV); return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::setUniformBuffers(const gl::Data &data, +gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, const std::vector<GLint> &vertexUniformBuffers, const std::vector<GLint> &fragmentUniformBuffers) { @@ -1415,7 +1449,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::Data &data, return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::updateState(const gl::Data &data, GLenum drawMode) +gl::Error Renderer11::updateState(const gl::ContextState &data, GLenum drawMode) { // Applies the render target surface, depth stencil surface, viewport rectangle and // scissor rectangle to the renderer @@ -1466,11 +1500,6 @@ gl::Error Renderer11::updateState(const gl::Data &data, GLenum drawMode) return error; } -void Renderer11::syncState(const gl::State &state, const gl::State::DirtyBits &bitmask) -{ - mStateManager.syncState(state, bitmask); -} - bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize) { D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; @@ -1565,7 +1594,7 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state, return gl::NoError(); } -gl::Error Renderer11::applyIndexBuffer(const gl::Data &data, +gl::Error Renderer11::applyIndexBuffer(const gl::ContextState &data, const GLvoid *indices, GLsizei count, GLenum mode, @@ -1687,7 +1716,7 @@ gl::Error Renderer11::applyTransformFeedbackBuffers(const gl::State &state) return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::drawArraysImpl(const gl::Data &data, +gl::Error Renderer11::drawArraysImpl(const gl::ContextState &data, GLenum mode, GLint startVertex, GLsizei count, @@ -1813,7 +1842,7 @@ gl::Error Renderer11::drawArraysImpl(const gl::Data &data, return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::drawElementsImpl(const gl::Data &data, +gl::Error Renderer11::drawElementsImpl(const gl::ContextState &data, const TranslatedIndexData &indexInfo, GLenum mode, GLsizei count, @@ -1888,7 +1917,7 @@ gl::Error Renderer11::drawElementsImpl(const gl::Data &data, return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::drawLineLoop(const gl::Data &data, +gl::Error Renderer11::drawLineLoop(const gl::ContextState &data, GLsizei count, GLenum type, const GLvoid *indexPointer, @@ -1992,7 +2021,7 @@ gl::Error Renderer11::drawLineLoop(const gl::Data &data, return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::drawTriangleFan(const gl::Data &data, +gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, GLsizei count, GLenum type, const GLvoid *indices, @@ -2095,7 +2124,7 @@ gl::Error Renderer11::drawTriangleFan(const gl::Data &data, return gl::Error(GL_NO_ERROR); } -gl::Error Renderer11::applyShadersImpl(const gl::Data &data, GLenum drawMode) +gl::Error Renderer11::applyShadersImpl(const gl::ContextState &data, GLenum drawMode) { ProgramD3D *programD3D = GetImplAs<ProgramD3D>(data.state->getProgram()); const auto &inputLayout = programD3D->getCachedInputLayout(); @@ -2354,21 +2383,21 @@ void Renderer11::SamplerMetadataD3D11::initData(unsigned int samplerCount) mSamplerMetadata.resize(samplerCount); } -void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, - unsigned int baseLevel, - GLenum internalFormat) +void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, const gl::Texture &texture) { - if (mSamplerMetadata[samplerIndex].parameters[0] != static_cast<int>(baseLevel)) + unsigned int baseLevel = texture.getTextureState().getEffectiveBaseLevel(); + GLenum internalFormat = texture.getInternalFormat(texture.getTarget(), baseLevel); + if (mSamplerMetadata[samplerIndex].baseLevel != static_cast<int>(baseLevel)) { - mSamplerMetadata[samplerIndex].parameters[0] = static_cast<int>(baseLevel); - mDirty = true; + mSamplerMetadata[samplerIndex].baseLevel = static_cast<int>(baseLevel); + mDirty = true; } - // internalFormatBits == 0 means a 32-bit texture in the case of integer textures. In the case - // of non-integer textures, internalFormatBits is meaningless. We avoid updating the constant - // buffer unnecessarily by changing the data only in case the texture is an integer texture and - // the value has changed. - bool needInternalFormatBits = false; + // Some metadata is needed only for integer textures. We avoid updating the constant buffer + // unnecessarily by changing the data only in case the texture is an integer texture and + // the values have changed. + bool needIntegerTextureMetadata = false; + // internalFormatBits == 0 means a 32-bit texture in the case of integer textures. int internalFormatBits = 0; switch (internalFormat) { @@ -2380,7 +2409,7 @@ void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, case GL_RG32UI: case GL_R32I: case GL_R32UI: - needInternalFormatBits = true; + needIntegerTextureMetadata = true; break; case GL_RGBA16I: case GL_RGBA16UI: @@ -2390,7 +2419,7 @@ void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, case GL_RG16UI: case GL_R16I: case GL_R16UI: - needInternalFormatBits = true; + needIntegerTextureMetadata = true; internalFormatBits = 16; break; case GL_RGBA8I: @@ -2401,21 +2430,34 @@ void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, case GL_RG8UI: case GL_R8I: case GL_R8UI: - needInternalFormatBits = true; + needIntegerTextureMetadata = true; internalFormatBits = 8; break; case GL_RGB10_A2UI: - needInternalFormatBits = true; + needIntegerTextureMetadata = true; internalFormatBits = 10; break; default: break; } - if (needInternalFormatBits && - mSamplerMetadata[samplerIndex].parameters[1] != internalFormatBits) + if (needIntegerTextureMetadata) { - mSamplerMetadata[samplerIndex].parameters[1] = internalFormatBits; - mDirty = true; + if (mSamplerMetadata[samplerIndex].internalFormatBits != internalFormatBits) + { + mSamplerMetadata[samplerIndex].internalFormatBits = internalFormatBits; + mDirty = true; + } + // Pack the wrap values into one integer so we can fit all the metadata in one 4-integer + // vector. + GLenum wrapS = texture.getWrapS(); + GLenum wrapT = texture.getWrapT(); + GLenum wrapR = texture.getWrapR(); + int wrapModes = GetWrapBits(wrapS) | (GetWrapBits(wrapT) << 2) | (GetWrapBits(wrapR) << 4); + if (mSamplerMetadata[samplerIndex].wrapModes != wrapModes) + { + mSamplerMetadata[samplerIndex].wrapModes = wrapModes; + mDirty = true; + } } } @@ -2759,7 +2801,7 @@ bool Renderer11::getShareHandleSupport() const // We only currently support share handles with BGRA surfaces, because // chrome needs BGRA. Once chrome fixes this, we should always support them. - if (!getRendererExtensions().textureFormatBGRA8888) + if (!getNativeExtensions().textureFormatBGRA8888) { mSupportsShareHandles = false; return false; @@ -2819,6 +2861,18 @@ bool Renderer11::getShareHandleSupport() const return true; } +bool Renderer11::getNV12TextureSupport() const +{ + HRESULT result; + UINT formatSupport; + result = mDevice->CheckFormatSupport(DXGI_FORMAT_NV12, &formatSupport); + if (result == E_FAIL) + { + return false; + } + return (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0; +} + int Renderer11::getMajorShaderModel() const { switch (mRenderer11DeviceCaps.featureLevel) @@ -3092,7 +3146,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G { const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(format, mRenderer11DeviceCaps); - const gl::TextureCaps &textureCaps = getRendererTextureCaps().get(format); + const gl::TextureCaps &textureCaps = getNativeTextureCaps().get(format); GLuint supportedSamples = textureCaps.getNearestSamples(samples); if (width > 0 && height > 0) @@ -3283,21 +3337,6 @@ gl::Error Renderer11::createRenderTargetCopy(RenderTargetD3D *source, RenderTarg return gl::Error(GL_NO_ERROR); } -FramebufferImpl *Renderer11::createFramebuffer(const gl::Framebuffer::Data &data) -{ - return new Framebuffer11(data, this); -} - -ShaderImpl *Renderer11::createShader(const gl::Shader::Data &data) -{ - return new ShaderD3D(data); -} - -ProgramImpl *Renderer11::createProgram(const gl::Program::Data &data) -{ - return new ProgramD3D(data, this); -} - gl::Error Renderer11::loadExecutable(const void *function, size_t length, ShaderType type, @@ -3494,46 +3533,16 @@ IndexBuffer *Renderer11::createIndexBuffer() return new IndexBuffer11(this); } -BufferImpl *Renderer11::createBuffer() +StreamProducerImpl *Renderer11::createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) { - Buffer11 *buffer = new Buffer11(this); - mAliveBuffers.insert(buffer); - return buffer; -} - -VertexArrayImpl *Renderer11::createVertexArray(const gl::VertexArray::Data &data) -{ - return new VertexArray11(data); -} - -QueryImpl *Renderer11::createQuery(GLenum type) -{ - return new Query11(this, type); -} - -FenceNVImpl *Renderer11::createFenceNV() -{ - return new FenceNV11(this); -} - -FenceSyncImpl *Renderer11::createFenceSync() -{ - return new FenceSync11(this); -} - -TransformFeedbackImpl* Renderer11::createTransformFeedback() -{ - return new TransformFeedbackD3D(); -} - -StreamImpl *Renderer11::createStream(const egl::AttributeMap &attribs) -{ - return new Stream11(this); + return new StreamProducerNV12(this); } bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const { - ASSERT(getRendererExtensions().pixelBufferObject); + ASSERT(getNativeExtensions().pixelBufferObject); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat); const d3d11::TextureFormat &d3d11FormatInfo = d3d11::GetTextureFormatInfo(internalFormat, mRenderer11DeviceCaps); @@ -3562,6 +3571,13 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const return false; } + // Buffer SRV creation in this format was not working on Windows 10, repro at least on Intel + // and NVIDIA. + if (internalFormat == GL_RGB5_A1) + { + return false; + } + return true; } @@ -3615,6 +3631,13 @@ TextureStorage *Renderer11::createTextureStorageEGLImage(EGLImageD3D *eglImage) return new TextureStorage11_EGLImage(this, eglImage); } +TextureStorage *Renderer11::createTextureStorageExternal( + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) +{ + return new TextureStorage11_External(this, stream, desc); +} + TextureStorage *Renderer11::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly) { return new TextureStorage11_2D(this, internalformat, renderTarget, width, height, levels, hintLevelZeroOnly); @@ -3635,27 +3658,6 @@ TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, b return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, levels); } -TextureImpl *Renderer11::createTexture(GLenum target) -{ - switch(target) - { - case GL_TEXTURE_2D: return new TextureD3D_2D(this); - case GL_TEXTURE_CUBE_MAP: return new TextureD3D_Cube(this); - case GL_TEXTURE_3D: return new TextureD3D_3D(this); - case GL_TEXTURE_2D_ARRAY: return new TextureD3D_2DArray(this); - default: - UNREACHABLE(); - } - - return NULL; -} - -RenderbufferImpl *Renderer11::createRenderbuffer() -{ - RenderbufferD3D *renderbuffer = new RenderbufferD3D(this); - return renderbuffer; -} - gl::Error Renderer11::readFromAttachment(const gl::FramebufferAttachment &srcAttachment, const gl::Rectangle &sourceArea, GLenum format, @@ -4200,14 +4202,14 @@ void Renderer11::updateHistograms() } } -void Renderer11::onBufferDelete(const Buffer11 *deleted) +void Renderer11::onBufferCreate(const Buffer11 *created) { - mAliveBuffers.erase(deleted); + mAliveBuffers.insert(created); } -void Renderer11::onMakeCurrent(const gl::Data &data) +void Renderer11::onBufferDelete(const Buffer11 *deleted) { - mStateManager.onMakeCurrent(data); + mAliveBuffers.erase(deleted); } ID3D11Texture2D *Renderer11::resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource) @@ -4365,4 +4367,105 @@ egl::Error Renderer11::getEGLDevice(DeviceImpl **device) return egl::Error(EGL_SUCCESS); } +ContextImpl *Renderer11::createContext(const gl::ContextState &state) +{ + return new Context11(state, this); +} + +gl::Error Renderer11::genericDrawElements(Context11 *context, + GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) +{ + const auto &data = context->getContextState(); + gl::Program *program = context->getState().getProgram(); + ASSERT(program != nullptr); + ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); + bool usesPointSize = programD3D->usesPointSize(); + + programD3D->updateSamplerMapping(); + + ANGLE_TRY(generateSwizzles(data)); + + if (!applyPrimitiveType(mode, count, usesPointSize)) + { + return gl::NoError(); + } + + ANGLE_TRY(updateState(data, mode)); + + TranslatedIndexData indexInfo; + indexInfo.indexRange = indexRange; + + ANGLE_TRY(applyIndexBuffer(data, indices, count, mode, type, &indexInfo)); + + applyTransformFeedbackBuffers(*data.state); + // Transform feedback is not allowed for DrawElements, this error should have been caught at the + // API validation + // layer. + ASSERT(!data.state->isTransformFeedbackActiveUnpaused()); + + size_t vertexCount = indexInfo.indexRange.vertexCount(); + ANGLE_TRY(applyVertexBuffer(*data.state, mode, static_cast<GLsizei>(indexInfo.indexRange.start), + static_cast<GLsizei>(vertexCount), instances, &indexInfo)); + ANGLE_TRY(applyTextures(context, data)); + ANGLE_TRY(applyShaders(data, mode)); + ANGLE_TRY(programD3D->applyUniformBuffers(data)); + + if (!skipDraw(data, mode)) + { + ANGLE_TRY(drawElementsImpl(data, indexInfo, mode, count, type, indices, instances)); + } + + return gl::NoError(); +} + +gl::Error Renderer11::genericDrawArrays(Context11 *context, + GLenum mode, + GLint first, + GLsizei count, + GLsizei instances) +{ + const auto &data = context->getContextState(); + gl::Program *program = context->getState().getProgram(); + ASSERT(program != nullptr); + ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); + bool usesPointSize = programD3D->usesPointSize(); + + programD3D->updateSamplerMapping(); + + ANGLE_TRY(generateSwizzles(data)); + if (!applyPrimitiveType(mode, count, usesPointSize)) + { + return gl::NoError(); + } + + ANGLE_TRY(updateState(data, mode)); + ANGLE_TRY(applyTransformFeedbackBuffers(*data.state)); + ANGLE_TRY(applyVertexBuffer(*data.state, mode, first, count, instances, nullptr)); + ANGLE_TRY(applyTextures(context, data)); + ANGLE_TRY(applyShaders(data, mode)); + ANGLE_TRY(programD3D->applyUniformBuffers(data)); + + if (!skipDraw(data, mode)) + { + ANGLE_TRY(drawArraysImpl(data, mode, first, count, instances)); + + if (data.state->isTransformFeedbackActiveUnpaused()) + { + ANGLE_TRY(markTransformFeedbackUsage(data)); + } + } + + return gl::NoError(); +} + +FramebufferImpl *Renderer11::createDefaultFramebuffer(const gl::FramebufferState &state) +{ + return new Framebuffer11(state, this); +} + } // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h index a23cc290070..cb6443a5539 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h @@ -31,17 +31,17 @@ struct ImageIndex; namespace rx { - -class VertexDataManager; -class IndexDataManager; -class StreamingIndexBufferInterface; class Blit11; class Buffer11; class Clear11; +class Context11; +class IndexDataManager; +struct PackPixelsParams; class PixelTransfer11; class RenderTarget11; +class StreamingIndexBufferInterface; class Trim11; -struct PackPixelsParams; +class VertexDataManager; struct Renderer11DeviceCaps { @@ -110,85 +110,106 @@ class Renderer11 : public RendererD3D egl::ConfigSet generateConfigs() const override; void generateDisplayExtensions(egl::DisplayExtensions *outExtensions) const override; - gl::Error flush() override; - gl::Error finish() override; + ContextImpl *createContext(const gl::ContextState &state) override; + + gl::Error flush(); + gl::Error finish(); - SwapChainD3D *createSwapChain(NativeWindow nativeWindow, + bool isValidNativeWindow(EGLNativeWindowType window) const override; + NativeWindowD3D *createNativeWindow(EGLNativeWindowType window, + const egl::Config *config, + const egl::AttributeMap &attribs) const override; + + SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) override; - CompilerImpl *createCompiler() override; - virtual gl::Error generateSwizzle(gl::Texture *texture); virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler); virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture); - gl::Error setUniformBuffers(const gl::Data &data, + gl::Error setUniformBuffers(const gl::ContextState &data, const std::vector<GLint> &vertexUniformBuffers, const std::vector<GLint> &fragmentUniformBuffers) override; - gl::Error updateState(const gl::Data &data, GLenum drawMode) override; + gl::Error updateState(const gl::ContextState &data, GLenum drawMode); - virtual bool applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize); - gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override; + bool applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize); + gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer); gl::Error applyUniforms(const ProgramD3D &programD3D, GLenum drawMode, const std::vector<D3DUniform *> &uniformArray) override; - virtual gl::Error applyVertexBuffer(const gl::State &state, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instances, - TranslatedIndexData *indexInfo); - gl::Error applyIndexBuffer(const gl::Data &data, + gl::Error applyVertexBuffer(const gl::State &state, + GLenum mode, + GLint first, + GLsizei count, + GLsizei instances, + TranslatedIndexData *indexInfo); + gl::Error applyIndexBuffer(const gl::ContextState &data, const GLvoid *indices, GLsizei count, GLenum mode, GLenum type, - TranslatedIndexData *indexInfo) override; - gl::Error applyTransformFeedbackBuffers(const gl::State &state) override; + TranslatedIndexData *indexInfo); + gl::Error applyTransformFeedbackBuffers(const gl::State &state); // lost device bool testDeviceLost() override; - bool testDeviceResettable() override; + bool testDeviceResettable(); - std::string getRendererDescription() const override; + std::string getRendererDescription() const; DeviceIdentifier getAdapterIdentifier() const override; - virtual unsigned int getReservedVertexUniformVectors() const; - virtual unsigned int getReservedFragmentUniformVectors() const; - virtual unsigned int getReservedVertexUniformBuffers() const; - virtual unsigned int getReservedFragmentUniformBuffers() const; + unsigned int getReservedVertexUniformVectors() const override; + unsigned int getReservedFragmentUniformVectors() const override; + unsigned int getReservedVertexUniformBuffers() const override; + unsigned int getReservedFragmentUniformBuffers() const override; bool getShareHandleSupport() const; + bool getNV12TextureSupport() const; + virtual int getMajorShaderModel() const; int getMinorShaderModel() const override; std::string getShaderModelSuffix() const override; // Pixel operations - virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLint level); - virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level); - virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLint level); - virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLint level); + gl::Error copyImage2D(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLint level) override; + gl::Error copyImageCube(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLenum target, + GLint level) override; + gl::Error copyImage3D(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLint level) override; + gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLint level) override; // RenderTarget creation - virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT); + gl::Error createRenderTarget(int width, + int height, + GLenum format, + GLsizei samples, + RenderTargetD3D **outRT) override; gl::Error createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT) override; - // Framebuffer creation - FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override; - - // Shader creation - ShaderImpl *createShader(const gl::Shader::Data &data) override; - ProgramImpl *createProgram(const gl::Program::Data &data) override; - // Shader operations gl::Error loadExecutable(const void *function, size_t length, @@ -206,48 +227,53 @@ class Renderer11 : public RendererD3D UniformStorageD3D *createUniformStorage(size_t storageSize) override; // Image operations - virtual ImageD3D *createImage(); + ImageD3D *createImage() override; gl::Error generateMipmap(ImageD3D *dest, ImageD3D *source) override; gl::Error generateMipmapsUsingD3D(TextureStorage *storage, const gl::TextureState &textureState) override; - virtual TextureStorage *createTextureStorage2D(SwapChainD3D *swapChain); + TextureStorage *createTextureStorage2D(SwapChainD3D *swapChain) override; TextureStorage *createTextureStorageEGLImage(EGLImageD3D *eglImage) override; - virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly); - virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels, bool hintLevelZeroOnly); - virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels); - virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels); - - // Texture creation - virtual TextureImpl *createTexture(GLenum target); - - // Renderbuffer creation - virtual RenderbufferImpl *createRenderbuffer(); - - // Buffer creation - virtual BufferImpl *createBuffer(); - virtual VertexBuffer *createVertexBuffer(); - virtual IndexBuffer *createIndexBuffer(); - - // Vertex Array creation - VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override; - - // Query and Fence creation - virtual QueryImpl *createQuery(GLenum type); - virtual FenceNVImpl *createFenceNV(); - virtual FenceSyncImpl *createFenceSync(); - - // Transform Feedback creation - virtual TransformFeedbackImpl* createTransformFeedback(); + TextureStorage *createTextureStorageExternal( + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) override; + TextureStorage *createTextureStorage2D(GLenum internalformat, + bool renderTarget, + GLsizei width, + GLsizei height, + int levels, + bool hintLevelZeroOnly) override; + TextureStorage *createTextureStorageCube(GLenum internalformat, + bool renderTarget, + int size, + int levels, + bool hintLevelZeroOnly) override; + TextureStorage *createTextureStorage3D(GLenum internalformat, + bool renderTarget, + GLsizei width, + GLsizei height, + GLsizei depth, + int levels) override; + TextureStorage *createTextureStorage2DArray(GLenum internalformat, + bool renderTarget, + GLsizei width, + GLsizei height, + GLsizei depth, + int levels) override; + + VertexBuffer *createVertexBuffer() override; + IndexBuffer *createIndexBuffer() override; // Stream Creation - StreamImpl *createStream(const egl::AttributeMap &attribs) override; + StreamProducerImpl *createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) override; // D3D11-renderer specific methods ID3D11Device *getDevice() { return mDevice; } void *getD3DDevice() override; ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; }; ID3D11DeviceContext1 *getDeviceContext1IfSupported() { return mDeviceContext1; }; - DXGIFactory *getDxgiFactory() { return mDxgiFactory; }; + IDXGIFactory *getDxgiFactory() { return mDxgiFactory; }; RenderStateCache &getStateCache() { return mStateCache; } @@ -291,25 +317,40 @@ class Renderer11 : public RendererD3D StateManager11 *getStateManager() { return &mStateManager; } void onSwap(); + void onBufferCreate(const Buffer11 *created); void onBufferDelete(const Buffer11 *deleted); - void onMakeCurrent(const gl::Data &data) override; egl::Error getEGLDevice(DeviceImpl **device) override; + gl::Error genericDrawArrays(Context11 *context, + GLenum mode, + GLint first, + GLsizei count, + GLsizei instances); + + gl::Error genericDrawElements(Context11 *context, + GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange); + + // Necessary hack for default framebuffers in D3D. + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; + protected: void createAnnotator() override; gl::Error clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd) override; - gl::Error applyShadersImpl(const gl::Data &data, GLenum drawMode) override; - - void syncState(const gl::State &state, const gl::State::DirtyBits &bitmask) override; + gl::Error applyShadersImpl(const gl::ContextState &data, GLenum drawMode) override; private: - gl::Error drawArraysImpl(const gl::Data &data, + gl::Error drawArraysImpl(const gl::ContextState &data, GLenum mode, GLint startVertex, GLsizei count, GLsizei instances) override; - gl::Error drawElementsImpl(const gl::Data &data, + gl::Error drawElementsImpl(const gl::ContextState &data, const TranslatedIndexData &indexInfo, GLenum mode, GLsizei count, @@ -323,13 +364,13 @@ class Renderer11 : public RendererD3D WorkaroundsD3D generateWorkarounds() const override; - gl::Error drawLineLoop(const gl::Data &data, + gl::Error drawLineLoop(const gl::ContextState &data, GLsizei count, GLenum type, const GLvoid *indices, const TranslatedIndexData *indexInfo, int instances); - gl::Error drawTriangleFan(const gl::Data &data, + gl::Error drawTriangleFan(const gl::ContextState &data, GLsizei count, GLenum type, const GLvoid *indices, @@ -350,11 +391,16 @@ class Renderer11 : public RendererD3D struct dx_SamplerMetadata { - int parameters[4]; + int baseLevel; + int internalFormatBits; + int wrapModes; + int padding; // This just pads the struct to 16 bytes }; + static_assert(sizeof(dx_SamplerMetadata) == 16u, + "Sampler metadata struct must be one 4-vec / 16 bytes."); void initData(unsigned int samplerCount); - void update(unsigned int samplerIndex, unsigned int baseLevel, GLenum internalFormat); + void update(unsigned int samplerIndex, const gl::Texture &texture); const dx_SamplerMetadata *getData() const; size_t sizeBytes() const; @@ -477,7 +523,7 @@ class Renderer11 : public RendererD3D IDXGIAdapter *mDxgiAdapter; DXGI_ADAPTER_DESC mAdapterDescription; char mDescription[128]; - DXGIFactory *mDxgiFactory; + IDXGIFactory *mDxgiFactory; ID3D11Debug *mDebug; std::vector<GLuint> mScratchIndexDataBuffer; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp index c3b3e5ea5a8..447ccfa1a0a 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp @@ -11,6 +11,7 @@ #include "common/BitSetIterator.h" #include "common/utilities.h" #include "libANGLE/Query.h" +#include "libANGLE/VertexArray.h" #include "libANGLE/renderer/d3d/d3d11/Framebuffer11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" @@ -130,7 +131,8 @@ void StateManager11::SRVCache::clear() } static const GLenum QueryTypes[] = {GL_ANY_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, - GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_TIME_ELAPSED_EXT}; + GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_TIME_ELAPSED_EXT, + GL_COMMANDS_COMPLETED_CHROMIUM}; StateManager11::StateManager11(Renderer11 *renderer) : mRenderer(renderer), @@ -839,7 +841,7 @@ void StateManager11::onDeleteQueryObject(Query11 *query) mCurrentQueries.erase(query); } -gl::Error StateManager11::onMakeCurrent(const gl::Data &data) +gl::Error StateManager11::onMakeCurrent(const gl::ContextState &data) { const gl::State &state = *data.state; @@ -1083,7 +1085,7 @@ gl::Error StateManager11::syncFramebuffer(const gl::Framebuffer *framebuffer) } // TODO(jmadill): Use context caps? - UINT drawBuffers = mRenderer->getRendererCaps().maxDrawBuffers; + UINT drawBuffers = mRenderer->getNativeCaps().maxDrawBuffers; // Apply the render target and depth stencil mRenderer->getDeviceContext()->OMSetRenderTargets(drawBuffers, framebufferRTVs.data(), diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.h index c926ccde57e..c98c2c53b11 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.h @@ -12,7 +12,7 @@ #include <array> #include "libANGLE/angletypes.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/State.h" #include "libANGLE/renderer/d3d/d3d11/RenderStateCache.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" @@ -90,7 +90,7 @@ class StateManager11 final : angle::NonCopyable void onBeginQuery(Query11 *query); void onDeleteQueryObject(Query11 *query); - gl::Error onMakeCurrent(const gl::Data &data); + gl::Error onMakeCurrent(const gl::ContextState &data); gl::Error updateCurrentValueAttribs(const gl::State &state, VertexDataManager *vertexDataManager); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Stream11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Stream11.cpp deleted file mode 100644 index 9dba705d922..00000000000 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Stream11.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// Stream11.cpp: Defines the rx::Stream11 class which implements rx::StreamImpl. - -#include "libANGLE/renderer/d3d/d3d11/Stream11.h" - -#include "common/utilities.h" -#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" -#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" - -namespace rx -{ - -Stream11::Stream11(Renderer11 *renderer) : mRenderer(renderer) -{ - UNUSED_VARIABLE(mRenderer); -} - -Stream11::~Stream11() -{ -} -} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Stream11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Stream11.h deleted file mode 100644 index 5a971f5121e..00000000000 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Stream11.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// Stream11.h: Defines the rx::Stream11 class which implements rx::StreamImpl. - -#ifndef LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ -#define LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ - -#include "libANGLE/renderer/StreamImpl.h" - -namespace rx -{ -class Renderer11; - -class Stream11 : public StreamImpl -{ - public: - Stream11(Renderer11 *renderer); - ~Stream11() override; - - private: - Renderer11 *mRenderer; -}; -} // namespace rx - -#endif // LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StreamProducerNV12.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StreamProducerNV12.cpp new file mode 100644 index 00000000000..fbbdf552a14 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StreamProducerNV12.cpp @@ -0,0 +1,102 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// StreamProducerNV12.cpp: Implements the stream producer for NV12 textures + +#include "libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h" + +#include "common/utilities.h" +#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" +#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" + +namespace rx +{ + +StreamProducerNV12::StreamProducerNV12(Renderer11 *renderer) + : mRenderer(renderer), mTexture(nullptr), mArraySlice(0), mTextureWidth(0), mTextureHeight(0) +{ +} + +StreamProducerNV12::~StreamProducerNV12() +{ + SafeRelease(mTexture); +} + +egl::Error StreamProducerNV12::validateD3DNV12Texture(void *pointer) const +{ + ID3D11Texture2D *textureD3D = static_cast<ID3D11Texture2D *>(pointer); + + // Check that the texture originated from our device + ID3D11Device *device; + textureD3D->GetDevice(&device); + if (device != mRenderer->getDevice()) + { + return egl::Error(EGL_BAD_PARAMETER, "Texture not created on ANGLE D3D device"); + } + + // Get the description and validate it + D3D11_TEXTURE2D_DESC desc; + textureD3D->GetDesc(&desc); + if (desc.Format != DXGI_FORMAT_NV12) + { + return egl::Error(EGL_BAD_PARAMETER, "Texture format not DXGI_FORMAT_NV12"); + } + if (desc.Width < 1 || desc.Height < 1) + { + return egl::Error(EGL_BAD_PARAMETER, "Texture is of size 0"); + } + if ((desc.Width % 2) != 0 || (desc.Height % 2) != 0) + { + return egl::Error(EGL_BAD_PARAMETER, "Texture dimensions are not even"); + } + return egl::Error(EGL_SUCCESS); +} + +void StreamProducerNV12::postD3DNV12Texture(void *pointer, const egl::AttributeMap &attributes) +{ + ASSERT(pointer != nullptr); + ID3D11Texture2D *textureD3D = static_cast<ID3D11Texture2D *>(pointer); + + // Check that the texture originated from our device + ID3D11Device *device; + textureD3D->GetDevice(&device); + + // Get the description + D3D11_TEXTURE2D_DESC desc; + textureD3D->GetDesc(&desc); + + // Release the previous texture if there is one + SafeRelease(mTexture); + + mTexture = textureD3D; + mTexture->AddRef(); + mTextureWidth = desc.Width; + mTextureHeight = desc.Height; + mArraySlice = static_cast<UINT>(attributes.get(EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, 0)); +} + +egl::Stream::GLTextureDescription StreamProducerNV12::getGLFrameDescription(int planeIndex) +{ + // The UV plane of NV12 textures has half the width/height of the Y plane + egl::Stream::GLTextureDescription desc; + desc.width = (planeIndex == 0) ? mTextureWidth : (mTextureWidth / 2); + desc.height = (planeIndex == 0) ? mTextureHeight : (mTextureHeight / 2); + desc.internalFormat = (planeIndex == 0) ? GL_R8 : GL_RG8; + desc.mipLevels = 0; + return desc; +} + +ID3D11Texture2D *StreamProducerNV12::getD3DTexture() +{ + return mTexture; +} + +UINT StreamProducerNV12::getArraySlice() +{ + return mArraySlice; +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h new file mode 100644 index 00000000000..304c9dfe530 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h @@ -0,0 +1,44 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// StreamProducerNV12.h: Interface for a NV12 texture stream producer + +#ifndef LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ +#define LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ + +#include "libANGLE/renderer/StreamProducerImpl.h" + +namespace rx +{ +class Renderer11; + +class StreamProducerNV12 : public StreamProducerImpl +{ + public: + StreamProducerNV12(Renderer11 *renderer); + ~StreamProducerNV12() override; + + egl::Error validateD3DNV12Texture(void *pointer) const override; + void postD3DNV12Texture(void *pointer, const egl::AttributeMap &attributes) override; + egl::Stream::GLTextureDescription getGLFrameDescription(int planeIndex) override; + + // Gets a pointer to the internal D3D texture + ID3D11Texture2D *getD3DTexture(); + + // Gets the slice index for the D3D texture that the frame is in + UINT getArraySlice(); + + private: + Renderer11 *mRenderer; + + ID3D11Texture2D *mTexture; + UINT mArraySlice; + UINT mTextureWidth; + UINT mTextureHeight; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp index 4b308cc3a22..e934aa888f8 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp @@ -12,7 +12,7 @@ #include "libANGLE/features.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h" -#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" +#include "libANGLE/renderer/d3d/d3d11/NativeWindow11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" @@ -33,22 +33,22 @@ namespace rx namespace { -bool NeedsOffscreenTexture(Renderer11 *renderer, NativeWindow nativeWindow, EGLint orientation) +bool NeedsOffscreenTexture(Renderer11 *renderer, NativeWindow11 *nativeWindow, EGLint orientation) { // We don't need an offscreen texture if either orientation = INVERT_Y, // or present path fast is enabled and we're not rendering onto an offscreen surface. return orientation != EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && - !(renderer->presentPathFastEnabled() && nativeWindow.getNativeWindow()); + !(renderer->presentPathFastEnabled() && nativeWindow->getNativeWindow()); } } // anonymous namespace SwapChain11::SwapChain11(Renderer11 *renderer, - NativeWindow nativeWindow, + NativeWindow11 *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) - : SwapChainD3D(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat), + : SwapChainD3D(shareHandle, backBufferFormat, depthBufferFormat), mRenderer(renderer), mWidth(-1), mHeight(-1), @@ -56,6 +56,7 @@ SwapChain11::SwapChain11(Renderer11 *renderer, mAppCreatedShareHandle(mShareHandle != nullptr), mSwapInterval(0), mPassThroughResourcesInit(false), + mNativeWindow(nativeWindow), mFirstSwap(true), mSwapChain(nullptr), mSwapChain1(nullptr), @@ -218,7 +219,8 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe } else { - const bool useSharedResource = !mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport(); + const bool useSharedResource = + !mNativeWindow->getNativeWindow() && mRenderer->getShareHandleSupport(); D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0}; offscreenTextureDesc.Width = backbufferWidth; @@ -525,11 +527,11 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap return EGL_SUCCESS; } - if (mNativeWindow.getNativeWindow()) + if (mNativeWindow->getNativeWindow()) { - HRESULT result = mNativeWindow.createSwapChain(device, mRenderer->getDxgiFactory(), - getSwapChainNativeFormat(), - backbufferWidth, backbufferHeight, &mSwapChain); + HRESULT result = mNativeWindow->createSwapChain(device, mRenderer->getDxgiFactory(), + getSwapChainNativeFormat(), backbufferWidth, + backbufferHeight, &mSwapChain); if (FAILED(result)) { @@ -834,7 +836,7 @@ EGLint SwapChain11::present(EGLint x, EGLint y, EGLint width, EGLint height) ERR("Present failed with error code 0x%08X", result); } - mNativeWindow.commitChange(); + mNativeWindow->commitChange(); return EGL_SUCCESS; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h index 583e29c3c81..23f2fd37b12 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h @@ -16,12 +16,13 @@ namespace rx { class Renderer11; +class NativeWindow11; class SwapChain11 : public SwapChainD3D { public: SwapChain11(Renderer11 *renderer, - NativeWindow nativeWindow, + NativeWindow11 *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, @@ -71,8 +72,10 @@ class SwapChain11 : public SwapChainD3D unsigned int mSwapInterval; bool mPassThroughResourcesInit; + NativeWindow11 *mNativeWindow; // Handler for the Window that the surface is created for. + bool mFirstSwap; - DXGISwapChain *mSwapChain; + IDXGISwapChain *mSwapChain; IDXGISwapChain1 *mSwapChain1; IDXGIKeyedMutex *mKeyedMutex; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp index 05362c71d82..a0877f1606a 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp @@ -22,6 +22,7 @@ #include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" +#include "libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h" #include "libANGLE/renderer/d3d/d3d11/SwapChain11.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/EGLImageD3D.h" @@ -159,6 +160,8 @@ UINT TextureStorage11::getMiscFlags() const int TextureStorage11::getTopLevel() const { + // Applying top level is meant to be encapsulated inside TextureStorage11. + UNREACHABLE(); return mTopLevel; } @@ -209,13 +212,15 @@ UINT TextureStorage11::getSubresourceIndex(const gl::ImageIndex &index) const gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState, ID3D11ShaderResourceView **outSRV) { + // Make sure to add the level offset for our tiny compressed texture workaround + const GLuint effectiveBaseLevel = textureState.getEffectiveBaseLevel(); bool swizzleRequired = textureState.swizzleRequired(); bool mipmapping = gl::IsMipmapFiltered(textureState.samplerState); - unsigned int mipLevels = mipmapping ? (textureState.maxLevel - textureState.baseLevel + 1) : 1; + unsigned int mipLevels = mipmapping ? (textureState.maxLevel - effectiveBaseLevel + 1) : 1; // Make sure there's 'mipLevels' mipmap levels below the base level (offset by the top level, // which corresponds to GL level 0) - mipLevels = std::min(mipLevels, mMipLevels - mTopLevel - textureState.baseLevel); + mipLevels = std::min(mipLevels, mMipLevels - mTopLevel - effectiveBaseLevel); if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3) { @@ -239,45 +244,41 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState, textureState.swizzleBlue, textureState.swizzleAlpha); } - SRVKey key(textureState.baseLevel, mipLevels, swizzleRequired); + SRVKey key(effectiveBaseLevel, mipLevels, swizzleRequired); + ANGLE_TRY(getCachedOrCreateSRV(key, outSRV)); + + return gl::NoError(); +} + +gl::Error TextureStorage11::getCachedOrCreateSRV(const SRVKey &key, + ID3D11ShaderResourceView **outSRV) +{ auto iter = mSrvCache.find(key); if (iter != mSrvCache.end()) { *outSRV = iter->second; - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } ID3D11Resource *texture = nullptr; - if (swizzleRequired) + if (key.swizzle) { - gl::Error error = getSwizzleTexture(&texture); - if (error.isError()) - { - return error; - } + ANGLE_TRY(getSwizzleTexture(&texture)); } else { - gl::Error error = getResource(&texture); - if (error.isError()) - { - return error; - } + ANGLE_TRY(getResource(&texture)); } ID3D11ShaderResourceView *srv = nullptr; DXGI_FORMAT format = - (swizzleRequired ? mSwizzleFormatSet->srvFormat : mTextureFormatSet->srvFormat); - gl::Error error = createSRV(textureState.baseLevel, mipLevels, format, texture, &srv); - if (error.isError()) - { - return error; - } + (key.swizzle ? mSwizzleFormatSet->srvFormat : mTextureFormatSet->srvFormat); + ANGLE_TRY(createSRV(key.baseLevel, key.mipLevels, format, texture, &srv)); mSrvCache.insert(std::make_pair(key, srv)); *outSRV = srv; - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } gl::Error TextureStorage11::getSRVLevel(int mipLevel, @@ -348,31 +349,9 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel, } SRVKey key(baseLevel, mipLevels, false); - auto iter = mSrvCache.find(key); - if (iter != mSrvCache.end()) - { - *outSRV = iter->second; - return gl::Error(GL_NO_ERROR); - } - - ID3D11Resource *texture = nullptr; - gl::Error error = getResource(&texture); - if (error.isError()) - { - return error; - } + ANGLE_TRY(getCachedOrCreateSRV(key, outSRV)); - ID3D11ShaderResourceView *srv = nullptr; - error = createSRV(baseLevel, mipLevels, mTextureFormatSet->srvFormat, texture, &srv); - if (error.isError()) - { - return error; - } - - mSrvCache[key] = srv; - *outSRV = srv; - - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } d3d11::ANGLEFormat TextureStorage11::getANGLEFormat() const @@ -1468,6 +1447,152 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render return gl::Error(GL_NO_ERROR); } +TextureStorage11_External::TextureStorage11_External( + Renderer11 *renderer, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &glDesc) + : TextureStorage11(renderer, D3D11_BIND_SHADER_RESOURCE, 0) +{ + ASSERT(stream->getProducerType() == egl::Stream::ProducerType::D3D11TextureNV12); + StreamProducerNV12 *producer = static_cast<StreamProducerNV12 *>(stream->getImplementation()); + mTexture = producer->getD3DTexture(); + mSubresourceIndex = producer->getArraySlice(); + mTexture->AddRef(); + mMipLevels = 1; + + D3D11_TEXTURE2D_DESC desc; + mTexture->GetDesc(&desc); + mTextureWidth = desc.Width; + mTextureHeight = desc.Height; + mTextureDepth = 1; + mInternalFormat = glDesc.internalFormat; + + const d3d11::TextureFormat &formatInfo = + d3d11::GetTextureFormatInfo(mInternalFormat, renderer->getRenderer11DeviceCaps()); + mTextureFormatSet = formatInfo.formatSet; + mSwizzleFormatSet = formatInfo.swizzleFormatSet; +} + +TextureStorage11_External::~TextureStorage11_External() +{ + SafeRelease(mTexture); +} + +gl::Error TextureStorage11_External::copyToStorage(TextureStorage *destStorage) +{ + UNIMPLEMENTED(); + return gl::NoError(); +} + +void TextureStorage11_External::associateImage(Image11 *image, const gl::ImageIndex &index) +{ + ASSERT(index.mipIndex == 0); + mAssociatedImage = image; +} + +bool TextureStorage11_External::isAssociatedImageValid(const gl::ImageIndex &index, + Image11 *expectedImage) +{ + return (index.mipIndex == 0 && mAssociatedImage == expectedImage); +} + +void TextureStorage11_External::disassociateImage(const gl::ImageIndex &index, + Image11 *expectedImage) +{ + ASSERT(index.mipIndex == 0); + ASSERT(mAssociatedImage == expectedImage); + mAssociatedImage = nullptr; +} + +gl::Error TextureStorage11_External::releaseAssociatedImage(const gl::ImageIndex &index, + Image11 *incomingImage) +{ + ASSERT(index.mipIndex == 0); + + if (mAssociatedImage != nullptr && mAssociatedImage != incomingImage) + { + bool imageAssociationCorrect = mAssociatedImage->isAssociatedStorageValid(this); + ASSERT(imageAssociationCorrect); + + if (imageAssociationCorrect) + { + ANGLE_TRY(mAssociatedImage->recoverFromAssociatedStorage()); + } + } + + return gl::NoError(); +} + +gl::Error TextureStorage11_External::getResource(ID3D11Resource **outResource) +{ + *outResource = mTexture; + return gl::Error(GL_NO_ERROR); +} + +gl::Error TextureStorage11_External::getMippedResource(ID3D11Resource **outResource) +{ + *outResource = mTexture; + return gl::Error(GL_NO_ERROR); +} + +gl::Error TextureStorage11_External::getRenderTarget(const gl::ImageIndex &index, + RenderTargetD3D **outRT) +{ + // Render targets are not supported for external textures + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureStorage11_External::createSRV(int baseLevel, + int mipLevels, + DXGI_FORMAT format, + ID3D11Resource *texture, + ID3D11ShaderResourceView **outSRV) const +{ + // Since external textures are treates as non-mipmapped textures, we ignore mipmap levels and + // use the specified subresource ID the storage was created with. + ASSERT(mipLevels == 1); + ASSERT(outSRV); + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + srvDesc.Format = format; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; + // subresource index is equal to the mip level for 2D textures + srvDesc.Texture2DArray.MostDetailedMip = 0; + srvDesc.Texture2DArray.MipLevels = 1; + srvDesc.Texture2DArray.FirstArraySlice = mSubresourceIndex; + srvDesc.Texture2DArray.ArraySize = 1; + + ID3D11Resource *srvTexture = texture; + + ID3D11Device *device = mRenderer->getDevice(); + HRESULT result = device->CreateShaderResourceView(srvTexture, &srvDesc, outSRV); + + ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result)); + if (FAILED(result)) + { + return gl::Error(GL_OUT_OF_MEMORY, + "Failed to create internal texture storage SRV, result: 0x%X.", result); + } + + d3d11::SetDebugName(*outSRV, "TexStorage2D.SRV"); + + return gl::NoError(); +} + +gl::Error TextureStorage11_External::getSwizzleTexture(ID3D11Resource **outTexture) +{ + UNIMPLEMENTED(); + return gl::Error(GL_INVALID_OPERATION); +} + +gl::Error TextureStorage11_External::getSwizzleRenderTarget(int mipLevel, + ID3D11RenderTargetView **outRTV) +{ + UNIMPLEMENTED(); + return gl::Error(GL_INVALID_OPERATION); +} + TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer, EGLImageD3D *eglImage) : TextureStorage11(renderer, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, 0), mImage(eglImage), diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h index 6275f032a10..b02ab75ddc9 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h @@ -94,6 +94,7 @@ class TextureStorage11 : public TextureStorage virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV) = 0; gl::Error getSRVLevel(int mipLevel, bool blitSRV, ID3D11ShaderResourceView **outSRV); + // The baseLevel parameter should *not* have mTopLevel applied. virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture, ID3D11ShaderResourceView **outSRV) const = 0; @@ -138,12 +139,14 @@ class TextureStorage11 : public TextureStorage bool operator<(const SRVKey &rhs) const; - int baseLevel; + int baseLevel; // Without mTopLevel applied. int mipLevels; bool swizzle; }; typedef std::map<SRVKey, ID3D11ShaderResourceView *> SRVCache; + gl::Error getCachedOrCreateSRV(const SRVKey &key, ID3D11ShaderResourceView **outSRV); + SRVCache mSrvCache; std::array<ID3D11ShaderResourceView *, gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS> mLevelSRVs; std::array<ID3D11ShaderResourceView *, gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS> mLevelBlitSRVs; @@ -203,6 +206,42 @@ class TextureStorage11_2D : public TextureStorage11 Image11 *mAssociatedImages[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; }; +class TextureStorage11_External : public TextureStorage11 +{ + public: + TextureStorage11_External(Renderer11 *renderer, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &glDesc); + ~TextureStorage11_External() override; + + gl::Error getResource(ID3D11Resource **outResource) override; + gl::Error getMippedResource(ID3D11Resource **outResource) override; + gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) override; + + gl::Error copyToStorage(TextureStorage *destStorage) override; + + void associateImage(Image11 *image, const gl::ImageIndex &index) override; + void disassociateImage(const gl::ImageIndex &index, Image11 *expectedImage) override; + bool isAssociatedImageValid(const gl::ImageIndex &index, Image11 *expectedImage) override; + gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11 *incomingImage) override; + + protected: + gl::Error getSwizzleTexture(ID3D11Resource **outTexture) override; + gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV) override; + + private: + gl::Error createSRV(int baseLevel, + int mipLevels, + DXGI_FORMAT format, + ID3D11Resource *texture, + ID3D11ShaderResourceView **outSRV) const override; + + ID3D11Texture2D *mTexture; + int mSubresourceIndex; + + Image11 *mAssociatedImage; +}; + class TextureStorage11_EGLImage final : public TextureStorage11 { public: diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp index 213ce318174..ca48b1872c4 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp @@ -11,9 +11,15 @@ #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #if defined (ANGLE_ENABLE_WINDOWS_STORE) -using namespace ABI::Windows::Foundation; +#include <wrl.h> +#include <wrl/wrappers/corewrappers.h> +#include <windows.applicationmodel.core.h> +using namespace Microsoft::WRL; +using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::ApplicationModel; using namespace ABI::Windows::ApplicationModel::Core; +using namespace ABI::Windows::Foundation; +using namespace ABI::Windows::Foundation::Collections; #endif namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp index f8dbbe0f20f..39a11f3fc32 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp @@ -37,7 +37,7 @@ size_t GetAttribIndex(unsigned long dirtyBit) } } // anonymous namespace -VertexArray11::VertexArray11(const gl::VertexArray::Data &data) +VertexArray11::VertexArray11(const gl::VertexArrayState &data) : VertexArrayImpl(data), mAttributeStorageTypes(data.getVertexAttributes().size(), VertexStorageType::CURRENT_VALUE), mTranslatedAttribs(data.getVertexAttributes().size()), @@ -55,9 +55,13 @@ VertexArray11::VertexArray11(const gl::VertexArray::Data &data) VertexArray11::~VertexArray11() { - for (auto &binding : mCurrentBuffers) + for (size_t attribIndex = 0; attribIndex < mCurrentBuffers.size(); ++attribIndex) { - binding.set(nullptr); + if (mCurrentBuffers[attribIndex].get()) + { + unlinkBuffer(attribIndex, mAttributeStorageTypes[attribIndex]); + mCurrentBuffers[attribIndex].set(nullptr); + } } } @@ -114,15 +118,7 @@ void VertexArray11::updateVertexAttribStorage(size_t attribIndex) // we need to tag dynamic buffers with static callbacks. if (oldBuffer11 != nullptr) { - if (oldStorageType == VertexStorageType::DIRECT) - { - oldBuffer11->removeDirectBufferDirtyCallback(&mOnBufferDataDirty[attribIndex]); - } - else if (oldStorageType == VertexStorageType::STATIC || - oldStorageType == VertexStorageType::DYNAMIC) - { - oldBuffer11->removeStaticBufferDirtyCallback(&mOnBufferDataDirty[attribIndex]); - } + unlinkBuffer(attribIndex, oldStorageType); } if (newBuffer11 != nullptr) { @@ -253,4 +249,17 @@ void VertexArray11::clearDirtyAndPromoteDynamicAttribs(const gl::State &state, G VertexDataManager::PromoteDynamicAttribs(mTranslatedAttribs, activeDynamicAttribs, count); } +void VertexArray11::unlinkBuffer(size_t attribIndex, VertexStorageType storageType) +{ + Buffer11 *buffer = GetImplAs<Buffer11>(mCurrentBuffers[attribIndex].get()); + if (storageType == VertexStorageType::DIRECT) + { + buffer->removeDirectBufferDirtyCallback(&mOnBufferDataDirty[attribIndex]); + } + else if (storageType == VertexStorageType::STATIC || storageType == VertexStorageType::DYNAMIC) + { + buffer->removeStaticBufferDirtyCallback(&mOnBufferDataDirty[attribIndex]); + } +} + } // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h index 00a223eeda9..8a2c775f5fd 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h @@ -19,7 +19,7 @@ class Renderer11; class VertexArray11 : public VertexArrayImpl { public: - VertexArray11(const gl::VertexArray::Data &data); + VertexArray11(const gl::VertexArrayState &data); ~VertexArray11() override; void syncState(const gl::VertexArray::DirtyBits &dirtyBits) override; @@ -35,6 +35,7 @@ class VertexArray11 : public VertexArrayImpl private: void updateVertexAttribStorage(size_t attribIndex); void markBufferDataDirty(size_t attribIndex); + void unlinkBuffer(size_t attribIndex, VertexStorageType storageType); std::vector<VertexStorageType> mAttributeStorageTypes; std::vector<TranslatedAttribute> mTranslatedAttribs; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp index 7a94835b070..2eaf7a70bb9 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp @@ -16,7 +16,6 @@ #include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/generatemip.h" #include "libANGLE/renderer/d3d/loadimage.h" -#include "libANGLE/renderer/Renderer.h" namespace rx { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp index 89a574be6a3..a26152e6857 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp @@ -224,6 +224,8 @@ D3D11_QUERY ConvertQueryType(GLenum queryType) case GL_TIME_ELAPSED_EXT: // Two internal queries are also created for begin/end timestamps return D3D11_QUERY_TIMESTAMP_DISJOINT; + case GL_COMMANDS_COMPLETED_CHROMIUM: + return D3D11_QUERY_EVENT; default: UNREACHABLE(); return D3D11_QUERY_EVENT; } } @@ -1229,11 +1231,14 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons extensions->fboRenderMipmap = false; extensions->debugMarker = true; extensions->eglImage = true; + extensions->eglStreamConsumerExternal = true; extensions->unpackSubimage = true; extensions->packSubimage = true; extensions->vertexArrayObject = true; extensions->noError = true; extensions->lossyETCDecode = true; + extensions->bindUniformLocation = true; + extensions->syncQuery = GetEventQuerySupport(featureLevel); // D3D11 Feature Level 10_0+ uses SV_IsFrontFace in HLSL to emulate gl_FrontFacing. // D3D11 Feature Level 9_3 doesn't support SV_IsFrontFace, and has no equivalent, so can't support gl_FrontFacing. diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp index 05d7a467332..ac6bda6113a 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp @@ -1,12 +1,12 @@ // -// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// NativeWindow.cpp: Handler for managing HWND native window types. +// NativeWindow11Win32.cpp: Implementation of NativeWindow11 using win32 window APIs. -#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" +#include "libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "common/debug.h" @@ -17,48 +17,46 @@ namespace rx { -NativeWindow::NativeWindow(EGLNativeWindowType window, - const egl::Config *config, - bool directComposition) - : mWindow(window), +NativeWindow11Win32::NativeWindow11Win32(EGLNativeWindowType window, + bool hasAlpha, + bool directComposition) + : NativeWindow11(window), mDirectComposition(directComposition), + mHasAlpha(hasAlpha), mDevice(nullptr), mCompositionTarget(nullptr), - mVisual(nullptr), - mConfig(config) + mVisual(nullptr) { } -NativeWindow::~NativeWindow() +NativeWindow11Win32::~NativeWindow11Win32() { SafeRelease(mCompositionTarget); SafeRelease(mDevice); SafeRelease(mVisual); } -bool NativeWindow::initialize() +bool NativeWindow11Win32::initialize() { return true; } -bool NativeWindow::getClientRect(LPRECT rect) +bool NativeWindow11Win32::getClientRect(LPRECT rect) const { - return GetClientRect(mWindow, rect) == TRUE; + return GetClientRect(getNativeWindow(), rect) == TRUE; } -bool NativeWindow::isIconic() +bool NativeWindow11Win32::isIconic() const { - return IsIconic(mWindow) == TRUE; + return IsIconic(getNativeWindow()) == TRUE; } -bool NativeWindow::isValidNativeWindow(EGLNativeWindowType window) -{ - return IsWindow(window) == TRUE; -} - -HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory, - DXGI_FORMAT format, unsigned int width, unsigned int height, - DXGISwapChain** swapChain) +HRESULT NativeWindow11Win32::createSwapChain(ID3D11Device *device, + IDXGIFactory *factory, + DXGI_FORMAT format, + UINT width, + UINT height, + IDXGISwapChain **swapChain) { if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0) { @@ -98,7 +96,8 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory if (!mCompositionTarget) { - HRESULT result = mDevice->CreateTargetForHwnd(mWindow, TRUE, &mCompositionTarget); + HRESULT result = + mDevice->CreateTargetForHwnd(getNativeWindow(), TRUE, &mCompositionTarget); if (FAILED(result)) { return result; @@ -121,21 +120,21 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory swapChainDesc.Format = format; swapChainDesc.Stereo = FALSE; swapChainDesc.SampleDesc.Count = 1; - swapChainDesc.SampleDesc.Quality = 0; + swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER | DXGI_USAGE_SHADER_INPUT; - swapChainDesc.BufferCount = 2; - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + swapChainDesc.BufferCount = 2; + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; swapChainDesc.AlphaMode = - mConfig->alphaSize == 0 ? DXGI_ALPHA_MODE_IGNORE : DXGI_ALPHA_MODE_PREMULTIPLIED; + mHasAlpha ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE; swapChainDesc.Flags = 0; IDXGISwapChain1 *swapChain1 = nullptr; HRESULT result = factory2->CreateSwapChainForComposition(device, &swapChainDesc, nullptr, &swapChain1); if (SUCCEEDED(result)) { - *swapChain = static_cast<DXGISwapChain *>(swapChain1); + *swapChain = static_cast<IDXGISwapChain *>(swapChain1); } mVisual->SetContent(swapChain1); mCompositionTarget->SetRoot(mVisual); @@ -143,60 +142,68 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory return result; } - // Use IDXGIFactory2::CreateSwapChainForHwnd if DXGI 1.2 is available to create a DXGI_SWAP_EFFECT_SEQUENTIAL swap chain. + // Use IDXGIFactory2::CreateSwapChainForHwnd if DXGI 1.2 is available to create a + // DXGI_SWAP_EFFECT_SEQUENTIAL swap chain. IDXGIFactory2 *factory2 = d3d11::DynamicCastComObject<IDXGIFactory2>(factory); if (factory2 != nullptr) { - DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 }; - swapChainDesc.Width = width; - swapChainDesc.Height = height; - swapChainDesc.Format = format; - swapChainDesc.Stereo = FALSE; - swapChainDesc.SampleDesc.Count = 1; + DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0}; + swapChainDesc.Width = width; + swapChainDesc.Height = height; + swapChainDesc.Format = format; + swapChainDesc.Stereo = FALSE; + swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_BACK_BUFFER; - swapChainDesc.BufferCount = 1; - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; - swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; - swapChainDesc.Flags = 0; + swapChainDesc.BufferCount = 1; + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; + swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; + swapChainDesc.Flags = 0; IDXGISwapChain1 *swapChain1 = nullptr; - HRESULT result = factory2->CreateSwapChainForHwnd(device, mWindow, &swapChainDesc, nullptr, nullptr, &swapChain1); + HRESULT result = factory2->CreateSwapChainForHwnd(device, getNativeWindow(), &swapChainDesc, + nullptr, nullptr, &swapChain1); if (SUCCEEDED(result)) { - *swapChain = static_cast<DXGISwapChain*>(swapChain1); + *swapChain = static_cast<IDXGISwapChain *>(swapChain1); } SafeRelease(factory2); return result; } - DXGI_SWAP_CHAIN_DESC swapChainDesc = {}; - swapChainDesc.BufferCount = 1; - swapChainDesc.BufferDesc.Format = format; - swapChainDesc.BufferDesc.Width = width; - swapChainDesc.BufferDesc.Height = height; - swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; - swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; - swapChainDesc.BufferDesc.RefreshRate.Numerator = 0; + DXGI_SWAP_CHAIN_DESC swapChainDesc = {}; + swapChainDesc.BufferCount = 1; + swapChainDesc.BufferDesc.Format = format; + swapChainDesc.BufferDesc.Width = width; + swapChainDesc.BufferDesc.Height = height; + swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; + swapChainDesc.BufferDesc.RefreshRate.Numerator = 0; swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_BACK_BUFFER; - swapChainDesc.Flags = 0; - swapChainDesc.OutputWindow = mWindow; - swapChainDesc.SampleDesc.Count = 1; + swapChainDesc.Flags = 0; + swapChainDesc.OutputWindow = getNativeWindow(); + swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; - swapChainDesc.Windowed = TRUE; - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + swapChainDesc.Windowed = TRUE; + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; return factory->CreateSwapChain(device, &swapChainDesc, swapChain); } -void NativeWindow::commitChange() +void NativeWindow11Win32::commitChange() { if (mDevice) { mDevice->Commit(); } } + +// static +bool NativeWindow11Win32::IsValidNativeWindow(EGLNativeWindowType window) +{ + return IsWindow(window) == TRUE; } +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h new file mode 100644 index 00000000000..8a9ebe80065 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h @@ -0,0 +1,52 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindow11Win32.h: Implementation of NativeWindow11 using win32 window APIs. + +#ifndef LIBANGLE_RENDERER_D3D_D3D11_WIN32_NATIVEWINDOW11WIN32_H_ +#define LIBANGLE_RENDERER_D3D_D3D11_WIN32_NATIVEWINDOW11WIN32_H_ + +#include "libANGLE/renderer/d3d/d3d11/NativeWindow11.h" + +typedef interface IDCompositionDevice IDCompositionDevice; +typedef interface IDCompositionTarget IDCompositionTarget; +typedef interface IDCompositionVisual IDCompositionVisual; + +namespace rx +{ + +class NativeWindow11Win32 : public NativeWindow11 +{ + public: + NativeWindow11Win32(EGLNativeWindowType window, bool hasAlpha, bool directComposition); + ~NativeWindow11Win32() override; + + bool initialize() override; + bool getClientRect(LPRECT rect) const override; + bool isIconic() const override; + + HRESULT createSwapChain(ID3D11Device *device, + IDXGIFactory *factory, + DXGI_FORMAT format, + UINT width, + UINT height, + IDXGISwapChain **swapChain) override; + + void commitChange() override; + + static bool IsValidNativeWindow(EGLNativeWindowType window); + + private: + bool mDirectComposition; + bool mHasAlpha; + IDCompositionDevice *mDevice; + IDCompositionTarget *mCompositionTarget; + IDCompositionVisual *mVisual; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D11_WIN32_NATIVEWINDOW11WIN32_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp index 71f0e4208db..8fa767b4aa4 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp @@ -135,12 +135,12 @@ void CoreWindowNativeWindow::unregisterForSizeChangeEvents() } HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, - DXGIFactory *factory, + IDXGIFactory2 *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, bool containsAlpha, - DXGISwapChain **swapChain) + IDXGISwapChain1 **swapChain) { if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0) { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h index 77470053fbe..3311c964641 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h @@ -13,6 +13,8 @@ #include <memory> +#include <EGL/eglplatform.h> + typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler; namespace rx @@ -26,12 +28,12 @@ class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enabl bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override; HRESULT createSwapChain(ID3D11Device *device, - DXGIFactory *factory, + IDXGIFactory2 *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, bool containsAlpha, - DXGISwapChain **swapChain) override; + IDXGISwapChain1 **swapChain) override; protected: HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) override; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp index 47a6daed2d0..ddda518e304 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp @@ -11,96 +11,6 @@ namespace rx { -NativeWindow::NativeWindow(EGLNativeWindowType window, - const egl::Config *config, - bool directComposition) -{ - mWindow = window; - mConfig = config; -} - -NativeWindow::~NativeWindow() -{ -} - -void NativeWindow::commitChange() -{ -} - -bool NativeWindow::initialize() -{ - // If the native window type is a IPropertySet, extract the - // EGLNativeWindowType (IInspectable) and initialize the - // proper host with this IPropertySet. - ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet; - ComPtr<IInspectable> eglNativeWindow; - if (IsEGLConfiguredPropertySet(mWindow, &propertySet, &eglNativeWindow)) - { - // A property set was found and the EGLNativeWindowType was - // retrieved. The mWindow member of the host to must be updated - // to use the EGLNativeWindowType specified in the property set. - // mWindow is treated as a raw pointer not an AddRef'd interface, so - // the old mWindow does not need a Release() before this assignment. - mWindow = eglNativeWindow.Get(); - } - - ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow; - ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> swapChainPanel; - if (IsCoreWindow(mWindow, &coreWindow)) - { - mImpl = std::make_shared<CoreWindowNativeWindow>(); - if (mImpl) - { - return mImpl->initialize(mWindow, propertySet.Get()); - } - } - else if (IsSwapChainPanel(mWindow, &swapChainPanel)) - { - mImpl = std::make_shared<SwapChainPanelNativeWindow>(); - if (mImpl) - { - return mImpl->initialize(mWindow, propertySet.Get()); - } - } - else - { - ERR("Invalid IInspectable EGLNativeWindowType detected. Valid IInspectables include ICoreWindow, ISwapChainPanel and IPropertySet"); - } - - return false; -} - -bool NativeWindow::getClientRect(RECT *rect) -{ - if (mImpl) - { - return mImpl->getClientRect(rect); - } - - return false; -} - -bool NativeWindow::isIconic() -{ - return false; -} - -bool NativeWindow::isValidNativeWindow(EGLNativeWindowType window) -{ - return IsValidEGLNativeWindowType(window); -} - -HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) -{ - if (mImpl) - { - bool containsAlpha = (mConfig->alphaSize > 0); - return mImpl->createSwapChain(device, factory, format, width, height, containsAlpha, - swapChain); - } - - return E_UNEXPECTED; -} bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow) { @@ -207,18 +117,6 @@ bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Founda return false; } -// A Valid EGLNativeWindowType IInspectable can only be: -// -// ICoreWindow -// ISwapChainPanel -// IPropertySet -// -// Anything else will be rejected as an invalid IInspectable. -bool IsValidEGLNativeWindowType(EGLNativeWindowType window) -{ - return IsCoreWindow(window) || IsSwapChainPanel(window) || IsEGLConfiguredPropertySet(window); -} - // Retrieve an optional property from a property set HRESULT GetOptionalPropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>> &propertyMap, const wchar_t *propertyName, diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h index 4b9cf802aec..fd3897ad842 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h @@ -10,14 +10,18 @@ #ifndef LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_ #define LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_ -#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" - +#include "common/debug.h" #include "common/platform.h" #include "angle_windowsstore.h" +#include <EGL/eglplatform.h> + +#include <windows.applicationmodel.core.h> #include <windows.ui.xaml.h> #include <windows.ui.xaml.media.dxinterop.h> +#include <wrl.h> +#include <wrl/wrappers/corewrappers.h> using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; @@ -44,12 +48,12 @@ class InspectableNativeWindow virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0; virtual HRESULT createSwapChain(ID3D11Device *device, - DXGIFactory *factory, + IDXGIFactory2 *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, bool containsAlpha, - DXGISwapChain **swapChain) = 0; + IDXGISwapChain1 **swapChain) = 0; bool getClientRect(RECT *rect) { @@ -108,7 +112,6 @@ class InspectableNativeWindow EventRegistrationToken mSizeChangedEventToken; }; -bool IsValidEGLNativeWindowType(EGLNativeWindowType window); bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow = nullptr); bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> *swapChainPanel = nullptr); bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet = nullptr, IInspectable **inspectable = nullptr); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp new file mode 100644 index 00000000000..a5ce4ca68ad --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp @@ -0,0 +1,126 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindow11WinRT.cpp: NativeWindow base class for managing IInspectable native window types. + +#include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h" + +#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" +#include "libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h" +#include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h" +#include "libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h" + +using namespace Microsoft::WRL; +using namespace Microsoft::WRL::Wrappers; + +namespace rx +{ +NativeWindow11WinRT::NativeWindow11WinRT(EGLNativeWindowType window, bool hasAlpha) + : NativeWindow11(window), mHasAlpha(hasAlpha) +{ +} + +bool NativeWindow11WinRT::initialize() +{ + EGLNativeWindowType window = getNativeWindow(); + + // If the native window type is a IPropertySet, extract the + // EGLNativeWindowType (IInspectable) and initialize the + // proper host with this IPropertySet. + ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet; + ComPtr<IInspectable> eglNativeWindow; + if (IsEGLConfiguredPropertySet(window, &propertySet, &eglNativeWindow)) + { + // A property set was found and the EGLNativeWindowType was + // retrieved. The mWindow member of the host to must be updated + // to use the EGLNativeWindowType specified in the property set. + // mWindow is treated as a raw pointer not an AddRef'd interface, so + // the old mWindow does not need a Release() before this assignment. + window = eglNativeWindow.Get(); + } + + ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow; + ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> swapChainPanel; + if (IsCoreWindow(window, &coreWindow)) + { + mImpl = std::make_shared<CoreWindowNativeWindow>(); + if (mImpl) + { + return mImpl->initialize(window, propertySet.Get()); + } + } + else if (IsSwapChainPanel(window, &swapChainPanel)) + { + mImpl = std::make_shared<SwapChainPanelNativeWindow>(); + if (mImpl) + { + return mImpl->initialize(window, propertySet.Get()); + } + } + else + { + ERR( + "Invalid IInspectable EGLNativeWindowType detected. Valid IInspectables include " + "ICoreWindow, ISwapChainPanel and IPropertySet"); + } + + return false; +} + +bool NativeWindow11WinRT::getClientRect(LPRECT rect) const +{ + if (mImpl) + { + return mImpl->getClientRect(rect); + } + + return false; +} + +bool NativeWindow11WinRT::isIconic() const +{ + return false; +} + +HRESULT NativeWindow11WinRT::createSwapChain(ID3D11Device *device, + IDXGIFactory *factory, + DXGI_FORMAT format, + UINT width, + UINT height, + IDXGISwapChain **swapChain) +{ + if (mImpl) + { + IDXGIFactory2 *factory2 = d3d11::DynamicCastComObject<IDXGIFactory2>(factory); + IDXGISwapChain1 *swapChain1 = nullptr; + HRESULT result = + mImpl->createSwapChain(device, factory2, format, width, height, mHasAlpha, &swapChain1); + SafeRelease(factory2); + *swapChain = static_cast<IDXGISwapChain *>(swapChain1); + return result; + } + + return E_UNEXPECTED; +} + +void NativeWindow11WinRT::commitChange() +{ +} + +// static +bool NativeWindow11WinRT::IsValidNativeWindow(EGLNativeWindowType window) +{ + // A Valid EGLNativeWindowType IInspectable can only be: + // + // ICoreWindow + // ISwapChainPanel + // IPropertySet + // + // Anything else will be rejected as an invalid IInspectable. + return IsCoreWindow(window) || IsSwapChainPanel(window) || IsEGLConfiguredPropertySet(window); +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h new file mode 100644 index 00000000000..996fd3a1065 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h @@ -0,0 +1,50 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindow11WinRT.h: NativeWindow base class for managing IInspectable native window types. + +#ifndef LIBANGLE_RENDERER_D3D_D3D11_WINRT_NATIVEWINDOW11WINRT_H_ +#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_NATIVEWINDOW11WINRT_H_ + +#include "libANGLE/renderer/d3d/d3d11/NativeWindow11.h" + +#include <memory> +#include <windows.applicationmodel.core.h> +#include <wrl.h> +#include <wrl/wrappers/corewrappers.h> + +namespace rx +{ +class InspectableNativeWindow; + +class NativeWindow11WinRT : public NativeWindow11 +{ + public: + NativeWindow11WinRT(EGLNativeWindowType window, bool hasAlpha); + + bool initialize() override; + bool getClientRect(LPRECT rect) const override; + bool isIconic() const override; + + HRESULT createSwapChain(ID3D11Device *device, + IDXGIFactory *factory, + DXGI_FORMAT format, + UINT width, + UINT height, + IDXGISwapChain **swapChain) override; + + void commitChange() override; + + static bool IsValidNativeWindow(EGLNativeWindowType window); + + private: + bool mHasAlpha; + std::shared_ptr<InspectableNativeWindow> mImpl; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_NATIVEWINDOW11WINRT_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp index 1ed3645b9c9..22448ed11ba 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp @@ -238,12 +238,12 @@ void SwapChainPanelNativeWindow::unregisterForSizeChangeEvents() } HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device, - DXGIFactory *factory, + IDXGIFactory2 *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, bool containsAlpha, - DXGISwapChain **swapChain) + IDXGISwapChain1 **swapChain) { if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0) { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h index 9cc051d1f45..df14fddaa23 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h @@ -11,6 +11,8 @@ #include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h" +#include <memory> + namespace rx { class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::enable_shared_from_this<SwapChainPanelNativeWindow> @@ -20,12 +22,12 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::e bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override; HRESULT createSwapChain(ID3D11Device *device, - DXGIFactory *factory, + IDXGIFactory2 *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, bool containsAlpha, - DXGISwapChain **swapChain) override; + IDXGISwapChain1 **swapChain) override; protected: HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) override; @@ -37,7 +39,7 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::e ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> mSwapChainPanel; ComPtr<ABI::Windows::UI::Core::ICoreDispatcher> mSwapChainPanelDispatcher; ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap; - ComPtr<DXGISwapChain> mSwapChain; + ComPtr<IDXGISwapChain1> mSwapChain; }; [uuid(8ACBD974-8187-4508-AD80-AEC77F93CF36)] diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp new file mode 100644 index 00000000000..a1e30d12a35 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp @@ -0,0 +1,257 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Context9: +// D3D9-specific functionality associated with a GL Context. +// + +#include "libANGLE/renderer/d3d/d3d9/Context9.h" + +#include "libANGLE/renderer/d3d/CompilerD3D.h" +#include "libANGLE/renderer/d3d/ShaderD3D.h" +#include "libANGLE/renderer/d3d/ProgramD3D.h" +#include "libANGLE/renderer/d3d/RenderbufferD3D.h" +#include "libANGLE/renderer/d3d/SamplerD3D.h" +#include "libANGLE/renderer/d3d/TextureD3D.h" +#include "libANGLE/renderer/d3d/TransformFeedbackD3D.h" +#include "libANGLE/renderer/d3d/d3d9/Buffer9.h" +#include "libANGLE/renderer/d3d/d3d9/Fence9.h" +#include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h" +#include "libANGLE/renderer/d3d/d3d9/Query9.h" +#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" +#include "libANGLE/renderer/d3d/d3d9/StateManager9.h" +#include "libANGLE/renderer/d3d/d3d9/VertexArray9.h" + +namespace rx +{ + +Context9::Context9(const gl::ContextState &state, Renderer9 *renderer) + : ContextImpl(state), mRenderer(renderer) +{ +} + +Context9::~Context9() +{ +} + +gl::Error Context9::initialize() +{ + return gl::NoError(); +} + +CompilerImpl *Context9::createCompiler() +{ + return new CompilerD3D(SH_HLSL_3_0_OUTPUT); +} + +ShaderImpl *Context9::createShader(const gl::ShaderState &data) +{ + return new ShaderD3D(data); +} + +ProgramImpl *Context9::createProgram(const gl::ProgramState &data) +{ + return new ProgramD3D(data, mRenderer); +} + +FramebufferImpl *Context9::createFramebuffer(const gl::FramebufferState &data) +{ + return new Framebuffer9(data, mRenderer); +} + +TextureImpl *Context9::createTexture(const gl::TextureState &state) +{ + switch (state.target) + { + case GL_TEXTURE_2D: + return new TextureD3D_2D(state, mRenderer); + case GL_TEXTURE_CUBE_MAP: + return new TextureD3D_Cube(state, mRenderer); + default: + UNREACHABLE(); + } + return nullptr; +} + +RenderbufferImpl *Context9::createRenderbuffer() +{ + return new RenderbufferD3D(mRenderer); +} + +BufferImpl *Context9::createBuffer() +{ + return new Buffer9(mRenderer); +} + +VertexArrayImpl *Context9::createVertexArray(const gl::VertexArrayState &data) +{ + return new VertexArray9(data); +} + +QueryImpl *Context9::createQuery(GLenum type) +{ + return new Query9(mRenderer, type); +} + +FenceNVImpl *Context9::createFenceNV() +{ + return new FenceNV9(mRenderer); +} + +FenceSyncImpl *Context9::createFenceSync() +{ + // D3D9 doesn't support ES 3.0 and its sync objects. + UNREACHABLE(); + return nullptr; +} + +TransformFeedbackImpl *Context9::createTransformFeedback() +{ + return new TransformFeedbackD3D(); +} + +SamplerImpl *Context9::createSampler() +{ + return new SamplerD3D(); +} + +gl::Error Context9::flush() +{ + return mRenderer->flush(); +} + +gl::Error Context9::finish() +{ + return mRenderer->finish(); +} + +gl::Error Context9::drawArrays(GLenum mode, GLint first, GLsizei count) +{ + return mRenderer->genericDrawArrays(this, mode, first, count, 0); +} + +gl::Error Context9::drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) +{ + return mRenderer->genericDrawArrays(this, mode, first, count, instanceCount); +} + +gl::Error Context9::drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) +{ + return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); +} + +gl::Error Context9::drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) +{ + return mRenderer->genericDrawElements(this, mode, count, type, indices, instances, indexRange); +} + +gl::Error Context9::drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) +{ + return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); +} + +void Context9::notifyDeviceLost() +{ + mRenderer->notifyDeviceLost(); +} + +bool Context9::isDeviceLost() const +{ + return mRenderer->isDeviceLost(); +} + +bool Context9::testDeviceLost() +{ + return mRenderer->testDeviceLost(); +} + +bool Context9::testDeviceResettable() +{ + return mRenderer->testDeviceResettable(); +} + +std::string Context9::getVendorString() const +{ + return mRenderer->getVendorString(); +} + +std::string Context9::getRendererDescription() const +{ + return mRenderer->getRendererDescription(); +} + +void Context9::insertEventMarker(GLsizei length, const char *marker) +{ + mRenderer->insertEventMarker(length, marker); +} + +void Context9::pushGroupMarker(GLsizei length, const char *marker) +{ + mRenderer->pushGroupMarker(length, marker); +} + +void Context9::popGroupMarker() +{ + mRenderer->popGroupMarker(); +} + +void Context9::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) +{ + mRenderer->getStateManager()->syncState(state, dirtyBits); +} + +GLint Context9::getGPUDisjoint() +{ + return mRenderer->getGPUDisjoint(); +} + +GLint64 Context9::getTimestamp() +{ + return mRenderer->getTimestamp(); +} + +void Context9::onMakeCurrent(const gl::ContextState &data) +{ +} + +const gl::Caps &Context9::getNativeCaps() const +{ + return mRenderer->getNativeCaps(); +} + +const gl::TextureCapsMap &Context9::getNativeTextureCaps() const +{ + return mRenderer->getNativeTextureCaps(); +} + +const gl::Extensions &Context9::getNativeExtensions() const +{ + return mRenderer->getNativeExtensions(); +} + +const gl::Limitations &Context9::getNativeLimitations() const +{ + return mRenderer->getNativeLimitations(); +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h new file mode 100644 index 00000000000..b450aea66ed --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h @@ -0,0 +1,125 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Context9: +// D3D9-specific functionality associated with a GL Context. +// + +#ifndef LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_ +#define LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_ + +#include "libANGLE/renderer/ContextImpl.h" + +namespace rx +{ +class Renderer9; + +class Context9 : public ContextImpl +{ + public: + Context9(const gl::ContextState &state, Renderer9 *renderer); + ~Context9() override; + + gl::Error initialize() override; + + // Shader creation + CompilerImpl *createCompiler() override; + ShaderImpl *createShader(const gl::ShaderState &data) override; + ProgramImpl *createProgram(const gl::ProgramState &data) override; + + // Framebuffer creation + FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; + + // Texture creation + TextureImpl *createTexture(const gl::TextureState &state) override; + + // Renderbuffer creation + RenderbufferImpl *createRenderbuffer() override; + + // Buffer creation + BufferImpl *createBuffer() override; + + // Vertex Array creation + VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; + + // Query and Fence creation + QueryImpl *createQuery(GLenum type) override; + FenceNVImpl *createFenceNV() override; + FenceSyncImpl *createFenceSync() override; + + // Transform Feedback creation + TransformFeedbackImpl *createTransformFeedback() override; + + // Sampler object creation + SamplerImpl *createSampler() override; + + // Flush and finish. + gl::Error flush() override; + gl::Error finish() override; + + // Drawing methods. + gl::Error drawArrays(GLenum mode, GLint first, GLsizei count) override; + gl::Error drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) override; + + gl::Error drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) override; + gl::Error drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) override; + gl::Error drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) override; + + // TODO(jmadill): Investigate proper impl methods for this. + void notifyDeviceLost() override; + bool isDeviceLost() const override; + bool testDeviceLost() override; + bool testDeviceResettable() override; + + // Vendor and description strings. + std::string getVendorString() const override; + std::string getRendererDescription() const override; + + // Debug markers. + void insertEventMarker(GLsizei length, const char *marker) override; + void pushGroupMarker(GLsizei length, const char *marker) override; + void popGroupMarker() override; + + // State sync with dirty bits. + void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override; + + // Disjoint timer queries + GLint getGPUDisjoint() override; + GLint64 getTimestamp() override; + + // Context switching + void onMakeCurrent(const gl::ContextState &data) override; + + // Caps queries + const gl::Caps &getNativeCaps() const override; + const gl::TextureCapsMap &getNativeTextureCaps() const override; + const gl::Extensions &getNativeExtensions() const override; + const gl::Limitations &getNativeLimitations() const override; + + private: + Renderer9 *mRenderer; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp index 9c269a85658..d7662fb194e 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp @@ -7,21 +7,23 @@ // Framebuffer9.cpp: Implements the Framebuffer9 class. #include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h" -#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" -#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h" -#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" -#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h" -#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" -#include "libANGLE/renderer/d3d/TextureD3D.h" -#include "libANGLE/formatutils.h" + #include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/Texture.h" +#include "libANGLE/formatutils.h" +#include "libANGLE/renderer/ContextImpl.h" +#include "libANGLE/renderer/d3d/TextureD3D.h" +#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" +#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" +#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h" +#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" +#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h" namespace rx { -Framebuffer9::Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer) +Framebuffer9::Framebuffer9(const gl::FramebufferState &data, Renderer9 *renderer) : FramebufferD3D(data, renderer), mRenderer(renderer) { ASSERT(mRenderer != nullptr); @@ -52,23 +54,25 @@ gl::Error Framebuffer9::invalidateSub(size_t, const GLenum *, const gl::Rectangl return gl::Error(GL_NO_ERROR); } -gl::Error Framebuffer9::clear(const gl::Data &data, const ClearParameters &clearParams) +gl::Error Framebuffer9::clearImpl(ContextImpl *context, const ClearParameters &clearParams) { - const gl::FramebufferAttachment *colorAttachment = mData.getColorAttachment(0); - const gl::FramebufferAttachment *depthStencilAttachment = mData.getDepthOrStencilAttachment(); + const gl::FramebufferAttachment *colorAttachment = mState.getColorAttachment(0); + const gl::FramebufferAttachment *depthStencilAttachment = mState.getDepthOrStencilAttachment(); - gl::Error error = mRenderer->applyRenderTarget(colorAttachment, depthStencilAttachment); + gl::Error error = + mRenderer->applyRenderTarget(context, colorAttachment, depthStencilAttachment); if (error.isError()) { return error; } - float nearZ = data.state->getNearPlane(); - float farZ = data.state->getFarPlane(); - mRenderer->setViewport(data.caps, data.state->getViewport(), nearZ, farZ, GL_TRIANGLES, - data.state->getRasterizerState().frontFace, true); + const gl::State &glState = context->getState(); + float nearZ = glState.getNearPlane(); + float farZ = glState.getFarPlane(); + mRenderer->setViewport(glState.getViewport(), nearZ, farZ, GL_TRIANGLES, + glState.getRasterizerState().frontFace, true); - mRenderer->setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled()); + mRenderer->setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled()); return mRenderer->clear(clearParams, colorAttachment, depthStencilAttachment); } @@ -82,7 +86,7 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area, { ASSERT(pack.pixelBuffer.get() == nullptr); - const gl::FramebufferAttachment *colorbuffer = mData.getColorAttachment(0); + const gl::FramebufferAttachment *colorbuffer = mState.getColorAttachment(0); ASSERT(colorbuffer); RenderTarget9 *renderTarget = nullptr; @@ -256,9 +260,14 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area, return gl::Error(GL_NO_ERROR); } -gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, - bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, - const gl::Framebuffer *sourceFramebuffer) +gl::Error Framebuffer9::blitImpl(const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + const gl::Rectangle *scissor, + bool blitRenderTarget, + bool blitDepth, + bool blitStencil, + GLenum filter, + const gl::Framebuffer *sourceFramebuffer) { ASSERT(filter == GL_NEAREST); @@ -280,7 +289,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl } ASSERT(readRenderTarget); - const gl::FramebufferAttachment *drawBuffer = mData.getColorAttachment(0); + const gl::FramebufferAttachment *drawBuffer = mState.getColorAttachment(0); ASSERT(drawBuffer); RenderTarget9 *drawRenderTarget = nullptr; @@ -406,7 +415,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl } ASSERT(readDepthStencil); - const gl::FramebufferAttachment *drawBuffer = mData.getDepthOrStencilAttachment(); + const gl::FramebufferAttachment *drawBuffer = mState.getDepthOrStencilAttachment(); ASSERT(drawBuffer); RenderTarget9 *drawDepthStencil = nullptr; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.h index fe12079ae0b..8401350b3d9 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.h @@ -18,7 +18,7 @@ class Renderer9; class Framebuffer9 : public FramebufferD3D { public: - Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer); + Framebuffer9(const gl::FramebufferState &data, Renderer9 *renderer); virtual ~Framebuffer9(); gl::Error discard(size_t count, const GLenum *attachments) override; @@ -26,7 +26,7 @@ class Framebuffer9 : public FramebufferD3D gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; private: - gl::Error clear(const gl::Data &data, const ClearParameters &clearParams) override; + gl::Error clearImpl(ContextImpl *context, const ClearParameters &clearParams) override; gl::Error readPixelsImpl(const gl::Rectangle &area, GLenum format, @@ -35,9 +35,14 @@ class Framebuffer9 : public FramebufferD3D const gl::PixelPackState &pack, uint8_t *pixels) const override; - gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, - bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, - const gl::Framebuffer *sourceFramebuffer) override; + gl::Error blitImpl(const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + const gl::Rectangle *scissor, + bool blitRenderTarget, + bool blitDepth, + bool blitStencil, + GLenum filter, + const gl::Framebuffer *sourceFramebuffer) override; GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp index 97c7f721366..40152df25d4 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp @@ -40,7 +40,7 @@ gl::Error IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bo } else if (indexType == GL_UNSIGNED_INT) { - ASSERT(mRenderer->getRendererExtensions().elementIndexUint); + ASSERT(mRenderer->getNativeExtensions().elementIndexUint); format = D3DFMT_INDEX32; } else UNREACHABLE(); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/NativeWindow9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/NativeWindow9.cpp new file mode 100644 index 00000000000..388b8aa168a --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/NativeWindow9.cpp @@ -0,0 +1,39 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindow9.cpp: Defines NativeWindow9, a class for managing and +// performing operations on an EGLNativeWindowType for the D3D9 renderer. + +#include "libANGLE/renderer/d3d/d3d9/NativeWindow9.h" + +namespace rx +{ +NativeWindow9::NativeWindow9(EGLNativeWindowType window) : NativeWindowD3D(window) +{ +} + +bool NativeWindow9::initialize() +{ + return true; +} + +bool NativeWindow9::getClientRect(LPRECT rect) const +{ + return GetClientRect(getNativeWindow(), rect) == TRUE; +} + +bool NativeWindow9::isIconic() const +{ + return IsIconic(getNativeWindow()) == TRUE; +} + +// static +bool NativeWindow9::IsValidNativeWindow(EGLNativeWindowType window) +{ + return IsWindow(window) == TRUE; +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/NativeWindow9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/NativeWindow9.h new file mode 100644 index 00000000000..a56b08dc81a --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/NativeWindow9.h @@ -0,0 +1,35 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// NativeWindow9.h: Defines NativeWindow9, a class for managing and +// performing operations on an EGLNativeWindowType for the D3D9 renderer. + +#ifndef LIBANGLE_RENDERER_D3D_D3D9_NATIVEWINDOW9_H_ +#define LIBANGLE_RENDERER_D3D_D3D9_NATIVEWINDOW9_H_ + +#include "common/debug.h" +#include "common/platform.h" + +#include "libANGLE/renderer/d3d/NativeWindowD3D.h" + +namespace rx +{ + +class NativeWindow9 : public NativeWindowD3D +{ + public: + explicit NativeWindow9(EGLNativeWindowType window); + + bool initialize() override; + bool getClientRect(LPRECT rect) const override; + bool isIconic() const override; + + static bool IsValidNativeWindow(EGLNativeWindowType window); +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_D3D_D3D9_NATIVEWINDOW9_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Query9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Query9.cpp index c826abf81cd..9e5a90a2ff8 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Query9.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Query9.cpp @@ -30,20 +30,25 @@ Query9::~Query9() gl::Error Query9::begin() { - if (mQuery == NULL) + D3DQUERYTYPE d3dQueryType = gl_d3d9::ConvertQueryType(getType()); + if (mQuery == nullptr) { - HRESULT result = mRenderer->getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery); + HRESULT result = mRenderer->getDevice()->CreateQuery(d3dQueryType, &mQuery); if (FAILED(result)) { return gl::Error(GL_OUT_OF_MEMORY, "Internal query creation failed, result: 0x%X.", result); } } - HRESULT result = mQuery->Issue(D3DISSUE_BEGIN); - ASSERT(SUCCEEDED(result)); - if (FAILED(result)) + if (d3dQueryType != D3DQUERYTYPE_EVENT) { - return gl::Error(GL_OUT_OF_MEMORY, "Failed to begin internal query, result: 0x%X.", result); + HRESULT result = mQuery->Issue(D3DISSUE_BEGIN); + ASSERT(SUCCEEDED(result)); + if (FAILED(result)) + { + return gl::Error(GL_OUT_OF_MEMORY, "Failed to begin internal query, result: 0x%X.", + result); + } } return gl::Error(GL_NO_ERROR); @@ -133,26 +138,40 @@ gl::Error Query9::testQuery() { ASSERT(mQuery); - DWORD numPixels = 0; - - HRESULT hres = mQuery->GetData(&numPixels, sizeof(DWORD), D3DGETDATA_FLUSH); - if (hres == S_OK) + HRESULT result = S_OK; + switch (getType()) { - mQueryFinished = true; + case GL_ANY_SAMPLES_PASSED_EXT: + case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: + { + DWORD numPixels = 0; + result = mQuery->GetData(&numPixels, sizeof(numPixels), D3DGETDATA_FLUSH); + if (result == S_OK) + { + mQueryFinished = true; + mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; + } + break; + } - switch (getType()) + case GL_COMMANDS_COMPLETED_CHROMIUM: { - case GL_ANY_SAMPLES_PASSED_EXT: - case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: - mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; + BOOL completed = FALSE; + result = mQuery->GetData(&completed, sizeof(completed), D3DGETDATA_FLUSH); + if (result == S_OK) + { + mQueryFinished = true; + mResult = (completed == TRUE) ? GL_TRUE : GL_FALSE; + } break; + } - default: + default: UNREACHABLE(); break; - } } - else if (d3d9::isDeviceLostError(hres)) + + if (d3d9::isDeviceLostError(result)) { mRenderer->notifyDeviceLost(); return gl::Error(GL_OUT_OF_MEMORY, "Failed to test get query result, device is lost."); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp index 04d0ce8d20d..32953593601 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp @@ -23,11 +23,13 @@ #include "libANGLE/Renderbuffer.h" #include "libANGLE/renderer/d3d/d3d9/Blit9.h" #include "libANGLE/renderer/d3d/d3d9/Buffer9.h" +#include "libANGLE/renderer/d3d/d3d9/Context9.h" #include "libANGLE/renderer/d3d/d3d9/Fence9.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h" #include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h" #include "libANGLE/renderer/d3d/d3d9/Image9.h" #include "libANGLE/renderer/d3d/d3d9/IndexBuffer9.h" +#include "libANGLE/renderer/d3d/d3d9/NativeWindow9.h" #include "libANGLE/renderer/d3d/d3d9/Query9.h" #include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h" #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" @@ -346,7 +348,7 @@ void Renderer9::initializeDevice() mDevice->SetRenderState(D3DRS_POINTSIZE_MAX, 0x3F800000); // 1.0f } - const gl::Caps &rendererCaps = getRendererCaps(); + const gl::Caps &rendererCaps = getNativeCaps(); mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits); mCurPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits); @@ -366,7 +368,7 @@ void Renderer9::initializeDevice() mVertexDataManager = new VertexDataManager(this); mIndexDataManager = new IndexDataManager(this, getRendererClass()); - mTranslatedAttribCache.resize(getRendererCaps().maxVertexAttributes); + mTranslatedAttribCache.resize(getNativeCaps().maxVertexAttributes); mStateManager.initialize(); } @@ -412,8 +414,8 @@ egl::ConfigSet Renderer9::generateConfigs() const GL_DEPTH_COMPONENT16, }; - const gl::Caps &rendererCaps = getRendererCaps(); - const gl::TextureCapsMap &rendererTextureCaps = getRendererTextureCaps(); + const gl::Caps &rendererCaps = getNativeCaps(); + const gl::TextureCapsMap &rendererTextureCaps = getNativeTextureCaps(); D3DDISPLAYMODE currentDisplayMode; mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); @@ -657,19 +659,31 @@ gl::Error Renderer9::finish() return gl::Error(GL_NO_ERROR); } -SwapChainD3D *Renderer9::createSwapChain(NativeWindow nativeWindow, +bool Renderer9::isValidNativeWindow(EGLNativeWindowType window) const +{ + return NativeWindow9::IsValidNativeWindow(window); +} + +NativeWindowD3D *Renderer9::createNativeWindow(EGLNativeWindowType window, + const egl::Config *, + const egl::AttributeMap &) const +{ + return new NativeWindow9(window); +} + +SwapChainD3D *Renderer9::createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) { - return new SwapChain9(this, nativeWindow, shareHandle, backBufferFormat, depthBufferFormat, - orientation); + return new SwapChain9(this, GetAs<NativeWindow9>(nativeWindow), shareHandle, backBufferFormat, + depthBufferFormat, orientation); } -CompilerImpl *Renderer9::createCompiler() +ContextImpl *Renderer9::createContext(const gl::ContextState &state) { - return new CompilerD3D(SH_HLSL_3_0_OUTPUT); + return new Context9(state, this); } void *Renderer9::getD3DDevice() @@ -741,39 +755,9 @@ IndexBuffer *Renderer9::createIndexBuffer() return new IndexBuffer9(this); } -BufferImpl *Renderer9::createBuffer() -{ - return new Buffer9(this); -} - -VertexArrayImpl *Renderer9::createVertexArray(const gl::VertexArray::Data &data) -{ - return new VertexArray9(data); -} - -QueryImpl *Renderer9::createQuery(GLenum type) -{ - return new Query9(this, type); -} - -FenceNVImpl *Renderer9::createFenceNV() -{ - return new FenceNV9(this); -} - -FenceSyncImpl *Renderer9::createFenceSync() -{ - // Renderer9 doesn't support ES 3.0 and its sync objects. - UNREACHABLE(); - return NULL; -} - -TransformFeedbackImpl* Renderer9::createTransformFeedback() -{ - return new TransformFeedbackD3D(); -} - -StreamImpl *Renderer9::createStream(const egl::AttributeMap &attribs) +StreamProducerImpl *Renderer9::createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) { // Streams are not supported under D3D9 UNREACHABLE(); @@ -840,7 +824,7 @@ gl::Error Renderer9::setSamplerState(gl::SamplerType type, int index, gl::Textur mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter); mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, baseLevel); mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPMAPLODBIAS, static_cast<DWORD>(lodBias)); - if (getRendererExtensions().textureFilterAnisotropic) + if (getNativeExtensions().textureFilterAnisotropic) { mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)samplerState.maxAnisotropy); } @@ -901,36 +885,28 @@ gl::Error Renderer9::setTexture(gl::SamplerType type, int index, gl::Texture *te return gl::Error(GL_NO_ERROR); } -gl::Error Renderer9::setUniformBuffers(const gl::Data &/*data*/, - const std::vector<GLint> &/*vertexUniformBuffers*/, - const std::vector<GLint> &/*fragmentUniformBuffers*/) +gl::Error Renderer9::setUniformBuffers(const gl::ContextState & /*data*/, + const std::vector<GLint> & /*vertexUniformBuffers*/, + const std::vector<GLint> & /*fragmentUniformBuffers*/) { // No effect in ES2/D3D9 return gl::Error(GL_NO_ERROR); } -void Renderer9::syncState(const gl::State &state, const gl::State::DirtyBits &bitmask) +gl::Error Renderer9::updateState(Context9 *context, GLenum drawMode) { - mStateManager.syncState(state, bitmask); -} + const auto &data = context->getContextState(); -gl::Error Renderer9::updateState(const gl::Data &data, GLenum drawMode) -{ // Applies the render target surface, depth stencil surface, viewport rectangle and // scissor rectangle to the renderer const gl::Framebuffer *framebufferObject = data.state->getDrawFramebuffer(); ASSERT(framebufferObject && framebufferObject->checkStatus(data) == GL_FRAMEBUFFER_COMPLETE); - gl::Error error = applyRenderTarget(framebufferObject); - if (error.isError()) - { - return error; - } + ANGLE_TRY(applyRenderTarget(context, framebufferObject)); // Setting viewport state - setViewport(data.caps, data.state->getViewport(), data.state->getNearPlane(), - data.state->getFarPlane(), drawMode, data.state->getRasterizerState().frontFace, - false); + setViewport(data.state->getViewport(), data.state->getNearPlane(), data.state->getFarPlane(), + drawMode, data.state->getRasterizerState().frontFace, false); // Setting scissors state setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled()); @@ -942,16 +918,11 @@ gl::Error Renderer9::updateState(const gl::Data &data, GLenum drawMode) rasterizer.multiSample = (samples != 0); unsigned int mask = GetBlendSampleMask(data, samples); - error = setBlendDepthRasterStates(data, mask); - - if (error.isError()) - { - return error; - } + ANGLE_TRY(setBlendDepthRasterStates(data, mask)); mStateManager.resetDirtyBits(); - return error; + return gl::NoError(); } void Renderer9::setScissorRectangle(const gl::Rectangle &scissor, bool enabled) @@ -959,7 +930,7 @@ void Renderer9::setScissorRectangle(const gl::Rectangle &scissor, bool enabled) mStateManager.setScissorState(scissor, enabled); } -gl::Error Renderer9::setBlendDepthRasterStates(const gl::Data &glData, GLenum drawMode) +gl::Error Renderer9::setBlendDepthRasterStates(const gl::ContextState &glData, GLenum drawMode) { int samples = glData.state->getDrawFramebuffer()->getSamples(glData); gl::RasterizerState rasterizer = glData.state->getRasterizerState(); @@ -970,16 +941,14 @@ gl::Error Renderer9::setBlendDepthRasterStates(const gl::Data &glData, GLenum dr return mStateManager.setBlendDepthRasterStates(*glData.state, mask); } -void Renderer9::setViewport(const gl::Caps *caps, - const gl::Rectangle &viewport, +void Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace, bool ignoreViewport) { - mStateManager.setViewportState(caps, viewport, zNear, zFar, drawMode, frontFace, - ignoreViewport); + mStateManager.setViewportState(viewport, zNear, zFar, drawMode, frontFace, ignoreViewport); } bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize) @@ -1022,8 +991,9 @@ bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSiz return mPrimitiveCount > 0; } - -gl::Error Renderer9::getNullColorbuffer(const gl::FramebufferAttachment *depthbuffer, const gl::FramebufferAttachment **outColorBuffer) +gl::Error Renderer9::getNullColorbuffer(GLImplFactory *implFactory, + const gl::FramebufferAttachment *depthbuffer, + const gl::FramebufferAttachment **outColorBuffer) { ASSERT(depthbuffer); @@ -1042,7 +1012,7 @@ gl::Error Renderer9::getNullColorbuffer(const gl::FramebufferAttachment *depthbu } } - gl::Renderbuffer *nullRenderbuffer = new gl::Renderbuffer(createRenderbuffer(), 0); + gl::Renderbuffer *nullRenderbuffer = new gl::Renderbuffer(implFactory->createRenderbuffer(), 0); gl::Error error = nullRenderbuffer->setStorage(GL_NONE, size.width, size.height); if (error.isError()) { @@ -1072,7 +1042,8 @@ gl::Error Renderer9::getNullColorbuffer(const gl::FramebufferAttachment *depthbu return gl::Error(GL_NO_ERROR); } -gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorAttachment, +gl::Error Renderer9::applyRenderTarget(GLImplFactory *implFactory, + const gl::FramebufferAttachment *colorAttachment, const gl::FramebufferAttachment *depthStencilAttachment) { const gl::FramebufferAttachment *renderAttachment = colorAttachment; @@ -1082,7 +1053,7 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorAtt // to keep the D3D runtime happy. This should only be possible if depth texturing. if (renderAttachment == nullptr) { - error = getNullColorbuffer(depthStencilAttachment, &renderAttachment); + error = getNullColorbuffer(implFactory, depthStencilAttachment, &renderAttachment); if (error.isError()) { return error; @@ -1176,9 +1147,11 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorAtt return gl::Error(GL_NO_ERROR); } -gl::Error Renderer9::applyRenderTarget(const gl::Framebuffer *framebuffer) +gl::Error Renderer9::applyRenderTarget(GLImplFactory *implFactory, + const gl::Framebuffer *framebuffer) { - return applyRenderTarget(framebuffer->getColorbuffer(0), framebuffer->getDepthOrStencilbuffer()); + return applyRenderTarget(implFactory, framebuffer->getColorbuffer(0), + framebuffer->getDepthOrStencilbuffer()); } gl::Error Renderer9::applyVertexBuffer(const gl::State &state, @@ -1199,7 +1172,7 @@ gl::Error Renderer9::applyVertexBuffer(const gl::State &state, } // Applies the indices and element array bindings to the Direct3D 9 device -gl::Error Renderer9::applyIndexBuffer(const gl::Data &data, +gl::Error Renderer9::applyIndexBuffer(const gl::ContextState &data, const GLvoid *indices, GLsizei count, GLenum mode, @@ -1235,7 +1208,7 @@ gl::Error Renderer9::applyTransformFeedbackBuffers(const gl::State &state) return gl::Error(GL_NO_ERROR); } -gl::Error Renderer9::drawArraysImpl(const gl::Data &data, +gl::Error Renderer9::drawArraysImpl(const gl::ContextState &data, GLenum mode, GLint startVertex, GLsizei count, @@ -1280,7 +1253,7 @@ gl::Error Renderer9::drawArraysImpl(const gl::Data &data, } } -gl::Error Renderer9::drawElementsImpl(const gl::Data &data, +gl::Error Renderer9::drawElementsImpl(const gl::ContextState &data, const TranslatedIndexData &indexInfo, GLenum mode, GLsizei count, @@ -1334,7 +1307,7 @@ gl::Error Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indi unsigned int startIndex = 0; - if (getRendererExtensions().elementIndexUint) + if (getNativeExtensions().elementIndexUint) { if (!mLineLoopIB) { @@ -1578,7 +1551,7 @@ gl::Error Renderer9::getCountingIB(size_t count, StaticIndexBufferInterface **ou } } } - else if (getRendererExtensions().elementIndexUint) + else if (getNativeExtensions().elementIndexUint) { const unsigned int spaceNeeded = static_cast<unsigned int>(count) * sizeof(unsigned int); @@ -1617,7 +1590,7 @@ gl::Error Renderer9::getCountingIB(size_t count, StaticIndexBufferInterface **ou return gl::Error(GL_NO_ERROR); } -gl::Error Renderer9::applyShadersImpl(const gl::Data &data, GLenum /*drawMode*/) +gl::Error Renderer9::applyShadersImpl(const gl::ContextState &data, GLenum /*drawMode*/) { ProgramD3D *programD3D = GetImplAs<ProgramD3D>(data.state->getProgram()); const auto &inputLayout = programD3D->getCachedInputLayout(); @@ -2370,7 +2343,7 @@ gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GL { const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(format); - const gl::TextureCaps &textureCaps = getRendererTextureCaps().get(format); + const gl::TextureCaps &textureCaps = getNativeTextureCaps().get(format); GLuint supportedSamples = textureCaps.getNearestSamples(samples); IDirect3DTexture9 *texture = nullptr; @@ -2459,21 +2432,6 @@ gl::Error Renderer9::createRenderTargetCopy(RenderTargetD3D *source, RenderTarge return gl::Error(GL_NO_ERROR); } -FramebufferImpl *Renderer9::createFramebuffer(const gl::Framebuffer::Data &data) -{ - return new Framebuffer9(data, this); -} - -ShaderImpl *Renderer9::createShader(const gl::Shader::Data &data) -{ - return new ShaderD3D(data); -} - -ProgramImpl *Renderer9::createProgram(const gl::Program::Data &data) -{ - return new ProgramD3D(data, this); -} - gl::Error Renderer9::loadExecutable(const void *function, size_t length, ShaderType type, @@ -2697,6 +2655,14 @@ TextureStorage *Renderer9::createTextureStorageEGLImage(EGLImageD3D *eglImage) return new TextureStorage9_EGLImage(this, eglImage); } +TextureStorage *Renderer9::createTextureStorageExternal( + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) +{ + UNIMPLEMENTED(); + return nullptr; +} + TextureStorage *Renderer9::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly) { return new TextureStorage9_2D(this, internalformat, renderTarget, width, height, levels); @@ -2723,24 +2689,6 @@ TextureStorage *Renderer9::createTextureStorage2DArray(GLenum internalformat, bo return NULL; } -TextureImpl *Renderer9::createTexture(GLenum target) -{ - switch(target) - { - case GL_TEXTURE_2D: return new TextureD3D_2D(this); - case GL_TEXTURE_CUBE_MAP: return new TextureD3D_Cube(this); - default: UNREACHABLE(); - } - - return NULL; -} - -RenderbufferImpl *Renderer9::createRenderbuffer() -{ - RenderbufferD3D *renderbuffer = new RenderbufferD3D(this); - return renderbuffer; -} - bool Renderer9::getLUID(LUID *adapterLuid) const { adapterLuid->HighPart = 0; @@ -2858,4 +2806,100 @@ Renderer9::CurSamplerState::CurSamplerState() { } +gl::Error Renderer9::genericDrawElements(Context9 *context, + GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) +{ + const auto &data = context->getContextState(); + gl::Program *program = context->getState().getProgram(); + ASSERT(program != nullptr); + ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); + bool usesPointSize = programD3D->usesPointSize(); + + programD3D->updateSamplerMapping(); + + ANGLE_TRY(generateSwizzles(data)); + + if (!applyPrimitiveType(mode, count, usesPointSize)) + { + return gl::NoError(); + } + + ANGLE_TRY(updateState(context, mode)); + + TranslatedIndexData indexInfo; + indexInfo.indexRange = indexRange; + + ANGLE_TRY(applyIndexBuffer(data, indices, count, mode, type, &indexInfo)); + + applyTransformFeedbackBuffers(*data.state); + // Transform feedback is not allowed for DrawElements, this error should have been caught at the + // API validation + // layer. + ASSERT(!data.state->isTransformFeedbackActiveUnpaused()); + + size_t vertexCount = indexInfo.indexRange.vertexCount(); + ANGLE_TRY(applyVertexBuffer(*data.state, mode, static_cast<GLsizei>(indexInfo.indexRange.start), + static_cast<GLsizei>(vertexCount), instances, &indexInfo)); + ANGLE_TRY(applyTextures(context, data)); + ANGLE_TRY(applyShaders(data, mode)); + ANGLE_TRY(programD3D->applyUniformBuffers(data)); + + if (!skipDraw(data, mode)) + { + ANGLE_TRY(drawElementsImpl(data, indexInfo, mode, count, type, indices, instances)); + } + + return gl::NoError(); +} + +gl::Error Renderer9::genericDrawArrays(Context9 *context, + GLenum mode, + GLint first, + GLsizei count, + GLsizei instances) +{ + const auto &data = context->getContextState(); + gl::Program *program = context->getState().getProgram(); + ASSERT(program != nullptr); + ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program); + bool usesPointSize = programD3D->usesPointSize(); + + programD3D->updateSamplerMapping(); + + ANGLE_TRY(generateSwizzles(data)); + if (!applyPrimitiveType(mode, count, usesPointSize)) + { + return gl::NoError(); + } + + ANGLE_TRY(updateState(context, mode)); + ANGLE_TRY(applyTransformFeedbackBuffers(*data.state)); + ANGLE_TRY(applyVertexBuffer(*data.state, mode, first, count, instances, nullptr)); + ANGLE_TRY(applyTextures(context, data)); + ANGLE_TRY(applyShaders(data, mode)); + ANGLE_TRY(programD3D->applyUniformBuffers(data)); + + if (!skipDraw(data, mode)) + { + ANGLE_TRY(drawArraysImpl(data, mode, first, count, instances)); + + if (data.state->isTransformFeedbackActiveUnpaused()) + { + ANGLE_TRY(markTransformFeedbackUsage(data)); + } + } + + return gl::NoError(); +} + +FramebufferImpl *Renderer9::createDefaultFramebuffer(const gl::FramebufferState &state) +{ + return new Framebuffer9(state, this); } + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h index b6456ae12f5..2b7f9aac3f8 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h @@ -32,6 +32,7 @@ class AttributeMap; namespace rx { class Blit9; +class Context9; class IndexDataManager; class ProgramD3D; class StreamingIndexBufferInterface; @@ -76,16 +77,21 @@ class Renderer9 : public RendererD3D void startScene(); void endScene(); - gl::Error flush() override; - gl::Error finish() override; + gl::Error flush(); + gl::Error finish(); - SwapChainD3D *createSwapChain(NativeWindow nativeWindow, + bool isValidNativeWindow(EGLNativeWindowType window) const override; + NativeWindowD3D *createNativeWindow(EGLNativeWindowType window, + const egl::Config *config, + const egl::AttributeMap &attribs) const override; + + SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) override; - CompilerImpl *createCompiler() override; + ContextImpl *createContext(const gl::ContextState &state) override; gl::Error allocateEventQuery(IDirect3DQuery9 **outQuery); void freeEventQuery(IDirect3DQuery9* query); @@ -99,42 +105,42 @@ class Renderer9 : public RendererD3D virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler); virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture); - gl::Error setUniformBuffers(const gl::Data &data, + gl::Error setUniformBuffers(const gl::ContextState &data, const std::vector<GLint> &vertexUniformBuffers, const std::vector<GLint> &fragmentUniformBuffers) override; - gl::Error updateState(const gl::Data &data, GLenum drawMode) override; + gl::Error updateState(Context9 *context, GLenum drawMode); void setScissorRectangle(const gl::Rectangle &scissor, bool enabled); - void setViewport(const gl::Caps *caps, - const gl::Rectangle &viewport, + void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace, bool ignoreViewport); - gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override; - gl::Error applyRenderTarget(const gl::FramebufferAttachment *colorAttachment, + gl::Error applyRenderTarget(GLImplFactory *implFactory, const gl::Framebuffer *frameBuffer); + gl::Error applyRenderTarget(GLImplFactory *implFactory, + const gl::FramebufferAttachment *colorAttachment, const gl::FramebufferAttachment *depthStencilAttachment); gl::Error applyUniforms(const ProgramD3D &programD3D, GLenum drawMode, const std::vector<D3DUniform *> &uniformArray) override; - virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize); - virtual gl::Error applyVertexBuffer(const gl::State &state, - GLenum mode, - GLint first, - GLsizei count, - GLsizei instances, - TranslatedIndexData *indexInfo); - gl::Error applyIndexBuffer(const gl::Data &data, + bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize); + gl::Error applyVertexBuffer(const gl::State &state, + GLenum mode, + GLint first, + GLsizei count, + GLsizei instances, + TranslatedIndexData *indexInfo); + gl::Error applyIndexBuffer(const gl::ContextState &data, const GLvoid *indices, GLsizei count, GLenum mode, GLenum type, - TranslatedIndexData *indexInfo) override; + TranslatedIndexData *indexInfo); - gl::Error applyTransformFeedbackBuffers(const gl::State &state) override; + gl::Error applyTransformFeedbackBuffers(const gl::State &state); gl::Error clear(const ClearParameters &clearParams, const gl::FramebufferAttachment *colorBuffer, @@ -144,19 +150,19 @@ class Renderer9 : public RendererD3D // lost device bool testDeviceLost() override; - bool testDeviceResettable() override; + bool testDeviceResettable(); VendorID getVendorId() const; - std::string getRendererDescription() const override; + std::string getRendererDescription() const; DeviceIdentifier getAdapterIdentifier() const override; IDirect3DDevice9 *getDevice() { return mDevice; } void *getD3DDevice() override; - virtual unsigned int getReservedVertexUniformVectors() const; - virtual unsigned int getReservedFragmentUniformVectors() const; - virtual unsigned int getReservedVertexUniformBuffers() const; - virtual unsigned int getReservedFragmentUniformBuffers() const; + unsigned int getReservedVertexUniformVectors() const override; + unsigned int getReservedFragmentUniformVectors() const override; + unsigned int getReservedVertexUniformBuffers() const override; + unsigned int getReservedFragmentUniformBuffers() const override; bool getShareHandleSupport() const; @@ -167,26 +173,40 @@ class Renderer9 : public RendererD3D DWORD getCapsDeclTypes() const; // Pixel operations - virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLint level); - virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level); - virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLint level); - virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, - const gl::Offset &destOffset, TextureStorage *storage, GLint level); + gl::Error copyImage2D(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLint level) override; + gl::Error copyImageCube(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLenum target, + GLint level) override; + gl::Error copyImage3D(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLint level) override; + gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, + const gl::Rectangle &sourceRect, + GLenum destFormat, + const gl::Offset &destOffset, + TextureStorage *storage, + GLint level) override; // RenderTarget creation - virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT); + gl::Error createRenderTarget(int width, + int height, + GLenum format, + GLsizei samples, + RenderTargetD3D **outRT) override; gl::Error createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT) override; - // Framebuffer creation - FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override; - - // Shader creation - ShaderImpl *createShader(const gl::Shader::Data &data) override; - ProgramImpl *createProgram(const gl::Program::Data &data) override; - // Shader operations gl::Error loadExecutable(const void *function, size_t length, @@ -204,49 +224,53 @@ class Renderer9 : public RendererD3D UniformStorageD3D *createUniformStorage(size_t storageSize) override; // Image operations - virtual ImageD3D *createImage(); + ImageD3D *createImage() override; gl::Error generateMipmap(ImageD3D *dest, ImageD3D *source) override; gl::Error generateMipmapsUsingD3D(TextureStorage *storage, const gl::TextureState &textureState) override; virtual TextureStorage *createTextureStorage2D(SwapChainD3D *swapChain); TextureStorage *createTextureStorageEGLImage(EGLImageD3D *eglImage) override; - virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly); - virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels, bool hintLevelZeroOnly); - virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels); - virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels); - - // Texture creation - virtual TextureImpl *createTexture(GLenum target); - - // Renderbuffer creation - virtual RenderbufferImpl *createRenderbuffer(); + TextureStorage *createTextureStorageExternal( + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) override; + TextureStorage *createTextureStorage2D(GLenum internalformat, + bool renderTarget, + GLsizei width, + GLsizei height, + int levels, + bool hintLevelZeroOnly) override; + TextureStorage *createTextureStorageCube(GLenum internalformat, + bool renderTarget, + int size, + int levels, + bool hintLevelZeroOnly) override; + TextureStorage *createTextureStorage3D(GLenum internalformat, + bool renderTarget, + GLsizei width, + GLsizei height, + GLsizei depth, + int levels) override; + TextureStorage *createTextureStorage2DArray(GLenum internalformat, + bool renderTarget, + GLsizei width, + GLsizei height, + GLsizei depth, + int levels) override; // Buffer creation - virtual BufferImpl *createBuffer(); - virtual VertexBuffer *createVertexBuffer(); - virtual IndexBuffer *createIndexBuffer(); - - // Vertex Array creation - VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override; - - // Query and Fence creation - virtual QueryImpl *createQuery(GLenum type); - virtual FenceNVImpl *createFenceNV(); - virtual FenceSyncImpl *createFenceSync(); - - // Transform Feedback creation - virtual TransformFeedbackImpl* createTransformFeedback(); + VertexBuffer *createVertexBuffer() override; + IndexBuffer *createIndexBuffer() override; // Stream Creation - StreamImpl *createStream(const egl::AttributeMap &attribs) override; + StreamProducerImpl *createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) override; // Buffer-to-texture and Texture-to-buffer copies virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const; virtual gl::Error fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTargetD3D *destRenderTarget, GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea); - void syncState(const gl::State &state, const gl::State::DirtyBits &bitmask) override; - // D3D9-renderer specific methods gl::Error boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest); @@ -267,18 +291,37 @@ class Renderer9 : public RendererD3D egl::Error getEGLDevice(DeviceImpl **device) override; + StateManager9 *getStateManager() { return &mStateManager; } + + gl::Error genericDrawArrays(Context9 *context, + GLenum mode, + GLint first, + GLsizei count, + GLsizei instances); + + gl::Error genericDrawElements(Context9 *context, + GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange); + + // Necessary hack for default framebuffers in D3D. + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; + protected: void createAnnotator() override; gl::Error clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd) override; - gl::Error applyShadersImpl(const gl::Data &data, GLenum drawMode) override; + gl::Error applyShadersImpl(const gl::ContextState &data, GLenum drawMode) override; private: - gl::Error drawArraysImpl(const gl::Data &data, + gl::Error drawArraysImpl(const gl::ContextState &data, GLenum mode, GLint startVertex, GLsizei count, GLsizei instances) override; - gl::Error drawElementsImpl(const gl::Data &data, + gl::Error drawElementsImpl(const gl::ContextState &data, const TranslatedIndexData &indexInfo, GLenum mode, GLsizei count, @@ -292,7 +335,7 @@ class Renderer9 : public RendererD3D WorkaroundsD3D generateWorkarounds() const override; - gl::Error setBlendDepthRasterStates(const gl::Data &glData, GLenum drawMode); + gl::Error setBlendDepthRasterStates(const gl::ContextState &glData, GLenum drawMode); void release(); @@ -305,7 +348,9 @@ class Renderer9 : public RendererD3D gl::Error getCountingIB(size_t count, StaticIndexBufferInterface **outIB); - gl::Error getNullColorbuffer(const gl::FramebufferAttachment *depthbuffer, const gl::FramebufferAttachment **outColorBuffer); + gl::Error getNullColorbuffer(GLImplFactory *implFactory, + const gl::FramebufferAttachment *depthbuffer, + const gl::FramebufferAttachment **outColorBuffer); D3DPOOL getBufferPool(DWORD usage) const; @@ -400,5 +445,6 @@ class Renderer9 : public RendererD3D std::vector<TranslatedAttribute> mTranslatedAttribCache; }; -} +} // namespace rx + #endif // LIBANGLE_RENDERER_D3D_D3D9_RENDERER9_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp index 97f77bd5b92..d9afddb32ed 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp @@ -473,8 +473,7 @@ gl::Error StateManager9::setBlendDepthRasterStates(const gl::State &glState, return gl::Error(GL_NO_ERROR); } -void StateManager9::setViewportState(const gl::Caps *caps, - const gl::Rectangle &viewport, +void StateManager9::setViewportState(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.h index 0ecbbb61ecf..bd2cef2e55c 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.h @@ -10,7 +10,7 @@ #define LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_ #include "libANGLE/angletypes.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/State.h" #include "libANGLE/renderer/d3d/RendererD3D.h" @@ -45,8 +45,7 @@ class StateManager9 final : angle::NonCopyable gl::Error setBlendDepthRasterStates(const gl::State &glState, unsigned int sampleMask); void setScissorState(const gl::Rectangle &scissor, bool enabled); - void setViewportState(const gl::Caps *caps, - const gl::Rectangle &viewport, + void setViewportState(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp index be6a9c424ca..4484fccfe18 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp @@ -9,6 +9,7 @@ #include "libANGLE/renderer/d3d/d3d9/SwapChain9.h" #include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h" +#include "libANGLE/renderer/d3d/d3d9/NativeWindow9.h" #include "libANGLE/renderer/d3d/d3d9/Renderer9.h" #include "libANGLE/features.h" @@ -16,16 +17,17 @@ namespace rx { SwapChain9::SwapChain9(Renderer9 *renderer, - NativeWindow nativeWindow, + NativeWindow9 *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) - : SwapChainD3D(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat), + : SwapChainD3D(shareHandle, backBufferFormat, depthBufferFormat), mRenderer(renderer), mWidth(-1), mHeight(-1), mSwapInterval(-1), + mNativeWindow(nativeWindow), mSwapChain(nullptr), mBackBuffer(nullptr), mRenderTarget(nullptr), @@ -50,7 +52,7 @@ void SwapChain9::release() SafeRelease(mRenderTarget); SafeRelease(mOffscreenTexture); - if (mNativeWindow.getNativeWindow()) + if (mNativeWindow->getNativeWindow()) { mShareHandle = NULL; } @@ -104,7 +106,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI SafeRelease(mDepthStencil); HANDLE *pShareHandle = NULL; - if (!mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport()) + if (!mNativeWindow->getNativeWindow() && mRenderer->getShareHandleSupport()) { pShareHandle = &mShareHandle; } @@ -163,7 +165,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI // Don't create a swapchain for NULLREF devices D3DDEVTYPE deviceType = mRenderer->getD3D9DeviceType(); - EGLNativeWindowType window = mNativeWindow.getNativeWindow(); + EGLNativeWindowType window = mNativeWindow->getNativeWindow(); if (window && deviceType != D3DDEVTYPE_NULLREF) { D3DPRESENT_PARAMETERS presentParameters = {0}; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h index 55a700c2d64..7c21b178806 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h @@ -15,13 +15,14 @@ namespace rx { +class NativeWindow9; class Renderer9; class SwapChain9 : public SwapChainD3D { public: SwapChain9(Renderer9 *renderer, - NativeWindow nativeWindow, + NativeWindow9 *nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat, @@ -53,6 +54,8 @@ class SwapChain9 : public SwapChainD3D EGLint mHeight; EGLint mSwapInterval; + NativeWindow9 *mNativeWindow; + IDirect3DSwapChain9 *mSwapChain; IDirect3DSurface9 *mBackBuffer; IDirect3DSurface9 *mRenderTarget; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/VertexArray9.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/VertexArray9.h index 992201737f8..28b8717e6ea 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/VertexArray9.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/VertexArray9.h @@ -19,10 +19,7 @@ class Renderer9; class VertexArray9 : public VertexArrayImpl { public: - VertexArray9(const gl::VertexArray::Data &data) - : VertexArrayImpl(data) - { - } + VertexArray9(const gl::VertexArrayState &data) : VertexArrayImpl(data) {} virtual ~VertexArray9() { } }; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp index 8622dc4d132..b55f7dcfe07 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp @@ -264,6 +264,21 @@ void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DT } } +D3DQUERYTYPE ConvertQueryType(GLenum queryType) +{ + switch (queryType) + { + case GL_ANY_SAMPLES_PASSED_EXT: + case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: + return D3DQUERYTYPE_OCCLUSION; + case GL_COMMANDS_COMPLETED_CHROMIUM: + return D3DQUERYTYPE_EVENT; + default: + UNREACHABLE(); + return static_cast<D3DQUERYTYPE>(0); + } +} + D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples) { return (samples > 1) ? static_cast<D3DMULTISAMPLE_TYPE>(samples) : D3DMULTISAMPLE_NONE; @@ -579,6 +594,8 @@ void GenerateCaps(IDirect3D9 *d3d9, extensions->packSubimage = true; extensions->vertexArrayObject = true; extensions->noError = true; + extensions->bindUniformLocation = true; + extensions->syncQuery = extensions->fence; // D3D9 has no concept of separate masks and refs for front and back faces in the depth stencil // state. diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.h b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.h index aa494adb62f..5e2b6d25490 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.h @@ -39,6 +39,7 @@ DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha); D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy); void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float *d3dLodBias, float maxAnisotropy, size_t baseLevel); +D3DQUERYTYPE ConvertQueryType(GLenum queryType); D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/d3d/loadimage_etc.cpp b/chromium/third_party/angle/src/libANGLE/renderer/d3d/loadimage_etc.cpp index 26a3b32ce08..cdb9389b3aa 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/d3d/loadimage_etc.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/d3d/loadimage_etc.cpp @@ -45,14 +45,6 @@ static const int intensityModifierNonOpaque[][4] = }; // clang-format on -// Table C.7, mapping from pixel index values to modifier value orders -// clang-format off -static const int valueMappingTable[] = -{ - 2, 3, 1, 0 -}; -// clang-format on - struct ETC2Block { // Decodes unsigned single or dual channel block to bytes @@ -738,8 +730,8 @@ struct ETC2Block void packBC1(void *bc1, const R8G8B8A8 *rgba, - R8G8B8A8 &minColor, - R8G8B8A8 &maxColor, + const R8G8B8A8 &minColor, + const R8G8B8A8 &maxColor, bool opaque) const { uint32_t bits; @@ -854,7 +846,6 @@ struct ETC2Block } void decodeSubblock(R8G8B8A8 *rgbaBlock, - size_t pixelRange[2][2], size_t x, size_t y, size_t w, @@ -880,19 +871,125 @@ struct ETC2Block for (size_t i = dxBegin; i < dxEnd && (x + i) < w; i++) { const size_t pixelIndex = getIndex(i, j); - if (valueMappingTable[pixelIndex] < valueMappingTable[pixelRange[subblockIdx][0]]) - { - pixelRange[subblockIdx][0] = pixelIndex; - } - if (valueMappingTable[pixelIndex] > valueMappingTable[pixelRange[subblockIdx][1]]) - { - pixelRange[subblockIdx][1] = pixelIndex; - } + row[i] = subblockColors[subblockIdx][pixelIndex]; + row[i].A = alphaValues[j][i]; + } + } + } - row[i] = subblockColors[subblockIdx][pixelIndex]; - row[i].A = alphaValues[j][i]; + void selectEndPointPCA(const R8G8B8A8 *pixels, R8G8B8A8 *minColor, R8G8B8A8 *maxColor) const + { + static const int kNumPixels = 16; + + // determine color distribution + int mu[3], min[3], max[3]; + for (int ch = 0; ch < 3; ch++) + { + int muv, minv, maxv; + + muv = minv = maxv = (&pixels[0].R)[ch]; + for (size_t i = 1; i < kNumPixels; i++) + { + muv += (&pixels[i].R)[ch]; + minv = std::min<int>(minv, (&pixels[i].R)[ch]); + maxv = std::max<int>(maxv, (&pixels[i].R)[ch]); + } + + mu[ch] = (muv + kNumPixels / 2) / kNumPixels; + min[ch] = minv; + max[ch] = maxv; + } + + // determine covariance matrix + int cov[6] = {0, 0, 0, 0, 0, 0}; + for (size_t i = 0; i < kNumPixels; i++) + { + int r = pixels[i].R - mu[0]; + int g = pixels[i].G - mu[1]; + int b = pixels[i].B - mu[2]; + + cov[0] += r * r; + cov[1] += r * g; + cov[2] += r * b; + cov[3] += g * g; + cov[4] += g * b; + cov[5] += b * b; + } + + // Power iteration algorithm to get the eigenvalues and eigenvector + + // Starts with diagonal vector + float vfr = static_cast<float>(max[0] - min[0]); + float vfg = static_cast<float>(max[1] - min[1]); + float vfb = static_cast<float>(max[2] - min[2]); + float eigenvalue; + + static const size_t kPowerIterations = 4; + for (size_t i = 0; i < kPowerIterations; i++) + { + float r = vfr * cov[0] + vfg * cov[1] + vfb * cov[2]; + float g = vfr * cov[1] + vfg * cov[3] + vfb * cov[4]; + float b = vfr * cov[2] + vfg * cov[4] + vfb * cov[5]; + + vfr = r; + vfg = g; + vfb = b; + + eigenvalue = sqrt(r * r + g * g + b * b); + if (eigenvalue > 0) + { + float invNorm = 1.0f / eigenvalue; + vfr *= invNorm; + vfg *= invNorm; + vfb *= invNorm; } } + + int vr, vg, vb; + + static const float kDefaultLuminanceThreshold = 4.0f * 255; + static const float kQuantizeRange = 512.0f; + if (eigenvalue < kDefaultLuminanceThreshold) // too small, default to luminance + { + // Luminance weights defined by ITU-R Recommendation BT.601, scaled by 1000 + vr = 299; + vg = 587; + vb = 114; + } + else + { + // From the eigenvalue and eigenvector, choose the axis to project + // colors on. When projecting colors we want to do integer computations + // for speed, so we normalize the eigenvector to the [0, 512] range. + float magn = std::max(std::max(std::abs(vfr), std::abs(vfg)), std::abs(vfb)); + magn = kQuantizeRange / magn; + vr = static_cast<int>(vfr * magn); + vg = static_cast<int>(vfg * magn); + vb = static_cast<int>(vfb * magn); + } + + // Pick colors at extreme points + int minD = pixels[0].R * vr + pixels[0].G * vg + pixels[0].B * vb; + int maxD = minD; + size_t minIndex = 0; + size_t maxIndex = 0; + for (size_t i = 1; i < kNumPixels; i++) + { + int dot = pixels[i].R * vr + pixels[i].G * vg + pixels[i].B * vb; + if (dot < minD) + { + minD = dot; + minIndex = i; + } + if (dot > maxD) + { + maxD = dot; + maxIndex = i; + } + } + + *minColor = pixels[minIndex]; + *maxColor = pixels[maxIndex]; } void transcodeIndividualOrDifferentialBlockToBC1(uint8_t *dest, @@ -912,18 +1009,15 @@ struct ETC2Block // A BC1 block has 2 endpoints, pixels is encoded as linear // interpolations of them. A ETC1/ETC2 individual or differential block // has 2 subblocks. Each subblock has one color and a modifier. We - // compute the max intensity and min intensity pixel values to use as + // select axis by principal component analysis (PCA) to use as // our two BC1 endpoints and then map pixels to BC1 by projecting on the // line between the two endpoints and choosing the right fraction. // - // In the future, we have 2 potential improvements to this algorithm. + // In the future, we have a potential improvements to this algorithm. // 1. We don't actually need to decode ETC blocks to RGBs. Instead, // the subblock colors and pixel indices alreay contains enough // information for transcode. A direct mapping would be more // efficient here. - // 2. Currently the BC1 endpoints come from the max and min intensity - // of ETC colors. A principal component analysis (PCA) on them might - // give us better quality results, with limited costs const auto intensityModifier = nonOpaquePunchThroughAlpha ? intensityModifierNonOpaque : intensityModifierDefault; @@ -940,15 +1034,12 @@ struct ETC2Block subblockColors[1][modifierIdx] = createRGBA(r2 + i2, g2 + i2, b2 + i2); } - // 1 and 3 are the argmax and argmin of valueMappingTable - size_t pixelRange[2][2] = {{1, 3}, {1, 3}}; R8G8B8A8 rgbaBlock[16]; - // Decode the block in rgbaBlock and store the inverse valueTableMapping - // of {min(modifier index), max(modifier index)} + // Decode the block in rgbaBlock. for (size_t blockIdx = 0; blockIdx < 2; blockIdx++) { - decodeSubblock(rgbaBlock, pixelRange, x, y, w, h, alphaValues, u.idht.mode.idm.flipbit, - blockIdx, subblockColors); + decodeSubblock(rgbaBlock, x, y, w, h, alphaValues, u.idht.mode.idm.flipbit, blockIdx, + subblockColors); } if (nonOpaquePunchThroughAlpha) { @@ -956,30 +1047,8 @@ struct ETC2Block sizeof(R8G8B8A8) * 4); } - // Get the "min" and "max" pixel colors that have been used. - R8G8B8A8 minColor; - const R8G8B8A8 &minColor0 = subblockColors[0][pixelRange[0][0]]; - const R8G8B8A8 &minColor1 = subblockColors[1][pixelRange[1][0]]; - if (minColor0.R + minColor0.G + minColor0.B < minColor1.R + minColor1.G + minColor1.B) - { - minColor = minColor0; - } - else - { - minColor = minColor1; - } - - R8G8B8A8 maxColor; - const R8G8B8A8 &maxColor0 = subblockColors[0][pixelRange[0][1]]; - const R8G8B8A8 &maxColor1 = subblockColors[1][pixelRange[1][1]]; - if (maxColor0.R + maxColor0.G + maxColor0.B < maxColor1.R + maxColor1.G + maxColor1.B) - { - maxColor = maxColor1; - } - else - { - maxColor = maxColor0; - } + R8G8B8A8 minColor, maxColor; + selectEndPointPCA(rgbaBlock, &minColor, &maxColor); packBC1(dest, rgbaBlock, minColor, maxColor, !nonOpaquePunchThroughAlpha); } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/ContextGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/ContextGL.cpp new file mode 100644 index 00000000000..ded0ecaaeb9 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/ContextGL.cpp @@ -0,0 +1,268 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// ContextGL: +// OpenGL-specific functionality associated with a GL Context. +// + +#include "libANGLE/renderer/gl/ContextGL.h" + +#include "libANGLE/renderer/gl/BufferGL.h" +#include "libANGLE/renderer/gl/CompilerGL.h" +#include "libANGLE/renderer/gl/FenceNVGL.h" +#include "libANGLE/renderer/gl/FenceSyncGL.h" +#include "libANGLE/renderer/gl/FramebufferGL.h" +#include "libANGLE/renderer/gl/ProgramGL.h" +#include "libANGLE/renderer/gl/QueryGL.h" +#include "libANGLE/renderer/gl/RenderbufferGL.h" +#include "libANGLE/renderer/gl/RendererGL.h" +#include "libANGLE/renderer/gl/SamplerGL.h" +#include "libANGLE/renderer/gl/ShaderGL.h" +#include "libANGLE/renderer/gl/StateManagerGL.h" +#include "libANGLE/renderer/gl/TextureGL.h" +#include "libANGLE/renderer/gl/TransformFeedbackGL.h" +#include "libANGLE/renderer/gl/VertexArrayGL.h" + +namespace rx +{ + +ContextGL::ContextGL(const gl::ContextState &state, RendererGL *renderer) + : ContextImpl(state), mRenderer(renderer) +{ +} + +ContextGL::~ContextGL() +{ +} + +gl::Error ContextGL::initialize() +{ + return gl::NoError(); +} + +CompilerImpl *ContextGL::createCompiler() +{ + return new CompilerGL(getFunctions()); +} + +ShaderImpl *ContextGL::createShader(const gl::ShaderState &data) +{ + return new ShaderGL(data, getFunctions(), getWorkaroundsGL()); +} + +ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data) +{ + return new ProgramGL(data, getFunctions(), getWorkaroundsGL(), getStateManager()); +} + +FramebufferImpl *ContextGL::createFramebuffer(const gl::FramebufferState &data) +{ + return new FramebufferGL(data, getFunctions(), getStateManager(), getWorkaroundsGL(), false); +} + +TextureImpl *ContextGL::createTexture(const gl::TextureState &state) +{ + return new TextureGL(state, getFunctions(), getWorkaroundsGL(), getStateManager(), + mRenderer->getBlitter()); +} + +RenderbufferImpl *ContextGL::createRenderbuffer() +{ + return new RenderbufferGL(getFunctions(), getWorkaroundsGL(), getStateManager(), + getNativeTextureCaps()); +} + +BufferImpl *ContextGL::createBuffer() +{ + return new BufferGL(getFunctions(), getStateManager()); +} + +VertexArrayImpl *ContextGL::createVertexArray(const gl::VertexArrayState &data) +{ + return new VertexArrayGL(data, getFunctions(), getStateManager()); +} + +QueryImpl *ContextGL::createQuery(GLenum type) +{ + return new QueryGL(type, getFunctions(), getStateManager()); +} + +FenceNVImpl *ContextGL::createFenceNV() +{ + return new FenceNVGL(getFunctions()); +} + +FenceSyncImpl *ContextGL::createFenceSync() +{ + return new FenceSyncGL(getFunctions()); +} + +TransformFeedbackImpl *ContextGL::createTransformFeedback() +{ + return new TransformFeedbackGL(getFunctions(), getStateManager(), + getNativeCaps().maxTransformFeedbackSeparateComponents); +} + +SamplerImpl *ContextGL::createSampler() +{ + return new SamplerGL(getFunctions(), getStateManager()); +} + +gl::Error ContextGL::flush() +{ + return mRenderer->flush(); +} + +gl::Error ContextGL::finish() +{ + return mRenderer->finish(); +} + +gl::Error ContextGL::drawArrays(GLenum mode, GLint first, GLsizei count) +{ + return mRenderer->drawArrays(mState, mode, first, count); +} + +gl::Error ContextGL::drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) +{ + return mRenderer->drawArraysInstanced(mState, mode, first, count, instanceCount); +} + +gl::Error ContextGL::drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) +{ + return mRenderer->drawElements(mState, mode, count, type, indices, indexRange); +} + +gl::Error ContextGL::drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) +{ + return mRenderer->drawElementsInstanced(mState, mode, count, type, indices, instances, + indexRange); +} + +gl::Error ContextGL::drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) +{ + return mRenderer->drawRangeElements(mState, mode, start, end, count, type, indices, indexRange); +} + +void ContextGL::notifyDeviceLost() +{ + mRenderer->notifyDeviceLost(); +} + +bool ContextGL::isDeviceLost() const +{ + return mRenderer->isDeviceLost(); +} + +bool ContextGL::testDeviceLost() +{ + return mRenderer->testDeviceLost(); +} + +bool ContextGL::testDeviceResettable() +{ + return mRenderer->testDeviceResettable(); +} + +std::string ContextGL::getVendorString() const +{ + return mRenderer->getVendorString(); +} + +std::string ContextGL::getRendererDescription() const +{ + return mRenderer->getRendererDescription(); +} + +void ContextGL::insertEventMarker(GLsizei length, const char *marker) +{ + mRenderer->insertEventMarker(length, marker); +} + +void ContextGL::pushGroupMarker(GLsizei length, const char *marker) +{ + mRenderer->pushGroupMarker(length, marker); +} + +void ContextGL::popGroupMarker() +{ + mRenderer->popGroupMarker(); +} + +void ContextGL::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) +{ + mRenderer->getStateManager()->syncState(state, dirtyBits); +} + +GLint ContextGL::getGPUDisjoint() +{ + return mRenderer->getGPUDisjoint(); +} + +GLint64 ContextGL::getTimestamp() +{ + return mRenderer->getTimestamp(); +} + +void ContextGL::onMakeCurrent(const gl::ContextState &data) +{ + // Queries need to be paused/resumed on context switches + mRenderer->getStateManager()->onMakeCurrent(data); +} + +const gl::Caps &ContextGL::getNativeCaps() const +{ + return mRenderer->getNativeCaps(); +} + +const gl::TextureCapsMap &ContextGL::getNativeTextureCaps() const +{ + return mRenderer->getNativeTextureCaps(); +} + +const gl::Extensions &ContextGL::getNativeExtensions() const +{ + return mRenderer->getNativeExtensions(); +} + +const gl::Limitations &ContextGL::getNativeLimitations() const +{ + return mRenderer->getNativeLimitations(); +} + +const FunctionsGL *ContextGL::getFunctions() const +{ + return mRenderer->getFunctions(); +} + +StateManagerGL *ContextGL::getStateManager() +{ + return mRenderer->getStateManager(); +} + +const WorkaroundsGL &ContextGL::getWorkaroundsGL() +{ + return mRenderer->getWorkarounds(); +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/ContextGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/ContextGL.h new file mode 100644 index 00000000000..5dd73b92a63 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/ContextGL.h @@ -0,0 +1,138 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// ContextGL: +// OpenGL-specific functionality associated with a GL Context. +// + +#ifndef LIBANGLE_RENDERER_GL_CONTEXTGL_H_ +#define LIBANGLE_RENDERER_GL_CONTEXTGL_H_ + +#include "libANGLE/renderer/ContextImpl.h" + +namespace sh +{ +struct BlockMemberInfo; +} + +namespace rx +{ +class FunctionsGL; +class RendererGL; +class StateManagerGL; +struct WorkaroundsGL; + +class ContextGL : public ContextImpl +{ + public: + ContextGL(const gl::ContextState &state, RendererGL *renderer); + ~ContextGL() override; + + gl::Error initialize() override; + + // Shader creation + CompilerImpl *createCompiler() override; + ShaderImpl *createShader(const gl::ShaderState &data) override; + ProgramImpl *createProgram(const gl::ProgramState &data) override; + + // Framebuffer creation + FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; + + // Texture creation + TextureImpl *createTexture(const gl::TextureState &state) override; + + // Renderbuffer creation + RenderbufferImpl *createRenderbuffer() override; + + // Buffer creation + BufferImpl *createBuffer() override; + + // Vertex Array creation + VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; + + // Query and Fence creation + QueryImpl *createQuery(GLenum type) override; + FenceNVImpl *createFenceNV() override; + FenceSyncImpl *createFenceSync() override; + + // Transform Feedback creation + TransformFeedbackImpl *createTransformFeedback() override; + + // Sampler object creation + SamplerImpl *createSampler() override; + + // Flush and finish. + gl::Error flush() override; + gl::Error finish() override; + + // Drawing methods. + gl::Error drawArrays(GLenum mode, GLint first, GLsizei count) override; + gl::Error drawArraysInstanced(GLenum mode, + GLint first, + GLsizei count, + GLsizei instanceCount) override; + + gl::Error drawElements(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) override; + gl::Error drawElementsInstanced(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei instances, + const gl::IndexRange &indexRange) override; + gl::Error drawRangeElements(GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices, + const gl::IndexRange &indexRange) override; + + // TODO(jmadill): Investigate proper impl methods for this. + void notifyDeviceLost() override; + bool isDeviceLost() const override; + bool testDeviceLost() override; + bool testDeviceResettable() override; + + // Vendor and description strings. + std::string getVendorString() const override; + std::string getRendererDescription() const override; + + // Debug markers. + void insertEventMarker(GLsizei length, const char *marker) override; + void pushGroupMarker(GLsizei length, const char *marker) override; + void popGroupMarker() override; + + // State sync with dirty bits. + void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override; + + // Disjoint timer queries + GLint getGPUDisjoint() override; + GLint64 getTimestamp() override; + + // Context switching + void onMakeCurrent(const gl::ContextState &data) override; + + // Caps queries + const gl::Caps &getNativeCaps() const override; + const gl::TextureCapsMap &getNativeTextureCaps() const override; + const gl::Extensions &getNativeExtensions() const override; + const gl::Limitations &getNativeLimitations() const override; + + // Handle helpers + const FunctionsGL *getFunctions() const; + StateManagerGL *getStateManager(); + const WorkaroundsGL &getWorkaroundsGL(); + + private: + RendererGL *mRenderer; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_GL_CONTEXTGL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.cpp index 93aa0499f54..fa443ca3b72 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.cpp @@ -9,9 +9,9 @@ #include "libANGLE/renderer/gl/DisplayGL.h" #include "libANGLE/AttributeMap.h" -#include "libANGLE/Context.h" #include "libANGLE/Display.h" #include "libANGLE/Surface.h" +#include "libANGLE/renderer/gl/ContextGL.h" #include "libANGLE/renderer/gl/RendererGL.h" #include "libANGLE/renderer/gl/SurfaceGL.h" @@ -55,17 +55,17 @@ ImageImpl *DisplayGL::createImage(EGLenum target, return nullptr; } -gl::Context *DisplayGL::createContext(const egl::Config *config, - const gl::Context *shareContext, - const egl::AttributeMap &attribs) +ContextImpl *DisplayGL::createContext(const gl::ContextState &state) { ASSERT(mRenderer != nullptr); - return new gl::Context(config, shareContext, mRenderer, attribs); + return new ContextGL(state, mRenderer); } -StreamImpl *DisplayGL::createStream(const egl::AttributeMap &attribs) +StreamProducerImpl *DisplayGL::createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) { - UNREACHABLE(); + UNIMPLEMENTED(); return nullptr; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.h index dd7bb3cf551..9a300c1007b 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/DisplayGL.h @@ -30,11 +30,11 @@ class DisplayGL : public DisplayImpl egl::ImageSibling *buffer, const egl::AttributeMap &attribs) override; - gl::Context *createContext(const egl::Config *config, - const gl::Context *shareContext, - const egl::AttributeMap &attribs) override; + ContextImpl *createContext(const gl::ContextState &state) override; - StreamImpl *createStream(const egl::AttributeMap &attribs) override; + StreamProducerImpl *createStreamProducerD3DTextureNV12( + egl::Stream::ConsumerType consumerType, + const egl::AttributeMap &attribs) override; egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp index 6c9f046a1ee..40890e0625d 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp @@ -10,11 +10,12 @@ #include "common/BitSetIterator.h" #include "common/debug.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/State.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/angletypes.h" #include "libANGLE/formatutils.h" +#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/RenderbufferGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h" @@ -27,12 +28,12 @@ using namespace gl; namespace rx { -FramebufferGL::FramebufferGL(const Framebuffer::Data &data, +FramebufferGL::FramebufferGL(const FramebufferState &state, const FunctionsGL *functions, StateManagerGL *stateManager, const WorkaroundsGL &workarounds, bool isDefault) - : FramebufferImpl(data), + : FramebufferImpl(state), mFunctions(functions), mStateManager(stateManager), mWorkarounds(workarounds), @@ -46,11 +47,11 @@ FramebufferGL::FramebufferGL(const Framebuffer::Data &data, } FramebufferGL::FramebufferGL(GLuint id, - const Framebuffer::Data &data, + const FramebufferState &state, const FunctionsGL *functions, const WorkaroundsGL &workarounds, StateManagerGL *stateManager) - : FramebufferImpl(data), + : FramebufferImpl(state), mFunctions(functions), mStateManager(stateManager), mWorkarounds(workarounds), @@ -149,7 +150,7 @@ Error FramebufferGL::invalidateSub(size_t count, return Error(GL_NO_ERROR); } -Error FramebufferGL::clear(const Data &data, GLbitfield mask) +Error FramebufferGL::clear(ContextImpl *context, GLbitfield mask) { syncClearState(mask); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); @@ -158,7 +159,7 @@ Error FramebufferGL::clear(const Data &data, GLbitfield mask) return Error(GL_NO_ERROR); } -Error FramebufferGL::clearBufferfv(const Data &data, +Error FramebufferGL::clearBufferfv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLfloat *values) @@ -170,7 +171,7 @@ Error FramebufferGL::clearBufferfv(const Data &data, return Error(GL_NO_ERROR); } -Error FramebufferGL::clearBufferuiv(const Data &data, +Error FramebufferGL::clearBufferuiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLuint *values) @@ -182,7 +183,7 @@ Error FramebufferGL::clearBufferuiv(const Data &data, return Error(GL_NO_ERROR); } -Error FramebufferGL::clearBufferiv(const Data &data, +Error FramebufferGL::clearBufferiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLint *values) @@ -194,7 +195,7 @@ Error FramebufferGL::clearBufferiv(const Data &data, return Error(GL_NO_ERROR); } -Error FramebufferGL::clearBufferfi(const Data &data, +Error FramebufferGL::clearBufferfi(ContextImpl *context, GLenum buffer, GLint drawbuffer, GLfloat depth, @@ -209,7 +210,7 @@ Error FramebufferGL::clearBufferfi(const Data &data, GLenum FramebufferGL::getImplementationColorReadFormat() const { - const FramebufferAttachment *readAttachment = getData().getReadAttachment(); + const FramebufferAttachment *readAttachment = mState.getReadAttachment(); GLenum internalFormat = readAttachment->getInternalFormat(); const InternalFormat &internalFormatInfo = GetInternalFormatInfo(internalFormat); return internalFormatInfo.format; @@ -217,13 +218,13 @@ GLenum FramebufferGL::getImplementationColorReadFormat() const GLenum FramebufferGL::getImplementationColorReadType() const { - const FramebufferAttachment *readAttachment = getData().getReadAttachment(); + const FramebufferAttachment *readAttachment = mState.getReadAttachment(); GLenum internalFormat = readAttachment->getInternalFormat(); const InternalFormat &internalFormatInfo = GetInternalFormatInfo(internalFormat); return internalFormatInfo.type; } -Error FramebufferGL::readPixels(const State &state, +Error FramebufferGL::readPixels(ContextImpl *context, const gl::Rectangle &area, GLenum format, GLenum type, @@ -231,7 +232,7 @@ Error FramebufferGL::readPixels(const State &state, { // TODO: don't sync the pixel pack state here once the dirty bits contain the pixel pack buffer // binding - const PixelPackState &packState = state.getPackState(); + const PixelPackState &packState = context->getState().getPackState(); mStateManager->setPixelPackState(packState); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, mFramebufferID); @@ -240,13 +241,13 @@ Error FramebufferGL::readPixels(const State &state, return Error(GL_NO_ERROR); } -Error FramebufferGL::blit(const State &state, +Error FramebufferGL::blit(ContextImpl *context, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, GLbitfield mask, - GLenum filter, - const Framebuffer *sourceFramebuffer) + GLenum filter) { + const Framebuffer *sourceFramebuffer = context->getState().getReadFramebuffer(); const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(sourceFramebuffer); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID()); @@ -285,21 +286,21 @@ void FramebufferGL::syncState(const Framebuffer::DirtyBits &dirtyBits) { case Framebuffer::DIRTY_BIT_DEPTH_ATTACHMENT: BindFramebufferAttachment(mFunctions, GL_DEPTH_ATTACHMENT, - mData.getDepthAttachment()); + mState.getDepthAttachment()); break; case Framebuffer::DIRTY_BIT_STENCIL_ATTACHMENT: BindFramebufferAttachment(mFunctions, GL_STENCIL_ATTACHMENT, - mData.getStencilAttachment()); + mState.getStencilAttachment()); break; case Framebuffer::DIRTY_BIT_DRAW_BUFFERS: { - const auto &drawBuffers = mData.getDrawBufferStates(); + const auto &drawBuffers = mState.getDrawBufferStates(); mFunctions->drawBuffers(static_cast<GLsizei>(drawBuffers.size()), drawBuffers.data()); break; } case Framebuffer::DIRTY_BIT_READ_BUFFER: - mFunctions->readBuffer(mData.getReadBufferState()); + mFunctions->readBuffer(mState.getReadBufferState()); break; default: { @@ -309,7 +310,7 @@ void FramebufferGL::syncState(const Framebuffer::DirtyBits &dirtyBits) static_cast<size_t>(dirtyBit - Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0); BindFramebufferAttachment(mFunctions, static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + index), - mData.getColorAttachment(index)); + mState.getColorAttachment(index)); break; } } @@ -342,7 +343,7 @@ void FramebufferGL::syncClearState(GLbitfield mask) (mask & GL_COLOR_BUFFER_BIT) != 0 && !mIsDefault) { bool hasSRBAttachment = false; - for (const auto &attachment : mData.getColorAttachments()) + for (const auto &attachment : mState.getColorAttachments()) { if (attachment.isAttached() && attachment.getColorEncoding() == GL_SRGB) { @@ -369,8 +370,8 @@ void FramebufferGL::syncClearBufferState(GLenum buffer, GLint drawBuffer) { // If doing a clear on a color buffer, set SRGB blend enabled only if the color buffer // is an SRGB format. - const auto &drawbufferState = mData.getDrawBufferStates(); - const auto &colorAttachments = mData.getColorAttachments(); + const auto &drawbufferState = mState.getDrawBufferStates(); + const auto &colorAttachments = mState.getColorAttachments(); const FramebufferAttachment *attachment = nullptr; if (drawbufferState[drawBuffer] >= GL_COLOR_ATTACHMENT0 && diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.h index 224b10c7b97..69d4aef351e 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/FramebufferGL.h @@ -21,7 +21,7 @@ struct WorkaroundsGL; class FramebufferGL : public FramebufferImpl { public: - FramebufferGL(const gl::Framebuffer::Data &data, + FramebufferGL(const gl::FramebufferState &data, const FunctionsGL *functions, StateManagerGL *stateManager, const WorkaroundsGL &workarounds, @@ -30,7 +30,7 @@ class FramebufferGL : public FramebufferImpl // existing framebuffer name, for example for the default framebuffer // on the Mac EGL CGL backend. FramebufferGL(GLuint id, - const gl::Framebuffer::Data &data, + const gl::FramebufferState &data, const FunctionsGL *functions, const WorkaroundsGL &workarounds, StateManagerGL *stateManager); @@ -40,20 +40,20 @@ class FramebufferGL : public FramebufferImpl gl::Error invalidate(size_t count, const GLenum *attachments) override; gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; - gl::Error clear(const gl::Data &data, GLbitfield mask) override; - gl::Error clearBufferfv(const gl::Data &data, + gl::Error clear(ContextImpl *context, GLbitfield mask) override; + gl::Error clearBufferfv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLfloat *values) override; - gl::Error clearBufferuiv(const gl::Data &data, + gl::Error clearBufferuiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLuint *values) override; - gl::Error clearBufferiv(const gl::Data &data, + gl::Error clearBufferiv(ContextImpl *context, GLenum buffer, GLint drawbuffer, const GLint *values) override; - gl::Error clearBufferfi(const gl::Data &data, + gl::Error clearBufferfi(ContextImpl *context, GLenum buffer, GLint drawbuffer, GLfloat depth, @@ -61,10 +61,17 @@ class FramebufferGL : public FramebufferImpl GLenum getImplementationColorReadFormat() const override; GLenum getImplementationColorReadType() const override; - gl::Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const override; - - gl::Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, - GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) override; + gl::Error readPixels(ContextImpl *context, + const gl::Rectangle &area, + GLenum format, + GLenum type, + GLvoid *pixels) const override; + + gl::Error blit(ContextImpl *context, + const gl::Rectangle &sourceArea, + const gl::Rectangle &destArea, + GLbitfield mask, + GLenum filter) override; bool checkStatus() const override; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp index bd7d773f148..fd588f9d40c 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp @@ -640,6 +640,7 @@ FunctionsGL::FunctionsGL() vertexAttribIFormat(nullptr), vertexAttribLFormat(nullptr), vertexBindingDivisor(nullptr), + coverageModulationNV(nullptr), bindBuffersBase(nullptr), bindBuffersRange(nullptr), @@ -823,6 +824,9 @@ void FunctionsGL::initializeProcsDesktopGL() // Even though extensions are written against specific versions of GL, many drivers expose the extensions // in even older versions. Always try loading the extensions regardless of GL version. + // GL_NV_framebuffer_mixed_samples + AssignGLExtensionEntryPoint(extensions, "GL_NV_framebuffer_mixed_samples", loadProcAddress("glCoverageModulationNV"), &coverageModulationNV); + // GL_NV_fence AssignGLExtensionEntryPoint(extensions, "GL_NV_fence", loadProcAddress("glDeleteFencesNV"), &deleteFencesNV); AssignGLExtensionEntryPoint(extensions, "GL_NV_fence", loadProcAddress("glGenFencesNV"), &genFencesNV); @@ -961,6 +965,11 @@ void FunctionsGL::initializeProcsDesktopGL() AssignGLExtensionEntryPoint(extensions, "GL_ARB_transform_feedback3", loadProcAddress("glEndQueryIndexed"), &endQueryIndexed); AssignGLExtensionEntryPoint(extensions, "GL_ARB_transform_feedback3", loadProcAddress("glGetQueryIndexediv"), &getQueryIndexediv); + // GL_ARB_get_program_binary + AssignGLExtensionEntryPoint(extensions, "GL_ARB_get_program_binary", loadProcAddress("glGetProgramBinary"), &getProgramBinary); + AssignGLExtensionEntryPoint(extensions, "GL_ARB_get_program_binary", loadProcAddress("glProgramBinary"), &programBinary); + AssignGLExtensionEntryPoint(extensions, "GL_ARB_get_program_binary", loadProcAddress("glProgramParameteri"), &programParameteri); + // 1.0 if (isAtLeastGL(gl::Version(1, 0))) { @@ -1719,6 +1728,9 @@ void FunctionsGL::initializeProcsGLES() AssignGLExtensionEntryPoint(extensions, "GL_OES_texture_3D", loadProcAddress("glTexSubImage3DOES"), &texSubImage3D); AssignGLExtensionEntryPoint(extensions, "GL_OES_texture_3D", loadProcAddress("glCopyTexSubImage3DOES"), ©TexSubImage3D); + // GL_NV_framebuffer_mixed_samples + AssignGLExtensionEntryPoint(extensions, "GL_NV_framebuffer_mixed_samples", loadProcAddress("glCoverageModulationNV"), &coverageModulationNV); + // GL_NV_fence AssignGLExtensionEntryPoint(extensions, "GL_NV_fence", loadProcAddress("glDeleteFencesNV"), &deleteFencesNV); AssignGLExtensionEntryPoint(extensions, "GL_NV_fence", loadProcAddress("glGenFencesNV"), &genFencesNV); @@ -1791,6 +1803,10 @@ void FunctionsGL::initializeProcsGLES() AssignGLExtensionEntryPoint(extensions, "GL_OES_EGL_image", loadProcAddress("glEGLImageTargetRenderbufferStorageOES"), &eglImageTargetRenderbufferStorageOES); AssignGLExtensionEntryPoint(extensions, "GL_OES_EGL_image", loadProcAddress("glEGLImageTargetTexture2DOES"), &eglImageTargetTexture2DOES); + // GL_OES_get_program_binary + AssignGLExtensionEntryPoint(extensions, "GL_OES_get_program_binary", loadProcAddress("glGetProgramBinaryOES"), &getProgramBinary); + AssignGLExtensionEntryPoint(extensions, "GL_OES_get_program_binary", loadProcAddress("glProgramBinaryOES"), &programBinary); + // 2.0 if (isAtLeastGLES(gl::Version(2, 0))) { diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.h index c33c1a01c53..44a1004f773 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/FunctionsGL.h @@ -619,6 +619,7 @@ class FunctionsGL PFNGLVERTEXATTRIBIFORMATPROC vertexAttribIFormat; PFNGLVERTEXATTRIBLFORMATPROC vertexAttribLFormat; PFNGLVERTEXBINDINGDIVISORPROC vertexBindingDivisor; + PFNGLCOVERAGEMODULATIONNVPROC coverageModulationNV; // 4.4 PFNGLBINDBUFFERSBASEPROC bindBuffersBase; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.cpp index cac198540ed..a13aa56f537 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.cpp @@ -13,15 +13,22 @@ #include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/ShaderGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h" +#include "libANGLE/renderer/gl/WorkaroundsGL.h" +#include "libANGLE/Uniform.h" #include "platform/Platform.h" namespace rx { -ProgramGL::ProgramGL(const gl::Program::Data &data, +ProgramGL::ProgramGL(const gl::ProgramState &data, const FunctionsGL *functions, + const WorkaroundsGL &workarounds, StateManagerGL *stateManager) - : ProgramImpl(data), mFunctions(functions), mStateManager(stateManager), mProgramID(0) + : ProgramImpl(data), + mFunctions(functions), + mWorkarounds(workarounds), + mStateManager(stateManager), + mProgramID(0) { ASSERT(mFunctions); ASSERT(mStateManager); @@ -37,29 +44,62 @@ ProgramGL::~ProgramGL() LinkResult ProgramGL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) { - UNIMPLEMENTED(); - return LinkResult(false, gl::Error(GL_INVALID_OPERATION)); + preLink(); + + // Read the binary format, size and blob + GLenum binaryFormat = stream->readInt<GLenum>(); + GLint binaryLength = stream->readInt<GLint>(); + const uint8_t *binary = stream->data() + stream->offset(); + stream->skip(binaryLength); + + // Load the binary + mFunctions->programBinary(mProgramID, binaryFormat, binary, binaryLength); + + // Verify that the program linked + if (!checkLinkStatus(infoLog)) + { + return LinkResult(false, gl::Error(GL_NO_ERROR)); + } + + postLink(); + + return LinkResult(true, gl::Error(GL_NO_ERROR)); } gl::Error ProgramGL::save(gl::BinaryOutputStream *stream) { - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); + GLint binaryLength = 0; + mFunctions->getProgramiv(mProgramID, GL_PROGRAM_BINARY_LENGTH, &binaryLength); + + std::vector<uint8_t> binary(binaryLength); + GLenum binaryFormat = GL_NONE; + mFunctions->getProgramBinary(mProgramID, binaryLength, &binaryLength, &binaryFormat, + &binary[0]); + + stream->writeInt(binaryFormat); + stream->writeInt(binaryLength); + stream->writeBytes(&binary[0], binaryLength); + + return gl::Error(GL_NO_ERROR); } void ProgramGL::setBinaryRetrievableHint(bool retrievable) { - UNIMPLEMENTED(); + // glProgramParameteri isn't always available on ES backends. + if (mFunctions->programParameteri) + { + mFunctions->programParameteri(mProgramID, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, + retrievable ? GL_TRUE : GL_FALSE); + } } -LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) +LinkResult ProgramGL::link(const gl::ContextState &data, gl::InfoLog &infoLog) { - // Reset the program state, delete the current program if one exists - reset(); + preLink(); // Set the transform feedback state std::vector<const GLchar *> transformFeedbackVaryings; - for (const auto &tfVarying : mData.getTransformFeedbackVaryingNames()) + for (const auto &tfVarying : mState.getTransformFeedbackVaryingNames()) { transformFeedbackVaryings.push_back(tfVarying.c_str()); } @@ -69,7 +109,7 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) if (mFunctions->transformFeedbackVaryings) { mFunctions->transformFeedbackVaryings(mProgramID, 0, nullptr, - mData.getTransformFeedbackBufferMode()); + mState.getTransformFeedbackBufferMode()); } } else @@ -77,21 +117,18 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) ASSERT(mFunctions->transformFeedbackVaryings); mFunctions->transformFeedbackVaryings( mProgramID, static_cast<GLsizei>(transformFeedbackVaryings.size()), - &transformFeedbackVaryings[0], mData.getTransformFeedbackBufferMode()); + &transformFeedbackVaryings[0], mState.getTransformFeedbackBufferMode()); } - const gl::Shader *vertexShader = mData.getAttachedVertexShader(); - const gl::Shader *fragmentShader = mData.getAttachedFragmentShader(); - - const ShaderGL *vertexShaderGL = GetImplAs<ShaderGL>(vertexShader); - const ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(fragmentShader); + const ShaderGL *vertexShaderGL = GetImplAs<ShaderGL>(mState.getAttachedVertexShader()); + const ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(mState.getAttachedFragmentShader()); // Attach the shaders mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID()); mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID()); // Bind attribute locations to match the GL layer. - for (const sh::Attribute &attribute : mData.getAttributes()) + for (const sh::Attribute &attribute : mState.getAttributes()) { if (!attribute.staticUse) { @@ -109,78 +146,17 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) mFunctions->detachShader(mProgramID, fragmentShaderGL->getShaderID()); // Verify the link - GLint linkStatus = GL_FALSE; - mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus); - if (linkStatus == GL_FALSE) + if (!checkLinkStatus(infoLog)) { - // Linking failed, put the error into the info log - GLint infoLogLength = 0; - mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength); - - std::string warning; - - // Info log length includes the null terminator, so 1 means that the info log is an empty - // string. - if (infoLogLength > 1) - { - std::vector<char> buf(infoLogLength); - mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]); - - mFunctions->deleteProgram(mProgramID); - mProgramID = 0; - - infoLog << buf.data(); - - warning = FormatString("Program link failed unexpectedly: %s", buf.data()); - } - else - { - warning = "Program link failed unexpectedly with no info log."; - } - ANGLEPlatformCurrent()->logWarning(warning.c_str()); - TRACE("\n%s", warning.c_str()); - - // TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case return LinkResult(false, gl::Error(GL_NO_ERROR)); } - // Query the uniform information - ASSERT(mUniformRealLocationMap.empty()); - const auto &uniforms = mData.getUniforms(); - for (const gl::VariableLocation &entry : mData.getUniformLocations()) + if (mWorkarounds.alwaysCallUseProgramAfterLink) { - // From the spec: - // "Locations for sequential array indices are not required to be sequential." - const gl::LinkedUniform &uniform = uniforms[entry.index]; - std::stringstream fullNameStr; - fullNameStr << uniform.name; - if (uniform.isArray()) - { - fullNameStr << "[" << entry.element << "]"; - } - const std::string &fullName = fullNameStr.str(); - - GLint realLocation = mFunctions->getUniformLocation(mProgramID, fullName.c_str()); - mUniformRealLocationMap.push_back(realLocation); + mStateManager->forceUseProgram(mProgramID); } - mUniformIndexToSamplerIndex.resize(mData.getUniforms().size(), GL_INVALID_INDEX); - - for (size_t uniformId = 0; uniformId < uniforms.size(); ++uniformId) - { - const gl::LinkedUniform &linkedUniform = uniforms[uniformId]; - - if (!linkedUniform.isSampler() || !linkedUniform.staticUse) - continue; - - mUniformIndexToSamplerIndex[uniformId] = mSamplerBindings.size(); - - // If uniform is a sampler type, insert it into the mSamplerBindings array - SamplerBindingGL samplerBinding; - samplerBinding.textureType = gl::SamplerTypeToTextureType(linkedUniform.type); - samplerBinding.boundTextureUnits.resize(linkedUniform.elementCount(), 0); - mSamplerBindings.push_back(samplerBinding); - } + postLink(); return LinkResult(true, gl::Error(GL_NO_ERROR)); } @@ -220,7 +196,7 @@ void ProgramGL::setUniform1iv(GLint location, GLsizei count, const GLint *v) mStateManager->useProgram(mProgramID); mFunctions->uniform1iv(uniLoc(location), count, v); - const gl::VariableLocation &locationEntry = mData.getUniformLocations()[location]; + const gl::VariableLocation &locationEntry = mState.getUniformLocations()[location]; size_t samplerIndex = mUniformIndexToSamplerIndex[locationEntry.index]; if (samplerIndex != GL_INVALID_INDEX) @@ -334,8 +310,8 @@ void ProgramGL::setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformB // Lazy init if (mUniformBlockRealLocationMap.empty()) { - mUniformBlockRealLocationMap.reserve(mData.getUniformBlocks().size()); - for (const gl::UniformBlock &uniformBlock : mData.getUniformBlocks()) + mUniformBlockRealLocationMap.reserve(mState.getUniformBlocks().size()); + for (const gl::UniformBlock &uniformBlock : mState.getUniformBlocks()) { const std::string &nameWithIndex = uniformBlock.nameWithArrayIndex(); GLuint blockIndex = mFunctions->getUniformBlockIndex(mProgramID, nameWithIndex.c_str()); @@ -350,14 +326,6 @@ void ProgramGL::setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformB } } -void ProgramGL::reset() -{ - mUniformRealLocationMap.clear(); - mUniformBlockRealLocationMap.clear(); - mSamplerBindings.clear(); - mUniformIndexToSamplerIndex.clear(); -} - GLuint ProgramGL::getProgramID() const { return mProgramID; @@ -414,4 +382,102 @@ bool ProgramGL::getUniformBlockMemberInfo(const std::string &memberUniformName, return true; } +void ProgramGL::preLink() +{ + // Reset the program state + mUniformRealLocationMap.clear(); + mUniformBlockRealLocationMap.clear(); + mSamplerBindings.clear(); + mUniformIndexToSamplerIndex.clear(); +} + +bool ProgramGL::checkLinkStatus(gl::InfoLog &infoLog) +{ + GLint linkStatus = GL_FALSE; + mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus); + if (linkStatus == GL_FALSE) + { + // Linking failed, put the error into the info log + GLint infoLogLength = 0; + mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength); + + std::string warning; + + // Info log length includes the null terminator, so 1 means that the info log is an empty + // string. + if (infoLogLength > 1) + { + std::vector<char> buf(infoLogLength); + mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]); + + mFunctions->deleteProgram(mProgramID); + mProgramID = 0; + + infoLog << buf.data(); + + warning = FormatString("Program link failed unexpectedly: %s", buf.data()); + } + else + { + warning = "Program link failed unexpectedly with no info log."; + } + ANGLEPlatformCurrent()->logWarning(warning.c_str()); + TRACE("\n%s", warning.c_str()); + + // TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case + return false; + } + + return true; +} + +void ProgramGL::postLink() +{ + // Query the uniform information + ASSERT(mUniformRealLocationMap.empty()); + const auto &uniformLocations = mState.getUniformLocations(); + const auto &uniforms = mState.getUniforms(); + mUniformRealLocationMap.resize(uniformLocations.size(), GL_INVALID_INDEX); + for (size_t uniformLocation = 0; uniformLocation < uniformLocations.size(); uniformLocation++) + { + const auto &entry = uniformLocations[uniformLocation]; + if (!entry.used) + { + continue; + } + + // From the spec: + // "Locations for sequential array indices are not required to be sequential." + const gl::LinkedUniform &uniform = uniforms[entry.index]; + std::stringstream fullNameStr; + fullNameStr << uniform.name; + if (uniform.isArray()) + { + fullNameStr << "[" << entry.element << "]"; + } + const std::string &fullName = fullNameStr.str(); + + GLint realLocation = mFunctions->getUniformLocation(mProgramID, fullName.c_str()); + mUniformRealLocationMap[uniformLocation] = realLocation; + } + + mUniformIndexToSamplerIndex.resize(mState.getUniforms().size(), GL_INVALID_INDEX); + + for (size_t uniformId = 0; uniformId < uniforms.size(); ++uniformId) + { + const gl::LinkedUniform &linkedUniform = uniforms[uniformId]; + + if (!linkedUniform.isSampler() || !linkedUniform.staticUse) + continue; + + mUniformIndexToSamplerIndex[uniformId] = mSamplerBindings.size(); + + // If uniform is a sampler type, insert it into the mSamplerBindings array + SamplerBindingGL samplerBinding; + samplerBinding.textureType = gl::SamplerTypeToTextureType(linkedUniform.type); + samplerBinding.boundTextureUnits.resize(linkedUniform.elementCount(), 0); + mSamplerBindings.push_back(samplerBinding); + } +} + } // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.h index fa343688a61..901c6ca9367 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/ProgramGL.h @@ -9,6 +9,7 @@ #ifndef LIBANGLE_RENDERER_GL_PROGRAMGL_H_ #define LIBANGLE_RENDERER_GL_PROGRAMGL_H_ +#include "libANGLE/renderer/gl/WorkaroundsGL.h" #include "libANGLE/renderer/ProgramImpl.h" namespace rx @@ -26,8 +27,9 @@ struct SamplerBindingGL class ProgramGL : public ProgramImpl { public: - ProgramGL(const gl::Program::Data &data, + ProgramGL(const gl::ProgramState &data, const FunctionsGL *functions, + const WorkaroundsGL &workarounds, StateManagerGL *stateManager); ~ProgramGL() override; @@ -35,7 +37,7 @@ class ProgramGL : public ProgramImpl gl::Error save(gl::BinaryOutputStream *stream) override; void setBinaryRetrievableHint(bool retrievable) override; - LinkResult link(const gl::Data &data, gl::InfoLog &infoLog) override; + LinkResult link(const gl::ContextState &data, gl::InfoLog &infoLog) override; GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override; void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override; @@ -70,12 +72,15 @@ class ProgramGL : public ProgramImpl const std::vector<SamplerBindingGL> &getAppliedSamplerUniforms() const; private: - void reset(); + void preLink(); + bool checkLinkStatus(gl::InfoLog &infoLog); + void postLink(); // Helper function, makes it simpler to type. GLint uniLoc(GLint glLocation) const { return mUniformRealLocationMap[glLocation]; } const FunctionsGL *mFunctions; + const WorkaroundsGL &mWorkarounds; StateManagerGL *mStateManager; std::vector<GLint> mUniformRealLocationMap; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.cpp index 77fcbe7fe34..8fbdca96324 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.cpp @@ -12,11 +12,12 @@ #include "common/debug.h" #include "libANGLE/AttributeMap.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/Surface.h" #include "libANGLE/renderer/gl/BlitGL.h" #include "libANGLE/renderer/gl/BufferGL.h" #include "libANGLE/renderer/gl/CompilerGL.h" +#include "libANGLE/renderer/gl/ContextGL.h" #include "libANGLE/renderer/gl/FenceNVGL.h" #include "libANGLE/renderer/gl/FenceSyncGL.h" #include "libANGLE/renderer/gl/FramebufferGL.h" @@ -81,16 +82,16 @@ namespace rx { RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &attribMap) - : Renderer(), - mMaxSupportedESVersion(0, 0), + : mMaxSupportedESVersion(0, 0), mFunctions(functions), mStateManager(nullptr), mBlitter(nullptr), mHasDebugOutput(false), - mSkipDrawCalls(false) + mSkipDrawCalls(false), + mCapsInitialized(false) { ASSERT(mFunctions); - mStateManager = new StateManagerGL(mFunctions, getRendererCaps()); + mStateManager = new StateManagerGL(mFunctions, getNativeCaps()); nativegl_gl::GenerateWorkarounds(mFunctions, &mWorkarounds); mBlitter = new BlitGL(functions, mWorkarounds, mStateManager); @@ -151,66 +152,56 @@ gl::Error RendererGL::finish() return gl::Error(GL_NO_ERROR); } -gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode, GLint first, GLsizei count) +gl::Error RendererGL::drawArrays(const gl::ContextState &data, + GLenum mode, + GLint first, + GLsizei count) { - gl::Error error = mStateManager->setDrawArraysState(data, first, count, 0); - if (error.isError()) - { - return error; - } + ANGLE_TRY(mStateManager->setDrawArraysState(data, first, count, 0)); if (!mSkipDrawCalls) { mFunctions->drawArrays(mode, first, count); } - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } -gl::Error RendererGL::drawArraysInstanced(const gl::Data &data, +gl::Error RendererGL::drawArraysInstanced(const gl::ContextState &data, GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) { - gl::Error error = mStateManager->setDrawArraysState(data, first, count, instanceCount); - if (error.isError()) - { - return error; - } + ANGLE_TRY(mStateManager->setDrawArraysState(data, first, count, instanceCount)); if (!mSkipDrawCalls) { mFunctions->drawArraysInstanced(mode, first, count, instanceCount); } - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } -gl::Error RendererGL::drawElements(const gl::Data &data, +gl::Error RendererGL::drawElements(const gl::ContextState &data, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, const gl::IndexRange &indexRange) { - const GLvoid *drawIndexPointer = nullptr; - gl::Error error = - mStateManager->setDrawElementsState(data, count, type, indices, 0, &drawIndexPointer); - if (error.isError()) - { - return error; - } + const GLvoid *drawIndexPtr = nullptr; + ANGLE_TRY(mStateManager->setDrawElementsState(data, count, type, indices, 0, &drawIndexPtr)); if (!mSkipDrawCalls) { - mFunctions->drawElements(mode, count, type, drawIndexPointer); + mFunctions->drawElements(mode, count, type, drawIndexPtr); } - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } -gl::Error RendererGL::drawElementsInstanced(const gl::Data &data, +gl::Error RendererGL::drawElementsInstanced(const gl::ContextState &data, GLenum mode, GLsizei count, GLenum type, @@ -219,22 +210,18 @@ gl::Error RendererGL::drawElementsInstanced(const gl::Data &data, const gl::IndexRange &indexRange) { const GLvoid *drawIndexPointer = nullptr; - gl::Error error = mStateManager->setDrawElementsState(data, count, type, indices, instances, - &drawIndexPointer); - if (error.isError()) - { - return error; - } + ANGLE_TRY(mStateManager->setDrawElementsState(data, count, type, indices, instances, + &drawIndexPointer)); if (!mSkipDrawCalls) { mFunctions->drawElementsInstanced(mode, count, type, drawIndexPointer, instances); } - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } -gl::Error RendererGL::drawRangeElements(const gl::Data &data, +gl::Error RendererGL::drawRangeElements(const gl::ContextState &data, GLenum mode, GLuint start, GLuint end, @@ -244,12 +231,8 @@ gl::Error RendererGL::drawRangeElements(const gl::Data &data, const gl::IndexRange &indexRange) { const GLvoid *drawIndexPointer = nullptr; - gl::Error error = - mStateManager->setDrawElementsState(data, count, type, indices, 0, &drawIndexPointer); - if (error.isError()) - { - return error; - } + ANGLE_TRY( + mStateManager->setDrawElementsState(data, count, type, indices, 0, &drawIndexPointer)); if (!mSkipDrawCalls) { @@ -259,70 +242,9 @@ gl::Error RendererGL::drawRangeElements(const gl::Data &data, return gl::Error(GL_NO_ERROR); } -CompilerImpl *RendererGL::createCompiler() -{ - return new CompilerGL(mFunctions); -} - -ShaderImpl *RendererGL::createShader(const gl::Shader::Data &data) -{ - return new ShaderGL(data, mFunctions, mWorkarounds); -} - -ProgramImpl *RendererGL::createProgram(const gl::Program::Data &data) -{ - return new ProgramGL(data, mFunctions, mStateManager); -} - -FramebufferImpl *RendererGL::createFramebuffer(const gl::Framebuffer::Data &data) -{ - return new FramebufferGL(data, mFunctions, mStateManager, mWorkarounds, false); -} - -TextureImpl *RendererGL::createTexture(GLenum target) -{ - return new TextureGL(target, mFunctions, mWorkarounds, mStateManager, mBlitter); -} - -RenderbufferImpl *RendererGL::createRenderbuffer() -{ - return new RenderbufferGL(mFunctions, mWorkarounds, mStateManager, getRendererTextureCaps()); -} - -BufferImpl *RendererGL::createBuffer() -{ - return new BufferGL(mFunctions, mStateManager); -} - -VertexArrayImpl *RendererGL::createVertexArray(const gl::VertexArray::Data &data) -{ - return new VertexArrayGL(data, mFunctions, mStateManager); -} - -QueryImpl *RendererGL::createQuery(GLenum type) -{ - return new QueryGL(type, mFunctions, mStateManager); -} - -FenceNVImpl *RendererGL::createFenceNV() -{ - return new FenceNVGL(mFunctions); -} - -FenceSyncImpl *RendererGL::createFenceSync() -{ - return new FenceSyncGL(mFunctions); -} - -TransformFeedbackImpl *RendererGL::createTransformFeedback() -{ - return new TransformFeedbackGL(mFunctions, mStateManager, - getRendererCaps().maxTransformFeedbackSeparateComponents); -} - -SamplerImpl *RendererGL::createSampler() +ContextImpl *RendererGL::createContext(const gl::ContextState &state) { - return new SamplerGL(mFunctions, mStateManager); + return new ContextGL(state, this); } void RendererGL::insertEventMarker(GLsizei length, const char *marker) @@ -401,7 +323,7 @@ std::string RendererGL::getRendererDescription() const const gl::Version &RendererGL::getMaxSupportedESVersion() const { // Force generation of caps - getRendererCaps(); + getNativeCaps(); return mMaxSupportedESVersion; } @@ -413,11 +335,6 @@ void RendererGL::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureC nativegl_gl::GenerateCaps(mFunctions, outCaps, outTextureCaps, outExtensions, &mMaxSupportedESVersion); } -void RendererGL::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) -{ - mStateManager->syncState(state, dirtyBits); -} - GLint RendererGL::getGPUDisjoint() { // TODO(ewell): On GLES backends we should find a way to reliably query disjoint events @@ -431,9 +348,37 @@ GLint64 RendererGL::getTimestamp() return result; } -void RendererGL::onMakeCurrent(const gl::Data &data) +void RendererGL::ensureCapsInitialized() const { - // Queries need to be paused/resumed on context switches - mStateManager->onMakeCurrent(data); + if (!mCapsInitialized) + { + generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations); + mCapsInitialized = true; + } } + +const gl::Caps &RendererGL::getNativeCaps() const +{ + ensureCapsInitialized(); + return mNativeCaps; } + +const gl::TextureCapsMap &RendererGL::getNativeTextureCaps() const +{ + ensureCapsInitialized(); + return mNativeTextureCaps; +} + +const gl::Extensions &RendererGL::getNativeExtensions() const +{ + ensureCapsInitialized(); + return mNativeExtensions; +} + +const gl::Limitations &RendererGL::getNativeLimitations() const +{ + ensureCapsInitialized(); + return mNativeLimitations; +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.h index 0a66fedbc20..be010df9225 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/RendererGL.h @@ -9,115 +9,108 @@ #ifndef LIBANGLE_RENDERER_GL_RENDERERGL_H_ #define LIBANGLE_RENDERER_GL_RENDERERGL_H_ +#include "libANGLE/Caps.h" +#include "libANGLE/Error.h" #include "libANGLE/Version.h" -#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/gl/WorkaroundsGL.h" +namespace gl +{ +struct ContextState; +struct IndexRange; +} + +namespace egl +{ +class AttributeMap; +} + +namespace sh +{ +struct BlockMemberInfo; +} + namespace rx { class BlitGL; +class ContextImpl; class FunctionsGL; class StateManagerGL; -class RendererGL : public Renderer +class RendererGL : angle::NonCopyable { public: RendererGL(const FunctionsGL *functions, const egl::AttributeMap &attribMap); - ~RendererGL() override; + ~RendererGL(); - gl::Error flush() override; - gl::Error finish() override; + ContextImpl *createContext(const gl::ContextState &state); - gl::Error drawArrays(const gl::Data &data, GLenum mode, GLint first, GLsizei count) override; - gl::Error drawArraysInstanced(const gl::Data &data, + gl::Error flush(); + gl::Error finish(); + + gl::Error drawArrays(const gl::ContextState &data, GLenum mode, GLint first, GLsizei count); + gl::Error drawArraysInstanced(const gl::ContextState &data, GLenum mode, GLint first, GLsizei count, - GLsizei instanceCount) override; + GLsizei instanceCount); - gl::Error drawElements(const gl::Data &data, + gl::Error drawElements(const gl::ContextState &data, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, - const gl::IndexRange &indexRange) override; - gl::Error drawElementsInstanced(const gl::Data &data, + const gl::IndexRange &indexRange); + gl::Error drawElementsInstanced(const gl::ContextState &data, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instances, - const gl::IndexRange &indexRange) override; - gl::Error drawRangeElements(const gl::Data &data, + const gl::IndexRange &indexRange); + gl::Error drawRangeElements(const gl::ContextState &data, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, - const gl::IndexRange &indexRange) override; - - // Shader creation - CompilerImpl *createCompiler() override; - ShaderImpl *createShader(const gl::Shader::Data &data) override; - ProgramImpl *createProgram(const gl::Program::Data &data) override; - - // Framebuffer creation - FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override; - - // Texture creation - TextureImpl *createTexture(GLenum target) override; - - // Renderbuffer creation - RenderbufferImpl *createRenderbuffer() override; - - // Buffer creation - BufferImpl *createBuffer() override; - - // Vertex Array creation - VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override; - - // Query and Fence creation - QueryImpl *createQuery(GLenum type) override; - FenceNVImpl *createFenceNV() override; - FenceSyncImpl *createFenceSync() override; - - // Transform Feedback creation - TransformFeedbackImpl *createTransformFeedback() override; - - // Sampler object creation - SamplerImpl *createSampler() override; + const gl::IndexRange &indexRange); // EXT_debug_marker - void insertEventMarker(GLsizei length, const char *marker) override; - void pushGroupMarker(GLsizei length, const char *marker) override; - void popGroupMarker() override; + void insertEventMarker(GLsizei length, const char *marker); + void pushGroupMarker(GLsizei length, const char *marker); + void popGroupMarker(); // lost device - void notifyDeviceLost() override; - bool isDeviceLost() const override; - bool testDeviceLost() override; - bool testDeviceResettable() override; - - std::string getVendorString() const override; - std::string getRendererDescription() const override; - - void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override; + void notifyDeviceLost(); + bool isDeviceLost() const; + bool testDeviceLost(); + bool testDeviceResettable(); - GLint getGPUDisjoint() override; - GLint64 getTimestamp() override; + std::string getVendorString() const; + std::string getRendererDescription() const; - void onMakeCurrent(const gl::Data &data) override; + GLint getGPUDisjoint(); + GLint64 getTimestamp(); const gl::Version &getMaxSupportedESVersion() const; const FunctionsGL *getFunctions() const { return mFunctions; } StateManagerGL *getStateManager() const { return mStateManager; } const WorkaroundsGL &getWorkarounds() const { return mWorkarounds; } + BlitGL *getBlitter() const { return mBlitter; } + + const gl::Caps &getNativeCaps() const; + const gl::TextureCapsMap &getNativeTextureCaps() const; + const gl::Extensions &getNativeExtensions() const; + const gl::Limitations &getNativeLimitations() const; private: - void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, + void ensureCapsInitialized() const; + void generateCaps(gl::Caps *outCaps, + gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions, - gl::Limitations *outLimitations) const override; + gl::Limitations *outLimitations) const; mutable gl::Version mMaxSupportedESVersion; @@ -132,8 +125,14 @@ class RendererGL : public Renderer // For performance debugging bool mSkipDrawCalls; + + mutable bool mCapsInitialized; + mutable gl::Caps mNativeCaps; + mutable gl::TextureCapsMap mNativeTextureCaps; + mutable gl::Extensions mNativeExtensions; + mutable gl::Limitations mNativeLimitations; }; -} +} // namespace rx #endif // LIBANGLE_RENDERER_GL_RENDERERGL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.cpp index aa54d17c2c0..400917b3520 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.cpp @@ -19,7 +19,7 @@ namespace rx { -ShaderGL::ShaderGL(const gl::Shader::Data &data, +ShaderGL::ShaderGL(const gl::ShaderState &data, const FunctionsGL *functions, const WorkaroundsGL &workarounds) : ShaderImpl(data), mFunctions(functions), mWorkarounds(workarounds), mShaderID(0) diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.h index 76139ace8f3..f35d2f711e6 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/ShaderGL.h @@ -19,7 +19,7 @@ struct WorkaroundsGL; class ShaderGL : public ShaderImpl { public: - ShaderGL(const gl::Shader::Data &data, + ShaderGL(const gl::ShaderState &data, const FunctionsGL *functions, const WorkaroundsGL &workarounds); ~ShaderGL() override; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp index a1e4b466a0f..0b30afe5cbd 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp @@ -9,7 +9,7 @@ #include "libANGLE/renderer/gl/StateManagerGL.h" #include "common/BitSetIterator.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/Framebuffer.h" #include "libANGLE/TransformFeedback.h" #include "libANGLE/VertexArray.h" @@ -28,7 +28,8 @@ namespace rx { static const GLenum QueryTypes[] = {GL_ANY_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, - GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_TIME_ELAPSED}; + GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_TIME_ELAPSED, + GL_COMMANDS_COMPLETED_CHROMIUM}; StateManagerGL::IndexedBufferBinding::IndexedBufferBinding() : offset(0), size(0), buffer(0) { @@ -112,6 +113,9 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren mClearStencil(0), mFramebufferSRGBEnabled(false), mTextureCubemapSeamlessEnabled(false), + mMultisamplingEnabled(true), + mSampleAlphaToOneEnabled(false), + mCoverageModulation(GL_NONE), mLocalDirtyBits() { ASSERT(mFunctions); @@ -302,11 +306,16 @@ void StateManagerGL::useProgram(GLuint program) { if (mProgram != program) { - mProgram = program; - mFunctions->useProgram(mProgram); + forceUseProgram(program); } } +void StateManagerGL::forceUseProgram(GLuint program) +{ + mProgram = program; + mFunctions->useProgram(mProgram); +} + void StateManagerGL::bindVertexArray(GLuint vao, GLuint elementArrayBuffer) { if (mVAO != vao) @@ -587,7 +596,7 @@ void StateManagerGL::onDeleteQueryObject(QueryGL *query) mCurrentQueries.erase(query); } -gl::Error StateManagerGL::setDrawArraysState(const gl::Data &data, +gl::Error StateManagerGL::setDrawArraysState(const gl::ContextState &data, GLint first, GLsizei count, GLsizei instanceCount) @@ -611,7 +620,7 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Data &data, return setGenericDrawState(data); } -gl::Error StateManagerGL::setDrawElementsState(const gl::Data &data, +gl::Error StateManagerGL::setDrawElementsState(const gl::ContextState &data, GLsizei count, GLenum type, const GLvoid *indices, @@ -638,7 +647,7 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Data &data, return setGenericDrawState(data); } -gl::Error StateManagerGL::onMakeCurrent(const gl::Data &data) +gl::Error StateManagerGL::onMakeCurrent(const gl::ContextState &data) { const gl::State &state = *data.state; @@ -675,7 +684,7 @@ gl::Error StateManagerGL::onMakeCurrent(const gl::Data &data) return gl::Error(GL_NO_ERROR); } -gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data) +gl::Error StateManagerGL::setGenericDrawState(const gl::ContextState &data) { const gl::State &state = *data.state; @@ -724,7 +733,7 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data) bindTexture(textureType, textureGL->getTextureID()); } - textureGL->syncState(textureUnitIndex, texture->getTextureState()); + textureGL->syncState(textureUnitIndex); } else { @@ -791,11 +800,11 @@ void StateManagerGL::setAttributeCurrentData(size_t index, mVertexAttribCurrentValues[index].FloatValues); break; case GL_INT: - mFunctions->vertexAttrib4iv(static_cast<GLuint>(index), + mFunctions->vertexAttribI4iv(static_cast<GLuint>(index), mVertexAttribCurrentValues[index].IntValues); break; case GL_UNSIGNED_INT: - mFunctions->vertexAttrib4uiv(static_cast<GLuint>(index), + mFunctions->vertexAttribI4uiv(static_cast<GLuint>(index), mVertexAttribCurrentValues[index].UnsignedIntValues); break; default: UNREACHABLE(); @@ -1455,6 +1464,10 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit // TODO(jmadill): split this setPixelUnpackState(state.getUnpackState()); break; + case gl::State::DIRTY_BIT_UNPACK_BUFFER_BINDING: + // TODO(jmadill): split this + setPixelUnpackState(state.getUnpackState()); + break; case gl::State::DIRTY_BIT_PACK_ALIGNMENT: // TODO(jmadill): split this setPixelPackState(state.getPackState()); @@ -1475,6 +1488,10 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit // TODO(jmadill): split this setPixelPackState(state.getPackState()); break; + case gl::State::DIRTY_BIT_PACK_BUFFER_BINDING: + // TODO(jmadill): split this + setPixelPackState(state.getPackState()); + break; case gl::State::DIRTY_BIT_DITHER_ENABLED: // TODO(jmadill): implement this break; @@ -1499,6 +1516,14 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit case gl::State::DIRTY_BIT_PROGRAM_BINDING: // TODO(jmadill): implement this break; + case gl::State::DIRTY_BIT_MULTISAMPLING: + setMultisamplingStateEnabled(state.isMultisamplingEnabled()); + break; + case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_ONE: + setSampleAlphaToOneStateEnabled(state.isSampleAlphaToOneEnabled()); + case gl::State::DIRTY_BIT_COVERAGE_MODULATION: + setCoverageModulation(state.getCoverageModulation()); + break; default: { ASSERT(dirtyBit >= gl::State::DIRTY_BIT_CURRENT_VALUE_0 && @@ -1531,6 +1556,51 @@ void StateManagerGL::setFramebufferSRGBEnabled(bool enabled) } } +void StateManagerGL::setMultisamplingStateEnabled(bool enabled) +{ + if (mMultisamplingEnabled != enabled) + { + mMultisamplingEnabled = enabled; + if (mMultisamplingEnabled) + { + mFunctions->enable(GL_MULTISAMPLE_EXT); + } + else + { + mFunctions->disable(GL_MULTISAMPLE_EXT); + } + mLocalDirtyBits.set(gl::State::DIRTY_BIT_MULTISAMPLING); + } +} + +void StateManagerGL::setSampleAlphaToOneStateEnabled(bool enabled) +{ + if (mSampleAlphaToOneEnabled != enabled) + { + mSampleAlphaToOneEnabled = enabled; + if (mSampleAlphaToOneEnabled) + { + mFunctions->enable(GL_SAMPLE_ALPHA_TO_ONE); + } + else + { + mFunctions->disable(GL_SAMPLE_ALPHA_TO_ONE); + } + mLocalDirtyBits.set(gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_ONE); + } +} + +void StateManagerGL::setCoverageModulation(GLenum components) +{ + if (mCoverageModulation != components) + { + mCoverageModulation = components; + mFunctions->coverageModulationNV(components); + + mLocalDirtyBits.set(gl::State::DIRTY_BIT_COVERAGE_MODULATION); + } +} + void StateManagerGL::setTextureCubemapSeamlessEnabled(bool enabled) { if (mTextureCubemapSeamlessEnabled != enabled) diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.h index 1e4cdd7f618..c09fb80fef5 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.h @@ -20,7 +20,7 @@ namespace gl { struct Caps; -struct Data; +struct ContextState; class State; } @@ -47,6 +47,7 @@ class StateManagerGL final : angle::NonCopyable void deleteQuery(GLuint query); void useProgram(GLuint program); + void forceUseProgram(GLuint program); void bindVertexArray(GLuint vao, GLuint elementArrayBuffer); void bindBuffer(GLenum type, GLuint buffer); void bindBufferBase(GLenum type, size_t index, GLuint buffer); @@ -123,25 +124,30 @@ class StateManagerGL final : angle::NonCopyable void setFramebufferSRGBEnabled(bool enabled); + void setMultisamplingStateEnabled(bool enabled); + void setSampleAlphaToOneStateEnabled(bool enabled); + + void setCoverageModulation(GLenum components); + void onDeleteQueryObject(QueryGL *query); - gl::Error setDrawArraysState(const gl::Data &data, + gl::Error setDrawArraysState(const gl::ContextState &data, GLint first, GLsizei count, GLsizei instanceCount); - gl::Error setDrawElementsState(const gl::Data &data, + gl::Error setDrawElementsState(const gl::ContextState &data, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instanceCount, const GLvoid **outIndices); - gl::Error onMakeCurrent(const gl::Data &data); + gl::Error onMakeCurrent(const gl::ContextState &data); void syncState(const gl::State &state, const gl::State::DirtyBits &glDirtyBits); private: - gl::Error setGenericDrawState(const gl::Data &data); + gl::Error setGenericDrawState(const gl::ContextState &data); void setTextureCubemapSeamlessEnabled(bool enabled); @@ -253,6 +259,11 @@ class StateManagerGL final : angle::NonCopyable bool mFramebufferSRGBEnabled; bool mTextureCubemapSeamlessEnabled; + bool mMultisamplingEnabled; + bool mSampleAlphaToOneEnabled; + + GLenum mCoverageModulation; + gl::State::DirtyBits mLocalDirtyBits; }; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp index 46627847e6d..51499f24d07 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp @@ -22,7 +22,7 @@ SurfaceGL::~SurfaceGL() { } -FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::Framebuffer::Data &data) +FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::FramebufferState &data) { return new FramebufferGL(data, mRenderer->getFunctions(), mRenderer->getStateManager(), mRenderer->getWorkarounds(), true); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.h index e056dd2a872..91d58c51845 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/SurfaceGL.h @@ -28,7 +28,7 @@ class SurfaceGL : public SurfaceImpl return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL"); } - FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override; + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; virtual egl::Error makeCurrent() = 0; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.cpp index a30d70d7020..7d74254b2b2 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.cpp @@ -106,19 +106,18 @@ LevelInfoGL::LevelInfoGL(GLenum sourceFormat_, { } -TextureGL::TextureGL(GLenum type, +TextureGL::TextureGL(const gl::TextureState &state, const FunctionsGL *functions, const WorkaroundsGL &workarounds, StateManagerGL *stateManager, BlitGL *blitter) - : TextureImpl(), - mTextureType(type), + : TextureImpl(state), mFunctions(functions), mWorkarounds(workarounds), mStateManager(stateManager), mBlitter(blitter), - mLevelInfo(gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS), - mAppliedTextureState(), + mLevelInfo(gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1), + mAppliedTextureState(state.target), mTextureID(0) { ASSERT(mFunctions); @@ -126,7 +125,7 @@ TextureGL::TextureGL(GLenum type, ASSERT(mBlitter); mFunctions->genTextures(1, &mTextureID); - mStateManager->bindTexture(mTextureType, mTextureID); + mStateManager->bindTexture(mState.target, mTextureID); } TextureGL::~TextureGL() @@ -145,20 +144,20 @@ gl::Error TextureGL::setImage(GLenum target, size_t level, GLenum internalFormat const gl::PixelUnpackState &unpack, const uint8_t *pixels) { UNUSED_ASSERTION_VARIABLE(&CompatibleTextureTarget); // Reference this function to avoid warnings. - ASSERT(CompatibleTextureTarget(mTextureType, target)); + ASSERT(CompatibleTextureTarget(mState.target, target)); nativegl::TexImageFormat texImageFormat = nativegl::GetTexImageFormat(mFunctions, mWorkarounds, internalFormat, format, type); - mStateManager->bindTexture(mTextureType, mTextureID); - if (UseTexImage2D(mTextureType)) + mStateManager->bindTexture(mState.target, mTextureID); + if (UseTexImage2D(mState.target)) { ASSERT(size.depth == 1); mFunctions->texImage2D(target, static_cast<GLint>(level), texImageFormat.internalFormat, size.width, size.height, 0, texImageFormat.format, texImageFormat.type, pixels); } - else if (UseTexImage3D(mTextureType)) + else if (UseTexImage3D(mState.target)) { mFunctions->texImage3D(target, static_cast<GLint>(level), texImageFormat.internalFormat, size.width, size.height, size.depth, 0, texImageFormat.format, @@ -177,20 +176,20 @@ gl::Error TextureGL::setImage(GLenum target, size_t level, GLenum internalFormat gl::Error TextureGL::setSubImage(GLenum target, size_t level, const gl::Box &area, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const uint8_t *pixels) { - ASSERT(CompatibleTextureTarget(mTextureType, target)); + ASSERT(CompatibleTextureTarget(mState.target, target)); nativegl::TexSubImageFormat texSubImageFormat = nativegl::GetTexSubImageFormat(mFunctions, mWorkarounds, format, type); - mStateManager->bindTexture(mTextureType, mTextureID); - if (UseTexImage2D(mTextureType)) + mStateManager->bindTexture(mState.target, mTextureID); + if (UseTexImage2D(mState.target)) { ASSERT(area.z == 0 && area.depth == 1); mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, area.y, area.width, area.height, texSubImageFormat.format, texSubImageFormat.type, pixels); } - else if (UseTexImage3D(mTextureType)) + else if (UseTexImage3D(mState.target)) { mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z, area.width, area.height, area.depth, texSubImageFormat.format, @@ -210,20 +209,20 @@ gl::Error TextureGL::setSubImage(GLenum target, size_t level, const gl::Box &are gl::Error TextureGL::setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size, const gl::PixelUnpackState &unpack, size_t imageSize, const uint8_t *pixels) { - ASSERT(CompatibleTextureTarget(mTextureType, target)); + ASSERT(CompatibleTextureTarget(mState.target, target)); nativegl::CompressedTexImageFormat compressedTexImageFormat = nativegl::GetCompressedTexImageFormat(mFunctions, mWorkarounds, internalFormat); - mStateManager->bindTexture(mTextureType, mTextureID); - if (UseTexImage2D(mTextureType)) + mStateManager->bindTexture(mState.target, mTextureID); + if (UseTexImage2D(mState.target)) { ASSERT(size.depth == 1); mFunctions->compressedTexImage2D(target, static_cast<GLint>(level), compressedTexImageFormat.internalFormat, size.width, size.height, 0, static_cast<GLsizei>(imageSize), pixels); } - else if (UseTexImage3D(mTextureType)) + else if (UseTexImage3D(mState.target)) { mFunctions->compressedTexImage3D( target, static_cast<GLint>(level), compressedTexImageFormat.internalFormat, size.width, @@ -243,20 +242,20 @@ gl::Error TextureGL::setCompressedImage(GLenum target, size_t level, GLenum inte gl::Error TextureGL::setCompressedSubImage(GLenum target, size_t level, const gl::Box &area, GLenum format, const gl::PixelUnpackState &unpack, size_t imageSize, const uint8_t *pixels) { - ASSERT(CompatibleTextureTarget(mTextureType, target)); + ASSERT(CompatibleTextureTarget(mState.target, target)); nativegl::CompressedTexSubImageFormat compressedTexSubImageFormat = nativegl::GetCompressedSubTexImageFormat(mFunctions, mWorkarounds, format); - mStateManager->bindTexture(mTextureType, mTextureID); - if (UseTexImage2D(mTextureType)) + mStateManager->bindTexture(mState.target, mTextureID); + if (UseTexImage2D(mState.target)) { ASSERT(area.z == 0 && area.depth == 1); mFunctions->compressedTexSubImage2D( target, static_cast<GLint>(level), area.x, area.y, area.width, area.height, compressedTexSubImageFormat.format, static_cast<GLsizei>(imageSize), pixels); } - else if (UseTexImage3D(mTextureType)) + else if (UseTexImage3D(mState.target)) { mFunctions->compressedTexSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z, area.width, area.height, area.depth, @@ -284,7 +283,7 @@ gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle if (levelInfo.lumaWorkaround.enabled) { gl::Error error = mBlitter->copyImageToLUMAWorkaroundTexture( - mTextureID, mTextureType, target, levelInfo.sourceFormat, level, sourceArea, + mTextureID, mState.target, target, levelInfo.sourceFormat, level, sourceArea, copyTexImageFormat.internalFormat, source); if (error.isError()) { @@ -295,11 +294,11 @@ gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle { const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source); - mStateManager->bindTexture(mTextureType, mTextureID); + mStateManager->bindTexture(mState.target, mTextureID); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID()); - if (UseTexImage2D(mTextureType)) + if (UseTexImage2D(mState.target)) { mFunctions->copyTexImage2D(target, static_cast<GLint>(level), copyTexImageFormat.internalFormat, sourceArea.x, @@ -321,15 +320,15 @@ gl::Error TextureGL::copySubImage(GLenum target, size_t level, const gl::Offset { const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source); - mStateManager->bindTexture(mTextureType, mTextureID); + mStateManager->bindTexture(mState.target, mTextureID); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID()); const LevelInfoGL &levelInfo = mLevelInfo[level]; if (levelInfo.lumaWorkaround.enabled) { gl::Error error = mBlitter->copySubImageToLUMAWorkaroundTexture( - mTextureID, mTextureType, target, levelInfo.sourceFormat, level, destOffset, sourceArea, - source); + mTextureID, mState.target, target, levelInfo.sourceFormat, level, destOffset, + sourceArea, source); if (error.isError()) { return error; @@ -337,14 +336,14 @@ gl::Error TextureGL::copySubImage(GLenum target, size_t level, const gl::Offset } else { - if (UseTexImage2D(mTextureType)) + if (UseTexImage2D(mState.target)) { ASSERT(destOffset.z == 0); mFunctions->copyTexSubImage2D(target, static_cast<GLint>(level), destOffset.x, destOffset.y, sourceArea.x, sourceArea.y, sourceArea.width, sourceArea.height); } - else if (UseTexImage3D(mTextureType)) + else if (UseTexImage3D(mState.target)) { mFunctions->copyTexSubImage3D(target, static_cast<GLint>(level), destOffset.x, destOffset.y, destOffset.z, sourceArea.x, sourceArea.y, @@ -367,8 +366,8 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor nativegl::TexStorageFormat texStorageFormat = nativegl::GetTexStorageFormat(mFunctions, mWorkarounds, internalFormat); - mStateManager->bindTexture(mTextureType, mTextureID); - if (UseTexImage2D(mTextureType)) + mStateManager->bindTexture(mState.target, mTextureID); + if (UseTexImage2D(mState.target)) { ASSERT(size.depth == 1); if (mFunctions->texStorage2D) @@ -392,7 +391,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor std::max(size.height >> level, 1), 1); - if (mTextureType == GL_TEXTURE_2D) + if (mState.target == GL_TEXTURE_2D) { if (internalFormatInfo.compressed) { @@ -410,7 +409,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor internalFormatInfo.type, nullptr); } } - else if (mTextureType == GL_TEXTURE_CUBE_MAP) + else if (mState.target == GL_TEXTURE_CUBE_MAP) { for (GLenum face = gl::FirstCubeMapTextureTarget; face <= gl::LastCubeMapTextureTarget; face++) { @@ -438,7 +437,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor } } } - else if (UseTexImage3D(mTextureType)) + else if (UseTexImage3D(mState.target)) { if (mFunctions->texStorage3D) { @@ -458,9 +457,9 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor for (GLsizei i = 0; i < static_cast<GLsizei>(levels); i++) { - gl::Extents levelSize(std::max(size.width >> i, 1), - std::max(size.height >> i, 1), - mTextureType == GL_TEXTURE_3D ? std::max(size.depth >> i, 1) : size.depth); + gl::Extents levelSize( + std::max(size.width >> i, 1), std::max(size.height >> i, 1), + mState.target == GL_TEXTURE_3D ? std::max(size.depth >> i, 1) : size.depth); if (internalFormatInfo.compressed) { @@ -495,14 +494,22 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor return gl::Error(GL_NO_ERROR); } -gl::Error TextureGL::generateMipmaps(const gl::TextureState &textureState) +gl::Error TextureGL::setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) { - mStateManager->bindTexture(mTextureType, mTextureID); - mFunctions->generateMipmap(mTextureType); + UNIMPLEMENTED(); + return gl::Error(GL_INVALID_OPERATION); +} - for (size_t level = textureState.baseLevel; level < mLevelInfo.size(); level++) +gl::Error TextureGL::generateMipmaps() +{ + mStateManager->bindTexture(mState.target, mTextureID); + mFunctions->generateMipmap(mState.target); + + for (size_t level = mState.baseLevel; level < mLevelInfo.size(); level++) { - mLevelInfo[level] = mLevelInfo[textureState.baseLevel]; + mLevelInfo[level] = mLevelInfo[mState.baseLevel]; } return gl::Error(GL_NO_ERROR); @@ -510,10 +517,10 @@ gl::Error TextureGL::generateMipmaps(const gl::TextureState &textureState) void TextureGL::bindTexImage(egl::Surface *surface) { - ASSERT(mTextureType == GL_TEXTURE_2D); + ASSERT(mState.target == GL_TEXTURE_2D); // Make sure this texture is bound - mStateManager->bindTexture(mTextureType, mTextureID); + mStateManager->bindTexture(mState.target, mTextureID); mLevelInfo[0] = LevelInfoGL(); } @@ -521,12 +528,13 @@ void TextureGL::bindTexImage(egl::Surface *surface) void TextureGL::releaseTexImage() { // Not all Surface implementations reset the size of mip 0 when releasing, do it manually - ASSERT(mTextureType == GL_TEXTURE_2D); + ASSERT(mState.target == GL_TEXTURE_2D); - mStateManager->bindTexture(mTextureType, mTextureID); - if (UseTexImage2D(mTextureType)) + mStateManager->bindTexture(mState.target, mTextureID); + if (UseTexImage2D(mState.target)) { - mFunctions->texImage2D(mTextureType, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); + mFunctions->texImage2D(mState.target, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, + nullptr); } else { @@ -704,7 +712,7 @@ static inline void SyncTextureStateSwizzle(const FunctionsGL *functions, } } -void TextureGL::syncState(size_t textureUnit, const gl::TextureState &textureState) const +void TextureGL::syncState(size_t textureUnit) const { // Callback lamdba to bind this texture only if needed. bool textureApplied = false; @@ -713,34 +721,47 @@ void TextureGL::syncState(size_t textureUnit, const gl::TextureState &textureSta if (!textureApplied) { mStateManager->activeTexture(textureUnit); - mStateManager->bindTexture(mTextureType, mTextureID); + mStateManager->bindTexture(mState.target, mTextureID); textureApplied = true; } }; - // clang-format off - // Sync texture state - SyncTextureStateMember(mFunctions, applyTextureFunc, textureState, mAppliedTextureState, mTextureType, GL_TEXTURE_BASE_LEVEL, &gl::TextureState::baseLevel); - SyncTextureStateMember(mFunctions, applyTextureFunc, textureState, mAppliedTextureState, mTextureType, GL_TEXTURE_MAX_LEVEL, &gl::TextureState::maxLevel); + // Apply the effective base level and max level instead of the base level and max level set from + // the API. This can help with buggy drivers. + if (mAppliedTextureState.getEffectiveBaseLevel() != mState.getEffectiveBaseLevel()) + { + applyTextureFunc(); + mFunctions->texParameteri(mState.target, GL_TEXTURE_BASE_LEVEL, + mState.getEffectiveBaseLevel()); + } + mAppliedTextureState.baseLevel = mState.baseLevel; + if (mAppliedTextureState.getEffectiveMaxLevel() != mState.getEffectiveMaxLevel()) + { + applyTextureFunc(); + mFunctions->texParameteri(mState.target, GL_TEXTURE_MAX_LEVEL, + mState.getEffectiveMaxLevel()); + } + mAppliedTextureState.maxLevel = mState.maxLevel; - const LevelInfoGL &levelInfo = mLevelInfo[textureState.baseLevel]; - SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, textureState, mAppliedTextureState, mTextureType, GL_TEXTURE_SWIZZLE_R, &gl::TextureState::swizzleRed); - SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, textureState, mAppliedTextureState, mTextureType, GL_TEXTURE_SWIZZLE_G, &gl::TextureState::swizzleGreen); - SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, textureState, mAppliedTextureState, mTextureType, GL_TEXTURE_SWIZZLE_B, &gl::TextureState::swizzleBlue); - SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, textureState, mAppliedTextureState, mTextureType, GL_TEXTURE_SWIZZLE_A, &gl::TextureState::swizzleAlpha); + // clang-format off + const LevelInfoGL &levelInfo = mLevelInfo[mState.getEffectiveBaseLevel()]; + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState, mAppliedTextureState, mState.target, GL_TEXTURE_SWIZZLE_R, &gl::TextureState::swizzleRed); + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState, mAppliedTextureState, mState.target, GL_TEXTURE_SWIZZLE_G, &gl::TextureState::swizzleGreen); + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState, mAppliedTextureState, mState.target, GL_TEXTURE_SWIZZLE_B, &gl::TextureState::swizzleBlue); + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState, mAppliedTextureState, mState.target, GL_TEXTURE_SWIZZLE_A, &gl::TextureState::swizzleAlpha); // Sync sampler state - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode); - SyncSamplerStateMember(mFunctions, applyTextureFunc, textureState.samplerState, mAppliedTextureState.samplerState, mTextureType, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.samplerState, mAppliedTextureState.samplerState, mState.target, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc); // clang-format on } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.h index 6d64d9d1f36..1daa97b4d79 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/TextureGL.h @@ -11,6 +11,7 @@ #include "libANGLE/angletypes.h" #include "libANGLE/renderer/TextureImpl.h" +#include "libANGLE/Texture.h" namespace rx { @@ -51,7 +52,7 @@ struct LevelInfoGL class TextureGL : public TextureImpl { public: - TextureGL(GLenum type, + TextureGL(const gl::TextureState &state, const FunctionsGL *functions, const WorkaroundsGL &workarounds, StateManagerGL *stateManager, @@ -77,14 +78,18 @@ class TextureGL : public TextureImpl gl::Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size) override; - gl::Error generateMipmaps(const gl::TextureState &textureState) override; + gl::Error setImageExternal(GLenum target, + egl::Stream *stream, + const egl::Stream::GLTextureDescription &desc) override; + + gl::Error generateMipmaps() override; void bindTexImage(egl::Surface *surface) override; void releaseTexImage() override; gl::Error setEGLImageTarget(GLenum target, egl::Image *image) override; - void syncState(size_t textureUnit, const gl::TextureState &textureState) const; + void syncState(size_t textureUnit) const; GLuint getTextureID() const; gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, @@ -93,9 +98,9 @@ class TextureGL : public TextureImpl return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL"); } - private: - GLenum mTextureType; + void setBaseLevel(GLuint) override {} + private: const FunctionsGL *mFunctions; const WorkaroundsGL &mWorkarounds; StateManagerGL *mStateManager; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/TransformFeedbackGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/TransformFeedbackGL.cpp index c325bb199a9..6b7560ff06e 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/TransformFeedbackGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/TransformFeedbackGL.cpp @@ -9,7 +9,7 @@ #include "libANGLE/renderer/gl/TransformFeedbackGL.h" #include "common/debug.h" -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/renderer/gl/BufferGL.h" #include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h" diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.cpp index 255b41f565b..5f5b032c77f 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.cpp @@ -32,10 +32,10 @@ bool AttributeNeedsStreaming(const VertexAttribute &attribute) } // anonymous namespace -VertexArrayGL::VertexArrayGL(const VertexArray::Data &data, +VertexArrayGL::VertexArrayGL(const VertexArrayState &state, const FunctionsGL *functions, StateManagerGL *stateManager) - : VertexArrayImpl(data), + : VertexArrayImpl(state), mFunctions(functions), mStateManager(stateManager), mVertexArrayID(0), diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.h index 30419996545..261b63d918f 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/VertexArrayGL.h @@ -20,7 +20,9 @@ class StateManagerGL; class VertexArrayGL : public VertexArrayImpl { public: - VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager); + VertexArrayGL(const gl::VertexArrayState &data, + const FunctionsGL *functions, + StateManagerGL *stateManager); ~VertexArrayGL() override; gl::Error syncDrawArraysState(const gl::AttributesMask &activeAttributesMask, diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h index e05d4700482..a79da25c667 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h @@ -19,7 +19,8 @@ struct WorkaroundsGL rgba4IsNotSupportedForColorRendering(false), doesSRGBClearsOnLinearFramebufferAttachments(false), doWhileGLSLCausesGPUHang(false), - finishDoesNotCauseQueriesToBeAvailable(false) + finishDoesNotCauseQueriesToBeAvailable(false), + alwaysCallUseProgramAfterLink(false) { } @@ -56,6 +57,12 @@ struct WorkaroundsGL // (NVIDIA) drivers. It was found that enabling GL_DEBUG_OUTPUT_SYNCHRONOUS before the finish // causes it to fully finish. bool finishDoesNotCauseQueriesToBeAvailable; + + // Always call useProgram after a successful link to avoid a driver bug. + // This workaround is meant to reproduce the use_current_program_after_successful_link + // workaround in Chromium (http://crbug.com/110263). It has been shown that this workaround is + // not necessary for MacOSX 10.9 and higher (http://crrev.com/39eb535b). + bool alwaysCallUseProgramAfterLink; }; } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h index 80b5f58ecde..35aa83fda55 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h @@ -44,7 +44,7 @@ class PbufferSurfaceCGL : public SurfaceGL EGLint isPostSubBufferSupported() const override; EGLint getSwapBehavior() const override; - FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override; + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; private: unsigned mWidth; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm index ec936a60a48..1a4e7d40bb1 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm @@ -132,10 +132,10 @@ EGLint PbufferSurfaceCGL::getSwapBehavior() const return EGL_BUFFER_PRESERVED; } -FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::Framebuffer::Data &data) +FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state) { // TODO(cwallez) assert it happens only once? - return new FramebufferGL(mFramebuffer, data, mFunctions, mWorkarounds, mStateManager); + return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mStateManager); } } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h index 83cbe8f092c..d2650b05c60 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h @@ -76,7 +76,7 @@ class WindowSurfaceCGL : public SurfaceGL EGLint isPostSubBufferSupported() const override; EGLint getSwapBehavior() const override; - FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override; + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; private: SwapLayer *mSwapLayer; diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm index 0dc5770f297..69c4377aa8a 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm @@ -320,10 +320,10 @@ EGLint WindowSurfaceCGL::getSwapBehavior() const return EGL_BUFFER_DESTROYED; } -FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::Framebuffer::Data &data) +FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state) { // TODO(cwallez) assert it happens only once? - return new FramebufferGL(mFramebuffer, data, mFunctions, mWorkarounds, mStateManager); + return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mStateManager); } } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGL.cpp new file mode 100644 index 00000000000..bde7fd731c2 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGL.cpp @@ -0,0 +1,264 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// FunctionsEGL.cpp: Implements the FunctionsEGL class. + +#include "libANGLE/renderer/gl/egl/FunctionsEGL.h" + +#include <algorithm> + +#include "libANGLE/renderer/gl/FunctionsGL.h" +#include "libANGLE/renderer/gl/egl/functionsegl_typedefs.h" +#include "common/string_utils.h" + +namespace +{ + +template <typename T> +bool SetPtr(T *dst, void *src) +{ + if (src) + { + *dst = reinterpret_cast<T>(src); + return true; + } + return false; +} +} // namespace + +namespace rx +{ + +struct FunctionsEGL::EGLDispatchTable +{ + EGLDispatchTable() + : bindAPIPtr(nullptr), + chooseConfigPtr(nullptr), + createContextPtr(nullptr), + destroyContextPtr(nullptr), + getConfigAttribPtr(nullptr), + getDisplayPtr(nullptr), + getErrorPtr(nullptr), + initializePtr(nullptr), + makeCurrentPtr(nullptr), + queryStringPtr(nullptr), + terminatePtr(nullptr), + + createImageKHRPtr(nullptr), + destroyImageKHRPtr(nullptr), + + clientWaitSyncKHRPtr(nullptr), + createSyncKHRPtr(nullptr), + destroySyncKHRPtr(nullptr), + getSyncAttribKHRPtr(nullptr) + { + } + + PFNEGLBINDAPIPROC bindAPIPtr; + PFNEGLCHOOSECONFIGPROC chooseConfigPtr; + PFNEGLCREATECONTEXTPROC createContextPtr; + PFNEGLDESTROYCONTEXTPROC destroyContextPtr; + PFNEGLGETCONFIGATTRIBPROC getConfigAttribPtr; + PFNEGLGETDISPLAYPROC getDisplayPtr; + PFNEGLGETERRORPROC getErrorPtr; + PFNEGLINITIALIZEPROC initializePtr; + PFNEGLMAKECURRENTPROC makeCurrentPtr; + PFNEGLQUERYSTRINGPROC queryStringPtr; + PFNEGLTERMINATEPROC terminatePtr; + + // EGL_KHR_image + PFNEGLCREATEIMAGEKHRPROC createImageKHRPtr; + PFNEGLDESTROYIMAGEKHRPROC destroyImageKHRPtr; + + // EGL_KHR_fence_sync + PFNEGLCLIENTWAITSYNCKHRPROC clientWaitSyncKHRPtr; + PFNEGLCREATESYNCKHRPROC createSyncKHRPtr; + PFNEGLDESTROYSYNCKHRPROC destroySyncKHRPtr; + PFNEGLGETSYNCATTRIBKHRPROC getSyncAttribKHRPtr; +}; + +FunctionsEGL::FunctionsEGL() + : majorVersion(0), minorVersion(0), mFnPtrs(new EGLDispatchTable()), mEGLDisplay(EGL_NO_DISPLAY) +{ +} + +FunctionsEGL::~FunctionsEGL() +{ + SafeDelete(mFnPtrs); +} + +egl::Error FunctionsEGL::initialize(EGLNativeDisplayType nativeDisplay) +{ +#define ANGLE_GET_PROC_OR_ERROR(MEMBER, NAME) \ + if (!SetPtr(MEMBER, getProcAddress(#NAME))) \ + { \ + return egl::Error(EGL_NOT_INITIALIZED, "Could not load EGL entry point " #NAME); \ + } + + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->bindAPIPtr, eglBindAPI); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->chooseConfigPtr, eglChooseConfig); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createContextPtr, eglCreateContext); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroyContextPtr, eglDestroyContext); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getConfigAttribPtr, eglGetConfigAttrib); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getDisplayPtr, eglGetDisplay); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getErrorPtr, eglGetError); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->initializePtr, eglInitialize); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->makeCurrentPtr, eglMakeCurrent); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->queryStringPtr, eglQueryString); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->terminatePtr, eglTerminate); + + mEGLDisplay = mFnPtrs->getDisplayPtr(nativeDisplay); + if (mEGLDisplay == EGL_NO_DISPLAY) + { + return egl::Error(mFnPtrs->getErrorPtr(), "Failed to get system egl display"); + } + if (mFnPtrs->initializePtr(mEGLDisplay, &majorVersion, &minorVersion) != EGL_TRUE) + { + return egl::Error(mFnPtrs->getErrorPtr(), "Failed to initialize system egl"); + } + if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 4)) + { + return egl::Error(EGL_NOT_INITIALIZED, "Unsupported EGL version (require at least 1.4)."); + } + if (mFnPtrs->bindAPIPtr(EGL_OPENGL_ES_API) != EGL_TRUE) + { + return egl::Error(mFnPtrs->getErrorPtr(), "Failed to bind API in system egl"); + } + + const char *extensions = queryString(EGL_EXTENSIONS); + if (!extensions) + { + return egl::Error(mFnPtrs->getErrorPtr(), "Faild to query extensions in system egl"); + } + angle::SplitStringAlongWhitespace(extensions, &mExtensions); + + if (hasExtension("EGL_KHR_image_base")) + { + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createImageKHRPtr, eglCreateImageKHR); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroyImageKHRPtr, eglDestroyImageKHR); + } + if (hasExtension("EGL_KHR_fence_sync")) + { + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->clientWaitSyncKHRPtr, eglClientWaitSyncKHR); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createSyncKHRPtr, eglCreateSyncKHR); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroySyncKHRPtr, eglDestroySyncKHR); + ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getSyncAttribKHRPtr, eglGetSyncAttribKHR); + } + +#undef ANGLE_GET_PROC_OR_ERROR + + return egl::Error(EGL_SUCCESS); +} + +egl::Error FunctionsEGL::terminate() +{ + if (mFnPtrs->terminatePtr(mEGLDisplay) == EGL_TRUE) + { + mEGLDisplay = nullptr; + return egl::Error(EGL_SUCCESS); + } + return egl::Error(mFnPtrs->getErrorPtr()); +} + +class FunctionsGLEGL : public FunctionsGL +{ + public: + FunctionsGLEGL(const FunctionsEGL &egl) : mEGL(egl) {} + + ~FunctionsGLEGL() override {} + + private: + void *loadProcAddress(const std::string &function) override + { + return mEGL.getProcAddress(function.c_str()); + } + + const FunctionsEGL &mEGL; +}; + +FunctionsGL *FunctionsEGL::makeFunctionsGL(void) const +{ + return new FunctionsGLEGL(*this); +} + +bool FunctionsEGL::hasExtension(const char *extension) const +{ + return std::find(mExtensions.begin(), mExtensions.end(), extension) != mExtensions.end(); +} + +EGLDisplay FunctionsEGL::getDisplay() const +{ + return mEGLDisplay; +} + +EGLBoolean FunctionsEGL::chooseConfig(EGLint const *attribList, + EGLConfig *configs, + EGLint configSize, + EGLint *numConfig) +{ + return mFnPtrs->chooseConfigPtr(mEGLDisplay, attribList, configs, configSize, numConfig); +} + +EGLBoolean FunctionsEGL::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) +{ + return mFnPtrs->getConfigAttribPtr(mEGLDisplay, config, attribute, value); +} + +EGLContext FunctionsEGL::createContext(EGLConfig config, + EGLContext share_context, + EGLint const *attrib_list) const +{ + return mFnPtrs->createContextPtr(mEGLDisplay, config, share_context, attrib_list); +} + +EGLBoolean FunctionsEGL::destroyContext(EGLContext context) const +{ + return mFnPtrs->destroyContextPtr(mEGLDisplay, context); +} + +EGLBoolean FunctionsEGL::makeCurrent(EGLSurface surface, EGLContext context) const +{ + return mFnPtrs->makeCurrentPtr(mEGLDisplay, surface, surface, context); +} + +char const *FunctionsEGL::queryString(EGLint name) const +{ + return mFnPtrs->queryStringPtr(mEGLDisplay, name); +} + +EGLImageKHR FunctionsEGL::createImageKHR(EGLContext context, + EGLenum target, + EGLClientBuffer buffer, + const EGLint *attrib_list) const +{ + return mFnPtrs->createImageKHRPtr(mEGLDisplay, context, target, buffer, attrib_list); +} + +EGLBoolean FunctionsEGL::destroyImageKHR(EGLImageKHR image) const +{ + return mFnPtrs->destroyImageKHRPtr(mEGLDisplay, image); +} + +EGLSyncKHR FunctionsEGL::createSyncKHR(EGLenum type, const EGLint *attrib_list) +{ + return mFnPtrs->createSyncKHRPtr(mEGLDisplay, type, attrib_list); +} + +EGLBoolean FunctionsEGL::destroySyncKHR(EGLSyncKHR sync) +{ + return mFnPtrs->destroySyncKHRPtr(mEGLDisplay, sync); +} + +EGLint FunctionsEGL::clientWaitSyncKHR(EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) +{ + return mFnPtrs->clientWaitSyncKHRPtr(mEGLDisplay, sync, flags, timeout); +} + +EGLBoolean FunctionsEGL::getSyncAttribKHR(EGLSyncKHR sync, EGLint attribute, EGLint *value) +{ + return mFnPtrs->getSyncAttribKHRPtr(mEGLDisplay, sync, attribute, value); +} +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGL.h new file mode 100644 index 00000000000..574573c9569 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGL.h @@ -0,0 +1,79 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// FunctionsEGL.h: Defines the FunctionsEGL class to load functions and data from EGL + +#ifndef LIBANGLE_RENDERER_GL_CROS_FUNCTIONSEGL_H_ +#define LIBANGLE_RENDERER_GL_CROS_FUNCTIONSEGL_H_ + +#include <EGL/egl.h> +#include <EGL/eglext.h> + +#include <string> +#include <vector> + +#include "libANGLE/Error.h" + +namespace rx +{ + +class FunctionsGL; + +class FunctionsEGL +{ + public: + FunctionsEGL(); + virtual ~FunctionsEGL(); + + int majorVersion; + int minorVersion; + + virtual egl::Error initialize(EGLNativeDisplayType nativeDisplay); + virtual egl::Error terminate(); + + virtual void *getProcAddress(const char *name) const = 0; + + FunctionsGL *makeFunctionsGL() const; + bool hasExtension(const char *extension) const; + EGLDisplay getDisplay() const; + + EGLBoolean chooseConfig(EGLint const *attrib_list, + EGLConfig *configs, + EGLint config_size, + EGLint *num_config); + EGLBoolean getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); + EGLContext createContext(EGLConfig config, + EGLContext share_context, + EGLint const *attrib_list) const; + EGLBoolean destroyContext(EGLContext context) const; + EGLBoolean makeCurrent(EGLSurface surface, EGLContext context) const; + const char *queryString(EGLint name) const; + + EGLImageKHR createImageKHR(EGLContext context, + EGLenum target, + EGLClientBuffer buffer, + const EGLint *attrib_list) const; + EGLBoolean destroyImageKHR(EGLImageKHR image) const; + + EGLSyncKHR createSyncKHR(EGLenum type, const EGLint *attrib_list); + EGLBoolean destroySyncKHR(EGLSyncKHR sync); + EGLint clientWaitSyncKHR(EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); + EGLBoolean getSyncAttribKHR(EGLSyncKHR sync, EGLint attribute, EGLint *value); + + private: + // So as to isolate from angle we do not include angleutils.h and cannot + // use angle::NonCopyable so we replicated it here instead. + FunctionsEGL(const FunctionsEGL &) = delete; + void operator=(const FunctionsEGL &) = delete; + + struct EGLDispatchTable; + EGLDispatchTable *mFnPtrs; + EGLDisplay mEGLDisplay; + std::vector<std::string> mExtensions; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_GL_CROS_FUNCTIONSEGL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp new file mode 100644 index 00000000000..350d90d01b9 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp @@ -0,0 +1,74 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// FunctionsEGLDL.cpp: Implements the FunctionsEGLDL class. + +#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h" + +#include <dlfcn.h> + +namespace rx +{ + +DynamicLib::DynamicLib() : handle(nullptr) +{ +} + +DynamicLib::~DynamicLib() +{ + if (handle) + { + dlclose(handle); + handle = nullptr; + } +} + +// Due to a bug in Mesa (or maybe libdl) it's not possible to close and re-open libEGL.so +// an arbitrary number of times. End2end tests would die after a couple hundred tests. +// So we use a static object with a destructor to close the library when the program exits. +// TODO(fjhenigman) File a bug and put a link here. +DynamicLib FunctionsEGLDL::sNativeLib; + +FunctionsEGLDL::FunctionsEGLDL() +{ +} + +FunctionsEGLDL::~FunctionsEGLDL() +{ +} + +egl::Error FunctionsEGLDL::initialize(EGLNativeDisplayType nativeDisplay, const char *libName) +{ + if (!sNativeLib.handle) + { + sNativeLib.handle = dlopen(libName, RTLD_NOW); + if (!sNativeLib.handle) + { + return egl::Error(EGL_NOT_INITIALIZED, "Could not dlopen native EGL: %s", dlerror()); + } + } + + mGetProcAddressPtr = + reinterpret_cast<PFNEGLGETPROCADDRESSPROC>(dlsym(sNativeLib.handle, "eglGetProcAddress")); + if (!mGetProcAddressPtr) + { + return egl::Error(EGL_NOT_INITIALIZED, "Could not find eglGetProcAddress"); + } + + return FunctionsEGL::initialize(nativeDisplay); +} + +void *FunctionsEGLDL::getProcAddress(const char *name) const +{ + void *f = reinterpret_cast<void *>(mGetProcAddressPtr(name)); + if (f) + { + return f; + } + return dlsym(sNativeLib.handle, name); +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h new file mode 100644 index 00000000000..50aa43d487d --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h @@ -0,0 +1,42 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// FunctionsEGL.h: Implements FunctionsEGL with dlopen/dlsym/dlclose + +#ifndef LIBANGLE_RENDERER_GL_CROS_FUNCTIONSEGLDL_H_ +#define LIBANGLE_RENDERER_GL_CROS_FUNCTIONSEGLDL_H_ + +#include "libANGLE/renderer/gl/egl/FunctionsEGL.h" +#include "libANGLE/renderer/gl/egl/functionsegl_typedefs.h" + +namespace rx +{ + +class DynamicLib final +{ + public: + void *handle; + + DynamicLib(); + ~DynamicLib(); +}; + +class FunctionsEGLDL : public FunctionsEGL +{ + public: + FunctionsEGLDL(); + virtual ~FunctionsEGLDL(); + + egl::Error initialize(EGLNativeDisplayType nativeDisplay, const char *libName); + virtual void *getProcAddress(const char *name) const override; + + private: + PFNEGLGETPROCADDRESSPROC mGetProcAddressPtr; + static DynamicLib sNativeLib; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_GL_CROS_FUNCTIONSEGLDL_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/functionsegl_typedefs.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/functionsegl_typedefs.h new file mode 100644 index 00000000000..78f9009bf3d --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/functionsegl_typedefs.h @@ -0,0 +1,131 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// functionsegl_typedefs.h: Typedefs of EGL functions. + +#ifndef LIBANGLE_RENDERER_GL_EGL_FUNCTIONSEGLTYPEDEFS_H_ +#define LIBANGLE_RENDERER_GL_EGL_FUNCTIONSEGLTYPEDEFS_H_ + +#include <EGL/egl.h> + +namespace rx +{ +// EGL 1.0 +typedef EGLBoolean (*PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, + const EGLint *attrib_list, + EGLConfig *configs, + EGLint config_size, + EGLint *num_config); +typedef EGLBoolean (*PFNEGLCOPYBUFFERSPROC)(EGLDisplay dpy, + EGLSurface surface, + EGLNativePixmapType target); +typedef EGLContext (*PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, + EGLConfig config, + EGLContext share_context, + const EGLint *attrib_list); +typedef EGLSurface (*PFNEGLCREATEPBUFFERSURFACEPROC)(EGLDisplay dpy, + EGLConfig config, + const EGLint *attrib_list); +typedef EGLSurface (*PFNEGLCREATEPIXMAPSURFACEPROC)(EGLDisplay dpy, + EGLConfig config, + EGLNativePixmapType pixmap, + const EGLint *attrib_list); +typedef EGLSurface (*PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, + EGLConfig config, + EGLNativeWindowType win, + const EGLint *attrib_list); +typedef EGLBoolean (*PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx); +typedef EGLBoolean (*PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (*PFNEGLGETCONFIGATTRIBPROC)(EGLDisplay dpy, + EGLConfig config, + EGLint attribute, + EGLint *value); +typedef EGLBoolean (*PFNEGLGETCONFIGSPROC)(EGLDisplay dpy, + EGLConfig *configs, + EGLint config_size, + EGLint *num_config); +typedef EGLDisplay (*PFNEGLGETCURRENTDISPLAYPROC)(void); +typedef EGLSurface (*PFNEGLGETCURRENTSURFACEPROC)(EGLint readdraw); +typedef EGLDisplay (*PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id); +typedef EGLint (*PFNEGLGETERRORPROC)(void); +typedef __eglMustCastToProperFunctionPointerType (*PFNEGLGETPROCADDRESSPROC)(const char *procname); +typedef EGLBoolean (*PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint *major, EGLint *minor); +typedef EGLBoolean (*PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, + EGLSurface draw, + EGLSurface read, + EGLContext ctx); +typedef EGLBoolean (*PFNEGLQUERYCONTEXTPROC)(EGLDisplay dpy, + EGLContext ctx, + EGLint attribute, + EGLint *value); +typedef const char *(*PFNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name); +typedef EGLBoolean (*PFNEGLQUERYSURFACEPROC)(EGLDisplay dpy, + EGLSurface surface, + EGLint attribute, + EGLint *value); +typedef EGLBoolean (*PFNEGLSWAPBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (*PFNEGLTERMINATEPROC)(EGLDisplay dpy); +typedef EGLBoolean (*PFNEGLWAITGLPROC)(void); +typedef EGLBoolean (*PFNEGLWAITNATIVEPROC)(EGLint engine); + +// EGL 1.1 +typedef EGLBoolean (*PFNEGLBINDTEXIMAGEPROC)(EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (*PFNEGLRELEASETEXIMAGEPROC)(EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (*PFNEGLSURFACEATTRIBPROC)(EGLDisplay dpy, + EGLSurface surface, + EGLint attribute, + EGLint value); +typedef EGLBoolean (*PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval); + +// EGL 1.2 +typedef EGLBoolean (*PFNEGLBINDAPIPROC)(EGLenum api); +typedef EGLenum (*PFNEGLQUERYAPIPROC)(void); +typedef EGLSurface (*PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC)(EGLDisplay dpy, + EGLenum buftype, + EGLClientBuffer buffer, + EGLConfig config, + const EGLint *attrib_list); +typedef EGLBoolean (*PFNEGLRELEASETHREADPROC)(void); +typedef EGLBoolean (*PFNEGLWAITCLIENTPROC)(void); + +// EGL 1.3 + +// EGL 1.4 +typedef EGLContext (*PFNEGLGETCURRENTCONTEXTPROC)(void); + +// EGL 1.5 +typedef EGLSync (*PFNEGLCREATESYNCPROC)(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +typedef EGLBoolean (*PFNEGLDESTROYSYNCPROC)(EGLDisplay dpy, EGLSync sync); +typedef EGLint (*PFNEGLCLIENTWAITSYNCPROC)(EGLDisplay dpy, + EGLSync sync, + EGLint flags, + EGLTime timeout); +typedef EGLBoolean (*PFNEGLGETSYNCATTRIBPROC)(EGLDisplay dpy, + EGLSync sync, + EGLint attribute, + EGLAttrib *value); +typedef EGLImage (*PFNEGLCREATEIMAGEPROC)(EGLDisplay dpy, + EGLContext ctx, + EGLenum target, + EGLClientBuffer buffer, + const EGLAttrib *attrib_list); +typedef EGLBoolean (*PFNEGLDESTROYIMAGEPROC)(EGLDisplay dpy, EGLImage image); +typedef EGLDisplay (*PFNEGLGETPLATFORMDISPLAYPROC)(EGLenum platform, + void *native_display, + const EGLAttrib *attrib_list); +typedef EGLSurface (*PFNEGLCREATEPLATFORMWINDOWSURFACEPROC)(EGLDisplay dpy, + EGLConfig config, + void *native_window, + const EGLAttrib *attrib_list); +typedef EGLSurface (*PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC)(EGLDisplay dpy, + EGLConfig config, + void *native_pixmap, + const EGLAttrib *attrib_list); +typedef EGLBoolean (*PFNEGLWAITSYNCPROC)(EGLDisplay dpy, EGLSync sync, EGLint flags); + +} // namespace rx + +#endif // LIBANGLE_RENDERER_GL_EGL_FUNCTIONSEGLTYPEDEFS_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp new file mode 100644 index 00000000000..ca3936d7c45 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp @@ -0,0 +1,1008 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// DisplayOzone.cpp: Ozone implementation of egl::Display + +#include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h" + +#include <fcntl.h> +#include <poll.h> +#include <iostream> +#include <unistd.h> +#include <sys/time.h> + +#include <EGL/eglext.h> + +#include <gbm.h> +#include <drm_fourcc.h> + +#include "common/debug.h" +#include "libANGLE/Config.h" +#include "libANGLE/Display.h" +#include "libANGLE/Surface.h" +#include "libANGLE/renderer/gl/FramebufferGL.h" +#include "libANGLE/renderer/gl/RendererGL.h" +#include "libANGLE/renderer/gl/StateManagerGL.h" +#include "libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h" +#include "platform/Platform.h" + +// ARM-specific extension needed to make Mali GPU behave - not in any +// published header file. +#ifndef EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM +#define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A +#endif + +#ifndef EGL_NO_CONFIG_MESA +#define EGL_NO_CONFIG_MESA ((EGLConfig)0) +#endif + +namespace +{ + +EGLint UnsignedToSigned(uint32_t u) +{ + return *reinterpret_cast<const EGLint *>(&u); +} + +drmModeModeInfoPtr ChooseMode(drmModeConnectorPtr conn) +{ + drmModeModeInfoPtr mode = nullptr; + ASSERT(conn); + ASSERT(conn->connection == DRM_MODE_CONNECTED); + // use first preferred mode if any, else end up with last mode in list + for (int i = 0; i < conn->count_modes; ++i) + { + mode = conn->modes + i; + if (mode->type & DRM_MODE_TYPE_PREFERRED) + { + break; + } + } + return mode; +} + +int ChooseCRTC(int fd, drmModeConnectorPtr conn) +{ + for (int i = 0; i < conn->count_encoders; ++i) + { + drmModeEncoderPtr enc = drmModeGetEncoder(fd, conn->encoders[i]); + unsigned long crtcs = enc->possible_crtcs; + drmModeFreeEncoder(enc); + if (crtcs) + { + return __builtin_ctzl(crtcs); + } + } + return -1; +} +} // namespace + +namespace rx +{ + +// TODO(fjhenigman) Implement swap control. Until then this is unused. +SwapControlData::SwapControlData() + : targetSwapInterval(0), maxSwapInterval(-1), currentSwapInterval(-1) +{ +} + +DisplayOzone::Buffer::Buffer(DisplayOzone *display, + uint32_t useFlags, + uint32_t gbmFormat, + uint32_t drmFormat, + uint32_t drmFormatFB, + int depthBits, + int stencilBits) + : mDisplay(display), + mNative(nullptr), + mWidth(0), + mHeight(0), + mDepthBits(depthBits), + mStencilBits(stencilBits), + mUseFlags(useFlags), + mGBMFormat(gbmFormat), + mDRMFormat(drmFormat), + mDRMFormatFB(drmFormatFB), + mBO(nullptr), + mDMABuf(-1), + mHasDRMFB(false), + mDRMFB(0), + mImage(EGL_NO_IMAGE_KHR), + mColorBuffer(0), + mDSBuffer(0), + mGLFB(0), + mTexture(0) +{ +} + +DisplayOzone::Buffer::~Buffer() +{ + mDisplay->mFunctionsGL->deleteFramebuffers(1, &mGLFB); + reset(); +} + +void DisplayOzone::Buffer::reset() +{ + if (mHasDRMFB) + { + int fd = gbm_device_get_fd(mDisplay->mGBM); + drmModeRmFB(fd, mDRMFB); + mHasDRMFB = false; + } + + FunctionsGL *gl = mDisplay->mFunctionsGL; + gl->deleteRenderbuffers(1, &mColorBuffer); + mColorBuffer = 0; + gl->deleteRenderbuffers(1, &mDSBuffer); + mDSBuffer = 0; + + // Here we might destroy the GL framebuffer (mGLFB) but unlike every other resource in Buffer, + // it does not get destroyed (and recreated) because when it is the default framebuffer for + // an ANGLE surface then ANGLE expects it to have the same lifetime as that surface. + + if (mImage != EGL_NO_IMAGE_KHR) + { + mDisplay->mEGL->destroyImageKHR(mImage); + mImage = EGL_NO_IMAGE_KHR; + } + + if (mTexture) + { + gl->deleteTextures(1, &mTexture); + mTexture = 0; + } + + if (mDMABuf >= 0) + { + close(mDMABuf); + mDMABuf = -1; + } + + if (mBO) + { + gbm_bo_destroy(mBO); + mBO = nullptr; + } +} + +bool DisplayOzone::Buffer::resize(int32_t width, int32_t height) +{ + if (mWidth == width && mHeight == height) + { + return true; + } + + reset(); + + if (width <= 0 || height <= 0) + { + return true; + } + + mBO = gbm_bo_create(mDisplay->mGBM, width, height, mGBMFormat, mUseFlags); + if (!mBO) + { + return false; + } + + mDMABuf = gbm_bo_get_fd(mBO); + if (mDMABuf < 0) + { + return false; + } + + // clang-format off + const EGLint attr[] = + { + EGL_WIDTH, width, + EGL_HEIGHT, height, + EGL_LINUX_DRM_FOURCC_EXT, UnsignedToSigned(mDRMFormat), + EGL_DMA_BUF_PLANE0_FD_EXT, mDMABuf, + EGL_DMA_BUF_PLANE0_PITCH_EXT, UnsignedToSigned(gbm_bo_get_stride(mBO)), + EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, + EGL_NONE, + }; + // clang-format on + + mImage = mDisplay->mEGL->createImageKHR(EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, attr); + if (mImage == EGL_NO_IMAGE_KHR) + { + return false; + } + + FunctionsGL *gl = mDisplay->mFunctionsGL; + StateManagerGL *sm = mDisplay->getRenderer()->getStateManager(); + + gl->genRenderbuffers(1, &mColorBuffer); + sm->bindRenderbuffer(GL_RENDERBUFFER, mColorBuffer); + gl->eglImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, mImage); + + sm->bindFramebuffer(GL_FRAMEBUFFER, mGLFB); + gl->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER, + mColorBuffer); + + if (mDepthBits || mStencilBits) + { + gl->genRenderbuffers(1, &mDSBuffer); + sm->bindRenderbuffer(GL_RENDERBUFFER, mDSBuffer); + gl->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); + } + + if (mDepthBits) + { + gl->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, + mDSBuffer); + } + + if (mStencilBits) + { + gl->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, + mDSBuffer); + } + + mWidth = width; + mHeight = height; + return true; +} + +bool DisplayOzone::Buffer::initialize(const NativeWindow *native) +{ + mNative = native; + mDisplay->mFunctionsGL->genFramebuffers(1, &mGLFB); + return resize(native->width, native->height); +} + +bool DisplayOzone::Buffer::initialize(int width, int height) +{ + mDisplay->mFunctionsGL->genFramebuffers(1, &mGLFB); + return resize(width, height); +} + +void DisplayOzone::Buffer::bindTexImage() +{ + mDisplay->mFunctionsGL->eglImageTargetTexture2DOES(GL_TEXTURE_2D, mImage); +} + +GLuint DisplayOzone::Buffer::getTexture() +{ + // TODO(fjhenigman) Try not to create a new texture every time. That already works on Intel + // and should work on Mali with proper fences. + FunctionsGL *gl = mDisplay->mFunctionsGL; + StateManagerGL *sm = mDisplay->getRenderer()->getStateManager(); + + gl->genTextures(1, &mTexture); + sm->bindTexture(GL_TEXTURE_2D, mTexture); + gl->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + ASSERT(mImage != EGL_NO_IMAGE_KHR); + gl->eglImageTargetTexture2DOES(GL_TEXTURE_2D, mImage); + return mTexture; +} + +uint32_t DisplayOzone::Buffer::getDRMFB() +{ + if (!mHasDRMFB) + { + int fd = gbm_device_get_fd(mDisplay->mGBM); + uint32_t handles[4] = {gbm_bo_get_handle(mBO).u32}; + uint32_t pitches[4] = {gbm_bo_get_stride(mBO)}; + uint32_t offsets[4] = {0}; + if (drmModeAddFB2(fd, mWidth, mHeight, mDRMFormatFB, handles, pitches, offsets, &mDRMFB, 0)) + { + std::cerr << "drmModeAddFB2 failed" << std::endl; + } + else + { + mHasDRMFB = true; + } + } + + return mDRMFB; +} + +FramebufferGL *DisplayOzone::Buffer::framebufferGL(const gl::FramebufferState &state) +{ + return new FramebufferGL(mGLFB, state, mDisplay->mFunctionsGL, + mDisplay->getRenderer()->getWorkarounds(), + mDisplay->getRenderer()->getStateManager()); +} + +void DisplayOzone::Buffer::present() +{ + if (mNative) + { + if (mNative->visible) + { + mDisplay->drawBuffer(this); + } + resize(mNative->width, mNative->height); + } +} + +DisplayOzone::DisplayOzone() + : mContextConfig(nullptr), + mContext(nullptr), + mSwapControl(SwapControl::ABSENT), + mMinSwapInterval(0), + mMaxSwapInterval(0), + mCurrentSwapInterval(-1), + mEGL(nullptr), + mFunctionsGL(nullptr), + mGBM(nullptr), + mConnector(nullptr), + mMode(nullptr), + mCRTC(nullptr), + mSetCRTC(true), + mWidth(0), + mHeight(0), + mScanning(nullptr), + mPending(nullptr), + mDrawing(nullptr), + mUnused(nullptr), + mProgram(0), + mVertexShader(0), + mFragmentShader(0), + mVertexBuffer(0), + mIndexBuffer(0), + mCenterUniform(0), + mWindowSizeUniform(0), + mBorderSizeUniform(0), + mDepthUniform(0) +{ +} + +DisplayOzone::~DisplayOzone() +{ +} + +egl::Error DisplayOzone::initialize(egl::Display *display) +{ + int fd; + char deviceName[30]; + drmModeResPtr resources = nullptr; + + for (int i = 0; i < 9; ++i) + { + snprintf(deviceName, sizeof(deviceName), "/dev/dri/card%d", i); + fd = open(deviceName, O_RDWR | O_CLOEXEC); + if (fd >= 0) + { + resources = drmModeGetResources(fd); + if (resources) + { + if (resources->count_connectors > 0) + { + break; + } + drmModeFreeResources(resources); + resources = nullptr; + } + close(fd); + } + } + if (!resources) + { + return egl::Error(EGL_NOT_INITIALIZED, "Could not open drm device."); + } + + mGBM = gbm_create_device(fd); + if (!mGBM) + { + close(fd); + drmModeFreeResources(resources); + return egl::Error(EGL_NOT_INITIALIZED, "Could not create gbm device."); + } + + mConnector = nullptr; + bool monitorConnected = false; + for (int i = 0; !mCRTC && i < resources->count_connectors; ++i) + { + drmModeFreeConnector(mConnector); + mConnector = drmModeGetConnector(fd, resources->connectors[i]); + if (!mConnector || mConnector->connection != DRM_MODE_CONNECTED) + { + continue; + } + monitorConnected = true; + mMode = ChooseMode(mConnector); + if (!mMode) + { + continue; + } + int n = ChooseCRTC(fd, mConnector); + if (n < 0) + { + continue; + } + mCRTC = drmModeGetCrtc(fd, resources->crtcs[n]); + } + drmModeFreeResources(resources); + + if (mCRTC) + { + mWidth = mMode->hdisplay; + mHeight = mMode->vdisplay; + } + else if (!monitorConnected) + { + // Even though there is no monitor to show it, we still do + // everything the same as if there were one, so we need an + // arbitrary size for our buffers. + mWidth = 1280; + mHeight = 1024; + } + else + { + return egl::Error(EGL_NOT_INITIALIZED, "Failed to choose mode/crtc."); + } + + // ANGLE builds its executables with an RPATH so they pull in ANGLE's libGL and libEGL. + // Here we need to open the native libEGL. An absolute path would work, but then we + // couldn't use LD_LIBRARY_PATH which is often useful during development. Instead we take + // advantage of the fact that the system lib is available under multiple names (for example + // with a .1 suffix) while Angle only installs libEGL.so. + mEGL = new FunctionsEGLDL(); + egl::Error result = mEGL->initialize(display->getNativeDisplayId(), "libEGL.so.1"); + if (result.isError()) + { + return result; + } + + const char *necessaryExtensions[] = { + "EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context", + }; + for (auto &ext : necessaryExtensions) + { + if (!mEGL->hasExtension(ext)) + { + return egl::Error(EGL_NOT_INITIALIZED, "need %s", ext); + } + } + + if (mEGL->hasExtension("EGL_MESA_configless_context")) + { + mContextConfig = EGL_NO_CONFIG_MESA; + } + else + { + // clang-format off + const EGLint attrib[] = + { + // We want RGBA8 and DEPTH24_STENCIL8 + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 24, + EGL_STENCIL_SIZE, 8, + EGL_NONE, + }; + // clang-format on + EGLint numConfig; + EGLConfig config[1]; + if (!mEGL->chooseConfig(attrib, config, 1, &numConfig) || numConfig < 1) + { + return egl::Error(EGL_NOT_INITIALIZED, "Could not get EGL config."); + } + mContextConfig = config[0]; + } + + mContext = initializeContext(mContextConfig, display->getAttributeMap()); + if (mContext == EGL_NO_CONTEXT) + { + return egl::Error(EGL_NOT_INITIALIZED, "Could not create GLES context."); + } + + if (!mEGL->makeCurrent(EGL_NO_SURFACE, mContext)) + { + return egl::Error(EGL_NOT_INITIALIZED, "Could not make context current."); + } + + mFunctionsGL = mEGL->makeFunctionsGL(); + mFunctionsGL->initialize(); + + return DisplayGL::initialize(display); +} + +void DisplayOzone::pageFlipHandler(int fd, + unsigned int sequence, + unsigned int tv_sec, + unsigned int tv_usec, + void *data) +{ + DisplayOzone *display = reinterpret_cast<DisplayOzone *>(data); + uint64_t tv = tv_sec; + display->pageFlipHandler(sequence, tv * 1000000 + tv_usec); +} + +void DisplayOzone::pageFlipHandler(unsigned int sequence, uint64_t tv) +{ + ASSERT(mPending); + mUnused = mScanning; + mScanning = mPending; + mPending = nullptr; +} + +void DisplayOzone::presentScreen() +{ + if (!mCRTC) + { + // no monitor + return; + } + + // see if pending flip has finished, without blocking + int fd = gbm_device_get_fd(mGBM); + if (mPending) + { + pollfd pfd; + pfd.fd = fd; + pfd.events = POLLIN; + if (poll(&pfd, 1, 0) < 0) + { + std::cerr << "poll failed: " << errno << " " << strerror(errno) << std::endl; + } + if (pfd.revents & POLLIN) + { + drmEventContext event; + event.version = DRM_EVENT_CONTEXT_VERSION; + event.page_flip_handler = pageFlipHandler; + drmHandleEvent(fd, &event); + } + } + + // if pending flip has finished, schedule next one + if (!mPending && mDrawing) + { + flushGL(); + if (mSetCRTC) + { + if (drmModeSetCrtc(fd, mCRTC->crtc_id, mDrawing->getDRMFB(), 0, 0, + &mConnector->connector_id, 1, mMode)) + { + std::cerr << "set crtc failed: " << errno << " " << strerror(errno) << std::endl; + } + mSetCRTC = false; + } + if (drmModePageFlip(fd, mCRTC->crtc_id, mDrawing->getDRMFB(), DRM_MODE_PAGE_FLIP_EVENT, + this)) + { + std::cerr << "page flip failed: " << errno << " " << strerror(errno) << std::endl; + } + mPending = mDrawing; + mDrawing = nullptr; + } +} + +GLuint DisplayOzone::makeShader(GLuint type, const char *src) +{ + FunctionsGL *gl = mFunctionsGL; + GLuint shader = gl->createShader(type); + gl->shaderSource(shader, 1, &src, nullptr); + gl->compileShader(shader); + + GLchar buf[999]; + GLsizei len; + GLint compiled; + gl->getShaderInfoLog(shader, sizeof(buf), &len, buf); + gl->getShaderiv(shader, GL_COMPILE_STATUS, &compiled); + if (compiled != GL_TRUE) + { + ANGLEPlatformCurrent()->logError("DisplayOzone shader compilation error:"); + ANGLEPlatformCurrent()->logError(buf); + } + + return shader; +} + +void DisplayOzone::drawWithTexture(Buffer *buffer) +{ + FunctionsGL *gl = mFunctionsGL; + StateManagerGL *sm = getRenderer()->getStateManager(); + + if (!mProgram) + { + const GLchar *vertexSource = + "#version 100\n" + "attribute vec3 vertex;\n" + "uniform vec2 center;\n" + "uniform vec2 windowSize;\n" + "uniform vec2 borderSize;\n" + "uniform float depth;\n" + "varying vec3 texCoord;\n" + "void main()\n" + "{\n" + " vec2 pos = vertex.xy * (windowSize + borderSize * vertex.z);\n" + " gl_Position = vec4(center + pos, depth, 1);\n" + " texCoord = vec3(pos / windowSize * vec2(.5, -.5) + vec2(.5, .5), vertex.z);\n" + "}\n"; + + const GLchar *fragmentSource = + "#version 100\n" + "precision mediump float;\n" + "uniform sampler2D tex;\n" + "varying vec3 texCoord;\n" + "void main()\n" + "{\n" + " if (texCoord.z > 0.)\n" + " {\n" + " float c = abs((texCoord.z * 2.) - 1.);\n" + " gl_FragColor = vec4(c, c, c, 1);\n" + " }\n" + " else\n" + " {\n" + " gl_FragColor = texture2D(tex, texCoord.xy);\n" + " }\n" + "}\n"; + + mVertexShader = makeShader(GL_VERTEX_SHADER, vertexSource); + mFragmentShader = makeShader(GL_FRAGMENT_SHADER, fragmentSource); + mProgram = gl->createProgram(); + gl->attachShader(mProgram, mVertexShader); + gl->attachShader(mProgram, mFragmentShader); + gl->bindAttribLocation(mProgram, 0, "vertex"); + gl->linkProgram(mProgram); + GLint linked; + gl->getProgramiv(mProgram, GL_LINK_STATUS, &linked); + ASSERT(linked); + mCenterUniform = gl->getUniformLocation(mProgram, "center"); + mWindowSizeUniform = gl->getUniformLocation(mProgram, "windowSize"); + mBorderSizeUniform = gl->getUniformLocation(mProgram, "borderSize"); + mDepthUniform = gl->getUniformLocation(mProgram, "depth"); + GLint texUniform = gl->getUniformLocation(mProgram, "tex"); + sm->useProgram(mProgram); + gl->uniform1i(texUniform, 0); + + // clang-format off + const GLfloat vertices[] = + { + // window corners, and window border inside corners + 1, -1, 0, + -1, -1, 0, + 1, 1, 0, + -1, 1, 0, + // window border outside corners + 1, -1, 1, + -1, -1, 1, + 1, 1, 1, + -1, 1, 1, + }; + // clang-format on + gl->genBuffers(1, &mVertexBuffer); + sm->bindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); + gl->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + + // window border triangle strip + const GLuint borderStrip[] = {5, 0, 4, 2, 6, 3, 7, 1, 5, 0}; + + gl->genBuffers(1, &mIndexBuffer); + sm->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); + gl->bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(borderStrip), borderStrip, GL_STATIC_DRAW); + } + else + { + sm->useProgram(mProgram); + sm->bindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); + sm->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); + } + + // convert from pixels to "-1 to 1" space + const NativeWindow *n = buffer->getNative(); + double x = n->x * 2. / mWidth - 1; + double y = n->y * 2. / mHeight - 1; + double halfw = n->width * 1. / mWidth; + double halfh = n->height * 1. / mHeight; + double borderw = n->borderWidth * 2. / mWidth; + double borderh = n->borderHeight * 2. / mHeight; + + gl->uniform2f(mCenterUniform, x + halfw, y + halfh); + gl->uniform2f(mWindowSizeUniform, halfw, halfh); + gl->uniform2f(mBorderSizeUniform, borderw, borderh); + gl->uniform1f(mDepthUniform, n->depth / 1e6); + + sm->setBlendEnabled(false); + sm->setCullFaceEnabled(false); + sm->setStencilTestEnabled(false); + sm->setScissorTestEnabled(false); + sm->setDepthTestEnabled(true); + sm->setColorMask(true, true, true, true); + sm->setDepthMask(true); + sm->setDepthRange(0, 1); + sm->setDepthFunc(GL_LESS); + sm->setViewport(gl::Rectangle(0, 0, mWidth, mHeight)); + sm->activeTexture(0); + GLuint tex = buffer->getTexture(); + sm->bindTexture(GL_TEXTURE_2D, tex); + gl->vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); + gl->enableVertexAttribArray(0); + sm->bindFramebuffer(GL_DRAW_FRAMEBUFFER, mDrawing->getGLFB()); + gl->drawArrays(GL_TRIANGLE_STRIP, 0, 4); + gl->drawElements(GL_TRIANGLE_STRIP, 10, GL_UNSIGNED_INT, 0); + sm->deleteTexture(tex); +} + +void DisplayOzone::drawBuffer(Buffer *buffer) +{ + if (!mDrawing) + { + // get buffer on which to draw window + if (mUnused) + { + mDrawing = mUnused; + mUnused = nullptr; + } + else + { + mDrawing = new Buffer(this, GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT, + GBM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888, + true, true); // XXX shouldn't need stencil + if (!mDrawing || !mDrawing->initialize(mWidth, mHeight)) + { + return; + } + } + + StateManagerGL *sm = getRenderer()->getStateManager(); + sm->bindFramebuffer(GL_DRAW_FRAMEBUFFER, mDrawing->getGLFB()); + sm->setClearColor(gl::ColorF(0, 0, 0, 1)); + sm->setClearDepth(1); + sm->setScissorTestEnabled(false); + sm->setColorMask(true, true, true, true); + sm->setDepthMask(true); + mFunctionsGL->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + + drawWithTexture(buffer); + presentScreen(); +} + +void DisplayOzone::flushGL() +{ + mFunctionsGL->flush(); + if (mEGL->hasExtension("EGL_KHR_fence_sync")) + { + const EGLint attrib[] = {EGL_SYNC_CONDITION_KHR, + EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM, EGL_NONE}; + EGLSyncKHR fence = mEGL->createSyncKHR(EGL_SYNC_FENCE_KHR, attrib); + if (fence) + { + // TODO(fjhenigman) Figure out the right way to use fences on Mali GPU + // to maximize throughput and avoid hangs when a program is interrupted. + // This busy wait was an attempt to reduce hangs when interrupted by SIGINT, + // but we still get some. + for (;;) + { + EGLint r = mEGL->clientWaitSyncKHR(fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 0); + if (r != EGL_TIMEOUT_EXPIRED_KHR) + { + break; + } + usleep(99); + } + mEGL->destroySyncKHR(fence); + return; + } + } +} + +void DisplayOzone::terminate() +{ + SafeDelete(mScanning); + SafeDelete(mPending); + SafeDelete(mDrawing); + SafeDelete(mUnused); + + if (mProgram) + { + mFunctionsGL->deleteProgram(mProgram); + mFunctionsGL->deleteShader(mVertexShader); + mFunctionsGL->deleteShader(mFragmentShader); + mFunctionsGL->deleteBuffers(1, &mVertexBuffer); + mFunctionsGL->deleteBuffers(1, &mIndexBuffer); + mProgram = 0; + } + + DisplayGL::terminate(); + + if (mContext) + { + // Mesa might crash if you terminate EGL with a context current + // then re-initialize EGL, so make our context not current. + mEGL->makeCurrent(EGL_NO_SURFACE, EGL_NO_CONTEXT); + mEGL->destroyContext(mContext); + mContext = nullptr; + } + + SafeDelete(mFunctionsGL); + + mEGL->terminate(); + SafeDelete(mEGL); + + drmModeFreeCrtc(mCRTC); + + int fd = gbm_device_get_fd(mGBM); + gbm_device_destroy(mGBM); + close(fd); +} + +SurfaceImpl *DisplayOzone::createWindowSurface(const egl::Config *configuration, + EGLNativeWindowType window, + const egl::AttributeMap &attribs) +{ + Buffer *buffer = new Buffer(this, GBM_BO_USE_RENDERING, GBM_FORMAT_ARGB8888, + DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888, true, true); + if (!buffer || !buffer->initialize(reinterpret_cast<const NativeWindow *>(window))) + { + return nullptr; + } + return new SurfaceOzone(getRenderer(), buffer); +} + +SurfaceImpl *DisplayOzone::createPbufferSurface(const egl::Config *configuration, + const egl::AttributeMap &attribs) +{ + EGLAttrib width = attribs.get(EGL_WIDTH, 0); + EGLAttrib height = attribs.get(EGL_HEIGHT, 0); + Buffer *buffer = new Buffer(this, GBM_BO_USE_RENDERING, GBM_FORMAT_ARGB8888, + DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888, true, true); + if (!buffer || !buffer->initialize(width, height)) + { + return nullptr; + } + return new SurfaceOzone(getRenderer(), buffer); +} + +SurfaceImpl *DisplayOzone::createPbufferFromClientBuffer(const egl::Config *configuration, + EGLClientBuffer shareHandle, + const egl::AttributeMap &attribs) +{ + UNIMPLEMENTED(); + return nullptr; +} + +SurfaceImpl *DisplayOzone::createPixmapSurface(const egl::Config *configuration, + NativePixmapType nativePixmap, + const egl::AttributeMap &attribs) +{ + UNIMPLEMENTED(); + return nullptr; +} + +egl::Error DisplayOzone::getDevice(DeviceImpl **device) +{ + UNIMPLEMENTED(); + return egl::Error(EGL_BAD_DISPLAY); +} + +EGLContext DisplayOzone::initializeContext(EGLConfig config, const egl::AttributeMap &eglAttributes) +{ + if (!(mEGL->majorVersion > 1 || mEGL->minorVersion > 4 || + mEGL->hasExtension("EGL_KHR_create_context"))) + { + const EGLint attrib[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + return mEGL->createContext(config, EGL_NO_CONTEXT, attrib); + } + + std::vector<gl::Version> versions; + + EGLint major = eglAttributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE); + EGLint minor = eglAttributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE); + if (major != EGL_DONT_CARE && minor != EGL_DONT_CARE) + { + // If specific version requested, only try that one. + versions.push_back(gl::Version(major, minor)); + } + else + { + // Acceptable versions, from most to least preferred. + versions.push_back(gl::Version(3, 0)); + versions.push_back(gl::Version(2, 0)); + } + + for (auto &version : versions) + { + const EGLint attrib[] = {EGL_CONTEXT_MAJOR_VERSION_KHR, UnsignedToSigned(version.major), + EGL_CONTEXT_MINOR_VERSION_KHR, UnsignedToSigned(version.minor), + EGL_NONE}; + auto context = mEGL->createContext(config, EGL_NO_CONTEXT, attrib); + if (context != EGL_NO_CONTEXT) + { + return context; + } + } + + return EGL_NO_CONTEXT; +} + +egl::ConfigSet DisplayOzone::generateConfigs() const +{ + egl::ConfigSet configs; + + egl::Config config; + config.redSize = 8; + config.greenSize = 8; + config.blueSize = 8; + config.alphaSize = 8; + config.depthSize = 24; + config.stencilSize = 8; + config.bindToTextureRGBA = EGL_TRUE; + config.renderableType = EGL_OPENGL_ES2_BIT; + config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; + + configs.add(config); + return configs; +} + +bool DisplayOzone::isDeviceLost() const +{ + return false; +} + +bool DisplayOzone::testDeviceLost() +{ + return false; +} + +egl::Error DisplayOzone::restoreLostDevice() +{ + UNIMPLEMENTED(); + return egl::Error(EGL_BAD_DISPLAY); +} + +bool DisplayOzone::isValidNativeWindow(EGLNativeWindowType window) const +{ + return true; +} + +std::string DisplayOzone::getVendorString() const +{ + return ""; +} + +egl::Error DisplayOzone::getDriverVersion(std::string *version) const +{ + *version = ""; + return egl::Error(EGL_SUCCESS); +} + +egl::Error DisplayOzone::waitClient() const +{ + // TODO(fjhenigman) Implement this. + return egl::Error(EGL_SUCCESS); +} + +egl::Error DisplayOzone::waitNative(EGLint engine, + egl::Surface *drawSurface, + egl::Surface *readSurface) const +{ + // TODO(fjhenigman) Implement this. + return egl::Error(EGL_SUCCESS); +} + +void DisplayOzone::setSwapInterval(EGLSurface drawable, SwapControlData *data) +{ + ASSERT(data != nullptr); +} + +const FunctionsGL *DisplayOzone::getFunctionsGL() const +{ + return mFunctionsGL; +} + +void DisplayOzone::generateExtensions(egl::DisplayExtensions *outExtensions) const +{ + outExtensions->createContext = true; + outExtensions->createContextNoError = true; +} + +void DisplayOzone::generateCaps(egl::Caps *outCaps) const +{ + outCaps->textureNPOT = true; +} + +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h new file mode 100644 index 00000000000..8f179668d9f --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h @@ -0,0 +1,218 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// DisplayOzone.h: Ozone implementation of egl::Display + +#ifndef LIBANGLE_RENDERER_GL_EGL_OZONE_DISPLAYOZONE_H_ +#define LIBANGLE_RENDERER_GL_EGL_OZONE_DISPLAYOZONE_H_ + +#include <xf86drm.h> +#include <xf86drmMode.h> + +#include <string> + +#include "libANGLE/renderer/gl/DisplayGL.h" +#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h" + +struct gbm_device; +struct gbm_bo; + +namespace rx +{ + +class FramebufferGL; + +// TODO(fjhenigman) Implement swap control. The following struct will be used for that. +// State-tracking data for the swap control to allow DisplayOzone to remember per +// drawable information for swap control. +struct SwapControlData final +{ + SwapControlData(); + + // Set by the drawable + int targetSwapInterval; + + // DisplayOzone-side state-tracking + int maxSwapInterval; + int currentSwapInterval; +}; + +class DisplayOzone final : public DisplayGL +{ + public: + struct NativeWindow + { + int32_t x; + int32_t y; + int32_t width; + int32_t height; + int32_t borderWidth; + int32_t borderHeight; + int32_t visible; + int32_t depth; + }; + + class Buffer final : angle::NonCopyable + { + public: + Buffer(DisplayOzone *display, + uint32_t useFlags, + uint32_t gbmFormat, + uint32_t drmFormat, + uint32_t drmFormatFB, + int depthBits, + int stencilBits); + + ~Buffer(); + bool initialize(const NativeWindow *window); + bool initialize(int32_t width, int32_t height); + void reset(); + bool resize(int32_t width, int32_t height); + FramebufferGL *framebufferGL(const gl::FramebufferState &state); + void present(); + uint32_t getDRMFB(); + void bindTexImage(); + GLuint getTexture(); + int32_t getWidth() const { return mWidth; } + int32_t getHeight() const { return mHeight; } + GLuint getGLFB() const { return mGLFB; } + const NativeWindow *getNative() const { return mNative; } + + private: + DisplayOzone *mDisplay; + const NativeWindow *mNative; + int mWidth; + int mHeight; + const int mDepthBits; + const int mStencilBits; + const uint32_t mUseFlags; + const uint32_t mGBMFormat; + const uint32_t mDRMFormat; + const uint32_t mDRMFormatFB; + gbm_bo *mBO; + int mDMABuf; + bool mHasDRMFB; + uint32_t mDRMFB; + EGLImageKHR mImage; + GLuint mColorBuffer; + GLuint mDSBuffer; + GLuint mGLFB; + GLuint mTexture; + }; + + DisplayOzone(); + ~DisplayOzone() override; + + egl::Error initialize(egl::Display *display) override; + void terminate() override; + + SurfaceImpl *createWindowSurface(const egl::Config *configuration, + EGLNativeWindowType window, + const egl::AttributeMap &attribs) override; + SurfaceImpl *createPbufferSurface(const egl::Config *configuration, + const egl::AttributeMap &attribs) override; + SurfaceImpl *createPbufferFromClientBuffer(const egl::Config *configuration, + EGLClientBuffer shareHandle, + const egl::AttributeMap &attribs) override; + SurfaceImpl *createPixmapSurface(const egl::Config *configuration, + NativePixmapType nativePixmap, + const egl::AttributeMap &attribs) override; + + egl::ConfigSet generateConfigs() const override; + + bool isDeviceLost() const override; + bool testDeviceLost() override; + egl::Error restoreLostDevice() override; + + bool isValidNativeWindow(EGLNativeWindowType window) const override; + + egl::Error getDevice(DeviceImpl **device) override; + + std::string getVendorString() const override; + + egl::Error waitClient() const override; + egl::Error waitNative(EGLint engine, + egl::Surface *drawSurface, + egl::Surface *readSurface) const override; + + // TODO(fjhenigman) Implement this. + // Swap interval can be set globally or per drawable. + // This function will make sure the drawable's swap interval is the + // one required so that the subsequent swapBuffers acts as expected. + void setSwapInterval(EGLSurface drawable, SwapControlData *data); + + egl::Error getDriverVersion(std::string *version) const override; + + private: + const FunctionsGL *getFunctionsGL() const override; + + EGLContext initializeContext(EGLConfig config, const egl::AttributeMap &eglAttributes); + + void generateExtensions(egl::DisplayExtensions *outExtensions) const override; + void generateCaps(egl::Caps *outCaps) const override; + + GLuint makeShader(GLuint type, const char *src); + void drawBuffer(Buffer *buffer); + void drawWithBlit(Buffer *buffer); + void drawWithTexture(Buffer *buffer); + void flushGL(); + void presentScreen(); + static void pageFlipHandler(int fd, + unsigned int sequence, + unsigned int tv_sec, + unsigned int tv_usec, + void *data); + void pageFlipHandler(unsigned int sequence, uint64_t tv); + + EGLConfig mContextConfig; + EGLContext mContext; + + // TODO(fjhenigman) Implement swap control. The following stuff will be used for that. + enum class SwapControl + { + ABSENT, + EXT, + MESA, + SGI, + }; + SwapControl mSwapControl; + int mMinSwapInterval; + int mMaxSwapInterval; + int mCurrentSwapInterval; + + FunctionsEGLDL *mEGL; + FunctionsGL *mFunctionsGL; + + gbm_device *mGBM; + drmModeConnectorPtr mConnector; + drmModeModeInfoPtr mMode; + drmModeCrtcPtr mCRTC; + bool mSetCRTC; + + int32_t mWidth; + int32_t mHeight; + + // Three scanout buffers cycle through four states. The state of a buffer + // is indicated by which of these pointers points to it. + // TODO(fjhenigman) It might be simpler/clearer to use a ring buffer. + Buffer *mScanning; + Buffer *mPending; + Buffer *mDrawing; + Buffer *mUnused; + + GLuint mProgram; + GLuint mVertexShader; + GLuint mFragmentShader; + GLuint mVertexBuffer; + GLuint mIndexBuffer; + GLint mCenterUniform; + GLint mWindowSizeUniform; + GLint mBorderSizeUniform; + GLint mDepthUniform; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_GL_EGL_OZONE_DISPLAYOZONE_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/SurfaceOzone.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/SurfaceOzone.cpp new file mode 100644 index 00000000000..5421e9cad74 --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/SurfaceOzone.cpp @@ -0,0 +1,96 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// SurfaceOzone.cpp: Ozone implementation of egl::SurfaceGL + +#include "libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h" + +#include "libANGLE/renderer/gl/FramebufferGL.h" +#include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h" + +namespace rx +{ + +SurfaceOzone::SurfaceOzone(RendererGL *renderer, DisplayOzone::Buffer *buffer) + : SurfaceGL(renderer), mBuffer(buffer) +{ +} + +SurfaceOzone::~SurfaceOzone() +{ + delete mBuffer; +} + +egl::Error SurfaceOzone::initialize() +{ + return egl::Error(EGL_SUCCESS); +} + +FramebufferImpl *SurfaceOzone::createDefaultFramebuffer(const gl::FramebufferState &state) +{ + return mBuffer->framebufferGL(state); +} + +egl::Error SurfaceOzone::makeCurrent() +{ + return egl::Error(EGL_SUCCESS); +} + +egl::Error SurfaceOzone::swap() +{ + mBuffer->present(); + return egl::Error(EGL_SUCCESS); +} + +egl::Error SurfaceOzone::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) +{ + UNIMPLEMENTED(); + return egl::Error(EGL_SUCCESS); +} + +egl::Error SurfaceOzone::querySurfacePointerANGLE(EGLint attribute, void **value) +{ + UNIMPLEMENTED(); + return egl::Error(EGL_SUCCESS); +} + +egl::Error SurfaceOzone::bindTexImage(gl::Texture *texture, EGLint buffer) +{ + mBuffer->bindTexImage(); + return egl::Error(EGL_SUCCESS); +} + +egl::Error SurfaceOzone::releaseTexImage(EGLint buffer) +{ + return egl::Error(EGL_SUCCESS); +} + +void SurfaceOzone::setSwapInterval(EGLint interval) +{ + mSwapControl.targetSwapInterval = interval; +} + +EGLint SurfaceOzone::getWidth() const +{ + return mBuffer->getWidth(); +} + +EGLint SurfaceOzone::getHeight() const +{ + return mBuffer->getHeight(); +} + +EGLint SurfaceOzone::isPostSubBufferSupported() const +{ + UNIMPLEMENTED(); + return EGL_FALSE; +} + +EGLint SurfaceOzone::getSwapBehavior() const +{ + return EGL_BUFFER_PRESERVED; +} +} // namespace rx diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h new file mode 100644 index 00000000000..9ad1169db2b --- /dev/null +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h @@ -0,0 +1,50 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// SurfaceOzone.h: Ozone implementation of egl::SurfaceGL + +#ifndef LIBANGLE_RENDERER_GL_EGL_OZONE_SURFACEOZONE_H_ +#define LIBANGLE_RENDERER_GL_EGL_OZONE_SURFACEOZONE_H_ + +#include "libANGLE/renderer/gl/SurfaceGL.h" +#include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h" + +namespace rx +{ + +class SurfaceOzone : public SurfaceGL +{ + public: + SurfaceOzone(RendererGL *renderer, DisplayOzone::Buffer *buffer); + ~SurfaceOzone() override; + + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; + + egl::Error initialize() override; + egl::Error makeCurrent() override; + + egl::Error swap() override; + egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override; + egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override; + egl::Error bindTexImage(gl::Texture *texture, EGLint buffer) override; + egl::Error releaseTexImage(EGLint buffer) override; + void setSwapInterval(EGLint interval) override; + + EGLint getWidth() const override; + EGLint getHeight() const override; + + EGLint isPostSubBufferSupported() const override; + EGLint getSwapBehavior() const override; + + private: + DisplayOzone::Buffer *mBuffer; + + // TODO(fjhenigman) Implement swap control. This will be used for that. + SwapControlData mSwapControl; +}; +} // namespace rx + +#endif // LIBANGLE_RENDERER_GL_EGL_OZONE_SURFACEOZONE_H_ diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/functionsgl_typedefs.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/functionsgl_typedefs.h index 50888e61e01..daf7ff74ea6 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/functionsgl_typedefs.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/functionsgl_typedefs.h @@ -627,6 +627,9 @@ typedef void (INTERNAL_GL_APIENTRY *PFNGLVERTEXATTRIBIFORMATPROC)(GLuint, GLint, typedef void (INTERNAL_GL_APIENTRY *PFNGLVERTEXATTRIBLFORMATPROC)(GLuint, GLint, GLenum, GLuint); typedef void (INTERNAL_GL_APIENTRY *PFNGLVERTEXBINDINGDIVISORPROC)(GLuint, GLuint); +// NV_framebuffer_mixed_samples +typedef void (INTERNAL_GL_APIENTRY *PFNGLCOVERAGEMODULATIONNVPROC)(GLenum); + // 4.4 typedef void (INTERNAL_GL_APIENTRY *PFNGLBINDBUFFERSBASEPROC)(GLenum, GLuint, GLsizei, const GLuint *); typedef void (INTERNAL_GL_APIENTRY *PFNGLBINDBUFFERSRANGEPROC)(GLenum, GLuint, GLsizei, const GLuint *, const GLintptr *, const GLsizeiptr *); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp index 41ca358a8ff..0bf96033e58 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp @@ -10,6 +10,8 @@ #include <EGL/eglext.h> #include <algorithm> +#include <cstring> +#include <fstream> #include "common/debug.h" #include "libANGLE/Config.h" @@ -21,6 +23,54 @@ #include "third_party/libXNVCtrl/NVCtrl.h" #include "third_party/libXNVCtrl/NVCtrlLib.h" +namespace +{ + +// Scan /etc/ati/amdpcsdb.default for "ReleaseVersion". +// Return empty string on failing. +egl::Error GetAMDDriverVersion(std::string *version) +{ + *version = ""; + + const char kAMDDriverInfoFileName[] = "/etc/ati/amdpcsdb.default"; + std::ifstream file(kAMDDriverInfoFileName); + + if (!file) + { + return egl::Error(EGL_SUCCESS); + } + + std::string line; + while (std::getline(file, line)) + { + static const char kReleaseVersion[] = "ReleaseVersion="; + if (line.compare(0, std::strlen(kReleaseVersion), kReleaseVersion) != 0) + { + continue; + } + + const size_t begin = line.find_first_of("0123456789"); + if (begin == std::string::npos) + { + continue; + } + + const size_t end = line.find_first_not_of("0123456789.", begin); + if (end == std::string::npos) + { + *version = line.substr(begin); + } + else + { + *version = line.substr(begin, end - begin); + } + return egl::Error(EGL_SUCCESS); + } + return egl::Error(EGL_SUCCESS); +} + +} // anonymous namespace + namespace rx { @@ -727,6 +777,8 @@ egl::Error DisplayGLX::getDriverVersion(std::string *version) const { case VENDOR_ID_NVIDIA: return getNVIDIADriverVersion(version); + case VENDOR_ID_AMD: + return GetAMDDriverVersion(version); default: *version = ""; return egl::Error(EGL_SUCCESS); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp index d54e2a037b2..20037ec590c 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp @@ -289,6 +289,24 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM // Doesn't impact supported version } + if (functions->isAtLeastGL(gl::Version(4, 1)) || + functions->hasGLExtension("GL_ARB_get_program_binary") || + functions->isAtLeastGLES(gl::Version(3, 0)) || + functions->hasGLExtension("GL_OES_get_program_binary")) + { + // Able to support the GL_PROGRAM_BINARY_ANGLE format as long as another program binary + // format is available. + GLint numBinaryFormats = QuerySingleGLInt(functions, GL_NUM_PROGRAM_BINARY_FORMATS_OES); + if (numBinaryFormats > 0) + { + caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE); + } + } + else + { + // Doesn't impact supported version + } + // glGetShaderPrecisionFormat is not available until desktop GL version 4.1 or GL_ARB_ES2_compatibility exists if (functions->isAtLeastGL(gl::Version(4, 1)) || functions->hasGLExtension("GL_ARB_ES2_compatibility") || functions->isAtLeastGLES(gl::Version(2, 0))) @@ -564,10 +582,10 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM // updated. caps->maxVertexUniformVectors = std::min(1024u, caps->maxVertexUniformVectors); caps->maxVertexUniformComponents = - std::min(caps->maxVertexUniformVectors / 4, caps->maxVertexUniformComponents); + std::min(caps->maxVertexUniformVectors * 4, caps->maxVertexUniformComponents); caps->maxFragmentUniformVectors = std::min(1024u, caps->maxFragmentUniformVectors); caps->maxFragmentUniformComponents = - std::min(caps->maxFragmentUniformVectors / 4, caps->maxFragmentUniformComponents); + std::min(caps->maxFragmentUniformVectors * 4, caps->maxFragmentUniformComponents); // If it is not possible to support reading buffer data back, a shadow copy of the buffers must // be held. This disallows writing to buffers indirectly through transform feedback, thus @@ -581,6 +599,7 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM extensions->setTextureExtensionSupport(*textureCapsMap); extensions->elementIndexUint = functions->standard == STANDARD_GL_DESKTOP || functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_element_index_uint"); + extensions->getProgramBinary = caps->programBinaryFormats.size() > 0; extensions->readFormatBGRA = functions->isAtLeastGL(gl::Version(1, 2)) || functions->hasGLExtension("GL_EXT_bgra") || functions->hasGLESExtension("GL_EXT_read_format_bgra"); extensions->mapBuffer = functions->isAtLeastGL(gl::Version(1, 5)) || @@ -638,10 +657,21 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM QueryQueryValue(functions, GL_TIMESTAMP, GL_QUERY_COUNTER_BITS); } + // the EXT_multisample_compatibility is written against ES3.1 but can apply + // to earlier versions so therefore we're only checking for the extension string + // and not the specific GLES version. + extensions->multisampleCompatibility = functions->isAtLeastGL(gl::Version(1, 3)) || + functions->hasGLESExtension("GL_EXT_multisample_compatibility"); + + extensions->framebufferMixedSamples = functions->hasGLExtension("GL_NV_framebuffer_mixed_samples") || + functions->hasGLESExtension("GL_NV_framebuffer_mixed_samples"); + // ANGLE emulates vertex array objects in its GL layer extensions->vertexArrayObject = true; extensions->noError = true; + + extensions->bindUniformLocation = true; } void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds) @@ -666,6 +696,9 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround workarounds->finishDoesNotCauseQueriesToBeAvailable = functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_NVIDIA; + + // TODO(cwallez): Disable this workaround for MacOSX versions 10.9 or later. + workarounds->alwaysCallUseProgramAfterLink = true; } } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp index bd705a89e64..0ca4f85adcb 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp @@ -289,7 +289,7 @@ EGLint DXGISwapChainWindowSurfaceWGL::getSwapBehavior() const } FramebufferImpl *DXGISwapChainWindowSurfaceWGL::createDefaultFramebuffer( - const gl::Framebuffer::Data &data) + const gl::FramebufferState &data) { return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds, mStateManager); } diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h b/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h index a4549c6e25f..1488a4dbb85 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h @@ -53,7 +53,7 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL EGLint isPostSubBufferSupported() const override; EGLint getSwapBehavior() const override; - FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override; + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; private: egl::Error setObjectsLocked(bool locked); diff --git a/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp b/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp index 6cb4f4fd121..382252866b6 100644 --- a/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp @@ -345,7 +345,9 @@ egl::Error DisplayWGL::initialize(egl::Display *display) DWORD currentProcessId = GetCurrentProcessId(); DWORD windowProcessId; GetWindowThreadProcessId(nativeWindow, &windowProcessId); - mUseDXGISwapChains = (currentProcessId != windowProcessId); + + // AMD drivers advertise the WGL_NV_DX_interop and WGL_NV_DX_interop2 extensions but fail + mUseDXGISwapChains = vendor != VENDOR_ID_AMD && (currentProcessId != windowProcessId); } else { diff --git a/chromium/third_party/angle/src/libANGLE/validationEGL.cpp b/chromium/third_party/angle/src/libANGLE/validationEGL.cpp index 2f531d0de33..846a32dd2bb 100644 --- a/chromium/third_party/angle/src/libANGLE/validationEGL.cpp +++ b/chromium/third_party/angle/src/libANGLE/validationEGL.cpp @@ -16,6 +16,7 @@ #include "libANGLE/Image.h" #include "libANGLE/Stream.h" #include "libANGLE/Surface.h" +#include "libANGLE/Texture.h" #include <EGL/eglext.h> @@ -1245,6 +1246,11 @@ Error ValidateStreamConsumerGLTextureExternalKHR(const Display *display, return Error(EGL_BAD_ACCESS, "Stream consumer extension not active"); } + if (!context->getExtensions().eglStreamConsumerExternal) + { + return Error(EGL_BAD_ACCESS, "EGL stream consumer external GL extension not enabled"); + } + if (stream == EGL_NO_STREAM_KHR || !display->isValidStream(stream)) { return Error(EGL_BAD_STREAM_KHR, "Invalid stream"); @@ -1255,6 +1261,13 @@ Error ValidateStreamConsumerGLTextureExternalKHR(const Display *display, return Error(EGL_BAD_STATE_KHR, "Invalid stream state"); } + // Lookup the texture and ensure it is correct + gl::Texture *texture = context->getState().getTargetTexture(GL_TEXTURE_EXTERNAL_OES); + if (texture == nullptr || texture->getId() == 0) + { + return Error(EGL_BAD_ACCESS, "No external texture bound"); + } + return Error(EGL_SUCCESS); } @@ -1268,12 +1281,6 @@ Error ValidateStreamConsumerAcquireKHR(const Display *display, return error; } - error = ValidateContext(display, context); - if (error.isError()) - { - return error; - } - const DisplayExtensions &displayExtensions = display->getExtensions(); if (!displayExtensions.streamConsumerGLTexture) { @@ -1285,6 +1292,26 @@ Error ValidateStreamConsumerAcquireKHR(const Display *display, return Error(EGL_BAD_STREAM_KHR, "Invalid stream"); } + error = ValidateContext(display, context); + if (error.isError()) + { + return Error(EGL_BAD_ACCESS, "Invalid GL context"); + } + + if (!stream->isConsumerBoundToContext(context)) + { + return Error(EGL_BAD_ACCESS, "Current GL context not associated with stream consumer"); + } + + if (stream->getConsumerType() != Stream::ConsumerType::GLTextureRGB && + stream->getConsumerType() != Stream::ConsumerType::GLTextureYUV) + { + return Error(EGL_BAD_ACCESS, "Invalid stream consumer type"); + } + + // Note: technically EGL_STREAM_STATE_EMPTY_KHR is a valid state when the timeout is non-zero. + // However, the timeout is effectively ignored since it has no useful functionality with the + // current producers that are implemented, so we don't allow that state if (stream->getState() != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR && stream->getState() != EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR) { @@ -1304,12 +1331,6 @@ Error ValidateStreamConsumerReleaseKHR(const Display *display, return error; } - error = ValidateContext(display, context); - if (error.isError()) - { - return error; - } - const DisplayExtensions &displayExtensions = display->getExtensions(); if (!displayExtensions.streamConsumerGLTexture) { @@ -1321,6 +1342,23 @@ Error ValidateStreamConsumerReleaseKHR(const Display *display, return Error(EGL_BAD_STREAM_KHR, "Invalid stream"); } + error = ValidateContext(display, context); + if (error.isError()) + { + return Error(EGL_BAD_ACCESS, "Invalid GL context"); + } + + if (!stream->isConsumerBoundToContext(context)) + { + return Error(EGL_BAD_ACCESS, "Current GL context not associated with stream consumer"); + } + + if (stream->getConsumerType() != Stream::ConsumerType::GLTextureRGB && + stream->getConsumerType() != Stream::ConsumerType::GLTextureYUV) + { + return Error(EGL_BAD_ACCESS, "Invalid stream consumer type"); + } + if (stream->getState() != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR && stream->getState() != EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR) { @@ -1353,6 +1391,14 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, return Error(EGL_BAD_ACCESS, "Stream consumer extension not active"); } + // Although technically not a requirement in spec, the context needs to be checked for support + // for external textures or future logic will cause assertations. This extension is also + // effectively useless without external textures. + if (!context->getExtensions().eglStreamConsumerExternal) + { + return Error(EGL_BAD_ACCESS, "EGL stream consumer external GL extension not enabled"); + } + if (stream == EGL_NO_STREAM_KHR || !display->isValidStream(stream)) { return Error(EGL_BAD_STREAM_KHR, "Invalid stream"); @@ -1363,6 +1409,8 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, return Error(EGL_BAD_STATE_KHR, "Invalid stream state"); } + const gl::Caps &glCaps = context->getCaps(); + EGLAttrib colorBufferType = EGL_RGB_BUFFER; EGLAttrib planeCount = -1; EGLAttrib plane[3]; @@ -1378,7 +1426,7 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, switch (attribute) { case EGL_COLOR_BUFFER_TYPE: - if (value != EGL_RGB_BUFFER || value != EGL_YUV_BUFFER_EXT) + if (value != EGL_RGB_BUFFER && value != EGL_YUV_BUFFER_EXT) { return Error(EGL_BAD_PARAMETER, "Invalid color buffer type"); } @@ -1398,7 +1446,9 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, if (attribute >= EGL_YUV_PLANE0_TEXTURE_UNIT_NV && attribute <= EGL_YUV_PLANE2_TEXTURE_UNIT_NV) { - if (value < 0) + if ((value < 0 || + value >= static_cast<EGLAttrib>(glCaps.maxCombinedTextureImageUnits)) && + value != EGL_NONE) { return Error(EGL_BAD_ACCESS, "Invalid texture unit"); } @@ -1424,6 +1474,13 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, return Error(EGL_BAD_MATCH, "Planes cannot be specified"); } } + + // Lookup the texture and ensure it is correct + gl::Texture *texture = context->getState().getTargetTexture(GL_TEXTURE_EXTERNAL_OES); + if (texture == nullptr || texture->getId() == 0) + { + return Error(EGL_BAD_ACCESS, "No external texture bound"); + } } else { @@ -1435,22 +1492,131 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, { return Error(EGL_BAD_MATCH, "Invalid YUV plane count"); } + for (EGLAttrib i = planeCount; i < 3; i++) + { + if (plane[i] != -1) + { + return Error(EGL_BAD_MATCH, "Invalid plane specified"); + } + } + + // Set to ensure no texture is referenced more than once + std::set<gl::Texture *> textureSet; for (EGLAttrib i = 0; i < planeCount; i++) { if (plane[i] == -1) { return Error(EGL_BAD_MATCH, "Not all planes specified"); } - } - for (EGLAttrib i = planeCount; i < 3; i++) - { - if (plane[i] != -1) + if (plane[i] != EGL_NONE) { - return Error(EGL_BAD_MATCH, "Invalid plane specified"); + gl::Texture *texture = context->getState().getSamplerTexture( + static_cast<unsigned int>(plane[i]), GL_TEXTURE_EXTERNAL_OES); + if (texture == nullptr || texture->getId() == 0) + { + return Error( + EGL_BAD_ACCESS, + "No external texture bound at one or more specified texture units"); + } + if (textureSet.find(texture) != textureSet.end()) + { + return Error(EGL_BAD_ACCESS, "Multiple planes bound to same texture object"); + } + textureSet.insert(texture); } } } return Error(EGL_SUCCESS); } + +Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display, + const Stream *stream, + const AttributeMap &attribs) +{ + const DisplayExtensions &displayExtensions = display->getExtensions(); + if (!displayExtensions.streamProducerD3DTextureNV12) + { + return Error(EGL_BAD_ACCESS, "Stream producer extension not active"); + } + + Error error = ValidateStream(display, stream); + if (error.isError()) + { + return error; + } + + if (!attribs.isEmpty()) + { + return Error(EGL_BAD_ATTRIBUTE, "Invalid attribute"); + } + + if (stream->getState() != EGL_STREAM_STATE_CONNECTING_KHR) + { + return Error(EGL_BAD_STATE_KHR, "Stream not in connecting state"); + } + + if (stream->getConsumerType() != Stream::ConsumerType::GLTextureYUV || + stream->getPlaneCount() != 2) + { + return Error(EGL_BAD_MATCH, "Incompatible stream consumer type"); + } + + return Error(EGL_SUCCESS); +} + +Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, + const Stream *stream, + void *texture, + const AttributeMap &attribs) +{ + const DisplayExtensions &displayExtensions = display->getExtensions(); + if (!displayExtensions.streamProducerD3DTextureNV12) + { + return Error(EGL_BAD_ACCESS, "Stream producer extension not active"); + } + + Error error = ValidateStream(display, stream); + if (error.isError()) + { + return error; + } + + for (auto &attributeIter : attribs) + { + EGLAttrib attribute = attributeIter.first; + EGLAttrib value = attributeIter.second; + + switch (attribute) + { + case EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE: + if (value < 0) + { + return Error(EGL_BAD_PARAMETER, "Invalid subresource index"); + } + break; + default: + return Error(EGL_BAD_ATTRIBUTE, "Invalid attribute"); + } + } + + if (stream->getState() != EGL_STREAM_STATE_EMPTY_KHR && + stream->getState() != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR && + stream->getState() != EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR) + { + return Error(EGL_BAD_STATE_KHR, "Stream not fully configured"); + } + + if (stream->getProducerType() != Stream::ProducerType::D3D11TextureNV12) + { + return Error(EGL_BAD_MATCH, "Incompatible stream producer"); + } + + if (texture == nullptr) + { + return egl::Error(EGL_BAD_PARAMETER, "Texture is null"); + } + + return stream->validateD3D11NV12Texture(texture); +} } diff --git a/chromium/third_party/angle/src/libANGLE/validationEGL.h b/chromium/third_party/angle/src/libANGLE/validationEGL.h index 66e0357dd04..04927908735 100644 --- a/chromium/third_party/angle/src/libANGLE/validationEGL.h +++ b/chromium/third_party/angle/src/libANGLE/validationEGL.h @@ -87,6 +87,13 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, gl::Context *context, const Stream *stream, const AttributeMap &attribs); +Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display, + const Stream *stream, + const AttributeMap &attribs); +Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, + const Stream *stream, + void *texture, + const AttributeMap &attribs); // Other validation Error ValidateCompatibleConfigs(const Display *display, diff --git a/chromium/third_party/angle/src/libANGLE/validationES.cpp b/chromium/third_party/angle/src/libANGLE/validationES.cpp index d3efd918097..76e8c64fed5 100644 --- a/chromium/third_party/angle/src/libANGLE/validationES.cpp +++ b/chromium/third_party/angle/src/libANGLE/validationES.cpp @@ -75,7 +75,7 @@ bool ValidateDrawAttribs(ValidationContext *context, GLint primcount, GLint maxV // enough backing data. if (attribDataSize + attribOffset > buffer->getSize()) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Vertex buffer is not big enough for the draw call")); return false; @@ -86,7 +86,7 @@ bool ValidateDrawAttribs(ValidationContext *context, GLint primcount, GLint maxV { // This is an application error that would normally result in a crash, // but we catch it and return an error - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "An enabled vertex array has no buffer and no pointer.")); return false; } @@ -102,6 +102,11 @@ bool ValidCap(const Context *context, GLenum cap) { switch (cap) { + // EXT_multisample_compatibility + case GL_MULTISAMPLE_EXT: + case GL_SAMPLE_ALPHA_TO_ONE_EXT: + return context->getExtensions().multisampleCompatibility; + case GL_CULL_FACE: case GL_POLYGON_OFFSET_FILL: case GL_SAMPLE_ALPHA_TO_COVERAGE: @@ -169,6 +174,15 @@ bool ValidTexture3DTarget(const ValidationContext *context, GLenum target) } } +// Most texture GL calls are not compatible with external textures, so we have a separate validation +// function for use in the GL calls that do +bool ValidTextureExternalTarget(const ValidationContext *context, GLenum target) +{ + return (target == GL_TEXTURE_EXTERNAL_OES) && + (context->getExtensions().eglImageExternal || + context->getExtensions().eglStreamConsumerExternal); +} + // This function differs from ValidTextureTarget in that the target must be // usable as the destination of a 2D operation-- so a cube face is valid, but // GL_TEXTURE_CUBE_MAP is not. @@ -389,6 +403,8 @@ bool ValidQueryType(const Context *context, GLenum queryType) return (context->getClientVersion() >= 3); case GL_TIME_ELAPSED_EXT: return context->getExtensions().disjointTimerQuery; + case GL_COMMANDS_COMPLETED_CHROMIUM: + return context->getExtensions().syncQuery; default: return false; } @@ -406,12 +422,12 @@ Program *GetValidProgram(Context *context, GLuint id) { if (context->getShader(id)) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Expected a program name, but found a shader name")); } else { - context->recordError(Error(GL_INVALID_VALUE, "Program name is not valid")); + context->handleError(Error(GL_INVALID_VALUE, "Program name is not valid")); } } @@ -428,12 +444,12 @@ Shader *GetValidShader(Context *context, GLuint id) { if (context->getProgram(id)) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Expected a shader name, but found a program name")); } else { - context->recordError(Error(GL_INVALID_VALUE, "Shader name is invalid")); + context->handleError(Error(GL_INVALID_VALUE, "Shader name is invalid")); } } @@ -448,7 +464,7 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) if (colorAttachment >= context->getCaps().maxColorAttachments) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -463,13 +479,13 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) case GL_DEPTH_STENCIL_ATTACHMENT: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } } @@ -485,20 +501,20 @@ bool ValidateRenderbufferStorageParametersBase(gl::Context *context, GLenum targ case GL_RENDERBUFFER: break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (width < 0 || height < 0 || samples < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); if (!formatCaps.renderable) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -508,20 +524,20 @@ bool ValidateRenderbufferStorageParametersBase(gl::Context *context, GLenum targ const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); if (formatInfo.pixelBytes == 0) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (static_cast<GLuint>(std::max(width, height)) > context->getCaps().maxRenderbufferSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } GLuint handle = context->getState().getRenderbufferId(); if (handle == 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -538,7 +554,7 @@ bool ValidateRenderbufferStorageParametersANGLE(gl::Context *context, GLenum tar // generated. if (static_cast<GLuint>(samples) > context->getCaps().maxSamples) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -551,7 +567,7 @@ bool ValidateRenderbufferStorageParametersANGLE(gl::Context *context, GLenum tar const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples()) { - context->recordError(Error(GL_OUT_OF_MEMORY)); + context->handleError(Error(GL_OUT_OF_MEMORY)); return false; } } @@ -564,7 +580,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ { if (!ValidFramebufferTarget(target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -573,7 +589,8 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ ASSERT(framebuffer); if (framebuffer->id() == 0) { - context->recordError(Error(GL_INVALID_OPERATION, "Cannot change default FBO's attachments")); + context->handleError( + Error(GL_INVALID_OPERATION, "Cannot change default FBO's attachments")); return false; } @@ -590,7 +607,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ { if (!context->getRenderbuffer(renderbuffer)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -617,13 +634,13 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, case GL_LINEAR: break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -638,13 +655,13 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, // color buffer, leaving only nearest being unfiltered from above if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (context->getState().getReadFramebuffer()->id() == context->getState().getDrawFramebuffer()->id()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -653,25 +670,25 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, if (!readFramebuffer || !drawFramebuffer) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } if (!readFramebuffer->checkStatus(context->getData())) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } if (!drawFramebuffer->checkStatus(context->getData())) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } if (drawFramebuffer->getSamples(context->getData()) != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -718,7 +735,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, if (readFixedOrFloat != drawFixedOrFloat) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "If the read buffer contains fixed-point or " "floating-point values, the draw buffer " "must as well.")); @@ -727,7 +744,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, } else if (readFixedPoint != drawFixedPoint) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "If the read buffer contains fixed-point " "values, the draw buffer must as well.")); return false; @@ -736,19 +753,19 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, if (readComponentType == GL_UNSIGNED_INT && drawComponentType != GL_UNSIGNED_INT) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (readComponentType == GL_INT && drawComponentType != GL_INT) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawInternalFormat || !sameBounds)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -756,7 +773,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, if ((readFormatInfo.componentType == GL_INT || readFormatInfo.componentType == GL_UNSIGNED_INT) && filter == GL_LINEAR) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -775,13 +792,13 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, { if (readBuffer->getInternalFormat() != drawBuffer->getInternalFormat()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (readBuffer->getSamples() > 0 && !sameBounds) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -814,18 +831,18 @@ bool ValidateGetVertexAttribParameters(Context *context, GLenum pname) case GL_VERTEX_ATTRIB_ARRAY_INTEGER: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } } -bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) +bool ValidateTexParamParameters(gl::Context *context, GLenum target, GLenum pname, GLint param) { switch (pname) { @@ -840,9 +857,11 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_TEXTURE_COMPARE_FUNC: case GL_TEXTURE_MIN_LOD: case GL_TEXTURE_MAX_LOD: - if (context->getClientVersion() < 3) + // ES3 texture paramters are not supported on external textures as the extension is + // written against ES2. + if (context->getClientVersion() < 3 || target == GL_TEXTURE_EXTERNAL_OES) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -857,12 +876,20 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_TEXTURE_WRAP_R: switch (param) { - case GL_REPEAT: case GL_CLAMP_TO_EDGE: + return true; + case GL_REPEAT: case GL_MIRRORED_REPEAT: - return true; + if (target == GL_TEXTURE_EXTERNAL_OES) + { + // OES_EGL_image_external specifies this error. + context->handleError(Error( + GL_INVALID_ENUM, "external textures only support CLAMP_TO_EDGE wrap mode")); + return false; + } + return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -871,13 +898,22 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) { case GL_NEAREST: case GL_LINEAR: + return true; case GL_NEAREST_MIPMAP_NEAREST: case GL_LINEAR_MIPMAP_NEAREST: case GL_NEAREST_MIPMAP_LINEAR: case GL_LINEAR_MIPMAP_LINEAR: - return true; + if (target == GL_TEXTURE_EXTERNAL_OES) + { + // OES_EGL_image_external specifies this error. + context->handleError( + Error(GL_INVALID_ENUM, + "external textures only support NEAREST and LINEAR filtering")); + return false; + } + return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -889,7 +925,7 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_LINEAR: return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -901,7 +937,7 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_FRAMEBUFFER_ATTACHMENT_ANGLE: return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -909,14 +945,14 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_TEXTURE_MAX_ANISOTROPY_EXT: if (!context->getExtensions().textureFilterAnisotropic) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } // we assume the parameter passed to this validation method is truncated, not rounded if (param < 1) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } return true; @@ -934,7 +970,7 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_COMPARE_REF_TO_TEXTURE: return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -953,7 +989,7 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_NEVER: return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -972,23 +1008,31 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) case GL_ONE: return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_TEXTURE_BASE_LEVEL: case GL_TEXTURE_MAX_LEVEL: - if (param < 0) - { - context->recordError(Error(GL_INVALID_VALUE)); - return false; - } - return true; - + if (target == GL_TEXTURE_EXTERNAL_OES) + { + // This is not specified, but in line with the spirit of OES_EGL_image_external spec, + // which generally forbids setting mipmap related parameters on external textures. + context->handleError( + Error(GL_INVALID_OPERATION, + "Setting the base level or max level of external textures not supported")); + return false; + } + if (param < 0) + { + context->handleError(Error(GL_INVALID_VALUE)); + return false; + } + return true; default: - context->recordError(Error(GL_INVALID_ENUM)); - return false; + context->handleError(Error(GL_INVALID_ENUM)); + return false; } } @@ -1008,7 +1052,7 @@ bool ValidateSamplerObjectParameter(gl::Context *context, GLenum pname) return true; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } } @@ -1024,7 +1068,7 @@ bool ValidateReadPixels(Context *context, { if (width < 0 || height < 0) { - context->recordError(Error(GL_INVALID_VALUE, "width and height must be positive")); + context->handleError(Error(GL_INVALID_VALUE, "width and height must be positive")); return false; } @@ -1033,21 +1077,21 @@ bool ValidateReadPixels(Context *context, if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } if (context->getState().getReadFramebuffer()->id() != 0 && framebuffer->getSamples(context->getData()) != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } const FramebufferAttachment *readBuffer = framebuffer->getReadColorbuffer(); if (!readBuffer) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1061,7 +1105,7 @@ bool ValidateReadPixels(Context *context, if (!(currentFormat == format && currentType == type) && !validReadFormat) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1080,7 +1124,7 @@ bool ValidateReadnPixelsEXT(Context *context, { if (bufSize < 0) { - context->recordError(Error(GL_INVALID_VALUE, "bufSize must be a positive number")); + context->handleError(Error(GL_INVALID_VALUE, "bufSize must be a positive number")); return false; } @@ -1094,7 +1138,7 @@ bool ValidateReadnPixelsEXT(Context *context, int requiredSize = outputPitch * height; if (requiredSize > bufSize) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1106,7 +1150,7 @@ bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n) if (!context->getExtensions().occlusionQueryBoolean && !context->getExtensions().disjointTimerQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } @@ -1118,7 +1162,7 @@ bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n) if (!context->getExtensions().occlusionQueryBoolean && !context->getExtensions().disjointTimerQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } @@ -1129,13 +1173,13 @@ bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id) { if (!ValidQueryType(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid query target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid query target")); return false; } if (id == 0) { - context->recordError(Error(GL_INVALID_OPERATION, "Query id is 0")); + context->handleError(Error(GL_INVALID_OPERATION, "Query id is 0")); return false; } @@ -1155,11 +1199,9 @@ bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id) // of GL_ANY_SAMPLES_PASSED_EXT and GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, // no query may be active for either if glBeginQuery targets either. - // TODO(ewell): I think this needs to be changed for timer and occlusion queries to work at the - // same time - if (context->getState().isQueryActive()) + if (context->getState().isQueryActive(target)) { - context->recordError(Error(GL_INVALID_OPERATION, "Other query is active")); + context->handleError(Error(GL_INVALID_OPERATION, "Other query is active")); return false; } @@ -1168,14 +1210,14 @@ bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id) // check that name was obtained with glGenQueries if (!queryObject) { - context->recordError(Error(GL_INVALID_OPERATION, "Invalid query id")); + context->handleError(Error(GL_INVALID_OPERATION, "Invalid query id")); return false; } // check for type mismatch if (queryObject->getType() != target) { - context->recordError(Error(GL_INVALID_OPERATION, "Query type does not match target")); + context->handleError(Error(GL_INVALID_OPERATION, "Query type does not match target")); return false; } @@ -1185,9 +1227,9 @@ bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id) bool ValidateBeginQueryEXT(gl::Context *context, GLenum target, GLuint id) { if (!context->getExtensions().occlusionQueryBoolean && - !context->getExtensions().disjointTimerQuery) + !context->getExtensions().disjointTimerQuery && !context->getExtensions().syncQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } @@ -1198,7 +1240,7 @@ bool ValidateEndQueryBase(gl::Context *context, GLenum target) { if (!ValidQueryType(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid query target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid query target")); return false; } @@ -1206,7 +1248,7 @@ bool ValidateEndQueryBase(gl::Context *context, GLenum target) if (queryObject == nullptr) { - context->recordError(Error(GL_INVALID_OPERATION, "Query target not active")); + context->handleError(Error(GL_INVALID_OPERATION, "Query target not active")); return false; } @@ -1216,9 +1258,9 @@ bool ValidateEndQueryBase(gl::Context *context, GLenum target) bool ValidateEndQueryEXT(gl::Context *context, GLenum target) { if (!context->getExtensions().occlusionQueryBoolean && - !context->getExtensions().disjointTimerQuery) + !context->getExtensions().disjointTimerQuery && !context->getExtensions().syncQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } @@ -1229,26 +1271,26 @@ bool ValidateQueryCounterEXT(Context *context, GLuint id, GLenum target) { if (!context->getExtensions().disjointTimerQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Disjoint timer query not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Disjoint timer query not enabled")); return false; } if (target != GL_TIMESTAMP_EXT) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid query target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid query target")); return false; } Query *queryObject = context->getQuery(id, true, target); if (queryObject == nullptr) { - context->recordError(Error(GL_INVALID_OPERATION, "Invalid query id")); + context->handleError(Error(GL_INVALID_OPERATION, "Invalid query id")); return false; } if (context->getState().isQueryActive(queryObject)) { - context->recordError(Error(GL_INVALID_OPERATION, "Query is active")); + context->handleError(Error(GL_INVALID_OPERATION, "Query is active")); return false; } @@ -1259,7 +1301,7 @@ bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname) { if (!ValidQueryType(context, target) && target != GL_TIMESTAMP_EXT) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid query type")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid query type")); return false; } @@ -1268,7 +1310,7 @@ bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname) case GL_CURRENT_QUERY_EXT: if (target == GL_TIMESTAMP_EXT) { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "Cannot use current query for timestamp")); return false; } @@ -1277,12 +1319,12 @@ bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname) if (!context->getExtensions().disjointTimerQuery || (target != GL_TIMESTAMP_EXT && target != GL_TIME_ELAPSED_EXT)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid pname")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid pname")); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid pname")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid pname")); return false; } @@ -1292,9 +1334,9 @@ bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname) bool ValidateGetQueryivEXT(Context *context, GLenum target, GLenum pname, GLint *params) { if (!context->getExtensions().occlusionQueryBoolean && - !context->getExtensions().disjointTimerQuery) + !context->getExtensions().disjointTimerQuery && !context->getExtensions().syncQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } @@ -1307,13 +1349,13 @@ bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname) if (!queryObject) { - context->recordError(Error(GL_INVALID_OPERATION, "Query does not exist")); + context->handleError(Error(GL_INVALID_OPERATION, "Query does not exist")); return false; } if (context->getState().isQueryActive(queryObject)) { - context->recordError(Error(GL_INVALID_OPERATION, "Query currently active")); + context->handleError(Error(GL_INVALID_OPERATION, "Query currently active")); return false; } @@ -1324,7 +1366,7 @@ bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname) break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid pname enum")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid pname enum")); return false; } @@ -1335,7 +1377,7 @@ bool ValidateGetQueryObjectivEXT(Context *context, GLuint id, GLenum pname, GLin { if (!context->getExtensions().disjointTimerQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); return false; } return ValidateGetQueryObjectValueBase(context, id, pname); @@ -1344,9 +1386,9 @@ bool ValidateGetQueryObjectivEXT(Context *context, GLuint id, GLenum pname, GLin bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLuint *params) { if (!context->getExtensions().disjointTimerQuery && - !context->getExtensions().occlusionQueryBoolean) + !context->getExtensions().occlusionQueryBoolean && !context->getExtensions().syncQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } return ValidateGetQueryObjectValueBase(context, id, pname); @@ -1356,7 +1398,7 @@ bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GL { if (!context->getExtensions().disjointTimerQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); return false; } return ValidateGetQueryObjectValueBase(context, id, pname); @@ -1366,7 +1408,7 @@ bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, G { if (!context->getExtensions().disjointTimerQuery) { - context->recordError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); return false; } return ValidateGetQueryObjectValueBase(context, id, pname); @@ -1380,18 +1422,18 @@ static bool ValidateUniformCommonBase(gl::Context *context, { if (count < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } gl::Program *program = context->getState().getProgram(); if (!program) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } - if (location == -1) + if (program->isIgnoredUniformLocation(location)) { // Silently ignore the uniform command return false; @@ -1399,7 +1441,7 @@ static bool ValidateUniformCommonBase(gl::Context *context, if (!program->isValidUniformLocation(location)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1408,7 +1450,7 @@ static bool ValidateUniformCommonBase(gl::Context *context, // attempting to write an array to a non-array uniform is an INVALID_OPERATION if (!uniform.isArray() && count > 1) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1421,7 +1463,7 @@ bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, G // Check for ES3 uniform entry points if (VariableComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1435,7 +1477,7 @@ bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, G bool samplerUniformCheck = (IsSamplerType(uniform->type) && uniformType == GL_INT); if (!samplerUniformCheck && uniformType != uniform->type && targetBoolType != uniform->type) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1450,13 +1492,13 @@ bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint locati int cols = VariableColumnCount(matrixType); if (rows != cols && context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (transpose != GL_FALSE && context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1468,7 +1510,7 @@ bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint locati if (uniform->type != matrixType) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1479,7 +1521,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, { if (!context->getQueryParameterInfo(pname, nativeType, numParams)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1491,7 +1533,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, if (colorAttachment >= caps.maxDrawBuffers) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1506,7 +1548,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, case GL_TEXTURE_BINDING_EXTERNAL_OES: if (!context->getExtensions().eglStreamConsumerExternal) { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "NV_EGL_stream_consumer_external extension not enabled")); return false; } @@ -1519,14 +1561,14 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, ASSERT(framebuffer); if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } const FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); if (!attachment) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1562,39 +1604,39 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, { if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (border != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (!ValidMipLevel(context, target, level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } const gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } const auto &state = context->getState(); if (state.getReadFramebuffer()->id() != 0 && framebuffer->getSamples(context->getData()) != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1625,7 +1667,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1633,13 +1675,13 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, state.getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); if (!texture) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (texture->getImmutableFormat() && !isSubImage) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1647,13 +1689,13 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, if (formatInfo.depthBits > 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (formatInfo.compressed && !ValidCompressedImageSize(context, internalformat, width, height)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1663,7 +1705,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, static_cast<size_t>(yoffset + height) > texture->getHeight(target, level) || static_cast<size_t>(zoffset) >= texture->getDepth(target, level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1671,20 +1713,20 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, { if (IsCubeMapTextureTarget(target) && width != height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } int maxLevelDimension = (maxDimension >> level); if (static_cast<int>(width) > maxLevelDimension || static_cast<int>(height) > maxLevelDimension) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1709,13 +1751,13 @@ static bool ValidateDrawBase(ValidationContext *context, case GL_TRIANGLE_FAN: break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (count < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1724,7 +1766,7 @@ static bool ValidateDrawBase(ValidationContext *context, // Check for mapped buffers if (state.hasMappedBuffer(GL_ARRAY_BUFFER)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1746,7 +1788,7 @@ static bool ValidateDrawBase(ValidationContext *context, ERR( "This ANGLE implementation does not support separate front/back stencil " "writemasks, reference values, or stencil mask values."); - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1754,20 +1796,20 @@ static bool ValidateDrawBase(ValidationContext *context, const gl::Framebuffer *fbo = state.getDrawFramebuffer(); if (!fbo || fbo->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } gl::Program *program = state.getProgram(); if (!program) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (!program->validateSamplers(NULL, context->getCaps())) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1782,7 +1824,9 @@ static bool ValidateDrawBase(ValidationContext *context, if (uniformBuffer.get() == nullptr) { // undefined behaviour - context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to have a used but unbound uniform buffer.")); + context->handleError( + Error(GL_INVALID_OPERATION, + "It is undefined behaviour to have a used but unbound uniform buffer.")); return false; } @@ -1796,7 +1840,9 @@ static bool ValidateDrawBase(ValidationContext *context, if (uniformBufferSize < uniformBlock.dataSize) { // undefined behaviour - context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small.")); + context->handleError( + Error(GL_INVALID_OPERATION, + "It is undefined behaviour to use a uniform buffer that is too small.")); return false; } } @@ -1809,7 +1855,7 @@ bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei coun { if (first < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1821,7 +1867,7 @@ bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei coun // It is an invalid operation to call DrawArrays or DrawArraysInstanced with a draw mode // that does not match the current transform feedback object's draw mode (if transform feedback // is active), (3.0.2, section 2.14, pg 86) - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1842,7 +1888,7 @@ bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLs { if (primcount < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1872,8 +1918,9 @@ static bool ValidateDrawInstancedANGLE(Context *context) } } - context->recordError(Error(GL_INVALID_OPERATION, "ANGLE_instanced_arrays requires that at least one active attribute" - "has a divisor of zero.")); + context->handleError(Error(GL_INVALID_OPERATION, + "ANGLE_instanced_arrays requires that at least one active attribute" + "has a divisor of zero.")); return false; } @@ -1903,12 +1950,12 @@ bool ValidateDrawElements(ValidationContext *context, case GL_UNSIGNED_INT: if (context->getClientVersion() < 3 && !context->getExtensions().elementIndexUint) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1919,14 +1966,14 @@ bool ValidateDrawElements(ValidationContext *context, { // It is an invalid operation to call DrawElements, DrawRangeElements or DrawElementsInstanced // while transform feedback is active, (3.0.2, section 2.14, pg 86) - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } // Check for mapped buffers if (state.hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1934,7 +1981,7 @@ bool ValidateDrawElements(ValidationContext *context, gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get(); if (!indices && !elementArrayBuffer) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1949,21 +1996,21 @@ bool ValidateDrawElements(ValidationContext *context, if (static_cast<GLuint>(count) > (std::numeric_limits<GLuint>::max() / typeInfo.bytes) || byteCount > static_cast<GLint64>(std::numeric_limits<GLuint>::max())) { - context->recordError(Error(GL_OUT_OF_MEMORY)); + context->handleError(Error(GL_OUT_OF_MEMORY)); return false; } // Check for reading past the end of the bound buffer object if (byteCount > elementArrayBuffer->getSize()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } else if (!indices) { // Catch this programming error here - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1983,7 +2030,7 @@ bool ValidateDrawElements(ValidationContext *context, state.isPrimitiveRestartEnabled(), indexRangeOut); if (error.isError()) { - context->recordError(error); + context->handleError(error); return false; } } @@ -1997,7 +2044,7 @@ bool ValidateDrawElements(ValidationContext *context, // return an error if possible here. if (static_cast<GLuint64>(indexRangeOut->end) >= context->getCaps().maxElementIndex) { - context->recordError(Error(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage)); + context->handleError(Error(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage)); return false; } @@ -2020,7 +2067,7 @@ bool ValidateDrawElementsInstanced(Context *context, { if (primcount < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -2054,7 +2101,7 @@ bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum atta { if (!ValidFramebufferTarget(target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -2069,13 +2116,13 @@ bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum atta if (tex == NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (level < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -2085,7 +2132,8 @@ bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum atta if (framebuffer->id() == 0) { - context->recordError(Error(GL_INVALID_OPERATION, "Cannot change default FBO's attachments")); + context->handleError( + Error(GL_INVALID_OPERATION, "Cannot change default FBO's attachments")); return false; } @@ -2098,7 +2146,7 @@ bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attach // Attachments are required to be bound to level 0 without ES3 or the GL_OES_fbo_render_mipmap extension if (context->getClientVersion() < 3 && !context->getExtensions().fboRenderMipmap && level != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -2120,12 +2168,12 @@ bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attach { if (level > gl::log2(caps.max2DTextureSize)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (tex->getTarget() != GL_TEXTURE_2D) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -2140,26 +2188,26 @@ bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attach { if (level > gl::log2(caps.maxCubeMapTextureSize)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(tex->getInternalFormat(textarget, level)); if (internalFormatInfo.compressed) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -2171,7 +2219,7 @@ bool ValidateGetUniformBase(Context *context, GLuint program, GLint location) { if (program == 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -2183,13 +2231,13 @@ bool ValidateGetUniformBase(Context *context, GLuint program, GLint location) if (!programObject || !programObject->isLinked()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (!programObject->isValidUniformLocation(location)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2221,7 +2269,7 @@ static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint loca size_t requiredBytes = VariableExternalSize(uniform.type); if (static_cast<size_t>(bufSize) < requiredBytes) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2243,7 +2291,7 @@ bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei num { if (numAttachments < 0) { - context->recordError(Error(GL_INVALID_VALUE, "numAttachments must not be less than zero")); + context->handleError(Error(GL_INVALID_VALUE, "numAttachments must not be less than zero")); return false; } @@ -2253,14 +2301,16 @@ bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei num { if (defaultFramebuffer) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is bound")); + context->handleError(Error( + GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is bound")); return false; } if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getCaps().maxColorAttachments) { - context->recordError(Error(GL_INVALID_OPERATION, - "Requested color attachment is greater than the maximum supported color attachments")); + context->handleError(Error(GL_INVALID_OPERATION, + "Requested color attachment is greater than the maximum " + "supported color attachments")); return false; } } @@ -2273,7 +2323,9 @@ bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei num case GL_DEPTH_STENCIL_ATTACHMENT: if (defaultFramebuffer) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is bound")); + context->handleError( + Error(GL_INVALID_ENUM, + "Invalid attachment when the default framebuffer is bound")); return false; } break; @@ -2282,12 +2334,14 @@ bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei num case GL_STENCIL: if (!defaultFramebuffer) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is not bound")); + context->handleError( + Error(GL_INVALID_ENUM, + "Invalid attachment when the default framebuffer is not bound")); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid attachment")); return false; } } @@ -2337,7 +2391,7 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context, { if (!context->getExtensions().eglImage && !context->getExtensions().eglImageExternal) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2347,19 +2401,19 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context, break; default: - context->recordError(Error(GL_INVALID_ENUM, "invalid texture target.")); + context->handleError(Error(GL_INVALID_ENUM, "invalid texture target.")); return false; } if (!display->isValidImage(image)) { - context->recordError(Error(GL_INVALID_VALUE, "EGL image is not valid.")); + context->handleError(Error(GL_INVALID_VALUE, "EGL image is not valid.")); return false; } if (image->getSamples() > 0) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "cannot create a 2D texture from a multisampled EGL image.")); return false; } @@ -2367,7 +2421,7 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context, const TextureCaps &textureCaps = context->getTextureCaps().get(image->getInternalFormat()); if (!textureCaps.texturable) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "EGL image internal format is not supported as a texture.")); return false; } @@ -2382,7 +2436,7 @@ bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context, { if (!context->getExtensions().eglImage) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2392,20 +2446,20 @@ bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context, break; default: - context->recordError(Error(GL_INVALID_ENUM, "invalid renderbuffer target.")); + context->handleError(Error(GL_INVALID_ENUM, "invalid renderbuffer target.")); return false; } if (!display->isValidImage(image)) { - context->recordError(Error(GL_INVALID_VALUE, "EGL image is not valid.")); + context->handleError(Error(GL_INVALID_VALUE, "EGL image is not valid.")); return false; } const TextureCaps &textureCaps = context->getTextureCaps().get(image->getInternalFormat()); if (!textureCaps.renderable) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "EGL image internal format is not supported as a renderbuffer.")); return false; } @@ -2419,7 +2473,7 @@ bool ValidateBindVertexArrayBase(Context *context, GLuint array) { // The default VAO should always exist ASSERT(array != 0); - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2431,7 +2485,7 @@ bool ValidateLinkProgram(Context *context, GLuint program) if (context->hasActiveTransformFeedback(program)) { // ES 3.0.4 section 2.15 page 91 - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "Cannot link program while program is associated with an active " "transform feedback object.")); return false; @@ -2455,14 +2509,14 @@ bool ValidateProgramBinaryBase(Context *context, if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end()) { - context->recordError(Error(GL_INVALID_ENUM, "Program binary format is not valid.")); + context->handleError(Error(GL_INVALID_ENUM, "Program binary format is not valid.")); return false; } if (context->hasActiveTransformFeedback(program)) { // ES 3.0.4 section 2.15 page 91 - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "Cannot change program binary while program is associated with " "an active transform feedback object.")); return false; @@ -2486,7 +2540,7 @@ bool ValidateGetProgramBinaryBase(Context *context, if (!programObject->isLinked()) { - context->recordError(Error(GL_INVALID_OPERATION, "Program is not linked.")); + context->handleError(Error(GL_INVALID_OPERATION, "Program is not linked.")); return false; } @@ -2503,27 +2557,27 @@ bool ValidateUseProgram(Context *context, GLuint program) // ES 3.1.0 section 7.3 page 72 if (context->getShader(program)) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Attempted to use a single shader instead of a shader program.")); return false; } else { - context->recordError(Error(GL_INVALID_VALUE, "Program invalid.")); + context->handleError(Error(GL_INVALID_VALUE, "Program invalid.")); return false; } } if (!programObject->isLinked()) { - context->recordError(Error(GL_INVALID_OPERATION, "Program not linked.")); + context->handleError(Error(GL_INVALID_OPERATION, "Program not linked.")); return false; } } if (context->getState().isTransformFeedbackActiveUnpaused()) { // ES 3.0.4 section 2.15 page 91 - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Cannot change active program while transform feedback is unpaused.")); return false; @@ -2562,7 +2616,7 @@ bool ValidateFramebufferRenderbuffer(Context *context, if (!ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -2575,7 +2629,7 @@ bool ValidateDrawBuffersBase(ValidationContext *context, GLsizei n, const GLenum // INVALID_VALUE is generated if n is negative or greater than value of MAX_DRAW_BUFFERS if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "n must be non-negative and no greater than MAX_DRAW_BUFFERS")); return false; } @@ -2600,12 +2654,12 @@ bool ValidateDrawBuffersBase(ValidationContext *context, GLsizei n, const GLenum // was changed to GL_INVALID_ENUM in 3.1, which dEQP also expects. // 3.1 is still a bit ambiguous about the error, but future specs are // expected to clarify that GL_INVALID_ENUM is the correct error. - context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer value")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer value")); return false; } else if (bufs[colorAttachment] >= maxColorAttachment) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Buffer value is greater than MAX_DRAW_BUFFERS")); return false; } @@ -2614,7 +2668,7 @@ bool ValidateDrawBuffersBase(ValidationContext *context, GLsizei n, const GLenum { // INVALID_OPERATION-GL is bound to buffer and ith argument // is not COLOR_ATTACHMENTi or NONE - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Ith value does not match COLOR_ATTACHMENTi or NONE")); return false; } @@ -2626,14 +2680,14 @@ bool ValidateDrawBuffersBase(ValidationContext *context, GLsizei n, const GLenum { if (n != 1) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "n must be 1 when GL is bound to the default framebuffer")); return false; } if (bufs[0] != GL_NONE && bufs[0] != GL_BACK) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "Only NONE or BACK are valid values when drawing to the default framebuffer")); return false; @@ -2667,13 +2721,13 @@ bool ValidateGetBufferPointervBase(Context *context, GLenum target, GLenum pname { if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Buffer target not valid: 0x%X", target)); + context->handleError(Error(GL_INVALID_ENUM, "Buffer target not valid: 0x%X", target)); return false; } if (pname != GL_BUFFER_MAP_POINTER) { - context->recordError(Error(GL_INVALID_ENUM, "pname not valid: 0x%X", pname)); + context->handleError(Error(GL_INVALID_ENUM, "pname not valid: 0x%X", pname)); return false; } @@ -2684,7 +2738,7 @@ bool ValidateGetBufferPointervBase(Context *context, GLenum target, GLenum pname // GLES 3.1 section 6.6 explicitly specifies this error. if (!buffer) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Can not get pointer for reserved buffer name zero.")); return false; } @@ -2696,7 +2750,7 @@ bool ValidateUnmapBufferBase(Context *context, GLenum target) { if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); return false; } @@ -2704,7 +2758,7 @@ bool ValidateUnmapBufferBase(Context *context, GLenum target) if (buffer == nullptr || !buffer->isMapped()) { - context->recordError(Error(GL_INVALID_OPERATION, "Buffer not mapped.")); + context->handleError(Error(GL_INVALID_OPERATION, "Buffer not mapped.")); return false; } @@ -2719,13 +2773,13 @@ bool ValidateMapBufferRangeBase(Context *context, { if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); return false; } if (offset < 0 || length < 0) { - context->recordError(Error(GL_INVALID_VALUE, "Invalid offset or length.")); + context->handleError(Error(GL_INVALID_VALUE, "Invalid offset or length.")); return false; } @@ -2733,7 +2787,7 @@ bool ValidateMapBufferRangeBase(Context *context, if (!buffer) { - context->recordError(Error(GL_INVALID_OPERATION, "Attempted to map buffer object zero.")); + context->handleError(Error(GL_INVALID_OPERATION, "Attempted to map buffer object zero.")); return false; } @@ -2744,7 +2798,7 @@ bool ValidateMapBufferRangeBase(Context *context, if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || offsetSize + lengthSize > static_cast<size_t>(buffer->getSize())) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "Mapped range does not fit into buffer dimensions.")); return false; } @@ -2756,26 +2810,26 @@ bool ValidateMapBufferRangeBase(Context *context, if (access & ~(allAccessBits)) { - context->recordError(Error(GL_INVALID_VALUE, "Invalid access bits: 0x%X.", access)); + context->handleError(Error(GL_INVALID_VALUE, "Invalid access bits: 0x%X.", access)); return false; } if (length == 0) { - context->recordError(Error(GL_INVALID_OPERATION, "Buffer mapping length is zero.")); + context->handleError(Error(GL_INVALID_OPERATION, "Buffer mapping length is zero.")); return false; } if (buffer->isMapped()) { - context->recordError(Error(GL_INVALID_OPERATION, "Buffer is already mapped.")); + context->handleError(Error(GL_INVALID_OPERATION, "Buffer is already mapped.")); return false; } // Check for invalid bit combinations if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Need to map buffer for either reading or writing.")); return false; } @@ -2785,7 +2839,7 @@ bool ValidateMapBufferRangeBase(Context *context, if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "Invalid access bits when mapping buffer for reading: 0x%X.", access)); return false; @@ -2793,7 +2847,7 @@ bool ValidateMapBufferRangeBase(Context *context, if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "The explicit flushing bit may only be set if the buffer is mapped for writing.")); return false; @@ -2808,13 +2862,13 @@ bool ValidateFlushMappedBufferRangeBase(Context *context, { if (offset < 0 || length < 0) { - context->recordError(Error(GL_INVALID_VALUE, "Invalid offset/length parameters.")); + context->handleError(Error(GL_INVALID_VALUE, "Invalid offset/length parameters.")); return false; } if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); return false; } @@ -2822,13 +2876,13 @@ bool ValidateFlushMappedBufferRangeBase(Context *context, if (buffer == nullptr) { - context->recordError(Error(GL_INVALID_OPERATION, "Attempted to flush buffer object zero.")); + context->handleError(Error(GL_INVALID_OPERATION, "Attempted to flush buffer object zero.")); return false; } if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "Attempted to flush a buffer not mapped for explicit flushing.")); return false; } @@ -2840,7 +2894,7 @@ bool ValidateFlushMappedBufferRangeBase(Context *context, if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength())) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "Flushed range does not fit into buffer mapping dimensions.")); return false; } @@ -2892,7 +2946,7 @@ bool ValidateGenOrDelete(Context *context, GLint n) { if (n < 0) { - context->recordError(Error(GL_INVALID_VALUE, "n < 0")); + context->handleError(Error(GL_INVALID_VALUE, "n < 0")); return false; } return true; diff --git a/chromium/third_party/angle/src/libANGLE/validationES.h b/chromium/third_party/angle/src/libANGLE/validationES.h index c36b1eeba5d..91edaa418de 100644 --- a/chromium/third_party/angle/src/libANGLE/validationES.h +++ b/chromium/third_party/angle/src/libANGLE/validationES.h @@ -31,6 +31,7 @@ bool ValidCap(const Context *context, GLenum cap); bool ValidTextureTarget(const ValidationContext *context, GLenum target); bool ValidTexture2DTarget(const ValidationContext *context, GLenum target); bool ValidTexture3DTarget(const ValidationContext *context, GLenum target); +bool ValidTextureExternalTarget(const ValidationContext *context, GLenum target); bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum target); bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target); bool ValidFramebufferTarget(GLenum target); @@ -83,7 +84,7 @@ bool ValidateBlitFramebufferParameters(Context *context, bool ValidateGetVertexAttribParameters(Context *context, GLenum pname); -bool ValidateTexParamParameters(Context *context, GLenum pname, GLint param); +bool ValidateTexParamParameters(Context *context, GLenum target, GLenum pname, GLint param); bool ValidateSamplerObjectParameter(Context *context, GLenum pname); diff --git a/chromium/third_party/angle/src/libANGLE/validationES2.cpp b/chromium/third_party/angle/src/libANGLE/validationES2.cpp index a8266b96393..6e38100185d 100644 --- a/chromium/third_party/angle/src/libANGLE/validationES2.cpp +++ b/chromium/third_party/angle/src/libANGLE/validationES2.cpp @@ -15,6 +15,7 @@ #include "libANGLE/Renderbuffer.h" #include "libANGLE/formatutils.h" #include "libANGLE/FramebufferAttachment.h" +#include "libANGLE/Uniform.h" #include "common/mathutil.h" #include "common/utilities.h" @@ -64,13 +65,13 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, { if (!ValidTexture2DDestinationTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (!ValidImageSizeParameters(context, target, level, width, height, 1, isSubImage)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -78,13 +79,13 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (!isSubImage && !isCompressed && internalformat != format) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -95,7 +96,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) || static_cast<GLuint>(height) > (caps.max2DTextureSize >> level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -103,27 +104,27 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, { if (!isSubImage && width != height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (static_cast<GLuint>(width) > (caps.maxCubeMapTextureSize >> level) || static_cast<GLuint>(height) > (caps.maxCubeMapTextureSize >> level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } gl::Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); if (!texture) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -133,7 +134,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, { if (gl::GetSizedInternalFormat(format, type) != texture->getInternalFormat(target, level)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -141,7 +142,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, if (static_cast<size_t>(xoffset + width) > texture->getWidth(target, level) || static_cast<size_t>(yoffset + height) > texture->getHeight(target, level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -149,7 +150,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, { if (texture->getImmutableFormat()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -157,7 +158,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, // Verify zero border if (border != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -171,47 +172,47 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: if (!context->getExtensions().textureCompressionDXT1) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: if (!context->getExtensions().textureCompressionDXT1) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: if (!context->getExtensions().textureCompressionDXT5) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_OES: if (!context->getExtensions().compressedETC1RGB8Texture) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: if (!context->getExtensions().lossyETCDecode) { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "ANGLE_lossy_etc_decode extension is not supported")); return false; } break; default: - context->recordError(Error( + context->handleError(Error( GL_INVALID_ENUM, "internalformat is not a supported compressed internal format")); return false; } if (!ValidCompressedImageSize(context, actualInternalFormat, width, height)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -231,7 +232,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_FLOAT: break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -250,7 +251,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_HALF_FLOAT_OES: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -258,7 +259,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_RG: if (!context->getExtensions().textureRG) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } switch (type) @@ -268,7 +269,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_HALF_FLOAT_OES: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -281,7 +282,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_HALF_FLOAT_OES: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -295,7 +296,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_HALF_FLOAT_OES: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -305,7 +306,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_UNSIGNED_BYTE: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -313,7 +314,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_SRGB_ALPHA_EXT: if (!context->getExtensions().sRGB) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } switch (type) @@ -321,7 +322,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_UNSIGNED_BYTE: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -337,7 +338,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_UNSIGNED_INT: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -347,12 +348,12 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_UNSIGNED_INT_24_8_OES: break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -362,62 +363,62 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: if (context->getExtensions().textureCompressionDXT1) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: if (context->getExtensions().textureCompressionDXT3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: if (context->getExtensions().textureCompressionDXT5) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_OES: if (context->getExtensions().compressedETC1RGB8Texture) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: if (context->getExtensions().lossyETCDecode) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "ETC1_RGB8_LOSSY_DECODE_ANGLE can't work with this type.")); return false; } else { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "ANGLE_lossy_etc_decode extension is not supported.")); return false; } @@ -426,19 +427,19 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, case GL_DEPTH_STENCIL_OES: if (!context->getExtensions().depthTextures) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (target != GL_TEXTURE_2D) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } // OES_depth_texture supports loading depth data and multiple levels, // but ANGLE_depth_texture does not if (pixels != NULL || level != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -450,7 +451,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, { if (!context->getExtensions().textureFloat) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } } @@ -458,7 +459,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, { if (!context->getExtensions().textureHalfFloat) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } } @@ -484,7 +485,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, if (!ValidTexture2DDestinationTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid texture target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return false; } @@ -510,7 +511,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -523,7 +524,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -540,7 +541,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGB32F && colorbufferFormat != GL_RGBA32F) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -555,7 +556,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGB32F && colorbufferFormat != GL_RGBA32F) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -568,7 +569,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGB32F && colorbufferFormat != GL_RGBA32F) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -579,7 +580,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGBA32F) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -589,21 +590,21 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: case GL_ETC1_RGB8_OES: case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; case GL_DEPTH_COMPONENT: case GL_DEPTH_STENCIL_OES: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (internalFormatInfo.type == GL_FLOAT && !context->getExtensions().textureFloat) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -619,7 +620,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -634,7 +635,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -649,7 +650,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -663,7 +664,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -676,7 +677,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -688,7 +689,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -696,61 +697,61 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: if (context->getExtensions().textureCompressionDXT1) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: if (context->getExtensions().textureCompressionDXT3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: if (context->getExtensions().textureCompressionDXT5) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_OES: if (context->getExtensions().compressedETC1RGB8Texture) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: if (context->getExtensions().lossyETCDecode) { - context->recordError(Error(GL_INVALID_OPERATION, + context->handleError(Error(GL_INVALID_OPERATION, "ETC1_RGB8_LOSSY_DECODE_ANGLE can't be copied to.")); return false; } else { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "ANGLE_lossy_etc_decode extension is not supported.")); return false; } @@ -762,16 +763,16 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, case GL_DEPTH24_STENCIL8_OES: if (context->getExtensions().depthTextures) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } else { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } } @@ -785,32 +786,32 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le { if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (width < 1 || height < 1 || levels < 1) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (target == GL_TEXTURE_CUBE_MAP && width != height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); if (formatInfo.format == GL_NONE || formatInfo.type == GL_NONE) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -822,7 +823,7 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le if (static_cast<GLuint>(width) > caps.max2DTextureSize || static_cast<GLuint>(height) > caps.max2DTextureSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; @@ -830,12 +831,12 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le if (static_cast<GLuint>(width) > caps.maxCubeMapTextureSize || static_cast<GLuint>(height) > caps.maxCubeMapTextureSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -843,7 +844,7 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le { if (!gl::isPow2(width) || !gl::isPow2(height)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -854,35 +855,35 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: if (!context->getExtensions().textureCompressionDXT1) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: if (!context->getExtensions().textureCompressionDXT3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: if (!context->getExtensions().textureCompressionDXT5) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_OES: if (!context->getExtensions().compressedETC1RGB8Texture) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: if (!context->getExtensions().lossyETCDecode) { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "ANGLE_lossy_etc_decode extension is not supported.")); return false; } @@ -894,7 +895,7 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le case GL_LUMINANCE_ALPHA32F_EXT: if (!context->getExtensions().textureFloat) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -905,7 +906,7 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le case GL_LUMINANCE_ALPHA16F_EXT: if (!context->getExtensions().textureHalfFloat) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -917,7 +918,7 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le case GL_RG32F_EXT: if (!context->getExtensions().textureRG) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } break; @@ -926,18 +927,18 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le case GL_DEPTH24_STENCIL8_OES: if (!context->getExtensions().depthTextures) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (target != GL_TEXTURE_2D) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } // ANGLE_depth_texture only supports 1-level textures if (levels != 1) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } break; @@ -948,13 +949,13 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le gl::Texture *texture = context->getTargetTexture(target); if (!texture || texture->id() == 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (texture->getImmutableFormat()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1012,7 +1013,7 @@ bool ValidateDiscardFramebufferEXT(Context *context, GLenum target, GLsizei numA { if (!context->getExtensions().discardFramebuffer) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1024,7 +1025,7 @@ bool ValidateDiscardFramebufferEXT(Context *context, GLenum target, GLsizei numA defaultFramebuffer = (context->getState().getTargetFramebuffer(GL_FRAMEBUFFER)->id() == 0); break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid framebuffer target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid framebuffer target")); return false; } @@ -1035,7 +1036,7 @@ bool ValidateBindVertexArrayOES(Context *context, GLuint array) { if (!context->getExtensions().vertexArrayObject) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1046,7 +1047,7 @@ bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n) { if (!context->getExtensions().vertexArrayObject) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1057,7 +1058,7 @@ bool ValidateGenVertexArraysOES(Context *context, GLsizei n) { if (!context->getExtensions().vertexArrayObject) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1068,7 +1069,7 @@ bool ValidateIsVertexArrayOES(Context *context) { if (!context->getExtensions().vertexArrayObject) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1083,7 +1084,7 @@ bool ValidateProgramBinaryOES(Context *context, { if (!context->getExtensions().getProgramBinary) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1099,7 +1100,7 @@ bool ValidateGetProgramBinaryOES(Context *context, { if (!context->getExtensions().getProgramBinary) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1171,25 +1172,25 @@ bool ValidateDebugMessageControlKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } if (!ValidDebugSource(source, false) && source != GL_DONT_CARE) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug source.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug source.")); return false; } if (!ValidDebugType(type) && type != GL_DONT_CARE) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug type.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug type.")); return false; } if (!ValidDebugSeverity(severity) && severity != GL_DONT_CARE) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug severity.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug severity.")); return false; } @@ -1197,7 +1198,7 @@ bool ValidateDebugMessageControlKHR(Context *context, { if (source == GL_DONT_CARE || type == GL_DONT_CARE) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "If count is greater than zero, source and severity cannot be GL_DONT_CARE.")); return false; @@ -1205,7 +1206,7 @@ bool ValidateDebugMessageControlKHR(Context *context, if (severity != GL_DONT_CARE) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "If count is greater than zero, severity must be GL_DONT_CARE.")); return false; @@ -1225,7 +1226,7 @@ bool ValidateDebugMessageInsertKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1238,26 +1239,26 @@ bool ValidateDebugMessageInsertKHR(Context *context, if (!ValidDebugSeverity(severity)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug severity.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug severity.")); return false; } if (!ValidDebugType(type)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug type.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug type.")); return false; } if (!ValidDebugSource(source, true)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug source.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug source.")); return false; } size_t messageLength = (length < 0) ? strlen(buf) : length; if (messageLength > context->getExtensions().maxDebugMessageLength) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "Message length is larger than GL_MAX_DEBUG_MESSAGE_LENGTH.")); return false; } @@ -1271,7 +1272,7 @@ bool ValidateDebugMessageCallbackKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1290,13 +1291,13 @@ bool ValidateGetDebugMessageLogKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } if (bufSize < 0 && messageLog != nullptr) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "bufSize must be positive if messageLog is not null.")); return false; } @@ -1312,20 +1313,20 @@ bool ValidatePushDebugGroupKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } if (!ValidDebugSource(source, true)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid debug source.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid debug source.")); return false; } size_t messageLength = (length < 0) ? strlen(message) : length; if (messageLength > context->getExtensions().maxDebugMessageLength) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "Message length is larger than GL_MAX_DEBUG_MESSAGE_LENGTH.")); return false; } @@ -1333,7 +1334,7 @@ bool ValidatePushDebugGroupKHR(Context *context, size_t currentStackSize = context->getState().getDebug().getGroupStackDepth(); if (currentStackSize >= context->getExtensions().maxDebugGroupStackDepth) { - context->recordError( + context->handleError( Error(GL_STACK_OVERFLOW, "Cannot push more than GL_MAX_DEBUG_GROUP_STACK_DEPTH debug groups.")); return false; @@ -1346,14 +1347,14 @@ bool ValidatePopDebugGroupKHR(Context *context) { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } size_t currentStackSize = context->getState().getDebug().getGroupStackDepth(); if (currentStackSize <= 1) { - context->recordError(Error(GL_STACK_UNDERFLOW, "Cannot pop the default debug group.")); + context->handleError(Error(GL_STACK_UNDERFLOW, "Cannot pop the default debug group.")); return false; } @@ -1367,7 +1368,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_BUFFER: if (context->getBuffer(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid buffer.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid buffer.")); return false; } return true; @@ -1375,7 +1376,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_SHADER: if (context->getShader(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid shader.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid shader.")); return false; } return true; @@ -1383,7 +1384,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_PROGRAM: if (context->getProgram(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid program.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid program.")); return false; } return true; @@ -1391,7 +1392,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_VERTEX_ARRAY: if (context->getVertexArray(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid vertex array.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid vertex array.")); return false; } return true; @@ -1399,7 +1400,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_QUERY: if (context->getQuery(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid query.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid query.")); return false; } return true; @@ -1407,7 +1408,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_TRANSFORM_FEEDBACK: if (context->getTransformFeedback(name) == nullptr) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "name is not a valid transform feedback.")); return false; } @@ -1416,7 +1417,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_SAMPLER: if (context->getSampler(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid sampler.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid sampler.")); return false; } return true; @@ -1424,7 +1425,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_TEXTURE: if (context->getTexture(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid texture.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid texture.")); return false; } return true; @@ -1432,7 +1433,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_RENDERBUFFER: if (context->getRenderbuffer(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid renderbuffer.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid renderbuffer.")); return false; } return true; @@ -1440,13 +1441,13 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, case GL_FRAMEBUFFER: if (context->getFramebuffer(name) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid framebuffer.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid framebuffer.")); return false; } return true; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid identifier.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid identifier.")); return false; } @@ -1461,7 +1462,7 @@ bool ValidateObjectLabelKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1473,7 +1474,7 @@ bool ValidateObjectLabelKHR(Context *context, size_t labelLength = (length < 0) ? strlen(label) : length; if (labelLength > context->getExtensions().maxLabelLength) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "Label length is larger than GL_MAX_LABEL_LENGTH.")); return false; } @@ -1490,13 +1491,13 @@ bool ValidateGetObjectLabelKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } if (bufSize < 0) { - context->recordError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); + context->handleError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); return false; } @@ -1513,7 +1514,7 @@ static bool ValidateObjectPtrName(Context *context, const void *ptr) { if (context->getFenceSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))) == nullptr) { - context->recordError(Error(GL_INVALID_VALUE, "name is not a valid sync.")); + context->handleError(Error(GL_INVALID_VALUE, "name is not a valid sync.")); return false; } @@ -1527,7 +1528,7 @@ bool ValidateObjectPtrLabelKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1539,7 +1540,7 @@ bool ValidateObjectPtrLabelKHR(Context *context, size_t labelLength = (length < 0) ? strlen(label) : length; if (labelLength > context->getExtensions().maxLabelLength) { - context->recordError( + context->handleError( Error(GL_INVALID_VALUE, "Label length is larger than GL_MAX_LABEL_LENGTH.")); return false; } @@ -1555,13 +1556,13 @@ bool ValidateGetObjectPtrLabelKHR(Context *context, { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } if (bufSize < 0) { - context->recordError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); + context->handleError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); return false; } @@ -1578,7 +1579,7 @@ bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params) { if (!context->getExtensions().debug) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return false; } @@ -1590,7 +1591,7 @@ bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params) break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid pname.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid pname.")); return false; } @@ -1611,14 +1612,14 @@ bool ValidateBlitFramebufferANGLE(Context *context, { if (!context->getExtensions().framebufferBlit) { - context->recordError(Error(GL_INVALID_OPERATION, "Blit extension not available.")); + context->handleError(Error(GL_INVALID_OPERATION, "Blit extension not available.")); return false; } if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) { // TODO(jmadill): Determine if this should be available on other implementations. - context->recordError(Error( + context->handleError(Error( GL_INVALID_OPERATION, "Scaling and flipping in BlitFramebufferANGLE not supported by this implementation.")); return false; @@ -1626,7 +1627,7 @@ bool ValidateBlitFramebufferANGLE(Context *context, if (filter == GL_LINEAR) { - context->recordError(Error(GL_INVALID_ENUM, "Linear blit not supported in this extension")); + context->handleError(Error(GL_INVALID_ENUM, "Linear blit not supported in this extension")); return false; } @@ -1645,7 +1646,7 @@ bool ValidateBlitFramebufferANGLE(Context *context, readColorAttachment->type() != GL_RENDERBUFFER && readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1661,14 +1662,14 @@ bool ValidateBlitFramebufferANGLE(Context *context, attachment->type() != GL_RENDERBUFFER && attachment->type() != GL_FRAMEBUFFER_DEFAULT) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } // Return an error if the destination formats do not match if (attachment->getInternalFormat() != readColorAttachment->getInternalFormat()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1680,7 +1681,7 @@ bool ValidateBlitFramebufferANGLE(Context *context, IsPartialBlit(context, readColorAttachment, drawColorAttachment, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1706,13 +1707,13 @@ bool ValidateBlitFramebufferANGLE(Context *context, ERR( "Only whole-buffer depth and stencil blits are supported by this " "implementation."); - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (readBuffer->getSamples() != 0 || drawBuffer->getSamples() != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1730,13 +1731,13 @@ bool ValidateClear(ValidationContext *context, GLbitfield mask) if (framebufferObject->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1747,7 +1748,7 @@ bool ValidateDrawBuffersEXT(ValidationContext *context, GLsizei n, const GLenum { if (!context->getExtensions().drawBuffers) { - context->recordError(Error(GL_INVALID_OPERATION, "Extension not supported.")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not supported.")); return false; } @@ -1833,7 +1834,7 @@ bool ValidateCompressedTexImage2D(Context *context, static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1875,7 +1876,7 @@ bool ValidateCompressedTexSubImage2D(Context *context, static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1886,7 +1887,7 @@ bool ValidateGetBufferPointervOES(Context *context, GLenum target, GLenum pname, { if (!context->getExtensions().mapBuffer) { - context->recordError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); + context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); return false; } @@ -1897,13 +1898,13 @@ bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access) { if (!context->getExtensions().mapBuffer) { - context->recordError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); + context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); return false; } if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); return false; } @@ -1911,19 +1912,19 @@ bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access) if (buffer == nullptr) { - context->recordError(Error(GL_INVALID_OPERATION, "Attempted to map buffer object zero.")); + context->handleError(Error(GL_INVALID_OPERATION, "Attempted to map buffer object zero.")); return false; } if (access != GL_WRITE_ONLY_OES) { - context->recordError(Error(GL_INVALID_ENUM, "Non-write buffer mapping not supported.")); + context->handleError(Error(GL_INVALID_ENUM, "Non-write buffer mapping not supported.")); return false; } if (buffer->isMapped()) { - context->recordError(Error(GL_INVALID_OPERATION, "Buffer is already mapped.")); + context->handleError(Error(GL_INVALID_OPERATION, "Buffer is already mapped.")); return false; } @@ -1934,7 +1935,7 @@ bool ValidateUnmapBufferOES(Context *context, GLenum target) { if (!context->getExtensions().mapBuffer) { - context->recordError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); + context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); return false; } @@ -1949,7 +1950,7 @@ bool ValidateMapBufferRangeEXT(Context *context, { if (!context->getExtensions().mapBufferRange) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Map buffer range extension not available.")); return false; } @@ -1964,7 +1965,7 @@ bool ValidateFlushMappedBufferRangeEXT(Context *context, { if (!context->getExtensions().mapBufferRange) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Map buffer range extension not available.")); return false; } @@ -1977,7 +1978,7 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture) Texture *textureObject = context->getTexture(texture); if (textureObject && textureObject->getTarget() != target && texture != 0) { - context->recordError(Error(GL_INVALID_OPERATION, "Invalid texture")); + context->handleError(Error(GL_INVALID_OPERATION, "Invalid texture")); return false; } @@ -1991,20 +1992,88 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture) case GL_TEXTURE_2D_ARRAY: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM, "GLES 3.0 disabled")); + context->handleError(Error(GL_INVALID_ENUM, "GLES 3.0 disabled")); return false; } break; case GL_TEXTURE_EXTERNAL_OES: if (!context->getExtensions().eglStreamConsumerExternal) { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "External texture extension not enabled")); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid target")); + return false; + } + + return true; +} + +bool ValidateBindUniformLocationCHROMIUM(Context *context, + GLuint program, + GLint location, + const GLchar *name) +{ + if (!context->getExtensions().bindUniformLocation) + { + context->handleError( + Error(GL_INVALID_OPERATION, "GL_CHROMIUM_bind_uniform_location is not available.")); + return false; + } + + Program *programObject = GetValidProgram(context, program); + if (!programObject) + { + return false; + } + + if (location < 0) + { + context->handleError(Error(GL_INVALID_VALUE, "Location cannot be less than 0.")); + return false; + } + + const Caps &caps = context->getCaps(); + if (static_cast<size_t>(location) >= + (caps.maxVertexUniformVectors + caps.maxFragmentUniformVectors) * 4) + { + context->handleError(Error(GL_INVALID_VALUE, + "Location must be less than (MAX_VERTEX_UNIFORM_VECTORS + " + "MAX_FRAGMENT_UNIFORM_VECTORS) * 4")); + return false; + } + + if (strncmp(name, "gl_", 3) == 0) + { + context->handleError( + Error(GL_INVALID_OPERATION, "Name cannot start with the reserved \"gl_\" prefix.")); + return false; + } + + return true; +} + +bool ValidateCoverageModulationCHROMIUM(Context* context, GLenum components) +{ + if (!context->getExtensions().framebufferMixedSamples) + { + context->handleError( + Error(GL_INVALID_OPERATION, "GL_CHROMIUM_framebuffer_mixed_samples is not available.")); + return false; + } + switch (components) + { + case GL_RGB: + case GL_RGBA: + case GL_ALPHA: + case GL_NONE: + break; + default: + context->handleError( + Error(GL_INVALID_ENUM, "GLenum components is not one of GL_RGB, GL_RGBA, GL_ALPHA or GL_NONE.")); return false; } diff --git a/chromium/third_party/angle/src/libANGLE/validationES2.h b/chromium/third_party/angle/src/libANGLE/validationES2.h index 9acfec1828f..4b6db66593a 100644 --- a/chromium/third_party/angle/src/libANGLE/validationES2.h +++ b/chromium/third_party/angle/src/libANGLE/validationES2.h @@ -183,6 +183,13 @@ bool ValidateFlushMappedBufferRangeEXT(Context *context, GLintptr offset, GLsizeiptr length); +bool ValidateBindUniformLocationCHROMIUM(Context *context, + GLuint program, + GLint location, + const GLchar *name); + +bool ValidateCoverageModulationCHROMIUM(Context* context, GLenum components); + } // namespace gl #endif // LIBANGLE_VALIDATION_ES2_H_ diff --git a/chromium/third_party/angle/src/libANGLE/validationES3.cpp b/chromium/third_party/angle/src/libANGLE/validationES3.cpp index c879ea5b797..c097059daee 100644 --- a/chromium/third_party/angle/src/libANGLE/validationES3.cpp +++ b/chromium/third_party/angle/src/libANGLE/validationES3.cpp @@ -209,7 +209,7 @@ static bool ValidateTexImageFormatCombination(gl::Context *context, GLenum inter const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -243,7 +243,7 @@ static bool ValidateTexImageFormatCombination(gl::Context *context, GLenum inter if (!typeSupported || !formatSupported) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -255,7 +255,7 @@ static bool ValidateTexImageFormatCombination(gl::Context *context, GLenum inter if (es3FormatSet.find(searchFormat) == es3FormatSet.end()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -282,14 +282,14 @@ bool ValidateES3TexImageParametersBase(Context *context, // Validate image size if (!ValidImageSizeParameters(context, target, level, width, height, depth, isSubImage)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } // Verify zero border if (border != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -298,7 +298,7 @@ bool ValidateES3TexImageParametersBase(Context *context, std::numeric_limits<GLsizei>::max() - yoffset < height || std::numeric_limits<GLsizei>::max() - zoffset < depth) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -310,7 +310,7 @@ bool ValidateES3TexImageParametersBase(Context *context, if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) || static_cast<GLuint>(height) > (caps.max2DTextureSize >> level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; @@ -323,13 +323,13 @@ bool ValidateES3TexImageParametersBase(Context *context, case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: if (!isSubImage && width != height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (static_cast<GLuint>(width) > (caps.maxCubeMapTextureSize >> level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; @@ -339,7 +339,7 @@ bool ValidateES3TexImageParametersBase(Context *context, static_cast<GLuint>(height) > (caps.max3DTextureSize >> level) || static_cast<GLuint>(depth) > (caps.max3DTextureSize >> level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; @@ -349,26 +349,26 @@ bool ValidateES3TexImageParametersBase(Context *context, static_cast<GLuint>(height) > (caps.max2DTextureSize >> level) || static_cast<GLuint>(depth) > caps.maxArrayTextureLayers) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } gl::Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); if (!texture) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (texture->getImmutableFormat() && !isSubImage) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -379,26 +379,26 @@ bool ValidateES3TexImageParametersBase(Context *context, { if (!actualFormatInfo.compressed) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_ENUM, "internalformat is not a supported compressed internal format.")); return false; } if (!ValidCompressedImageSize(context, actualInternalFormat, width, height)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (!actualFormatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (target == GL_TEXTURE_3D) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -411,7 +411,7 @@ bool ValidateES3TexImageParametersBase(Context *context, if (target == GL_TEXTURE_3D && (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -421,7 +421,7 @@ bool ValidateES3TexImageParametersBase(Context *context, { if (isCompressed != actualFormatInfo.compressed) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -432,7 +432,7 @@ bool ValidateES3TexImageParametersBase(Context *context, if (xoffset < 0 || yoffset < 0 || zoffset < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -440,7 +440,7 @@ bool ValidateES3TexImageParametersBase(Context *context, std::numeric_limits<GLsizei>::max() - yoffset < height || std::numeric_limits<GLsizei>::max() - zoffset < depth) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -448,7 +448,7 @@ bool ValidateES3TexImageParametersBase(Context *context, static_cast<size_t>(yoffset + height) > texture->getHeight(target, level) || static_cast<size_t>(zoffset + depth) > texture->getDepth(target, level)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -471,7 +471,7 @@ bool ValidateES3TexImageParametersBase(Context *context, !rx::IsUnsignedMultiplicationSafe(widthSize * heightSize * depthSize, pixelBytes)) { // Overflow past the end of the buffer - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -483,7 +483,7 @@ bool ValidateES3TexImageParametersBase(Context *context, ((offset + copyBytes) > static_cast<size_t>(pixelUnpackBuffer->getSize()))) { // Overflow past the end of the buffer - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -495,7 +495,7 @@ bool ValidateES3TexImageParametersBase(Context *context, if ((offset % dataBytesPerPixel) != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -503,7 +503,7 @@ bool ValidateES3TexImageParametersBase(Context *context, // ...the buffer object's data store is currently mapped. if (pixelUnpackBuffer->isMapped()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -530,7 +530,7 @@ bool ValidateES3TexImage2DParameters(Context *context, { if (!ValidTexture2DDestinationTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -558,7 +558,7 @@ bool ValidateES3TexImage3DParameters(Context *context, { if (!ValidTexture3DDestinationTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -728,6 +728,11 @@ static CopyConversionSet BuildValidES3CopyTexImageCombinations() return set; } +static bool EqualOrFirstZero(GLuint first, GLuint second) +{ + return first == 0 || first == second; +} + static bool IsValidES3CopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle) { const InternalFormat &textureInternalFormatInfo = GetInternalFormatInfo(textureInternalFormat); @@ -832,12 +837,17 @@ static bool IsValidES3CopyTexImageCombination(GLenum textureInternalFormat, GLen if (textureInternalFormatInfo.pixelBytes > 0) { - // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination format is sized, - // component sizes of the source and destination formats must exactly match - if (textureInternalFormatInfo.redBits != sourceEffectiveFormat->redBits || - textureInternalFormatInfo.greenBits != sourceEffectiveFormat->greenBits || - textureInternalFormatInfo.blueBits != sourceEffectiveFormat->blueBits || - textureInternalFormatInfo.alphaBits != sourceEffectiveFormat->alphaBits) + // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination + // format is sized, component sizes of the source and destination formats must exactly + // match if the destination format exists. + if (!EqualOrFirstZero(textureInternalFormatInfo.redBits, + sourceEffectiveFormat->redBits) || + !EqualOrFirstZero(textureInternalFormatInfo.greenBits, + sourceEffectiveFormat->greenBits) || + !EqualOrFirstZero(textureInternalFormatInfo.blueBits, + sourceEffectiveFormat->blueBits) || + !EqualOrFirstZero(textureInternalFormatInfo.alphaBits, + sourceEffectiveFormat->alphaBits)) { return false; } @@ -879,13 +889,13 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } if (readFramebufferID != 0 && framebuffer->getSamples(context->getData()) != 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -897,7 +907,7 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, if (!IsValidES3CopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, readFramebufferID)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -906,7 +916,7 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, if (!gl::IsValidES3CopyTexImageCombination(internalformat, colorbufferInternalFormat, readFramebufferID)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -931,7 +941,7 @@ bool ValidateES3CopyTexImage2DParameters(ValidationContext *context, { if (!ValidTexture2DDestinationTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -956,7 +966,7 @@ bool ValidateES3CopyTexImage3DParameters(ValidationContext *context, { if (!ValidTexture3DDestinationTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -975,7 +985,7 @@ bool ValidateES3TexStorageParametersBase(Context *context, { if (width < 1 || height < 1 || depth < 1 || levels < 1) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -987,7 +997,7 @@ bool ValidateES3TexStorageParametersBase(Context *context, if (levels > gl::log2(maxDim) + 1) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1000,7 +1010,7 @@ bool ValidateES3TexStorageParametersBase(Context *context, if (static_cast<GLuint>(width) > caps.max2DTextureSize || static_cast<GLuint>(height) > caps.max2DTextureSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1010,13 +1020,13 @@ bool ValidateES3TexStorageParametersBase(Context *context, { if (width != height) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (static_cast<GLuint>(width) > caps.maxCubeMapTextureSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1028,7 +1038,7 @@ bool ValidateES3TexStorageParametersBase(Context *context, static_cast<GLuint>(height) > caps.max3DTextureSize || static_cast<GLuint>(depth) > caps.max3DTextureSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1040,7 +1050,7 @@ bool ValidateES3TexStorageParametersBase(Context *context, static_cast<GLuint>(height) > caps.max2DTextureSize || static_cast<GLuint>(depth) > caps.maxArrayTextureLayers) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1054,26 +1064,26 @@ bool ValidateES3TexStorageParametersBase(Context *context, gl::Texture *texture = context->getTargetTexture(target); if (!texture || texture->id() == 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (texture->getImmutableFormat()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } if (formatInfo.pixelBytes == 0) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1090,7 +1100,7 @@ bool ValidateES3TexStorage2DParameters(Context *context, { if (!ValidTexture2DTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1108,7 +1118,7 @@ bool ValidateES3TexStorage3DParameters(Context *context, { if (!ValidTexture3DTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1120,7 +1130,7 @@ bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); + context->handleError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); return false; } @@ -1131,7 +1141,7 @@ bool ValidateEndQuery(gl::Context *context, GLenum target) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); + context->handleError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); return false; } @@ -1142,7 +1152,7 @@ bool ValidateGetQueryiv(Context *context, GLenum target, GLenum pname, GLint *pa { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); + context->handleError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); return false; } @@ -1153,7 +1163,7 @@ bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); + context->handleError(Error(GL_INVALID_OPERATION, "GLES version < 3.0")); return false; } @@ -1165,13 +1175,13 @@ bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum att { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } if (layer < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1192,13 +1202,13 @@ bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum att { if (level > gl::log2(caps.max2DTextureSize)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (static_cast<GLuint>(layer) >= caps.maxArrayTextureLayers) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } @@ -1208,27 +1218,27 @@ bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum att { if (level > gl::log2(caps.max3DTextureSize)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (static_cast<GLuint>(layer) >= caps.max3DTextureSize) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } } break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(tex->getInternalFormat(tex->getTarget(), level)); if (internalFormatInfo.compressed) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -1325,7 +1335,7 @@ bool ValidateES3RenderbufferStorageParameters(gl::Context *context, GLenum targe const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) && samples > 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1333,7 +1343,7 @@ bool ValidateES3RenderbufferStorageParameters(gl::Context *context, GLenum targe const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples()) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Samples must not be greater than maximum supported value for the format.")); return false; @@ -1347,7 +1357,8 @@ bool ValidateInvalidateFramebuffer(Context *context, GLenum target, GLsizei numA { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Operation only supported on ES 3.0 and above")); + context->handleError( + Error(GL_INVALID_OPERATION, "Operation only supported on ES 3.0 and above")); return false; } @@ -1363,7 +1374,7 @@ bool ValidateInvalidateFramebuffer(Context *context, GLenum target, GLsizei numA defaultFramebuffer = context->getState().getReadFramebuffer()->id() == 0; break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid framebuffer target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid framebuffer target")); return false; } @@ -1374,14 +1385,14 @@ bool ValidateClearBuffer(ValidationContext *context) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } const gl::Framebuffer *fbo = context->getState().getDrawFramebuffer(); if (!fbo || fbo->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) { - context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } @@ -1399,13 +1410,13 @@ bool ValidateDrawRangeElements(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } if (end < start) { - context->recordError(Error(GL_INVALID_VALUE, "end < start")); + context->handleError(Error(GL_INVALID_VALUE, "end < start")); return false; } @@ -1417,7 +1428,7 @@ bool ValidateDrawRangeElements(Context *context, if (indexRange->end > end || indexRange->start < start) { // GL spec says that behavior in this case is undefined - generating an error is fine. - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Indices are out of the start, end range.")); return false; } @@ -1428,7 +1439,7 @@ bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLu { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1439,7 +1450,7 @@ bool ValidateReadBuffer(Context *context, GLenum src) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1447,7 +1458,7 @@ bool ValidateReadBuffer(Context *context, GLenum src) if (readFBO == nullptr) { - context->recordError(gl::Error(GL_INVALID_OPERATION, "No active read framebuffer.")); + context->handleError(gl::Error(GL_INVALID_OPERATION, "No active read framebuffer.")); return false; } @@ -1458,7 +1469,7 @@ bool ValidateReadBuffer(Context *context, GLenum src) if (src != GL_BACK && (src < GL_COLOR_ATTACHMENT0 || src > GL_COLOR_ATTACHMENT31)) { - context->recordError(gl::Error(GL_INVALID_ENUM, "Unknown enum for 'src' in ReadBuffer")); + context->handleError(gl::Error(GL_INVALID_ENUM, "Unknown enum for 'src' in ReadBuffer")); return false; } @@ -1467,7 +1478,7 @@ bool ValidateReadBuffer(Context *context, GLenum src) if (src != GL_BACK) { const char *errorMsg = "'src' must be GL_NONE or GL_BACK when reading from the default framebuffer."; - context->recordError(gl::Error(GL_INVALID_OPERATION, errorMsg)); + context->handleError(gl::Error(GL_INVALID_OPERATION, errorMsg)); return false; } } @@ -1478,7 +1489,7 @@ bool ValidateReadBuffer(Context *context, GLenum src) if (drawBuffer >= context->getCaps().maxDrawBuffers) { const char *errorMsg = "'src' is greater than MAX_DRAW_BUFFERS."; - context->recordError(gl::Error(GL_INVALID_OPERATION, errorMsg)); + context->handleError(gl::Error(GL_INVALID_OPERATION, errorMsg)); return false; } } @@ -1499,7 +1510,7 @@ bool ValidateCompressedTexImage3D(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1508,14 +1519,14 @@ bool ValidateCompressedTexImage3D(Context *context, static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } // 3D texture target validation if (target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY) { - context->recordError( + context->handleError( Error(GL_INVALID_ENUM, "Must specify a valid 3D texture destination target")); return false; } @@ -1534,7 +1545,7 @@ bool ValidateBindVertexArray(Context *context, GLuint array) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1545,7 +1556,7 @@ bool ValidateIsVertexArray(Context *context) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1560,7 +1571,7 @@ bool ValidateProgramBinary(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1576,7 +1587,7 @@ bool ValidateGetProgramBinary(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1587,7 +1598,7 @@ bool ValidateProgramParameteri(Context *context, GLuint program, GLenum pname, G { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } @@ -1601,14 +1612,14 @@ bool ValidateProgramParameteri(Context *context, GLuint program, GLenum pname, G case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: if (value != GL_FALSE && value != GL_TRUE) { - context->recordError(Error( + context->handleError(Error( GL_INVALID_VALUE, "Invalid value, expected GL_FALSE or GL_TRUE: %i", value)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid pname: 0x%X", pname)); + context->handleError(Error(GL_INVALID_ENUM, "Invalid pname: 0x%X", pname)); return false; } @@ -1629,7 +1640,7 @@ bool ValidateBlitFramebuffer(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1648,7 +1659,7 @@ bool ValidateClearBufferiv(ValidationContext *context, if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; @@ -1656,13 +1667,13 @@ bool ValidateClearBufferiv(ValidationContext *context, case GL_STENCIL: if (drawbuffer != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1680,13 +1691,13 @@ bool ValidateClearBufferuiv(ValidationContext *context, if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1704,7 +1715,7 @@ bool ValidateClearBufferfv(ValidationContext *context, if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; @@ -1712,13 +1723,13 @@ bool ValidateClearBufferfv(ValidationContext *context, case GL_DEPTH: if (drawbuffer != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1736,13 +1747,13 @@ bool ValidateClearBufferfi(ValidationContext *context, case GL_DEPTH_STENCIL: if (drawbuffer != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return false; } @@ -1753,7 +1764,7 @@ bool ValidateDrawBuffers(ValidationContext *context, GLsizei n, const GLenum *bu { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } @@ -1773,7 +1784,7 @@ bool ValidateCopyTexSubImage3D(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1795,7 +1806,7 @@ bool ValidateTexImage3D(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1819,7 +1830,7 @@ bool ValidateTexSubImage3D(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1843,7 +1854,7 @@ bool ValidateCompressedTexSubImage3D(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1852,13 +1863,13 @@ bool ValidateCompressedTexSubImage3D(Context *context, static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } if (!data) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return false; } @@ -1903,7 +1914,7 @@ bool ValidateDeleteTransformFeedbacks(Context *context, GLint n, const GLuint *i if (transformFeedback != nullptr && transformFeedback->isActive()) { // ES 3.0.4 section 2.15.1 page 86 - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Attempt to delete active transform feedback.")); return false; } @@ -1925,7 +1936,7 @@ bool ValidateGenOrDeleteES3(Context *context, GLint n) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } return ValidateGenOrDelete(context, n); @@ -1935,12 +1946,12 @@ bool ValidateGenOrDeleteCountES3(Context *context, GLint count) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } if (count < 0) { - context->recordError(Error(GL_INVALID_VALUE, "count < 0")); + context->handleError(Error(GL_INVALID_VALUE, "count < 0")); return false; } return true; @@ -1950,7 +1961,7 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } switch (primitiveMode) @@ -1961,7 +1972,7 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) break; default: - context->recordError(Error(GL_INVALID_ENUM, "Invalid primitive mode.")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid primitive mode.")); return false; } @@ -1970,7 +1981,7 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) if (transformFeedback->isActive()) { - context->recordError(Error(GL_INVALID_OPERATION, "Transform feedback is already active.")); + context->handleError(Error(GL_INVALID_OPERATION, "Transform feedback is already active.")); return false; } return true; @@ -1980,13 +1991,13 @@ bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, G { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } if (!context->isSampler(sampler)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -1995,7 +2006,7 @@ bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, G return false; } - if (!ValidateTexParamParameters(context, pname, param)) + if (!ValidateTexParamParameters(context, GL_TEXTURE_2D, pname, param)) { return false; } @@ -2013,7 +2024,7 @@ bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GL { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } @@ -2024,7 +2035,7 @@ bool ValidateUnmapBuffer(Context *context, GLenum target) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2039,7 +2050,7 @@ bool ValidateMapBufferRange(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } @@ -2053,7 +2064,7 @@ bool ValidateFlushMappedBufferRange(Context *context, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } diff --git a/chromium/third_party/angle/src/libANGLE/validationES_unittest.cpp b/chromium/third_party/angle/src/libANGLE/validationES_unittest.cpp index ef049f99c26..26ac00abd42 100644 --- a/chromium/third_party/angle/src/libANGLE/validationES_unittest.cpp +++ b/chromium/third_party/angle/src/libANGLE/validationES_unittest.cpp @@ -10,7 +10,7 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include "libANGLE/Data.h" +#include "libANGLE/ContextState.h" #include "libANGLE/renderer/FramebufferImpl_mock.h" #include "libANGLE/renderer/ProgramImpl_mock.h" #include "libANGLE/renderer/TextureImpl_mock.h" @@ -26,14 +26,6 @@ using testing::Return; namespace { -class MockFactory : public NullFactory -{ - public: - MOCK_METHOD1(createFramebuffer, FramebufferImpl *(const gl::Framebuffer::Data &)); - MOCK_METHOD1(createProgram, ProgramImpl *(const gl::Program::Data &)); - MOCK_METHOD1(createVertexArray, VertexArrayImpl *(const gl::VertexArray::Data &)); -}; - class MockValidationContext : public ValidationContext { public: @@ -46,7 +38,7 @@ class MockValidationContext : public ValidationContext const Limitations &limitations, bool skipValidation); - MOCK_METHOD1(recordError, void(const Error &)); + MOCK_METHOD1(handleError, void(const Error &)); }; MockValidationContext::MockValidationContext(GLint clientVersion, @@ -77,7 +69,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) auto programImpl = MakeProgramMock(); // TODO(jmadill): Generalize some of this code so we can re-use it for other tests. - NiceMock<MockFactory> mockFactory; + NiceMock<MockGLFactory> mockFactory; EXPECT_CALL(mockFactory, createFramebuffer(_)).WillOnce(Return(framebufferImpl)); EXPECT_CALL(mockFactory, createProgram(_)).WillOnce(Return(programImpl)); EXPECT_CALL(mockFactory, createVertexArray(_)).WillOnce(Return(nullptr)); @@ -95,10 +87,11 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) state.initialize(caps, extensions, 3, false); NiceMock<MockTextureImpl> *textureImpl = new NiceMock<MockTextureImpl>(); + EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl)); EXPECT_CALL(*textureImpl, setStorage(_, _, _, _)).WillOnce(Return(Error(GL_NO_ERROR))); EXPECT_CALL(*textureImpl, destructor()).Times(1).RetiresOnSaturation(); - Texture *texture = new Texture(textureImpl, 0, GL_TEXTURE_2D); + Texture *texture = new Texture(&mockFactory, 0, GL_TEXTURE_2D); texture->addRef(); texture->setStorage(GL_TEXTURE_2D, 1, GL_RGBA8, Extents(1, 1, 0)); @@ -117,7 +110,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) // Set the expectation for the validation error here. Error expectedError(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage); - EXPECT_CALL(testContext, recordError(expectedError)).Times(1); + EXPECT_CALL(testContext, handleError(expectedError)).Times(1); // Call once with maximum index, and once with an excessive index. GLuint indexData[] = {0, 1, static_cast<GLuint>(caps.maxElementIndex - 1), diff --git a/chromium/third_party/angle/src/libEGL/libEGL.cpp b/chromium/third_party/angle/src/libEGL/libEGL.cpp index 0a39d760afb..511565379ec 100644 --- a/chromium/third_party/angle/src/libEGL/libEGL.cpp +++ b/chromium/third_party/angle/src/libEGL/libEGL.cpp @@ -343,4 +343,19 @@ EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV(EGLDisplay dp { return egl::StreamConsumerGLTextureExternalAttribsNV(dpy, stream, attrib_list); } + +EGLBoolean EGLAPIENTRY eglCreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + const EGLAttrib *attrib_list) +{ + return egl::CreateStreamProducerD3DTextureNV12ANGLE(dpy, stream, attrib_list); +} + +EGLBoolean EGLAPIENTRY eglStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + void *texture, + const EGLAttrib *attrib_list) +{ + return egl::StreamPostD3DTextureNV12ANGLE(dpy, stream, texture, attrib_list); +} } diff --git a/chromium/third_party/angle/src/libEGL/libEGL.def b/chromium/third_party/angle/src/libEGL/libEGL.def index 588a8f1b645..d4596c23d06 100644 --- a/chromium/third_party/angle/src/libEGL/libEGL.def +++ b/chromium/third_party/angle/src/libEGL/libEGL.def @@ -55,6 +55,8 @@ EXPORTS eglStreamConsumerAcquireKHR @61 eglStreamConsumerReleaseKHR @62 eglStreamConsumerGLTextureExternalAttribsNV @63 + eglCreateStreamProducerD3DTextureNV12ANGLE @64 + eglStreamPostD3DTextureNV12ANGLE @65 ; 1.5 entry points eglCreateSync @38 diff --git a/chromium/third_party/angle/src/libGLESv2.gypi b/chromium/third_party/angle/src/libGLESv2.gypi index 591fa9a4349..008e408b06e 100644 --- a/chromium/third_party/angle/src/libGLESv2.gypi +++ b/chromium/third_party/angle/src/libGLESv2.gypi @@ -68,8 +68,8 @@ 'libANGLE/Constants.h', 'libANGLE/Context.cpp', 'libANGLE/Context.h', - 'libANGLE/Data.cpp', - 'libANGLE/Data.h', + 'libANGLE/ContextState.cpp', + 'libANGLE/ContextState.h', 'libANGLE/Debug.cpp', 'libANGLE/Debug.h', 'libANGLE/Device.cpp', @@ -137,23 +137,24 @@ 'libANGLE/queryconversions.h', 'libANGLE/renderer/BufferImpl.h', 'libANGLE/renderer/CompilerImpl.h', + 'libANGLE/renderer/ContextImpl.cpp', + 'libANGLE/renderer/ContextImpl.h', 'libANGLE/renderer/DeviceImpl.cpp', 'libANGLE/renderer/DeviceImpl.h', 'libANGLE/renderer/DisplayImpl.cpp', 'libANGLE/renderer/DisplayImpl.h', + 'libANGLE/renderer/EGLImplFactory.h', 'libANGLE/renderer/FenceNVImpl.h', 'libANGLE/renderer/FenceSyncImpl.h', 'libANGLE/renderer/FramebufferImpl.h', + 'libANGLE/renderer/GLImplFactory.h', 'libANGLE/renderer/ImageImpl.h', - 'libANGLE/renderer/ImplFactory.h', 'libANGLE/renderer/ProgramImpl.h', 'libANGLE/renderer/QueryImpl.h', 'libANGLE/renderer/RenderbufferImpl.h', - 'libANGLE/renderer/Renderer.cpp', - 'libANGLE/renderer/Renderer.h', 'libANGLE/renderer/SamplerImpl.h', 'libANGLE/renderer/ShaderImpl.h', - 'libANGLE/renderer/StreamImpl.h', + 'libANGLE/renderer/StreamProducerImpl.h', 'libANGLE/renderer/SurfaceImpl.cpp', 'libANGLE/renderer/SurfaceImpl.h', 'libANGLE/renderer/TextureImpl.h', @@ -208,6 +209,8 @@ 'libANGLE/renderer/d3d/loadimageSSE2.cpp', 'libANGLE/renderer/d3d/loadimage_etc.cpp', 'libANGLE/renderer/d3d/loadimage_etc.h', + 'libANGLE/renderer/d3d/NativeWindowD3D.cpp', + 'libANGLE/renderer/d3d/NativeWindowD3D.h', 'libANGLE/renderer/d3d/ProgramD3D.cpp', 'libANGLE/renderer/d3d/ProgramD3D.h', 'libANGLE/renderer/d3d/RenderbufferD3D.cpp', @@ -243,6 +246,8 @@ 'libANGLE/renderer/d3d/d3d9/Blit9.h', 'libANGLE/renderer/d3d/d3d9/Buffer9.cpp', 'libANGLE/renderer/d3d/d3d9/Buffer9.h', + 'libANGLE/renderer/d3d/d3d9/Context9.cpp', + 'libANGLE/renderer/d3d/d3d9/Context9.h', 'libANGLE/renderer/d3d/d3d9/DebugAnnotator9.cpp', 'libANGLE/renderer/d3d/d3d9/DebugAnnotator9.h', 'libANGLE/renderer/d3d/d3d9/Fence9.cpp', @@ -255,6 +260,8 @@ 'libANGLE/renderer/d3d/d3d9/Image9.h', 'libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp', 'libANGLE/renderer/d3d/d3d9/IndexBuffer9.h', + 'libANGLE/renderer/d3d/d3d9/NativeWindow9.cpp', + 'libANGLE/renderer/d3d/d3d9/NativeWindow9.h', 'libANGLE/renderer/d3d/d3d9/Query9.cpp', 'libANGLE/renderer/d3d/d3d9/Query9.h', 'libANGLE/renderer/d3d/d3d9/Renderer9.cpp', @@ -292,6 +299,8 @@ 'libANGLE/renderer/d3d/d3d11/Buffer11.h', 'libANGLE/renderer/d3d/d3d11/Clear11.cpp', 'libANGLE/renderer/d3d/d3d11/Clear11.h', + 'libANGLE/renderer/d3d/d3d11/Context11.cpp', + 'libANGLE/renderer/d3d/d3d11/Context11.h', 'libANGLE/renderer/d3d/d3d11/copyvertex.h', 'libANGLE/renderer/d3d/d3d11/copyvertex.inl', 'libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp', @@ -312,7 +321,7 @@ 'libANGLE/renderer/d3d/d3d11/InputLayoutCache.h', 'libANGLE/renderer/d3d/d3d11/load_functions_table.h', 'libANGLE/renderer/d3d/d3d11/load_functions_table_autogen.cpp', - 'libANGLE/renderer/d3d/d3d11/NativeWindow.h', + 'libANGLE/renderer/d3d/d3d11/NativeWindow11.h', 'libANGLE/renderer/d3d/d3d11/PixelTransfer11.cpp', 'libANGLE/renderer/d3d/d3d11/PixelTransfer11.h', 'libANGLE/renderer/d3d/d3d11/Query11.cpp', @@ -381,8 +390,8 @@ 'libANGLE/renderer/d3d/d3d11/shaders/compiled/swizzleui3dps.h', 'libANGLE/renderer/d3d/d3d11/StateManager11.cpp', 'libANGLE/renderer/d3d/d3d11/StateManager11.h', - 'libANGLE/renderer/d3d/d3d11/Stream11.cpp', - 'libANGLE/renderer/d3d/d3d11/Stream11.h', + 'libANGLE/renderer/d3d/d3d11/StreamProducerNV12.cpp', + 'libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h', 'libANGLE/renderer/d3d/d3d11/SwapChain11.cpp', 'libANGLE/renderer/d3d/d3d11/SwapChain11.h', 'libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp', @@ -399,18 +408,21 @@ ], 'libangle_d3d11_win32_sources': [ - 'libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp', + 'libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp', + 'libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h', 'third_party/systeminfo/SystemInfo.cpp', 'third_party/systeminfo/SystemInfo.h', ], 'libangle_d3d11_winrt_sources': [ - 'libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp', - 'libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h', 'libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp', 'libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h', 'libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp', 'libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h', + 'libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp', + 'libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h', + 'libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp', + 'libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h', ], 'libangle_gl_sources': [ @@ -420,6 +432,8 @@ 'libANGLE/renderer/gl/BufferGL.h', 'libANGLE/renderer/gl/CompilerGL.cpp', 'libANGLE/renderer/gl/CompilerGL.h', + 'libANGLE/renderer/gl/ContextGL.cpp', + 'libANGLE/renderer/gl/ContextGL.h', 'libANGLE/renderer/gl/DisplayGL.cpp', 'libANGLE/renderer/gl/DisplayGL.h', 'libANGLE/renderer/gl/FenceNVGL.cpp', @@ -491,6 +505,24 @@ 'libANGLE/renderer/gl/glx/functionsglx_typedefs.h', 'libANGLE/renderer/gl/glx/platform_glx.h', ], + 'libangle_gl_egl_sources': + [ + 'libANGLE/renderer/gl/egl/FunctionsEGL.cpp', + 'libANGLE/renderer/gl/egl/FunctionsEGL.h', + 'libANGLE/renderer/gl/egl/functionsegl_typedefs.h', + ], + 'libangle_gl_egl_dl_sources': + [ + 'libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp', + 'libANGLE/renderer/gl/egl/FunctionsEGLDL.h', + ], + 'libangle_gl_ozone_sources': + [ + 'libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp', + 'libANGLE/renderer/gl/egl/ozone/DisplayOzone.h', + 'libANGLE/renderer/gl/egl/ozone/SurfaceOzone.cpp', + 'libANGLE/renderer/gl/egl/ozone/SurfaceOzone.h', + ], 'libangle_gl_cgl_sources': [ 'libANGLE/renderer/gl/cgl/DisplayCGL.mm', @@ -755,6 +787,31 @@ ], }, }], + ['use_ozone==1', + { + 'defines': + [ + 'ANGLE_USE_OZONE', + ], + 'sources': + [ + '<@(libangle_gl_egl_sources)', + '<@(libangle_gl_egl_dl_sources)', + '<@(libangle_gl_ozone_sources)', + ], + 'cflags': + [ + '<!@(<(pkg-config) --cflags libdrm gbm)', + ], + 'link_settings': { + 'ldflags': [ + '<!@(<(pkg-config) --libs-only-L --libs-only-other libdrm gbm)', + ], + 'libraries': [ + '<!@(<(pkg-config) --libs-only-l libdrm gbm) -ldl', + ], + }, + }], ['angle_link_glx==1', { 'link_settings': @@ -779,9 +836,9 @@ { 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', - '$(SDKROOT)/System/Library/Frameworks/IOSurface.framework', '$(SDKROOT)/System/Library/Frameworks/Cocoa.framework', + '$(SDKROOT)/System/Library/Frameworks/IOSurface.framework', + '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework', ], }, diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_egl.cpp b/chromium/third_party/angle/src/libGLESv2/entry_points_egl.cpp index 5db7a077393..308cc7ccce8 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_egl.cpp +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_egl.cpp @@ -1460,6 +1460,9 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * INSERT_PROC_ADDRESS(gl, GetObjectPtrLabelKHR); INSERT_PROC_ADDRESS(gl, GetPointervKHR); + // GL_CHROMIUM_bind_uniform_location + INSERT_PROC_ADDRESS(gl, BindUniformLocationCHROMIUM); + // GLES3 core INSERT_PROC_ADDRESS(gl, ReadBuffer); INSERT_PROC_ADDRESS(gl, DrawRangeElements); @@ -1658,6 +1661,10 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * // EGL_NV_stream_consumer_gltexture_yuv INSERT_PROC_ADDRESS(egl, StreamConsumerGLTextureExternalAttribsNV); + // EGL_ANGLE_stream_producer_d3d_texture_nv12 + INSERT_PROC_ADDRESS(egl, CreateStreamProducerD3DTextureNV12ANGLE); + INSERT_PROC_ADDRESS(egl, StreamPostD3DTextureNV12ANGLE); + #undef INSERT_PROC_ADDRESS return map; }; diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.cpp b/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.cpp index aa6f76184b4..130c419d468 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.cpp +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.cpp @@ -725,8 +725,16 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStr SetGlobalError(error); return EGL_FALSE; } + + error = streamObject->createConsumerGLTextureExternal(AttributeMap(), context); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + SetGlobalError(error); - return EGL_FALSE; + return EGL_TRUE; } EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream) @@ -742,8 +750,16 @@ EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR str SetGlobalError(error); return EGL_FALSE; } + + error = streamObject->consumerAcquire(); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + SetGlobalError(error); - return EGL_FALSE; + return EGL_TRUE; } EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream) @@ -759,8 +775,16 @@ EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR str SetGlobalError(error); return EGL_FALSE; } + + error = streamObject->consumerRelease(); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + SetGlobalError(error); - return EGL_FALSE; + return EGL_TRUE; } EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, @@ -782,7 +806,76 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, SetGlobalError(error); return EGL_FALSE; } + + error = streamObject->createConsumerGLTextureExternal(attributes, context); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + + SetGlobalError(error); + return EGL_TRUE; +} + +EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + const EGLAttrib *attrib_list) +{ + EVENT( + "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p", + dpy, stream, attrib_list); + Display *display = static_cast<Display *>(dpy); + Stream *streamObject = static_cast<Stream *>(stream); + AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list); + + Error error = + ValidateCreateStreamProducerD3DTextureNV12ANGLE(display, streamObject, attributes); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + + error = streamObject->createProducerD3D11TextureNV12(attributes); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + SetGlobalError(error); - return EGL_FALSE; + return EGL_TRUE; +} + +EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + void *texture, + const EGLAttrib *attrib_list) +{ + EVENT( + "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, void* texture = 0x%0.8p, " + "EGLAttrib attrib_list = 0x%0.8p", + dpy, stream, texture, attrib_list); + Display *display = static_cast<Display *>(dpy); + Stream *streamObject = static_cast<Stream *>(stream); + AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list); + + Error error = ValidateStreamPostD3DTextureNV12ANGLE(display, streamObject, texture, attributes); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + + error = streamObject->postD3D11NV12Texture(texture, attributes); + if (error.isError()) + { + SetGlobalError(error); + return EGL_FALSE; + } + + SetGlobalError(error); + return EGL_TRUE; } } diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.h b/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.h index 0a0b6385e11..4ec0450bfcb 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.h +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_egl_ext.h @@ -69,6 +69,16 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); -} + +// EGL_ANGLE_stream_producer_d3d_texture_nv12 +ANGLE_EXPORT EGLBoolean EGLAPIENTRY +CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + const EGLAttrib *attrib_list); +ANGLE_EXPORT EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, + EGLStreamKHR stream, + void *texture, + const EGLAttrib *attrib_list); +} // namespace egl #endif // LIBGLESV2_ENTRYPOINTSEGLEXT_H_ diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0.cpp b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0.cpp index b48bf46deb3..2babb5617ec 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0.cpp +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0.cpp @@ -44,7 +44,7 @@ void GL_APIENTRY ActiveTexture(GLenum texture) { if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -73,7 +73,7 @@ void GL_APIENTRY AttachShader(GLuint program, GLuint shader) if (!programObject->attachShader(shaderObject)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } } @@ -88,7 +88,7 @@ void GL_APIENTRY BindAttribLocation(GLuint program, GLuint index, const GLchar* { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -101,7 +101,7 @@ void GL_APIENTRY BindAttribLocation(GLuint program, GLuint index, const GLchar* if (strncmp(name, "gl_", 3) == 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -118,7 +118,7 @@ void GL_APIENTRY BindBuffer(GLenum target, GLuint buffer) { if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -150,7 +150,7 @@ void GL_APIENTRY BindBuffer(GLenum target, GLuint buffer) return; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -165,7 +165,7 @@ void GL_APIENTRY BindFramebuffer(GLenum target, GLuint framebuffer) { if (!ValidFramebufferTarget(target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -190,7 +190,7 @@ void GL_APIENTRY BindRenderbuffer(GLenum target, GLuint renderbuffer) { if (target != GL_RENDERBUFFER) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -248,7 +248,7 @@ void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -262,7 +262,7 @@ void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -303,7 +303,7 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -328,13 +328,13 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha case GL_SRC_ALPHA_SATURATE: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -358,7 +358,7 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -383,13 +383,13 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha case GL_SRC_ALPHA_SATURATE: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -409,7 +409,7 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha "Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and " "GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not supported by this " "implementation."); - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } } @@ -428,7 +428,7 @@ void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, { if (size < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -447,19 +447,19 @@ void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, case GL_DYNAMIC_COPY: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -467,14 +467,14 @@ void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, if (!buffer) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } Error error = buffer->bufferData(data, size, usage); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -490,13 +490,13 @@ void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, { if (size < 0 || offset < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -504,26 +504,26 @@ void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, if (!buffer) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (buffer->isMapped()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } // Check for possible overflow of size + offset if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset)) { - context->recordError(Error(GL_OUT_OF_MEMORY)); + context->handleError(Error(GL_OUT_OF_MEMORY)); return; } if (size + offset > buffer->getSize()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -535,7 +535,7 @@ void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, Error error = buffer->bufferSubData(data, size, offset); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -550,7 +550,7 @@ GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target) { if (!ValidFramebufferTarget(target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return 0; } @@ -752,7 +752,7 @@ GLuint GL_APIENTRY CreateShader(GLenum type) return context->createShader(type); default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return 0; } } @@ -775,7 +775,7 @@ void GL_APIENTRY CullFace(GLenum mode) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -840,12 +840,12 @@ void GL_APIENTRY DeleteProgram(GLuint program) { if(context->getShader(program)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } else { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } } @@ -889,12 +889,12 @@ void GL_APIENTRY DeleteShader(GLuint shader) { if(context->getProgram(shader)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } else { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } } @@ -946,7 +946,7 @@ void GL_APIENTRY DepthFunc(GLenum func) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -995,7 +995,7 @@ void GL_APIENTRY DetachShader(GLuint program, GLuint shader) if (!programObject->detachShader(shaderObject)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } } @@ -1010,7 +1010,7 @@ void GL_APIENTRY Disable(GLenum cap) { if (!ValidCap(context, cap)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1027,7 +1027,7 @@ void GL_APIENTRY DisableVertexAttribArray(GLuint index) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1050,7 +1050,7 @@ void GL_APIENTRY DrawArrays(GLenum mode, GLint first, GLsizei count) Error error = context->drawArrays(mode, first, count); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1073,7 +1073,7 @@ void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const GLv Error error = context->drawElements(mode, count, type, indices, indexRange); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1088,7 +1088,7 @@ void GL_APIENTRY Enable(GLenum cap) { if (!ValidCap(context, cap)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1097,7 +1097,7 @@ void GL_APIENTRY Enable(GLenum cap) if (cap == GL_SAMPLE_ALPHA_TO_COVERAGE) { const char *errorMessage = "Current renderer doesn't support alpha-to-coverage"; - context->recordError(Error(GL_INVALID_OPERATION, errorMessage)); + context->handleError(Error(GL_INVALID_OPERATION, errorMessage)); // We also output an error message to the debugger window if tracing is active, so that developers can see the error message. ERR("%s", errorMessage); @@ -1119,7 +1119,7 @@ void GL_APIENTRY EnableVertexAttribArray(GLuint index) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1137,7 +1137,7 @@ void GL_APIENTRY Finish(void) Error error = context->finish(); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1153,7 +1153,7 @@ void GL_APIENTRY Flush(void) Error error = context->flush(); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1210,7 +1210,7 @@ void GL_APIENTRY FrontFace(GLenum mode) context->getState().setFrontFace(mode); break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -1244,7 +1244,7 @@ void GL_APIENTRY GenerateMipmap(GLenum target) { if (!ValidTextureTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1252,12 +1252,12 @@ void GL_APIENTRY GenerateMipmap(GLenum target) if (texture == NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } GLenum baseTarget = (target == GL_TEXTURE_CUBE_MAP) ? GL_TEXTURE_CUBE_MAP_POSITIVE_X : target; - GLenum internalFormat = texture->getInternalFormat(baseTarget, 0); + GLenum internalFormat = texture->getInternalFormat(baseTarget, texture->getBaseLevel()); const TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat); const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat); @@ -1276,14 +1276,14 @@ void GL_APIENTRY GenerateMipmap(GLenum target) if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable || (!formatCaps.renderable && !isLUMA) || formatInfo.compressed) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } // GL_EXT_sRGB does not support mipmap generation on sRGB textures if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1293,21 +1293,21 @@ void GL_APIENTRY GenerateMipmap(GLenum target) !isPow2(static_cast<int>(texture->getHeight(baseTarget, 0))))) { ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP)); - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } // Cube completeness check if (target == GL_TEXTURE_CUBE_MAP && !texture->isCubeComplete()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } Error error = texture->generateMipmaps(); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1381,7 +1381,7 @@ void GL_APIENTRY GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, { if (bufsize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1394,7 +1394,7 @@ void GL_APIENTRY GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, if (index >= (GLuint)programObject->getActiveAttributeCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1414,7 +1414,7 @@ void GL_APIENTRY GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, { if (bufsize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1427,7 +1427,7 @@ void GL_APIENTRY GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, if (index >= (GLuint)programObject->getActiveUniformCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1445,7 +1445,7 @@ void GL_APIENTRY GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* c { if (maxcount < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1476,7 +1476,7 @@ GLint GL_APIENTRY GetAttribLocation(GLuint program, const GLchar* name) if (!programObject->isLinked()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return -1; } @@ -1520,13 +1520,13 @@ void GL_APIENTRY GetBufferParameteriv(GLenum target, GLenum pname, GLint* params { if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (!ValidBufferParameter(context, pname)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1535,7 +1535,7 @@ void GL_APIENTRY GetBufferParameteriv(GLenum target, GLenum pname, GLint* params if (!buffer) { // A null buffer means that "0" is bound to the requested buffer target - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1617,7 +1617,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac { if (!ValidFramebufferTarget(target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1634,7 +1634,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: if (clientVersion < 3 && !context->getExtensions().sRGB) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; @@ -1649,13 +1649,13 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: if (clientVersion < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1669,7 +1669,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_DEPTH_STENCIL_ATTACHMENT: if (clientVersion < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; @@ -1682,7 +1682,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac if (attachment < GL_COLOR_ATTACHMENT0_EXT || (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; @@ -1695,7 +1695,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac { if (clientVersion < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1707,7 +1707,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } } @@ -1728,13 +1728,13 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_DEPTH_STENCIL_ATTACHMENT: if (!framebuffer->hasValidDepthStencil()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } break; default: - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } } @@ -1756,7 +1756,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: if (attachmentObject->type() != GL_RENDERBUFFER && attachmentObject->type() != GL_TEXTURE) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = attachmentObject->id(); @@ -1765,7 +1765,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: if (attachmentObject->type() != GL_TEXTURE) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = attachmentObject->mipLevel(); @@ -1774,7 +1774,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: if (attachmentObject->type() != GL_TEXTURE) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = attachmentObject->cubeMapFace(); @@ -1807,7 +1807,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } *params = attachmentObject->getComponentType(); @@ -1820,7 +1820,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: if (attachmentObject->type() != GL_TEXTURE) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = attachmentObject->layer(); @@ -1849,7 +1849,7 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: if (clientVersion < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = 0; @@ -1858,12 +1858,12 @@ void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attac default: if (clientVersion < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } else { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } } @@ -1921,7 +1921,7 @@ void GL_APIENTRY GetProgramiv(GLuint program, GLenum pname, GLint* params) case GL_TRANSFORM_FEEDBACK_VARYINGS: case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -1978,7 +1978,7 @@ void GL_APIENTRY GetProgramiv(GLuint program, GLenum pname, GLint* params) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -1994,7 +1994,7 @@ void GL_APIENTRY GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* len { if (bufsize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2017,13 +2017,13 @@ void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* { if (target != GL_RENDERBUFFER) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (context->getState().getRenderbufferId() == 0) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2044,14 +2044,14 @@ void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* case GL_RENDERBUFFER_SAMPLES_ANGLE: if (!context->getExtensions().framebufferMultisample) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = renderbuffer->getSamples(); break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2092,7 +2092,7 @@ void GL_APIENTRY GetShaderiv(GLuint shader, GLenum pname, GLint* params) return; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2108,7 +2108,7 @@ void GL_APIENTRY GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* lengt { if (bufsize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2156,7 +2156,7 @@ void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontyp break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; @@ -2184,12 +2184,12 @@ void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontyp break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2206,7 +2206,7 @@ void GL_APIENTRY GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length { if (bufsize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2264,7 +2264,7 @@ const GLubyte *GL_APIENTRY GetString(GLenum name) return reinterpret_cast<const GLubyte *>(context->getExtensionString().c_str()); default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return nullptr; } } @@ -2281,7 +2281,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { if (!ValidTextureTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid texture target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return; } @@ -2289,7 +2289,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) if (!texture) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2310,7 +2310,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_WRAP_R: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getWrapR(); @@ -2322,7 +2322,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_IMMUTABLE_LEVELS: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getImmutableLevels(); @@ -2333,7 +2333,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_MAX_ANISOTROPY_EXT: if (!context->getExtensions().textureFilterAnisotropic) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getMaxAnisotropy(); @@ -2341,7 +2341,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_SWIZZLE_R: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getSwizzleRed(); @@ -2349,7 +2349,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_SWIZZLE_G: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getSwizzleGreen(); @@ -2357,7 +2357,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_SWIZZLE_B: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getSwizzleBlue(); @@ -2365,7 +2365,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_SWIZZLE_A: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getSwizzleAlpha(); @@ -2373,7 +2373,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_BASE_LEVEL: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getBaseLevel(); @@ -2381,7 +2381,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_MAX_LEVEL: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLfloat)texture->getMaxLevel(); @@ -2389,7 +2389,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_MIN_LOD: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSamplerState().minLod; @@ -2397,7 +2397,7 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_MAX_LOD: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSamplerState().maxLod; @@ -2405,9 +2405,8 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_COMPARE_MODE: if (context->getClientVersion() < 3) { - context->recordError( - Error(GL_INVALID_ENUM, - "GL_TEXTURE_COMPARE_MODE not available in ES versions < 3.0")); + context->handleError(Error( + GL_INVALID_ENUM, "GL_TEXTURE_COMPARE_MODE not available in ES versions < 3.0")); return; } *params = static_cast<GLfloat>(texture->getCompareMode()); @@ -2415,15 +2414,14 @@ void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) case GL_TEXTURE_COMPARE_FUNC: if (context->getClientVersion() < 3) { - context->recordError( - Error(GL_INVALID_ENUM, - "GL_TEXTURE_COMPARE_FUNC not available in ES versions < 3.0")); + context->handleError(Error( + GL_INVALID_ENUM, "GL_TEXTURE_COMPARE_FUNC not available in ES versions < 3.0")); return; } *params = static_cast<GLfloat>(texture->getCompareFunc()); break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2438,7 +2436,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) { if (!ValidTextureTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid texture target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return; } @@ -2446,7 +2444,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) if (!texture) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2467,7 +2465,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_WRAP_R: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSamplerState().wrapR; @@ -2479,7 +2477,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_IMMUTABLE_LEVELS: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = static_cast<GLint>(texture->getImmutableLevels()); @@ -2490,7 +2488,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_MAX_ANISOTROPY_EXT: if (!context->getExtensions().textureFilterAnisotropic) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = (GLint)texture->getMaxAnisotropy(); @@ -2498,7 +2496,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_SWIZZLE_R: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSwizzleRed(); @@ -2506,7 +2504,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_SWIZZLE_G: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSwizzleGreen(); @@ -2514,7 +2512,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_SWIZZLE_B: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSwizzleBlue(); @@ -2522,7 +2520,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_SWIZZLE_A: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getSwizzleAlpha(); @@ -2530,7 +2528,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_BASE_LEVEL: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getBaseLevel(); @@ -2538,7 +2536,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_MAX_LEVEL: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = texture->getMaxLevel(); @@ -2546,7 +2544,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_MIN_LOD: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = iround<GLint>(texture->getMinLod()); @@ -2554,7 +2552,7 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_MAX_LOD: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } *params = iround<GLint>(texture->getMaxLod()); @@ -2562,9 +2560,8 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_COMPARE_MODE: if (context->getClientVersion() < 3) { - context->recordError( - Error(GL_INVALID_ENUM, - "GL_TEXTURE_COMPARE_MODE not available in ES versions < 3.0")); + context->handleError(Error( + GL_INVALID_ENUM, "GL_TEXTURE_COMPARE_MODE not available in ES versions < 3.0")); return; } *params = texture->getCompareMode(); @@ -2572,15 +2569,14 @@ void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params) case GL_TEXTURE_COMPARE_FUNC: if (context->getClientVersion() < 3) { - context->recordError( - Error(GL_INVALID_ENUM, - "GL_TEXTURE_COMPARE_FUNC not available in ES versions < 3.0")); + context->handleError(Error( + GL_INVALID_ENUM, "GL_TEXTURE_COMPARE_FUNC not available in ES versions < 3.0")); return; } *params = texture->getCompareFunc(); break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2645,7 +2641,7 @@ GLint GL_APIENTRY GetUniformLocation(GLuint program, const GLchar* name) if (!programObject->isLinked()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return -1; } @@ -2664,7 +2660,7 @@ void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2698,7 +2694,7 @@ void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2733,13 +2729,13 @@ void GL_APIENTRY GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** po { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2762,7 +2758,7 @@ void GL_APIENTRY Hint(GLenum target, GLenum mode) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2777,7 +2773,7 @@ void GL_APIENTRY Hint(GLenum target, GLenum mode) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2810,7 +2806,7 @@ GLboolean GL_APIENTRY IsEnabled(GLenum cap) { if (!ValidCap(context, cap)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return GL_FALSE; } @@ -2919,7 +2915,7 @@ void GL_APIENTRY LineWidth(GLfloat width) { if (width <= 0.0f) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2948,7 +2944,7 @@ void GL_APIENTRY LinkProgram(GLuint program) Error error = programObject->link(context->getData()); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -2967,7 +2963,7 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) { case GL_UNPACK_IMAGE_HEIGHT: case GL_UNPACK_SKIP_IMAGES: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; case GL_UNPACK_ROW_LENGTH: @@ -2975,7 +2971,7 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) case GL_UNPACK_SKIP_PIXELS: if (!context->getExtensions().unpackSubimage) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; @@ -2985,7 +2981,7 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) case GL_PACK_SKIP_PIXELS: if (!context->getExtensions().packSubimage) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; @@ -2994,7 +2990,8 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) if (param < 0) { - context->recordError(Error(GL_INVALID_VALUE, "Cannot use negative values in PixelStorei")); + context->handleError( + Error(GL_INVALID_VALUE, "Cannot use negative values in PixelStorei")); return; } @@ -3005,7 +3002,7 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) case GL_UNPACK_ALIGNMENT: if (param != 1 && param != 2 && param != 4 && param != 8) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3015,7 +3012,7 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) case GL_PACK_ALIGNMENT: if (param != 1 && param != 2 && param != 4 && param != 8) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3067,7 +3064,7 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -3116,7 +3113,7 @@ void GL_APIENTRY ReleaseShaderCompiler(void) Error error = compiler->release(); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -3140,7 +3137,7 @@ void GL_APIENTRY RenderbufferStorage(GLenum target, GLenum internalformat, GLsiz Error error = renderbuffer->setStorage(internalformat, width, height); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -3167,7 +3164,7 @@ void GL_APIENTRY Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { if (width < 0 || height < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3187,7 +3184,7 @@ void GL_APIENTRY ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryfor const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats; if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end()) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3206,7 +3203,7 @@ void GL_APIENTRY ShaderSource(GLuint shader, GLsizei count, const GLchar* const* { if (count < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3239,7 +3236,7 @@ void GL_APIENTRY StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3256,7 +3253,7 @@ void GL_APIENTRY StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3292,7 +3289,7 @@ void GL_APIENTRY StencilMaskSeparate(GLenum face, GLuint mask) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3329,7 +3326,7 @@ void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3346,7 +3343,7 @@ void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3363,7 +3360,7 @@ void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3380,7 +3377,7 @@ void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3425,13 +3422,13 @@ void GL_APIENTRY TexParameterf(GLenum target, GLenum pname, GLfloat param) Context *context = GetValidGlobalContext(); if (context) { - if (!ValidTextureTarget(context, target)) + if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid texture target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); return; } - if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) + if (!ValidateTexParamParameters(context, target, pname, static_cast<GLint>(param))) { return; } @@ -3440,7 +3437,7 @@ void GL_APIENTRY TexParameterf(GLenum target, GLenum pname, GLfloat param) if (!texture) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3482,13 +3479,13 @@ void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param) Context *context = GetValidGlobalContext(); if (context) { - if (!ValidTextureTarget(context, target)) + if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM, "Invalid Texture target")); + context->handleError(Error(GL_INVALID_ENUM, "Invalid Texture target")); return; } - if (!ValidateTexParamParameters(context, pname, param)) + if (!ValidateTexParamParameters(context, target, pname, param)) { return; } @@ -3497,7 +3494,7 @@ void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param) if (!texture) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -3840,7 +3837,7 @@ void GL_APIENTRY VertexAttrib1f(GLuint index, GLfloat x) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3858,7 +3855,7 @@ void GL_APIENTRY VertexAttrib1fv(GLuint index, const GLfloat* values) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3876,7 +3873,7 @@ void GL_APIENTRY VertexAttrib2f(GLuint index, GLfloat x, GLfloat y) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3894,7 +3891,7 @@ void GL_APIENTRY VertexAttrib2fv(GLuint index, const GLfloat* values) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3912,7 +3909,7 @@ void GL_APIENTRY VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3930,7 +3927,7 @@ void GL_APIENTRY VertexAttrib3fv(GLuint index, const GLfloat* values) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3948,7 +3945,7 @@ void GL_APIENTRY VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, G { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3966,7 +3963,7 @@ void GL_APIENTRY VertexAttrib4fv(GLuint index, const GLfloat* values) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -3985,13 +3982,13 @@ void GL_APIENTRY VertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if (size < 1 || size > 4) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -4012,25 +4009,25 @@ void GL_APIENTRY VertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo case GL_UNSIGNED_INT_2_10_10_10_REV: if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (stride < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -4040,7 +4037,7 @@ void GL_APIENTRY VertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo // and the pointer argument is not NULL. if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -4058,7 +4055,7 @@ void GL_APIENTRY Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { if (width < 0 || height < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp index f31663b33f4..56ad3068348 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp @@ -93,7 +93,7 @@ void GL_APIENTRY BeginQueryEXT(GLenum target, GLuint id) Error error = context->beginQuery(target, id); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -114,7 +114,7 @@ void GL_APIENTRY EndQueryEXT(GLenum target) Error error = context->endQuery(target); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -135,7 +135,7 @@ void GL_APIENTRY QueryCounterEXT(GLuint id, GLenum target) Error error = context->queryCounter(id, target); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -173,7 +173,7 @@ void GL_APIENTRY GetQueryObjectivEXT(GLuint id, GLenum pname, GLint *params) Error error = context->getQueryObjectiv(id, pname, params); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -194,7 +194,7 @@ void GL_APIENTRY GetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) Error error = context->getQueryObjectuiv(id, pname, params); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -215,7 +215,7 @@ void GL_APIENTRY GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64 *params) Error error = context->getQueryObjecti64v(id, pname, params); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -236,7 +236,7 @@ void GL_APIENTRY GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64 *param Error error = context->getQueryObjectui64v(id, pname, params); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -251,7 +251,7 @@ void GL_APIENTRY DeleteFencesNV(GLsizei n, const GLuint *fences) { if (n < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -281,7 +281,7 @@ void GL_APIENTRY DrawArraysInstancedANGLE(GLenum mode, Error error = context->drawArraysInstanced(mode, first, count, primcount); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -312,7 +312,7 @@ void GL_APIENTRY DrawElementsInstancedANGLE(GLenum mode, context->drawElementsInstanced(mode, count, type, indices, primcount, indexRange); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -329,13 +329,13 @@ void GL_APIENTRY FinishFenceNV(GLuint fence) if (fenceObject == NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (fenceObject->isSet() != GL_TRUE) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -352,7 +352,7 @@ void GL_APIENTRY GenFencesNV(GLsizei n, GLuint *fences) { if (n < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -374,13 +374,13 @@ void GL_APIENTRY GetFenceivNV(GLuint fence, GLenum pname, GLint *params) if (fenceObject == NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (fenceObject->isSet() != GL_TRUE) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -397,7 +397,7 @@ void GL_APIENTRY GetFenceivNV(GLuint fence, GLenum pname, GLint *params) Error error = fenceObject->test(&status); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -413,7 +413,7 @@ void GL_APIENTRY GetFenceivNV(GLuint fence, GLenum pname, GLint *params) default: { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -444,7 +444,7 @@ void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, { if (bufsize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -452,7 +452,7 @@ void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, if (!shaderObject) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -561,7 +561,7 @@ void GL_APIENTRY RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samp Error error = renderbuffer->setStorageMultisample(samples, internalformat, width, height); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -576,7 +576,7 @@ void GL_APIENTRY SetFenceNV(GLuint fence, GLenum condition) { if (condition != GL_ALL_COMPLETED_NV) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -584,14 +584,14 @@ void GL_APIENTRY SetFenceNV(GLuint fence, GLenum condition) if (fenceObject == NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } Error error = fenceObject->set(condition); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -608,13 +608,13 @@ GLboolean GL_APIENTRY TestFenceNV(GLuint fence) if (fenceObject == NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_TRUE; } if (fenceObject->isSet() != GL_TRUE) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_TRUE; } @@ -622,7 +622,7 @@ GLboolean GL_APIENTRY TestFenceNV(GLuint fence) Error error = fenceObject->test(&result); if (error.isError()) { - context->recordError(error); + context->handleError(error); return GL_TRUE; } @@ -642,7 +642,7 @@ void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf { if (!context->getExtensions().textureStorage) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -664,7 +664,7 @@ void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf Error error = texture->setStorage(target, levels, internalformat, size); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -679,7 +679,7 @@ void GL_APIENTRY VertexAttribDivisorANGLE(GLuint index, GLuint divisor) { if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -689,7 +689,7 @@ void GL_APIENTRY VertexAttribDivisorANGLE(GLuint index, GLuint divisor) { const char *errorMessage = "The current context doesn't support setting a non-zero divisor on the attribute with index zero. " "Please reorder the attributes in your vertex shader so that attribute zero can have a zero divisor."; - context->recordError(Error(GL_INVALID_OPERATION, errorMessage)); + context->handleError(Error(GL_INVALID_OPERATION, errorMessage)); // We also output an error message to the debugger window if tracing is active, so that developers can see the error message. ERR("%s", errorMessage); @@ -772,7 +772,7 @@ void GL_APIENTRY GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *l Error error = programObject->saveBinary(binaryFormat, binary, bufSize, length); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -797,7 +797,7 @@ void GL_APIENTRY ProgramBinaryOES(GLuint program, GLenum binaryFormat, const voi Error error = programObject->loadBinary(binaryFormat, binary, length); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -921,7 +921,7 @@ void GL_APIENTRY InsertEventMarkerEXT(GLsizei length, const char *marker) { // The debug marker calls should not set error state // However, it seems reasonable to set an error state if the extension is not enabled - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return; } @@ -946,7 +946,7 @@ void GL_APIENTRY PushGroupMarkerEXT(GLsizei length, const char *marker) { // The debug marker calls should not set error state // However, it seems reasonable to set an error state if the extension is not enabled - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return; } @@ -980,7 +980,7 @@ void GL_APIENTRY PopGroupMarkerEXT() { // The debug marker calls should not set error state // However, it seems reasonable to set an error state if the extension is not enabled - context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled")); + context->handleError(Error(GL_INVALID_OPERATION, "Extension not enabled")); return; } @@ -1006,7 +1006,7 @@ ANGLE_EXPORT void GL_APIENTRY EGLImageTargetTexture2DOES(GLenum target, GLeglIma Error error = texture->setEGLImageTarget(target, imageObject); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1031,7 +1031,7 @@ ANGLE_EXPORT void GL_APIENTRY EGLImageTargetRenderbufferStorageOES(GLenum target Error error = renderbuffer->setStorageEGLImageTarget(imageObject); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1369,4 +1369,39 @@ void GL_APIENTRY GetPointervKHR(GLenum pname, void **params) context->getPointerv(pname, params); } } + +ANGLE_EXPORT void GL_APIENTRY BindUniformLocationCHROMIUM(GLuint program, + GLint location, + const GLchar *name) +{ + EVENT("(GLuint program = %u, GLint location = %d, const GLchar *name = 0x%0.8p)", program, + location, name); + + Context *context = GetValidGlobalContext(); + if (context) + { + if (!ValidateBindUniformLocationCHROMIUM(context, program, location, name)) + { + return; + } + + context->bindUniformLocation(program, location, name); + } +} + +ANGLE_EXPORT void GL_APIENTRY CoverageModulationCHROMIUM(GLenum components) +{ + EVENT("(GLenum components = %u)", components); + + Context* context = GetValidGlobalContext(); + if (context) + { + if (!ValidateCoverageModulationCHROMIUM(context, components)) + { + return; + } + context->setCoverageModulation(components); + } +} + } diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.h b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.h index a2fb9c5e80f..06aab47c729 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.h +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_2_0_ext.h @@ -140,6 +140,14 @@ ANGLE_EXPORT void GL_APIENTRY GetObjectPtrLabelKHR(const void *ptr, GLsizei *length, GLchar *label); ANGLE_EXPORT void GL_APIENTRY GetPointervKHR(GLenum pname, void **params); + +// GL_CHROMIUM_bind_uniform_location +ANGLE_EXPORT void GL_APIENTRY BindUniformLocationCHROMIUM(GLuint program, + GLint location, + const GLchar *name); + +// GL_CHROMIUM_framebuffer_mixed_samples +ANGLE_EXPORT void GL_APIENTRY CoverageModulationCHROMIUM(GLenum components); } #endif // LIBGLESV2_ENTRYPOINTGLES20EXT_H_ diff --git a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_3_0.cpp b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_3_0.cpp index 00c1f511c2e..e9e1eeae34e 100644 --- a/chromium/third_party/angle/src/libGLESv2/entry_points_gles_3_0.cpp +++ b/chromium/third_party/angle/src/libGLESv2/entry_points_gles_3_0.cpp @@ -68,7 +68,7 @@ void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize context->drawRangeElements(mode, start, end, count, type, indices, indexRange); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -229,7 +229,7 @@ GLboolean GL_APIENTRY IsQuery(GLuint id) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_FALSE; } @@ -254,7 +254,7 @@ void GL_APIENTRY BeginQuery(GLenum target, GLuint id) Error error = context->beginQuery(target, id); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -275,7 +275,7 @@ void GL_APIENTRY EndQuery(GLenum target) Error error = context->endQuery(target); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -312,7 +312,7 @@ void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) Error error = context->getQueryObjectuiv(id, pname, params); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -506,7 +506,7 @@ void GL_APIENTRY RenderbufferStorageMultisample(GLenum target, GLsizei samples, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -667,7 +667,7 @@ void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -679,7 +679,7 @@ void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data) case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: if (index >= caps.maxTransformFeedbackSeparateAttributes) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; @@ -689,13 +689,13 @@ void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data) case GL_UNIFORM_BUFFER_BINDING: if (index >= caps.maxCombinedUniformBlocks) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -705,7 +705,7 @@ void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data) unsigned int numParams = 0; if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -763,7 +763,7 @@ void GL_APIENTRY EndTransformFeedback(void) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -772,7 +772,7 @@ void GL_APIENTRY EndTransformFeedback(void) if (!transformFeedback->isActive()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -790,7 +790,7 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -800,7 +800,7 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi case GL_TRANSFORM_FEEDBACK_BUFFER: if (index >= caps.maxTransformFeedbackSeparateAttributes) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; @@ -808,19 +808,19 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi case GL_UNIFORM_BUFFER: if (index >= caps.maxUniformBufferBindings) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (buffer != 0 && size <= 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -831,7 +831,7 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi // size and offset must be a multiple of 4 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -839,7 +839,7 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); if (curTransformFeedback && curTransformFeedback->isActive()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -853,7 +853,7 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi // it is an error to bind an offset not a multiple of the alignment if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -877,7 +877,7 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -887,7 +887,7 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer) case GL_TRANSFORM_FEEDBACK_BUFFER: if (index >= caps.maxTransformFeedbackSeparateAttributes) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; @@ -895,13 +895,13 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer) case GL_UNIFORM_BUFFER: if (index >= caps.maxUniformBufferBindings) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -913,7 +913,7 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer) TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); if (curTransformFeedback && curTransformFeedback->isActive()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -942,13 +942,13 @@ void GL_APIENTRY TransformFeedbackVaryings(GLuint program, GLsizei count, const { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (count < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -960,12 +960,12 @@ void GL_APIENTRY TransformFeedbackVaryings(GLuint program, GLsizei count, const case GL_SEPARATE_ATTRIBS: if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -990,13 +990,13 @@ void GL_APIENTRY GetTransformFeedbackVarying(GLuint program, GLuint index, GLsiz { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (bufSize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1008,7 +1008,7 @@ void GL_APIENTRY GetTransformFeedbackVarying(GLuint program, GLuint index, GLsiz if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount())) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1026,19 +1026,19 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if (size < 1 || size > 4) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1055,19 +1055,19 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (stride < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1077,7 +1077,7 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs // and the pointer argument is not NULL. if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1096,13 +1096,13 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1137,13 +1137,13 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1178,13 +1178,13 @@ void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1203,13 +1203,13 @@ void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1227,13 +1227,13 @@ void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1250,13 +1250,13 @@ void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1294,13 +1294,13 @@ GLint GL_APIENTRY GetFragDataLocation(GLuint program, const GLchar *name) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return -1; } if (program == 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return -1; } @@ -1308,7 +1308,7 @@ GLint GL_APIENTRY GetFragDataLocation(GLuint program, const GLchar *name) if (!programObject || !programObject->isLinked()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return -1; } @@ -1494,19 +1494,19 @@ const GLubyte *GL_APIENTRY GetStringi(GLenum name, GLuint index) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return NULL; } if (name != GL_EXTENSIONS) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return NULL; } if (index >= context->getExtensionStringCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return NULL; } @@ -1526,13 +1526,13 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (!ValidBufferTarget(context, readTarget) || !ValidBufferTarget(context, writeTarget)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -1541,14 +1541,14 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp if (!readBuffer || !writeBuffer) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } // Verify that readBuffer and writeBuffer are not currently mapped if (readBuffer->isMapped() || writeBuffer->isMapped()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1556,13 +1556,13 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() || static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1572,7 +1572,7 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1589,13 +1589,13 @@ void GL_APIENTRY GetUniformIndices(GLuint program, GLsizei uniformCount, const G { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (uniformCount < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1633,13 +1633,13 @@ void GL_APIENTRY GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (uniformCount < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1663,13 +1663,13 @@ void GL_APIENTRY GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (uniformCount > programObject->getActiveUniformCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1679,7 +1679,7 @@ void GL_APIENTRY GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const if (index >= static_cast<GLuint>(programObject->getActiveUniformCount())) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } } @@ -1701,7 +1701,7 @@ GLuint GL_APIENTRY GetUniformBlockIndex(GLuint program, const GLchar* uniformBlo { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_INVALID_INDEX; } @@ -1727,7 +1727,7 @@ void GL_APIENTRY GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockInde { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } Program *programObject = GetValidProgram(context, program); @@ -1739,7 +1739,7 @@ void GL_APIENTRY GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockInde if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1759,7 +1759,7 @@ void GL_APIENTRY GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockInde break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -1775,7 +1775,7 @@ void GL_APIENTRY GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIn { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1788,7 +1788,7 @@ void GL_APIENTRY GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIn if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1806,13 +1806,13 @@ void GL_APIENTRY UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, G { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1826,7 +1826,7 @@ void GL_APIENTRY UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, G // if never linked, there won't be any uniform blocks if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1844,7 +1844,7 @@ void GL_APIENTRY DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GL { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1856,7 +1856,7 @@ void GL_APIENTRY DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GL Error error = context->drawArraysInstanced(mode, first, count, instanceCount); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1872,7 +1872,7 @@ void GL_APIENTRY DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -1886,7 +1886,7 @@ void GL_APIENTRY DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, context->drawElementsInstanced(mode, count, type, indices, instanceCount, indexRange); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -1901,19 +1901,19 @@ GLsync GL_APIENTRY FenceSync_(GLenum condition, GLbitfield flags) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return 0; } if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return 0; } if (flags != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return 0; } @@ -1924,7 +1924,7 @@ GLsync GL_APIENTRY FenceSync_(GLenum condition, GLbitfield flags) if (error.isError()) { context->deleteFenceSync(fenceSync); - context->recordError(error); + context->handleError(error); return NULL; } @@ -1943,7 +1943,7 @@ GLboolean GL_APIENTRY IsSync(GLsync sync) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_FALSE; } @@ -1962,13 +1962,13 @@ void GL_APIENTRY DeleteSync(GLsync sync) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync)) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -1986,13 +1986,13 @@ GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeou { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_WAIT_FAILED; } if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return GL_WAIT_FAILED; } @@ -2000,7 +2000,7 @@ GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeou if (!fenceSync) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return GL_WAIT_FAILED; } @@ -2008,7 +2008,7 @@ GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeou Error error = fenceSync->clientWait(flags, timeout, &result); if (error.isError()) { - context->recordError(error); + context->handleError(error); return GL_WAIT_FAILED; } @@ -2028,19 +2028,19 @@ void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (flags != 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } if (timeout != GL_TIMEOUT_IGNORED) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2048,14 +2048,14 @@ void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) if (!fenceSync) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } Error error = fenceSync->serverWait(flags, timeout); if (error.isError()) { - context->recordError(error); + context->handleError(error); } } } @@ -2070,7 +2070,7 @@ void GL_APIENTRY GetInteger64v(GLenum pname, GLint64* params) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2102,13 +2102,13 @@ void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (bufSize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2116,7 +2116,7 @@ void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* if (!fenceSync) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2131,14 +2131,14 @@ void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* Error error = fenceSync->getStatus(values); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } break; } default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2154,7 +2154,7 @@ void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64* data) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2166,7 +2166,7 @@ void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64* data) case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: if (index >= caps.maxTransformFeedbackSeparateAttributes) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; @@ -2176,13 +2176,13 @@ void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64* data) case GL_UNIFORM_BUFFER_BINDING: if (index >= caps.maxUniformBufferBindings) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2192,7 +2192,7 @@ void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64* data) unsigned int numParams = 0; if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2230,19 +2230,19 @@ void GL_APIENTRY GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* pa { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (!ValidBufferTarget(context, target)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (!ValidBufferParameter(context, pname)) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } @@ -2251,7 +2251,7 @@ void GL_APIENTRY GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* pa if (!buffer) { // A null buffer means that "0" is bound to the requested buffer target - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2327,7 +2327,7 @@ GLboolean GL_APIENTRY IsSampler(GLuint sampler) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_FALSE; } @@ -2346,19 +2346,19 @@ void GL_APIENTRY BindSampler(GLuint unit, GLuint sampler) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (sampler != 0 && !context->isSampler(sampler)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (unit >= context->getCaps().maxCombinedTextureImageUnits) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2419,7 +2419,7 @@ void GL_APIENTRY GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* para { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2430,7 +2430,7 @@ void GL_APIENTRY GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* para if (!context->isSampler(sampler)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2447,7 +2447,7 @@ void GL_APIENTRY GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* pa { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2458,7 +2458,7 @@ void GL_APIENTRY GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* pa if (!context->isSampler(sampler)) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2475,13 +2475,13 @@ void GL_APIENTRY VertexAttribDivisor(GLuint index, GLuint divisor) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } if (index >= MAX_VERTEX_ATTRIBS) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2498,7 +2498,7 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2510,14 +2510,14 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id) TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1) if (!context->isTransformFeedbackGenerated(id)) { - context->recordError( + context->handleError( Error(GL_INVALID_OPERATION, "Cannot bind a transform feedback object that does not exist.")); return; @@ -2528,7 +2528,7 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id) break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } @@ -2581,7 +2581,7 @@ GLboolean GL_APIENTRY IsTransformFeedback(GLuint id) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return GL_FALSE; } @@ -2608,7 +2608,7 @@ void GL_APIENTRY PauseTransformFeedback(void) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2618,7 +2618,7 @@ void GL_APIENTRY PauseTransformFeedback(void) // Current transform feedback must be active and not paused in order to pause (3.0.2 pg 86) if (!transformFeedback->isActive() || transformFeedback->isPaused()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2635,7 +2635,7 @@ void GL_APIENTRY ResumeTransformFeedback(void) { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2645,7 +2645,7 @@ void GL_APIENTRY ResumeTransformFeedback(void) // Current transform feedback must be active and paused in order to resume (3.0.2 pg 86) if (!transformFeedback->isActive() || !transformFeedback->isPaused()) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2672,7 +2672,7 @@ void GL_APIENTRY GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* leng Error error = programObject->saveBinary(binaryFormat, binary, bufSize, length); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -2697,7 +2697,7 @@ void GL_APIENTRY ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid Error error = programObject->loadBinary(binaryFormat, binary, length); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -2768,7 +2768,7 @@ void GL_APIENTRY TexStorage2D(GLenum target, GLsizei levels, GLenum internalform { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2783,7 +2783,7 @@ void GL_APIENTRY TexStorage2D(GLenum target, GLsizei levels, GLenum internalform Error error = texture->setStorage(target, levels, internalformat, size); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -2800,7 +2800,7 @@ void GL_APIENTRY TexStorage3D(GLenum target, GLsizei levels, GLenum internalform { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } @@ -2815,7 +2815,7 @@ void GL_APIENTRY TexStorage3D(GLenum target, GLsizei levels, GLenum internalform Error error = texture->setStorage(target, levels, internalformat, size); if (error.isError()) { - context->recordError(error); + context->handleError(error); return; } } @@ -2832,26 +2832,26 @@ void GL_APIENTRY GetInternalformativ(GLenum target, GLenum internalformat, GLenu { if (context->getClientVersion() < 3) { - context->recordError(Error(GL_INVALID_OPERATION)); + context->handleError(Error(GL_INVALID_OPERATION)); return; } const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); if (!formatCaps.renderable) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (target != GL_RENDERBUFFER) { - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } if (bufSize < 0) { - context->recordError(Error(GL_INVALID_VALUE)); + context->handleError(Error(GL_INVALID_VALUE)); return; } @@ -2876,7 +2876,7 @@ void GL_APIENTRY GetInternalformativ(GLenum target, GLenum internalformat, GLenu break; default: - context->recordError(Error(GL_INVALID_ENUM)); + context->handleError(Error(GL_INVALID_ENUM)); return; } } diff --git a/chromium/third_party/angle/src/libGLESv2/global_state.cpp b/chromium/third_party/angle/src/libGLESv2/global_state.cpp index b99c3e1ca9b..fa681bde1f2 100644 --- a/chromium/third_party/angle/src/libGLESv2/global_state.cpp +++ b/chromium/third_party/angle/src/libGLESv2/global_state.cpp @@ -133,7 +133,7 @@ Context *GetValidGlobalContext() { if (context->isContextLost()) { - context->recordError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost.")); + context->handleError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost.")); return nullptr; } else diff --git a/chromium/third_party/angle/src/libGLESv2/libGLESv2.cpp b/chromium/third_party/angle/src/libGLESv2/libGLESv2.cpp index 42b749f3739..cd8cf40ce5c 100644 --- a/chromium/third_party/angle/src/libGLESv2/libGLESv2.cpp +++ b/chromium/third_party/angle/src/libGLESv2/libGLESv2.cpp @@ -1562,4 +1562,15 @@ void GL_APIENTRY glGetPointervKHR(GLenum pname, void **params) { return gl::GetPointervKHR(pname, params); } + +void GL_APIENTRY glBindUniformLocationCHROMIUM(GLuint program, GLint location, const GLchar *name) +{ + return gl::BindUniformLocationCHROMIUM(program, location, name); +} + +void GL_APIENTRY glCoverageModulationCHROMIUM(GLenum components) +{ + return gl::CoverageModulationCHROMIUM(components); +} + } diff --git a/chromium/third_party/angle/src/libGLESv2/libGLESv2.def b/chromium/third_party/angle/src/libGLESv2/libGLESv2.def index 0aebb6c8640..4b98faa7b1a 100644 --- a/chromium/third_party/angle/src/libGLESv2/libGLESv2.def +++ b/chromium/third_party/angle/src/libGLESv2/libGLESv2.def @@ -202,6 +202,8 @@ EXPORTS glGetQueryObjectivEXT @315 glGetQueryObjecti64vEXT @316 glGetQueryObjectui64vEXT @317 + glBindUniformLocationCHROMIUM @318 + glCoverageModulationCHROMIUM @319 ; GLES 3.0 Functions glReadBuffer @180 diff --git a/chromium/third_party/angle/src/tests/angle_end2end_tests.gypi b/chromium/third_party/angle/src/tests/angle_end2end_tests.gypi index 825825a024d..f2e898ff721 100644 --- a/chromium/third_party/angle/src/tests/angle_end2end_tests.gypi +++ b/chromium/third_party/angle/src/tests/angle_end2end_tests.gypi @@ -15,9 +15,13 @@ { 'angle_end2end_tests_sources': [ + '<(angle_path)/src/tests/gl_tests/MultisampleCompatibilityTest.cpp', + '<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp', + '<(angle_path)/src/tests/gl_tests/BindUniformLocationTest.cpp', '<(angle_path)/src/tests/gl_tests/BlendMinMaxTest.cpp', '<(angle_path)/src/tests/gl_tests/BlitFramebufferANGLETest.cpp', '<(angle_path)/src/tests/gl_tests/BufferDataTest.cpp', + '<(angle_path)/src/tests/gl_tests/BuiltinVariableTest.cpp', '<(angle_path)/src/tests/gl_tests/ClearTest.cpp', '<(angle_path)/src/tests/gl_tests/ColorMaskTest.cpp', '<(angle_path)/src/tests/gl_tests/CompressedTextureTest.cpp', @@ -58,6 +62,7 @@ '<(angle_path)/src/tests/gl_tests/SRGBTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/StateChangeTest.cpp', '<(angle_path)/src/tests/gl_tests/SwizzleTest.cpp', + '<(angle_path)/src/tests/gl_tests/SyncQueriesTest.cpp', '<(angle_path)/src/tests/gl_tests/TextureTest.cpp', '<(angle_path)/src/tests/gl_tests/TimerQueriesTest.cpp', '<(angle_path)/src/tests/gl_tests/TransformFeedbackTest.cpp', @@ -68,6 +73,7 @@ '<(angle_path)/src/tests/gl_tests/VertexAttributeTest.cpp', '<(angle_path)/src/tests/gl_tests/ViewportTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLContextCompatibilityTest.cpp', + '<(angle_path)/src/tests/egl_tests/EGLContextSharingTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLQueryContextTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLSanityCheckTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLSurfaceTest.cpp', @@ -89,6 +95,7 @@ '<(angle_path)/src/tests/egl_tests/EGLStreamTest.cpp', # TODO(cwallez) for Linux, requires a portable implementation of threads '<(angle_path)/src/tests/egl_tests/EGLThreadTest.cpp', + '<(angle_path)/src/tests/egl_tests/media/yuvtest.inl', ], 'angle_end2end_tests_x11_sources': [ diff --git a/chromium/third_party/angle/src/tests/angle_perftests.gypi b/chromium/third_party/angle/src/tests/angle_perftests.gypi index c8c07bad42e..5252adde898 100644 --- a/chromium/third_party/angle/src/tests/angle_perftests.gypi +++ b/chromium/third_party/angle/src/tests/angle_perftests.gypi @@ -27,6 +27,7 @@ '<(angle_path)/src/tests/perf_tests/PointSprites.cpp', '<(angle_path)/src/tests/perf_tests/TexSubImage.cpp', '<(angle_path)/src/tests/perf_tests/TextureSampling.cpp', + '<(angle_path)/src/tests/perf_tests/UniformsPerf.cpp', '<(angle_path)/src/tests/perf_tests/third_party/perf/perf_test.cc', '<(angle_path)/src/tests/perf_tests/third_party/perf/perf_test.h', '<(angle_path)/src/tests/test_utils/angle_test_configs.cpp', diff --git a/chromium/third_party/angle/src/tests/deqp.gypi b/chromium/third_party/angle/src/tests/deqp.gypi index 3323deaac90..6500b9c914a 100644 --- a/chromium/third_party/angle/src/tests/deqp.gypi +++ b/chromium/third_party/angle/src/tests/deqp.gypi @@ -1013,6 +1013,9 @@ [ '<(deqp_path)/framework/platform/x11', ], + }], + ['OS=="linux"', + { 'deqp_defines': [ # Ask the system headers to expose all the regular function otherwise @@ -1036,6 +1039,13 @@ '_XOPEN_SOURCE=600', ], }], + ['use_ozone==1', + { + 'deqp_defines': + [ + 'ANGLE_USE_OZONE', + ], + }], ], }, 'conditions': @@ -1373,7 +1383,7 @@ { 'sources': [ '<@(deqp_libtester_sources_win)', ], }], - ['(OS=="linux" and use_x11==1) or OS=="mac"', + ['OS=="linux" or OS=="mac"', { 'sources': [ '<@(deqp_libtester_sources_unix)', ], }], diff --git a/chromium/third_party/angle/src/third_party/libXNVCtrl/BUILD.gn b/chromium/third_party/angle/src/third_party/libXNVCtrl/BUILD.gn index 86dda7ec565..b58a5422be7 100644 --- a/chromium/third_party/angle/src/third_party/libXNVCtrl/BUILD.gn +++ b/chromium/third_party/angle/src/third_party/libXNVCtrl/BUILD.gn @@ -2,11 +2,27 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -static_library("libXNVCtrl") { - sources = [ - "NVCtrl.c", - "NVCtrl.h", - "NVCtrlLib.h", - "nv_control.h", - ] +# This warning disable must be appended to the command line after the general +# warnings setup, so must be in a config. +config("libXNVCtrl_config") { + # This will build under most configurations with this warning enabled, but + # some older system headers are missing a "const" on the third parameter of + # XextAddDisplay which will cause a failure. + cflags = [ + "-Wno-incompatible-pointer-types-discards-qualifiers", + ] +} + +source_set("libXNVCtrl") { + sources = [ + "NVCtrl.c", + "NVCtrl.h", + "NVCtrlLib.h", + "nv_control.h", + ] + + configs += [ + ":libXNVCtrl_config", + "//build/config/linux:x11", + ] } diff --git a/chromium/third_party/angle/util/linux/Linux_system_utils.cpp b/chromium/third_party/angle/util/linux/Linux_system_utils.cpp index dfb80f69409..efc58110a42 100644 --- a/chromium/third_party/angle/util/linux/Linux_system_utils.cpp +++ b/chromium/third_party/angle/util/linux/Linux_system_utils.cpp @@ -39,4 +39,9 @@ std::string GetExecutableDirectory() return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; } +std::string GetSharedLibraryExtension() +{ + return "so"; +} + } // namespace angle diff --git a/chromium/third_party/angle/util/osx/OSX_system_utils.cpp b/chromium/third_party/angle/util/osx/OSX_system_utils.cpp index d6daefa27a4..d22b914b206 100644 --- a/chromium/third_party/angle/util/osx/OSX_system_utils.cpp +++ b/chromium/third_party/angle/util/osx/OSX_system_utils.cpp @@ -42,4 +42,9 @@ std::string GetExecutableDirectory() return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; } +std::string GetSharedLibraryExtension() +{ + return "dylib"; +} + } // namespace angle diff --git a/chromium/third_party/angle/util/ozone/OzonePixmap.cpp b/chromium/third_party/angle/util/ozone/OzonePixmap.cpp new file mode 100644 index 00000000000..cc310a7a053 --- /dev/null +++ b/chromium/third_party/angle/util/ozone/OzonePixmap.cpp @@ -0,0 +1,12 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "OSPixmap.h" + +OSPixmap *CreateOSPixmap() +{ + return nullptr; +} diff --git a/chromium/third_party/angle/util/ozone/OzoneWindow.cpp b/chromium/third_party/angle/util/ozone/OzoneWindow.cpp new file mode 100644 index 00000000000..9feece2161f --- /dev/null +++ b/chromium/third_party/angle/util/ozone/OzoneWindow.cpp @@ -0,0 +1,82 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// OzoneWindow.cpp: Implementation of OSWindow for Ozone + +#include "ozone/OzoneWindow.h" + +int OzoneWindow::sLastDepth = 0; + +OzoneWindow::OzoneWindow() +{ +} + +OzoneWindow::~OzoneWindow() +{ +} + +bool OzoneWindow::initialize(const std::string &name, size_t width, size_t height) +{ + mNative.x = mX = 0; + mNative.y = mY = 0; + mNative.width = mWidth = width; + mNative.height = mHeight = height; + mNative.borderWidth = 5; + mNative.borderHeight = 5; + mNative.visible = 0; + mNative.depth = sLastDepth++; + return true; +} + +void OzoneWindow::destroy() +{ +} + +EGLNativeWindowType OzoneWindow::getNativeWindow() const +{ + return reinterpret_cast<EGLNativeWindowType>(&mNative); +} + +EGLNativeDisplayType OzoneWindow::getNativeDisplay() const +{ + return EGL_DEFAULT_DISPLAY; +} + +void OzoneWindow::messageLoop() +{ +} + +void OzoneWindow::setMousePosition(int x, int y) +{ +} + +bool OzoneWindow::setPosition(int x, int y) +{ + mNative.x = mX = x; + mNative.y = mY = y; + return true; +} + +bool OzoneWindow::resize(int width, int height) +{ + mNative.width = mWidth = width; + mNative.height = mHeight = height; + return true; +} + +void OzoneWindow::setVisible(bool isVisible) +{ + mNative.visible = isVisible; +} + +void OzoneWindow::signalTestEvent() +{ +} + +OSWindow *CreateOSWindow() +{ + return new OzoneWindow(); +} diff --git a/chromium/third_party/angle/util/ozone/OzoneWindow.h b/chromium/third_party/angle/util/ozone/OzoneWindow.h new file mode 100644 index 00000000000..1a2fed50ceb --- /dev/null +++ b/chromium/third_party/angle/util/ozone/OzoneWindow.h @@ -0,0 +1,54 @@ +// +// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// OzoneWindow.h: Definition of the implementation of OSWindow for Ozone + +#ifndef UTIL_OZONE_WINDOW_H +#define UTIL_OZONE_WINDOW_H + +#include <string> + +#include "OSWindow.h" + +class OzoneWindow : public OSWindow +{ + public: + OzoneWindow(); + ~OzoneWindow(); + + bool initialize(const std::string &name, size_t width, size_t height) override; + void destroy() override; + + EGLNativeWindowType getNativeWindow() const override; + EGLNativeDisplayType getNativeDisplay() const override; + + void messageLoop() override; + + void setMousePosition(int x, int y) override; + bool setPosition(int x, int y) override; + bool resize(int width, int height) override; + void setVisible(bool isVisible) override; + + void signalTestEvent() override; + + private: + struct Native + { + int32_t x; + int32_t y; + int32_t width; + int32_t height; + int32_t borderWidth; + int32_t borderHeight; + int32_t visible; + int32_t depth; + }; + + Native mNative; + static int sLastDepth; +}; + +#endif // UTIL_OZONE_WINDOW_H diff --git a/chromium/third_party/angle/util/posix/Posix_system_utils.cpp b/chromium/third_party/angle/util/posix/Posix_system_utils.cpp index 36007f7a6e3..010735b3bf6 100644 --- a/chromium/third_party/angle/util/posix/Posix_system_utils.cpp +++ b/chromium/third_party/angle/util/posix/Posix_system_utils.cpp @@ -9,6 +9,7 @@ #include "system_utils.h" #include <sys/resource.h> +#include <dlfcn.h> #include <sched.h> #include <time.h> #include <unistd.h> @@ -46,4 +47,45 @@ void WriteDebugMessage(const char *format, ...) // TODO(jmadill): Implement this } +class PosixLibrary : public Library +{ + public: + PosixLibrary(const std::string &libraryName); + ~PosixLibrary() override; + + void *getSymbol(const std::string &symbolName) override; + + private: + void *mModule; +}; + +PosixLibrary::PosixLibrary(const std::string &libraryName) : mModule(nullptr) +{ + const auto &fullName = libraryName + "." + GetSharedLibraryExtension(); + mModule = dlopen(fullName.c_str(), RTLD_NOW); +} + +PosixLibrary::~PosixLibrary() +{ + if (mModule) + { + dlclose(mModule); + } +} + +void *PosixLibrary::getSymbol(const std::string &symbolName) +{ + if (!mModule) + { + return nullptr; + } + + return dlsym(mModule, symbolName.c_str()); +} + +Library *loadLibrary(const std::string &libraryName) +{ + return new PosixLibrary(libraryName); +} + } // namespace angle diff --git a/chromium/third_party/angle/util/system_utils.h b/chromium/third_party/angle/util/system_utils.h index 9767b0e4072..42c20d8f0e5 100644 --- a/chromium/third_party/angle/util/system_utils.h +++ b/chromium/third_party/angle/util/system_utils.h @@ -6,16 +6,19 @@ // system_utils.h: declaration of OS-specific utility functions -#ifndef SAMPLE_UTIL_PATH_UTILS_H -#define SAMPLE_UTIL_PATH_UTILS_H +#ifndef UTIL_SYSTEM_UTILS_H_ +#define UTIL_SYSTEM_UTILS_H_ #include <string> +#include "common/angleutils.h" + namespace angle { std::string GetExecutablePath(); std::string GetExecutableDirectory(); +std::string GetSharedLibraryExtension(); // Cross platform equivalent of the Windows Sleep function void Sleep(unsigned int milliseconds); @@ -25,6 +28,15 @@ void SetLowPriorityProcess(); // Write a debug message, either to a standard output or Debug window. void WriteDebugMessage(const char *format, ...); +class Library : angle::NonCopyable +{ + public: + virtual ~Library() {} + virtual void *getSymbol(const std::string &symbolName) = 0; +}; + +Library *loadLibrary(const std::string &libraryName); + } // namespace angle -#endif // SAMPLE_UTIL_PATH_UTILS_H +#endif // UTIL_SYSTEM_UTILS_H_ diff --git a/chromium/third_party/angle/util/util.gyp b/chromium/third_party/angle/util/util.gyp index c29fffca286..88f8d7b030f 100644 --- a/chromium/third_party/angle/util/util.gyp +++ b/chromium/third_party/angle/util/util.gyp @@ -66,6 +66,12 @@ 'x11/X11Window.cpp', 'x11/X11Window.h', ], + 'util_ozone_sources': + [ + 'ozone/OzonePixmap.cpp', + 'ozone/OzoneWindow.cpp', + 'ozone/OzoneWindow.h', + ], 'util_osx_sources': [ 'osx/OSX_system_utils.cpp', @@ -162,6 +168,13 @@ ], }, }], + ['use_ozone==1', + { + 'sources': + [ + '<@(util_ozone_sources)', + ], + }], ['OS=="mac"', { 'sources': diff --git a/chromium/third_party/angle/util/windows/Windows_system_utils.cpp b/chromium/third_party/angle/util/windows/Windows_system_utils.cpp index 516e882926e..9c971658589 100644 --- a/chromium/third_party/angle/util/windows/Windows_system_utils.cpp +++ b/chromium/third_party/angle/util/windows/Windows_system_utils.cpp @@ -31,6 +31,11 @@ std::string GetExecutableDirectory() return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; } +std::string GetSharedLibraryExtension() +{ + return "dll"; +} + void Sleep(unsigned int milliseconds) { ::Sleep(static_cast<DWORD>(milliseconds)); diff --git a/chromium/third_party/angle/util/windows/win32/Win32_system_utils.cpp b/chromium/third_party/angle/util/windows/win32/Win32_system_utils.cpp index 39807baa784..a9fd97fe731 100644 --- a/chromium/third_party/angle/util/windows/win32/Win32_system_utils.cpp +++ b/chromium/third_party/angle/util/windows/win32/Win32_system_utils.cpp @@ -19,4 +19,45 @@ void SetLowPriorityProcess() SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); } +class Win32Library : public Library +{ + public: + Win32Library(const std::string &libraryName); + ~Win32Library() override; + + void *getSymbol(const std::string &symbolName) override; + + private: + HMODULE mModule; +}; + +Win32Library::Win32Library(const std::string &libraryName) : mModule(nullptr) +{ + const auto &fullName = libraryName + "." + GetSharedLibraryExtension(); + mModule = LoadLibraryA(fullName.c_str()); +} + +Win32Library::~Win32Library() +{ + if (mModule) + { + FreeLibrary(mModule); + } +} + +void *Win32Library::getSymbol(const std::string &symbolName) +{ + if (!mModule) + { + return nullptr; + } + + return GetProcAddress(mModule, symbolName.c_str()); +} + +Library *loadLibrary(const std::string &libraryName) +{ + return new Win32Library(libraryName); +} + } // namespace angle diff --git a/chromium/third_party/angle/util/windows/winrt/WinRT_system_utils.cpp b/chromium/third_party/angle/util/windows/winrt/WinRT_system_utils.cpp index 593c5f465d3..8513bacd915 100644 --- a/chromium/third_party/angle/util/windows/winrt/WinRT_system_utils.cpp +++ b/chromium/third_party/angle/util/windows/winrt/WinRT_system_utils.cpp @@ -19,4 +19,10 @@ void SetLowPriorityProcess() // No equivalent to this in WinRT } +Library *loadLibrary(const std::string &libraryName) +{ + // WinRT cannot load code dynamically. + return nullptr; +} + } // namespace angle |