On Tue, Jun 20, 2017 at 9:26 PM, Samuel Pitoiset <samuel.pitoi...@gmail.com> wrote: > _mesa_base_tex_image() returns NULL for bindless textures and this crashes. > See below.
Thanks. Is it a texture buffer object? st_convert_sampler will crash if it's a texture buffer object. The standard sampler codepath doesn't invoke the function for TBOs. Marek > > Thread 41 "OGL_Dispatch_3" received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x7ffee973e700 (LWP 17264)] > 0x00007fffdfdf0b61 in st_convert_sampler (st=st@entry=0x9497ef0, > texobj=texobj@entry=0x7ffeb9581ac0, msamp=msamp@entry=0x7ffeb8012bd0, > sampler=sampler@entry=0x7ffee973d760) at state_tracker/st_atom_sampler.c:148 > 148 GLenum texBaseFormat = > _mesa_base_tex_image(texobj)->_BaseFormat; > (gdb) bt > #0 0x00007fffdfdf0b61 in st_convert_sampler (st=st@entry=0x9497ef0, > texobj=texobj@entry=0x7ffeb9581ac0, msamp=msamp@entry=0x7ffeb8012bd0, > sampler=sampler@entry=0x7ffee973d760) at state_tracker/st_atom_sampler.c:148 > #1 0x00007fffdfe0f82b in st_NewTextureHandle (ctx=<optimized out>, > texObj=0x7ffeb9581ac0, sampObj=0x7ffeb8012bd0) at > state_tracker/st_cb_texture.c:2924 > #2 0x00007fffdfd96926 in get_texture_handle (ctx=0x9466920, > texObj=0x7ffeb9581ac0, sampObj=0x7ffeb8012bd0) at main/texturebindless.c:239 > #3 0x0000000002dede77 in (anonymous > namespace)::ProcessGLGetTextureSamplerHandleARB((anonymous > namespace)::CGLFunctionTable const&, (anonymous namespace)::CWorkItem > const&) (dispatch=..., item=...) > at > /media/BobBuild/dawnofwar3/Built/Release/64/Libraries/Feral/Feral3D/GeneratedProcessGLFunctions.cpp:20247 > #4 0x0000000002df19c0 in (anonymous namespace)::CWorkItem::operator() > (dispatch=..., this=<optimized out>) > at > /Volumes/BobSource/dawnofwar3/Companies/Feral/Development/Libraries/Feral/Feral3D/Source/OpenGL/FeralThreadedGL/FeralThreadedGL.cpp:784 > #5 0x0000000002df19c0 in FeralThreadedGL::CGLThread::WorkLoop() > (this=0x94b1b80) at > /Volumes/BobSource/dawnofwar3/Companies/Feral/Development/Libraries/Feral/Feral3D/Source/OpenGL/FeralThreadedGL/FeralThreadedGL.cpp:1956 > #6 0x000000000473667f in std::execute_native_thread_routine(void*) > (__p=0x8a56300) at > ../../../../../gcc-6.3.0/libstdc++-v3/src/c++11/thread.cc:83 > #7 0x00007ffff4a6b297 in start_thread () at /usr/lib/libpthread.so.0 > #8 0x00007fffee80325f in clone () at /usr/lib/libc.so.6 > > I think you have to keep _mesa_texture_base_format() here. > > > On 06/13/2017 08:22 AM, Timothy Arceri wrote: >> >> Reviewed-by: Timothy Arceri <tarc...@itsqueeze.com> >> >> On 13/06/17 04:18, Marek Olšák wrote: >>> >>> From: Marek Olšák <marek.ol...@amd.com> >>> >>> --- >>> src/mesa/state_tracker/st_atom_sampler.c | 17 +++++++++-------- >>> 1 file changed, 9 insertions(+), 8 deletions(-) >>> >>> diff --git a/src/mesa/state_tracker/st_atom_sampler.c >>> b/src/mesa/state_tracker/st_atom_sampler.c >>> index ea231f3..e7968bb 100644 >>> --- a/src/mesa/state_tracker/st_atom_sampler.c >>> +++ b/src/mesa/state_tracker/st_atom_sampler.c >>> @@ -112,23 +112,20 @@ gl_filter_to_img_filter(GLenum filter) >>> /** >>> * Convert a gl_sampler_object to a pipe_sampler_state object. >>> */ >>> void >>> st_convert_sampler(const struct st_context *st, >>> const struct gl_texture_object *texobj, >>> const struct gl_sampler_object *msamp, >>> struct pipe_sampler_state *sampler) >>> { >>> struct gl_context *ctx = st->ctx; >>> - GLenum texBaseFormat; >>> - >>> - texBaseFormat = _mesa_texture_base_format(texobj); >>> memset(sampler, 0, sizeof(*sampler)); >>> sampler->wrap_s = gl_wrap_xlate(msamp->WrapS); >>> sampler->wrap_t = gl_wrap_xlate(msamp->WrapT); >>> sampler->wrap_r = gl_wrap_xlate(msamp->WrapR); >>> sampler->min_img_filter = gl_filter_to_img_filter(msamp->MinFilter); >>> sampler->min_mip_filter = gl_filter_to_mip_filter(msamp->MinFilter); >>> sampler->mag_img_filter = gl_filter_to_img_filter(msamp->MagFilter); >>> @@ -154,20 +151,21 @@ st_convert_sampler(const struct st_context *st, >>> sampler->min_lod = tmp; >>> assert(sampler->min_lod <= sampler->max_lod); >>> } >>> /* For non-black borders... */ >>> if (msamp->BorderColor.ui[0] || >>> msamp->BorderColor.ui[1] || >>> msamp->BorderColor.ui[2] || >>> msamp->BorderColor.ui[3]) { >>> const GLboolean is_integer = texobj->_IsIntegerFormat; >>> + GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat; >>> if (st->apply_texture_swizzle_to_border_color) { >>> const struct st_texture_object *stobj = >>> st_texture_object_const(texobj); >>> const struct pipe_sampler_view *sv = NULL; >>> /* Just search for the first used view. We can do this because >>> the >>> swizzle is per-texture, not per context. */ >>> /* XXX: clean that up to not use the sampler view at all */ >>> for (unsigned i = 0; i < stobj->num_sampler_views; ++i) { >>> if (stobj->sampler_views[i]) { >>> @@ -200,25 +198,28 @@ st_convert_sampler(const struct st_context *st, >>> st_translate_color(&msamp->BorderColor, >>> &sampler->border_color, >>> texBaseFormat, is_integer); >>> } >>> } >>> sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ? >>> 0 : (GLuint) msamp->MaxAnisotropy); >>> /* If sampling a depth texture and using shadow comparison */ >>> - if ((texBaseFormat == GL_DEPTH_COMPONENT || >>> - (texBaseFormat == GL_DEPTH_STENCIL && !texobj->StencilSampling)) >>> && >>> - msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) { >>> - sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; >>> - sampler->compare_func = >>> st_compare_func_to_pipe(msamp->CompareFunc); >>> + if (msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) { >>> + GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat; >>> + >>> + if (texBaseFormat == GL_DEPTH_COMPONENT || >>> + (texBaseFormat == GL_DEPTH_STENCIL && >>> !texobj->StencilSampling)) { >>> + sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; >>> + sampler->compare_func = >>> st_compare_func_to_pipe(msamp->CompareFunc); >>> + } >>> } >>> sampler->seamless_cube_map = >>> ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless; >>> } >>> static void >>> convert_sampler_from_unit(const struct st_context *st, >>> struct pipe_sampler_state *sampler, >>> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev