• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "dawn_native/opengl/UtilsGL.h"
16 
17 #include "common/Assert.h"
18 
19 namespace dawn_native { namespace opengl {
20 
ToOpenGLCompareFunction(wgpu::CompareFunction compareFunction)21     GLuint ToOpenGLCompareFunction(wgpu::CompareFunction compareFunction) {
22         switch (compareFunction) {
23             case wgpu::CompareFunction::Never:
24                 return GL_NEVER;
25             case wgpu::CompareFunction::Less:
26                 return GL_LESS;
27             case wgpu::CompareFunction::LessEqual:
28                 return GL_LEQUAL;
29             case wgpu::CompareFunction::Greater:
30                 return GL_GREATER;
31             case wgpu::CompareFunction::GreaterEqual:
32                 return GL_GEQUAL;
33             case wgpu::CompareFunction::NotEqual:
34                 return GL_NOTEQUAL;
35             case wgpu::CompareFunction::Equal:
36                 return GL_EQUAL;
37             case wgpu::CompareFunction::Always:
38                 return GL_ALWAYS;
39 
40             case wgpu::CompareFunction::Undefined:
41                 break;
42         }
43         UNREACHABLE();
44     }
45 
GetStencilMaskFromStencilFormat(wgpu::TextureFormat depthStencilFormat)46     GLint GetStencilMaskFromStencilFormat(wgpu::TextureFormat depthStencilFormat) {
47         switch (depthStencilFormat) {
48             case wgpu::TextureFormat::Depth24PlusStencil8:
49                 return 0xFF;
50 
51             default:
52                 UNREACHABLE();
53         }
54     }
55 }}  // namespace dawn_native::opengl
56