Changeset View
Changeset View
Standalone View
Standalone View
intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc
| Show All 16 Lines | |||||
| // | // | ||||
| // Unless required by applicable law or agreed to in writing, software | // Unless required by applicable law or agreed to in writing, software | ||||
| // distributed under the Apache License with the above modification is | // distributed under the Apache License with the above modification is | ||||
| // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
| // KIND, either express or implied. See the Apache License for the specific | // KIND, either express or implied. See the Apache License for the specific | ||||
| // language governing permissions and limitations under the Apache License. | // language governing permissions and limitations under the Apache License. | ||||
| // | // | ||||
| #include "gl_compute_evaluator.h" | #include <epoxy/gl.h> | ||||
| /* There are few aspects here: | |||||
| * - macOS is strict about including both gl.h and gl3.h | |||||
| * - libepoxy only pretends to be a replacement for gl.h | |||||
| * - OpenSubdiv internally uses `OpenGL/gl3.h` on macOS | |||||
| * | |||||
| * In order to silence the warning pretend that gl3 has been included, fully relying on symbols | |||||
| * from the epoxy. | |||||
| * | |||||
| * This works differently from how OpenSubdiv internally will use `OpenGL/gl3.h` without epoxy. | |||||
| * Sounds fragile, but so far things seems to work. */ | |||||
| #if defined(__APPLE__) | |||||
| # define __gl3_h_ | |||||
| #endif | |||||
| #include <GL/glew.h> | #include "gl_compute_evaluator.h" | ||||
| #include <opensubdiv/far/error.h> | #include <opensubdiv/far/error.h> | ||||
| #include <opensubdiv/far/patchDescriptor.h> | #include <opensubdiv/far/patchDescriptor.h> | ||||
| #include <opensubdiv/far/stencilTable.h> | #include <opensubdiv/far/stencilTable.h> | ||||
| #include <opensubdiv/osd/glslPatchShaderSource.h> | #include <opensubdiv/osd/glslPatchShaderSource.h> | ||||
| #include <cassert> | #include <cassert> | ||||
| #include <cmath> | #include <cmath> | ||||
| Show All 16 Lines | |||||
| { | { | ||||
| if (src.empty()) { | if (src.empty()) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| GLuint devicePtr = 0; | GLuint devicePtr = 0; | ||||
| #if defined(GL_ARB_direct_state_access) | #if defined(GL_ARB_direct_state_access) | ||||
| if (GLEW_ARB_direct_state_access) { | if (epoxy_has_gl_extension("GL_ARB_direct_state_access")) { | ||||
| glCreateBuffers(1, &devicePtr); | glCreateBuffers(1, &devicePtr); | ||||
| glNamedBufferData(devicePtr, src.size() * sizeof(T), &src.at(0), GL_STATIC_DRAW); | glNamedBufferData(devicePtr, src.size() * sizeof(T), &src.at(0), GL_STATIC_DRAW); | ||||
| } | } | ||||
| else | else | ||||
| #endif | #endif | ||||
| { | { | ||||
| GLint prev = 0; | GLint prev = 0; | ||||
| glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev); | glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev); | ||||
| ▲ Show 20 Lines • Show All 583 Lines • Show Last 20 Lines | |||||