I've also submitted a patch series for buffer shader views a while back [1]. My series seems to have better tests. The "lod" parameter handling is probably solved in a nicer way as well. On Sun, Nov 20, 2016 at 6:16 PM, Andrew Wesie <awesie(a)gmail.com> wrote:
+ case GL_TEXTURE_BUFFER: + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, 0); + checkGLcall("glBindTexture"); + break;
I suppose that a dummy texture is generally required in order to get correct results for unbound shader views.
+ {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE },
This extension has to be also added to the "core_extensions" table.
+static void wined3d_shader_resource_view_create_buffer_view(struct wined3d_shader_resource_view *view, + const struct wined3d_shader_resource_view_desc *desc, struct wined3d_buffer *buffer, + const struct wined3d_format *view_format) +{ + const struct wined3d_gl_info *gl_info; + struct wined3d_context *context; + + context = context_acquire(buffer->resource.device, NULL); + gl_info = context->gl_info; + + wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER); + + gl_info->gl_ops.gl.p_glGenTextures(1, &view->object); + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, view->object); + + GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format->glInternal, buffer->buffer_object, + desc->u.buffer.start_idx * view_format->byte_count, desc->u.buffer.count * view_format->byte_count));
It would be nice to check if ARB_texture_buffer_range is supported and fallback to ARB_texture_buffer_object. This might be especially useful for macOS.
+ checkGLcall("Create buffer view"); + + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, 0); + context_release(context); +}
This might invalidate shader resource bindings. There is no need to unbind the texture buffer, but you need to call "context_invalidate_state(context, STATE_SHADER_RESOURCE_BINDING);". [1] - https://www.winehq.org/pipermail/wine-patches/2016-March/148496.html