OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // These functions emluate GLES2 over command buffers for C. | 5 // These functions emluate GLES2 over command buffers for C. |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include "../client/gles2_lib.h" | 8 #include "../client/gles2_lib.h" |
9 | 9 |
10 // Check that destination pointers point to initialized memory. | 10 // Check that destination pointers point to initialized memory. |
11 // When the context is lost, calling GL function has no effect so if destination | 11 // When the context is lost, calling GL function has no effect so if destination |
12 // pointers point to initialized memory it can often lead to crash bugs. eg. | 12 // pointers point to initialized memory it can often lead to crash bugs. eg. |
13 // | 13 // |
14 // GLsizei len; | 14 // GLsizei len; |
15 // glGetShaderSource(shader, max_size, &len, buffer); | 15 // glGetShaderSource(shader, max_size, &len, buffer); |
16 // std::string src(buffer, buffer + len); // len can be uninitialized here!!! | 16 // std::string src(buffer, buffer + len); // len can be uninitialized here!!! |
17 // | 17 // |
18 // Because this check is not official GL this check happens only on Chrome code, | 18 // Because this check is not official GL this check happens only on Chrome code, |
19 // not Pepper. | 19 // not Pepper. |
20 // | 20 // |
21 // If it was up to us we'd just always write to the destination but the OpenGL | 21 // If it was up to us we'd just always write to the destination but the OpenGL |
22 // spec defines the behavior of OpenGL function, not us. :-( | 22 // spec defines the behavior of OpenGL function, not us. :-( |
23 #if defined(__native_client__) | 23 #if defined(__native_client__) || defined(GLES2_CONFORMANCE_TESTS) |
24 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) | 24 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) |
25 #elif defined(GPU_DCHECK) | 25 #elif defined(GPU_DCHECK) |
26 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) GPU_DCHECK(v) | 26 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) GPU_DCHECK(v) |
27 #elif defined(DCHECK) | 27 #elif defined(DCHECK) |
28 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) DCHECK(v) | 28 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) DCHECK(v) |
29 #else | 29 #else |
30 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) ASSERT(v) | 30 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) ASSERT(v) |
31 #endif | 31 #endif |
32 | 32 |
33 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(type, ptr) \ | 33 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(type, ptr) \ |
34 GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \ | 34 GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \ |
35 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); | 35 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); |
36 | 36 |
37 extern "C" { | 37 extern "C" { |
38 // Include the auto-generated part of this file. We split this because it means | 38 // Include the auto-generated part of this file. We split this because it means |
39 // we can easily edit the non-auto generated parts right here in this file | 39 // we can easily edit the non-auto generated parts right here in this file |
40 // instead of having to edit some template or the code generator. | 40 // instead of having to edit some template or the code generator. |
41 #include "../client/gles2_c_lib_autogen.h" | 41 #include "../client/gles2_c_lib_autogen.h" |
42 } // extern "C" | 42 } // extern "C" |
43 | 43 |
44 | 44 |
OLD | NEW |