aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/buffers.c
Commit message (Collapse)AuthorAgeFilesLines
* mesa: add KHR_no_error support for gl*ReadBuffer()Samuel Pitoiset2017-06-281-0/+33
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: create read_buffer_err() and always inline read_buffer()Samuel Pitoiset2017-06-281-18/+31
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa/main: fix gl_buffer_index enum comparisonRob Herring2017-06-071-4/+4
| | | | | | | | | | | | | | For clang, enums are unsigned by default and gives the following warning: external/mesa3d/src/mesa/main/buffers.c:764:21: warning: comparison of constant -1 with expression of type 'gl_buffer_index' is always false [-Wtautological-constant-out-of-range-compare] if (srcBuffer == -1) { ~~~~~~~~~ ^ ~~ Replace -1 with an enum value to fix this. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]> Signed-off-by: Rob Herring <[email protected]>
* main/buffers: take into account FRONT_AND_BACK on ReadBufferAlejandro Piñeiro2017-01-121-0/+2
| | | | | | | | | | | | | | | | | | From OpenGL 3.1 spec, section 4.3.1 "Reading Pixels", page 190 (203 PDF) "When READ FRAMEBUFFER BINDING is zero, i.e. the default framebuffer, src must be one of the values listed in table 4.4, including NONE . FRONT_AND_BACK , FRONT , and LEFT refer to the front left buffer." There is an equivalent text on OpenGL 4.5 spec, section 18.2.1 "Selecting Buffers for Reading", page 502 (524 PDF), so the behaviour is still the same. Part of the fix for: GL45-CTS.direct_state_access.framebuffers_draw_read_buffers_errors Reviewed-by: Anuj Phogat <[email protected]>
* main/buffers: update error handling on DrawBuffers for 4.5Alejandro Piñeiro2017-01-121-13/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before 4.5, GL_BACK was not allowed as a value of bufs. Since 4.5 it is allowed under some circumstances: From the OpenGL 4.5 specification, Section 17.4.1 "Selecting Buffers for Writing", page 493 (page 515 of the PDF): "An INVALID_ENUM error is generated if any value in bufs is FRONT, LEFT, RIGHT, or FRONT_AND_BACK . This restriction applies to both the de- fault framebuffer and framebuffer objects, and exists because these constants may themselves refer to multiple buffers, as shown in table 17.4." And on page 492 (page 514 of the PDF): "If the default framebuffer is affected, then each of the constants must be one of the values listed in table 17.6 or the special value BACK . When BACK is used, n must be 1 and color values are written into the left buffer for single-buffered contexts, or into the back left buffer for double-buffered contexts." This patch keeps the same behaviour if OpenGL version is < 4. We assume that for 4.x this is the intended behaviour, so a fix, but for 3.x the intended behaviour is the already in place. Part of the fix for: GL45-CTS.direct_state_access.framebuffers_draw_read_buffers_errors v2: remove forgot printf v3: remove spaces before commas on spec quote, split line too long (Anuj) Reviewed-by: Anuj Phogat <[email protected]>
* mesa: fix error handling in DrawBuffersTapani Pälli2016-10-251-34/+37
| | | | | | | | | | | | | | | | | | | | | | Patch rearranges error checking so that enum checking provided via destmask happens before other checks. It needs to be done in this order because other error checks do not work properly if there were invalid enums passed. Patch also refines one existing check and it's documentation to match GLES 3.0 spec (also in later specs). This was somewhat mysteriously referring to desktop GL but had a check for gles3. Fixes following dEQP tests: dEQP-GLES31.functional.debug.negative_coverage.get_error.buffer.draw_buffers no CI regressions observed. Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98134 Cc: "12.0 13.0" <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* mesa: Make single-buffered GLES representation internally consistentGurchetan Singh2016-07-071-2/+12
| | | | | | | | | | | | | There are a few places in the code where clearing and reading are done on incorrect buffers for GLES contexts. See comments for details. This fixes 75 GLES3 dEQP tests on the surfaceless platform with no regressions. v2: Corrected unclear comment v3: Make the change in context.c instead of get.c v4: Removed whitespace Reviewed-by: Stéphane Marchesin <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* mesa: Make use of u_bit_scan{,64}.Mathias Fröhlich2016-06-141-2/+2
| | | | | | Reviewed-by: Brian Paul <[email protected]> Tested-by: Brian Paul <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
* mesa: Check glReadBuffer enums against the ES3 table.Kenneth Graunke2016-03-241-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | From the ES 3.2 spec, section 16.1.1 (Selecting Buffers for Reading): "An INVALID_ENUM error is generated if src is not BACK or one of the values from table 15.5." Table 15.5 contains NONE and COLOR_ATTACHMENTi. Mesa properly returned INVALID_ENUM for unknown enums, but it decided what was known by using read_buffer_enum_to_index, which handles all enums in every API. So enums that were valid in GL were making it past the "valid enum" check. Such targets would then be classified as unsupported, and we'd raise INVALID_OPERATION, but that's technically the wrong error code. Fixes dEQP-GLES31's functional.debug.negative_coverage.get_error.buffer.read_buffer v2: Only call read_buffer_enuM_to_index when required (Eduardo). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
* mesa: replace for loop with bitshifting in supported_buffer_bitmask()Brian Paul2016-02-241-4/+1
| | | | | Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: updates some comments in buffers.cBrian Paul2016-02-241-3/+6
| | | | | Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: make _mesa_draw_buffers() staticBrian Paul2016-02-241-7/+7
| | | | | Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: make _mesa_draw_buffer() staticBrian Paul2016-02-241-6/+6
| | | | | Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: make _mesa_read_buffer() staticBrian Paul2016-02-241-6/+7
| | | | | | | Not called from any other file. Remove _mesa_ prefix and update comments. Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: use gl_buffer_index in a few placesBrian Paul2016-02-241-3/+3
| | | | | Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: recognize enums GL_COLOR_ATTACHMENT8-31 as validIlia Mirkin2016-02-121-0/+6
| | | | | | | | | | | | Similar as for AUX1-3, these enums aren't invalid (i.e. -1) but also not supported by mesa. Returning BUFFER_COUNT causes the proper error to be returned by ReadBuffer and other functions. This resolves some failures in dEQP-GLES31.functional.debug.negative_coverage.get_error.buffer.read_buffer Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: update some old-style (K&R?) function pointer callsBrian Paul2015-11-201-1/+1
| | | | Reviewed-by: Emil Velikov <[email protected]>
* mesa: Rename _mesa_lookup_enum_by_nr() to _mesa_enum_to_string().Kenneth Graunke2015-07-201-11/+11
| | | | | | | Generated by sed; no manual changes. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* Revert "mesa: Add ARB_direct_state_access checks in FBO functions"Ian Romanick2015-05-281-21/+0
| | | | | | | This reverts commit 6ad0b7e07a0445e9e0f368e079c4f7b8a6757bb3. Acked-by: Fredrik Höglund <[email protected]> Cc: "10.6" <[email protected]>
* mesa: Add ARB_direct_state_access checks in FBO functionsFredrik Höglund2015-05-141-0/+21
| | | | | Signed-off-by: Fredrik Höglund <[email protected]> Reviewed-by: Adam Jackson <[email protected]>
* main: Add entry point for NamedFramebufferDrawBuffers.Laura Ekstrand2015-05-141-0/+20
| | | | | Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* main: Refactor DrawBuffers.Laura Ekstrand2015-05-141-23/+48
| | | | | | | | | | | | | | This could have added a new DD table entry for DrawBuffers that takes an arbitrary draw buffer, but, after looking at the existing DD functions, Kenneth Graunke recommended that we just skip calling the DD functions in the case of ARB_direct_state_access. The DD implementations for DrawBuffer(s) have limited functionality, especially with respect to ARB_direct_state_access. [Fredrik: Call the driver function when fb is the bound draw buffer] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* main: Add entry point for NamedFramebufferReadBuffer.Laura Ekstrand2015-05-141-0/+19
| | | | | | | [Fredrik: Fix the name of the buf parameter in the XML file] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* main: Refactor _mesa_ReadBuffer.Laura Ekstrand2015-05-141-22/+25
| | | | | | | | | | | | | | This could have added a new DD table entry for ReadBuffer that takes an arbitrary read buffer, but, after looking at the existing DD functions, Kenneth Graunke recommended that we just skip calling the DD functions in the case of ARB_direct_state_access. The DD implementations for ReadBuffer have limited functionality, especially with respect to ARB_direct_state_access. [Fredrik: Call the driver function when fb is the bound read buffer] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* main: Add entry point for NamedFramebufferDrawBuffer.Laura Ekstrand2015-05-141-0/+19
| | | | | | | [Fredrik: Fix the name of the buf parameter in the XML file] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* main: Refactor _mesa_DrawBuffer.Laura Ekstrand2015-05-141-17/+25
| | | | | | | | | | | | | | This could have added a new DD table entry for DrawBuffer that takes an arbitrary draw buffer, but, after looking at the existing DD functions, Kenneth Graunke recommended that we just skip calling the DD functions in the case of ARB_direct_state_access. The DD implementations for DrawBuffer(s) have limited functionality, especially with respect to ARB_direct_state_access. [Fredrik: Call the driver function when fb is the bound draw buffer] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* main: Refactor _mesa_drawbuffers.Laura Ekstrand2015-05-141-14/+12
| | | | | | | [Fredrik: Whitespace fix] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
* mesa: Use assert() instead of ASSERT wrapper.Matt Turner2015-02-231-2/+2
| | | | Acked-by: Eric Anholt <[email protected]>
* mesa: Check that draw buffers are valid for glDrawBuffers on GLES3Eduardo Lima Mitev2015-02-201-0/+14
| | | | | | | | | | | | | Section 4.2 (Whole Framebuffer Operations) of the OpenGL 3.0 specification says: "Each buffer listed in bufs must be BACK, NONE, or one of the values from table 4.3 (NONE, COLOR_ATTACHMENTi)". Fixes 1 dEQP test: * dEQP-GLES3.functional.negative_api.buffer.draw_buffers Reviewed-by: Matt Turner <[email protected]>
* mesa: Fix some signed-unsigned comparison warningsJan Vesely2015-01-211-1/+1
| | | | | | | | v2: s/unsigned int/unsigned/ in prog_optimize.c Signed-off-by: Jan Vesely <[email protected]> Reviewed-by: David Heidelberg <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* mesa/glsl/glapi: enable GL_EXT_draw_buffers extensionTapani Pälli2015-01-141-2/+4
| | | | | | | | | | | | | | | | Patch enables ES2 extension that utilizes existing ES3 functionality. Changes make all the subtests to run and pass in WebGL conformance test 'webgl-draw-buffers' when running Chrome on OpenGL ES, also Piglit test 'draw_buffers_gles2' passes. v2: remove unused boolean (Ilia Mirkin) v3: proper error checking for invalid values (Chad Versace) v4: run error check explicitly for ES2 and ES3 (Kenneth Graunke) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* mesa: trim down some #includesBrian Paul2014-09-101-1/+0
|
* mesa: fix NULL pointer deref bug in _mesa_drawbuffers()Brian Paul2014-08-191-1/+1
| | | | | | | | | This is a follow-on fix to commit 39b40ad144. Fixes a crash if the user calls glDrawBuffers(0, NULL). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82814 Cc: "10.2" <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: simplify _mesa_update_draw_buffers()Brian Paul2014-08-111-7/+2
| | | | | | | There's no need to copy the array of DrawBuffer enums to a temp array. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: fix assertion in _mesa_drawbuffers()Brian Paul2014-08-111-2/+3
| | | | | | | | | | Fixes failed assertion when _mesa_update_draw_buffers() was called with GL_DRAW_BUFFER == GL_FRONT_AND_BACK. The piglit gl30basic hit this. Cc: "10.2" <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* Use the magic behaviour of GL_BACK in GLES 1 and 2 as well as 3Neil Roberts2014-03-121-1/+6
| | | | | | | | | | | | | | | | | | In GLES 3 it is not possible to select rendering to the front buffer and instead selecting GL_BACK has the magic interpretation that it is either the front buffer on single-buffered configs or the back buffer on double-buffered. GLES 1 and 2 have no way of selecting the draw buffer at all. In that case we were initialising the draw buffer to either GL_FRONT or GL_BACK depending on the context's config and then leaving it at that. When we switch to having configless contexts we ideally want Mesa to automatically switch between the front and back buffer whenever a double- or single-buffered surface is bound. To make this happen we can just allow the magic behaviour from GLES 3 in GLES 1 and 2 as well. It shouldn't matter what the internal value of the draw buffer is in GLES 1 and 2 because there is no way to query it from the external API. Reviewed-by: Kristian Høgsberg <[email protected]>
* mesa: Generate correct error code in glDrawBuffers()Anuj Phogat2014-01-281-3/+5
| | | | | | | | | | | | | | | | | | | | | | | OpenGL 3.3 spec expects GL_INVALID_OPERATION: "For both the default framebuffer and framebuffer objects, the constants FRONT, BACK, LEFT, RIGHT, and FRONT AND BACK are not valid in the bufs array passed to DrawBuffers, and will result in the error INVALID OPERATION." But OpenGL 4.0 spec changed the error code to GL_INVALID_ENUM: "For both the default framebuffer and framebuffer objects, the constants FRONT, BACK, LEFT, RIGHT, and FRONT_AND_BACK are not valid in the bufs array passed to DrawBuffers, and will result in the error INVALID_ENUM." This patch changes the behaviour to match OpenGL 4.0 spec Fixes Khronos OpenGL CTS draw_buffers_api.test. V2: Update the comment in code. Cc: [email protected] Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: GL_EXT_framebuffer_object is not optionalIan Romanick2013-06-281-1/+0
| | | | | | | | | Every driver left in Mesa enables this extension all the time. There's no reason to let it be optional. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: remove outdated version lines in commentsRico Schüller2013-06-051-1/+0
| | | | Signed-off-by: Brian Paul <[email protected]>
* mesa: updated read_buffer_enum_to_index() commentBrian Paul2013-04-261-2/+2
| | | | Remove the part about the value of gl_framebuffer::Name.
* mesa: Restore 78-column wrapping of license text in C-style comments.Kenneth Graunke2013-04-231-3/+4
| | | | | | | | | | | | | | The previous commit introduced extra words, breaking the formatting. This text transformation was done automatically via the following shell command: $ git grep 'THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY' | sed 's/:.*$//' | xargs -I {} sh -c 'vim -e -s {} < vimscript where 'vimscript' is a file containing: /THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY/;/\*\// !fmt -w 78 -p ' * ' :wq Reviewed-by: Brian Paul <[email protected]>
* mesa: Add "OR COPYRIGHT HOLDERS" to license text disclaiming liability.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | This brings the license text in line with the MIT License as published on the Open Source Initiative website: http://opensource.org/licenses/mit-license.php Generated automatically be the following shell command: $ git grep 'THE AUTHORS BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/THE AUTHORS/THE AUTHORS OR COPYRIGHT HOLDERS/' {} This introduces some wrapping issues, to be fixed in the next commit. Reviewed-by: Brian Paul <[email protected]>
* mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | | Generated automatically be the following shell command: $ git grep 'BRIAN PAUL BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/BRIAN PAUL/THE AUTHORS/' {} The intention here is to protect all authors, not just Brian Paul. I believe that was already the sensible interpretation, but spelling it out is probably better. More practically, it also prevents people from accidentally copy & pasting the license into a new file which says Brian is not liable when he isn't even one of the authors. Reviewed-by: Brian Paul <[email protected]>
* mesa: remove redundant _NEW_BUFFERS setting in ReadBufferMarek Olšák2013-04-241-1/+0
| | | | | | | already set by _mesa_readbuffer Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Drop manual checks for outside begin/end.Eric Anholt2013-01-211-3/+6
| | | | | | | | | | | We now have a separate dispatch table for begin/end that prevent these functions from being entered during that time. The ASSERT_OUTSIDE_BEGIN_END_WITH_RETVALs are left because I don't want to change any return values or introduce new error-only stubs at this point. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Make ES3 glDrawBuffers() only accept BACK/NONE for the winsys fbo.Kenneth Graunke2013-01-151-5/+17
| | | | | | | | | | | | Nothing was explicitly checking this. v2: Update GL3 spec reference. Signed-off-by: Anuj Phogat <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Signed-off-by: Ian Romanick <[email protected]> [v2] Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v1]
* mesa: Handle GL_BACK correctly for ES 3.0 in glDrawBuffers().Kenneth Graunke2013-01-151-4/+19
| | | | | | | | | | | | | | | | | | | | | In ES 3.0, when calling glDrawBuffers() on the window system framebuffer, the only valid targets are GL_NONE or GL_BACK. Since there is no stereo rendering in ES 3.0, this is a single buffer, unlike desktop where it may be two (and thus isn't allowed). For single-buffered configs, GL_BACK ironically means the front (and only) buffer. I'm not sure that it matters, however, as ES shouldn't have front buffer rendering in the first place. Fixes es3conform framebuffer_blit_coverage_default_draw_buffer_binding. v2: Update GLES3 spec reference. Signed-off-by: Anuj Phogat <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Signed-off-by: Ian Romanick <[email protected]> [v2] Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v1]
* mesa: Rework crazy error code rules in glDrawBuffers().Kenneth Graunke2013-01-151-3/+63
| | | | | | | | | | | | | | | | | | | | | | | Perhaps most importantly, this patch adds comments quoting the relevant spec paragraphs above each error condition. It also makes three changes: - For FBOs, GL_COLOR_ATTACHMENTm where m >= MaxDrawBuffers is supposed to generate INVALID_OPERATION (not INVALID_ENUM). - Constants that refer to multiple buffers (such as FRONT, BACK, LEFT, RIGHT, and FRONT_AND_BACK) are supposed to generate INVALID_OPERATION, not INVALID_ENUM. - In ES 3.0, for FBOs, buffers[i] must be NONE or GL_COLOR_ATTACHMENTi or else INVALID_OPERATION occurs. (This is a new restriction.) Fixes es3conform's draw-buffers-api test. v2: The error path was missing a "return" like all the other error paths. Also, we may as well call it glDrawBuffers in the error message since the ARB suffix doesn't exist in ES 3. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Allow glReadBuffer(GL_NONE) for winsys framebuffers.Paul Berry2012-12-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | Previously, Mesa code assumed that glReadBuffer(GL_NONE) was only valid for user-created framebuffer objects. However, the spec is quite clear that is should also be valid for the default framebuffer. From section 18.2.1 ("Obtaining Pixels from the Framebuffer") of the GL 4.3 spec: "When READ_FRAMEBUFFER_BINDING is zero, i.e. the default framebuffer, src must be one of the values listed in table 17.4, including NONE." Similar language exists in the GLES 3.0 spec, and in desktop GL all the way back to ARB_framebuffer_object. Partially fixes GLES3 conformance test "CoverageES30.test". NOTE: This is a candidate for stable branches. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Rename API_OPENGL to API_OPENGL_COMPAT.Paul Berry2012-11-291-1/+1
| | | | | | | | | | This should help avoid confusion now that we're using the gl_api enum to distinguishing between core and compatibility API's. The corresponding enum value for core API's is API_OPENGL_CORE. Acked-by: Eric Anholt <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Kenneth Graunke <[email protected]>