| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 5905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5916 helper_->WaitSyncTokenCHROMIUM( | 5916 helper_->WaitSyncTokenCHROMIUM( |
| 5917 static_cast<GLint>(sync_token_data.namespace_id()), | 5917 static_cast<GLint>(sync_token_data.namespace_id()), |
| 5918 sync_token_data.command_buffer_id().GetUnsafeValue(), | 5918 sync_token_data.command_buffer_id().GetUnsafeValue(), |
| 5919 sync_token_data.release_count()); | 5919 sync_token_data.release_count()); |
| 5920 } | 5920 } |
| 5921 } | 5921 } |
| 5922 } | 5922 } |
| 5923 | 5923 |
| 5924 namespace { | 5924 namespace { |
| 5925 | 5925 |
| 5926 bool ValidImageFormat(GLenum internalformat, | 5926 bool CreateImageValidInternalFormat(GLenum internalformat, |
| 5927 const Capabilities& capabilities) { | 5927 const Capabilities& capabilities) { |
| 5928 switch (internalformat) { | 5928 switch (internalformat) { |
| 5929 case GL_ATC_RGB_AMD: | 5929 case GL_ATC_RGB_AMD: |
| 5930 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 5930 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
| 5931 return capabilities.texture_format_atc; | 5931 return capabilities.texture_format_atc; |
| 5932 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 5932 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 5933 return capabilities.texture_format_dxt1; | 5933 return capabilities.texture_format_dxt1; |
| 5934 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | 5934 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 5935 return capabilities.texture_format_dxt5; | 5935 return capabilities.texture_format_dxt5; |
| 5936 case GL_ETC1_RGB8_OES: | 5936 case GL_ETC1_RGB8_OES: |
| 5937 return capabilities.texture_format_etc1; | 5937 return capabilities.texture_format_etc1; |
| 5938 case GL_RED: | 5938 case GL_RED: |
| 5939 case GL_RGB: | 5939 case GL_RGB: |
| 5940 case GL_RGBA: | 5940 case GL_RGBA: |
| 5941 case GL_RGB_YCBCR_422_CHROMIUM: | 5941 case GL_RGB_YCBCR_422_CHROMIUM: |
| 5942 case GL_RGB_YCBCR_420V_CHROMIUM: | 5942 case GL_RGB_YCBCR_420V_CHROMIUM: |
| 5943 case GL_BGRA_EXT: | 5943 case GL_BGRA_EXT: |
| 5944 return true; | 5944 return true; |
| 5945 default: | 5945 default: |
| 5946 return false; | 5946 return false; |
| 5947 } | 5947 } |
| 5948 } | 5948 } |
| 5949 | 5949 |
| 5950 bool CreateGpuMemoryBufferValidInternalFormat(GLenum internalformat) { |
| 5951 switch (internalformat) { |
| 5952 case GL_RGB: |
| 5953 case GL_RGBA: |
| 5954 return true; |
| 5955 default: |
| 5956 return false; |
| 5957 } |
| 5958 } |
| 5959 |
| 5950 bool ValidImageUsage(GLenum usage) { | 5960 bool ValidImageUsage(GLenum usage) { |
| 5951 return usage == GL_READ_WRITE_CHROMIUM; | 5961 return usage == GL_READ_WRITE_CHROMIUM; |
| 5952 } | 5962 } |
| 5953 | 5963 |
| 5954 } // namespace | 5964 } // namespace |
| 5955 | 5965 |
| 5956 GLuint GLES2Implementation::CreateImageCHROMIUMHelper(ClientBuffer buffer, | 5966 GLuint GLES2Implementation::CreateImageCHROMIUMHelper(ClientBuffer buffer, |
| 5957 GLsizei width, | 5967 GLsizei width, |
| 5958 GLsizei height, | 5968 GLsizei height, |
| 5959 GLenum internalformat) { | 5969 GLenum internalformat) { |
| 5960 if (width <= 0) { | 5970 if (width <= 0) { |
| 5961 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "width <= 0"); | 5971 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "width <= 0"); |
| 5962 return 0; | 5972 return 0; |
| 5963 } | 5973 } |
| 5964 | 5974 |
| 5965 if (height <= 0) { | 5975 if (height <= 0) { |
| 5966 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "height <= 0"); | 5976 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "height <= 0"); |
| 5967 return 0; | 5977 return 0; |
| 5968 } | 5978 } |
| 5969 | 5979 |
| 5970 if (!ValidImageFormat(internalformat, capabilities_)) { | 5980 if (!CreateImageValidInternalFormat(internalformat, capabilities_)) { |
| 5971 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "invalid format"); | 5981 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "invalid format"); |
| 5972 return 0; | 5982 return 0; |
| 5973 } | 5983 } |
| 5974 | 5984 |
| 5975 // CreateImage creates a fence sync so we must flush first to ensure all | 5985 // CreateImage creates a fence sync so we must flush first to ensure all |
| 5976 // previously created fence syncs are flushed first. | 5986 // previously created fence syncs are flushed first. |
| 5977 FlushHelper(); | 5987 FlushHelper(); |
| 5978 | 5988 |
| 5979 int32_t image_id = | 5989 int32_t image_id = |
| 5980 gpu_control_->CreateImage(buffer, width, height, internalformat); | 5990 gpu_control_->CreateImage(buffer, width, height, internalformat); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6026 return 0; | 6036 return 0; |
| 6027 } | 6037 } |
| 6028 | 6038 |
| 6029 if (height <= 0) { | 6039 if (height <= 0) { |
| 6030 SetGLError(GL_INVALID_VALUE, | 6040 SetGLError(GL_INVALID_VALUE, |
| 6031 "glCreateGpuMemoryBufferImageCHROMIUM", | 6041 "glCreateGpuMemoryBufferImageCHROMIUM", |
| 6032 "height <= 0"); | 6042 "height <= 0"); |
| 6033 return 0; | 6043 return 0; |
| 6034 } | 6044 } |
| 6035 | 6045 |
| 6036 if (!ValidImageFormat(internalformat, capabilities_)) { | 6046 if (!CreateGpuMemoryBufferValidInternalFormat(internalformat)) { |
| 6037 SetGLError(GL_INVALID_VALUE, | 6047 SetGLError(GL_INVALID_VALUE, |
| 6038 "glCreateGpuMemoryBufferImageCHROMIUM", | 6048 "glCreateGpuMemoryBufferImageCHROMIUM", |
| 6039 "invalid format"); | 6049 "invalid format"); |
| 6040 return 0; | 6050 return 0; |
| 6041 } | 6051 } |
| 6042 | 6052 |
| 6043 if (!ValidImageUsage(usage)) { | 6053 if (!ValidImageUsage(usage)) { |
| 6044 SetGLError(GL_INVALID_VALUE, | 6054 SetGLError(GL_INVALID_VALUE, |
| 6045 "glCreateGpuMemoryBufferImageCHROMIUM", | 6055 "glCreateGpuMemoryBufferImageCHROMIUM", |
| 6046 "invalid usage"); | 6056 "invalid usage"); |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6823 cached_extensions_.clear(); | 6833 cached_extensions_.clear(); |
| 6824 } | 6834 } |
| 6825 | 6835 |
| 6826 // Include the auto-generated part of this file. We split this because it means | 6836 // Include the auto-generated part of this file. We split this because it means |
| 6827 // we can easily edit the non-auto generated parts right here in this file | 6837 // we can easily edit the non-auto generated parts right here in this file |
| 6828 // instead of having to edit some template or the code generator. | 6838 // instead of having to edit some template or the code generator. |
| 6829 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6839 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 6830 | 6840 |
| 6831 } // namespace gles2 | 6841 } // namespace gles2 |
| 6832 } // namespace gpu | 6842 } // namespace gpu |
| OLD | NEW |