Re: [Mesa-dev] [PATCH] i965/vec4: select predicate based on writemask for sel emissions
On 04/11/15 23:49, Matt Turner wrote: > On Wed, Nov 4, 2015 at 1:01 PM, Alejandro Piñeiro> wrote: >> On 04/11/15 20:13, Matt Turner wrote: >>> On Fri, Oct 23, 2015 at 7:17 AM, Alejandro Piñeiro >>> wrote: Equivalent to commit 4eebeb but with sel operations. In this case >>> That commit sha doesn't exist. I suspect you meant commit 8ac3b525c. >> Yes, probably that sha was the one on my wip branches. >> we select the PredCtrl based on the writemask. This change allows cmod propagation to optimize out several instructions. >>> Okay, so this patch helps a case like: >> I don't think that the case you pointed is a good one to explain why >> this is helping. Because this seems to suggest that this case is without >> the patch but... >> >>> cmp.g.f0.0 vgrf32.0.x:F, vgrf31.:F, 0.00F >>> cmp.nz.f0.0 null.x:D, vgrf32.:D, 0D >> ... this patch is needed to arrive to this point (null destination >> writemask being updated). >>> (+f0.0) sel vgrf2.0.x:F, |vgrf27.|:F, 0.00F >>> >>> where our code thinks the SEL reads all four channels of the flag >>> register when it actually only reads .x because of the writemask. >>> >>> Adding something like this to the commit message would be good. >> So if we want to go into the details of why this change helps to reduce >> instructions, what about something like: >> >> "This patch helps on cases like this: >> >> 1: cmp.l.f0.0 vgrf40.0.x:F, vgrf0.:F, vgrf7.:F >> 2: cmp.nz.f0.0 null:D, vgrf40.:D, 0D >> 3: (+f0.0) sel vgrf41.0.x:UD, vgrf6.:UD, vgrf5.:UD >> >> In this case, cmod propagation can't optimize instruction #2, because >> instructions #1 and #2 have different writemasks, and we can't update >> directly instruction #2 writemask because our code thinks that sel reads >> all four channels of the flag, when it actually only reads .x. >> >> So, with this patch, the previous case becames this: >> >> 1: cmp.l.f0.0 vgrf40.0.x:F, vgrf0.:F, vgrf7.:F >> 2: cmp.nz.f0.0 null:D, vgrf40.:D, 0D >> 3: (+f0.0.x) sel vgrf41.0.x:UD, vgrf6.:UD, vgrf5.:UD >> >> Now only the x channel of the flag is used, allowing dead code eliminate >> to update the writemask at the second instruction: >> 1: cmp.l.f0.0 vgrf40.0.x:F, vgrf0.:F, vgrf7.:F >> 2: cmp.nz.f0.0 null.x:D, vgrf40.:D, 0D >> 3: (+f0.0.x) sel vgrf41.0.x:UD, vgrf6.:UD, vgrf5.:UD >> >> So now cmod propagation can simplify out #2: >> 1: cmp.l.f0.0 vgrf40.0.x:F, attr18.:F, vgrf7.:F >> 2: (+f0.0.x) sel vgrf41.0.x:UD, vgrf6.:UD, vgrf5.:UD >> " >> >> Although not sure if this explanation is too long. >> Shader-db numbers: total instructions in shared programs: 6235835 -> 6228008 (-0.13%) instructions in affected programs: 219850 -> 212023 (-3.56%) total loops in shared programs:1979 -> 1979 (0.00%) helped:1192 HURT: 0 --- src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp index 0f04f65..bc86be6 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp @@ -1437,8 +1437,24 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr) case nir_op_bcsel: emit(CMP(dst_null_d(), op[0], src_reg(0), BRW_CONDITIONAL_NZ)); inst = emit(BRW_OPCODE_SEL, dst, op[1], op[2]); - inst->predicate = BRW_PREDICATE_NORMAL; + switch (dst.writemask) { + case WRITEMASK_X: + inst->predicate = BRW_PREDICATE_ALIGN16_REPLICATE_X; + break; + case WRITEMASK_Y: + inst->predicate = BRW_PREDICATE_ALIGN16_REPLICATE_Y; + break; + case WRITEMASK_Z: + inst->predicate = BRW_PREDICATE_ALIGN16_REPLICATE_Z; + break; + case WRITEMASK_W: + inst->predicate = BRW_PREDICATE_ALIGN16_REPLICATE_W; + break; + default: + inst->predicate = BRW_PREDICATE_NORMAL; break; >>> This break, and the one two lines below it are indented incorrectly. >> Ok. >> + } + break; case nir_op_fdot_replicated2: inst = emit(BRW_OPCODE_DP2, dst, op[0], op[1]); -- 2.1.4 >>> With the commit message fixed/updated and the breaks properly indented, >> As I changed totally the use case and description, I would prefer to >> confirm that I explained myself properly before pushing. > Thanks. Your description is great -- it'll definitely help future > readers to understand exactly why this is needed. Patch pushed with that description (with minor tweaks). Thanks for the patience. BR -- Alejandro Piñeiro
Re: [Mesa-dev] [PATCH] st/mesa: account for texture views when doing CopyImageSubData
Reviewed-by: Marek OlšákMarek On Thu, Nov 5, 2015 at 6:34 AM, Ilia Mirkin wrote: > Signed-off-by: Ilia Mirkin > --- > src/mesa/state_tracker/st_cb_copyimage.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/src/mesa/state_tracker/st_cb_copyimage.c > b/src/mesa/state_tracker/st_cb_copyimage.c > index 75114cd..03a7294 100644 > --- a/src/mesa/state_tracker/st_cb_copyimage.c > +++ b/src/mesa/state_tracker/st_cb_copyimage.c > @@ -552,6 +552,10 @@ st_CopyImageSubData(struct gl_context *ctx, >src_res = src->pt; >src_level = src_image->Level; >src_z += src_image->Face; > + if (src_image->TexObject->Immutable) { > + src_level += src_image->TexObject->MinLevel; > + src_z += src_image->TexObject->MinLayer; > + } > } else { >struct st_renderbuffer *src = st_renderbuffer(src_renderbuffer); >src_res = src->texture; > @@ -563,6 +567,10 @@ st_CopyImageSubData(struct gl_context *ctx, >dst_res = dst->pt; >dst_level = dst_image->Level; >dst_z += dst_image->Face; > + if (dst_image->TexObject->Immutable) { > + dst_level += dst_image->TexObject->MinLevel; > + dst_z += dst_image->TexObject->MinLayer; > + } > } else { >struct st_renderbuffer *dst = st_renderbuffer(dst_renderbuffer); >dst_res = dst->texture; > -- > 2.4.10 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2
Some lines were using 4 indentation spaces instead of 3. Signed-off-by: Julien Isorce--- src/gallium/state_trackers/va/surface.c | 566 1 file changed, 283 insertions(+), 283 deletions(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 8f406e0..59815aa 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -311,101 +311,101 @@ VAStatus vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, VASurfaceAttrib *attrib_list, unsigned int *num_attribs) { -vlVaDriver *drv; -VASurfaceAttrib *attribs; -struct pipe_screen *pscreen; -int i; + vlVaDriver *drv; + VASurfaceAttrib *attribs; + struct pipe_screen *pscreen; + int i; -if (config == VA_INVALID_ID) -return VA_STATUS_ERROR_INVALID_CONFIG; + if (config == VA_INVALID_ID) + return VA_STATUS_ERROR_INVALID_CONFIG; -if (!attrib_list && !num_attribs) -return VA_STATUS_ERROR_INVALID_PARAMETER; + if (!attrib_list && !num_attribs) + return VA_STATUS_ERROR_INVALID_PARAMETER; -if (!attrib_list) { -*num_attribs = VASurfaceAttribCount; -return VA_STATUS_SUCCESS; -} + if (!attrib_list) { + *num_attribs = VASurfaceAttribCount; + return VA_STATUS_SUCCESS; + } -if (!ctx) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!ctx) + return VA_STATUS_ERROR_INVALID_CONTEXT; -drv = VL_VA_DRIVER(ctx); + drv = VL_VA_DRIVER(ctx); -if (!drv) -return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; -pscreen = VL_VA_PSCREEN(ctx); + pscreen = VL_VA_PSCREEN(ctx); -if (!pscreen) - return VA_STATUS_ERROR_INVALID_CONTEXT; + if (!pscreen) + return VA_STATUS_ERROR_INVALID_CONTEXT; -attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); -if (!attribs) -return VA_STATUS_ERROR_ALLOCATION_FAILED; + if (!attribs) + return VA_STATUS_ERROR_ALLOCATION_FAILED; -i = 0; + i = 0; -if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { - /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN + if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { + /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN only for VAEntrypointVideoProc. */ - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_BGRA; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_RGBA; - i++; -} else { - /* Assume VAEntrypointVLD for now. */ - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_NV12; - i++; -} - -attribs[i].type = VASurfaceAttribMemoryType; -attribs[i].value.type = VAGenericValueTypeInteger; -attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | -VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; -i++; - -attribs[i].type = VASurfaceAttribExternalBufferDescriptor; -attribs[i].value.type = VAGenericValueTypePointer; -attribs[i].flags = VA_SURFACE_ATTRIB_SETTABLE; -attribs[i].value.value.p = NULL; /* ignore */ -i++; - -attribs[i].type = VASurfaceAttribMaxWidth; -attribs[i].value.type = VAGenericValueTypeInteger; -attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; -attribs[i].value.value.i = vl_video_buffer_max_size(pscreen); -i++; - -attribs[i].type = VASurfaceAttribMaxHeight; -attribs[i].value.type = VAGenericValueTypeInteger; -attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; -attribs[i].value.value.i = vl_video_buffer_max_size(pscreen); -i++; - -if (i > *num_attribs) { -*num_attribs = i; -FREE(attribs); -return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; -} - -*num_attribs = i; -memcpy(attrib_list, attribs, i * sizeof(VASurfaceAttrib)); -FREE(attribs); - -return VA_STATUS_SUCCESS; + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i].value.value.i = VA_FOURCC_BGRA; + i++; + + attribs[i].type = VASurfaceAttribPixelFormat; +
[Mesa-dev] [PATCH 3/4] st/va: properly indent buffer.c, config.c, image.c and picture.c
Some lines were using 4 indentation spaces instead of 3. The switch in vlVaAcquireBufferHandle actually had wrong brackets surrounding case+default. Signed-off-by: Julien Isorce--- src/gallium/state_trackers/va/buffer.c | 23 + src/gallium/state_trackers/va/config.c | 12 ++--- src/gallium/state_trackers/va/image.c | 4 +- src/gallium/state_trackers/va/picture.c | 82 - 4 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 71a6503..769305e 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -152,11 +152,11 @@ vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { - if (!buf->derived_surface.transfer) -return VA_STATUS_ERROR_INVALID_BUFFER; + if (!buf->derived_surface.transfer) + return VA_STATUS_ERROR_INVALID_BUFFER; - pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); - buf->derived_surface.transfer = NULL; + pipe_buffer_unmap(drv->pipe, buf->derived_surface.transfer); + buf->derived_surface.transfer = NULL; } return VA_STATUS_SUCCESS; @@ -175,10 +175,10 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->derived_surface.resource) { - if (buf->export_refcount > 0) - return VA_STATUS_ERROR_INVALID_BUFFER; + if (buf->export_refcount > 0) + return VA_STATUS_ERROR_INVALID_BUFFER; - pipe_resource_reference(>derived_surface.resource, NULL); + pipe_resource_reference(>derived_surface.resource, NULL); } FREE(buf->data); @@ -280,15 +280,14 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, buf_info->handle = (intptr_t)whandle.handle; break; + } default: return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; } - } - - buf_info->type = buf->type; - buf_info->mem_type = mem_type; - buf_info->mem_size = buf->num_elements * buf->size; + buf_info->type = buf->type; + buf_info->mem_type = mem_type; + buf_info->mem_size = buf->num_elements * buf->size; } buf->export_refcount++; diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 0f47aac..a545a18 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -71,8 +71,8 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, *num_entrypoints = 0; if (profile == VAProfileNone) { - entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; - return VA_STATUS_SUCCESS; + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVideoProc; + return VA_STATUS_SUCCESS; } p = ProfileToPipe(profile); @@ -104,7 +104,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint en value = VA_RT_FORMAT_YUV420; break; case VAConfigAttribRateControl: -value = VA_RC_NONE; + value = VA_RC_NONE; break; default: value = VA_ATTRIB_NOT_SUPPORTED; @@ -127,8 +127,8 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin return VA_STATUS_ERROR_INVALID_CONTEXT; if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) { - *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; - return VA_STATUS_SUCCESS; + *config_id = PIPE_VIDEO_PROFILE_UNKNOWN; + return VA_STATUS_SUCCESS; } p = ProfileToPipe(profile); @@ -167,7 +167,7 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) { *entrypoint = VAEntrypointVideoProc; - *num_attribs = 0; + *num_attribs = 0; return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index c6d0c5a..ae07da8 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -447,8 +447,8 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, tmp_buf = drv->pipe->create_video_buffer(drv->pipe, >templat); if (!tmp_buf) { - surf->templat.buffer_format = old_surf_format; - return VA_STATUS_ERROR_ALLOCATION_FAILED; + surf->templat.buffer_format = old_surf_format; + return VA_STATUS_ERROR_ALLOCATION_FAILED; } surf->buffer->destroy(surf->buffer); diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index e850689..644b848 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -65,7 +65,7 @@ vlVaBeginPicture(VADriverContextP ctx,
[Mesa-dev] [PATCH 4/4] st/va: add support for RGBX and BGRX in VPP
Before it was only possible to convert a NV12 surface to RGBA or BGRA. This patch uses the same post processing function, "handleVAProcPipelineParameterBufferType", but add definitions for RGBX and BGRX. This patch also makes vlVaQuerySurfaceAttributes more generic. Signed-off-by: Julien Isorce--- src/gallium/auxiliary/vl/vl_video_buffer.c | 18 +++ src/gallium/state_trackers/va/picture.c| 5 +++-- src/gallium/state_trackers/va/surface.c| 36 +- src/gallium/state_trackers/va/va_private.h | 1 + 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index 5e0ae0e..6cd2557 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -62,6 +62,18 @@ const enum pipe_format const_resource_formats_VUYA[3] = { PIPE_FORMAT_NONE }; +const enum pipe_format const_resource_formats_YUVX[3] = { + PIPE_FORMAT_R8G8B8X8_UNORM, + PIPE_FORMAT_NONE, + PIPE_FORMAT_NONE +}; + +const enum pipe_format const_resource_formats_VUYX[3] = { + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_NONE, + PIPE_FORMAT_NONE +}; + const enum pipe_format const_resource_formats_YUYV[3] = { PIPE_FORMAT_R8G8_R8B8_UNORM, PIPE_FORMAT_NONE, @@ -102,6 +114,12 @@ vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_UNORM: return const_resource_formats_VUYA; + case PIPE_FORMAT_R8G8B8X8_UNORM: + return const_resource_formats_VUYX; + + case PIPE_FORMAT_B8G8R8X8_UNORM: + return const_resource_formats_VUYX; + case PIPE_FORMAT_YUYV: return const_resource_formats_YUYV; diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 644b848..d6cdbea 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -59,11 +59,12 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende return VA_STATUS_ERROR_INVALID_SURFACE; context->target = surf->buffer; - if (!context->decoder) { /* VPP */ if ((context->target->buffer_format != PIPE_FORMAT_B8G8R8A8_UNORM && - context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM) || + context->target->buffer_format != PIPE_FORMAT_R8G8B8A8_UNORM && + context->target->buffer_format != PIPE_FORMAT_B8G8R8X8_UNORM && + context->target->buffer_format != PIPE_FORMAT_R8G8B8X8_UNORM) || context->target->interlaced) return VA_STATUS_ERROR_UNIMPLEMENTED; return VA_STATUS_SUCCESS; diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 3db21c3..589d686 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -45,6 +45,11 @@ #include +static const enum pipe_format vpp_surface_formats[] = { + PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_FORMAT_R8G8B8X8_UNORM +}; + VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) @@ -314,7 +319,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, vlVaDriver *drv; VASurfaceAttrib *attribs; struct pipe_screen *pscreen; - int i; + int i, j; + + STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats) <= VL_VA_MAX_IMAGE_FORMATS); if (config == VA_INVALID_ID) return VA_STATUS_ERROR_INVALID_CONFIG; @@ -323,7 +330,7 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, return VA_STATUS_ERROR_INVALID_PARAMETER; if (!attrib_list) { - *num_attribs = VASurfaceAttribCount; + *num_attribs = VL_VA_MAX_IMAGE_FORMATS + VASurfaceAttribCount; return VA_STATUS_SUCCESS; } @@ -340,27 +347,24 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, if (!pscreen) return VA_STATUS_ERROR_INVALID_CONTEXT; - attribs = CALLOC(VASurfaceAttribCount, sizeof(VASurfaceAttrib)); + attribs = CALLOC(VL_VA_MAX_IMAGE_FORMATS + VASurfaceAttribCount, +sizeof(VASurfaceAttrib)); if (!attribs) return VA_STATUS_ERROR_ALLOCATION_FAILED; i = 0; + /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN +* only for VAEntrypointVideoProc. */ if (config == PIPE_VIDEO_PROFILE_UNKNOWN) { - /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN - only for VAEntrypointVideoProc. */ - attribs[i].type = VASurfaceAttribPixelFormat; - attribs[i].value.type = VAGenericValueTypeInteger; - attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; - attribs[i].value.value.i = VA_FOURCC_BGRA; - i++; - - attribs[i].type = VASurfaceAttribPixelFormat; -
[Mesa-dev] [PATCH 0/4] st/va: indent, leak fix and RGBx/BGRx for vpp
A few fixes and small improvement from recent changes in st/va: * Indentation was wrong for some functions. * Coverity reported a memory leak. (thx to Ilia for pointing this) * More color formats convertion for Video Post Processing Julien Isorce (4): st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2 st/va: fix memory leak on error in vlVaCreateSurfaces2 st/va: properly indent buffer.c, config.c, image.c and picture.c st/va: add support for RGBX and BGRX in VPP src/gallium/auxiliary/vl/vl_video_buffer.c | 18 + src/gallium/state_trackers/va/buffer.c | 23 +- src/gallium/state_trackers/va/config.c | 12 +- src/gallium/state_trackers/va/image.c | 4 +- src/gallium/state_trackers/va/picture.c| 87 ++--- src/gallium/state_trackers/va/surface.c| 602 +++-- src/gallium/state_trackers/va/va_private.h | 1 + 7 files changed, 388 insertions(+), 359 deletions(-) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] st/va: fix memory leak on error in vlVaCreateSurfaces2
Found by coverity: CID #1337953 Signed-off-by: Julien Isorce--- src/gallium/state_trackers/va/surface.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 59815aa..3db21c3 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -479,8 +479,10 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, util_dynarray_init(>subpics); surfaces[index] = handle_table_add(drv->htab, surface); - if (!surfaces[index]) + if (!surfaces[index]) { + surface->buffer->destroy(surface->buffer); return VA_STATUS_ERROR_ALLOCATION_FAILED; + } return VA_STATUS_SUCCESS; } @@ -612,15 +614,19 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, switch (memory_type) { case VA_SURFACE_ATTRIB_MEM_TYPE_VA: surf->buffer = drv->pipe->create_video_buffer(drv->pipe, ); - if (!surf->buffer) + if (!surf->buffer) { +FREE(surf); goto no_res; + } util_dynarray_init(>subpics); surfaces[i] = handle_table_add(drv->htab, surf); break; case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: vaStatus = suface_from_external_memory(ctx, surf, memory_attibute, i, surfaces, ); - if (vaStatus != VA_STATUS_SUCCESS) + if (vaStatus != VA_STATUS_SUCCESS) { +FREE(surf); goto no_res; + } break; default: assert(0); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] glsl: Drop exec_list argument to lower_ubo_reference
On Wed, 2015-11-04 at 15:33 -0800, Kristian Høgsberg Kristensen wrote: > We always pass in shader->ir and we already pass in the shader, so just > drop the exec_list. Most passes either take just a exec_list or a > shader, so this seems more consistent. > > Signed-off-by: Kristian Høgsberg KristensenThis patch is: Reviewed-by: Timothy Arceri ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 04/24] i965: Make 'dw1' and 'bits' unnamed structures in brw_reg.
Matt Turnerwrites: > On Tue, Nov 3, 2015 at 5:48 AM, Francisco Jerez wrote: >> Matt Turner writes: >> >>> Generated by >>> >>>sed -i -e 's/\.bits\././g' *.c *.h *.cpp >>>sed -i -e 's/dw1\.//g' *.c *.h *.cpp >>> >>> and then reverting changes to comments in gen7_blorp.cpp and >>> brw_fs_generator.cpp. >>> >>> There wasn't any utility offered by forcing the programmer to list these >>> to access their fields. Removing them will reduce churn in future >>> commits. >>> >>> This is C11 (and gcc has apparently supported it for sometime >>> "compatibility with other compilers") >>> >>> See https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html >> >> This is also used from C++ source where anonymous structs are not part >> of any released standard. > > That is true. I have built this series with both clang-3.6 and > gcc-4.4.7. I don't think it's a problem. > >> I guess in C++ it would be preferable to >> define accessor methods instead of relying on a language extension -- >> That would also allow you to introduce checks making sure that the >> register is of the correct type in order to catch cases in which the >> wrong field of the union is accessed easily. > > Maybe. Since I was changing so much code in this series, I wouldn't > want to do that here. Yeah, I agree that there's no need to make that change as part of this series. However if we agree that accessors would be a better approach this patch is unnecessary, since we will get a similar kind of syntactic sugar without relying on unnamed structures. > Also, having commits that use the brw_reg fields separately from any > accessors seems beneficial. > > We could also simply mark fields private with using declarations. That > would get almost all of any potential benefit (of which I'm not sure > how much there is, really). signature.asc Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/4] st/va: indent, leak fix and RGBx/BGRx for vpp
Patches #1-#3 are Reviewed-by: Christian KönigPlease split patch #4 in two with first adding the new vl_video_buffer formats and then using them in the state tracker. Should I commit that for you as well or do you now have an account? Regards, Christian. On 05.11.2015 09:24, Julien Isorce wrote: A few fixes and small improvement from recent changes in st/va: * Indentation was wrong for some functions. * Coverity reported a memory leak. (thx to Ilia for pointing this) * More color formats convertion for Video Post Processing Julien Isorce (4): st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2 st/va: fix memory leak on error in vlVaCreateSurfaces2 st/va: properly indent buffer.c, config.c, image.c and picture.c st/va: add support for RGBX and BGRX in VPP src/gallium/auxiliary/vl/vl_video_buffer.c | 18 + src/gallium/state_trackers/va/buffer.c | 23 +- src/gallium/state_trackers/va/config.c | 12 +- src/gallium/state_trackers/va/image.c | 4 +- src/gallium/state_trackers/va/picture.c| 87 ++--- src/gallium/state_trackers/va/surface.c| 602 +++-- src/gallium/state_trackers/va/va_private.h | 1 + 7 files changed, 388 insertions(+), 359 deletions(-) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 5/7] glsl: Add precision information to ir_variable
From: Iago Toral QuirogaWe will need this later on when we implement proper support for precision qualifiers in the drivers and also to do link time checks for uniforms as indicated by the spec. This patch also adds compile-time checks for variables without precision information (currently, Mesa only checks that a default precision is set for floats in fragment shaders). As indicated by Ian, the addition of the precision information to ir_variable has been done using a bitfield and pahole to identify an available hole so that memory requirements for ir_variable stay the same. v2 (Ian): - Avoid if-ladders by defining arrays of supported sampler names and indexing into them with type->sampler_array + 2 * type->sampler_shadow - Make the code that selects the precision qualifier to use an utility function - Fix a typo v3 (Tapani): - rebased - squashed in "Precision qualifiers are not allowed on structs" - fixed select_gles_precision for sampler arrays - fixed precision_qualifier_allowed for arrays of structs v4 (Tapani): - add atomic_uint handling - do not allow precision qualifier on images (issues reported by Marta) --- src/glsl/ast_to_hir.cpp | 272 src/glsl/ir.h | 13 +++ src/glsl/nir/glsl_types.cpp | 4 + src/glsl/nir/glsl_types.h | 11 ++ 4 files changed, 277 insertions(+), 23 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index b6d662b..444ce7f 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2189,10 +2189,11 @@ precision_qualifier_allowed(const glsl_type *type) * From this, we infer that GLSL 1.30 (and later) should allow precision * qualifiers on sampler types just like float and integer types. */ - return type->is_float() + return (type->is_float() || type->is_integer() - || type->is_record() - || type->contains_opaque(); + || type->contains_opaque()) + && !type->without_array()->is_record() + && !type->without_array()->is_image(); } const glsl_type * @@ -2210,31 +2211,243 @@ ast_type_specifier::glsl_type(const char **name, return type; } -const glsl_type * -ast_fully_specified_type::glsl_type(const char **name, -struct _mesa_glsl_parse_state *state) const +/** + * From the OpenGL ES 3.0 spec, 4.5.4 Default Precision Qualifiers: + * + * "The precision statement + * + *precision precision-qualifier type; + * + * can be used to establish a default precision qualifier. The type field can + * be either int or float or any of the sampler types, (...) If type is float, + * the directive applies to non-precision-qualified floating point type + * (scalar, vector, and matrix) declarations. If type is int, the directive + * applies to all non-precision-qualified integer type (scalar, vector, signed, + * and unsigned) declarations." + * + * We use the symbol table to keep the values of the default precisions for + * each 'type' in each scope and we use the 'type' string from the precision + * statement as key in the symbol table. When we want to retrieve the default + * precision associated with a given glsl_type we need to know the type string + * associated with it. This is what this function returns. + */ +static const char * +get_type_name_for_precision_qualifier(const glsl_type *type) { - const struct glsl_type *type = this->specifier->glsl_type(name, state); - - if (type == NULL) - return NULL; + switch (type->base_type) { + case GLSL_TYPE_FLOAT: + return "float"; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + return "int"; + case GLSL_TYPE_ATOMIC_UINT: + return "atomic_uint"; + case GLSL_TYPE_SAMPLER: { + const unsigned type_idx = + type->sampler_array + 2 * type->sampler_shadow; + assert(type_idx < 4); + switch (type->sampler_type) { + case GLSL_TYPE_FLOAT: + switch (type->sampler_dimensionality) { + case GLSL_SAMPLER_DIM_1D: { +static const char *const names[4] = { + "sampler1D", "sampler1DArray", + "sampler1DShadow", "sampler1DArrayShadow" +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_2D: { +static const char *const names[4] = { + "sampler2D", "sampler2DArray", + "sampler2DShadow", "sampler2DArrayShadow" +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_3D: { +static const char *const names[4] = { + "sampler3D", NULL, NULL, NULL +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_CUBE: { +static const char *const names[4] = { + "samplerCube", "samplerCubeArray", + "samplerCubeShadow", "samplerCubeArrayShadow" +}; +return
[Mesa-dev] [PATCH v3 2/7] glsl: Add default precision qualifiers to the symbol table
From: Iago Toral QuirogaThe GLSL ES spec specifies default precision qualifiers for certain types, so populate the symbol table with these. Notice that the desktop GLSL spec also indicates defaults for some types but this is not really useful since precision qualifiers are completely ignored in desktop GLSL. v2: simplify and add samplerExternalOES, specified by OES_EGL_image_external (Tapani) v3: add atomic_uint (reported missing by Marta) --- src/glsl/glsl_parser.yy | 12 1 file changed, 12 insertions(+) diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 4636435..59315b3 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -312,6 +312,18 @@ translation_unit: { delete state->symbols; state->symbols = new(ralloc_parent(state)) glsl_symbol_table; + if (state->es_shader) { + if (state->stage == MESA_SHADER_FRAGMENT) { +state->symbols->add_default_precision_qualifier("int", ast_precision_medium); + } else { +state->symbols->add_default_precision_qualifier("float", ast_precision_high); +state->symbols->add_default_precision_qualifier("int", ast_precision_high); + } + state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low); + state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low); + state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low); + state->symbols->add_default_precision_qualifier("atomic_uint", ast_precision_high); + } _mesa_glsl_initialize_types(state); } ; -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] i965: Don't include missing components in the fast clear color
Ben Widawskywrites: > It seems reasonable to me, but since you touch the same code I touch > in fast clears, and since I always screw up rebases, any chance I > could persuade you to wait until I land fast clears? Sure, I don't mind waiting. I did have a go at rebasing the patch on top of your branch and I think the code should look something like this: if (brw->gen >= 9) { mt->gen9_fast_clear_color = *color; + + /* Override components that aren't in the surface format */ + for (int i = 0; i < 4; i++) { + if (!_mesa_format_has_color_component(mt->format, i)) { +if (_mesa_is_format_integer(mt->format)) + mt->gen9_fast_clear_color.i[i] = (i == 3); +else + mt->gen9_fast_clear_color.f[i] = (i == 3); + } + } } else { mt->fast_clear_color_value = 0; for (int i = 0; i < 4; i++) { - /* Testing for non-0 works for integer and float colors */ - if (color->f[i] != 0.0f) { - mt->fast_clear_color_value |= -1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i)); + /* Testing for non-0 works for integer and float colors. If the + * component doesn't exist in the format then force the color to 0 for + * the RGB components and 1 for the alpha. + */ + if (_mesa_format_has_color_component(mt->format, i) ? + (color->f[i] != 0.0f) : + (i == 3)) { +mt->fast_clear_color_value |= + 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i)); } } } However I haven't been able to get it to work. It looks like there is a more general problem with fast clears on SKL where a bunch of formats (such as GL_RGB) always return 0,0,0,0 for the pixels that are cleared regardless of the clear color. I think we haven't noticed this in the Piglit tests because most of them clear to black anyway. However if you modify ColorGradientSunburst to clear to white instead then the multisample formats tests starts failing for a lot more formats. I am currently trying to look into this but maybe we should discuss this in a different thread because I think it's not directly related to this patch. Regards, - Neil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] glsl: do not loose precision information when packing varyings
I believe you meant "do not lose ..." :) On 05/11/15 13:33, Tapani Pälli wrote: This information will be used by cross stage validation of varyings for pipeline objects. Signed-off-by: Tapani Pälli--- src/glsl/lower_packed_varyings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp index 5d66ca9..037c27d 100644 --- a/src/glsl/lower_packed_varyings.cpp +++ b/src/glsl/lower_packed_varyings.cpp @@ -621,6 +621,7 @@ lower_packed_varyings_visitor::get_packed_varying_deref( packed_var->data.patch = unpacked_var->data.patch; packed_var->data.interpolation = unpacked_var->data.interpolation; packed_var->data.location = location; + packed_var->data.precision = unpacked_var->data.precision; unpacked_var->insert_before(packed_var); this->packed_varyings[slot] = packed_var; } else { ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/7] glsl: Add default precision qualifiers to the symbol table
On 11/05/2015 01:33 PM, Tapani Pälli wrote: From: Iago Toral QuirogaThe GLSL ES spec specifies default precision qualifiers for certain types, so populate the symbol table with these. Notice that the desktop GLSL spec also indicates defaults for some types but this is not really useful since precision qualifiers are completely ignored in desktop GLSL. v2: simplify and add samplerExternalOES, specified by OES_EGL_image_external (Tapani) --- src/glsl/glsl_parser.yy | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 4636435..4bef345 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -312,6 +312,17 @@ translation_unit: { delete state->symbols; state->symbols = new(ralloc_parent(state)) glsl_symbol_table; + if (state->es_shader) { + if (state->stage == MESA_SHADER_FRAGMENT) { +state->symbols->add_default_precision_qualifier("int", ast_precision_medium); + } else { +state->symbols->add_default_precision_qualifier("float", ast_precision_high); +state->symbols->add_default_precision_qualifier("int", ast_precision_high); + } + state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low); + state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low); + state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low); I missed atomic_uint here, will fix and send new version. + } _mesa_glsl_initialize_types(state); } ; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 00/10] i965: always mark used surfaces in the visitors
On Tue, 2015-11-03 at 09:19 -0800, Mark Janes wrote: > Francisco Jerezwrites: > > > Iago Toral writes: > > > >> On Tue, 2015-11-03 at 15:28 +0200, Francisco Jerez wrote: > >>> Iago Toral writes: > >>> > >>> > On Fri, 2015-10-30 at 16:19 +0200, Francisco Jerez wrote: > >>> >> Iago Toral Quiroga writes: > >>> >> > >>> >> > Right now some opcodes that only use constant surface indexing mark > >>> >> > them as > >>> >> > used in the generator while others do it in the visitor. When the > >>> >> > opcode can > >>> >> > handle both direct and indirect surface indexing then some opcodes > >>> >> > handle > >>> >> > only the constant part in the generator and leave the indirect case > >>> >> > to the > >>> >> > caller. It is all very inconsistent and leads to confusion, since > >>> >> > one has to > >>> >> > go and look into the generator code in each case to check if it > >>> >> > marks surfaces > >>> >> > as used or not, and in which cases. > >>> >> > > >>> >> > when I was working on SSBOs I was tempted to try and fix this but > >>> >> > then I > >>> >> > forgot. Jordan bumped into this recently too when comparing visitor > >>> >> > code paths for similar opcodes (ubos and ssbos) that need to handle > >>> >> > this > >>> >> > differently because they use different generator opcodes. > >>> >> > > >>> >> > Since the generator opcodes never handle marking of indirect > >>> >> > surfaces, just > >>> >> > leave surface marking to the caller completely, since callers always > >>> >> > have > >>> >> > all the information needed for this. It also makes things more > >>> >> > consistent > >>> >> > and clear for everyone: marking surfaces as used is always on the > >>> >> > side > >>> >> > of the visitor, never the generator. > >>> >> > > >>> >> > No piglit regressions observed in my IVB laptop. Would be nice to > >>> >> > have > >>> >> > someone giving this a try with Jenkins though, to make sure I did > >>> >> > not miss > >>> >> > anything in paths specific to other gens. > >>> >> > >>> >> Jenkins seems to be mostly happy about the series except for three > >>> >> apparent regressions: > >>> >> > >>> >> > >>> >> piglit.spec.arb_fragment_layer_viewport.layer-gs-writes-in-range.bdwm64 > >>> > > >>> > Mmmm... not sure what could be going on with this, at first glance, it > >>> > does not look like this test should be affected by this series. The test > >>> > does not use any UBOs, does not really check what is written to the FBO, > >>> > does not emit texture accesses... Also, there are other tests in > >>> > piglit.spec.arb_fragment_layer_viewport that do very similar stuff > >>> > (specially the our-of-range test) and those are passing fine. > >>> > > >>> Odd, I guess it may have been an intermittent failing test that just > >>> happens to have failed during your run. Mark, have you seen any of > >>> these fail intermittently by any chance? > > This was fixed in https://bugs.freedesktop.org/show_bug.cgi?id=92744 > > Ordinarily, all failures/fixes are tracked by commit, and failures due > to an old branchpoint are filtered out. Unfortunately, these failures > were intermittent. > > If you rebase, you shouldn't see those failures anymore. Thanks Mark! It seems that we don't have regressions then. Curro, I was thinking in pushing the patches you reviewed so far. I want to look into the other patches too (the ones dealing with fb writes, textures and shader time), but I got sidetracked with other stuff so I'll probably do that later. Is this fine or would you rather postpone pushing any of these until we got all these opcodes addressed? Iago > >>> > >>> >> > >>> >> piglit.spec.arb_shader_texture_lod.compiler.tex_grad-texture2dproj-2d-vec4.frag.g965m64 > >>> >> > >>> >> piglit.spec.glsl-es-1_00.compiler.structure-and-array-operations.sampler-array-index.frag.g965m64 > >>> >> > >>> >> The latter two die with a crash so you may be able to look into them > >>> >> even if you don't have the original i965 by using > >>> >> INTEL_DEVID_OVERRIDE. ;) > >>> > > >>> > Unfortunately it seems that these don't break for me with the DEVID > >>> > override, that's weird I guess, since they are compiler tests that I can > >>> > fully run without INTEL_NO_HW set: > >>> > > >>> > $ INTEL_DEVID_OVERRIDE=0x29A2 bin/glslparsertest > >>> > generated_tests/spec/arb_shader_texture_lod/compiler/tex_grad-texture2DProj-2D-vec4.frag > >>> > pass 1.10 GL_ARB_shader_texture_lod > >>> > Successfully compiled fragment shader > >>> > generated_tests/spec/arb_shader_texture_lod/compiler/tex_grad-texture2DProj-2D-vec4.frag: > >>> > > >>> > PIGLIT: {"result": "pass" } > >>> > > >>> > $ INTEL_DEVID_OVERRIDE=0x29A2 bin/glslparsertest_gles2 > >>> > tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/sampler-array-index.frag > >>> > pass 1.00 > >>> > Successfully compiled fragment shader > >>> >
Re: [Mesa-dev] [PATCH 00/10] i965: always mark used surfaces in the visitors
Iago Toralwrites: > On Tue, 2015-11-03 at 09:19 -0800, Mark Janes wrote: >> Francisco Jerez writes: >> >> > Iago Toral writes: >> > >> >> On Tue, 2015-11-03 at 15:28 +0200, Francisco Jerez wrote: >> >>> Iago Toral writes: >> >>> >> >>> > On Fri, 2015-10-30 at 16:19 +0200, Francisco Jerez wrote: >> >>> >> Iago Toral Quiroga writes: >> >>> >> >> >>> >> > Right now some opcodes that only use constant surface indexing mark >> >>> >> > them as >> >>> >> > used in the generator while others do it in the visitor. When the >> >>> >> > opcode can >> >>> >> > handle both direct and indirect surface indexing then some opcodes >> >>> >> > handle >> >>> >> > only the constant part in the generator and leave the indirect case >> >>> >> > to the >> >>> >> > caller. It is all very inconsistent and leads to confusion, since >> >>> >> > one has to >> >>> >> > go and look into the generator code in each case to check if it >> >>> >> > marks surfaces >> >>> >> > as used or not, and in which cases. >> >>> >> > >> >>> >> > when I was working on SSBOs I was tempted to try and fix this but >> >>> >> > then I >> >>> >> > forgot. Jordan bumped into this recently too when comparing visitor >> >>> >> > code paths for similar opcodes (ubos and ssbos) that need to handle >> >>> >> > this >> >>> >> > differently because they use different generator opcodes. >> >>> >> > >> >>> >> > Since the generator opcodes never handle marking of indirect >> >>> >> > surfaces, just >> >>> >> > leave surface marking to the caller completely, since callers >> >>> >> > always have >> >>> >> > all the information needed for this. It also makes things more >> >>> >> > consistent >> >>> >> > and clear for everyone: marking surfaces as used is always on the >> >>> >> > side >> >>> >> > of the visitor, never the generator. >> >>> >> > >> >>> >> > No piglit regressions observed in my IVB laptop. Would be nice to >> >>> >> > have >> >>> >> > someone giving this a try with Jenkins though, to make sure I did >> >>> >> > not miss >> >>> >> > anything in paths specific to other gens. >> >>> >> >> >>> >> Jenkins seems to be mostly happy about the series except for three >> >>> >> apparent regressions: >> >>> >> >> >>> >> >> >>> >> piglit.spec.arb_fragment_layer_viewport.layer-gs-writes-in-range.bdwm64 >> >>> > >> >>> > Mmmm... not sure what could be going on with this, at first glance, it >> >>> > does not look like this test should be affected by this series. The >> >>> > test >> >>> > does not use any UBOs, does not really check what is written to the >> >>> > FBO, >> >>> > does not emit texture accesses... Also, there are other tests in >> >>> > piglit.spec.arb_fragment_layer_viewport that do very similar stuff >> >>> > (specially the our-of-range test) and those are passing fine. >> >>> > >> >>> Odd, I guess it may have been an intermittent failing test that just >> >>> happens to have failed during your run. Mark, have you seen any of >> >>> these fail intermittently by any chance? >> >> This was fixed in https://bugs.freedesktop.org/show_bug.cgi?id=92744 >> >> Ordinarily, all failures/fixes are tracked by commit, and failures due >> to an old branchpoint are filtered out. Unfortunately, these failures >> were intermittent. >> >> If you rebase, you shouldn't see those failures anymore. > > > Thanks Mark! It seems that we don't have regressions then. > > Curro, I was thinking in pushing the patches you reviewed so far. I want > to look into the other patches too (the ones dealing with fb writes, > textures and shader time), but I got sidetracked with other stuff so > I'll probably do that later. Is this fine or would you rather postpone > pushing any of these until we got all these opcodes addressed? > Sounds good to me. > Iago > >> >>> >> >>> >> >> >>> >> piglit.spec.arb_shader_texture_lod.compiler.tex_grad-texture2dproj-2d-vec4.frag.g965m64 >> >>> >> >> >>> >> piglit.spec.glsl-es-1_00.compiler.structure-and-array-operations.sampler-array-index.frag.g965m64 >> >>> >> >> >>> >> The latter two die with a crash so you may be able to look into them >> >>> >> even if you don't have the original i965 by using >> >>> >> INTEL_DEVID_OVERRIDE. ;) >> >>> > >> >>> > Unfortunately it seems that these don't break for me with the DEVID >> >>> > override, that's weird I guess, since they are compiler tests that I >> >>> > can >> >>> > fully run without INTEL_NO_HW set: >> >>> > >> >>> > $ INTEL_DEVID_OVERRIDE=0x29A2 bin/glslparsertest >> >>> > generated_tests/spec/arb_shader_texture_lod/compiler/tex_grad-texture2DProj-2D-vec4.frag >> >>> > pass 1.10 GL_ARB_shader_texture_lod >> >>> > Successfully compiled fragment shader >> >>> > generated_tests/spec/arb_shader_texture_lod/compiler/tex_grad-texture2DProj-2D-vec4.frag: >> >>> > >> >>> > PIGLIT: {"result": "pass" } >> >>> > >> >>> > $ INTEL_DEVID_OVERRIDE=0x29A2
[Mesa-dev] [PATCH 3/7] glsl: Add user-defined default precision qualifiers to the symbol table
From: Iago Toral QuirogaNotice that the spec requires that a default precision has been set for every type used by a shader that can use a precision qualifier and does not have a predefined precision, however, at the moment, Mesa only checks this for floats in the fragment shader. This is probably because the GLSL ES 1.0 specs mentions this case specifically, but GLSL ES 3.0 clarifies that the same applies to other types: "The fragment language has no default precision qualifier for floating point types. Hence for float, floating point vector and matrix variable declarations, either the declaration must include a precision qualifier or the default float precision must have been previously declared. Similarly, there is no default precision qualifier for the following sampler types in either the vertex or fragment language: sampler3D; samplerCubeShadow; sampler2DShadow; sampler2DArray; sampler2DArrayShadow; isampler2D; isampler3D; isamplerCube; isampler2DArray; usampler2D; usampler3D; usamplerCube; usampler2DArray;" we will fix this in a later patch. --- src/glsl/ast_to_hir.cpp | 29 ++--- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0306530..d20be0b 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2184,11 +2184,15 @@ ast_fully_specified_type::glsl_type(const char **name, if (type == NULL) return NULL; + /* The fragment language does not define a default precision value +* for float types, so check that one is defined if the type declaration +* isn't providing one explictly. +*/ if (type->base_type == GLSL_TYPE_FLOAT && state->es_shader && state->stage == MESA_SHADER_FRAGMENT && this->qualifier.precision == ast_precision_none - && state->symbols->get_variable("#default precision") == NULL) { + && state->symbols->get_default_precision_qualifier("float") == ast_precision_none) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(, state, "no precision specified this scope for type `%s'", @@ -5749,20 +5753,10 @@ ast_type_specifier::hir(exec_list *instructions, return NULL; } - if (type->base_type == GLSL_TYPE_FLOAT - && state->es_shader - && state->stage == MESA_SHADER_FRAGMENT) { + if (state->es_shader) { /* Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00 * spec says: * - * "The fragment language has no default precision qualifier for - * floating point types." - * - * As a result, we have to track whether or not default precision has - * been specified for float in GLSL ES fragment shaders. - * - * Earlier in that same section, the spec says: - * * "Non-precision qualified declarations will use the precision * qualifier specified in the most recent precision statement * that is still in scope. The precision statement has the same @@ -5775,16 +5769,13 @@ ast_type_specifier::hir(exec_list *instructions, * overriding earlier statements within that scope." * * Default precision specifications follow the same scope rules as - * variables. So, we can track the state of the default float - * precision in the symbol table, and the rules will just work. This + * variables. So, we can track the state of the default precision + * qualifiers in the symbol table, and the rules will just work. This * is a slight abuse of the symbol table, but it has the semantics * that we want. */ - ir_variable *const junk = -new(state) ir_variable(type, "#default precision", - ir_var_auto); - - state->symbols->add_variable(junk); + state->symbols->add_default_precision_qualifier(this->type_name, + this->default_precision); } /* FINISHME: Translate precision statements into IR. */ -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/7] glsl: Add default precision qualifiers to the symbol table
From: Iago Toral QuirogaThe GLSL ES spec specifies default precision qualifiers for certain types, so populate the symbol table with these. Notice that the desktop GLSL spec also indicates defaults for some types but this is not really useful since precision qualifiers are completely ignored in desktop GLSL. v2: simplify and add samplerExternalOES, specified by OES_EGL_image_external (Tapani) --- src/glsl/glsl_parser.yy | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 4636435..4bef345 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -312,6 +312,17 @@ translation_unit: { delete state->symbols; state->symbols = new(ralloc_parent(state)) glsl_symbol_table; + if (state->es_shader) { + if (state->stage == MESA_SHADER_FRAGMENT) { +state->symbols->add_default_precision_qualifier("int", ast_precision_medium); + } else { +state->symbols->add_default_precision_qualifier("float", ast_precision_high); +state->symbols->add_default_precision_qualifier("int", ast_precision_high); + } + state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low); + state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low); + state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low); + } _mesa_glsl_initialize_types(state); } ; -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] ARB_enhanced_layout compile-time-constants
This series adds support for compile time constants and also adds subroutine index qualifier support which was missing for ARB_explicit_uniform_location it doesn't add the missing subroutine location qualifier I'll add that in a follow-up. Piglit tests have been reviewed and pushed to master, there is one outstanding that tests querying of the subroutine index [1]. The extension is disabled by default until the remaining features are added. MESA_EXTENSION_OVERRIDE=GL_ARB_enhanced_layouts can be used for testing. You can get the series from my arb_enhanced_layouts3 branch [2] [1] https://patchwork.freedesktop.org/patch/63795/ [2] https://github.com/tarceri/Mesa_arrays_of_arrays.git ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/6] mesa: add ARB_enhanced_layouts
From: Timothy ArceriSet to dummy_false until the remaining features are added. --- src/glsl/glcpp/glcpp-parse.y| 1 + src/glsl/glsl_parser_extras.cpp | 1 + src/glsl/glsl_parser_extras.h | 2 ++ src/mesa/main/extensions.c | 1 + 4 files changed, 5 insertions(+) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 4acccf7..6aa7abe 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -2387,6 +2387,7 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio } } else { add_builtin_define(parser, "GL_ARB_draw_buffers", 1); + add_builtin_define(parser, "GL_ARB_enhanced_layouts", 1); add_builtin_define(parser, "GL_ARB_separate_shader_objects", 1); add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1); diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 14cb9fc..be344d6 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -594,6 +594,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(ARB_derivative_control, true, false, ARB_derivative_control), EXT(ARB_draw_buffers, true, false, dummy_true), EXT(ARB_draw_instanced, true, false, ARB_draw_instanced), + EXT(ARB_enhanced_layouts, true, false, dummy_true), EXT(ARB_explicit_attrib_location, true, false, ARB_explicit_attrib_location), EXT(ARB_explicit_uniform_location,true, false, ARB_explicit_uniform_location), EXT(ARB_fragment_coord_conventions, true, false, ARB_fragment_coord_conventions), diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index b54c535..684b917 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -499,6 +499,8 @@ struct _mesa_glsl_parse_state { bool ARB_draw_buffers_warn; bool ARB_draw_instanced_enable; bool ARB_draw_instanced_warn; + bool ARB_enhanced_layouts_enable; + bool ARB_enhanced_layouts_warn; bool ARB_explicit_attrib_location_enable; bool ARB_explicit_attrib_location_warn; bool ARB_explicit_uniform_location_enable; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index bdc6817..b8556aa 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -111,6 +111,7 @@ static const struct extension extension_table[] = { { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 }, { "GL_ARB_draw_indirect", o(ARB_draw_indirect), GLC,2010 }, { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL, 2008 }, + { "GL_ARB_enhanced_layouts",o(dummy_false), GLC,2013 }, { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location),GL, 2009 }, { "GL_ARB_explicit_uniform_location", o(ARB_explicit_uniform_location), GL, 2012 }, { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL, 2009 }, -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/6] docs: mark compile-time constant expressions as done
From: Timothy Arceri--- docs/GL3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 7abdcd8..416b734 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -179,7 +179,7 @@ GL 4.4, GLSL 4.40: GL_ARB_buffer_storageDONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_clear_texture DONE (i965) (gallium - in progress, VMware) GL_ARB_enhanced_layouts in progress (Timothy) - - compile-time constant expressions in progress + - compile-time constant expressions DONE - explicit byte offsets for blocks in progress - forced alignment within blocks in progress - specified vec4-slot component numbers in progress -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/6] glsl: add support for complie-time constant expressions
From: Timothy ArceriIn this patch we introduce a new ast type for holding the new compile-time constant expressions. The main reason for this is that we can no longer do merging of layout qualifiers before they have been converted into GLSL IR. The remainder of the patch replaces all the old interger constant qualifiers with either the new ast_layout_expression type if the qualifier requires merging or ast_expression if the qualifier can't have mulitple declorations or if all but he newest qualifier is simply ignored. There are three main helper functions introduced in this patch: - process_qualifier_constant() Used to evaluate qualifiers of type ast_expression - ast_layout_expression::process_qualifier_constant() Used to merge and then evaluate qualifiers of type ast_layout_expression - ast_layout_expression::merge_qualifier() Simply appends a qualifier to a list to be merged later by process_qualifier_constant() In order to avoid cascading error messages the process_qualifier_constant() helpers return a bool. --- src/glsl/ast.h | 60 ++--- src/glsl/ast_to_hir.cpp | 274 src/glsl/ast_type.cpp | 128 +++ src/glsl/glsl_parser.yy | 25 ++-- src/glsl/glsl_parser_extras.cpp | 68 ++ 5 files changed, 363 insertions(+), 192 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index afd2d41..8fbb5dd 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -350,6 +350,26 @@ public: exec_list array_dimensions; }; +class ast_layout_expression : public ast_node { +public: + ast_layout_expression(const struct YYLTYPE , ast_expression *expr) + { + set_location(locp); + layout_const_expressions.push_tail(>link); + } + + bool process_qualifier_constant(struct _mesa_glsl_parse_state *state, + const char *qual_indentifier, + int *value); + + void merge_qualifier(ast_layout_expression *l_expr) + { + layout_const_expressions.append_list(_expr->layout_const_expressions); + } + + exec_list layout_const_expressions; +}; + /** * C-style aggregate initialization class * @@ -553,13 +573,11 @@ struct ast_type_qualifier { uint64_t i; } flags; - struct YYLTYPE *loc; - /** Precision of the type (highp/medium/lowp). */ unsigned precision:2; /** Geometry shader invocations for GL_ARB_gpu_shader5. */ - int invocations; + ast_layout_expression *invocations; /** * Location specified via GL_ARB_explicit_attrib_location layout @@ -567,20 +585,20 @@ struct ast_type_qualifier { * \note * This field is only valid if \c explicit_location is set. */ - int location; + ast_expression *location; /** * Index specified via GL_ARB_explicit_attrib_location layout * * \note * This field is only valid if \c explicit_index is set. */ - int index; + ast_expression *index; /** Maximum output vertices in GLSL 1.50 geometry shaders. */ - int max_vertices; + ast_layout_expression *max_vertices; /** Stream in GLSL 1.50 geometry shaders. */ - unsigned stream; + ast_expression *stream; /** * Input or output primitive type in GLSL 1.50 geometry shaders @@ -594,7 +612,7 @@ struct ast_type_qualifier { * \note * This field is only valid if \c explicit_binding is set. */ - int binding; + ast_expression *binding; /** * Offset specified via GL_ARB_shader_atomic_counter's "offset" @@ -603,14 +621,14 @@ struct ast_type_qualifier { * \note * This field is only valid if \c explicit_offset is set. */ - int offset; + ast_expression *offset; /** * Local size specified via GL_ARB_compute_shader's "local_size_{x,y,z}" * layout qualifier. Element i of this array is only valid if * flags.q.local_size & (1 << i) is set. */ - int local_size[3]; + ast_layout_expression *local_size[3]; /** Tessellation evaluation shader: vertex spacing (equal, fractional even/odd) */ GLenum vertex_spacing; @@ -622,7 +640,7 @@ struct ast_type_qualifier { bool point_mode; /** Tessellation control shader: number of output vertices */ - int vertices; + ast_layout_expression *vertices; /** * Image format specified with an ARB_shader_image_load_store @@ -1094,17 +1112,13 @@ public: class ast_tcs_output_layout : public ast_node { public: - ast_tcs_output_layout(const struct YYLTYPE , int vertices) - : vertices(vertices) + ast_tcs_output_layout(const struct YYLTYPE ) { set_location(locp); } virtual ir_rvalue *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); - -private: - const int vertices; }; @@ -1136,9 +1150,10 @@ private: class ast_cs_input_layout : public ast_node { public: - ast_cs_input_layout(const struct
[Mesa-dev] [PATCH 5/6] glsl: add subroutine index qualifier support
From: Timothy ArceriARB_explicit_uniform_location allows the index for subroutine functions to be explicitly set in the shader. This patch reduces the restriction on the index qualifier in validate_layout_qualifiers() to allow it to be applied to subroutines and adds the new subroutine qualifier validation to ast_function::hir(). ast_fully_specified_type::has_qualifiers() is updated to allow the index qualifier on subroutine functions when explicit uniform loctions is available. A new check is added to ast_type_qualifier::merge_qualifier() to stop multiple function qualifiers from being defied, before this patch this would cause a segfault. Finally a new variable is added to ir_function_signature to store the index. This value is validated and the non explicit values assigned in link_assign_subroutine_types(). --- src/glsl/ast.h | 2 +- src/glsl/ast_to_hir.cpp| 68 ++ src/glsl/ast_type.cpp | 14 - src/glsl/ir.cpp| 1 + src/glsl/ir.h | 2 ++ src/glsl/ir_clone.cpp | 1 + src/glsl/linker.cpp| 33 src/mesa/main/mtypes.h | 1 + src/mesa/main/shader_query.cpp | 7 + 9 files changed, 108 insertions(+), 21 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 8fbb5dd..f96585f 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -771,7 +771,7 @@ public: class ast_fully_specified_type : public ast_node { public: virtual void print(void) const; - bool has_qualifiers() const; + bool has_qualifiers(_mesa_glsl_parse_state *state) const; ast_fully_specified_type() : qualifier(), specifier(NULL) { diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e71c539..f1cc263 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2617,28 +2617,37 @@ validate_layout_qualifiers(const struct ast_type_qualifier *qual, validate_explicit_location(qual, var, state, loc); if (qual->flags.q.explicit_index) { - /* From the GLSL 4.30 specification, section 4.4.2 (Output - * Layout Qualifiers): - * - * "It is also a compile-time error if a fragment shader - * sets a layout index to less than 0 or greater than 1." - * - * Older specifications don't mandate a behavior; we take - * this as a clarification and always generate the error. - */ - int qual_index; - if (process_qualifier_constant(state, loc, "index", -qual->index, _index) && - (qual_index < 0 || qual_index > 1)) { -_mesa_glsl_error(loc, state, - "explicit index may only be 0 or 1"); + /* Check if index was set for the uniform instead of the function */ + if (qual->flags.q.subroutine) { +_mesa_glsl_error(loc, state, "an index qualifier can only be " + "used with subroutine functions"); } else { -var->data.explicit_index = true; -var->data.index = qual_index; + +/* From the GLSL 4.30 specification, section 4.4.2 (Output + * Layout Qualifiers): + * + * "It is also a compile-time error if a fragment shader + * sets a layout index to less than 0 or greater than 1." + * + * Older specifications don't mandate a behavior; we take + * this as a clarification and always generate the error. + */ +int qual_index; +if (process_qualifier_constant(state, loc, "index", + qual->index, _index) && +(qual_index < 0 || qual_index > 1)) { + _mesa_glsl_error(loc, state, +"explicit index may only be 0 or 1"); +} else { + var->data.explicit_index = true; + var->data.index = qual_index; +} } } } else if (qual->flags.q.explicit_index) { - _mesa_glsl_error(loc, state, "explicit index requires explicit location"); + if (!qual->flags.q.subroutine_def) + _mesa_glsl_error(loc, state, + "explicit index requires explicit location"); } if (qual->flags.q.explicit_binding && @@ -4855,7 +4864,7 @@ ast_function::hir(exec_list *instructions, /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec: * "No qualifier is allowed on the return type of a function." */ - if (this->return_type->has_qualifiers()) { + if (this->return_type->has_qualifiers(state)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "function `%s' return type has qualifiers", name); @@ -4987,6 +4996,27 @@ ast_function::hir(exec_list *instructions, if
[Mesa-dev] [PATCH 3/6] glsl: move layout qualifier validation out of the parser
From: Timothy ArceriThis is in preperation for compile-time constant support. Also fix up the locations for some of the extension checking error messages in the parser. We now correctly give the location of the layout qualifier identifier rather than the integer constant. The validation is moved to two locations, for validation on variables the checks are moved to the ast to hir pass and for qualifiers that apply to the shader the validation is moved into glsl_parser_extras.cpp. In order to do validation at the later stage in glsl_parser_extras.cpp we need to temporarily add a field in ast_type_qualifier to keep track of the parser location, this will be removed in a following patch when we introduce a new type for storing the comiple-time qualifiers. Also as the set_shader_inout_layout() function in glsl parser extras is normally called after all validation is done we need to move the code that sets CompileStatus and InfoLog otherwise the newly moved error messages will be ignored. --- src/glsl/ast.h | 2 + src/glsl/ast_to_hir.cpp | 101 ++-- src/glsl/ast_type.cpp | 2 + src/glsl/glsl_parser.yy | 100 +-- src/glsl/glsl_parser_extras.cpp | 50 +--- 5 files changed, 137 insertions(+), 118 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index e803e6d..afd2d41 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -553,6 +553,8 @@ struct ast_type_qualifier { uint64_t i; } flags; + struct YYLTYPE *loc; + /** Precision of the type (highp/medium/lowp). */ unsigned precision:2; diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0306530..8fb8875 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2414,6 +2414,12 @@ validate_explicit_location(const struct ast_type_qualifier *qual, { bool fail = false; + if (qual->location < 0) { + _mesa_glsl_error(loc, state, "invalid location %d specified", +qual->location); + return; + } + /* Checks for GL_ARB_explicit_uniform_location. */ if (qual->flags.q.uniform) { if (!state->check_explicit_uniform_location_allowed(loc, var)) @@ -2537,6 +2543,18 @@ validate_explicit_location(const struct ast_type_qualifier *qual, assert(!"Unexpected shader type"); break; } + } +} + +static void +validate_layout_qualifiers(const struct ast_type_qualifier *qual, + ir_variable *var, + struct _mesa_glsl_parse_state *state, + YYLTYPE *loc) +{ + if (qual->flags.q.explicit_location) { + + validate_explicit_location(qual, var, state, loc); if (qual->flags.q.explicit_index) { /* From the GLSL 4.30 specification, section 4.4.2 (Output @@ -2556,6 +2574,38 @@ validate_explicit_location(const struct ast_type_qualifier *qual, var->data.index = qual->index; } } + } else if (qual->flags.q.explicit_index) { + _mesa_glsl_error(loc, state, "explicit index requires explicit location"); + } + + if (qual->flags.q.explicit_binding && + validate_binding_qualifier(state, loc, var->type, qual)) { + var->data.explicit_binding = true; + var->data.binding = qual->binding; + } + + if (var->type->contains_atomic()) { + if (var->data.mode == ir_var_uniform) { + if (var->data.explicit_binding) { +unsigned *offset = + >atomic_counter_offsets[var->data.binding]; + +if (*offset % ATOMIC_COUNTER_SIZE) + _mesa_glsl_error(loc, state, +"misaligned atomic counter offset"); + +var->data.atomic.offset = *offset; +*offset += var->type->atomic_size(); + + } else { +_mesa_glsl_error(loc, state, + "atomic counters require explicit binding point"); + } + } else if (var->data.mode != ir_var_function_in) { + _mesa_glsl_error(loc, state, "atomic counters may only be declared as " + "function parameters or uniform-qualified " + "global variables"); + } } } @@ -2935,41 +2985,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, state->fs_redeclares_gl_fragcoord_with_no_layout_qualifiers; } - if (qual->flags.q.explicit_location) { - validate_explicit_location(qual, var, state, loc); - } else if (qual->flags.q.explicit_index) { - _mesa_glsl_error(loc, state, "explicit index requires explicit location"); - } - - if (qual->flags.q.explicit_binding && - validate_binding_qualifier(state, loc, var->type, qual)) { - var->data.explicit_binding = true; - var->data.binding = qual->binding; - } - - if (var->type->contains_atomic()) { -
[Mesa-dev] [PATCH 2/6] glsl: add helper to check for enhanced layouts support
From: Timothy Arceri--- src/glsl/glsl_parser_extras.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 684b917..1d8c1b8 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -209,6 +209,11 @@ struct _mesa_glsl_parse_state { return ARB_shader_atomic_counters_enable || is_version(420, 310); } + bool has_enhanced_layouts() const + { + return ARB_enhanced_layouts_enable || is_version(440, 0); + } + bool has_explicit_attrib_stream() const { return ARB_gpu_shader5_enable || is_version(400, 0); -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/7] precision qualifiers for ir_variable
Hi; I rebased Iago's patches and fixed some issues that I saw. On top of it is 2 patches that fix precision related ES 3.1 CTS errors. Any comments appreciated. What should be included in validation seems a bit vague in the specs and I did not include anything else than precision since this is what CTS explicitly checks for. Also, I noticed that Mesa sets INVALID_OPERATION error always when validation fails, I don't think this is correct. Spec lists the cases when error should happen and otherwise only the validation state should be changed, this is also how CTS expects it to work. Currently we fail almost all dEQP tests for separate shader objects, these patches did not have any effect on dEQP. I believe changes from Gregory Hainut will fix some of those issues. Thanks; Iago Toral Quiroga (5): glsl: Add API to put default precision qualifiers in the symbol table glsl: Add default precision qualifiers to the symbol table glsl: Add user-defined default precision qualifiers to the symbol table glsl: Move the definition of precision_qualifier_allowed glsl: Add precision information to ir_variable Tapani Pälli (2): glsl: do not loose precision information when packing varyings mesa: validate precision of varyings during ValidateProgramPipeline src/glsl/ast_to_hir.cpp| 355 + src/glsl/glsl_parser.yy| 11 ++ src/glsl/glsl_symbol_table.cpp | 24 +++ src/glsl/glsl_symbol_table.h | 2 + src/glsl/ir.h | 13 ++ src/glsl/lower_packed_varyings.cpp | 1 + src/glsl/nir/glsl_types.cpp| 4 + src/glsl/nir/glsl_types.h | 11 ++ src/mesa/main/pipelineobj.c| 15 ++ src/mesa/main/shader_query.cpp | 55 ++ src/mesa/main/shaderobj.h | 3 + 11 files changed, 423 insertions(+), 71 deletions(-) -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/7] glsl: Add API to put default precision qualifiers in the symbol table
From: Iago Toral QuirogaThese have scoping rules that match the ones defined for other things such as variables, so we want them in the symbol table. --- src/glsl/glsl_symbol_table.cpp | 24 src/glsl/glsl_symbol_table.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp index 536f0a3..6c682ac 100644 --- a/src/glsl/glsl_symbol_table.cpp +++ b/src/glsl/glsl_symbol_table.cpp @@ -23,6 +23,7 @@ */ #include "glsl_symbol_table.h" +#include "ast.h" class symbol_table_entry { public: @@ -201,6 +202,20 @@ bool glsl_symbol_table::add_function(ir_function *f) return _mesa_symbol_table_add_symbol(table, -1, f->name, entry) == 0; } +bool glsl_symbol_table::add_default_precision_qualifier(const char *type_name, +int precision) +{ + char *name = ralloc_asprintf(mem_ctx, "#default_precision_%s", type_name); + + ast_type_specifier *default_specifier = new(mem_ctx) ast_type_specifier(name); + default_specifier->default_precision = precision; + + symbol_table_entry *entry = + new(mem_ctx) symbol_table_entry(default_specifier); + + return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; +} + void glsl_symbol_table::add_global_function(ir_function *f) { symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f); @@ -234,6 +249,15 @@ ir_function *glsl_symbol_table::get_function(const char *name) return entry != NULL ? entry->f : NULL; } +int glsl_symbol_table::get_default_precision_qualifier(const char *type_name) +{ + char *name = ralloc_asprintf(mem_ctx, "#default_precision_%s", type_name); + symbol_table_entry *entry = get_entry(name); + if (!entry) + return ast_precision_none; + return entry->a->default_precision; +} + symbol_table_entry *glsl_symbol_table::get_entry(const char *name) { return (symbol_table_entry *) diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h index e32b88b..5d654e5 100644 --- a/src/glsl/glsl_symbol_table.h +++ b/src/glsl/glsl_symbol_table.h @@ -72,6 +72,7 @@ struct glsl_symbol_table { bool add_function(ir_function *f); bool add_interface(const char *name, const glsl_type *i, enum ir_variable_mode mode); + bool add_default_precision_qualifier(const char *type_name, int precision); /*@}*/ /** @@ -88,6 +89,7 @@ struct glsl_symbol_table { ir_function *get_function(const char *name); const glsl_type *get_interface(const char *name, enum ir_variable_mode mode); + int get_default_precision_qualifier(const char *type_name); /*@}*/ /** -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/7] glsl: Add precision information to ir_variable
From: Iago Toral QuirogaWe will need this later on when we implement proper support for precision qualifiers in the drivers and also to do link time checks for uniforms as indicated by the spec. This patch also adds compile-time checks for variables without precision information (currently, Mesa only checks that a default precision is set for floats in fragment shaders). As indicated by Ian, the addition of the precision information to ir_variable has been done using a bitfield and pahole to identify an available hole so that memory requirements for ir_variable stay the same. v2 (Ian): - Avoid if-ladders by defining arrays of supported sampler names and indexing into them with type->sampler_array + 2 * type->sampler_shadow - Make the code that selects the precision qualifier to use an utility function - Fix a typo v3 (Tapani): - rebased - squashed in "Precision qualifiers are not allowed on structs" - fixed select_gles_precision for sampler arrays - fixed precision_qualifier_allowed for arrays of structs --- src/glsl/ast_to_hir.cpp | 269 src/glsl/ir.h | 13 +++ src/glsl/nir/glsl_types.cpp | 4 + src/glsl/nir/glsl_types.h | 11 ++ 4 files changed, 274 insertions(+), 23 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index b6d662b..db6db9d 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2189,10 +2189,10 @@ precision_qualifier_allowed(const glsl_type *type) * From this, we infer that GLSL 1.30 (and later) should allow precision * qualifiers on sampler types just like float and integer types. */ - return type->is_float() + return (type->is_float() || type->is_integer() - || type->is_record() - || type->contains_opaque(); + || type->contains_opaque()) + && !type->without_array()->is_record(); } const glsl_type * @@ -2210,31 +2210,241 @@ ast_type_specifier::glsl_type(const char **name, return type; } -const glsl_type * -ast_fully_specified_type::glsl_type(const char **name, -struct _mesa_glsl_parse_state *state) const +/** + * From the OpenGL ES 3.0 spec, 4.5.4 Default Precision Qualifiers: + * + * "The precision statement + * + *precision precision-qualifier type; + * + * can be used to establish a default precision qualifier. The type field can + * be either int or float or any of the sampler types, (...) If type is float, + * the directive applies to non-precision-qualified floating point type + * (scalar, vector, and matrix) declarations. If type is int, the directive + * applies to all non-precision-qualified integer type (scalar, vector, signed, + * and unsigned) declarations." + * + * We use the symbol table to keep the values of the default precisions for + * each 'type' in each scope and we use the 'type' string from the precision + * statement as key in the symbol table. When we want to retrieve the default + * precision associated with a given glsl_type we need to know the type string + * associated with it. This is what this function returns. + */ +static const char * +get_type_name_for_precision_qualifier(const glsl_type *type) { - const struct glsl_type *type = this->specifier->glsl_type(name, state); - - if (type == NULL) - return NULL; + switch (type->base_type) { + case GLSL_TYPE_FLOAT: + return "float"; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + return "int"; + case GLSL_TYPE_SAMPLER: { + const unsigned type_idx = + type->sampler_array + 2 * type->sampler_shadow; + assert(type_idx < 4); + switch (type->sampler_type) { + case GLSL_TYPE_FLOAT: + switch (type->sampler_dimensionality) { + case GLSL_SAMPLER_DIM_1D: { +static const char *const names[4] = { + "sampler1D", "sampler1DArray", + "sampler1DShadow", "sampler1DArrayShadow" +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_2D: { +static const char *const names[4] = { + "sampler2D", "sampler2DArray", + "sampler2DShadow", "sampler2DArrayShadow" +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_3D: { +static const char *const names[4] = { + "sampler3D", NULL, NULL, NULL +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_CUBE: { +static const char *const names[4] = { + "samplerCube", "samplerCubeArray", + "samplerCubeShadow", "samplerCubeArrayShadow" +}; +return names[type_idx]; + } + case GLSL_SAMPLER_DIM_MS: { +static const char *const names[4] = { + "sampler2DMS", "sampler2DMSArray", NULL, NULL +}; +return names[type_idx]; +
[Mesa-dev] [PATCH 4/7] glsl: Move the definition of precision_qualifier_allowed
From: Iago Toral QuirogaWe will need this to build later patches --- src/glsl/ast_to_hir.cpp | 71 - 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index d20be0b..b6d662b 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2159,6 +2159,41 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, return array_type; } +static bool +precision_qualifier_allowed(const glsl_type *type) +{ + /* Precision qualifiers apply to floating point, integer and opaque +* types. +* +* Section 4.5.2 (Precision Qualifiers) of the GLSL 1.30 spec says: +*"Any floating point or any integer declaration can have the type +*preceded by one of these precision qualifiers [...] Literal +*constants do not have precision qualifiers. Neither do Boolean +*variables. +* +* Section 4.5 (Precision and Precision Qualifiers) of the GLSL 1.30 +* spec also says: +* +* "Precision qualifiers are added for code portability with OpenGL +* ES, not for functionality. They have the same syntax as in OpenGL +* ES." +* +* Section 8 (Built-In Functions) of the GLSL ES 1.00 spec says: +* +* "uniform lowp sampler2D sampler; +* highp vec2 coord; +* ... +* lowp vec4 col = texture2D (sampler, coord); +*// texture2D returns lowp" +* +* From this, we infer that GLSL 1.30 (and later) should allow precision +* qualifiers on sampler types just like float and integer types. +*/ + return type->is_float() + || type->is_integer() + || type->is_record() + || type->contains_opaque(); +} const glsl_type * ast_type_specifier::glsl_type(const char **name, @@ -3645,42 +3680,6 @@ validate_identifier(const char *identifier, YYLTYPE loc, } } -static bool -precision_qualifier_allowed(const glsl_type *type) -{ - /* Precision qualifiers apply to floating point, integer and opaque -* types. -* -* Section 4.5.2 (Precision Qualifiers) of the GLSL 1.30 spec says: -*"Any floating point or any integer declaration can have the type -*preceded by one of these precision qualifiers [...] Literal -*constants do not have precision qualifiers. Neither do Boolean -*variables. -* -* Section 4.5 (Precision and Precision Qualifiers) of the GLSL 1.30 -* spec also says: -* -* "Precision qualifiers are added for code portability with OpenGL -* ES, not for functionality. They have the same syntax as in OpenGL -* ES." -* -* Section 8 (Built-In Functions) of the GLSL ES 1.00 spec says: -* -* "uniform lowp sampler2D sampler; -* highp vec2 coord; -* ... -* lowp vec4 col = texture2D (sampler, coord); -*// texture2D returns lowp" -* -* From this, we infer that GLSL 1.30 (and later) should allow precision -* qualifiers on sampler types just like float and integer types. -*/ - return type->is_float() - || type->is_integer() - || type->is_record() - || type->contains_opaque(); -} - ir_rvalue * ast_declarator_list::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/7] mesa: validate precision of varyings during ValidateProgramPipeline
Fixes following failing ES3.1 CTS tests: ES31-CTS.sepshaderobjs.InterfacePrecisionMatchingFloat ES31-CTS.sepshaderobjs.InterfacePrecisionMatchingInt ES31-CTS.sepshaderobjs.InterfacePrecisionMatchingUInt Signed-off-by: Tapani Pälli--- src/mesa/main/pipelineobj.c| 15 src/mesa/main/shader_query.cpp | 55 ++ src/mesa/main/shaderobj.h | 3 +++ 3 files changed, 73 insertions(+) diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c index 699a2ae..90dff13 100644 --- a/src/mesa/main/pipelineobj.c +++ b/src/mesa/main/pipelineobj.c @@ -907,6 +907,21 @@ _mesa_ValidateProgramPipeline(GLuint pipeline) _mesa_validate_program_pipeline(ctx, pipe, (ctx->_Shader->Name == pipe->Name)); + + /* Validate inputs against outputs, this cannot be done during linking +* since programs have been linked separately from each other. +* +* From OpenGL 4.5 Core spec: +* "Separable program objects may have validation failures that cannot be +* detected without the complete program pipeline. Mismatched interfaces, +* improper usage of program objects together, and the same +* state-dependent failures can result in validation errors for such +* program objects." +* +* OpenGL ES 3.1 specification has the same text. +*/ + if (!_mesa_validate_pipeline_io(pipe)) + pipe->Validated = GL_FALSE; } void GLAPIENTRY diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index 5cb877b..595bdea 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -1359,3 +1359,58 @@ _mesa_get_program_resourceiv(struct gl_shader_program *shProg, if (length) *length = amount; } + +static bool +validate_io(const struct gl_shader *input_stage, +const struct gl_shader *output_stage) +{ + assert(input_stage && output_stage); + + /* For each output in a, find input in b and do any required checks. */ + foreach_in_list(ir_instruction, out, input_stage->ir) { + ir_variable *out_var = out->as_variable(); + if (!out_var || out_var->data.mode != ir_var_shader_out) + continue; + + foreach_in_list(ir_instruction, in, output_stage->ir) { + ir_variable *in_var = in->as_variable(); + if (!in_var || in_var->data.mode != ir_var_shader_in) +continue; + + if (strcmp(in_var->name, out_var->name) == 0) { +if (in_var->data.precision != out_var->data.precision) + return false; + } + } + } + return true; +} + +/** + * Validate inputs against outputs in a program pipeline. + */ +extern "C" bool +_mesa_validate_pipeline_io(struct gl_pipeline_object *pipeline) +{ + struct gl_shader_program **shProg = + (struct gl_shader_program **) pipeline->CurrentProgram; + + /* Find first active stage in pipeline. */ + unsigned idx, prev = 0; + for (idx = 0; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) { + if (shProg[idx]) { + prev = idx; + break; + } + } + + for (idx = prev + 1; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) { + if (shProg[idx]) { + if (!validate_io(shProg[prev]->_LinkedShaders[prev], + shProg[idx]->_LinkedShaders[idx])) +return false; + prev = idx; + } + } + return true; +} diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h index 796de47..be80752 100644 --- a/src/mesa/main/shaderobj.h +++ b/src/mesa/main/shaderobj.h @@ -234,6 +234,9 @@ _mesa_shader_stage_to_subroutine_uniform(gl_shader_stage stage) } } +extern bool +_mesa_validate_pipeline_io(struct gl_pipeline_object *); + #ifdef __cplusplus } #endif -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/7] glsl: do not loose precision information when packing varyings
This information will be used by cross stage validation of varyings for pipeline objects. Signed-off-by: Tapani Pälli--- src/glsl/lower_packed_varyings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp index 5d66ca9..037c27d 100644 --- a/src/glsl/lower_packed_varyings.cpp +++ b/src/glsl/lower_packed_varyings.cpp @@ -621,6 +621,7 @@ lower_packed_varyings_visitor::get_packed_varying_deref( packed_var->data.patch = unpacked_var->data.patch; packed_var->data.interpolation = unpacked_var->data.interpolation; packed_var->data.location = location; + packed_var->data.precision = unpacked_var->data.precision; unpacked_var->insert_before(packed_var); this->packed_varyings[slot] = packed_var; } else { -- 2.4.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 12/24] i965: Initialize registers' file to BAD_FILE.
On 3 November 2015 at 18:02, Matt Turnerwrote: > On Tue, Nov 3, 2015 at 8:05 AM, Emil Velikov wrote: >> On 3 November 2015 at 00:29, Matt Turner wrote: >>> The test (file == BAD_FILE) works on registers for which the constructor >>> has not run because BAD_FILE is zero. The next commit will move >>> BAD_FILE in the enum so that it's no longer zero. >> >> Doesn't the DECLARE_RALLOC_CXX_OPERATORS macro and fs_reg::fs_reg() >> kick in ? If not things look quite fragile and perhaps we should wire >> them up. > > I don't know. > > I'm certainly in favor of actually constructing fs_regs... > > Ken was pretty horrified when I told him that we were just > ralloc_arrary()ing fs_regs without calling the constructor, but he's > partly to blame (commit commit 6928bea :) > > What's worse, ralloc_array() isn't even supposed to zero-initialize > things. That's just an accident that's kind of hard to fix now. > > I could try to clean that stuff up, but again, this series is already > cleaning plenty of stuff. If I stopped to fix every bug I saw... For anyone interested (to answer my questions): With the proper ctors in place one of these hunks is no longer needed. For the remaining we need an extra (or to extend the) macro, because as is, it doesn't override the new[] operator (and to actually use it of course). -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/4] st/va: properly indent buffer.c, config.c, image.c and picture.c
On 5 November 2015 at 08:24, Julien Isorcewrote: > Some lines were using 4 indentation spaces instead of 3. > > The switch in vlVaAcquireBufferHandle actually had wrong brackets > surrounding case+default. > Please don't mix whitespace (trivial) patches and bugfixes. -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] Implement EXT_blend_func_extended
This is a very new extension to ES that gives you dual source blending just like in desktop OpenGL. This works with the piglits that I've written, which are in the process of being cleaned up so they can be pushed, and this also works great with the Dolphin emulator. --- src/glsl/ast_to_hir.cpp | 16 + src/glsl/builtin_variables.cpp | 62 + src/glsl/glsl_parser.yy | 5 +++ src/glsl/glsl_parser_extras.cpp | 3 ++ src/glsl/glsl_parser_extras.h | 5 +++ src/mapi/glapi/gen/EXT_gpu_shader4.xml | 3 +- src/mapi/glapi/gen/es_EXT.xml | 38 src/mesa/main/blend.c | 4 +-- src/mesa/main/extensions.c | 1 + src/mesa/main/get_hash_params.py| 4 ++- src/mesa/main/tests/dispatch_sanity.cpp | 8 + 11 files changed, 145 insertions(+), 4 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0306530..9ac7d80 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -6973,6 +6973,8 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, { bool gl_FragColor_assigned = false; bool gl_FragData_assigned = false; + bool gl_FragSecondaryColor_assigned = false; + bool gl_FragSecondaryData_assigned = false; bool user_defined_fs_output_assigned = false; ir_variable *user_defined_fs_output = NULL; @@ -6990,6 +6992,10 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, gl_FragColor_assigned = true; else if (strcmp(var->name, "gl_FragData") == 0) gl_FragData_assigned = true; + else if (strcmp(var->name, "gl_SecondaryFragColorEXT") == 0) + gl_FragSecondaryColor_assigned = true; + else if (strcmp(var->name, "gl_SecondaryFragDataEXT") == 0) + gl_FragSecondaryData_assigned = true; else if (!is_gl_identifier(var->name)) { if (state->stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out) { @@ -7021,11 +7027,21 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, _mesa_glsl_error(, state, "fragment shader writes to both " "`gl_FragColor' and `%s'", user_defined_fs_output->name); + } else if (gl_FragSecondaryColor_assigned && gl_FragSecondaryData_assigned) { + _mesa_glsl_error(, state, "fragment shader writes to both " + "`gl_FragSecondaryColorEXT' and" + " `gl_FragSecondaryDataEXT'"); } else if (gl_FragData_assigned && user_defined_fs_output_assigned) { _mesa_glsl_error(, state, "fragment shader writes to both " "`gl_FragData' and `%s'", user_defined_fs_output->name); } + + if ((gl_FragSecondaryColor_assigned || gl_FragSecondaryData_assigned) && + !state->EXT_blend_func_extended_enable) { + _mesa_glsl_error(, state, + "Dual source blending requires EXT_blend_func_extended"); + } } diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index c30fb92..ee08993 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -376,6 +376,11 @@ private: return add_variable(name, type, ir_var_shader_out, slot); } + ir_variable *add_index_output(int slot, int index, const glsl_type *type, const char *name) + { + return add_index_variable(name, type, ir_var_shader_out, slot, index); + } + ir_variable *add_system_value(int slot, const glsl_type *type, const char *name) { @@ -384,6 +389,8 @@ private: ir_variable *add_variable(const char *name, const glsl_type *type, enum ir_variable_mode mode, int slot); + ir_variable *add_index_variable(const char *name, const glsl_type *type, + enum ir_variable_mode mode, int slot, int index); ir_variable *add_uniform(const glsl_type *type, const char *name); ir_variable *add_const(const char *name, int value); ir_variable *add_const_ivec3(const char *name, int x, int y, int z); @@ -429,6 +436,46 @@ builtin_variable_generator::builtin_variable_generator( { } +ir_variable * +builtin_variable_generator::add_index_variable(const char *name, + const glsl_type *type, + enum ir_variable_mode mode, int slot, int index) +{ + ir_variable *var = new(symtab) ir_variable(type, name, mode); + var->data.how_declared = ir_var_declared_implicitly; + + switch (var->data.mode) { + case ir_var_auto: + case ir_var_shader_in: + case ir_var_uniform: + case ir_var_system_value: + var->data.read_only = true; + break; + case ir_var_shader_out: + case ir_var_shader_storage: + break; + default: + /* The only variables that are added
[Mesa-dev] [PATCH 02/13] fixup! i965: Combine register file field.
From: Emil VelikovSigned-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index e2f8a0a..6975a19 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -112,6 +112,7 @@ dst_reg::dst_reg(enum brw_reg_file file, int nr, const glsl_type *type, { init(); + this->file = file; this->nr = nr; this->type = brw_type_for_base_type(type); this->writemask = writemask; -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/13] i965: do not use memset in *_reg() ctors
Hi all, This is a series that builds on top of Matts "i965: Refactor register classes". As Matt's branch has some additional changes, the first two patches are fixups that could be merged directly. The follow-up four patches removes/reworks some of the constructors, in order to avoid reworking extra ctors. The rest rework the classes to use proper constructors rather than memset-ing and part reverts a 'hack' that Matt had to due to BAD_FILE != 0. Note that due to the inlined src/dst_reg the text size has increased a bit, (~6K iirc) although if people prefer we can make them non-inline. The lot can be found in branch bye-bye-memset over at https://github.com/evelikov/Mesa Cheers, Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/13] i965/fs: remove unneeded fs_reg(...) ctor
From: Emil VelikovBy using a default value for brw_reg_type the compiler will reuse the existing constructor. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_fs.cpp | 9 - src/mesa/drivers/dri/i965/brw_ir_fs.h | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index b812ef5..46941ae 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -892,15 +892,6 @@ fs_visitor::vgrf(const glsl_type *const type) brw_type_for_base_type(type)); } -fs_reg::fs_reg(enum brw_reg_file file, int nr) -{ - init(); - this->file = file; - this->nr = nr; - this->type = BRW_REGISTER_TYPE_F; - this->stride = (file == UNIFORM ? 0 : 1); -} - fs_reg::fs_reg(enum brw_reg_file file, int nr, enum brw_reg_type type) { init(); diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h index ec1654c..2e14917 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_fs.h +++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h @@ -37,8 +37,8 @@ public: fs_reg(); fs_reg(struct brw_reg reg); - fs_reg(enum brw_reg_file file, int nr); - fs_reg(enum brw_reg_file file, int nr, enum brw_reg_type type); + fs_reg(enum brw_reg_file file, int nr, + enum brw_reg_type type = BRW_REGISTER_TYPE_F); bool equals(const fs_reg ) const; bool is_contiguous() const; -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/13] fixup! i965: Combine register file field.
From: Emil VelikovRemove unneeded this->file assignment in dst_reg(const src_reg ) ctor Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 1f0a11e..e2f8a0a 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -138,7 +138,6 @@ dst_reg::dst_reg(struct brw_reg reg) : dst_reg::dst_reg(const src_reg ) : backend_reg(static_cast(reg)) { - this->file = reg.file; this->reg_offset = reg.reg_offset; this->writemask = brw_mask_for_swizzle(reg.swizzle); this->reladdr = reg.reladdr; -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/13] i965/vec4: kill off the final possible dst_reg ctor
From: Emil VelikovBy providing default values for type and writemask, the compiler will 'create' the constructor for us. The values chosen are the exact same ones, used in the default ctor - dst_reg(), as such the compiler should be smart enough to optimise the duplicated (identical) assignment. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_ir_vec4.h | 7 --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 8 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h index 9b5b10c..8d3efea 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h @@ -103,12 +103,13 @@ public: void init(); dst_reg(); - dst_reg(enum brw_reg_file file, int nr); dst_reg(enum brw_reg_file file, int nr, const glsl_type *type, unsigned writemask); - dst_reg(enum brw_reg_file file, int nr, brw_reg_type type, - unsigned writemask); + dst_reg(enum brw_reg_file file, int nr, + brw_reg_type type = BRW_REGISTER_TYPE_UD, + unsigned writemask = WRITEMASK_XYZW); dst_reg(struct brw_reg reg); + dst_reg(class vec4_visitor *v, const struct glsl_type *type); explicit dst_reg(const src_reg ); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 6975a19..39d4a68 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -99,14 +99,6 @@ dst_reg::dst_reg() init(); } -dst_reg::dst_reg(enum brw_reg_file file, int nr) -{ - init(); - - this->file = file; - this->nr = nr; -} - dst_reg::dst_reg(enum brw_reg_file file, int nr, const glsl_type *type, unsigned writemask) { -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/13] i965: do not memcmp to check if brw_regs are equal
From: Emil VelikovAs of last commit one can easily the whole brw_reg as two unsigned values. Lets use that and avoid the nastylooking memcmp + casts. XXX: reladdr looks a bit strange. we tend to do dst_reg<>src_reg and in some cases this might cause someheadaches. should we zero it in the respective ctors ? Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_fs.cpp | 3 ++- src/mesa/drivers/dri/i965/brw_vec4.cpp | 10 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 46941ae..0ee6ffc 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -391,7 +391,8 @@ fs_reg::fs_reg(struct brw_reg reg) : bool fs_reg::equals(const fs_reg ) const { - return (memcmp((brw_reg *)this, (brw_reg *), sizeof(brw_reg)) == 0 && + return (v == r.v && + d == r.d && reg_offset == r.reg_offset && subreg_offset == r.subreg_offset && !reladdr && !r.reladdr && diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index e348f17..db662d3 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -128,7 +128,8 @@ dst_reg::dst_reg(const src_reg ) : bool dst_reg::equals(const dst_reg ) const { - return (memcmp((brw_reg *)this, (brw_reg *), sizeof(brw_reg)) == 0 && + return (v == r.v && + d == r.d && reg_offset == r.reg_offset && (reladdr == r.reladdr || (reladdr && r.reladdr && reladdr->equals(*r.reladdr; @@ -265,9 +266,10 @@ vec4_visitor::implied_mrf_writes(vec4_instruction *inst) bool src_reg::equals(const src_reg ) const { - return (memcmp((brw_reg *)this, (brw_reg *), sizeof(brw_reg)) == 0 && - reg_offset == r.reg_offset && - !reladdr && !r.reladdr); + return (v == r.v && + d == r.d && + reg_offset == r.reg_offset && + !reladdr && !r.reladdr); } bool -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/13] i965/fs: properly construct fs_reg
From: Emil VelikovRather than doing memset(), implicitly use the backend_reg ctor(s) which will initialise its variables. For the fs_reg ones, set them manually. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_fs.cpp | 18 +++--- src/mesa/drivers/dri/i965/brw_ir_fs.h | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index e54c48b..5973e15 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -359,18 +359,12 @@ fs_inst::has_side_effects() const return this->eot || backend_instruction::has_side_effects(); } -void -fs_reg::init() -{ - memset(this, 0, sizeof(*this)); - stride = 1; -} - /** Generic unset register constructor. */ fs_reg::fs_reg() { - init(); - this->file = BAD_FILE; + this->subreg_offset = 0; + this->reladdr = NULL; + this->stride = 1; } fs_reg::fs_reg(struct brw_reg reg) : @@ -895,11 +889,13 @@ fs_visitor::vgrf(const glsl_type *const type) fs_reg::fs_reg(enum brw_reg_file file, int nr, enum brw_reg_type type) { - init(); + this->subreg_offset = 0; + this->reladdr = NULL; + this->stride = (file == UNIFORM ? 0 : 1); + this->file = file; this->nr = nr; this->type = type; - this->stride = (file == UNIFORM ? 0 : 1); } /* For SIMD16, we need to follow from the uniform setup of SIMD8 dispatch. diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h index 2e14917..4deb108 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_fs.h +++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h @@ -33,10 +33,9 @@ class fs_reg : public backend_reg { public: DECLARE_RALLOC_CXX_OPERATORS(fs_reg) - void init(); - fs_reg(); fs_reg(struct brw_reg reg); + fs_reg(enum brw_reg_file file, int nr, enum brw_reg_type type = BRW_REGISTER_TYPE_F); -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/13] i965/vec4: one dst_reg() constructor less
From: Emil VelikovJust fold the brw_type_for_base_type() and use a delegated constructor. Note this is a c++11 feature and the compiler will warn us if it's set/defaults to an earlier version of the standard. XXX: Should we just toggle c++11 on ? We seem to be using some of its functionality already (anonymous unions) and we could even simplify gallium/nouveau a bit. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_ir_vec4.h | 8 ++-- src/mesa/drivers/dri/i965/brw_vec4.cpp | 11 --- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h index 8d3efea..b7a9004 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h @@ -103,11 +103,15 @@ public: void init(); dst_reg(); - dst_reg(enum brw_reg_file file, int nr, const glsl_type *type, - unsigned writemask); + dst_reg(enum brw_reg_file file, int nr, brw_reg_type type = BRW_REGISTER_TYPE_UD, unsigned writemask = WRITEMASK_XYZW); + + dst_reg(enum brw_reg_file file, int nr, const glsl_type *type, + unsigned writemask) : + dst_reg(file, nr, brw_type_for_base_type(type), writemask) {} + dst_reg(struct brw_reg reg); dst_reg(class vec4_visitor *v, const struct glsl_type *type); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 39d4a68..e348f17 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -99,17 +99,6 @@ dst_reg::dst_reg() init(); } -dst_reg::dst_reg(enum brw_reg_file file, int nr, const glsl_type *type, - unsigned writemask) -{ - init(); - - this->file = file; - this->nr = nr; - this->type = brw_type_for_base_type(type); - this->writemask = writemask; -} - dst_reg::dst_reg(enum brw_reg_file file, int nr, brw_reg_type type, unsigned writemask) { -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/13] i965/vec4: sort dst_reg ctors like the src_reg ones
From: Emil VelikovSigned-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_ir_vec4.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h index b70dca5..2c7293d 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h @@ -108,12 +108,12 @@ public: unsigned writemask) : dst_reg(file, nr, brw_type_for_base_type(type), writemask) {} + bool equals(const dst_reg ) const; + dst_reg(class vec4_visitor *v, const struct glsl_type *type); explicit dst_reg(const src_reg ); - bool equals(const dst_reg ) const; - src_reg *reladdr; }; -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 7/8] Add EXT_blend_func_extended functions to the dispatch_sanity test
This need to be done along with the patch which adds these to the xml On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: > --- > src/mesa/main/tests/dispatch_sanity.cpp | 8 > 1 file changed, 8 insertions(+) > > diff --git a/src/mesa/main/tests/dispatch_sanity.cpp > b/src/mesa/main/tests/dispatch_sanity.cpp > index abe0f43..97f81f9 100644 > --- a/src/mesa/main/tests/dispatch_sanity.cpp > +++ b/src/mesa/main/tests/dispatch_sanity.cpp > @@ -2421,6 +2421,11 @@ const struct function gles3_functions_possible[] = { > { "glProgramUniform4uiEXT", 30, -1 }, > { "glProgramUniform4uivEXT", 30, -1 }, > > + /* GL_EXT_blend_func_extended */ > + { "glBindFragDataLocationIndexedEXT", 30, -1 }, > + { "glGetFragDataIndexEXT", 30, -1 }, > + { "glBindFragDataLocationEXT", 30, -1 }, > + > { NULL, 0, -1 } > }; > > @@ -2509,5 +2514,8 @@ const struct function gles31_functions_possible[] = { > /* GL_EXT_buffer_storage */ > { "glBufferStorageEXT", 31, -1 }, > > + /* GL_EXT_blend_func_extended */ > + { "glGetProgramResourceLocationIndexEXT", 31, -1 }, > + > { NULL, 0, -1 }, > }; > -- > 2.5.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/8] Implement support for EXT_blend_func_extended
You appear to be missing a patch to add this to glcpp: A new preprocessor #define is added to the OpenGL ES Shading Language: #define GL_EXT_blend_func_extended 1 On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: > This implements support for a very new extension to ES, which allows you > to do dual source blending just like in desktop OpenGL. > This works with the piglits that I am writing that just need to be cleaned > before they are pushed, and it also works fantastically with the > Dolphin emulator (Only known application that uses this extension) > > Ryan Houdek (8): > Add EXT_blend_func_extended XML definitions > Add required variables to _mesa_glsl_parse_state for > EXT_blend_func_extended > Add support for the new builtins that EXT_blend_func_extended > provides. > Add a parse check to check for the index layout qualifier > Enable usage of blend_func_extended blend factors > Allow MAX_DUAL_SOURCE_DRAW_BUFFERS to be available to ES > Add EXT_blend_func_extended functions to the dispatch_sanity test > Enable EXT_blend_func_extended if the driver supports the ARB version > > src/glsl/ast_to_hir.cpp | 16 + > src/glsl/builtin_variables.cpp | 62 > + > src/glsl/glsl_parser.yy | 5 +++ > src/glsl/glsl_parser_extras.cpp | 3 ++ > src/glsl/glsl_parser_extras.h | 5 +++ > src/mapi/glapi/gen/EXT_gpu_shader4.xml | 3 +- > src/mapi/glapi/gen/es_EXT.xml | 38 > src/mesa/main/blend.c | 4 +-- > src/mesa/main/extensions.c | 1 + > src/mesa/main/get_hash_params.py| 4 ++- > src/mesa/main/tests/dispatch_sanity.cpp | 8 + > 11 files changed, 145 insertions(+), 4 deletions(-) > > -- > 2.5.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/8] Enable usage of blend_func_extended blend factors
On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: > --- > src/mesa/main/blend.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c > index 20aa498..8da81ee 100644 > --- a/src/mesa/main/blend.c > +++ b/src/mesa/main/blend.c > @@ -67,7 +67,7 @@ legal_src_factor(const struct gl_context *ctx, GLenum > factor) > case GL_SRC1_ALPHA: > case GL_ONE_MINUS_SRC1_COLOR: > case GL_ONE_MINUS_SRC1_ALPHA: > - return _mesa_is_desktop_gl(ctx) > + return (_mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2) indent also, at your option, ctx->API != API_OPENGLES. Either way is fine by me. > && ctx->Extensions.ARB_blend_func_extended; > default: >return GL_FALSE; > @@ -107,7 +107,7 @@ legal_dst_factor(const struct gl_context *ctx, GLenum > factor) > case GL_SRC1_ALPHA: > case GL_ONE_MINUS_SRC1_COLOR: > case GL_ONE_MINUS_SRC1_ALPHA: > - return _mesa_is_desktop_gl(ctx) > + return (_mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2) > && ctx->Extensions.ARB_blend_func_extended; > default: >return GL_FALSE; > -- > 2.5.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/24] i965: Remove fixed_hw_reg field from backend_reg.
On 3 November 2015 at 16:04, Emil Velikovwrote: >> @@ -1596,8 +1586,7 @@ vec4_visitor::lower_attributes_to_hw_regs(const int >> *attribute_map, >> reg.type = inst->dst.type; >> reg.writemask = inst->dst.writemask; >> >> -inst->dst.file = HW_REG; >> -inst->dst.fixed_hw_reg = reg; >> + inst->dst = reg; > Same concern, as in fs_visitor::assign_curb_setup. Past the struct > brw_reg, dst_reg will be uninitialized. Or is the > dst_reg::dst_reg(struct brw_reg reg) ctor going to kick in here ? > For posterity: Yes. dst_reg::dst_reg(struct brw_reg reg) kicks in, thus the remaining variables are correctly initialised. -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/4] st/va: add support for RGBX and BGRX in VPP
Hi Julien, On 5 November 2015 at 08:24, Julien Isorcewrote: > Before it was only possible to convert a NV12 surface to > RGBA or BGRA. This patch uses the same post processing > function, "handleVAProcPipelineParameterBufferType", but > add definitions for RGBX and BGRX. > > This patch also makes vlVaQuerySurfaceAttributes more generic. > > Signed-off-by: Julien Isorce > --- > src/gallium/auxiliary/vl/vl_video_buffer.c | 18 +++ > src/gallium/state_trackers/va/picture.c| 5 +++-- > src/gallium/state_trackers/va/surface.c| 36 > +- > src/gallium/state_trackers/va/va_private.h | 1 + > 4 files changed, 42 insertions(+), 18 deletions(-) > As the diffstat suggests - two different areas, thus this should be different patches. > @@ -314,7 +319,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, > VAConfigID config, > vlVaDriver *drv; > VASurfaceAttrib *attribs; > struct pipe_screen *pscreen; > - int i; > + int i, j; > + > + STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats) <= VL_VA_MAX_IMAGE_FORMATS); > Nice, thank you ! > --- a/src/gallium/state_trackers/va/va_private.h > +++ b/src/gallium/state_trackers/va/va_private.h > @@ -49,6 +49,7 @@ > #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) > > #define VL_VA_MAX_IMAGE_FORMATS 9 > +#define VL_VA_MAX_SURFACE_ATTRIBUTES 24 > Unused define ? Cheers, Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 13/13] i965/fs_visitor: do not explicitly set outputs[x].file
On 5 November 2015 at 16:18, Emil Velikovwrote: > From: Emil Velikov > > This commits partially reverts "i965: Initialize registers' file to > BAD_FILE." > > No longer needed as of commit "i965/fs: properly construct fs_reg" which > removes the memset(...0...), and correctly sets BAD_FILE. > > Signed-off-by: Emil Velikov > --- > src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > index 85afc36..bc9b313 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > @@ -1189,9 +1189,6 @@ fs_visitor::init() > memset(>payload, 0, sizeof(this->payload)); > memset(this->outputs, 0, sizeof(this->outputs)); This line should be removed as well. -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 1/3] glsl: Add new barrier functions for compute shaders
Jordan Justenwrites: > On 2015-11-05 06:07:02, Francisco Jerez wrote: >> Jordan Justen writes: >> >> > When these functions are called in GLSL code, we create an intrinsic >> > function call: >> > >> > * groupMemoryBarrier => __intrinsic_group_memory_barrier >> > * memoryBarrierAtomicCounter => __intrinsic_memory_barrier_atomic_counter >> > * memoryBarrierBuffer => __intrinsic_memory_barrier_buffer >> > * memoryBarrierImage => __intrinsic_memory_barrier_image >> > * memoryBarrierShared => __intrinsic_memory_barrier_shared >> > >> > v2: >> > * Consolidate with memoryBarrier function/intrinsic creation (curro) >> > >> > Signed-off-by: Jordan Justen >> > --- >> > src/glsl/builtin_functions.cpp | 58 >> > +++--- >> > 1 file changed, 49 insertions(+), 9 deletions(-) >> > >> > diff --git a/src/glsl/builtin_functions.cpp >> > b/src/glsl/builtin_functions.cpp >> > index 509a57b..21ae5ce 100644 >> > --- a/src/glsl/builtin_functions.cpp >> > +++ b/src/glsl/builtin_functions.cpp >> > @@ -459,9 +459,15 @@ fp64(const _mesa_glsl_parse_state *state) >> > } >> > >> > static bool >> > +compute_shader(const _mesa_glsl_parse_state *state) >> > +{ >> > + return state->stage == MESA_SHADER_COMPUTE; >> > +} >> > + >> > +static bool >> > barrier_supported(const _mesa_glsl_parse_state *state) >> > { >> > - return state->stage == MESA_SHADER_COMPUTE || >> > + return compute_shader(state) || >> >state->stage == MESA_SHADER_TESS_CTRL; >> > } >> > >> > @@ -785,7 +791,9 @@ private: >> > >> > ir_function_signature *_memory_barrier_intrinsic( >> >builtin_available_predicate avail); >> > - ir_function_signature *_memory_barrier( >> > + void add_memory_barrier_function( >> > + const char *function_name, >> > + const char *intrinsic_name, >> >builtin_available_predicate avail); >> > >> Do we need a separate add_*_function() method for these? The most >> consistent with the other builtin builder code would be to have a >> _memory_barrier() method to construct the ir_function_signature given >> the name of the intrinsic to call and an availability predicate, and >> then pass it to the usual add_function() method, kind of like you did in >> your v1. Admittedly image load/store/atomic built-ins use a separate >> add_image_function() for this because they need such a ridiculous amount >> of overloads -- But that's the exception rather than the rule. > > So, add the intrinsic name to lookup to _memory_barrier? > > Like this? > >add_function("memoryBarrierAtomicCounter", > _memory_barrier("__intrinsic_memory_barrier_atomic_counter", > compute_shader), > NULL); > Yeah, I think that's the idiom used for all other built-ins generated in this file, except image load/store/atomic. > I thought add_memory_barrier_function looked a little better, but > either is fine with me. > *Shrug*, I don't have a strong preference either, but in doubt would go for the most consistent approach rather than the most convenient. ;) > -Jordan > >> >> > ir_function_signature >> > *_shader_clock_intrinsic(builtin_available_predicate avail, >> > @@ -963,6 +971,21 @@ builtin_builder::create_intrinsics() >> > add_function("__intrinsic_memory_barrier", >> > _memory_barrier_intrinsic(shader_image_load_store), >> > NULL); >> > + add_function("__intrinsic_group_memory_barrier", >> > +_memory_barrier_intrinsic(compute_shader), >> > +NULL); >> > + add_function("__intrinsic_memory_barrier_atomic_counter", >> > +_memory_barrier_intrinsic(compute_shader), >> > +NULL); >> > + add_function("__intrinsic_memory_barrier_buffer", >> > +_memory_barrier_intrinsic(compute_shader), >> > +NULL); >> > + add_function("__intrinsic_memory_barrier_image", >> > +_memory_barrier_intrinsic(compute_shader), >> > +NULL); >> > + add_function("__intrinsic_memory_barrier_shared", >> > +_memory_barrier_intrinsic(compute_shader), >> > +NULL); >> > >> > add_function("__intrinsic_shader_clock", >> > _shader_clock_intrinsic(shader_clock, >> > @@ -2753,9 +2776,24 @@ builtin_builder::create_builtins() >> > >> > add_image_functions(true); >> > >> > - add_function("memoryBarrier", >> > -_memory_barrier(shader_image_load_store), >> > -NULL); >> > + add_memory_barrier_function("memoryBarrier", >> > + "__intrinsic_memory_barrier", >> > + shader_image_load_store); >> > + add_memory_barrier_function("groupMemoryBarrier", >> > + "__intrinsic_group_memory_barrier", >> > +
Re: [Mesa-dev] [PATCH 1/8] Add EXT_blend_func_extended XML definitions
subject: glapi: add ... On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: > --- > src/mapi/glapi/gen/EXT_gpu_shader4.xml | 3 ++- > src/mapi/glapi/gen/es_EXT.xml | 38 > ++ > 2 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/src/mapi/glapi/gen/EXT_gpu_shader4.xml > b/src/mapi/glapi/gen/EXT_gpu_shader4.xml > index b1f7eae..b4120b9 100644 > --- a/src/mapi/glapi/gen/EXT_gpu_shader4.xml > +++ b/src/mapi/glapi/gen/EXT_gpu_shader4.xml > @@ -232,7 +232,8 @@ > > > > - > + + es2="3.0"> > > > > diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml > index 9a777a2..e689b47 100644 > --- a/src/mapi/glapi/gen/es_EXT.xml > +++ b/src/mapi/glapi/gen/es_EXT.xml > @@ -914,4 +914,42 @@ > > > > + > + > +alias="BindFragDataLocationIndexed" indent > +es2="3.0"> > + > + > + > + > + > + > + +es2="3.0"> > + > + > + > + > + > + alias="GetProgramResourceLocationIndex" > + es2="3.1"> > + > + > + > + > + > + > + > + > + > + > + > + > + These duplicate existing enums right? I think this will confuse the table. I'd just as soon leave them out. We never map name -> id, only id -> name. I think :) [In piglit we do name -> id.] > + > + > + indent > + > + > + > > -- > 2.5.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/8] Add required variables to _mesa_glsl_parse_state for EXT_blend_func_extended
subject: glsl: ... On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: > This adds a state for the maximum dual source draw variables available > and the variable for determining if the extension has been enabled > in the program shaders. > --- > src/glsl/glsl_parser_extras.cpp | 3 +++ > src/glsl/glsl_parser_extras.h | 5 + > 2 files changed, 8 insertions(+) > > diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp > index 14cb9fc..31c0319 100644 > --- a/src/glsl/glsl_parser_extras.cpp > +++ b/src/glsl/glsl_parser_extras.cpp > @@ -102,6 +102,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct > gl_context *_ctx, > > this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; > > + this->Const.MaxDualSourceDrawBuffers = > ctx->Const.MaxDualSourceDrawBuffers; > + > /* 1.50 constants */ > this->Const.MaxVertexOutputComponents = > ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents; > this->Const.MaxGeometryInputComponents = > ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents; > @@ -643,6 +645,7 @@ static const _mesa_glsl_extension > _mesa_glsl_supported_extensions[] = { > EXT(AMD_shader_trinary_minmax, true, false, dummy_true), > EXT(AMD_vertex_shader_layer,true, false, > AMD_vertex_shader_layer), > EXT(AMD_vertex_shader_viewport_index, true, false, > AMD_vertex_shader_viewport_index), > + EXT(EXT_blend_func_extended,false, true, > ARB_blend_func_extended), > EXT(EXT_draw_buffers, false, true, dummy_true), > EXT(EXT_separate_shader_objects,false, true, dummy_true), > EXT(EXT_shader_integer_mix, true, true, > EXT_shader_integer_mix), > diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h > index b54c535..7dd9477 100644 > --- a/src/glsl/glsl_parser_extras.h > +++ b/src/glsl/glsl_parser_extras.h > @@ -375,6 +375,9 @@ struct _mesa_glsl_parse_state { >/* ARB_draw_buffers */ >unsigned MaxDrawBuffers; > > + /* ARB_blend_func_extended */ > + unsigned MaxDualSourceDrawBuffers; > + >/* 3.00 ES */ >int MinProgramTexelOffset; >int MaxProgramTexelOffset; > @@ -588,6 +591,8 @@ struct _mesa_glsl_parse_state { > bool AMD_vertex_shader_layer_warn; > bool AMD_vertex_shader_viewport_index_enable; > bool AMD_vertex_shader_viewport_index_warn; > + bool EXT_blend_func_extended_enable; > + bool EXT_blend_func_extended_warn; > bool EXT_draw_buffers_enable; > bool EXT_draw_buffers_warn; > bool EXT_separate_shader_objects_enable; > -- > 2.5.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 1/3] glsl: Add new barrier functions for compute shaders
On 2015-11-05 06:07:02, Francisco Jerez wrote: > Jordan Justenwrites: > > > When these functions are called in GLSL code, we create an intrinsic > > function call: > > > > * groupMemoryBarrier => __intrinsic_group_memory_barrier > > * memoryBarrierAtomicCounter => __intrinsic_memory_barrier_atomic_counter > > * memoryBarrierBuffer => __intrinsic_memory_barrier_buffer > > * memoryBarrierImage => __intrinsic_memory_barrier_image > > * memoryBarrierShared => __intrinsic_memory_barrier_shared > > > > v2: > > * Consolidate with memoryBarrier function/intrinsic creation (curro) > > > > Signed-off-by: Jordan Justen > > --- > > src/glsl/builtin_functions.cpp | 58 > > +++--- > > 1 file changed, 49 insertions(+), 9 deletions(-) > > > > diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp > > index 509a57b..21ae5ce 100644 > > --- a/src/glsl/builtin_functions.cpp > > +++ b/src/glsl/builtin_functions.cpp > > @@ -459,9 +459,15 @@ fp64(const _mesa_glsl_parse_state *state) > > } > > > > static bool > > +compute_shader(const _mesa_glsl_parse_state *state) > > +{ > > + return state->stage == MESA_SHADER_COMPUTE; > > +} > > + > > +static bool > > barrier_supported(const _mesa_glsl_parse_state *state) > > { > > - return state->stage == MESA_SHADER_COMPUTE || > > + return compute_shader(state) || > >state->stage == MESA_SHADER_TESS_CTRL; > > } > > > > @@ -785,7 +791,9 @@ private: > > > > ir_function_signature *_memory_barrier_intrinsic( > >builtin_available_predicate avail); > > - ir_function_signature *_memory_barrier( > > + void add_memory_barrier_function( > > + const char *function_name, > > + const char *intrinsic_name, > >builtin_available_predicate avail); > > > Do we need a separate add_*_function() method for these? The most > consistent with the other builtin builder code would be to have a > _memory_barrier() method to construct the ir_function_signature given > the name of the intrinsic to call and an availability predicate, and > then pass it to the usual add_function() method, kind of like you did in > your v1. Admittedly image load/store/atomic built-ins use a separate > add_image_function() for this because they need such a ridiculous amount > of overloads -- But that's the exception rather than the rule. So, add the intrinsic name to lookup to _memory_barrier? Like this? add_function("memoryBarrierAtomicCounter", _memory_barrier("__intrinsic_memory_barrier_atomic_counter", compute_shader), NULL); I thought add_memory_barrier_function looked a little better, but either is fine with me. -Jordan > > > ir_function_signature > > *_shader_clock_intrinsic(builtin_available_predicate avail, > > @@ -963,6 +971,21 @@ builtin_builder::create_intrinsics() > > add_function("__intrinsic_memory_barrier", > > _memory_barrier_intrinsic(shader_image_load_store), > > NULL); > > + add_function("__intrinsic_group_memory_barrier", > > +_memory_barrier_intrinsic(compute_shader), > > +NULL); > > + add_function("__intrinsic_memory_barrier_atomic_counter", > > +_memory_barrier_intrinsic(compute_shader), > > +NULL); > > + add_function("__intrinsic_memory_barrier_buffer", > > +_memory_barrier_intrinsic(compute_shader), > > +NULL); > > + add_function("__intrinsic_memory_barrier_image", > > +_memory_barrier_intrinsic(compute_shader), > > +NULL); > > + add_function("__intrinsic_memory_barrier_shared", > > +_memory_barrier_intrinsic(compute_shader), > > +NULL); > > > > add_function("__intrinsic_shader_clock", > > _shader_clock_intrinsic(shader_clock, > > @@ -2753,9 +2776,24 @@ builtin_builder::create_builtins() > > > > add_image_functions(true); > > > > - add_function("memoryBarrier", > > -_memory_barrier(shader_image_load_store), > > -NULL); > > + add_memory_barrier_function("memoryBarrier", > > + "__intrinsic_memory_barrier", > > + shader_image_load_store); > > + add_memory_barrier_function("groupMemoryBarrier", > > + "__intrinsic_group_memory_barrier", > > + compute_shader); > > + add_memory_barrier_function("memoryBarrierAtomicCounter", > > + "__intrinsic_memory_barrier_atomic_counter", > > + compute_shader); > > + add_memory_barrier_function("memoryBarrierBuffer", > > + "__intrinsic_memory_barrier_buffer", > > + compute_shader); > > +
[Mesa-dev] [PATCH 3/8] Add support for the new builtins that EXT_blend_func_extended provides.
gl_MaxDualSourceDrawBuffersEXT - Maximum DS draw buffers supported Only for ESSL 1.0 it provides two builtins since you can't have user-defined color output variables gl_SecondaryFragColorEXT and gl_SecondaryFragDataEXT[MaxDSDrawBuffers] --- src/glsl/ast_to_hir.cpp| 16 +++ src/glsl/builtin_variables.cpp | 62 ++ 2 files changed, 78 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0306530..9ac7d80 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -6973,6 +6973,8 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, { bool gl_FragColor_assigned = false; bool gl_FragData_assigned = false; + bool gl_FragSecondaryColor_assigned = false; + bool gl_FragSecondaryData_assigned = false; bool user_defined_fs_output_assigned = false; ir_variable *user_defined_fs_output = NULL; @@ -6990,6 +6992,10 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, gl_FragColor_assigned = true; else if (strcmp(var->name, "gl_FragData") == 0) gl_FragData_assigned = true; + else if (strcmp(var->name, "gl_SecondaryFragColorEXT") == 0) + gl_FragSecondaryColor_assigned = true; + else if (strcmp(var->name, "gl_SecondaryFragDataEXT") == 0) + gl_FragSecondaryData_assigned = true; else if (!is_gl_identifier(var->name)) { if (state->stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out) { @@ -7021,11 +7027,21 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, _mesa_glsl_error(, state, "fragment shader writes to both " "`gl_FragColor' and `%s'", user_defined_fs_output->name); + } else if (gl_FragSecondaryColor_assigned && gl_FragSecondaryData_assigned) { + _mesa_glsl_error(, state, "fragment shader writes to both " + "`gl_FragSecondaryColorEXT' and" + " `gl_FragSecondaryDataEXT'"); } else if (gl_FragData_assigned && user_defined_fs_output_assigned) { _mesa_glsl_error(, state, "fragment shader writes to both " "`gl_FragData' and `%s'", user_defined_fs_output->name); } + + if ((gl_FragSecondaryColor_assigned || gl_FragSecondaryData_assigned) && + !state->EXT_blend_func_extended_enable) { + _mesa_glsl_error(, state, + "Dual source blending requires EXT_blend_func_extended"); + } } diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index c30fb92..45c8dfb 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -376,6 +376,11 @@ private: return add_variable(name, type, ir_var_shader_out, slot); } + ir_variable *add_index_output(int slot, int index, const glsl_type *type, const char *name) + { + return add_index_variable(name, type, ir_var_shader_out, slot, index); + } + ir_variable *add_system_value(int slot, const glsl_type *type, const char *name) { @@ -384,6 +389,8 @@ private: ir_variable *add_variable(const char *name, const glsl_type *type, enum ir_variable_mode mode, int slot); + ir_variable *add_index_variable(const char *name, const glsl_type *type, + enum ir_variable_mode mode, int slot, int index); ir_variable *add_uniform(const glsl_type *type, const char *name); ir_variable *add_const(const char *name, int value); ir_variable *add_const_ivec3(const char *name, int x, int y, int z); @@ -429,6 +436,46 @@ builtin_variable_generator::builtin_variable_generator( { } +ir_variable * +builtin_variable_generator::add_index_variable(const char *name, + const glsl_type *type, + enum ir_variable_mode mode, int slot, int index) +{ + ir_variable *var = new(symtab) ir_variable(type, name, mode); + var->data.how_declared = ir_var_declared_implicitly; + + switch (var->data.mode) { + case ir_var_auto: + case ir_var_shader_in: + case ir_var_uniform: + case ir_var_system_value: + var->data.read_only = true; + break; + case ir_var_shader_out: + case ir_var_shader_storage: + break; + default: + /* The only variables that are added using this function should be + * uniforms, shader storage, shader inputs, and shader outputs, constants + * (which use ir_var_auto), and system values. + */ + assert(0); + break; + } + + var->data.location = slot; + var->data.explicit_location = (slot >= 0); + var->data.explicit_index = 1; + var->data.index = index; + + /* Once the variable is created an initialized, add it to the symbol table +* and add the declaration to the IR stream. +*/ +
[Mesa-dev] [PATCH 2/8] Add required variables to _mesa_glsl_parse_state for EXT_blend_func_extended
This adds a state for the maximum dual source draw variables available and the variable for determining if the extension has been enabled in the program shaders. --- src/glsl/glsl_parser_extras.cpp | 3 +++ src/glsl/glsl_parser_extras.h | 5 + 2 files changed, 8 insertions(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 14cb9fc..31c0319 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -102,6 +102,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + this->Const.MaxDualSourceDrawBuffers = ctx->Const.MaxDualSourceDrawBuffers; + /* 1.50 constants */ this->Const.MaxVertexOutputComponents = ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents; this->Const.MaxGeometryInputComponents = ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents; @@ -643,6 +645,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(AMD_shader_trinary_minmax, true, false, dummy_true), EXT(AMD_vertex_shader_layer,true, false, AMD_vertex_shader_layer), EXT(AMD_vertex_shader_viewport_index, true, false, AMD_vertex_shader_viewport_index), + EXT(EXT_blend_func_extended,false, true, ARB_blend_func_extended), EXT(EXT_draw_buffers, false, true, dummy_true), EXT(EXT_separate_shader_objects,false, true, dummy_true), EXT(EXT_shader_integer_mix, true, true, EXT_shader_integer_mix), diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index b54c535..7dd9477 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -375,6 +375,9 @@ struct _mesa_glsl_parse_state { /* ARB_draw_buffers */ unsigned MaxDrawBuffers; + /* ARB_blend_func_extended */ + unsigned MaxDualSourceDrawBuffers; + /* 3.00 ES */ int MinProgramTexelOffset; int MaxProgramTexelOffset; @@ -588,6 +591,8 @@ struct _mesa_glsl_parse_state { bool AMD_vertex_shader_layer_warn; bool AMD_vertex_shader_viewport_index_enable; bool AMD_vertex_shader_viewport_index_warn; + bool EXT_blend_func_extended_enable; + bool EXT_blend_func_extended_warn; bool EXT_draw_buffers_enable; bool EXT_draw_buffers_warn; bool EXT_separate_shader_objects_enable; -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/8] Enable usage of blend_func_extended blend factors
--- src/mesa/main/blend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 20aa498..8da81ee 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -67,7 +67,7 @@ legal_src_factor(const struct gl_context *ctx, GLenum factor) case GL_SRC1_ALPHA: case GL_ONE_MINUS_SRC1_COLOR: case GL_ONE_MINUS_SRC1_ALPHA: - return _mesa_is_desktop_gl(ctx) + return (_mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2) && ctx->Extensions.ARB_blend_func_extended; default: return GL_FALSE; @@ -107,7 +107,7 @@ legal_dst_factor(const struct gl_context *ctx, GLenum factor) case GL_SRC1_ALPHA: case GL_ONE_MINUS_SRC1_COLOR: case GL_ONE_MINUS_SRC1_ALPHA: - return _mesa_is_desktop_gl(ctx) + return (_mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2) && ctx->Extensions.ARB_blend_func_extended; default: return GL_FALSE; -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/8] Add EXT_blend_func_extended XML definitions
--- src/mapi/glapi/gen/EXT_gpu_shader4.xml | 3 ++- src/mapi/glapi/gen/es_EXT.xml | 38 ++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/mapi/glapi/gen/EXT_gpu_shader4.xml b/src/mapi/glapi/gen/EXT_gpu_shader4.xml index b1f7eae..b4120b9 100644 --- a/src/mapi/glapi/gen/EXT_gpu_shader4.xml +++ b/src/mapi/glapi/gen/EXT_gpu_shader4.xml @@ -232,7 +232,8 @@ - + diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml index 9a777a2..e689b47 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -914,4 +914,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/8] Implement support for EXT_blend_func_extended
This implements support for a very new extension to ES, which allows you to do dual source blending just like in desktop OpenGL. This works with the piglits that I am writing that just need to be cleaned before they are pushed, and it also works fantastically with the Dolphin emulator (Only known application that uses this extension) Ryan Houdek (8): Add EXT_blend_func_extended XML definitions Add required variables to _mesa_glsl_parse_state for EXT_blend_func_extended Add support for the new builtins that EXT_blend_func_extended provides. Add a parse check to check for the index layout qualifier Enable usage of blend_func_extended blend factors Allow MAX_DUAL_SOURCE_DRAW_BUFFERS to be available to ES Add EXT_blend_func_extended functions to the dispatch_sanity test Enable EXT_blend_func_extended if the driver supports the ARB version src/glsl/ast_to_hir.cpp | 16 + src/glsl/builtin_variables.cpp | 62 + src/glsl/glsl_parser.yy | 5 +++ src/glsl/glsl_parser_extras.cpp | 3 ++ src/glsl/glsl_parser_extras.h | 5 +++ src/mapi/glapi/gen/EXT_gpu_shader4.xml | 3 +- src/mapi/glapi/gen/es_EXT.xml | 38 src/mesa/main/blend.c | 4 +-- src/mesa/main/extensions.c | 1 + src/mesa/main/get_hash_params.py| 4 ++- src/mesa/main/tests/dispatch_sanity.cpp | 8 + 11 files changed, 145 insertions(+), 4 deletions(-) -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/8] Add EXT_blend_func_extended functions to the dispatch_sanity test
--- src/mesa/main/tests/dispatch_sanity.cpp | 8 1 file changed, 8 insertions(+) diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index abe0f43..97f81f9 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -2421,6 +2421,11 @@ const struct function gles3_functions_possible[] = { { "glProgramUniform4uiEXT", 30, -1 }, { "glProgramUniform4uivEXT", 30, -1 }, + /* GL_EXT_blend_func_extended */ + { "glBindFragDataLocationIndexedEXT", 30, -1 }, + { "glGetFragDataIndexEXT", 30, -1 }, + { "glBindFragDataLocationEXT", 30, -1 }, + { NULL, 0, -1 } }; @@ -2509,5 +2514,8 @@ const struct function gles31_functions_possible[] = { /* GL_EXT_buffer_storage */ { "glBufferStorageEXT", 31, -1 }, + /* GL_EXT_blend_func_extended */ + { "glGetProgramResourceLocationIndexEXT", 31, -1 }, + { NULL, 0, -1 }, }; -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 8/8] Enable EXT_blend_func_extended if the driver supports the ARB version
--- src/mesa/main/extensions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index bdc6817..f1692ba 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -221,6 +221,7 @@ static const struct extension extension_table[] = { { "GL_EXT_bgra",o(dummy_true), GLL,1995 }, { "GL_EXT_blend_color", o(EXT_blend_color), GLL,1995 }, { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 }, + { "GL_EXT_blend_func_extended", o(ARB_blend_func_extended), ES2, 2015 }, { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GLL,1999 }, { "GL_EXT_buffer_storage", o(ARB_buffer_storage), ES31, 2015 }, { "GL_EXT_discard_framebuffer", o(dummy_true), ES1 | ES2, 2009 }, -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/8] Allow MAX_DUAL_SOURCE_DRAW_BUFFERS to be available to ES
--- src/mesa/main/get_hash_params.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index fbc7b8f..9b22b91 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -330,6 +330,9 @@ descriptor=[ # GL_KHR_context_flush_control [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM(Const.ContextReleaseBehavior), NO_EXTRA" ], + +# blend_func_extended + [ "MAX_DUAL_SOURCE_DRAW_BUFFERS", "CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended" ], ]}, # GLES3 is not a typo. @@ -801,7 +804,6 @@ descriptor=[ # GL_ARB_robustness [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA" ], - [ "MAX_DUAL_SOURCE_DRAW_BUFFERS", "CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended" ], # GL_ARB_uniform_buffer_object [ "MAX_GEOMETRY_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks), extra_ARB_uniform_buffer_object_and_geometry_shader" ], -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/8] Add a parse check to check for the index layout qualifier
This can only be used if EXT_blend_func_extended is enabled --- src/glsl/glsl_parser.yy | 5 + 1 file changed, 5 insertions(+) diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 4636435..40e60e5 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -1463,6 +1463,11 @@ layout_qualifier_id: } if (match_layout_qualifier("index", $1, state) == 0) { + if (state->es_shader && !state->EXT_blend_func_extended_enable) { +_mesa_glsl_error(& @3, state, "index layout qualifier requires EXT_blend_func_extended"); +YYERROR; + } + $$.flags.q.explicit_index = 1; if ($3 >= 0) { -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 8/8] Enable EXT_blend_func_extended if the driver supports the ARB version
Add a note to release notes as well? Please fix up the subjects throughout the series to conform to other patches going to those areas. Generally glsl: or mesa: or glapi: depending on the area (for the bits you're touching). On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: > --- > src/mesa/main/extensions.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > index bdc6817..f1692ba 100644 > --- a/src/mesa/main/extensions.c > +++ b/src/mesa/main/extensions.c > @@ -221,6 +221,7 @@ static const struct extension extension_table[] = { > { "GL_EXT_bgra",o(dummy_true), > GLL,1995 }, > { "GL_EXT_blend_color", o(EXT_blend_color), > GLL,1995 }, > { "GL_EXT_blend_equation_separate", > o(EXT_blend_equation_separate), GL, 2003 }, > + { "GL_EXT_blend_func_extended", > o(ARB_blend_func_extended), ES2, 2015 }, > { "GL_EXT_blend_func_separate", > o(EXT_blend_func_separate), GLL,1999 }, > { "GL_EXT_buffer_storage", o(ARB_buffer_storage), > ES31, 2015 }, > { "GL_EXT_discard_framebuffer", o(dummy_true), > ES1 | ES2, 2009 }, > -- > 2.5.0 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/13] i965: make brw_reg imm attibs accessible as a value
From: Emil VelikovWill allow us an easy once-off get/set of the attribs. Thus we can drop all the memset/memcmp + magic casting. XXX: alternative name(s) are welcome Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_reg.h | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h index 209ccb5..c8f8f72 100644 --- a/src/mesa/drivers/dri/i965/brw_reg.h +++ b/src/mesa/drivers/dri/i965/brw_reg.h @@ -230,14 +230,19 @@ const char *brw_reg_type_letters(unsigned brw_reg_type); * or "structure of array" form: */ struct brw_reg { - enum brw_reg_type type:4; - enum brw_reg_file file:3; /* :2 hardware format */ - unsigned negate:1; /* source only */ - unsigned abs:1;/* source only */ - unsigned address_mode:1; /* relative addressing, hopefully! */ - unsigned pad0:1; - unsigned subnr:5; /* :1 in align16 */ - unsigned nr:16; + union { + struct { + enum brw_reg_type type:4; + enum brw_reg_file file:3; /* :2 hardware format */ + unsigned negate:1; /* source only */ + unsigned abs:1;/* source only */ + unsigned address_mode:1; /* relative addressing, hopefully! */ + unsigned pad0:1; + unsigned subnr:5; /* :1 in align16 */ + unsigned nr:16; + }; + unsigned v; + }; union { struct { -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/13] i965/vec4: rework the src_reg/dst_reg constructors
From: Emil VelikovAnalogous to the previous (fs) commit - drop the explicit memset and set the non-inherited variables (reladdr) manually. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_ir_vec4.h| 13 +++ src/mesa/drivers/dri/i965/brw_vec4.cpp | 48 -- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 10 +++--- 3 files changed, 14 insertions(+), 57 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h index e10c440..b70dca5 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h @@ -37,11 +37,9 @@ class src_reg : public backend_reg public: DECLARE_RALLOC_CXX_OPERATORS(src_reg) - void init(); - + src_reg() : reladdr(NULL) {} + src_reg(struct brw_reg reg) : backend_reg(reg), reladdr(NULL) {} src_reg(enum brw_reg_file file, int nr, const glsl_type *type); - src_reg(); - src_reg(struct brw_reg reg); bool equals(const src_reg ) const; @@ -99,9 +97,8 @@ class dst_reg : public backend_reg public: DECLARE_RALLOC_CXX_OPERATORS(dst_reg) - void init(); - - dst_reg(); + dst_reg() : reladdr(NULL) {} + dst_reg(struct brw_reg reg) : backend_reg(reg), reladdr(NULL) {} dst_reg(enum brw_reg_file file, int nr, brw_reg_type type = BRW_REGISTER_TYPE_UD, @@ -111,8 +108,6 @@ public: unsigned writemask) : dst_reg(file, nr, brw_type_for_base_type(type), writemask) {} - dst_reg(struct brw_reg reg); - dst_reg(class vec4_visitor *v, const struct glsl_type *type); explicit dst_reg(const src_reg ); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 66ea15e..618ac35 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -43,17 +43,9 @@ using namespace brw; namespace brw { -void -src_reg::init() -{ - memset(this, 0, sizeof(*this)); - - this->file = BAD_FILE; -} - src_reg::src_reg(enum brw_reg_file file, int nr, const glsl_type *type) { - init(); + this->reladdr = NULL; this->file = file; this->nr = nr; @@ -65,42 +57,19 @@ src_reg::src_reg(enum brw_reg_file file, int nr, const glsl_type *type) this->type = brw_type_for_base_type(type); } -/** Generic unset register constructor. */ -src_reg::src_reg() -{ - init(); -} - -src_reg::src_reg(struct brw_reg reg) : - backend_reg(reg) -{ - this->reladdr = NULL; -} - src_reg::src_reg(const dst_reg ) : backend_reg(static_cast(reg)) { this->reladdr = reg.reladdr; - this->swizzle = brw_swizzle_for_mask(reg.writemask); -} -void -dst_reg::init() -{ - memset(this, 0, sizeof(*this)); - this->file = BAD_FILE; - this->writemask = WRITEMASK_XYZW; -} - -dst_reg::dst_reg() -{ - init(); + this->reg_offset = reg.reg_offset; + this->swizzle = brw_swizzle_for_mask(reg.writemask); } dst_reg::dst_reg(enum brw_reg_file file, int nr, brw_reg_type type, unsigned writemask) { - init(); + this->reladdr = NULL; this->file = file; this->nr = nr; @@ -108,18 +77,13 @@ dst_reg::dst_reg(enum brw_reg_file file, int nr, brw_reg_type type, this->writemask = writemask; } -dst_reg::dst_reg(struct brw_reg reg) : - backend_reg(reg) -{ - this->reladdr = NULL; -} - dst_reg::dst_reg(const src_reg ) : backend_reg(static_cast(reg)) { + this->reladdr = reg.reladdr; + this->reg_offset = reg.reg_offset; this->writemask = brw_mask_for_swizzle(reg.swizzle); - this->reladdr = reg.reladdr; } bool diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index debe1ed..b42a350 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -631,34 +631,32 @@ type_size_vec4(const struct glsl_type *type) src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type, int size) { assert(size > 0); - init(); + this->reladdr = NULL; this->file = VGRF; this->nr = v->alloc.allocate(type_size_vec4(type) * size); + this->type = brw_type_for_base_type(type); if (type->is_array() || type->is_record()) { this->swizzle = BRW_SWIZZLE_NOOP; } else { this->swizzle = brw_swizzle_for_size(type->vector_elements); } - - this->type = brw_type_for_base_type(type); } dst_reg::dst_reg(class vec4_visitor *v, const struct glsl_type *type) { - init(); + this->reladdr = NULL; this->file = VGRF; this->nr = v->alloc.allocate(type_size_vec4(type)); + this->type = brw_type_for_base_type(type); if (type->is_array() || type->is_record()) { this->writemask = WRITEMASK_XYZW; } else { this->writemask = (1 << type->vector_elements) - 1; } - - this->type = brw_type_for_base_type(type); } vec4_instruction * -- 2.6.2
[Mesa-dev] [PATCH 06/13] i965/vec4: remove the explicitly sized vec4_visitor src_reg ctor
From: Emil VelikovJust default the size to 1, and let the compiler do its magic. XXX: Not 100% sure this is correct. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_ir_vec4.h| 3 +-- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 19 +++ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h index b7a9004..e10c440 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h @@ -45,8 +45,7 @@ public: bool equals(const src_reg ) const; - src_reg(class vec4_visitor *v, const struct glsl_type *type); - src_reg(class vec4_visitor *v, const struct glsl_type *type, int size); + src_reg(class vec4_visitor *v, const struct glsl_type *type, int size = 1); explicit src_reg(const dst_reg ); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 63455e8..debe1ed 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -628,12 +628,13 @@ type_size_vec4(const struct glsl_type *type) return 0; } -src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type) +src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type, int size) { + assert(size > 0); init(); this->file = VGRF; - this->nr = v->alloc.allocate(type_size_vec4(type)); + this->nr = v->alloc.allocate(type_size_vec4(type) * size); if (type->is_array() || type->is_record()) { this->swizzle = BRW_SWIZZLE_NOOP; @@ -644,20 +645,6 @@ src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type) this->type = brw_type_for_base_type(type); } -src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type, int size) -{ - assert(size > 0); - - init(); - - this->file = VGRF; - this->nr = v->alloc.allocate(type_size_vec4(type) * size); - - this->swizzle = BRW_SWIZZLE_NOOP; - - this->type = brw_type_for_base_type(type); -} - dst_reg::dst_reg(class vec4_visitor *v, const struct glsl_type *type) { init(); -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/13] i965/fs_visitor: do not explicitly set outputs[x].file
From: Emil VelikovThis commits partially reverts "i965: Initialize registers' file to BAD_FILE." No longer needed as of commit "i965/fs: properly construct fs_reg" which removes the memset(...0...), and correctly sets BAD_FILE. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 85afc36..bc9b313 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -1189,9 +1189,6 @@ fs_visitor::init() memset(>payload, 0, sizeof(this->payload)); memset(this->outputs, 0, sizeof(this->outputs)); memset(this->output_components, 0, sizeof(this->output_components)); - for (unsigned i = 0; i < ARRAY_SIZE(this->outputs); i++) { - this->outputs[i].file = BAD_FILE; - } this->source_depth_to_render_target = false; this->runtime_check_aads_emit = false; this->first_non_payload_grf = 0; -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/13] i965: initialise the backend_reg members in the ctor
From: Emil VelikovStep one towards having a normal constructors for the *_reg primitives, and removing a handful of somewhat ugly code. Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_fs.cpp | 2 +- src/mesa/drivers/dri/i965/brw_shader.h | 11 +-- src/mesa/drivers/dri/i965/brw_vec4.cpp | 3 --- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 0ee6ffc..e54c48b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -376,10 +376,10 @@ fs_reg::fs_reg() fs_reg::fs_reg(struct brw_reg reg) : backend_reg(reg) { - this->reg_offset = 0; this->subreg_offset = 0; this->reladdr = NULL; this->stride = 1; + if (this->file == IMM && (this->type != BRW_REGISTER_TYPE_V && this->type != BRW_REGISTER_TYPE_UV && diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index 31172a8..5908bf0 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -41,8 +41,15 @@ #ifdef __cplusplus struct backend_reg : public brw_reg { - backend_reg() {} - backend_reg(struct brw_reg reg) : brw_reg(reg) {} + backend_reg() { + v = 0; + d = 0; + file = BAD_FILE; + writemask = WRITEMASK_XYZW; + + reg_offset = 0; + } + backend_reg(struct brw_reg reg) : brw_reg(reg), reg_offset(0) {} bool is_zero() const; bool is_one() const; diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index db662d3..66ea15e 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -74,14 +74,12 @@ src_reg::src_reg() src_reg::src_reg(struct brw_reg reg) : backend_reg(reg) { - this->reg_offset = 0; this->reladdr = NULL; } src_reg::src_reg(const dst_reg ) : backend_reg(static_cast(reg)) { - this->reg_offset = reg.reg_offset; this->reladdr = reg.reladdr; this->swizzle = brw_swizzle_for_mask(reg.writemask); } @@ -113,7 +111,6 @@ dst_reg::dst_reg(enum brw_reg_file file, int nr, brw_reg_type type, dst_reg::dst_reg(struct brw_reg reg) : backend_reg(reg) { - this->reg_offset = 0; this->reladdr = NULL; } -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/8] Add support for the new builtins that EXT_blend_func_extended provides.
On Thu, Nov 5, 2015 at 12:16 PM, Ryan Houdekwrote: subject: glsl: ... > gl_MaxDualSourceDrawBuffersEXT - Maximum DS draw buffers supported > > Only for ESSL 1.0 it provides two builtins since you can't have user-defined > color output variables > gl_SecondaryFragColorEXT and gl_SecondaryFragDataEXT[MaxDSDrawBuffers] > --- > src/glsl/ast_to_hir.cpp| 16 +++ > src/glsl/builtin_variables.cpp | 62 > ++ > 2 files changed, 78 insertions(+) > > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp > index 0306530..9ac7d80 100644 > --- a/src/glsl/ast_to_hir.cpp > +++ b/src/glsl/ast_to_hir.cpp > @@ -6973,6 +6973,8 @@ detect_conflicting_assignments(struct > _mesa_glsl_parse_state *state, > { > bool gl_FragColor_assigned = false; > bool gl_FragData_assigned = false; > + bool gl_FragSecondaryColor_assigned = false; > + bool gl_FragSecondaryData_assigned = false; > bool user_defined_fs_output_assigned = false; > ir_variable *user_defined_fs_output = NULL; > > @@ -6990,6 +6992,10 @@ detect_conflicting_assignments(struct > _mesa_glsl_parse_state *state, > gl_FragColor_assigned = true; >else if (strcmp(var->name, "gl_FragData") == 0) > gl_FragData_assigned = true; > + else if (strcmp(var->name, "gl_SecondaryFragColorEXT") == 0) > + gl_FragSecondaryColor_assigned = true; > + else if (strcmp(var->name, "gl_SecondaryFragDataEXT") == 0) > + gl_FragSecondaryData_assigned = true; >else if (!is_gl_identifier(var->name)) { > if (state->stage == MESA_SHADER_FRAGMENT && > var->data.mode == ir_var_shader_out) { > @@ -7021,11 +7027,21 @@ detect_conflicting_assignments(struct > _mesa_glsl_parse_state *state, >_mesa_glsl_error(, state, "fragment shader writes to both " > "`gl_FragColor' and `%s'", > user_defined_fs_output->name); > + } else if (gl_FragSecondaryColor_assigned && > gl_FragSecondaryData_assigned) { > + _mesa_glsl_error(, state, "fragment shader writes to both " > + "`gl_FragSecondaryColorEXT' and" > + " `gl_FragSecondaryDataEXT'"); > } else if (gl_FragData_assigned && user_defined_fs_output_assigned) { >_mesa_glsl_error(, state, "fragment shader writes to both " > "`gl_FragData' and `%s'", > user_defined_fs_output->name); > } > + > + if ((gl_FragSecondaryColor_assigned || gl_FragSecondaryData_assigned) && > + !state->EXT_blend_func_extended_enable) { > + _mesa_glsl_error(, state, > + "Dual source blending requires > EXT_blend_func_extended"); > + } > } > > > diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp > index c30fb92..45c8dfb 100644 > --- a/src/glsl/builtin_variables.cpp > +++ b/src/glsl/builtin_variables.cpp > @@ -376,6 +376,11 @@ private: >return add_variable(name, type, ir_var_shader_out, slot); > } > > + ir_variable *add_index_output(int slot, int index, const glsl_type *type, > const char *name) > + { > + return add_index_variable(name, type, ir_var_shader_out, slot, index); > + } > + > ir_variable *add_system_value(int slot, const glsl_type *type, > const char *name) > { > @@ -384,6 +389,8 @@ private: > > ir_variable *add_variable(const char *name, const glsl_type *type, > enum ir_variable_mode mode, int slot); > + ir_variable *add_index_variable(const char *name, const glsl_type *type, > + enum ir_variable_mode mode, int slot, int > index); > ir_variable *add_uniform(const glsl_type *type, const char *name); > ir_variable *add_const(const char *name, int value); > ir_variable *add_const_ivec3(const char *name, int x, int y, int z); > @@ -429,6 +436,46 @@ builtin_variable_generator::builtin_variable_generator( > { > } > > +ir_variable * > +builtin_variable_generator::add_index_variable(const char *name, > + const glsl_type *type, > + enum ir_variable_mode mode, int > slot, int index) > +{ > + ir_variable *var = new(symtab) ir_variable(type, name, mode); > + var->data.how_declared = ir_var_declared_implicitly; > + > + switch (var->data.mode) { > + case ir_var_auto: > + case ir_var_shader_in: > + case ir_var_uniform: > + case ir_var_system_value: > + var->data.read_only = true; > + break; > + case ir_var_shader_out: > + case ir_var_shader_storage: > + break; > + default: > + /* The only variables that are added using this function should be > + * uniforms, shader storage, shader inputs, and shader outputs, > constants > + * (which use ir_var_auto), and system values. > + */ > + assert(0);
[Mesa-dev] [PATCH 1/4] st/va: fix build fails with pipe loader
There is no dev in drv, and dev should be from vl_screen here --- src/gallium/state_trackers/va/context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index ec9e048..25fa905 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -151,8 +151,9 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) #if GALLIUM_STATIC_TARGETS drv->vscreen->pscreen = dd_create_screen(drm_fd); #else - if (pipe_loader_drm_probe_fd(>dev, drm_fd)) - drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, PIPE_SEARCH_DIR); + if (pipe_loader_drm_probe_fd(>vscreen->dev, drm_fd)) + drv->vscreen->pscreen = + pipe_loader_create_screen(drv->vscreen->dev, PIPE_SEARCH_DIR); #endif if (!drv->vscreen->pscreen) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] main: Don't restrict several KHR_debug enum to desktop GL
Hi Boyan, On 4 November 2015 at 15:25, Boyan Dingwrote: > In preparation for supporting GL_KHR_debug in OpenGL ES > > Signed-off-by: Boyan Ding > --- > src/mesa/main/enable.c| 5 + > src/mesa/main/getstring.c | 5 + > 2 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c > index 42f6799..33000fd 100644 > --- a/src/mesa/main/enable.c > +++ b/src/mesa/main/enable.c > @@ -369,10 +369,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, > GLboolean state) > break; >case GL_DEBUG_OUTPUT: >case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: > - if (!_mesa_is_desktop_gl(ctx)) > -goto invalid_enum_error; > - else > -_mesa_set_debug_state_int(ctx, cap, state); > + _mesa_set_debug_state_int(ctx, cap, state); There is another similar hunk in _mesa_IsEnabled. With that the patch is Reviewed-by: Emil Velikov I will send a "append KHR to function names when in ES context" patch and with that we can enable the extension. Thanks for bringing this up ! Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] st/omx: add headless support
This will allow dec/enc/transcode without X Signed-off-by: Leo Liu--- src/gallium/state_trackers/omx/entrypoint.c | 39 + 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/gallium/state_trackers/omx/entrypoint.c b/src/gallium/state_trackers/omx/entrypoint.c index a765666..a6a1279 100644 --- a/src/gallium/state_trackers/omx/entrypoint.c +++ b/src/gallium/state_trackers/omx/entrypoint.c @@ -33,6 +33,7 @@ #include #include +#include #include @@ -47,6 +48,7 @@ pipe_static_mutex(omx_lock); static Display *omx_display = NULL; static struct vl_screen *omx_screen = NULL; static unsigned omx_usecount = 0; +static const char *omx_render_node = NULL; int omx_component_library_Setup(stLoaderComponentType **stComponents) { @@ -73,33 +75,50 @@ struct vl_screen *omx_get_screen(void) pipe_mutex_lock(omx_lock); if (!omx_display) { + omx_render_node = debug_get_option("OMX_DRM_RENDER_NODES", NULL); omx_display = XOpenDisplay(NULL); if (!omx_display) { - pipe_mutex_unlock(omx_lock); - return NULL; - } + if (!omx_render_node) +goto error; + } else + omx_render_node = NULL; } if (!omx_screen) { - omx_screen = vl_screen_create(omx_display, 0); - if (!omx_screen) { - pipe_mutex_unlock(omx_lock); - return NULL; - } + if (omx_render_node) { + int fd = open(omx_render_node, O_RDWR); + if (fd < 0) +goto error; + omx_screen = vl_drm_screen_create(fd); + } else + omx_screen = vl_screen_create(omx_display, 0); + + if (!omx_screen) + goto error; } ++omx_usecount; pipe_mutex_unlock(omx_lock); return omx_screen; + +error: + if (omx_display) + XCloseDisplay(omx_display); + pipe_mutex_unlock(omx_lock); + return NULL; } void omx_put_screen(void) { pipe_mutex_lock(omx_lock); if ((--omx_usecount) == 0) { - vl_screen_destroy(omx_screen); - XCloseDisplay(omx_display); + if (!omx_render_node) { + vl_screen_destroy(omx_screen); + if (omx_display) +XCloseDisplay(omx_display); + } else + vl_drm_screen_destroy(omx_screen); omx_screen = NULL; omx_display = NULL; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 3/3] i965/nir/fs: Implement new barrier functions for compute shaders
For these nir intrinsics, we emit the same code as nir_intrinsic_memory_barrier: * nir_intrinsic_memory_barrier_atomic_counter * nir_intrinsic_memory_barrier_buffer * nir_intrinsic_memory_barrier_image We treat these nir intrinsics as no-ops: * nir_intrinsic_group_memory_barrier * nir_intrinsic_memory_barrier_shared v3: * Add comment for no-op cases (curro) Signed-off-by: Jordan JustenCc: Francisco Jerez --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index b6f4c52..3b3bc67 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1697,6 +1697,9 @@ fs_visitor::nir_emit_intrinsic(const fs_builder , nir_intrinsic_instr *instr break; } + case nir_intrinsic_memory_barrier_atomic_counter: + case nir_intrinsic_memory_barrier_buffer: + case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier: { const fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_UD, 16 / dispatch_width); bld.emit(SHADER_OPCODE_MEMORY_FENCE, tmp) @@ -1704,6 +1707,14 @@ fs_visitor::nir_emit_intrinsic(const fs_builder , nir_intrinsic_instr *instr break; } + case nir_intrinsic_group_memory_barrier: + case nir_intrinsic_memory_barrier_shared: + /* We treat these single workgroup level barriers as no-ops. This is + * safe today because we don't allow memory functions to be re-ordered + * and we only execute programs on a single sub-slice. + */ + break; + case nir_intrinsic_shader_clock: { /* We cannot do anything if there is an event, so ignore it for now */ fs_reg shader_clock = get_timestamp(bld); -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 1/3] glsl: Add new barrier functions for compute shaders
When these functions are called in GLSL code, we create an intrinsic function call: * groupMemoryBarrier => __intrinsic_group_memory_barrier * memoryBarrierAtomicCounter => __intrinsic_memory_barrier_atomic_counter * memoryBarrierBuffer => __intrinsic_memory_barrier_buffer * memoryBarrierImage => __intrinsic_memory_barrier_image * memoryBarrierShared => __intrinsic_memory_barrier_shared v2: * Consolidate with memoryBarrier function/intrinsic creation (curro) v3: * Instead of add_memory_barrier_function, add an intrinsic_name parameter to _memory_barrier (curro) Signed-off-by: Jordan JustenCc: Francisco Jerez --- src/glsl/builtin_functions.cpp | 55 +- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 509a57b..1349444 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -459,9 +459,15 @@ fp64(const _mesa_glsl_parse_state *state) } static bool +compute_shader(const _mesa_glsl_parse_state *state) +{ + return state->stage == MESA_SHADER_COMPUTE; +} + +static bool barrier_supported(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_COMPUTE || + return compute_shader(state) || state->stage == MESA_SHADER_TESS_CTRL; } @@ -785,8 +791,8 @@ private: ir_function_signature *_memory_barrier_intrinsic( builtin_available_predicate avail); - ir_function_signature *_memory_barrier( - builtin_available_predicate avail); + ir_function_signature *_memory_barrier(const char *intrinsic_name, + builtin_available_predicate avail); ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail, const glsl_type *type); @@ -963,6 +969,21 @@ builtin_builder::create_intrinsics() add_function("__intrinsic_memory_barrier", _memory_barrier_intrinsic(shader_image_load_store), NULL); + add_function("__intrinsic_group_memory_barrier", +_memory_barrier_intrinsic(compute_shader), +NULL); + add_function("__intrinsic_memory_barrier_atomic_counter", +_memory_barrier_intrinsic(compute_shader), +NULL); + add_function("__intrinsic_memory_barrier_buffer", +_memory_barrier_intrinsic(compute_shader), +NULL); + add_function("__intrinsic_memory_barrier_image", +_memory_barrier_intrinsic(compute_shader), +NULL); + add_function("__intrinsic_memory_barrier_shared", +_memory_barrier_intrinsic(compute_shader), +NULL); add_function("__intrinsic_shader_clock", _shader_clock_intrinsic(shader_clock, @@ -2754,7 +2775,28 @@ builtin_builder::create_builtins() add_image_functions(true); add_function("memoryBarrier", -_memory_barrier(shader_image_load_store), +_memory_barrier("__intrinsic_memory_barrier", +shader_image_load_store), +NULL); + add_function("groupMemoryBarrier", +_memory_barrier("__intrinsic_group_memory_barrier", +compute_shader), +NULL); + add_function("memoryBarrierAtomicCounter", +_memory_barrier("__intrinsic_memory_barrier_atomic_counter", +compute_shader), +NULL); + add_function("memoryBarrierBuffer", +_memory_barrier("__intrinsic_memory_barrier_buffer", +compute_shader), +NULL); + add_function("memoryBarrierImage", +_memory_barrier("__intrinsic_memory_barrier_image", +compute_shader), +NULL); + add_function("memoryBarrierShared", +_memory_barrier("__intrinsic_memory_barrier_shared", +compute_shader), NULL); add_function("clock2x32ARB", @@ -5264,10 +5306,11 @@ builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail) } ir_function_signature * -builtin_builder::_memory_barrier(builtin_available_predicate avail) +builtin_builder::_memory_barrier(const char *intrinsic_name, + builtin_available_predicate avail) { MAKE_SIG(glsl_type::void_type, avail, 0); - body.emit(call(shader->symbols->get_function("__intrinsic_memory_barrier"), + body.emit(call(shader->symbols->get_function(intrinsic_name), NULL, sig->parameters)); return sig; } -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: use the correct string for the ES GL_KHR_debug functions
As defined in the spec when implemented in an OpenGL ES context, all entry points defined by this extension must have a "KHR" suffix. Signed-off-by: Emil Velikov--- The final piece afaict for KHR_debug + ES contexts. Mildly related - the enum tests seems somewhat busted/incomplete. Extra test + fixup coming shortly. -Emil src/mesa/main/errors.c | 40 --- src/mesa/main/getstring.c | 10 -- src/mesa/main/objectlabel.c | 46 +++-- 3 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index f720de3..fea4e2d 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -978,9 +978,13 @@ _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLint length, const GLchar *buf) { - const char *callerstr = "glDebugMessageInsert"; - GET_CURRENT_CONTEXT(ctx); + const char *callerstr; + + if (_mesa_is_desktop_gl(ctx)) + *callerstr = "glDebugMessageInsert"; + else + *callerstr = "glDebugMessageInsertKHR"; if (!validate_params(ctx, INSERT, callerstr, source, type, severity)) return; /* GL_INVALID_ENUM */ @@ -1004,15 +1008,21 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, { GET_CURRENT_CONTEXT(ctx); struct gl_debug_state *debug; + const char *callerstr; GLuint ret; + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glGetDebugMessageLog"; + else + callerstr = "glGetDebugMessageLogKHR"; + if (!messageLog) logSize = 0; if (logSize < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glGetDebugMessageLog(logSize=%d : logSize must not be" - " negative)", logSize); + "%s(logSize=%d : logSize must not be negative)", + callerstr, logSize); return 0; } @@ -1066,9 +1076,14 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type, enum mesa_debug_source source = gl_enum_to_debug_source(gl_source); enum mesa_debug_type type = gl_enum_to_debug_type(gl_type); enum mesa_debug_severity severity = gl_enum_to_debug_severity(gl_severity); - const char *callerstr = "glDebugMessageControl"; + const char *callerstr; struct gl_debug_state *debug; + if (_mesa_is_desktop_gl(ctx)) + *callerstr = "glDebugMessageControl"; + else + *callerstr = "glDebugMessageControlKHR"; + if (count < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(count=%d : count must not be negative)", callerstr, @@ -1124,9 +1139,15 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) { GET_CURRENT_CONTEXT(ctx); - const char *callerstr = "glPushDebugGroup"; + const char *callerstr; struct gl_debug_state *debug; struct gl_debug_message *emptySlot; + GLuint ret; + + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glPushDebugGroup"; + else + callerstr = "glPushDebugGroupKHR"; switch(source) { case GL_DEBUG_SOURCE_APPLICATION: @@ -1176,10 +1197,15 @@ void GLAPIENTRY _mesa_PopDebugGroup(void) { GET_CURRENT_CONTEXT(ctx); - const char *callerstr = "glPopDebugGroup"; + const char *callerstr; struct gl_debug_state *debug; struct gl_debug_message *gdmessage, msg; + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glPopDebugGroup"; + else + callerstr = "glPopDebugGroupKHR"; + debug = _mesa_lock_debug_state(ctx); if (!debug) return; diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 9873fdb..2e339c8 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -203,12 +203,18 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) { GET_CURRENT_CONTEXT(ctx); const GLuint clientUnit = ctx->Array.ActiveTexture; + const char *callerstr; + + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glGetPointerv"; + else + callerstr = "glGetPointervKHR"; if (!params) return; if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_enum_to_string(pname)); + _mesa_debug(ctx, "%s %s\n", callerstr, _mesa_enum_to_string(pname)); switch (pname) { case GL_VERTEX_ARRAY_POINTER: @@ -280,7 +286,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) return; invalid_pname: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); + _mesa_error( ctx, GL_INVALID_ENUM, "%s", callerstr); return; } diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c index 1019f89..ba8ac80 100644 --- a/src/mesa/main/objectlabel.c +++ b/src/mesa/main/objectlabel.c @@ -243,13 +243,19 @@ _mesa_ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) { GET_CURRENT_CONTEXT(ctx);
Re: [Mesa-dev] [PATCH 13/13] i965/fs_visitor: do not explicitly set outputs[x].file
On 5 November 2015 at 19:15, Matt Turnerwrote: > On Thu, Nov 5, 2015 at 8:18 AM, Emil Velikov wrote: >> From: Emil Velikov >> >> This commits partially reverts "i965: Initialize registers' file to >> BAD_FILE." >> >> No longer needed as of commit "i965/fs: properly construct fs_reg" which >> removes the memset(...0...), and correctly sets BAD_FILE. > > I don't think the problem is that the constructors are doing the wrong > thing by memsetting the object. The problem is that the constructor > *isn't being called* :) > > fs_reg::init() indeed memsets, but it also sets file = BAD_FILE > (today, and after my series). > > So I think the code you're removing is still needed because the > problem of not calling the constructors remain. > > Maybe I've misunderstood something. Afaict if one declares an array, the default ctor will be called for each instance in the list. Thus the BAD_FILE will be set. On the other hand - currently we zero the whole lot (thanks to memset(this->outputs, 0...). Which might be the prime suspect of the issue here. The above is from my humble understanding of C++ plus a quick side test. I will check if it holds true within mesa in a few minutes. -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] radeonsi: add basic glClearBufferSubData acceleration
On 04.11.2015 00:47, Marek Olšák wrote: From: Marek Olšák--- src/gallium/drivers/radeonsi/si_blit.c | 55 ++ 1 file changed, 55 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index fce014a..e934146 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -731,9 +731,64 @@ static void si_flush_resource(struct pipe_context *ctx, } } +static void si_pipe_clear_buffer(struct pipe_context *ctx, +struct pipe_resource *dst, +unsigned offset, unsigned size, +const void *clear_value, +int clear_value_size) +{ + struct si_context *sctx = (struct si_context*)ctx; + const uint32_t *u32 = clear_value; + unsigned i; + bool clear_value_fits_dword = true; + uint8_t *map; + + if (clear_value_size > 4) + for (i = 1; i < clear_value_size / 4; i++) + if (u32[0] != u32[i]) { + clear_value_fits_dword = false; + break; + } + + /* Use CP DMA for the simple case. */ + if (offset % 4 == 0 && size % 4 == 0 && clear_value_fits_dword) { + uint32_t value = u32[0]; + + switch (clear_value_size) { + case 1: + value &= 0xff; + value |= (value << 8) | (value << 16) | (value << 24); + break; + case 2: + value &= 0x; + value |= value << 16; + break; + } To reduce the chance of complaints by valgrind et al: switch (clear_value_size) { case 1: value = *(uint8_t *)u32; value |= (value << 8) | (value << 16) | (value << 24); break; case 2: value = *(uint16_t *)u32; value |= value << 16; break; default: value = *u32; break; } Cheers, Nicolai + + sctx->b.clear_buffer(ctx, dst, offset, size, value, false); + return; + } + + /* TODO: use a compute shader for other cases. */ + + /* Software fallback. */ + map = r600_buffer_map_sync_with_rings(>b, r600_resource(dst), + PIPE_TRANSFER_WRITE); + if (!map) + return; + + map += offset; + size /= clear_value_size; + for (i = 0; i < size; i++) { + memcpy(map, clear_value, clear_value_size); + map += clear_value_size; + } +} + void si_init_blit_functions(struct si_context *sctx) { sctx->b.b.clear = si_clear; + sctx->b.b.clear_buffer = si_pipe_clear_buffer; sctx->b.b.clear_render_target = si_clear_render_target; sctx->b.b.clear_depth_stencil = si_clear_depth_stencil; sctx->b.b.resource_copy_region = si_resource_copy_region; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 05/13] i965/vec4: one dst_reg() constructor less
On Thu, Nov 5, 2015 at 8:17 AM, Emil Velikovwrote: > From: Emil Velikov > > Just fold the brw_type_for_base_type() and use a delegated > constructor. > > Note this is a c++11 feature and the compiler will warn us if it's > set/defaults to an earlier version of the standard. > > XXX: Should we just toggle c++11 on ? We seem to be using some of its > functionality already (anonymous unions) and we could even simplify > gallium/nouveau a bit. I said anonymous unions were a C11 (not C++11) feature and a language extension supported by gcc and clang. I have no idea if it's C++11 and it's not reason to claim we're already using C++11. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] vl: add drm support for vl_screen
This will allow the state trackers to use render nodes with screen creation Signed-off-by: Leo Liu--- src/gallium/auxiliary/Makefile.sources | 3 +- src/gallium/auxiliary/vl/vl_winsys.h | 6 +++ src/gallium/auxiliary/vl/vl_winsys_drm.c | 76 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/gallium/auxiliary/vl/vl_winsys_drm.c diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 6e22ced..82ef5ec 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -349,7 +349,8 @@ VL_SOURCES := \ # XXX: Nuke this as our dri targets no longer depend on VL. VL_WINSYS_SOURCES := \ - vl/vl_winsys_dri.c + vl/vl_winsys_dri.c \ + vl/vl_winsys_drm.c VL_STUB_SOURCES := \ vl/vl_stubs.c diff --git a/src/gallium/auxiliary/vl/vl_winsys.h b/src/gallium/auxiliary/vl/vl_winsys.h index f6b47c9..df01917 100644 --- a/src/gallium/auxiliary/vl/vl_winsys.h +++ b/src/gallium/auxiliary/vl/vl_winsys.h @@ -66,4 +66,10 @@ vl_screen_set_next_timestamp(struct vl_screen *vscreen, uint64_t stamp); void* vl_screen_get_private(struct vl_screen *vscreen); +struct vl_screen* +vl_drm_screen_create(int fd); + +void +vl_drm_screen_destroy(struct vl_screen *vscreen); + #endif diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c new file mode 100644 index 000..65b74eb --- /dev/null +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -0,0 +1,76 @@ +/** + * + * Copyright 2009 Younes Manton. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#include + +#include "pipe/p_screen.h" +#include "pipe-loader/pipe_loader.h" + +#include "util/u_memory.h" +#include "vl/vl_winsys.h" + +struct vl_screen* +vl_drm_screen_create(int fd) +{ + struct vl_screen *vscreen; + + vscreen = CALLOC_STRUCT(vl_screen); + if (!vscreen) + return NULL; + +#if GALLIUM_STATIC_TARGETS + vscreen->pscreen = dd_create_screen(fd); +#else + if (pipe_loader_drm_probe_fd(>dev, fd)) { + vscreen->pscreen = + pipe_loader_create_screen(vscreen->dev, PIPE_SEARCH_DIR); + if (!vscreen->pscreen) + pipe_loader_release(>dev, 1); + } +#endif + + if (!vscreen->pscreen) { + FREE(vscreen); + return NULL; + } + + return vscreen; +} + +void +vl_drm_screen_destroy(struct vl_screen *vscreen) +{ + assert(vscreen); + + vscreen->pscreen->destroy(vscreen->pscreen); + +#if !GALLIUM_STATIC_TARGETS + pipe_loader_release(>dev, 1); +#endif + + FREE(vscreen); +} -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/4] vl: add drm support for vl_screen
+/** + * + * Copyright 2009 Younes Manton. + * All Rights Reserved. You probably want to change the copyright here. With that fixed the whole series is Reviewed-by: Christian KönigRegards, Christian. On 05.11.2015 19:47, Leo Liu wrote: This will allow the state trackers to use render nodes with screen creation Signed-off-by: Leo Liu --- src/gallium/auxiliary/Makefile.sources | 3 +- src/gallium/auxiliary/vl/vl_winsys.h | 6 +++ src/gallium/auxiliary/vl/vl_winsys_drm.c | 76 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/gallium/auxiliary/vl/vl_winsys_drm.c diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 6e22ced..82ef5ec 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -349,7 +349,8 @@ VL_SOURCES := \ # XXX: Nuke this as our dri targets no longer depend on VL. VL_WINSYS_SOURCES := \ - vl/vl_winsys_dri.c + vl/vl_winsys_dri.c \ + vl/vl_winsys_drm.c VL_STUB_SOURCES := \ vl/vl_stubs.c diff --git a/src/gallium/auxiliary/vl/vl_winsys.h b/src/gallium/auxiliary/vl/vl_winsys.h index f6b47c9..df01917 100644 --- a/src/gallium/auxiliary/vl/vl_winsys.h +++ b/src/gallium/auxiliary/vl/vl_winsys.h @@ -66,4 +66,10 @@ vl_screen_set_next_timestamp(struct vl_screen *vscreen, uint64_t stamp); void* vl_screen_get_private(struct vl_screen *vscreen); +struct vl_screen* +vl_drm_screen_create(int fd); + +void +vl_drm_screen_destroy(struct vl_screen *vscreen); + #endif diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c new file mode 100644 index 000..65b74eb --- /dev/null +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -0,0 +1,76 @@ +/** + * + * Copyright 2009 Younes Manton. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#include + +#include "pipe/p_screen.h" +#include "pipe-loader/pipe_loader.h" + +#include "util/u_memory.h" +#include "vl/vl_winsys.h" + +struct vl_screen* +vl_drm_screen_create(int fd) +{ + struct vl_screen *vscreen; + + vscreen = CALLOC_STRUCT(vl_screen); + if (!vscreen) + return NULL; + +#if GALLIUM_STATIC_TARGETS + vscreen->pscreen = dd_create_screen(fd); +#else + if (pipe_loader_drm_probe_fd(>dev, fd)) { + vscreen->pscreen = + pipe_loader_create_screen(vscreen->dev, PIPE_SEARCH_DIR); + if (!vscreen->pscreen) + pipe_loader_release(>dev, 1); + } +#endif + + if (!vscreen->pscreen) { + FREE(vscreen); + return NULL; + } + + return vscreen; +} + +void +vl_drm_screen_destroy(struct vl_screen *vscreen) +{ + assert(vscreen); + + vscreen->pscreen->destroy(vscreen->pscreen); + +#if !GALLIUM_STATIC_TARGETS + pipe_loader_release(>dev, 1); +#endif + + FREE(vscreen); +} ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] nir: add shader reference counting
On Sat, Oct 24, 2015 at 10:07 AM, Rob Clarkwrote: > From: Rob Clark > > For gallium, at least, we'll need this to manage shader's lifetimes, > since in some cases both the driver and the state tracker will need > to hold on to a reference for variant managing. > > Use nir_shader_mutable() before doing any IR opt/lowering/etc, to > ensure you are not modifying a copy someone else is also holding a > reference to. In this way, unnecessary nir_shader_clone()s are > avoided whenever possible. > > TODO: Any places missed to s/ralloc_free()/nir_shader_unref()/ outside > of freedreno/ir3? I talked with Ken about this a few days ago, and it doesn't seem like a good idea. Adding reference counting to NIR means mixing two very different memory management models. NIR already uses the ralloc model where a shader is tied to a context. Allowing both ralloc and refcount models is a bad idea because freeing a context could cause the shader to go out-of-scope early from the refcount perspective and refcounting means you don't know what thread the shader is deleted in which is really bad for ralloc. The only way we could do this is if we only used ralloc internally to NIR and disallowed parenting a nir_shader to anything. I don't really think we want this, at least not for the i965 driver. The best option here would probably be to make a little flyweight wrapper object for TGSI to use that acts as the ralloc context for a NIR shader and is, itself, reference-counted. You still have to provide similar guarantees (said object can never have a parent), but it would keep those guarantees obvious. Sorry :-/ --Jason > Signed-off-by: Rob Clark > --- > src/gallium/drivers/vc4/vc4_program.c | 2 +- > src/glsl/nir/nir.c| 2 ++ > src/glsl/nir/nir.h| 43 > +++ > src/mesa/program/program.c| 3 ++- > 4 files changed, 48 insertions(+), 2 deletions(-) > > diff --git a/src/gallium/drivers/vc4/vc4_program.c > b/src/gallium/drivers/vc4/vc4_program.c > index 5d7564b..9a055df 100644 > --- a/src/gallium/drivers/vc4/vc4_program.c > +++ b/src/gallium/drivers/vc4/vc4_program.c > @@ -1723,7 +1723,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage > stage, > c->num_uniforms); > } > > -ralloc_free(c->s); > +nir_shader_unref(c->s); > > return c; > } > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c > index 2defa36..53a11f5 100644 > --- a/src/glsl/nir/nir.c > +++ b/src/glsl/nir/nir.c > @@ -36,6 +36,8 @@ nir_shader_create(void *mem_ctx, > { > nir_shader *shader = ralloc(mem_ctx, nir_shader); > > + p_atomic_set(>refcount, 1); > + > exec_list_make_empty(>uniforms); > exec_list_make_empty(>inputs); > exec_list_make_empty(>outputs); > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h > index 926747c..3ab720b 100644 > --- a/src/glsl/nir/nir.h > +++ b/src/glsl/nir/nir.h > @@ -34,6 +34,7 @@ > #include "util/ralloc.h" > #include "util/set.h" > #include "util/bitset.h" > +#include "util/u_atomic.h" > #include "nir_types.h" > #include "shader_enums.h" > #include > @@ -1546,6 +1547,8 @@ typedef struct nir_shader_info { > } nir_shader_info; > > typedef struct nir_shader { > + int refcount; > + > /** list of uniforms (nir_variable) */ > struct exec_list uniforms; > > @@ -1894,6 +1897,46 @@ void nir_print_instr(const nir_instr *instr, FILE *fp); > > nir_shader * nir_shader_clone(void *mem_ctx, const nir_shader *s); > > +static inline void > +nir_shader_ref(nir_shader *shader) > +{ > + p_atomic_inc(>refcount); > +} > + > +static inline void > +nir_shader_unref(nir_shader *shader) > +{ > + if (p_atomic_dec_zero(>refcount)) { > + ralloc_free(shader); > + } > +} > + > +/* A shader with only a single reference is mutable: */ > +static inline bool > +nir_shader_is_mutable(nir_shader *shader) > +{ > + return p_atomic_read(>refcount) == 1; > +} > + > +/* Convert a shader reference into a mutable shader reference. Ie. if > + * there is only a single reference to the shader, then return that, > + * otherwise clone and drop reference to existing shader. > + * > + * TODO maybe an assert that shader->refcnt == 1 in the various opt/ > + * lowering passes? If only there was a good central place to put it. > + */ > +static inline nir_shader * > +nir_shader_mutable(nir_shader *shader) > +{ > + if (nir_shader_is_mutable(shader)) { > + return shader; > + } else { > + nir_shader *ns = nir_shader_clone(ralloc_parent(shader), shader); > + nir_shader_unref(shader); > + return ns; > + } > +} > + > #ifdef DEBUG > void nir_validate_shader(nir_shader *shader); > #else > diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c > index 0e78e6a..c2da66e 100644 > --- a/src/mesa/program/program.c > +++ b/src/mesa/program/program.c > @@ -38,6 +38,7 @@ >
[Mesa-dev] [PATCH 3/4] st/va: move vl screen drm support to vl_wys_drm
--- src/gallium/state_trackers/va/context.c | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 25fa905..845b547 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -28,8 +28,6 @@ #include "pipe/p_screen.h" #include "pipe/p_video_codec.h" -#include "pipe-loader/pipe_loader.h" -#include "state_tracker/drm_driver.h" #include "util/u_memory.h" #include "util/u_handle_table.h" #include "util/u_video.h" @@ -144,21 +142,9 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx) return VA_STATUS_ERROR_INVALID_PARAMETER; } - drv->vscreen = CALLOC_STRUCT(vl_screen); + drv->vscreen = vl_drm_screen_create(drm_fd); if (!drv->vscreen) goto error_screen; - -#if GALLIUM_STATIC_TARGETS - drv->vscreen->pscreen = dd_create_screen(drm_fd); -#else - if (pipe_loader_drm_probe_fd(>vscreen->dev, drm_fd)) - drv->vscreen->pscreen = - pipe_loader_create_screen(drv->vscreen->dev, PIPE_SEARCH_DIR); -#endif - - if (!drv->vscreen->pscreen) - goto error_pipe; - } break; default: @@ -203,7 +189,7 @@ error_pipe: if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) vl_screen_destroy(drv->vscreen); else - FREE(drv->vscreen); + vl_drm_screen_destroy(drv->vscreen); error_screen: FREE(drv); @@ -343,7 +329,7 @@ vlVaTerminate(VADriverContextP ctx) if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == VA_DISPLAY_X11) vl_screen_destroy(drv->vscreen); else - FREE(drv->vscreen); + vl_drm_screen_destroy(drv->vscreen); handle_table_destroy(drv->htab); FREE(drv); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 13/13] i965/fs_visitor: do not explicitly set outputs[x].file
On Thu, Nov 5, 2015 at 8:18 AM, Emil Velikovwrote: > From: Emil Velikov > > This commits partially reverts "i965: Initialize registers' file to > BAD_FILE." > > No longer needed as of commit "i965/fs: properly construct fs_reg" which > removes the memset(...0...), and correctly sets BAD_FILE. I don't think the problem is that the constructors are doing the wrong thing by memsetting the object. The problem is that the constructor *isn't being called* :) fs_reg::init() indeed memsets, but it also sets file = BAD_FILE (today, and after my series). So I think the code you're removing is still needed because the problem of not calling the constructors remain. Maybe I've misunderstood something. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 2/3] nir: Add new barrier functions for compute shaders
When these functions are called in glsl-ir, we create a corresponding nir intrinsic function call. Signed-off-by: Jordan JustenReviewed-by: Francisco Jerez --- src/glsl/nir/glsl_to_nir.cpp | 15 +++ src/glsl/nir/nir_intrinsics.h | 11 +++ 2 files changed, 26 insertions(+) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 57aba5b..facb9fa 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -719,6 +719,16 @@ nir_visitor::visit(ir_call *ir) op = nir_intrinsic_ssbo_atomic_comp_swap; } else if (strcmp(ir->callee_name(), "__intrinsic_shader_clock") == 0) { op = nir_intrinsic_shader_clock; + } else if (strcmp(ir->callee_name(), "__intrinsic_group_memory_barrier") == 0) { + op = nir_intrinsic_group_memory_barrier; + } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_atomic_counter") == 0) { + op = nir_intrinsic_memory_barrier_atomic_counter; + } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_buffer") == 0) { + op = nir_intrinsic_memory_barrier_buffer; + } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_image") == 0) { + op = nir_intrinsic_memory_barrier_image; + } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_shared") == 0) { + op = nir_intrinsic_memory_barrier_shared; } else { unreachable("not reached"); } @@ -821,6 +831,11 @@ nir_visitor::visit(ir_call *ir) break; } case nir_intrinsic_memory_barrier: + case nir_intrinsic_group_memory_barrier: + case nir_intrinsic_memory_barrier_atomic_counter: + case nir_intrinsic_memory_barrier_buffer: + case nir_intrinsic_memory_barrier_image: + case nir_intrinsic_memory_barrier_shared: nir_instr_insert_after_cf_list(this->cf_node_list, >instr); break; case nir_intrinsic_shader_clock: diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h index c2b6fe7..36fb286 100644 --- a/src/glsl/nir/nir_intrinsics.h +++ b/src/glsl/nir/nir_intrinsics.h @@ -91,6 +91,17 @@ BARRIER(memory_barrier) */ INTRINSIC(shader_clock, 0, ARR(), true, 1, 0, 0, NIR_INTRINSIC_CAN_ELIMINATE) +/* + * Memory barrier with semantics analogous to the compute shader + * groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(), + * memoryBarrierImage() and memoryBarrierShared() GLSL intrinsics. + */ +BARRIER(group_memory_barrier) +BARRIER(memory_barrier_atomic_counter) +BARRIER(memory_barrier_buffer) +BARRIER(memory_barrier_image) +BARRIER(memory_barrier_shared) + /** A conditional discard, with a single boolean source. */ INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, 0) -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] nir: add shader reference counting
On Thu, Nov 5, 2015 at 1:13 PM, Jason Ekstrandwrote: > On Sat, Oct 24, 2015 at 10:07 AM, Rob Clark wrote: >> From: Rob Clark >> >> For gallium, at least, we'll need this to manage shader's lifetimes, >> since in some cases both the driver and the state tracker will need >> to hold on to a reference for variant managing. >> >> Use nir_shader_mutable() before doing any IR opt/lowering/etc, to >> ensure you are not modifying a copy someone else is also holding a >> reference to. In this way, unnecessary nir_shader_clone()s are >> avoided whenever possible. >> >> TODO: Any places missed to s/ralloc_free()/nir_shader_unref()/ outside >> of freedreno/ir3? > > I talked with Ken about this a few days ago, and it doesn't seem like > a good idea. Adding reference counting to NIR means mixing two very > different memory management models. NIR already uses the ralloc model > where a shader is tied to a context. Allowing both ralloc and > refcount models is a bad idea because freeing a context could cause > the shader to go out-of-scope early from the refcount perspective and > refcounting means you don't know what thread the shader is deleted in > which is really bad for ralloc. The only way we could do this is if > we only used ralloc internally to NIR and disallowed parenting a > nir_shader to anything. I don't really think we want this, at least > not for the i965 driver. > > The best option here would probably be to make a little flyweight > wrapper object for TGSI to use that acts as the ralloc context for a > NIR shader and is, itself, reference-counted. You still have to > provide similar guarantees (said object can never have a parent), but > it would keep those guarantees obvious. Hmm, maybe a better idea still (and simpler) would be to just disallow nir_shader_ref() if parent memctx is not null? This way we can keep the centralized checks for refcnt>1 in the nir-pass runner function/macro/whatever.. BR, -R > Sorry :-/ > --Jason > >> Signed-off-by: Rob Clark >> --- >> src/gallium/drivers/vc4/vc4_program.c | 2 +- >> src/glsl/nir/nir.c| 2 ++ >> src/glsl/nir/nir.h| 43 >> +++ >> src/mesa/program/program.c| 3 ++- >> 4 files changed, 48 insertions(+), 2 deletions(-) >> >> diff --git a/src/gallium/drivers/vc4/vc4_program.c >> b/src/gallium/drivers/vc4/vc4_program.c >> index 5d7564b..9a055df 100644 >> --- a/src/gallium/drivers/vc4/vc4_program.c >> +++ b/src/gallium/drivers/vc4/vc4_program.c >> @@ -1723,7 +1723,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage >> stage, >> c->num_uniforms); >> } >> >> -ralloc_free(c->s); >> +nir_shader_unref(c->s); >> >> return c; >> } >> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c >> index 2defa36..53a11f5 100644 >> --- a/src/glsl/nir/nir.c >> +++ b/src/glsl/nir/nir.c >> @@ -36,6 +36,8 @@ nir_shader_create(void *mem_ctx, >> { >> nir_shader *shader = ralloc(mem_ctx, nir_shader); >> >> + p_atomic_set(>refcount, 1); >> + >> exec_list_make_empty(>uniforms); >> exec_list_make_empty(>inputs); >> exec_list_make_empty(>outputs); >> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h >> index 926747c..3ab720b 100644 >> --- a/src/glsl/nir/nir.h >> +++ b/src/glsl/nir/nir.h >> @@ -34,6 +34,7 @@ >> #include "util/ralloc.h" >> #include "util/set.h" >> #include "util/bitset.h" >> +#include "util/u_atomic.h" >> #include "nir_types.h" >> #include "shader_enums.h" >> #include >> @@ -1546,6 +1547,8 @@ typedef struct nir_shader_info { >> } nir_shader_info; >> >> typedef struct nir_shader { >> + int refcount; >> + >> /** list of uniforms (nir_variable) */ >> struct exec_list uniforms; >> >> @@ -1894,6 +1897,46 @@ void nir_print_instr(const nir_instr *instr, FILE >> *fp); >> >> nir_shader * nir_shader_clone(void *mem_ctx, const nir_shader *s); >> >> +static inline void >> +nir_shader_ref(nir_shader *shader) >> +{ >> + p_atomic_inc(>refcount); >> +} >> + >> +static inline void >> +nir_shader_unref(nir_shader *shader) >> +{ >> + if (p_atomic_dec_zero(>refcount)) { >> + ralloc_free(shader); >> + } >> +} >> + >> +/* A shader with only a single reference is mutable: */ >> +static inline bool >> +nir_shader_is_mutable(nir_shader *shader) >> +{ >> + return p_atomic_read(>refcount) == 1; >> +} >> + >> +/* Convert a shader reference into a mutable shader reference. Ie. if >> + * there is only a single reference to the shader, then return that, >> + * otherwise clone and drop reference to existing shader. >> + * >> + * TODO maybe an assert that shader->refcnt == 1 in the various opt/ >> + * lowering passes? If only there was a good central place to put it. >> + */ >> +static inline nir_shader * >> +nir_shader_mutable(nir_shader *shader) >> +{ >> + if
Re: [Mesa-dev] [PATCH] radeonsi: add basic glClearBufferSubData acceleration
On Thu, Nov 5, 2015 at 7:58 PM, Nicolai Hähnlewrote: > On 04.11.2015 00:47, Marek Olšák wrote: >> >> From: Marek Olšák >> >> --- >> src/gallium/drivers/radeonsi/si_blit.c | 55 >> ++ >> 1 file changed, 55 insertions(+) >> >> diff --git a/src/gallium/drivers/radeonsi/si_blit.c >> b/src/gallium/drivers/radeonsi/si_blit.c >> index fce014a..e934146 100644 >> --- a/src/gallium/drivers/radeonsi/si_blit.c >> +++ b/src/gallium/drivers/radeonsi/si_blit.c >> @@ -731,9 +731,64 @@ static void si_flush_resource(struct pipe_context >> *ctx, >> } >> } >> >> +static void si_pipe_clear_buffer(struct pipe_context *ctx, >> +struct pipe_resource *dst, >> +unsigned offset, unsigned size, >> +const void *clear_value, >> +int clear_value_size) >> +{ >> + struct si_context *sctx = (struct si_context*)ctx; >> + const uint32_t *u32 = clear_value; >> + unsigned i; >> + bool clear_value_fits_dword = true; >> + uint8_t *map; >> + >> + if (clear_value_size > 4) >> + for (i = 1; i < clear_value_size / 4; i++) >> + if (u32[0] != u32[i]) { >> + clear_value_fits_dword = false; >> + break; >> + } >> + >> + /* Use CP DMA for the simple case. */ >> + if (offset % 4 == 0 && size % 4 == 0 && clear_value_fits_dword) { >> + uint32_t value = u32[0]; >> + >> + switch (clear_value_size) { >> + case 1: >> + value &= 0xff; >> + value |= (value << 8) | (value << 16) | (value << >> 24); >> + break; >> + case 2: >> + value &= 0x; >> + value |= value << 16; >> + break; >> + } > > > To reduce the chance of complaints by valgrind et al: > > switch (clear_value_size) { > case 1: > value = *(uint8_t *)u32; > value |= (value << 8) | (value << 16) | (value << 24); > break; > case 2: > value = *(uint16_t *)u32; > value |= value << 16; > break; > default: > value = *u32; > break; > } Thanks. The preliminary plan is to use transform feedback for fills>=64 bits (already implemented by u_blitter), and CP DMA should be used for 32-bit fills and any fills that can be lowered to 32-bit. Unaligned 8-bit and 16-bit fills should fill the largest aligned subrange using CP DMA. Then, the unaligned beginning and ending dwords will be filled separately using: COPY_DATA from mem to reg REG_RMW to fill the requested bytes COPY_DATA from reg to mem Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCHv2] mesa: use the correct string for the ES GL_KHR_debug functions
As defined in the spec when implemented in an OpenGL ES context, all entry points defined by this extension must have a "KHR" suffix. Signed-off-by: Emil Velikov--- Actually build tested this time. src/mesa/main/errors.c | 40 --- src/mesa/main/getstring.c | 10 -- src/mesa/main/objectlabel.c | 46 +++-- 3 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index f720de3..fe628c3 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -978,9 +978,13 @@ _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLint length, const GLchar *buf) { - const char *callerstr = "glDebugMessageInsert"; - GET_CURRENT_CONTEXT(ctx); + const char *callerstr; + + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glDebugMessageInsert"; + else + callerstr = "glDebugMessageInsertKHR"; if (!validate_params(ctx, INSERT, callerstr, source, type, severity)) return; /* GL_INVALID_ENUM */ @@ -1004,15 +1008,21 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, { GET_CURRENT_CONTEXT(ctx); struct gl_debug_state *debug; + const char *callerstr; GLuint ret; + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glGetDebugMessageLog"; + else + callerstr = "glGetDebugMessageLogKHR"; + if (!messageLog) logSize = 0; if (logSize < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glGetDebugMessageLog(logSize=%d : logSize must not be" - " negative)", logSize); + "%s(logSize=%d : logSize must not be negative)", + callerstr, logSize); return 0; } @@ -1066,9 +1076,14 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type, enum mesa_debug_source source = gl_enum_to_debug_source(gl_source); enum mesa_debug_type type = gl_enum_to_debug_type(gl_type); enum mesa_debug_severity severity = gl_enum_to_debug_severity(gl_severity); - const char *callerstr = "glDebugMessageControl"; + const char *callerstr; struct gl_debug_state *debug; + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glDebugMessageControl"; + else + callerstr = "glDebugMessageControlKHR"; + if (count < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(count=%d : count must not be negative)", callerstr, @@ -1124,9 +1139,15 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) { GET_CURRENT_CONTEXT(ctx); - const char *callerstr = "glPushDebugGroup"; + const char *callerstr; struct gl_debug_state *debug; struct gl_debug_message *emptySlot; + GLuint ret; + + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glPushDebugGroup"; + else + callerstr = "glPushDebugGroupKHR"; switch(source) { case GL_DEBUG_SOURCE_APPLICATION: @@ -1176,10 +1197,15 @@ void GLAPIENTRY _mesa_PopDebugGroup(void) { GET_CURRENT_CONTEXT(ctx); - const char *callerstr = "glPopDebugGroup"; + const char *callerstr; struct gl_debug_state *debug; struct gl_debug_message *gdmessage, msg; + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glPopDebugGroup"; + else + callerstr = "glPopDebugGroupKHR"; + debug = _mesa_lock_debug_state(ctx); if (!debug) return; diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 9873fdb..2e339c8 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -203,12 +203,18 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) { GET_CURRENT_CONTEXT(ctx); const GLuint clientUnit = ctx->Array.ActiveTexture; + const char *callerstr; + + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glGetPointerv"; + else + callerstr = "glGetPointervKHR"; if (!params) return; if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_enum_to_string(pname)); + _mesa_debug(ctx, "%s %s\n", callerstr, _mesa_enum_to_string(pname)); switch (pname) { case GL_VERTEX_ARRAY_POINTER: @@ -280,7 +286,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) return; invalid_pname: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); + _mesa_error( ctx, GL_INVALID_ENUM, "%s", callerstr); return; } diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c index 1019f89..41f370c 100644 --- a/src/mesa/main/objectlabel.c +++ b/src/mesa/main/objectlabel.c @@ -243,13 +243,19 @@ _mesa_ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) { GET_CURRENT_CONTEXT(ctx); + const char *callerstr; char **labelPtr; - labelPtr = get_label_pointer(ctx, identifier, name, "glObjectLabel"); + if
Re: [Mesa-dev] [PATCH 4/4] st/va: add support for RGBX and BGRX in VPP
On 5 November 2015 at 16:27, Emil Velikovwrote: > Hi Julien, > > On 5 November 2015 at 08:24, Julien Isorce > wrote: > > Before it was only possible to convert a NV12 surface to > > RGBA or BGRA. This patch uses the same post processing > > function, "handleVAProcPipelineParameterBufferType", but > > add definitions for RGBX and BGRX. > > > > This patch also makes vlVaQuerySurfaceAttributes more generic. > > > > Signed-off-by: Julien Isorce > > --- > > src/gallium/auxiliary/vl/vl_video_buffer.c | 18 +++ > > src/gallium/state_trackers/va/picture.c| 5 +++-- > > src/gallium/state_trackers/va/surface.c| 36 > +- > > src/gallium/state_trackers/va/va_private.h | 1 + > > 4 files changed, 42 insertions(+), 18 deletions(-) > > > As the diffstat suggests - two different areas, thus this should be > different patches. > > Ok I'll split it. > > > @@ -314,7 +319,9 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, > VAConfigID config, > > vlVaDriver *drv; > > VASurfaceAttrib *attribs; > > struct pipe_screen *pscreen; > > - int i; > > + int i, j; > > + > > + STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats) <= > VL_VA_MAX_IMAGE_FORMATS); > > > Nice, thank you ! > no pb :) > > > > --- a/src/gallium/state_trackers/va/va_private.h > > +++ b/src/gallium/state_trackers/va/va_private.h > > @@ -49,6 +49,7 @@ > > #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) > > > > #define VL_VA_MAX_IMAGE_FORMATS 9 > > +#define VL_VA_MAX_SURFACE_ATTRIBUTES 24 > > > Unused define ? > Thx I'll remove this residual from a previous attempt. > > Cheers, > Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/4] st/va: properly indent buffer.c, config.c, image.c and picture.c
On 5 November 2015 at 16:28, Emil Velikovwrote: > On 5 November 2015 at 08:24, Julien Isorce > wrote: > > Some lines were using 4 indentation spaces instead of 3. > > > > The switch in vlVaAcquireBufferHandle actually had wrong brackets > > surrounding case+default. > > > Please don't mix whitespace (trivial) patches and bugfixes. > > -Emil > Right, I'll split it. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/4] st/va: indent, leak fix and RGBx/BGRx for vpp
On 5 November 2015 at 14:22, Christian Königwrote: > Patches #1-#3 are Reviewed-by: Christian König > > Please split patch #4 in two with first adding the new vl_video_buffer > formats and then using them in the state tracker. > Makes sense, I'll split it. > > Should I commit that for you as well or do you now have an account? > I requested the account few minutes ago but please push #1 and #2. Tomorrow I'll send a v2 about #3 and #4 after addressing remarks + split. Thx Julien > > Regards, > Christian. > > > On 05.11.2015 09:24, Julien Isorce wrote: > >> A few fixes and small improvement from recent changes in st/va: >> * Indentation was wrong for some functions. >> * Coverity reported a memory leak. (thx to Ilia for pointing this) >> * More color formats convertion for Video Post Processing >> >> Julien Isorce (4): >>st/va: indent vlVaQuerySurfaceAttributes and vlVaCreateSurfaces2 >>st/va: fix memory leak on error in vlVaCreateSurfaces2 >>st/va: properly indent buffer.c, config.c, image.c and picture.c >>st/va: add support for RGBX and BGRX in VPP >> >> src/gallium/auxiliary/vl/vl_video_buffer.c | 18 + >> src/gallium/state_trackers/va/buffer.c | 23 +- >> src/gallium/state_trackers/va/config.c | 12 +- >> src/gallium/state_trackers/va/image.c | 4 +- >> src/gallium/state_trackers/va/picture.c| 87 ++--- >> src/gallium/state_trackers/va/surface.c| 602 >> +++-- >> src/gallium/state_trackers/va/va_private.h | 1 + >> 7 files changed, 388 insertions(+), 359 deletions(-) >> >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/4] st/va: indent, leak fix and RGBx/BGRx for vpp
On 5 November 2015 at 23:13, Julien Isorcewrote: > On 5 November 2015 at 14:22, Christian König > wrote: >> >> Patches #1-#3 are Reviewed-by: Christian König >> >> Please split patch #4 in two with first adding the new vl_video_buffer >> formats and then using them in the state tracker. > > > Makes sense, I'll split it. > >> >> >> Should I commit that for you as well or do you now have an account? > > > I requested the account few minutes ago but please push #1 and #2. Tomorrow > I'll send a v2 about #3 and #4 after addressing remarks + split. > I've pushed the first two patches. Thanks again for working on these ! -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] nir: add shader reference counting
On Saturday, October 24, 2015 01:07:59 PM Rob Clark wrote: > From: Rob Clark> > For gallium, at least, we'll need this to manage shader's lifetimes, > since in some cases both the driver and the state tracker will need > to hold on to a reference for variant managing. > > Use nir_shader_mutable() before doing any IR opt/lowering/etc, to > ensure you are not modifying a copy someone else is also holding a > reference to. In this way, unnecessary nir_shader_clone()s are > avoided whenever possible. > > TODO: Any places missed to s/ralloc_free()/nir_shader_unref()/ outside > of freedreno/ir3? > > Signed-off-by: Rob Clark I'm pretty uncomfortable with mixing ralloc and reference counting. A ralloc context is essentially a linked list of child allocations. Freeing an item alters the parent context's linked list. As such, this is inherently not threadsafe at all. (It works great if you keep memory contexts within a single thread...) I'm afraid that if a NIR shader is used in multiple threads, with reference counting...and allocated out of a parent context...then we could corrupt the parent memory context's list, which would be an awful bug to track down. If reference counting is useful, then perhaps the best solution is to alter nir_shader_create() to *not* take a mem_ctx parameter, and simply do: nir_shader *shader = ralloc(NULL, nir_shader); Then, we're guaranteed that nir_shaders won't have a parent memory context, avoiding the potential threading fiasco. We can still use ralloc safely within a shader, but manage whole shaders entirely with reference counting... --Ken signature.asc Description: This is a digitally signed message part. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] nir: add shader reference counting
On Thu, Nov 5, 2015 at 10:53 AM, Rob Clarkwrote: > On Thu, Nov 5, 2015 at 1:13 PM, Jason Ekstrand wrote: >> On Sat, Oct 24, 2015 at 10:07 AM, Rob Clark wrote: >>> From: Rob Clark >>> >>> For gallium, at least, we'll need this to manage shader's lifetimes, >>> since in some cases both the driver and the state tracker will need >>> to hold on to a reference for variant managing. >>> >>> Use nir_shader_mutable() before doing any IR opt/lowering/etc, to >>> ensure you are not modifying a copy someone else is also holding a >>> reference to. In this way, unnecessary nir_shader_clone()s are >>> avoided whenever possible. >>> >>> TODO: Any places missed to s/ralloc_free()/nir_shader_unref()/ outside >>> of freedreno/ir3? >> >> I talked with Ken about this a few days ago, and it doesn't seem like >> a good idea. Adding reference counting to NIR means mixing two very >> different memory management models. NIR already uses the ralloc model >> where a shader is tied to a context. Allowing both ralloc and >> refcount models is a bad idea because freeing a context could cause >> the shader to go out-of-scope early from the refcount perspective and >> refcounting means you don't know what thread the shader is deleted in >> which is really bad for ralloc. The only way we could do this is if >> we only used ralloc internally to NIR and disallowed parenting a >> nir_shader to anything. I don't really think we want this, at least >> not for the i965 driver. >> >> The best option here would probably be to make a little flyweight >> wrapper object for TGSI to use that acts as the ralloc context for a >> NIR shader and is, itself, reference-counted. You still have to >> provide similar guarantees (said object can never have a parent), but >> it would keep those guarantees obvious. > > Hmm, maybe a better idea still (and simpler) would be to just disallow > nir_shader_ref() if parent memctx is not null? Yeah, we could do that. However, we have no way of doing a similar check to say you can't reparent it if refcount > 1. > This way we can keep the centralized checks for refcnt>1 in the > nir-pass runner function/macro/whatever.. Meh. Call the "get me a unique shader" function in your backend before you do any transformations on it.. There's no reason to call it multiple times. If the refcount goes from 1 to > 1 during your optimization loop, you're sunk anyway. --Jason > BR, > -R > >> Sorry :-/ >> --Jason >> >>> Signed-off-by: Rob Clark >>> --- >>> src/gallium/drivers/vc4/vc4_program.c | 2 +- >>> src/glsl/nir/nir.c| 2 ++ >>> src/glsl/nir/nir.h| 43 >>> +++ >>> src/mesa/program/program.c| 3 ++- >>> 4 files changed, 48 insertions(+), 2 deletions(-) >>> >>> diff --git a/src/gallium/drivers/vc4/vc4_program.c >>> b/src/gallium/drivers/vc4/vc4_program.c >>> index 5d7564b..9a055df 100644 >>> --- a/src/gallium/drivers/vc4/vc4_program.c >>> +++ b/src/gallium/drivers/vc4/vc4_program.c >>> @@ -1723,7 +1723,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage >>> stage, >>> c->num_uniforms); >>> } >>> >>> -ralloc_free(c->s); >>> +nir_shader_unref(c->s); >>> >>> return c; >>> } >>> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c >>> index 2defa36..53a11f5 100644 >>> --- a/src/glsl/nir/nir.c >>> +++ b/src/glsl/nir/nir.c >>> @@ -36,6 +36,8 @@ nir_shader_create(void *mem_ctx, >>> { >>> nir_shader *shader = ralloc(mem_ctx, nir_shader); >>> >>> + p_atomic_set(>refcount, 1); >>> + >>> exec_list_make_empty(>uniforms); >>> exec_list_make_empty(>inputs); >>> exec_list_make_empty(>outputs); >>> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h >>> index 926747c..3ab720b 100644 >>> --- a/src/glsl/nir/nir.h >>> +++ b/src/glsl/nir/nir.h >>> @@ -34,6 +34,7 @@ >>> #include "util/ralloc.h" >>> #include "util/set.h" >>> #include "util/bitset.h" >>> +#include "util/u_atomic.h" >>> #include "nir_types.h" >>> #include "shader_enums.h" >>> #include >>> @@ -1546,6 +1547,8 @@ typedef struct nir_shader_info { >>> } nir_shader_info; >>> >>> typedef struct nir_shader { >>> + int refcount; >>> + >>> /** list of uniforms (nir_variable) */ >>> struct exec_list uniforms; >>> >>> @@ -1894,6 +1897,46 @@ void nir_print_instr(const nir_instr *instr, FILE >>> *fp); >>> >>> nir_shader * nir_shader_clone(void *mem_ctx, const nir_shader *s); >>> >>> +static inline void >>> +nir_shader_ref(nir_shader *shader) >>> +{ >>> + p_atomic_inc(>refcount); >>> +} >>> + >>> +static inline void >>> +nir_shader_unref(nir_shader *shader) >>> +{ >>> + if (p_atomic_dec_zero(>refcount)) { >>> + ralloc_free(shader); >>> + } >>> +} >>> + >>> +/* A shader with only a single reference is mutable: */ >>> +static inline bool >>>
Re: [Mesa-dev] [PATCH 2/4] vl: add drm support for vl_screen
On 5 November 2015 at 19:43, Christian Königwrote: >> >> +/** >> + * >> + * Copyright 2009 Younes Manton. >> + * All Rights Reserved. > > You probably want to change the copyright here. > Heh considering that 90% of the following is bastardised^Wwritten by yours truly who never bothers updating copyrights headers ;-) >> --- /dev/null >> +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c >> +#include >> + >> +#include "pipe/p_screen.h" >> +#include "pipe-loader/pipe_loader.h" Please add the following include. #include "state_tracker/drm_driver.h" -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 92840] New account request
https://bugs.freedesktop.org/show_bug.cgi?id=92840 --- Comment #1 from Emil Velikov--- Fwiw I'm in favour of giving Julien commit access to mesa. He's doing some swell job on the vaapi side of things. -- You are receiving this mail because: You are the QA Contact for the bug. You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] nvc0: enable compute support on Fermi
On 11/06/2015 12:43 AM, Ilia Mirkin wrote: On Thu, Nov 5, 2015 at 6:41 PM, Samuel Pitoisetwrote: Altough the compute support is still not complete because textures and surfaces need to be implemented, it allows to launch very simple compute kernel like one which reads reading MP performance counters. Didn't those end up breaking 3d rendering? Have you figured out what was overwriting what? This doesn't break any stuff related to 3D rendering. The compute kernel for reading perf counters has been tested a lot on different chips. The compute support is already enabled on Kepler and it doesn't seem to break 3D rendering, btw. In the series which fixed those perf counters, I actually introduced a bug which has been fixed since: fc5ae0c13f71f049065b1422c20491d2264ae164 This turns on PIPE_CAP_COMPUTE and PIPE_SHADER_COMPUTE. Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 7d96977..5b7b39b 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -186,7 +186,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: return (class_3d >= NVE4_3D_CLASS) ? 1 : 0; case PIPE_CAP_COMPUTE: - return (class_3d == NVE4_3D_CLASS) ? 1 : 0; + return 1; Of course this also enables it for NVF0_3D_CLASS. Pretty sure compute doesn't work there for some dumb reason (like we're missing some in our ctxsw fw...) case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: return nouveau_screen(pscreen)->vram_domain & NOUVEAU_BO_VRAM ? 1 : 0; @@ -245,8 +245,6 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, return 0; break; case PIPE_SHADER_COMPUTE: - if (class_3d != NVE4_3D_CLASS) - return 0; break; default: return 0; -- 2.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC PATCH] main/tests: add inverse lookup test
Seems that we've been forgetting to update this test, leading to decreased usefulness. Thus lets add a test which walks over the mesa generated enums and checks the string (if non "0x" prefixed) against the local table. Signed-off-by: Emil Velikov--- I'm not 100% sure on the purpose of this test, although without this the local table can easily bitrot. Ian can you share your initial goal with this/these test(s). Should we extend it with this patch, nuke it altogether or else ? Note: with this in place we get ~400 missing symbols and `make check' fails. -Emil src/mesa/main/tests/enum_strings.cpp | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/tests/enum_strings.cpp b/src/mesa/main/tests/enum_strings.cpp index 48b6ec2..6e46851 100644 --- a/src/mesa/main/tests/enum_strings.cpp +++ b/src/mesa/main/tests/enum_strings.cpp @@ -29,7 +29,7 @@ extern "C" { } struct enum_info { - int value; + unsigned int value; const char *name; }; @@ -43,6 +43,36 @@ TEST(EnumStrings, LookUpByNumber) } } +/* + * This test will catch us, when the everything table below hasn't been + * updated. Note that this test might take a while since there is no way to + * linearly walk the enums. + */ +TEST(EnumStrings, InverseLookUpByNumber) +{ + const char *mesa_enum, *dummy = ""; + bool found; + + /* XXX: The 0x limit looks hacky, but it'll do for now */ + for (unsigned i = 0; i < 0x; i++) { + mesa_enum = _mesa_enum_to_string(i); + found = false; + + if (memcmp(mesa_enum, "0x", 2) != 0) { + for (int j = 0; everything[j].name != NULL; j++) { +if (i == everything[j].value) { + found = true; + break; +} + } + + if (!found) +EXPECT_STREQ(mesa_enum, dummy); + } + } +} + + TEST(EnumStrings, LookUpUnknownNumber) { EXPECT_STRCASEEQ("0x", _mesa_enum_to_string(0x)); -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/7] nir: add shader reference counting
On Thu, Nov 5, 2015 at 5:58 PM, Jason Ekstrandwrote: > On Thu, Nov 5, 2015 at 10:53 AM, Rob Clark wrote: >> On Thu, Nov 5, 2015 at 1:13 PM, Jason Ekstrand wrote: >>> On Sat, Oct 24, 2015 at 10:07 AM, Rob Clark wrote: From: Rob Clark For gallium, at least, we'll need this to manage shader's lifetimes, since in some cases both the driver and the state tracker will need to hold on to a reference for variant managing. Use nir_shader_mutable() before doing any IR opt/lowering/etc, to ensure you are not modifying a copy someone else is also holding a reference to. In this way, unnecessary nir_shader_clone()s are avoided whenever possible. TODO: Any places missed to s/ralloc_free()/nir_shader_unref()/ outside of freedreno/ir3? >>> >>> I talked with Ken about this a few days ago, and it doesn't seem like >>> a good idea. Adding reference counting to NIR means mixing two very >>> different memory management models. NIR already uses the ralloc model >>> where a shader is tied to a context. Allowing both ralloc and >>> refcount models is a bad idea because freeing a context could cause >>> the shader to go out-of-scope early from the refcount perspective and >>> refcounting means you don't know what thread the shader is deleted in >>> which is really bad for ralloc. The only way we could do this is if >>> we only used ralloc internally to NIR and disallowed parenting a >>> nir_shader to anything. I don't really think we want this, at least >>> not for the i965 driver. >>> >>> The best option here would probably be to make a little flyweight >>> wrapper object for TGSI to use that acts as the ralloc context for a >>> NIR shader and is, itself, reference-counted. You still have to >>> provide similar guarantees (said object can never have a parent), but >>> it would keep those guarantees obvious. >> >> Hmm, maybe a better idea still (and simpler) would be to just disallow >> nir_shader_ref() if parent memctx is not null? > > Yeah, we could do that. However, we have no way of doing a similar > check to say you can't reparent it if refcount > 1. well, we could always add a nir_shader_reparent().. current state, this all seems a bit hypothetical since nir_shader_create() is always called w/ a NULL parent memctx.. >> This way we can keep the centralized checks for refcnt>1 in the >> nir-pass runner function/macro/whatever.. > > Meh. Call the "get me a unique shader" function in your backend > before you do any transformations on it.. There's no reason to call > it multiple times. If the refcount goes from 1 to > 1 during your > optimization loop, you're sunk anyway. I do actually do this now, but there are places where mesa st will do lowering passes, etc. I do really like the kill-all-birds-with-one-stone approach of putting the check in the nir-pass runner. BR, -R ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 13/13] i965/fs_visitor: do not explicitly set outputs[x].file
On Thu, Nov 5, 2015 at 12:24 PM, Emil Velikovwrote: > On 5 November 2015 at 19:15, Matt Turner wrote: >> On Thu, Nov 5, 2015 at 8:18 AM, Emil Velikov >> wrote: >>> From: Emil Velikov >>> >>> This commits partially reverts "i965: Initialize registers' file to >>> BAD_FILE." >>> >>> No longer needed as of commit "i965/fs: properly construct fs_reg" which >>> removes the memset(...0...), and correctly sets BAD_FILE. >> >> I don't think the problem is that the constructors are doing the wrong >> thing by memsetting the object. The problem is that the constructor >> *isn't being called* :) >> >> fs_reg::init() indeed memsets, but it also sets file = BAD_FILE >> (today, and after my series). >> >> So I think the code you're removing is still needed because the >> problem of not calling the constructors remain. >> >> Maybe I've misunderstood something. > Afaict if one declares an array, the default ctor will be called for > each instance in the list. > > Thus the BAD_FILE will be set. On the other hand - currently we zero > the whole lot (thanks to memset(this->outputs, 0...). Which might be > the prime suspect of the issue here. Ah, yes. I believe you're right. In that case, the memset is just totally unnecessary, isn't it? Maybe I should just remove it in my patch directly? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev