| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 | 1330 |
| 1331 // Checks if a draw buffer's format and its corresponding fragment shader | 1331 // Checks if a draw buffer's format and its corresponding fragment shader |
| 1332 // output's type are compatible, i.e., a signed integer typed variable is | 1332 // output's type are compatible, i.e., a signed integer typed variable is |
| 1333 // incompatible with a float or unsigned integer buffer. | 1333 // incompatible with a float or unsigned integer buffer. |
| 1334 // If incompaticle, generates an INVALID_OPERATION to avoid undefined buffer | 1334 // If incompaticle, generates an INVALID_OPERATION to avoid undefined buffer |
| 1335 // contents and return false. | 1335 // contents and return false. |
| 1336 // Otherwise, filter out the draw buffers that are not written to but are not | 1336 // Otherwise, filter out the draw buffers that are not written to but are not |
| 1337 // NONE through DrawBuffers, to be on the safe side. Return true. | 1337 // NONE through DrawBuffers, to be on the safe side. Return true. |
| 1338 bool ValidateAndAdjustDrawBuffers(const char* function_name); | 1338 bool ValidateAndAdjustDrawBuffers(const char* function_name); |
| 1339 | 1339 |
| 1340 // Filter out the draw buffers that have no images attached but are not NONE |
| 1341 // through DrawBuffers, to be on the safe side. |
| 1342 void AdjustDrawBuffers(); |
| 1343 |
| 1340 // Checks if all active uniform blocks in the current program are backed by | 1344 // Checks if all active uniform blocks in the current program are backed by |
| 1341 // a buffer of sufficient size. | 1345 // a buffer of sufficient size. |
| 1342 // If not, generates an INVALID_OPERATION to avoid undefined behavior in | 1346 // If not, generates an INVALID_OPERATION to avoid undefined behavior in |
| 1343 // shader execution and return false. | 1347 // shader execution and return false. |
| 1344 bool ValidateUniformBlockBackings(const char* function_name); | 1348 bool ValidateUniformBlockBackings(const char* function_name); |
| 1345 | 1349 |
| 1346 // Checks if |api_type| is valid for the given uniform | 1350 // Checks if |api_type| is valid for the given uniform |
| 1347 // If the api type is not valid generates the appropriate GL | 1351 // If the api type is not valid generates the appropriate GL |
| 1348 // error. Returns true if |api_type| is valid for the uniform | 1352 // error. Returns true if |api_type| is valid for the uniform |
| 1349 bool CheckUniformForApiType(const Program::UniformInfo* info, | 1353 bool CheckUniformForApiType(const Program::UniformInfo* info, |
| (...skipping 5930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7280 } | 7284 } |
| 7281 if (mask & GL_COLOR_BUFFER_BIT) { | 7285 if (mask & GL_COLOR_BUFFER_BIT) { |
| 7282 Framebuffer* framebuffer = | 7286 Framebuffer* framebuffer = |
| 7283 framebuffer_state_.bound_draw_framebuffer.get(); | 7287 framebuffer_state_.bound_draw_framebuffer.get(); |
| 7284 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { | 7288 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { |
| 7285 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7289 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7286 "can't be called on integer buffers"); | 7290 "can't be called on integer buffers"); |
| 7287 return error::kNoError; | 7291 return error::kNoError; |
| 7288 } | 7292 } |
| 7289 } | 7293 } |
| 7294 AdjustDrawBuffers(); |
| 7290 glClear(mask); | 7295 glClear(mask); |
| 7291 } | 7296 } |
| 7292 return error::kNoError; | 7297 return error::kNoError; |
| 7293 } | 7298 } |
| 7294 | 7299 |
| 7295 void GLES2DecoderImpl::DoClearBufferiv(GLenum buffer, | 7300 void GLES2DecoderImpl::DoClearBufferiv(GLenum buffer, |
| 7296 GLint drawbuffer, | 7301 GLint drawbuffer, |
| 7297 const volatile GLint* value) { | 7302 const volatile GLint* value) { |
| 7298 const char* func_name = "glClearBufferiv"; | 7303 const char* func_name = "glClearBufferiv"; |
| 7299 if (!CheckBoundDrawFramebufferValid(func_name)) | 7304 if (!CheckBoundDrawFramebufferValid(func_name)) |
| (...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8839 state_.current_program->fragment_output_written_mask(); | 8844 state_.current_program->fragment_output_written_mask(); |
| 8840 if (!framebuffer->ValidateAndAdjustDrawBuffers( | 8845 if (!framebuffer->ValidateAndAdjustDrawBuffers( |
| 8841 fragment_output_type_mask, fragment_output_written_mask)) { | 8846 fragment_output_type_mask, fragment_output_written_mask)) { |
| 8842 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 8847 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 8843 "buffer format and fragment output variable type incompatible"); | 8848 "buffer format and fragment output variable type incompatible"); |
| 8844 return false; | 8849 return false; |
| 8845 } | 8850 } |
| 8846 return true; | 8851 return true; |
| 8847 } | 8852 } |
| 8848 | 8853 |
| 8854 void GLES2DecoderImpl::AdjustDrawBuffers() { |
| 8855 if (!SupportsDrawBuffers()) { |
| 8856 return; |
| 8857 } |
| 8858 Framebuffer* framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); |
| 8859 if (framebuffer) { |
| 8860 framebuffer->AdjustDrawBuffers(); |
| 8861 } |
| 8862 } |
| 8863 |
| 8849 bool GLES2DecoderImpl::ValidateUniformBlockBackings(const char* func_name) { | 8864 bool GLES2DecoderImpl::ValidateUniformBlockBackings(const char* func_name) { |
| 8850 DCHECK(feature_info_->IsWebGL2OrES3Context()); | 8865 DCHECK(feature_info_->IsWebGL2OrES3Context()); |
| 8851 if (!state_.current_program.get()) | 8866 if (!state_.current_program.get()) |
| 8852 return true; | 8867 return true; |
| 8853 int32_t max_index = -1; | 8868 int32_t max_index = -1; |
| 8854 for (auto info : state_.current_program->uniform_block_size_info()) { | 8869 for (auto info : state_.current_program->uniform_block_size_info()) { |
| 8855 int32_t index = static_cast<int32_t>(info.binding); | 8870 int32_t index = static_cast<int32_t>(info.binding); |
| 8856 if (index > max_index) | 8871 if (index > max_index) |
| 8857 max_index = index; | 8872 max_index = index; |
| 8858 } | 8873 } |
| (...skipping 10259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19118 } | 19133 } |
| 19119 | 19134 |
| 19120 // Include the auto-generated part of this file. We split this because it means | 19135 // Include the auto-generated part of this file. We split this because it means |
| 19121 // we can easily edit the non-auto generated parts right here in this file | 19136 // we can easily edit the non-auto generated parts right here in this file |
| 19122 // instead of having to edit some template or the code generator. | 19137 // instead of having to edit some template or the code generator. |
| 19123 #include "base/macros.h" | 19138 #include "base/macros.h" |
| 19124 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19139 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19125 | 19140 |
| 19126 } // namespace gles2 | 19141 } // namespace gles2 |
| 19127 } // namespace gpu | 19142 } // namespace gpu |
| OLD | NEW |