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 6799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6810 } | 6810 } |
6811 } else { | 6811 } else { |
6812 LOCAL_SET_GL_ERROR( | 6812 LOCAL_SET_GL_ERROR( |
6813 GL_INVALID_VALUE, "glDeleteProgram", "unknown program"); | 6813 GL_INVALID_VALUE, "glDeleteProgram", "unknown program"); |
6814 } | 6814 } |
6815 } | 6815 } |
6816 return error::kNoError; | 6816 return error::kNoError; |
6817 } | 6817 } |
6818 | 6818 |
6819 error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) { | 6819 error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) { |
| 6820 const char* func_name = "glClear"; |
6820 DCHECK(!ShouldDeferDraws()); | 6821 DCHECK(!ShouldDeferDraws()); |
6821 if (CheckBoundDrawFramebufferValid("glClear")) { | 6822 if (CheckBoundDrawFramebufferValid(func_name)) { |
6822 ApplyDirtyState(); | 6823 ApplyDirtyState(); |
6823 if (workarounds().gl_clear_broken) { | 6824 if (workarounds().gl_clear_broken) { |
6824 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::ClearWorkaround", | 6825 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::ClearWorkaround", |
6825 GetErrorState()); | 6826 GetErrorState()); |
6826 if (!BoundFramebufferHasDepthAttachment()) | 6827 if (!BoundFramebufferHasDepthAttachment()) |
6827 mask &= ~GL_DEPTH_BUFFER_BIT; | 6828 mask &= ~GL_DEPTH_BUFFER_BIT; |
6828 if (!BoundFramebufferHasStencilAttachment()) | 6829 if (!BoundFramebufferHasStencilAttachment()) |
6829 mask &= ~GL_STENCIL_BUFFER_BIT; | 6830 mask &= ~GL_STENCIL_BUFFER_BIT; |
6830 clear_framebuffer_blit_->ClearFramebuffer( | 6831 clear_framebuffer_blit_->ClearFramebuffer( |
6831 this, GetBoundReadFrameBufferSize(), mask, state_.color_clear_red, | 6832 this, GetBoundReadFrameBufferSize(), mask, state_.color_clear_red, |
6832 state_.color_clear_green, state_.color_clear_blue, | 6833 state_.color_clear_green, state_.color_clear_blue, |
6833 state_.color_clear_alpha, state_.depth_clear, state_.stencil_clear); | 6834 state_.color_clear_alpha, state_.depth_clear, state_.stencil_clear); |
6834 return error::kNoError; | 6835 return error::kNoError; |
6835 } | 6836 } |
| 6837 if (mask & GL_COLOR_BUFFER_BIT) { |
| 6838 Framebuffer* framebuffer = |
| 6839 framebuffer_state_.bound_draw_framebuffer.get(); |
| 6840 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { |
| 6841 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6842 "can't be called on integer buffers"); |
| 6843 return error::kNoError; |
| 6844 } |
| 6845 } |
6836 glClear(mask); | 6846 glClear(mask); |
6837 } | 6847 } |
6838 return error::kNoError; | 6848 return error::kNoError; |
6839 } | 6849 } |
6840 | 6850 |
6841 void GLES2DecoderImpl::DoClearBufferiv( | 6851 void GLES2DecoderImpl::DoClearBufferiv( |
6842 GLenum buffer, GLint drawbuffer, const GLint* value) { | 6852 GLenum buffer, GLint drawbuffer, const GLint* value) { |
6843 if (!CheckBoundDrawFramebufferValid("glClearBufferiv")) | 6853 const char* func_name = "glClearBufferiv"; |
| 6854 if (!CheckBoundDrawFramebufferValid(func_name)) |
6844 return; | 6855 return; |
6845 ApplyDirtyState(); | 6856 ApplyDirtyState(); |
6846 | 6857 |
6847 if (buffer == GL_COLOR) { | 6858 if (buffer == GL_COLOR) { |
6848 if (drawbuffer < 0 || | 6859 if (drawbuffer < 0 || |
6849 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6860 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
6850 LOCAL_SET_GL_ERROR( | 6861 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
6851 GL_INVALID_VALUE, "glClearBufferiv", "invalid drawBuffer"); | |
6852 return; | 6862 return; |
6853 } | 6863 } |
6854 GLenum internal_format = | 6864 GLenum internal_format = |
6855 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6865 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
6856 if (!GLES2Util::IsSignedIntegerFormat(internal_format)) { | 6866 if (!GLES2Util::IsSignedIntegerFormat(internal_format)) { |
6857 // To avoid undefined results, return without calling the gl function. | 6867 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6868 "can only be called on signed integer buffers"); |
6858 return; | 6869 return; |
6859 } | 6870 } |
6860 } else { | 6871 } else { |
6861 DCHECK(buffer == GL_STENCIL); | 6872 DCHECK(buffer == GL_STENCIL); |
6862 if (drawbuffer != 0) { | 6873 if (drawbuffer != 0) { |
6863 LOCAL_SET_GL_ERROR( | 6874 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
6864 GL_INVALID_VALUE, "glClearBufferiv", "invalid drawBuffer"); | |
6865 return; | 6875 return; |
6866 } | 6876 } |
6867 if (!BoundFramebufferHasStencilAttachment()) { | 6877 if (!BoundFramebufferHasStencilAttachment()) { |
6868 return; | 6878 return; |
6869 } | 6879 } |
6870 } | 6880 } |
6871 MarkDrawBufferAsCleared(buffer, drawbuffer); | 6881 MarkDrawBufferAsCleared(buffer, drawbuffer); |
6872 glClearBufferiv(buffer, drawbuffer, value); | 6882 glClearBufferiv(buffer, drawbuffer, value); |
6873 } | 6883 } |
6874 | 6884 |
6875 void GLES2DecoderImpl::DoClearBufferuiv( | 6885 void GLES2DecoderImpl::DoClearBufferuiv( |
6876 GLenum buffer, GLint drawbuffer, const GLuint* value) { | 6886 GLenum buffer, GLint drawbuffer, const GLuint* value) { |
6877 if (!CheckBoundDrawFramebufferValid("glClearBufferuiv")) | 6887 const char* func_name = "glClearBufferuiv"; |
| 6888 if (!CheckBoundDrawFramebufferValid(func_name)) |
6878 return; | 6889 return; |
6879 ApplyDirtyState(); | 6890 ApplyDirtyState(); |
6880 | 6891 |
6881 if (drawbuffer < 0 || | 6892 if (drawbuffer < 0 || |
6882 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6893 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
6883 LOCAL_SET_GL_ERROR( | 6894 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
6884 GL_INVALID_VALUE, "glClearBufferuiv", "invalid drawBuffer"); | |
6885 return; | 6895 return; |
6886 } | 6896 } |
6887 GLenum internal_format = | 6897 GLenum internal_format = |
6888 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6898 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
6889 if (!GLES2Util::IsUnsignedIntegerFormat(internal_format)) { | 6899 if (!GLES2Util::IsUnsignedIntegerFormat(internal_format)) { |
6890 // To avoid undefined results, return without calling the gl function. | 6900 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6901 "can only be called on unsigned integer buffers"); |
6891 return; | 6902 return; |
6892 } | 6903 } |
6893 MarkDrawBufferAsCleared(buffer, drawbuffer); | 6904 MarkDrawBufferAsCleared(buffer, drawbuffer); |
6894 glClearBufferuiv(buffer, drawbuffer, value); | 6905 glClearBufferuiv(buffer, drawbuffer, value); |
6895 } | 6906 } |
6896 | 6907 |
6897 void GLES2DecoderImpl::DoClearBufferfv( | 6908 void GLES2DecoderImpl::DoClearBufferfv( |
6898 GLenum buffer, GLint drawbuffer, const GLfloat* value) { | 6909 GLenum buffer, GLint drawbuffer, const GLfloat* value) { |
6899 if (!CheckBoundDrawFramebufferValid("glClearBufferfv")) | 6910 const char* func_name = "glClearBufferfv"; |
| 6911 if (!CheckBoundDrawFramebufferValid(func_name)) |
6900 return; | 6912 return; |
6901 ApplyDirtyState(); | 6913 ApplyDirtyState(); |
6902 | 6914 |
6903 if (buffer == GL_COLOR) { | 6915 if (buffer == GL_COLOR) { |
6904 if (drawbuffer < 0 || | 6916 if (drawbuffer < 0 || |
6905 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6917 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
6906 LOCAL_SET_GL_ERROR( | 6918 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
6907 GL_INVALID_VALUE, "glClearBufferfv", "invalid drawBuffer"); | |
6908 return; | 6919 return; |
6909 } | 6920 } |
6910 GLenum internal_format = | 6921 GLenum internal_format = |
6911 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6922 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
6912 if (GLES2Util::IsIntegerFormat(internal_format)) { | 6923 if (GLES2Util::IsIntegerFormat(internal_format)) { |
6913 // To avoid undefined results, return without calling the gl function. | 6924 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6925 "can only be called on float buffers"); |
6914 return; | 6926 return; |
6915 } | 6927 } |
6916 } else { | 6928 } else { |
6917 DCHECK(buffer == GL_DEPTH); | 6929 DCHECK(buffer == GL_DEPTH); |
6918 if (drawbuffer != 0) { | 6930 if (drawbuffer != 0) { |
6919 LOCAL_SET_GL_ERROR( | 6931 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
6920 GL_INVALID_VALUE, "glClearBufferfv", "invalid drawBuffer"); | |
6921 return; | 6932 return; |
6922 } | 6933 } |
6923 if (!BoundFramebufferHasDepthAttachment()) { | 6934 if (!BoundFramebufferHasDepthAttachment()) { |
6924 return; | 6935 return; |
6925 } | 6936 } |
6926 } | 6937 } |
6927 MarkDrawBufferAsCleared(buffer, drawbuffer); | 6938 MarkDrawBufferAsCleared(buffer, drawbuffer); |
6928 glClearBufferfv(buffer, drawbuffer, value); | 6939 glClearBufferfv(buffer, drawbuffer, value); |
6929 } | 6940 } |
6930 | 6941 |
6931 void GLES2DecoderImpl::DoClearBufferfi( | 6942 void GLES2DecoderImpl::DoClearBufferfi( |
6932 GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) { | 6943 GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) { |
6933 if (!CheckBoundDrawFramebufferValid("glClearBufferfi")) | 6944 const char* func_name = "glClearBufferfi"; |
| 6945 if (!CheckBoundDrawFramebufferValid(func_name)) |
6934 return; | 6946 return; |
6935 ApplyDirtyState(); | 6947 ApplyDirtyState(); |
6936 | 6948 |
6937 if (drawbuffer != 0) { | 6949 if (drawbuffer != 0) { |
6938 LOCAL_SET_GL_ERROR( | 6950 LOCAL_SET_GL_ERROR( |
6939 GL_INVALID_VALUE, "glClearBufferfi", "invalid drawBuffer"); | 6951 GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
6940 return; | 6952 return; |
6941 } | 6953 } |
6942 if (!BoundFramebufferHasDepthAttachment() && | 6954 if (!BoundFramebufferHasDepthAttachment() && |
6943 !BoundFramebufferHasStencilAttachment()) { | 6955 !BoundFramebufferHasStencilAttachment()) { |
6944 return; | 6956 return; |
6945 } | 6957 } |
6946 MarkDrawBufferAsCleared(GL_DEPTH, drawbuffer); | 6958 MarkDrawBufferAsCleared(GL_DEPTH, drawbuffer); |
6947 MarkDrawBufferAsCleared(GL_STENCIL, drawbuffer); | 6959 MarkDrawBufferAsCleared(GL_STENCIL, drawbuffer); |
6948 glClearBufferfi(buffer, drawbuffer, depth, stencil); | 6960 glClearBufferfi(buffer, drawbuffer, depth, stencil); |
6949 } | 6961 } |
(...skipping 10442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17392 } | 17404 } |
17393 | 17405 |
17394 // Include the auto-generated part of this file. We split this because it means | 17406 // Include the auto-generated part of this file. We split this because it means |
17395 // we can easily edit the non-auto generated parts right here in this file | 17407 // we can easily edit the non-auto generated parts right here in this file |
17396 // instead of having to edit some template or the code generator. | 17408 // instead of having to edit some template or the code generator. |
17397 #include "base/macros.h" | 17409 #include "base/macros.h" |
17398 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17410 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17399 | 17411 |
17400 } // namespace gles2 | 17412 } // namespace gles2 |
17401 } // namespace gpu | 17413 } // namespace gpu |
OLD | NEW |