mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2025-01-11 17:10:08 +00:00
Fixing a crash on Marvericks w/glew
This commit is contained in:
parent
7bdbf0c8a2
commit
7363049472
@ -102,14 +102,18 @@ OsdCLGLVertexBuffer::allocate(cl_context clContext) {
|
||||
|
||||
glGenBuffers(1, &_vbo);
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
|
||||
if (glNamedBufferDataEXT) {
|
||||
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
|
||||
} else {
|
||||
#else
|
||||
GLint prev = 0;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, prev);
|
||||
{
|
||||
#endif
|
||||
GLint prev = 0;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, prev);
|
||||
}
|
||||
|
||||
// register vbo as cl memory
|
||||
cl_int err;
|
||||
|
@ -104,12 +104,16 @@ OsdCudaGLVertexBuffer::allocate() {
|
||||
glGenBuffers(1, &_vbo);
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
|
||||
if (glNamedBufferDataEXT) {
|
||||
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
|
||||
} else {
|
||||
#else
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
// register vbo as cuda resource
|
||||
cudaError_t err = cudaGraphicsGLRegisterBuffer(
|
||||
|
@ -72,19 +72,23 @@ createTextureBuffer(T const &data, GLint format, int offset=0)
|
||||
glGenBuffers(1, &buffer);
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(buffer, (data.size()-offset) * sizeof(typename T::value_type),
|
||||
&data[offset], GL_STATIC_DRAW);
|
||||
glTextureBufferEXT(texture, GL_TEXTURE_BUFFER, format, buffer);
|
||||
if (glNamedBufferDataEXT and glTextureBufferEXT) {
|
||||
glNamedBufferDataEXT(buffer, (data.size()-offset) * sizeof(typename T::value_type),
|
||||
&data[offset], GL_STATIC_DRAW);
|
||||
glTextureBufferEXT(texture, GL_TEXTURE_BUFFER, format, buffer);
|
||||
} else {
|
||||
#else
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, (data.size()-offset) * sizeof(typename T::value_type),
|
||||
&data[offset], GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glBindTexture(GL_TEXTURE_BUFFER, texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, (data.size()-offset) * sizeof(typename T::value_type),
|
||||
&data[offset], GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glBindTexture(GL_TEXTURE_BUFFER, texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
}
|
||||
glDeleteBuffers(1, &buffer);
|
||||
|
||||
#endif
|
||||
@ -121,14 +125,18 @@ OsdGLDrawContext::create(FarPatchTables const * patchTables, bool requireFVarDat
|
||||
glGenBuffers(1, &_patchIndexBuffer);
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(_patchIndexBuffer,
|
||||
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
|
||||
if (glNamedBufferDataEXT) {
|
||||
glNamedBufferDataEXT(_patchIndexBuffer,
|
||||
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
|
||||
} else {
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _patchIndexBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _patchIndexBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
OsdDrawContext::ConvertPatchArrays(patchTables->GetPatchArrayVector(),
|
||||
patchArrays, patchTables->GetMaxValence(), 0);
|
||||
@ -183,12 +191,16 @@ OsdGLDrawContext::updateVertexTexture(GLuint vbo, int numVertexElements)
|
||||
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _vertexTextureBuffer);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, vbo);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
if (glTextureBufferEXT) {
|
||||
glTextureBufferEXT(_vertexTextureBuffer, GL_TEXTURE_BUFFER, GL_R32F, vbo);
|
||||
} else {
|
||||
#else
|
||||
glTextureBufferEXT(_vertexTextureBuffer, GL_TEXTURE_BUFFER, GL_R32F, vbo);
|
||||
{
|
||||
#endif
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _vertexTextureBuffer);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, vbo);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -55,19 +55,23 @@ genTextureBuffer(GLenum format, GLsizeiptr size, GLvoid const * data)
|
||||
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(buffer, size, data, GL_STATIC_DRAW);
|
||||
glTextureBufferEXT(result, GL_TEXTURE_BUFFER, format, buffer);
|
||||
if (glNamedBufferDataEXT) {
|
||||
glNamedBufferDataEXT(buffer, size, data, GL_STATIC_DRAW);
|
||||
glTextureBufferEXT(result, GL_TEXTURE_BUFFER, format, buffer);
|
||||
} else {
|
||||
#else
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, buffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, size, data, GL_STATIC_DRAW);
|
||||
|
||||
glBindTexture(GL_TEXTURE_BUFFER, result);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
|
||||
|
||||
// need to reset texture binding before deleting the source buffer.
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, buffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, size, data, GL_STATIC_DRAW);
|
||||
|
||||
glBindTexture(GL_TEXTURE_BUFFER, result);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
|
||||
|
||||
// need to reset texture binding before deleting the source buffer.
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, 0);
|
||||
}
|
||||
|
||||
glDeleteBuffers(1, &buffer);
|
||||
|
||||
|
@ -56,12 +56,16 @@ OsdGLVertexBuffer::UpdateData(const float *src, int startVertex, int numVertices
|
||||
|
||||
int size = numVertices * _numElements * sizeof(float);
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferSubDataEXT(_vbo, startVertex * _numElements * sizeof(float), size, src);
|
||||
if (glNamedBufferSubDataEXT) {
|
||||
glNamedBufferSubDataEXT(_vbo, startVertex * _numElements * sizeof(float), size, src);
|
||||
} else {
|
||||
#else
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, startVertex * _numElements * sizeof(float), size, src);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, startVertex * _numElements * sizeof(float), size, src);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -90,14 +94,18 @@ OsdGLVertexBuffer::allocate() {
|
||||
glGenBuffers(1, &_vbo);
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
|
||||
if (glNamedBufferDataEXT) {
|
||||
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
|
||||
} else {
|
||||
#else
|
||||
GLint prev = 0;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, prev);
|
||||
{
|
||||
#endif
|
||||
GLint prev = 0;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, prev);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -38,14 +38,18 @@ OsdGLSLComputeTable::createBuffer(size_t size, const void *ptr) {
|
||||
glGenBuffers(1, &_devicePtr);
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(_devicePtr, size, ptr, GL_STATIC_DRAW);
|
||||
if (glNamedBufferDataEXT) {
|
||||
glNamedBufferDataEXT(_devicePtr, size, ptr, GL_STATIC_DRAW);
|
||||
} else {
|
||||
#else
|
||||
GLint prev = 0;
|
||||
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _devicePtr);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, size, ptr, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, prev);
|
||||
{
|
||||
#endif
|
||||
GLint prev = 0;
|
||||
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _devicePtr);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, size, ptr, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, prev);
|
||||
}
|
||||
/*
|
||||
CHECK_GL_ERROR("UpdateTable tableIndex %d, size %ld, buffer =%d\n",
|
||||
tableIndex, size, _tableBuffers[tableIndex]);
|
||||
|
@ -42,21 +42,25 @@ OsdGLSLTransformFeedbackTable::createTextureBuffer(size_t size, const void *ptr,
|
||||
glGenTextures(1, &_texture);
|
||||
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glNamedBufferDataEXT(buffer, size, ptr, GL_STATIC_DRAW);
|
||||
glTextureBufferEXT(_texture, GL_TEXTURE_BUFFER, type, buffer);
|
||||
if (glNamedBufferDataEXT and glTextureBufferEXT) {
|
||||
glNamedBufferDataEXT(buffer, size, ptr, GL_STATIC_DRAW);
|
||||
glTextureBufferEXT(_texture, GL_TEXTURE_BUFFER, type, buffer);
|
||||
} else {
|
||||
#else
|
||||
GLint prev = 0;
|
||||
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, ptr, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, prev);
|
||||
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &prev);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, type, buffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, prev);
|
||||
{
|
||||
#endif
|
||||
GLint prev = 0;
|
||||
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, ptr, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, prev);
|
||||
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &prev);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, type, buffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, prev);
|
||||
}
|
||||
|
||||
glDeleteBuffers(1, &buffer);
|
||||
}
|
||||
@ -265,23 +269,31 @@ OsdGLSLTransformFeedbackComputeContext::bind() {
|
||||
if (_currentVertexBuffer) {
|
||||
if (not _vertexTexture) glGenTextures(1, &_vertexTexture);
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glTextureBufferEXT(_vertexTexture, GL_TEXTURE_BUFFER, GL_R32F, _currentVertexBuffer);
|
||||
if (glTextureBufferEXT) {
|
||||
glTextureBufferEXT(_vertexTexture, GL_TEXTURE_BUFFER, GL_R32F, _currentVertexBuffer);
|
||||
} else {
|
||||
#else
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _vertexTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, _currentVertexBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _vertexTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, _currentVertexBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (_currentVaryingBuffer) {
|
||||
if (not _varyingTexture) glGenTextures(1, &_varyingTexture);
|
||||
#if defined(GL_EXT_direct_state_access)
|
||||
glTextureBufferEXT(_varyingTexture, GL_TEXTURE_BUFFER, GL_R32F, _currentVaryingBuffer);
|
||||
if (glTextureBufferEXT) {
|
||||
glTextureBufferEXT(_varyingTexture, GL_TEXTURE_BUFFER, GL_R32F, _currentVaryingBuffer);
|
||||
} else {
|
||||
#else
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _varyingTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, _currentVaryingBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
{
|
||||
#endif
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _varyingTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, _currentVaryingBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (_vertexTexture)
|
||||
|
Loading…
Reference in New Issue
Block a user