Re: [Mesa-dev] [PATCH 1/5] glsl/linker: Use correct array length when linking inter-stage uniforms and varyings.
On 06/03/2013 01:23 PM, Fabian Bieler wrote: Signed-off-by: Fabian Bieler --- src/glsl/linker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 982fe46..7395ed5 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1147,7 +1147,7 @@ update_array_sizes(struct gl_shader_program *prog) } } -if (size + 1 != var->type->fields.array->length) { +if (size + 1 != var->type->length) { /* If this is a built-in uniform (i.e., it's backed by some * fixed-function state), adjust the number of state slots to * match the new array size. The number of slots per array entry I believe that Paul Berry also noticed this problem recently. I believe this change is correct. Reviewed-by: Ian Romanick ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/5] glsl: Don't copy array of sampler parameters when inlining functions.
On 06/03/2013 01:23 PM, Fabian Bieler wrote: Remove The parameter from the list of parameters and replace the derefs in the function body with the deref of the argument. It seems like the existing code would break for some uses. Is there a piglit test to go along with this change? This is the way scalar sampler variables are handled already. Signed-off-by: Fabian Bieler --- src/glsl/opt_function_inlining.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/opt_function_inlining.cpp b/src/glsl/opt_function_inlining.cpp index 0733d51..25a8ff8 100644 --- a/src/glsl/opt_function_inlining.cpp +++ b/src/glsl/opt_function_inlining.cpp @@ -123,7 +123,7 @@ ir_call::generate_inline(ir_instruction *next_ir) ir_rvalue *param = (ir_rvalue *) param_iter.get(); /* Generate a new variable for the parameter. */ - if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { + if (sig_param->type->get_scalar_type()->is_sampler()) { /* For samplers, we want the inlined sampler references * referencing the passed in sampler variable, since that * will have the location information, which an assignment of @@ -178,7 +178,7 @@ ir_call::generate_inline(ir_instruction *next_ir) ir_instruction *const param = (ir_instruction *) param_iter.get(); ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); - if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { + if (sig_param->type->get_scalar_type()->is_sampler()) { ir_dereference *deref = param->as_dereference(); assert(deref); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/5] glsl: Only call mark_whole_array_access for arrays.
On 06/03/2013 01:23 PM, Fabian Bieler wrote: Otherwise the max_array_access field of scalar variables is set to 0x. This doesn't lead to any errors since that field isn't used for scalar variables but leaving it at zero is probably better. I think this is okay. We don't rely on that field for matrices, which would be the only other possibly meaningful case. Reviewed-by: Ian Romanick Signed-off-by: Fabian Bieler --- src/glsl/ast_to_hir.cpp | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e918ade..f14a5b1 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -656,6 +656,8 @@ validate_assignment(struct _mesa_glsl_parse_state *state, static void mark_whole_array_access(ir_rvalue *access) { + assert(access->type->is_array()); + ir_dereference_variable *deref = access->as_dereference_variable(); if (deref && deref->var) { @@ -763,8 +765,10 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, rhs->type->array_size()); d->type = var->type; } - mark_whole_array_access(rhs); - mark_whole_array_access(lhs); + if (rhs->type->is_array()) { +mark_whole_array_access(rhs); +mark_whole_array_access(lhs); + } } /* Most callers of do_assignment (assign, add_assign, pre_inc/dec, ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/5] glsl: Don't copy array of sampler parameters when inlining functions.
On 2013-06-18 11:05, Ian Romanick wrote: > On 06/03/2013 01:23 PM, Fabian Bieler wrote: >> Remove The parameter from the list of parameters and replace the derefs in >> the >> function body with the deref of the argument. > > It seems like the existing code would break for some uses. Is there a piglit > test to go along with this change? tests/spec/glsl-1.10/execution/samplers/in-parameter-array.shader_test is a basic test for this. Unfortunately I don't see what a shader would have to do to break ir_sampler_replacement_visitor (I presume). If you can point me in the right direction I'll write another test. > >> This is the way scalar sampler variables are handled already. >> >> Signed-off-by: Fabian Bieler >> --- >> src/glsl/opt_function_inlining.cpp | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/src/glsl/opt_function_inlining.cpp >> b/src/glsl/opt_function_inlining.cpp >> index 0733d51..25a8ff8 100644 >> --- a/src/glsl/opt_function_inlining.cpp >> +++ b/src/glsl/opt_function_inlining.cpp >> @@ -123,7 +123,7 @@ ir_call::generate_inline(ir_instruction *next_ir) >> ir_rvalue *param = (ir_rvalue *) param_iter.get(); >> >> /* Generate a new variable for the parameter. */ >> - if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { >> + if (sig_param->type->get_scalar_type()->is_sampler()) { >>/* For samplers, we want the inlined sampler references >> * referencing the passed in sampler variable, since that >> * will have the location information, which an assignment of >> @@ -178,7 +178,7 @@ ir_call::generate_inline(ir_instruction *next_ir) >> ir_instruction *const param = (ir_instruction *) param_iter.get(); >> ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); >> >> - if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { >> + if (sig_param->type->get_scalar_type()->is_sampler()) { >>ir_dereference *deref = param->as_dereference(); >> >>assert(deref); >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/5] glsl: Update array access tracker of function parameters.
On 06/03/2013 01:23 PM, Fabian Bieler wrote: Uniform arrays are subject to beeing shrunk if higher members were not accessed. ^^ being Update the max_array_access flag so array members that were only accessed in the function are not optimized away. This fixes Piglit test spec/glsl-1.10/execution/samplers/in-parameter-array.shader_test. Signed-off-by: Fabian Bieler --- src/glsl/ast_function.cpp | 12 1 file changed, 12 insertions(+) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 00e0c05..9378894 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -322,6 +322,18 @@ generate_call(exec_list *instructions, ir_function_signature *sig, assert (!"Illegal formal parameter mode"); break; } + } else if (formal->type->is_array()) { +/* Update the max_array_access field for array parameters. + * If the max_array_access of the formal parameter is zero, chances + * are we haven't parsed the function yet. Just set the array access + * to the whole array in that case. + */ What will be the size of 'u' in the following vertex shader with this change? Will it be 3 or 16 or something else? Does that change of the definition of foo is in a different compilation unit? float foo(float [16]); uniform float u[32]; void main() { gl_Position = vec4(foo(u)); } float foo(float x[16]) { return x[2]; } +const unsigned max_array_access = (formal->max_array_access != 0) + ? formal->max_array_access : (formal->type->array_size() - 1); +ir_variable *var = actual->whole_variable_referenced(); +if (var) + var->max_array_access = + MAX2(var->max_array_access, max_array_access); } actual_iter.next(); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/5] glsl: Return error_type instead of NULL if element_type() is called on non array type.
On 06/03/2013 01:23 PM, Fabian Bieler wrote: This matches the behavior of field_type() and other get_*_type() methods. I looked through the calls to element_type() and didn't find a caller that depends on the old behavior. I'm a little be uncomfortable with this change. There are a few places where the behavior could change (src/glsl/ast_to_hir.cpp:780 and src/glsl/ast_function.cpp:658). The bigger issue is that error_type was only ever intend to "exist" in ast_to_hir. The intention was that type checking operations could propagate error_type up the tree. A compilation error would be emitted once, and when another expression saw " + " it wouldn't emit another error message. We started off following that idea really well, but we kind of fell of the wagon somewhere along the line. Once compilation as completely transitioned from AST to GLSL IR, it should be impossible to get error_type. That's the intention, anyway. Signed-off-by: Fabian Bieler --- src/glsl/glsl_types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 31e3dd2..362c970 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -213,12 +213,12 @@ struct glsl_type { * Query the type of elements in an array * * \return -* Pointer to the type of elements in the array for array types, or \c NULL -* for non-array types. +* Pointer to the type of elements in the array for array types, or +* \c glsl_type::error_type for non-array types. */ const glsl_type *element_type() const { - return is_array() ? fields.array : NULL; + return is_array() ? fields.array : error_type; } /** ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Initial VA-API state tracker
Hi everyone, the following patches reactivates the initial VA-API state tracker and add matching targets for r600 and radeonsi. It's in a quite early state, only MPEG2 and H264 are support and it is only tested with R600g, but apart from that seems to work quite well. Cheers, Christian. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 02/15] st/va: implement vlVaQueryConfigProfiles
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/config.c | 12 + src/gallium/state_trackers/va/context.c|2 +- src/gallium/state_trackers/va/va_private.h | 37 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index a9c652b..0060973 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -26,16 +26,28 @@ * **/ +#include "pipe/p_screen.h" + +#include "vl/vl_winsys.h" + #include "va_private.h" VAStatus vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_profiles) { + struct pipe_screen *pscreen; + enum pipe_video_profile p; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; *num_profiles = 0; + pscreen = VL_VA_PSCREEN(ctx); + for (p = PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; p <= PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; ++p) + if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_CAP_SUPPORTED)) + profile_list[(*num_profiles)++] = PipeToProfile(p); + return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 3e6ca0a..5940422 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -104,7 +104,7 @@ __vaDriverInit_0_32(VADriverContextP ctx) ctx->version_major = 0; ctx->version_minor = 1; *ctx->vtable = vtable; - ctx->max_profiles = 1; + ctx->max_profiles = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - PIPE_VIDEO_PROFILE_UNKNOWN; ctx->max_entrypoints = 1; ctx->max_attributes = 1; ctx->max_image_formats = 1; diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index adfed8d..5b432a8 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -29,9 +29,46 @@ #ifndef VA_PRIVATE_H #define VA_PRIVATE_H +#include + #include #include +#include "pipe/p_video_enums.h" + +#define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData) +#define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) + +static inline VAProfile +PipeToProfile(enum pipe_video_profile profile) +{ + switch (profile) { + case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: + return VAProfileMPEG2Simple; + case PIPE_VIDEO_PROFILE_MPEG2_MAIN: + return VAProfileMPEG2Main; + case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE: + return VAProfileMPEG4Simple; + case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE: + return VAProfileMPEG4AdvancedSimple; + case PIPE_VIDEO_PROFILE_VC1_SIMPLE: + return VAProfileVC1Simple; + case PIPE_VIDEO_PROFILE_VC1_MAIN: + return VAProfileVC1Main; + case PIPE_VIDEO_PROFILE_VC1_ADVANCED: + return VAProfileVC1Advanced; + case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE: + return VAProfileH264Baseline; + case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: + return VAProfileH264Main; + case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: + return VAProfileH264High; + default: + assert(0); + return -1; + } +} + typedef struct { struct vl_screen *vscreen; } vlVaDriver; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/15] st/va: implement vlVaQueryConfigEntrypoints
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/config.c | 13 + src/gallium/state_trackers/va/va_private.h | 29 2 files changed, 42 insertions(+) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 0060973..38639d0 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -55,11 +55,24 @@ VAStatus vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints) { + struct pipe_screen *pscreen; + enum pipe_video_profile p; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; *num_entrypoints = 0; + p = ProfileToPipe(profile); + if (p == PIPE_VIDEO_PROFILE_UNKNOWN) + return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; + + pscreen = VL_VA_PSCREEN(ctx); + if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_CAP_SUPPORTED)) + return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; + + entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD; + return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 5b432a8..cd6c7d7 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -69,6 +69,35 @@ PipeToProfile(enum pipe_video_profile profile) } } +static inline enum pipe_video_profile +ProfileToPipe(VAProfile profile) +{ + switch (profile) { + case VAProfileMPEG2Simple: + return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; + case VAProfileMPEG2Main: + return PIPE_VIDEO_PROFILE_MPEG2_MAIN; + case VAProfileMPEG4Simple: + return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE; + case VAProfileMPEG4AdvancedSimple: + return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE; + case VAProfileVC1Simple: + return PIPE_VIDEO_PROFILE_VC1_SIMPLE; + case VAProfileVC1Main: + return PIPE_VIDEO_PROFILE_VC1_MAIN; + case VAProfileVC1Advanced: + return PIPE_VIDEO_PROFILE_VC1_ADVANCED; + case VAProfileH264Baseline: + return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; + case VAProfileH264Main: + return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; + case VAProfileH264High: + return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; + default: + return PIPE_VIDEO_PROFILE_UNKNOWN; + } +} + typedef struct { struct vl_screen *vscreen; } vlVaDriver; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/15] st/va: implement vlVaGetConfigAttributes
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/config.c | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 38639d0..14951a1 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -80,10 +80,28 @@ VAStatus vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs) { + int i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + for (i = 0; i < num_attribs; ++i) { + unsigned int value; + switch (attrib_list[i].type) { + case VAConfigAttribRTFormat: + value = VA_RT_FORMAT_YUV420; + break; + case VAConfigAttribRateControl: +value = VA_RC_NONE; + break; + default: + value = VA_ATTRIB_NOT_SUPPORTED; + break; + } + attrib_list[i].value = value; + } + + return VA_STATUS_SUCCESS; } VAStatus -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/15] st/va: implement vlVa(Create|Destroy|Query)Config
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/config.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 14951a1..6779774 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -108,10 +108,26 @@ VAStatus vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id) { + struct pipe_screen *pscreen; + enum pipe_video_profile p; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + p = ProfileToPipe(profile); + if (p == PIPE_VIDEO_PROFILE_UNKNOWN) + return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; + + pscreen = VL_VA_PSCREEN(ctx); + if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_CAP_SUPPORTED)) + return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; + + if (entrypoint != VAEntrypointVLD) + return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; + + *config_id = p; + + return VA_STATUS_SUCCESS; } VAStatus @@ -120,7 +136,7 @@ vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id) if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } VAStatus @@ -130,5 +146,12 @@ vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + *profile = PipeToProfile(config_id); + *entrypoint = VAEntrypointVLD; + + *num_attribs = 1; + attrib_list[0].type = VAConfigAttribRTFormat; + attrib_list[0].value = VA_RT_FORMAT_YUV420; + + return VA_STATUS_SUCCESS; } -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/15] st/va: implement vlVa(Create|Destroy)Surfaces
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/context.c|9 src/gallium/state_trackers/va/surface.c| 61 +++- src/gallium/state_trackers/va/va_private.h | 22 ++ 3 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 5940422..51eb259 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -30,6 +30,7 @@ #include "pipe/p_video_decoder.h" #include "util/u_memory.h" +#include "util/u_handle_table.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -100,6 +101,13 @@ __vaDriverInit_0_32(VADriverContextP ctx) return VA_STATUS_ERROR_ALLOCATION_FAILED; } + drv->htab = handle_table_create(); + if (!drv->htab) { + vl_screen_destroy(drv->vscreen); + FREE(drv); + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + ctx->pDriverData = (void *)drv; ctx->version_major = 0; ctx->version_minor = 1; @@ -145,6 +153,7 @@ vlVaTerminate(VADriverContextP ctx) drv = ctx->pDriverData; vl_screen_destroy(drv->vscreen); + handle_table_destroy(drv->htab); FREE(drv); return VA_STATUS_SUCCESS; diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 56356e4..5b54d7c 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -26,28 +26,85 @@ * **/ +#include "pipe/p_screen.h" + +#include "util/u_memory.h" +#include "util/u_handle_table.h" +#include "vl/vl_winsys.h" + #include "va_private.h" VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, int num_surfaces, VASurfaceID *surfaces) { + struct pipe_video_buffer templat = {}; + struct pipe_screen *pscreen; + vlVaDriver *drv; + int i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; if (!(width && height)) return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + pscreen = VL_VA_PSCREEN(ctx); + + templat.buffer_format = pscreen->get_video_param + ( + pscreen, + PIPE_VIDEO_PROFILE_UNKNOWN, + PIPE_VIDEO_CAP_PREFERED_FORMAT + ); + templat.chroma_format = ChromaToPipe(format); + templat.width = width; + templat.height = height; + templat.interlaced = pscreen->get_video_param + ( + pscreen, + PIPE_VIDEO_PROFILE_UNKNOWN, + PIPE_VIDEO_CAP_PREFERS_INTERLACED + ); + + for (i = 0; i < num_surfaces; ++i) { + vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface)); + if (!surf) + goto no_res; + + surf->templat = templat; + surfaces[i] = handle_table_add(drv->htab, surf); + } + + return VA_STATUS_SUCCESS; + +no_res: + if (i) + vlVaDestroySurfaces(ctx, surfaces, i); + + return VA_STATUS_ERROR_ALLOCATION_FAILED; } VAStatus vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces) { + vlVaDriver *drv; + int i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + for (i = 0; i < num_surfaces; ++i) { + vlVaSurface *surf = handle_table_get(drv->htab, surface_list[i]); + if (surf->buffer) + surf->buffer->destroy(surf->buffer); + FREE(surf); + handle_table_remove(drv->htab, surface_list[i]); + } + + return VA_STATUS_SUCCESS; } VAStatus diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index cd6c7d7..88418f9 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -35,10 +35,27 @@ #include #include "pipe/p_video_enums.h" +#include "pipe/p_video_decoder.h" #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData) #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) +static inline enum pipe_video_chroma_format +ChromaToPipe(int format) +{ + switch (format) { + case VA_RT_FORMAT_YUV420: + return PIPE_VIDEO_CHROMA_FORMAT_420; + case VA_RT_FORMAT_YUV422: + return PIPE_VIDEO_CHROMA_FORMAT_422; + case VA_RT_FORMAT_YUV444: + return PIPE_VIDEO_CHROMA_FORMAT_444; + default: + assert(0); + return PIPE_VIDEO_CHROMA_FORMAT_420; + } +} + static inline VAProfile PipeToProfile(enum pipe_video_profile profile) { @@ -100,8 +117,13 @@ ProfileToPipe(VAProfile profile) typedef struct { struct vl_screen *vscreen; + struct handle_table *htab; } vlVaDriver; +typedef struct { + struct pipe_video_buffer templat, *buffer; +} vlVaSurface; + // Public functions: VAStatus __vaDriverInit_0_32(VADriverContextP ctx); -- 1.7.9.5 ___ mesa-dev mailin
[Mesa-dev] [PATCH 07/15] st/va: implement vlVa(Create|Destroy)Context
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/context.c| 71 +++- src/gallium/state_trackers/va/va_private.h | 12 + 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 51eb259..d535a6b 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -96,17 +96,16 @@ __vaDriverInit_0_32(VADriverContextP ctx) return VA_STATUS_ERROR_ALLOCATION_FAILED; drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen); - if (!drv->vscreen) { - FREE(drv); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } + if (!drv->vscreen) + goto error_screen; + + drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, drv->vscreen); + if (!drv->pipe) + goto error_pipe; drv->htab = handle_table_create(); - if (!drv->htab) { - vl_screen_destroy(drv->vscreen); - FREE(drv); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } + if (!drv->htab) + goto error_htab; ctx->pDriverData = (void *)drv; ctx->version_major = 0; @@ -121,26 +120,71 @@ __vaDriverInit_0_32(VADriverContextP ctx) ctx->str_vendor = "mesa gallium vaapi"; return VA_STATUS_SUCCESS; + +error_htab: + drv->pipe->destroy(drv->pipe); + +error_pipe: + vl_screen_destroy(drv->vscreen); + +error_screen: + FREE(drv); + return VA_STATUS_ERROR_ALLOCATION_FAILED; } VAStatus vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, int picture_height, int flag, VASurfaceID *render_targets, - int num_render_targets, VAContextID *conext) + int num_render_targets, VAContextID *context_id) { + vlVaDriver *drv; + vlVaContext *context; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + if (!(picture_width && picture_height)) + return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; + + drv = VL_VA_DRIVER(ctx); + context = CALLOC(1, sizeof(vlVaContext)); + if (!context) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + context->decoder = drv->pipe->create_video_decoder + ( + drv->pipe, config_id, + PIPE_VIDEO_ENTRYPOINT_BITSTREAM, + PIPE_VIDEO_CHROMA_FORMAT_420, + picture_width, picture_height, num_render_targets, + true + ); + if (!context->decoder) { + FREE(context); + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + + context->desc.base.profile = config_id; + *context_id = handle_table_add(drv->htab, context); + + return VA_STATUS_SUCCESS; } VAStatus -vlVaDestroyContext(VADriverContextP ctx, VAContextID context) +vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) { + vlVaDriver *drv; + vlVaContext *context; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + context = handle_table_get(drv->htab, context_id); + context->decoder->destroy(context->decoder); + FREE(context); + + return VA_STATUS_SUCCESS; } VAStatus @@ -152,6 +196,7 @@ vlVaTerminate(VADriverContextP ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; drv = ctx->pDriverData; + drv->pipe->destroy(drv->pipe); vl_screen_destroy(drv->vscreen); handle_table_destroy(drv->htab); FREE(drv); diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 88418f9..fcc1c59 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -117,10 +117,22 @@ ProfileToPipe(VAProfile profile) typedef struct { struct vl_screen *vscreen; + struct pipe_context *pipe; struct handle_table *htab; } vlVaDriver; typedef struct { + struct pipe_video_decoder *decoder; + union { + struct pipe_picture_desc base; + struct pipe_mpeg12_picture_desc mpeg12; + struct pipe_mpeg4_picture_desc mpeg4; + struct pipe_vc1_picture_desc vc1; + struct pipe_h264_picture_desc h264; + } desc; +} vlVaContext; + +typedef struct { struct pipe_video_buffer templat, *buffer; } vlVaSurface; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/15] st/va: implement vlVaPutSurface
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/context.c|6 src/gallium/state_trackers/va/surface.c| 50 ++-- src/gallium/state_trackers/va/va_private.h |6 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index d535a6b..b3c5757 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -107,6 +107,12 @@ __vaDriverInit_0_32(VADriverContextP ctx) if (!drv->htab) goto error_htab; + vl_compositor_init(&drv->compositor, drv->pipe); + vl_compositor_init_state(&drv->cstate, drv->pipe); + + vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &drv->csc); + vl_compositor_set_csc_matrix(&drv->cstate, (const vl_csc_matrix *)&drv->csc); + ctx->pDriverData = (void *)drv; ctx->version_major = 0; ctx->version_minor = 1; diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 7641ded..58303c6 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -31,6 +31,9 @@ #include "util/u_memory.h" #include "util/u_handle_table.h" +#include "util/u_rect.h" + +#include "vl/vl_compositor.h" #include "vl/vl_winsys.h" #include "va_private.h" @@ -136,15 +139,58 @@ vlVaQuerySurfaceError(VADriverContextP ctx, VASurfaceID render_target, VAStatus } VAStatus -vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, short srcy, +vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface_id, void* draw, short srcx, short srcy, unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags) { + vlVaDriver *drv; + vlVaSurface *surf; + struct pipe_resource *tex; + struct pipe_surface surf_templ, *surf_draw; + struct u_rect src_rect, *dirty_area; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + surf = handle_table_get(drv->htab, surface_id); + if (!surf) + return VA_STATUS_ERROR_INVALID_SURFACE; + + tex = vl_screen_texture_from_drawable(drv->vscreen, (Drawable)draw); + if (!tex) + return VA_STATUS_ERROR_INVALID_DISPLAY; + + dirty_area = vl_screen_get_dirty_area(drv->vscreen); + + memset(&surf_templ, 0, sizeof(surf_templ)); + surf_templ.format = tex->format; + surf_draw = drv->pipe->create_surface(drv->pipe, tex, &surf_templ); + if (!surf_draw) { + pipe_resource_reference(&tex, NULL); + return VA_STATUS_ERROR_INVALID_DISPLAY; + } + + src_rect.x0 = srcx; + src_rect.y0 = srcy; + src_rect.x1 = srcw + srcx; + src_rect.y1 = srch + srcy; + + vl_compositor_clear_layers(&drv->cstate); + vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, surf->buffer, &src_rect, NULL, VL_COMPOSITOR_WEAVE); + vl_compositor_render(&drv->cstate, &drv->compositor, surf_draw, dirty_area, true); + + drv->pipe->screen->flush_frontbuffer + ( + drv->pipe->screen, tex, 0, 0, + vl_screen_get_private(drv->vscreen) + ); + + pipe_resource_reference(&tex, NULL); + pipe_surface_reference(&surf_draw, NULL); + + return VA_STATUS_SUCCESS; } VAStatus diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 58b787d..ebbbedd 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -37,6 +37,9 @@ #include "pipe/p_video_enums.h" #include "pipe/p_video_state.h" +#include "vl/vl_compositor.h" +#include "vl/vl_csc.h" + #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData) #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) @@ -119,6 +122,9 @@ typedef struct { struct vl_screen *vscreen; struct pipe_context *pipe; struct handle_table *htab; + struct vl_compositor compositor; + struct vl_compositor_state cstate; + vl_csc_matrix csc; } vlVaDriver; typedef struct { -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/15] st/va: implement vlVa(Create|Destroy)Buffer
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/buffer.c | 83 +--- src/gallium/state_trackers/va/va_private.h |7 +++ 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 5610775..c672484 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -26,6 +26,9 @@ * **/ +#include "util/u_memory.h" +#include "util/u_handle_table.h" + #include "va_private.h" VAStatus @@ -33,55 +36,121 @@ vlVaCreateBuffer(VADriverContextP ctx, VAContextID context, VABufferType type, unsigned int size, unsigned int num_elements, void *data, VABufferID *buf_id) { + vlVaBuffer *buf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + buf = CALLOC(1, sizeof(vlVaBuffer)); + if (!buf) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + buf->type = type; + buf->size = size; + buf->num_elements = num_elements; + buf->data = MALLOC(size * num_elements); + + if (!buf->data) { + FREE(buf); + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + + if (data) + memcpy(buf->data, data, size * num_elements); + + *buf_id = handle_table_add(VL_VA_DRIVER(ctx)->htab, buf); + + return VA_STATUS_SUCCESS; } VAStatus vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, unsigned int num_elements) { + vlVaBuffer *buf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + buf->data = REALLOC(buf->data, buf->size * buf->num_elements, + buf->size * num_elements); + buf->num_elements = num_elements; + + if (!buf->data) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + return VA_STATUS_SUCCESS; } VAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) { + vlVaBuffer *buf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + *pbuff = buf->data; + + return VA_STATUS_SUCCESS; } VAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) { + vlVaBuffer *buf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + /* Nothing to do here */ + + return VA_STATUS_SUCCESS; } VAStatus -vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buffer_id) +vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) { + vlVaBuffer *buf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + FREE(buf->data); + FREE(buf); + + return VA_STATUS_SUCCESS; } VAStatus vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type, unsigned int *size, unsigned int *num_elements) { + vlVaBuffer *buf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id); + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + *type = buf->type; + *size = buf->size; + *num_elements = buf->num_elements; + + return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index fcc1c59..caa8c4a 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -133,6 +133,13 @@ typedef struct { } vlVaContext; typedef struct { + VABufferType type; + unsigned int size; + unsigned int num_elements; + void *data; +} vlVaBuffer; + +typedef struct { struct pipe_video_buffer templat, *buffer; } vlVaSurface; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/15] st/va: implement vlVa(Begin|Render|End)Picture
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/picture.c| 88 ++-- src/gallium/state_trackers/va/surface.c|3 +- src/gallium/state_trackers/va/va_private.h |5 +- 3 files changed, 87 insertions(+), 9 deletions(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 66612b8..8d16dfa 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -26,31 +26,107 @@ * **/ +#include "pipe/p_video_decoder.h" + +#include "util/u_handle_table.h" + #include "va_private.h" VAStatus -vlVaBeginPicture(VADriverContextP ctx, VAContextID context, VASurfaceID render_target) +vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID render_target) { + vlVaDriver *drv; + vlVaContext *context; + vlVaSurface *surf; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + context = handle_table_get(drv->htab, context_id); + if (!context) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + surf = handle_table_get(drv->htab, render_target); + if (!surf || !surf->buffer) + return VA_STATUS_ERROR_INVALID_SURFACE; + + context->target = surf->buffer; + context->decoder->begin_frame(context->decoder, context->target, NULL); + + return VA_STATUS_SUCCESS; } VAStatus -vlVaRenderPicture(VADriverContextP ctx, VAContextID context, VABufferID *buffers, int num_buffers) +vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buffers, int num_buffers) { + vlVaDriver *drv; + vlVaContext *context; + + unsigned i; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + context = handle_table_get(drv->htab, context_id); + if (!context) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + for (i = 0; i < num_buffers; ++i) { + vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]); + if (!buf) + return VA_STATUS_ERROR_INVALID_BUFFER; + + switch (buf->type) { + case VAPictureParameterBufferType: + // TODO + break; + + case VAIQMatrixBufferType: + // TODO + break; + + case VASliceParameterBufferType: + // TODO + break; + + case VASliceDataBufferType: + // TODO + break; + + default: + return VA_STATUS_ERROR_INVALID_BUFFER; + } + } + + return VA_STATUS_SUCCESS; } VAStatus -vlVaEndPicture(VADriverContextP ctx, VAContextID context) +vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) { + vlVaDriver *drv; + vlVaContext *context; + if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + drv = VL_VA_DRIVER(ctx); + if (!drv) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + context = handle_table_get(drv->htab, context_id); + if (!context) + return VA_STATUS_ERROR_INVALID_CONTEXT; + + context->decoder->end_frame(context->decoder, context->target, &context->desc.base); + + return VA_STATUS_SUCCESS; } diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 5b54d7c..7641ded 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -27,6 +27,7 @@ **/ #include "pipe/p_screen.h" +#include "pipe/p_video_decoder.h" #include "util/u_memory.h" #include "util/u_handle_table.h" @@ -73,7 +74,7 @@ vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format, if (!surf) goto no_res; - surf->templat = templat; + surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat); surfaces[i] = handle_table_add(drv->htab, surf); } diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index caa8c4a..58b787d 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -35,7 +35,7 @@ #include #include "pipe/p_video_enums.h" -#include "pipe/p_video_decoder.h" +#include "pipe/p_video_state.h" #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData) #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen) @@ -123,6 +123,7 @@ typedef struct { typedef struct { struct pipe_video_decoder *decoder; + struct pipe_video_buffer *target; union { struct pipe_picture_desc base; struct pipe_mpeg12_picture_desc mpeg12; @@ -140,7 +141,7 @@ typedef struct { } vlVaBuffer; typedef struct { - struct
[Mesa-dev] [PATCH 11/15] st/va: let vlVaSyncSurface suceed
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/surface.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 58303c6..34786c1 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -117,7 +117,7 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target) if (!ctx) return VA_STATUS_ERROR_INVALID_CONTEXT; - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } VAStatus -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/15] st/va: handle VAIQMatrixBufferMPEG2
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/picture.c | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 8d16dfa..66cd6ca 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -29,6 +29,7 @@ #include "pipe/p_video_decoder.h" #include "util/u_handle_table.h" +#include "util/u_video.h" #include "va_private.h" @@ -60,6 +61,32 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende return VA_STATUS_SUCCESS; } +static void +handleIQMatrixBuffer(vlVaContext *context, vlVaBuffer *buf) +{ + VAIQMatrixBufferMPEG2 *mpeg2; + + switch (u_reduce_video_profile(context->decoder->profile)) { + case PIPE_VIDEO_CODEC_MPEG12: + assert(buf->size >= sizeof(VAIQMatrixBufferMPEG2) && buf->num_elements == 1); + mpeg2 = buf->data; + + if (mpeg2->load_intra_quantiser_matrix) + context->desc.mpeg12.intra_matrix = mpeg2->intra_quantiser_matrix; + else + context->desc.mpeg12.intra_matrix = NULL; + + if (mpeg2->load_non_intra_quantiser_matrix) + context->desc.mpeg12.non_intra_matrix = mpeg2->non_intra_quantiser_matrix; + else + context->desc.mpeg12.non_intra_matrix = NULL; + break; + + default: + break; + } +} + VAStatus vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buffers, int num_buffers) { @@ -90,7 +117,7 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff break; case VAIQMatrixBufferType: - // TODO + handleIQMatrixBuffer(context, buf); break; case VASliceParameterBufferType: -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/15] st/va: handle VAPictureParameterBufferMPEG2
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/picture.c | 51 ++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 66cd6ca..f7d32c6 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -62,6 +62,55 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende } static void +getReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id, + struct pipe_video_buffer **ref_frame) +{ + vlVaSurface *surf = handle_table_get(drv->htab, surface_id); + if (surf) + *ref_frame = surf->buffer; + else + *ref_frame = NULL; +} + +static void +handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) +{ + VAPictureParameterBufferMPEG2 *mpeg2; + + switch (u_reduce_video_profile(context->decoder->profile)) { + case PIPE_VIDEO_CODEC_MPEG12: + assert(buf->size >= sizeof(VAPictureParameterBufferMPEG2) && buf->num_elements == 1); + mpeg2 = buf->data; + + /*horizontal_size;*/ + /*vertical_size;*/ + getReferenceFrame(drv, mpeg2->forward_reference_picture, &context->desc.mpeg12.ref[0]); + getReferenceFrame(drv, mpeg2->backward_reference_picture, &context->desc.mpeg12.ref[1]); + context->desc.mpeg12.picture_coding_type = mpeg2->picture_coding_type; + context->desc.mpeg12.f_code[0][0] = ((mpeg2->f_code >> 12) & 0xf) - 1; + context->desc.mpeg12.f_code[0][1] = ((mpeg2->f_code >> 8) & 0xf) - 1; + context->desc.mpeg12.f_code[1][0] = ((mpeg2->f_code >> 4) & 0xf) - 1; + context->desc.mpeg12.f_code[1][1] = (mpeg2->f_code & 0xf) - 1; + context->desc.mpeg12.intra_dc_precision = mpeg2->picture_coding_extension.bits.intra_dc_precision; + context->desc.mpeg12.picture_structure = mpeg2->picture_coding_extension.bits.picture_structure; + context->desc.mpeg12.top_field_first = mpeg2->picture_coding_extension.bits.top_field_first; + context->desc.mpeg12.frame_pred_frame_dct = mpeg2->picture_coding_extension.bits.frame_pred_frame_dct; + context->desc.mpeg12.concealment_motion_vectors = mpeg2->picture_coding_extension.bits.concealment_motion_vectors; + context->desc.mpeg12.q_scale_type = mpeg2->picture_coding_extension.bits.q_scale_type; + context->desc.mpeg12.intra_vlc_format = mpeg2->picture_coding_extension.bits.intra_vlc_format; + context->desc.mpeg12.alternate_scan = mpeg2->picture_coding_extension.bits.alternate_scan; + /*repeat_first_field*/ + /*progressive_frame*/ + /*is_first_field*/ + + break; + + default: + break; + } +} + +static void handleIQMatrixBuffer(vlVaContext *context, vlVaBuffer *buf) { VAIQMatrixBufferMPEG2 *mpeg2; @@ -113,7 +162,7 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff switch (buf->type) { case VAPictureParameterBufferType: - // TODO + handlePictureParameterBuffer(drv, context, buf); break; case VAIQMatrixBufferType: -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/15] st/va: try to decode something
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/picture.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index f7d32c6..7339366 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -174,7 +174,8 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff break; case VASliceDataBufferType: - // TODO + context->decoder->decode_bitstream(context->decoder, context->target, NULL, +1, (const void * const*)&buf->data, &buf->size); break; default: -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 15/15] st/va: add support for H264
From: Christian König Signed-off-by: Christian König --- src/gallium/state_trackers/va/picture.c | 100 ++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 7339366..1c7a1dc 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -31,6 +31,8 @@ #include "util/u_handle_table.h" #include "util/u_video.h" +#include "vl/vl_vlc.h" + #include "va_private.h" VAStatus @@ -76,6 +78,7 @@ static void handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { VAPictureParameterBufferMPEG2 *mpeg2; + VAPictureParameterBufferH264 *h264; switch (u_reduce_video_profile(context->decoder->profile)) { case PIPE_VIDEO_CODEC_MPEG12: @@ -105,6 +108,50 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer * break; + case PIPE_VIDEO_CODEC_MPEG4_AVC: + assert(buf->size >= sizeof(VAPictureParameterBufferH264) && buf->num_elements == 1); + h264 = buf->data; + + /*CurrPic*/ + context->desc.h264.field_order_cnt[0] = h264->CurrPic.TopFieldOrderCnt; + context->desc.h264.field_order_cnt[1] = h264->CurrPic.BottomFieldOrderCnt; + /*ReferenceFrames[16]*/ + /*picture_width_in_mbs_minus1*/ + /*picture_height_in_mbs_minus1*/ + /*bit_depth_luma_minus8*/ + /*bit_depth_chroma_minus8*/ + context->desc.h264.num_ref_frames = h264->num_ref_frames; + /*chroma_format_idc*/ + /*residual_colour_transform_flag*/ + /*gaps_in_frame_num_value_allowed_flag*/ + context->desc.h264.frame_mbs_only_flag = h264->seq_fields.bits.frame_mbs_only_flag; + context->desc.h264.mb_adaptive_frame_field_flag = h264->seq_fields.bits.mb_adaptive_frame_field_flag; + context->desc.h264.direct_8x8_inference_flag = h264->seq_fields.bits.direct_8x8_inference_flag; + /*MinLumaBiPredSize8x8*/ + context->desc.h264.log2_max_frame_num_minus4 = h264->seq_fields.bits.log2_max_frame_num_minus4; + context->desc.h264.pic_order_cnt_type = h264->seq_fields.bits.pic_order_cnt_type; + context->desc.h264.log2_max_pic_order_cnt_lsb_minus4 = h264->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4; + context->desc.h264.delta_pic_order_always_zero_flag = h264->seq_fields.bits.delta_pic_order_always_zero_flag; + /*num_slice_groups_minus1*/ + /*slice_group_map_type*/ + /*slice_group_change_rate_minus1*/ + context->desc.h264.pic_init_qp_minus26 = h264->pic_init_qp_minus26; + /*pic_init_qs_minus26*/ + context->desc.h264.chroma_qp_index_offset = h264->chroma_qp_index_offset; + context->desc.h264.second_chroma_qp_index_offset = h264->second_chroma_qp_index_offset; + context->desc.h264.entropy_coding_mode_flag = h264->pic_fields.bits.entropy_coding_mode_flag; + context->desc.h264.weighted_pred_flag = h264->pic_fields.bits.weighted_pred_flag; + context->desc.h264.weighted_bipred_idc = h264->pic_fields.bits.weighted_bipred_idc; + context->desc.h264.transform_8x8_mode_flag = h264->pic_fields.bits.transform_8x8_mode_flag; + context->desc.h264.field_pic_flag = h264->pic_fields.bits.field_pic_flag; + context->desc.h264.constrained_intra_pred_flag = h264->pic_fields.bits.constrained_intra_pred_flag; + context->desc.h264.pic_order_present_flag = h264->pic_fields.bits.pic_order_present_flag; + context->desc.h264.deblocking_filter_control_present_flag = h264->pic_fields.bits.deblocking_filter_control_present_flag; + context->desc.h264.redundant_pic_cnt_present_flag = h264->pic_fields.bits.redundant_pic_cnt_present_flag; + /*reference_pic_flag*/ + context->desc.h264.frame_num = h264->frame_num; + break; + default: break; } @@ -114,6 +161,7 @@ static void handleIQMatrixBuffer(vlVaContext *context, vlVaBuffer *buf) { VAIQMatrixBufferMPEG2 *mpeg2; + VAIQMatrixBufferH264 *h264; switch (u_reduce_video_profile(context->decoder->profile)) { case PIPE_VIDEO_CODEC_MPEG12: @@ -131,11 +179,60 @@ handleIQMatrixBuffer(vlVaContext *context, vlVaBuffer *buf) context->desc.mpeg12.non_intra_matrix = NULL; break; + case PIPE_VIDEO_CODEC_MPEG4_AVC: + assert(buf->size >= sizeof(VAIQMatrixBufferH264) && buf->num_elements == 1); + h264 = buf->data; + + memcpy(&context->desc.h264.scaling_lists_4x4, h264->ScalingList4x4, 6 * 16); + memcpy(&context->desc.h264.scaling_lists_8x8, h264->ScalingList8x8, 2 * 64); + break; + default: break; } } +static void +handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf) +{ + unsigned num_buffers = 0; + void * const *buffers[2]; + unsigned sizes[2]; + + if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_CODEC_MPEG4_AVC) { + static const uint8_t start_code[] = { 0x00, 0x00, 0x
Re: [Mesa-dev] [PATCH 5/5] glsl: Update array access tracker of function parameters.
On 2013-06-18 11:14, Ian Romanick wrote: > On 06/03/2013 01:23 PM, Fabian Bieler wrote: >> Uniform arrays are subject to beeing shrunk if higher members were not >> accessed. > ^^ > being > >> Update the max_array_access flag so array members that were only accessed in >> the function are not optimized away. >> >> This fixes Piglit test >> spec/glsl-1.10/execution/samplers/in-parameter-array.shader_test. >> >> Signed-off-by: Fabian Bieler >> --- >> src/glsl/ast_function.cpp | 12 >> 1 file changed, 12 insertions(+) >> >> diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp >> index 00e0c05..9378894 100644 >> --- a/src/glsl/ast_function.cpp >> +++ b/src/glsl/ast_function.cpp >> @@ -322,6 +322,18 @@ generate_call(exec_list *instructions, >> ir_function_signature *sig, >> assert (!"Illegal formal parameter mode"); >> break; >>} >> + } else if (formal->type->is_array()) { >> + /* Update the max_array_access field for array parameters. >> + * If the max_array_access of the formal parameter is zero, chances >> + * are we haven't parsed the function yet. Just set the array access >> + * to the whole array in that case. >> + */ > > What will be the size of 'u' in the following vertex shader with this change? > Will it be 3 or 16 or something else? Does that change of the definition of > foo is in a different compilation unit? It would be 16 and it doesn't change if the function is in a different compilation unit. If we wanted it to be 3 we would have to update the array access tracker later. I thought about doing it during function inlining since currently all functions are always inlined for all drivers, but that's of course somewhat of a hack. > > float foo(float [16]); > > uniform float u[32]; I'm assuming you meant u[16], otherwise this doesn't compile. > > void main() > { > gl_Position = vec4(foo(u)); > } > > float foo(float x[16]) > { > return x[2]; > } > >> + const unsigned max_array_access = (formal->max_array_access != 0) >> +? formal->max_array_access : (formal->type->array_size() - 1); >> + ir_variable *var = actual->whole_variable_referenced(); >> + if (var) >> +var->max_array_access = >> + MAX2(var->max_array_access, max_array_access); >> } >> >> actual_iter.next(); >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/5] glsl: Return error_type instead of NULL if element_type() is called on non array type.
On 2013-06-18 11:24, Ian Romanick wrote: > On 06/03/2013 01:23 PM, Fabian Bieler wrote: >> This matches the behavior of field_type() and other get_*_type() methods. >> >> I looked through the calls to element_type() and didn't find a caller that >> depends on the old behavior. > > I'm a little be uncomfortable with this change. There are a few places where > the behavior could change (src/glsl/ast_to_hir.cpp:780 and > src/glsl/ast_function.cpp:658). The bigger issue is that error_type was only > ever intend to "exist" in ast_to_hir. The intention was that type checking > operations could propagate error_type up the tree. A compilation error would > be emitted once, and when another expression saw " + " it > wouldn't emit another error message. We started off following that idea > really well, but we kind of fell of the wagon somewhere along the line. I see. Please disregard this patch, then. > > Once compilation as completely transitioned from AST to GLSL IR, it should be > impossible to get error_type. That's the intention, anyway. Thanks for pointing that out to me. > >> Signed-off-by: Fabian Bieler >> --- >> src/glsl/glsl_types.h | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h >> index 31e3dd2..362c970 100644 >> --- a/src/glsl/glsl_types.h >> +++ b/src/glsl/glsl_types.h >> @@ -213,12 +213,12 @@ struct glsl_type { >> * Query the type of elements in an array >> * >> * \return >> -* Pointer to the type of elements in the array for array types, or \c >> NULL >> -* for non-array types. >> +* Pointer to the type of elements in the array for array types, or >> +* \c glsl_type::error_type for non-array types. >> */ >> const glsl_type *element_type() const >> { >> - return is_array() ? fields.array : NULL; >> + return is_array() ? fields.array : error_type; >> } >> >> /** >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/6] mesa: Move the common _mesa_glsl_compile_shader() code to glsl/.
On 06/17/2013 04:10 PM, Eric Anholt wrote: ... and move the mesa-core-specific code into Mesa core. This code had no relation to ir_to_mesa.cpp, since it was also used by intel and state_tracker, and most of it was duplicated with the standalone compiler (which has periodically drifted from the Mesa copy). --- src/glsl/glsl_parser_extras.cpp | 83 src/glsl/glsl_parser_extras.h | 2 + src/glsl/main.cpp | 59 +- src/glsl/program.h | 16 ++- src/mesa/main/shaderapi.c | 57 - src/mesa/program/ir_to_mesa.cpp | 94 - src/mesa/program/ir_to_mesa.h | 1 - 7 files changed, 146 insertions(+), 166 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 7b827ba..f142d73 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -28,6 +28,7 @@ extern "C" { #include "main/core.h" /* for struct gl_context */ #include "main/context.h" +#include "main/shaderobj.h" } #include "ralloc.h" @@ -1237,6 +1238,88 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier, this->declarations.push_degenerate_list_at_head(&declarator_list->link); } +extern "C" { + +void +_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, + bool dump_ast, bool dump_hir) +{ + struct _mesa_glsl_parse_state *state = + new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); + const char *source = shader->Source; + + state->error = glcpp_preprocess(state, &source, &state->info_log, +&ctx->Extensions, ctx); + + if (!state->error) { + _mesa_glsl_lexer_ctor(state, source); + _mesa_glsl_parse(state); + _mesa_glsl_lexer_dtor(state); + } + + if (dump_ast) { + foreach_list_const(n, &state->translation_unit) { +ast_node *ast = exec_node_data(ast_node, n, link); +ast->print(); + } + printf("\n\n"); + } + + ralloc_free(shader->ir); + shader->ir = new(shader) exec_list; + if (!state->error && !state->translation_unit.is_empty()) + _mesa_ast_to_hir(shader->ir, state); + + if (!state->error) { + validate_ir_tree(shader->ir); + + /* Print out the unoptimized IR. */ + if (dump_hir) { +_mesa_print_ir(shader->ir, state); + } + } + + + if (!state->error && !shader->ir->is_empty()) { + struct gl_shader_compiler_options *options = + &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; + + /* Do some optimization at compile time to reduce shader IR size + * and reduce later work if the same shader is linked multiple times + */ + while (do_common_optimization(shader->ir, false, false, 32, options)) +; + + validate_ir_tree(shader->ir); + } + + if (shader->InfoLog) + ralloc_free(shader->InfoLog); + + shader->symbols = state->symbols; + shader->CompileStatus = !state->error; + shader->InfoLog = state->info_log; + shader->Version = state->language_version; + shader->InfoLog = state->info_log; + shader->IsES = state->es_shader; + + memcpy(shader->builtins_to_link, state->builtins_to_link, + sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); + shader->num_builtins_to_link = state->num_builtins_to_link; + + if (shader->UniformBlocks) + ralloc_free(shader->UniformBlocks); + shader->NumUniformBlocks = state->num_uniform_blocks; + shader->UniformBlocks = state->uniform_blocks; + ralloc_steal(shader, shader->UniformBlocks); + + /* Retain any live IR, but trash the rest. */ + reparent_ir(shader->ir, shader->ir); + + ralloc_free(state); +} + +} /* extern "C" */ /** * Do the set of common optimizations passes * The above change looks good. It makes a lot of sense for this to be in the compiler. There are tabs, if you care. Not a big deal either way. diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 7f478df..cf296e9 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -342,6 +342,8 @@ extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); +extern void compile_shader(); + /** * Process elements of the #extension directive * I am bewildered by this hunk. There are compile_shader() functions in both glsl/main.cpp and mesa/main/shaderapi.c, but both of those are static, and your patch doesn't change that. I can't find /anything/ that this would refer to. It almost looks like you split things differently in an earlier version of the patch and this got left in. diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 5713ee5..60bc628 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -143,70 +143,13 @@ compile_shader(struct
Re: [Mesa-dev] [PATCH 3/6] glsl: Remove ir_print_visitor.h includes and usage
On 06/17/2013 04:10 PM, Eric Anholt wrote: We have ir->print() to do the old declaration of a visitor and having the IR accept the visitor (yuck!). And now you can call _mesa_print_ir() safely anywhere that you know what an ir_instruction is. A couple of missing printf("\n")s are added in error paths -- when an expression is handed to the visitor, it doesn't print '\n' (since it might be a step in printing a whole expression tree). This is pretty obviously three separate changes: - Fixing missing '\n' characters - Converting from ir_print_visitor v; ir->accept(&v); to ir->print() - Removing unnecessary #include files. But that is being pedantic, so I'm not going to make you redo it. As is, patches 1-3 are: Reviewed-by: Kenneth Graunke --- src/glsl/ir_rvalue_visitor.cpp | 1 - src/glsl/main.cpp | 1 - src/glsl/opt_array_splitting.cpp| 1 - src/glsl/opt_noop_swizzle.cpp | 1 - src/glsl/opt_structure_splitting.cpp| 1 - src/glsl/test_optpass.cpp | 1 - src/mesa/drivers/dri/i965/brw_fs.cpp| 1 - src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 1 - src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 1 - src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp | 1 - src/mesa/drivers/dri/i965/brw_fs_visitor.cpp| 5 ++--- src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp | 1 - src/mesa/drivers/dri/i965/brw_shader.cpp| 1 - src/mesa/drivers/dri/i965/brw_vec4.cpp | 1 - src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp | 1 - src/mesa/main/ff_fragment_shader.cpp| 1 - src/mesa/program/ir_to_mesa.cpp | 9 - src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 ++--- 18 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/glsl/ir_rvalue_visitor.cpp b/src/glsl/ir_rvalue_visitor.cpp index 3504a4d..8eb1c62 100644 --- a/src/glsl/ir_rvalue_visitor.cpp +++ b/src/glsl/ir_rvalue_visitor.cpp @@ -32,7 +32,6 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_rvalue_visitor.h" -#include "ir_print_visitor.h" #include "glsl_types.h" ir_visitor_status diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index d7e35bc..5713ee5 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -34,7 +34,6 @@ #include "ast.h" #include "glsl_parser_extras.h" #include "ir_optimization.h" -#include "ir_print_visitor.h" #include "program.h" #include "loop_analysis.h" #include "standalone_scaffolding.h" diff --git a/src/glsl/opt_array_splitting.cpp b/src/glsl/opt_array_splitting.cpp index 67733ca..f4a7ef9 100644 --- a/src/glsl/opt_array_splitting.cpp +++ b/src/glsl/opt_array_splitting.cpp @@ -36,7 +36,6 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_rvalue_visitor.h" -#include "ir_print_visitor.h" #include "glsl_types.h" static bool debug = false; diff --git a/src/glsl/opt_noop_swizzle.cpp b/src/glsl/opt_noop_swizzle.cpp index 693719e..586ad5e 100644 --- a/src/glsl/opt_noop_swizzle.cpp +++ b/src/glsl/opt_noop_swizzle.cpp @@ -32,7 +32,6 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_rvalue_visitor.h" -#include "ir_print_visitor.h" #include "glsl_types.h" namespace { diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp index 806c079..9f4b3dd 100644 --- a/src/glsl/opt_structure_splitting.cpp +++ b/src/glsl/opt_structure_splitting.cpp @@ -34,7 +34,6 @@ #include "ir.h" #include "ir_visitor.h" -#include "ir_print_visitor.h" #include "ir_rvalue_visitor.h" #include "glsl_types.h" diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp index fc10cbbd..67e2ab2 100644 --- a/src/glsl/test_optpass.cpp +++ b/src/glsl/test_optpass.cpp @@ -39,7 +39,6 @@ #include "ast.h" #include "ir_optimization.h" -#include "ir_print_visitor.h" #include "program.h" #include "ir_reader.h" #include "standalone_scaffolding.h" diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 7f8edff..97cd291 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -48,7 +48,6 @@ extern "C" { } #include "brw_fs.h" #include "glsl/glsl_types.h" -#include "glsl/ir_print_visitor.h" void fs_inst::init() diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp index 9e1cf4a..f390989 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp @@ -35,7 +35,6 @@ extern "C" { #include "brw_fs.h" #include "brw_cfg.h" -#include "glsl/ir_print_visitor.h" fs_generator::fs_generator(struct brw_context *brw, struct brw_wm_compile *c, diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/driver
Re: [Mesa-dev] [PATCH 4/6] mesa: Use shared code for converting shader targets to short strings.
On 06/17/2013 04:10 PM, Eric Anholt wrote: We were duplicating this code all over the place, and they all would need updating for the next set of shader targets. --- src/glsl/glsl_parser_extras.cpp| 35 ++ src/glsl/glsl_parser_extras.h | 3 +++ src/glsl/link_varyings.cpp | 15 - src/glsl/linker.cpp| 4 ++-- src/mesa/drivers/dri/i965/brw_shader.cpp | 9 src/mesa/main/shaderapi.c | 17 ++- src/mesa/main/uniform_query.cpp| 9 ++-- src/mesa/program/ir_to_mesa.cpp| 5 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 ++ 9 files changed, 61 insertions(+), 43 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 9862714..7b827ba 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -302,6 +302,41 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version, } } +extern "C" { + +/** + * The most common use of _mesa_glsl_shader_target_name(), which is + * shared with C code in Mesa core to translate a GLenum to a short + * shader stage name in debug printouts. + * + * It recognizes the PROGRAM variants of the names so it can be used + * with a struct gl_program->Target, not just a struct + * gl_shader->Type. + */ +const char * +_mesa_glsl_shader_target_name(GLenum type) +{ + switch (type) { + case GL_VERTEX_SHADER: + case GL_VERTEX_PROGRAM_ARB: + return "vertex"; + case GL_FRAGMENT_SHADER: + case GL_FRAGMENT_PROGRAM_ARB: + return "fragment"; + case GL_GEOMETRY_SHADER: + return "geometry"; + default: + assert(!"Should not get here."); + return "unknown"; + } +} + +} /* extern "C" */ + +/** + * Overloaded C++ variant usable within the compiler for translating + * our internal enum into short stage names. + */ const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) { I'm kind of wary of having an overloaded function where the distinguisher is GLenum (int) vs. enum (basically int). I think the C vs. C++ enum rules save us here, but still not something I'm crazy about. Still, this is a really nice cleanup. I'm glad to see this centralized, as well as the vertex/fragment hardcoding going away. As is, Reviewed-by: Kenneth Graunke ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/6] mesa: Fix missing setting of shader->IsES.
On 06/17/2013 04:10 PM, Eric Anholt wrote: I noticed this while trying to merge code with the builtin compiler, which does set it. Note that this causes two regressions in piglit in default-precision-sampler.* which try to link without a vertex or fragment shader, due to being run under the desktop glslparsertest binary (using ARB_ES3_compatibility) that doesn't know about this requirement. That seems quite odd. --- src/mesa/program/ir_to_mesa.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 2739df7..a915974 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -3155,6 +3155,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader) shader->CompileStatus = !state->error; shader->InfoLog = state->info_log; shader->Version = state->language_version; + shader->IsES = state->es_shader; memcpy(shader->builtins_to_link, state->builtins_to_link, sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); shader->num_builtins_to_link = state->num_builtins_to_link; It does seem like we ought to be setting this. So, regressions or not, I think this is the right thing to do. Reviewed-by: Kenneth Graunke ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] glsl: Add simple vector type accessor helpers.
This patch introduces new functions to quickly grab a pointer to a vector type. For example: glsl_type::bvec(4) returns glsl_type::bvec4_type glsl_type::ivec(3) returns glsl_type::ivec3_type glsl_type::uvec(2) returns glsl_type::uvec2_type glsl_type::vec(1)returns glsl_type::float_type This is less wordy than glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1), which can help avoid extra word wrapping. Signed-off-by: Kenneth Graunke --- src/glsl/glsl_types.cpp | 52 + src/glsl/glsl_types.h | 9 + 2 files changed, 61 insertions(+) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index df9c5d3..a5491c5 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -534,6 +534,58 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : } +const glsl_type *const +glsl_type::vec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + float_type, vec2_type, vec3_type, vec4_type + }; + return ts[components - 1]; +} + + +const glsl_type *const +glsl_type::ivec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + int_type, ivec2_type, ivec3_type, ivec4_type + }; + return ts[components - 1]; +} + + +const glsl_type *const +glsl_type::uvec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + uint_type, uvec2_type, uvec3_type, uvec4_type + }; + return ts[components - 1]; +} + + +const glsl_type *const +glsl_type::bvec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + bool_type, bvec2_type, bvec3_type, bvec4_type + }; + return ts[components - 1]; +} + + const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 31e3dd2..665af8b 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -187,6 +187,15 @@ struct glsl_type { static const glsl_type *const mat4_type; /*@}*/ + /** +* Convenience accessors for vector types (shorter than get_instance()). +* @{ +*/ + static const glsl_type *const vec(unsigned components); + static const glsl_type *const ivec(unsigned components); + static const glsl_type *const uvec(unsigned components); + static const glsl_type *const bvec(unsigned components); + /**@}*/ /** * For numeric and boolean derrived types returns the basic scalar type -- 1.8.3.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] glsl: Stop being clever with pointer arithmetic when fetching types.
Currently, vector types are linked together closely: the glsl_type objects for float, vec2, vec3, and vec4 are all elements of the same array, in that exact order. This makes it possible to obtain vector types via pointer arithmetic on the scalar type's convenience pointer. For example, float_type + (3 - 1) = vec3. However, relying on this is extremely fragile. There's no particular reason the underlying type objects need to be stored in an array. They could be individual class members, possibly with padding between them. Then the pointer arithmetic would break, and we'd get bad pointers to non-heap allocated data, causing subtle breakage that can't be detected by valgrind. Cue insanity. Or someone could simply reorder the type variables, causing us to get the wrong type entirely. Also cue insanity. Writing this explicitly is much safer. With the new helper functions, it's a bit less code even. Signed-off-by: Kenneth Graunke --- src/glsl/glsl_types.cpp | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index a5491c5..d1d609a 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -600,13 +600,13 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) if (columns == 1) { switch (base_type) { case GLSL_TYPE_UINT: -return uint_type + (rows - 1); +return uvec(rows); case GLSL_TYPE_INT: -return int_type + (rows - 1); +return ivec(rows); case GLSL_TYPE_FLOAT: -return float_type + (rows - 1); +return vec(rows); case GLSL_TYPE_BOOL: -return bool_type + (rows - 1); +return bvec(rows); default: return error_type; } -- 1.8.3.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] glsl: Don't use random pointers as an array of glsl_type objects.
Using a random glsl_type convenience pointer as an array is a really bad idea, for all the reasons mentioned in the previous commit. The new glsl_type::bvec() function is simpler anyway. Prevents breakage in the next commit. Signed-off-by: Kenneth Graunke --- src/glsl/lower_variable_index_to_cond_assign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp index 040b0bf..0f50727 100644 --- a/src/glsl/lower_variable_index_to_cond_assign.cpp +++ b/src/glsl/lower_variable_index_to_cond_assign.cpp @@ -99,7 +99,7 @@ compare_index_block(exec_list *instructions, ir_variable *index, ir_rvalue *const condition_val = new(mem_ctx) ir_expression(ir_binop_equal, -&glsl_type::bool_type[components - 1], +glsl_type::bvec(components), broadcast_index, test_indices); -- 1.8.3.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] llvmpipe: Tighten check for alpha-only formats
The AoS version of ld_build_blend_factor was assuming that if the first channel was alpha, there were no rgb components. Fixes several piglit tests on System z. No piglit regressions on x86_64. The shortcut is still used in tests like spec/ARB_framebuffer_object/ fbo-alpha. Signed-off-by: Richard Sandiford --- src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c index c4d04a2..7c485e7 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c @@ -245,7 +245,7 @@ lp_build_blend_factor(struct lp_build_blend_aos_context *bld, LLVMValueRef rgb_factor_, alpha_factor_; enum lp_build_blend_swizzle rgb_swizzle; - if (alpha_swizzle == 0) { + if (alpha_swizzle == UTIL_FORMAT_SWIZZLE_X && num_channels == 1) { return lp_build_blend_factor_unswizzled(bld, alpha_factor, TRUE); } -- 1.7.11.7 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 65898] New: Low(er) FPS in Half-Life 2 on Arch Linux
https://bugs.freedesktop.org/show_bug.cgi?id=65898 Priority: medium Bug ID: 65898 Assignee: mesa-dev@lists.freedesktop.org Summary: Low(er) FPS in Half-Life 2 on Arch Linux Severity: normal Classification: Unclassified OS: Linux (All) Reporter: gont...@hotmail.com Hardware: x86 (IA32) Status: NEW Version: 9.1 Component: Mesa core Product: Mesa Hi there, I have recently installed Steam for Linux and downloaded Half-Life 2. My laptop is by no means a new or speedy machine, and uses a built-in graphics card, so I'm not expecting miracles. However. I have loaded Half-Life 2 on my Windows install on the same machine, and get around 17FPS (not amazingly smooth, granted, but responsive enough when moving around) This is with the default settings (full screen, low model detail, high texture detail, high shader detail, simple reflections, medium shadow detail, color correction disabled, antialiasing off, trilinear filtering, vertical sync disabled, motion blur enabled, multicore rendering, HDR none). With the same settings (or even lower) on the linux install, I get around 5-10FPS (which is much slower, less reponsive and generally unplayable). What would cause this difference? I am not sure what info you require, so have gathered some h/w, system and graphics details from my system: --- Steam System Information: --- Processor Information: Vendor: GenuineIntel Speed: 1500 Mhz 2 logical processors 2 physical processors HyperThreading: Unsupported FCMOV: Supported SSE2: Supported SSE3: Supported SSSE3: Supported SSE4a: Unsupported SSE41: Unsupported SSE42: Unsupported Network Information: Network Speed: Operating System Version: Linux (32 bit) Kernel Name: Linux Kernel Version: 3.9.4-1-ARCH X Server Vendor: The X.Org Foundation X Server Release: 11401000 X Window Manager: GNOME Shell Steam Runtime Version: steam-runtime-release-i386_2013-05-08 Video Card: Driver: Intel Open Source Technology Center Mesa DRI Intel(R) 965GM x86/MMX/SSE2 Driver Version: 2.1 Mesa 9.1.3 Desktop Color Depth: 24 bits per pixel Monitor Refresh Rate: 59 Hz VendorID: 0x8086 DeviceID: 0x2a02 Number of Monitors: 1 Number of Logical Video Cards: 1 Primary Display Resolution: 1280 x 800 Desktop Resolution: 1280 x 800 Primary Display Size: 13.03" x 8.15" (15.35" diag) 33.1cm x 20.7cm (39.0cm diag) Primary VRAM Not Detected Sound card: Audio device: Realtek ALC268 Memory: RAM: 2010 Mb Miscellaneous: UI Language: English LANG: en_GB.utf8 Microphone: Not set Total Hard Disk Space Available: 20034 Mb Largest Free Hard Disk Block: 12225 Mb Installed software: Recent Failure Reports: --- GLX Gears --- [mike@mike-laptop ~]$ glxgears Running synchronized to the vertical refresh. The framerate should be approximately the same as the monitor refresh rate. 307 frames in 5.0 seconds = 61.369 FPS 309 frames in 5.0 seconds = 61.702 FPS 309 frames in 5.0 seconds = 61.702 FPS 309 frames in 5.0 seconds = 61.707 FPS XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0" after 4528 requests (4528 known processed) with 0 events remaining. --- GLXINFO --- [mike@mike-laptop ~]$ glxinfo name of display: :0 brwCreateContext: failed to init intel context display: :0 screen: 0 direct rendering: Yes server glx vendor string: SGI server glx version string: 1.4 server glx extensions: GLX_ARB_create_context, GLX_ARB_create_context_profile, GLX_ARB_multisample, GLX_EXT_create_context_es2_profile, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, GLX_SGI_swap_control client glx vendor string: Mesa Project and SGI client glx version string: 1.4 client glx extensions: GLX_ARB_create_context, GLX_ARB_create_context_profile, GLX_ARB_create_context_robustness, GLX_ARB_framebuffer_sRGB, GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_create_context_es2_profile, GLX_EXT_framebuffer_sRGB, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, GLX_SGI_make_current_read, GLX_SGI_swap_control, GLX_SGI_video_sync GLX version: 1
[Mesa-dev] [Bug 65898] Low(er) FPS in Half-Life 2 on Arch Linux
https://bugs.freedesktop.org/show_bug.cgi?id=65898 Mike Higgins changed: What|Removed |Added CC||gont...@hotmail.com -- You are receiving this mail because: 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] llvmpipe: Tighten check for alpha-only formats
Am 25.03.2013 16:19, schrieb Richard Sandiford: > The AoS version of ld_build_blend_factor was assuming that if the first > channel was alpha, there were no rgb components. > > Fixes several piglit tests on System z. No piglit regressions on x86_64. > The shortcut is still used in tests like spec/ARB_framebuffer_object/ > fbo-alpha. > > Signed-off-by: Richard Sandiford > --- > src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c > b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c > index c4d04a2..7c485e7 100644 > --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c > +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c > @@ -245,7 +245,7 @@ lp_build_blend_factor(struct lp_build_blend_aos_context > *bld, > LLVMValueRef rgb_factor_, alpha_factor_; > enum lp_build_blend_swizzle rgb_swizzle; > > - if (alpha_swizzle == 0) { > + if (alpha_swizzle == UTIL_FORMAT_SWIZZLE_X && num_channels == 1) { >return lp_build_blend_factor_unswizzled(bld, alpha_factor, TRUE); > } > > LGTM. Roland ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 65898] Low(er) FPS in Half-Life 2 on Arch Linux
https://bugs.freedesktop.org/show_bug.cgi?id=65898 Ian Romanick changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #1 from Ian Romanick --- You might try a build from Mesa master. We've done a lot of performance work, but, unfortunately for you, most of it probably won't help that particular GPU. The rest of the bad news is that we don't have the bandwidth to do performance work on older platforms. Sorry. :( -- You are receiving this mail because: 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 2/4] glsl: Stop being clever with pointer arithmetic when fetching types.
On 06/18/2013 04:22 AM, Kenneth Graunke wrote: Currently, vector types are linked together closely: the glsl_type objects for float, vec2, vec3, and vec4 are all elements of the same array, in that exact order. This makes it possible to obtain vector types via pointer arithmetic on the scalar type's convenience pointer. For example, float_type + (3 - 1) = vec3. My recollection, is that this wasn't originally "clever" (aka bong hits). Originally, we had something like const glsl_type *int_type[4]; int_type[0] pointed to the type for int, int_type[1] pointed to the type for ivec2, etc. Many places in the code got the arithmetic wrong, so we added the ivec2_type fields, and so on, and so on... Fast forward a couple years, and now we have madness. However, relying on this is extremely fragile. There's no particular reason the underlying type objects need to be stored in an array. They could be individual class members, possibly with padding between them. Then the pointer arithmetic would break, and we'd get bad pointers to non-heap allocated data, causing subtle breakage that can't be detected by valgrind. Cue insanity. Or someone could simply reorder the type variables, causing us to get the wrong type entirely. Also cue insanity. Writing this explicitly is much safer. With the new helper functions, it's a bit less code even. Signed-off-by: Kenneth Graunke --- src/glsl/glsl_types.cpp | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index a5491c5..d1d609a 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -600,13 +600,13 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) if (columns == 1) { switch (base_type) { case GLSL_TYPE_UINT: -return uint_type + (rows - 1); +return uvec(rows); case GLSL_TYPE_INT: -return int_type + (rows - 1); +return ivec(rows); case GLSL_TYPE_FLOAT: -return float_type + (rows - 1); +return vec(rows); case GLSL_TYPE_BOOL: -return bool_type + (rows - 1); +return bvec(rows); default: return error_type; } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] glsl: Add simple vector type accessor helpers.
On 06/18/2013 04:22 AM, Kenneth Graunke wrote: This patch introduces new functions to quickly grab a pointer to a vector type. For example: glsl_type::bvec(4) returns glsl_type::bvec4_type glsl_type::ivec(3) returns glsl_type::ivec3_type glsl_type::uvec(2) returns glsl_type::uvec2_type glsl_type::vec(1)returns glsl_type::float_type This is less wordy than glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1), which can help avoid extra word wrapping. One thing that's annoying about this code is that we have so many ways to get at types. You can get them from a symbol table, you can get them from the direct pointers, you can get them from pointer math, or you can get them from get_instance. I'm not sure replacing one with another makes it much better. I remember considering having separate overloads of get_instance for vectors and matrices. I don't recall why I didn't do it that way. Signed-off-by: Kenneth Graunke --- src/glsl/glsl_types.cpp | 52 + src/glsl/glsl_types.h | 9 + 2 files changed, 61 insertions(+) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index df9c5d3..a5491c5 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -534,6 +534,58 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : } +const glsl_type *const +glsl_type::vec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + float_type, vec2_type, vec3_type, vec4_type + }; + return ts[components - 1]; We could just embed this code in get_instance. That seems better than adding new methods that are only used in method that's part of the same class. +} + + +const glsl_type *const +glsl_type::ivec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + int_type, ivec2_type, ivec3_type, ivec4_type + }; + return ts[components - 1]; +} + + +const glsl_type *const +glsl_type::uvec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + uint_type, uvec2_type, uvec3_type, uvec4_type + }; + return ts[components - 1]; +} + + +const glsl_type *const +glsl_type::bvec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + bool_type, bvec2_type, bvec3_type, bvec4_type + }; + return ts[components - 1]; +} + + const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 31e3dd2..665af8b 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -187,6 +187,15 @@ struct glsl_type { static const glsl_type *const mat4_type; /*@}*/ + /** +* Convenience accessors for vector types (shorter than get_instance()). +* @{ +*/ + static const glsl_type *const vec(unsigned components); + static const glsl_type *const ivec(unsigned components); + static const glsl_type *const uvec(unsigned components); + static const glsl_type *const bvec(unsigned components); + /**@}*/ /** * For numeric and boolean derrived types returns the basic scalar type ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] mesa/main: Check for 0 size draws after validation.
On 05/25/2013 05:33 AM, Fabian Bieler wrote: When validating draw parameters move check for 0 draw count last (drawing with count 0 is not an error), so that other parameters (e.g.: the primitive type) are validated and the correct errors (if applicable) are generated. From the OpenGL 3.3 spec page 33 (page 48 of the PDF): "[Regarding DrawArraysOneInstance, in terms of which other draw operations are defined:] If count is negative, an INVALID_VALUE error is generated." This patch also changes the bahavior of MultiDrawElements to perform the draw operation if some primitive's index counts are zero. Signed-off-by: Fabian Bieler Reviewed-by: Brian Paul ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] R600: Add support for i32 loads from the constant address space on Cayman
From: Tom Stellard --- lib/Target/R600/R600Instructions.td | 9 + test/CodeGen/R600/load.ll | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/Target/R600/R600Instructions.td b/lib/Target/R600/R600Instructions.td index 83d735f..803f597 100644 --- a/lib/Target/R600/R600Instructions.td +++ b/lib/Target/R600/R600Instructions.td @@ -1755,6 +1755,15 @@ def VTX_READ_GLOBAL_128_cm : VTX_READ_128_cm <1, [(set v4i32:$dst_gpr, (global_load ADDRVTX_READ:$src_gpr))] >; +//===--===// +// Constant Loads +// XXX: We are currently storing all constants in the global address space. +//===--===// + +def CONSTANT_LOAD_cm : VTX_READ_32_cm <1, + [(set i32:$dst_gpr, (constant_load ADDRVTX_READ:$src_gpr))] +>; + } // End isCayman //===--===// diff --git a/test/CodeGen/R600/load.ll b/test/CodeGen/R600/load.ll index ff774ec..d1ebaa3 100644 --- a/test/CodeGen/R600/load.ll +++ b/test/CodeGen/R600/load.ll @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=R600-CHECK %s +; RUN: llc < %s -march=r600 -mcpu=cayman | FileCheck --check-prefix=R600-CHECK %s ; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck --check-prefix=SI-CHECK %s ; Load an i8 value from the global address space. -- 1.7.11.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] R600/SI: Report unaligned memory accesses as legal for > 32-bit types
From: Tom Stellard In reality, some unaligned memory accesses are legal for 32-bit types and smaller too, but it all depends on the address space. Allowing unaligned loads/stores for > 32-bit types is mainly to prevent the legalizer from splitting one load into multiple loads of smaller types. https://bugs.freedesktop.org/show_bug.cgi?id=65873 --- lib/Target/R600/SIISelLowering.cpp | 12 lib/Target/R600/SIISelLowering.h | 1 + test/CodeGen/R600/store.ll | 32 3 files changed, 45 insertions(+) diff --git a/lib/Target/R600/SIISelLowering.cpp b/lib/Target/R600/SIISelLowering.cpp index d74f401..9d4cfef 100644 --- a/lib/Target/R600/SIISelLowering.cpp +++ b/lib/Target/R600/SIISelLowering.cpp @@ -82,6 +82,18 @@ SITargetLowering::SITargetLowering(TargetMachine &TM) : setSchedulingPreference(Sched::RegPressure); } +//===--===// +// TargetLowering queries +//===--===// + +bool SITargetLowering::allowsUnalignedMemoryAccesses(EVT VT, + bool *IsFast) const { + // XXX: This depends on the address space and also we may want to revist + // the alignment values we specify in the DataLayout. + return VT.bitsGT(MVT::i32); +} + + SDValue SITargetLowering::LowerParameter(SelectionDAG &DAG, EVT VT, SDLoc DL, SDValue Chain, unsigned Offset) const { diff --git a/lib/Target/R600/SIISelLowering.h b/lib/Target/R600/SIISelLowering.h index 78ae6a1..0a856d5 100644 --- a/lib/Target/R600/SIISelLowering.h +++ b/lib/Target/R600/SIISelLowering.h @@ -40,6 +40,7 @@ class SITargetLowering : public AMDGPUTargetLowering { public: SITargetLowering(TargetMachine &tm); + bool allowsUnalignedMemoryAccesses(EVT VT, bool *IsFast) const; SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, diff --git a/test/CodeGen/R600/store.ll b/test/CodeGen/R600/store.ll index e87229a..f8c6f84 100644 --- a/test/CodeGen/R600/store.ll +++ b/test/CodeGen/R600/store.ll @@ -14,3 +14,35 @@ define void @store_f32(float addrspace(1)* %out, float %in) { store float %in, float addrspace(1)* %out ret void } + +; The stores in this function are combined by the optimizer to create a +; 64-bit store with 32-bit alignment. This is legal for SI and the legalizer +; should not try to split the 64-bit store back into 2 32-bit stores. +; +; Evergreen / Northern Islands don't support 64-bit stores yet, so there should +; be two 32-bit stores. + +; EG-CHECK: @vecload2 +; EG-CHECK: RAT_WRITE_CACHELESS_32_eg +; EG-CHECK: RAT_WRITE_CACHELESS_32_eg +; CM-CHECK: @vecload2 +; CM-CHECK: EXPORT_RAT_INST_STORE_DWORD +; CM-CHECK: EXPORT_RAT_INST_STORE_DWORD +; SI-CHECK: @vecload2 +; SI-CHECK: BUFFER_STORE_DWORDX2 +define void @vecload2(i32 addrspace(1)* nocapture %out, i32 addrspace(2)* nocapture %mem) #0 { +entry: + %0 = load i32 addrspace(2)* %mem, align 4, !tbaa !5 + %arrayidx1.i = getelementptr inbounds i32 addrspace(2)* %mem, i64 1 + %1 = load i32 addrspace(2)* %arrayidx1.i, align 4, !tbaa !5 + store i32 %0, i32 addrspace(1)* %out, align 4, !tbaa !5 + %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %out, i64 1 + store i32 %1, i32 addrspace(1)* %arrayidx1, align 4, !tbaa !5 + ret void +} + +attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!5 = metadata !{metadata !"int", metadata !6} +!6 = metadata !{metadata !"omnipotent char", metadata !7} +!7 = metadata !{metadata !"Simple C/C++ TBAA"} -- 1.7.11.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 00/14] Big-endian support in gallivm and llvmpipe
New in this series: - Includes gallium format name documentation - Defines packed formats as aliases into the existing enum - Changes packed format names to be lsb-to-msb Note that the existing hardware drivers will be "broken" by this series (on big-endian machines), but that they probably already are broken. On evergreen, for instance, gnome-shell will display properly before this series, but you can't click on anything, because ReadPixels gets things backwards; after this series, and with this: @@ -615,7 +615,7 @@ static uint32_t r600_translate_colorformat(enum pipe_format static uint32_t r600_colorformat_endian_swap(uint32_t colorformat) { - if (R600_BIG_ENDIAN) { + if (0 && R600_BIG_ENDIAN) { switch(colorformat) { /* 8-bit buffers. */ gnome-shell works, and you have way more piglit passes than you did with current master. Probably other radeon generations and all of nouveau would need similar fixes, which I've not audited for yet. - ajax ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/14] gallivm: Remove all notion of byte-swapping
Signed-off-by: Adam Jackson --- src/gallium/auxiliary/gallivm/lp_bld_conv.c| 76 -- src/gallium/auxiliary/gallivm/lp_bld_conv.h| 11 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c | 9 --- .../auxiliary/gallivm/lp_bld_format_aos_array.c| 56 src/gallium/auxiliary/util/u_format_pack.py| 21 -- 5 files changed, 173 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c index f11361a..cbea966 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c @@ -80,82 +80,6 @@ /** - * Byte swap on element. It will construct a call to intrinsic llvm.bswap - * based on the type. - * - * @param res element to byte swap. - * @param type int16_t, int32_t, int64_t, float or double - * @param - */ -LLVMValueRef -lp_build_bswap(struct gallivm_state *gallivm, - LLVMValueRef res, - struct lp_type type) -{ - LLVMTypeRef int_type = LLVMIntTypeInContext(gallivm->context, - type.width); - const char *intrinsic = NULL; - if (type.width == 8) - return res; - if (type.width == 16) - intrinsic = "llvm.bswap.i16"; - else if (type.width == 32) - intrinsic = "llvm.bswap.i32"; - else if (type.width == 64) - intrinsic = "llvm.bswap.i64"; - - assert (intrinsic != NULL); - - /* In case of a floating-point type cast to a int of same size and then -* cast back to fp type. -*/ - if (type.floating) - res = LLVMBuildBitCast(gallivm->builder, res, int_type, ""); - res = lp_build_intrinsic_unary(gallivm->builder, intrinsic, int_type, res); - if (type.floating) - res = LLVMBuildBitCast(gallivm->builder, res, - lp_build_elem_type(gallivm, type), ""); - return res; -} - - -/** - * Byte swap every element in the vector. - * - * @param packed to convert - * @param src_type type of int16_t, int32_t, int64_t, float or - * double - * @param dst_type type to return - */ -LLVMValueRef -lp_build_bswap_vec(struct gallivm_state *gallivm, - LLVMValueRef packed, - struct lp_type src_type_vec, - struct lp_type dst_type_vec) -{ - LLVMBuilderRef builder = gallivm->builder; - LLVMTypeRef dst_type = lp_build_elem_type(gallivm, dst_type_vec); - LLVMValueRef res; - - if (src_type_vec.length == 1) { - res = lp_build_bswap(gallivm, packed, src_type_vec); - res = LLVMBuildBitCast(gallivm->builder, res, dst_type, ""); - } else { - unsigned i; - res = LLVMGetUndef(lp_build_vec_type(gallivm, dst_type_vec)); - for (i = 0; i < src_type_vec.length; ++i) { - LLVMValueRef index = lp_build_const_int32(gallivm, i); - LLVMValueRef elem = LLVMBuildExtractElement(builder, packed, index, ""); - elem = lp_build_bswap(gallivm, elem, src_type_vec); - elem = LLVMBuildBitCast(gallivm->builder, elem, dst_type, ""); - res = LLVMBuildInsertElement(gallivm->builder, res, elem, index, ""); - } - } - return res; -} - - -/** * Converts int16 half-float to float32 * Note this can be performed in 1 instruction if vcvtph2ps exists (f16c/cvt16) * [llvm.x86.vcvtph2ps / _mm_cvtph_ps] diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.h b/src/gallium/auxiliary/gallivm/lp_bld_conv.h index d7dfed8..42a1113 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.h @@ -43,17 +43,6 @@ struct lp_type; LLVMValueRef -lp_build_bswap(struct gallivm_state *gallivm, - LLVMValueRef res, - struct lp_type type); - -LLVMValueRef -lp_build_bswap_vec(struct gallivm_state *gallivm, - LLVMValueRef packed, - struct lp_type src_type, - struct lp_type dst_type); - -LLVMValueRef lp_build_half_to_float(struct gallivm_state *gallivm, LLVMValueRef src); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c index 6a1bf67..3675e68 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c @@ -172,10 +172,6 @@ lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm, * matches floating point size */ assert (LLVMTypeOf(packed) == LLVMInt32TypeInContext(gallivm->context)); -#ifdef PIPE_ARCH_BIG_ENDIAN - packed = lp_build_bswap(gallivm, packed, lp_type_uint(32)); -#endif - /* Broadcast the packed value to all four channels * before: packed = BGRA * after: packed = {BGRA, BGRA, BGRA, BGRA} @@ -415,11 +411,6 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, assert(format_desc->block.bits <= vec_len); packed = LLVMBuildBitCast(gallivm->builder, pa
[Mesa-dev] [PATCH 02/14] gallium: Document format name conventions
v2: - Fix a channel name thinko (Michel Dänzer) - Elaborate on SCALED versus INT - Add links to DirectX and FOURCC docs Signed-off-by: Adam Jackson --- src/gallium/docs/format.rst | 54 + 1 file changed, 54 insertions(+) create mode 100644 src/gallium/docs/format.rst diff --git a/src/gallium/docs/format.rst b/src/gallium/docs/format.rst new file mode 100644 index 000..2514656 --- /dev/null +++ b/src/gallium/docs/format.rst @@ -0,0 +1,54 @@ +Formats in gallium +== + +Gallium format names mostly follow D3D10 conventions, with some extensions. + +Format names like XnYnZnWn have the X component in the lowest-address n bits +and the W component in the highest-address n bits; for B8G8R8A8, byte 0 is +blue and byte 3 is alpha. Note that platform endianness is not considered +in this definition. + +Format suffixes affect the interpretation of the channel: + +- ``SINT``: N bit signed integer [-2^(N-1) ... 2^(N-1) - 1] +- ``SNORM``:N bit signed integer normalized to [-1 ... 1] +- ``SSCALED``: N bit signed integer [-2^(N-1) ... 2^(N-1) - 1] +- ``FIXED``:Signed fixed point integer, (N/2 - 1) bits of mantissa +- ``FLOAT``:N bit IEEE754 float +- ``NORM``: Normalized integers, signed or unsigned per channel +- ``UINT``: N bit unsigned integer [0 ... 2^N - 1] +- ``UNORM``:N bit unsigned integer normalized to [0 ... 1] +- ``USCALED``: N bit unsigned integer [0 ... 2^N - 1] + +The difference between ``SINT`` and ``SSCALED`` is that the former are pure +integers in shaders, while the latter are floats; likewise for ``UINT`` versus +``USCALED``. + +There are two exceptions for ``FLOAT``. ``R9G9B9E5_FLOAT`` is nine bits +each of red green and blue mantissa, with a shared five bit exponent. +``R11G11B10_FLOAT`` is five bits of exponent and five or six bits of mantissa +for each color channel. + +For the ``NORM`` suffix, the signedness of each channel is indicated with an +S or U after the number of channel bits, as in ``R5SG5SB6U_NORM``. + +The ``SRGB`` suffix is like ``UNORM`` in range, but in the sRGB colorspace. + +Compressed formats are named first by the compression format string (``DXT1``, +``ETC1``, etc), followed by a format-specific subtype. Refer to the +appropriate compression spec for details. + +Formats used in video playback are named by their FOURCC code. + +Format names with an embedded underscore are subsampled. ``R8G8_B8G8`` is a +single 32-bit block of two pixels, where the R and B values are repeated in +both pixels. + +References +-- + +DirectX Graphics Infrastructure documentation on DXGI_FORMAT enum: +http://msdn.microsoft.com/en-us/library/windows/desktop/bb173059%28v=vs.85%29.aspx + +FOURCC codes for YUV formats: +http://www.fourcc.org/yuv.php -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/14] gallium: Introduce 32-bit packed format names
From: Richard Sandiford These are for interacting with buffers natively described in terms of bit shifts, like X11 visuals: uint32_t xyzw = (x << 0) | (y << 8) | (z << 16) | (w << 24); Define these in terms of (endian-dependent) aliases to the array-style format names. Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/include/pipe/p_format.h | 22 ++ 1 file changed, 22 insertions(+) diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 098b25b..f181621 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -33,6 +33,7 @@ extern "C" { #endif +#include "p_config.h" enum pipe_type { PIPE_TYPE_UNORM = 0, @@ -343,6 +344,27 @@ enum pipe_format { PIPE_FORMAT_COUNT }; +#if defined(PIPE_ARCH_LITTLE_ENDIAN) +#define PIPE_FORMAT_RGBA_UNORM PIPE_FORMAT_R8G8B8A8_UNORM +#define PIPE_FORMAT_RGBX_UNORM PIPE_FORMAT_R8G8B8X8_UNORM +#define PIPE_FORMAT_BGRA_UNORM PIPE_FORMAT_B8G8R8A8_UNORM +#define PIPE_FORMAT_BGRX_UNORM PIPE_FORMAT_B8G8R8X8_UNORM +#define PIPE_FORMAT_ARGB_UNORM PIPE_FORMAT_A8R8G8B8_UNORM +#define PIPE_FORMAT_XRGB_UNORM PIPE_FORMAT_X8R8G8B8_UNORM +#define PIPE_FORMAT_ABGR_UNORM PIPE_FORMAT_A8B8G8R8_UNORM +#define PIPE_FORMAT_XBGR_UNORM PIPE_FORMAT_X8B8G8R8_UNORM +#elif defined(PIPE_ARCH_BIG_ENDIAN) +#define PIPE_FORMAT_ABGR_UNORM PIPE_FORMAT_R8G8B8A8_UNORM +#define PIPE_FORMAT_XBGR_UNORM PIPE_FORMAT_R8G8B8X8_UNORM +#define PIPE_FORMAT_XRGB_UNORM PIPE_FORMAT_B8G8R8X8_UNORM +#define PIPE_FORMAT_ARGB_UNORM PIPE_FORMAT_B8G8R8A8_UNORM +#define PIPE_FORMAT_XRGB_UNORM PIPE_FORMAT_B8G8R8X8_UNORM +#define PIPE_FORMAT_BGRA_UNORM PIPE_FORMAT_A8R8G8B8_UNORM +#define PIPE_FORMAT_BGRX_UNORM PIPE_FORMAT_X8R8G8B8_UNORM +#define PIPE_FORMAT_RGBA_UNORM PIPE_FORMAT_A8B8G8R8_UNORM +#define PIPE_FORMAT_RGBX_UNORM PIPE_FORMAT_X8B8G8R8_UNORM +#endif + enum pipe_video_chroma_format { PIPE_VIDEO_CHROMA_FORMAT_420, -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/14] gallium: Document packed formats
Signed-off-by: Adam Jackson --- src/gallium/docs/format.rst | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/format.rst b/src/gallium/docs/format.rst index 2514656..e270d93 100644 --- a/src/gallium/docs/format.rst +++ b/src/gallium/docs/format.rst @@ -6,7 +6,14 @@ Gallium format names mostly follow D3D10 conventions, with some extensions. Format names like XnYnZnWn have the X component in the lowest-address n bits and the W component in the highest-address n bits; for B8G8R8A8, byte 0 is blue and byte 3 is alpha. Note that platform endianness is not considered -in this definition. +in this definition. In C: + +struct xyzw { uint8_t x, y, z, w; }; + +Format aliases like XYZWstrq are (s+t+r+q)-bit integers in host endianness, +with the X component in the s least-significant bits of the integer. In C: + +uint32_t xyzw = (x << 0) | (y << 8) | (z << 16) | (w << 24); Format suffixes affect the interpretation of the channel: -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/14] tests: Convert to packed formats
From: Richard Sandiford Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/tests/graw/clear.c | 4 ++-- src/gallium/tests/graw/fs-test.c | 4 ++-- src/gallium/tests/graw/graw_util.h | 6 +++--- src/gallium/tests/graw/quad-sample.c | 4 ++-- src/gallium/tests/graw/shader-leak.c | 4 ++-- src/gallium/tests/graw/tri-gs.c| 4 ++-- src/gallium/tests/graw/tri-instanced.c | 4 ++-- src/gallium/tests/graw/vs-test.c | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gallium/tests/graw/clear.c b/src/gallium/tests/graw/clear.c index 6afdf40..77c59db 100644 --- a/src/gallium/tests/graw/clear.c +++ b/src/gallium/tests/graw/clear.c @@ -10,8 +10,8 @@ #include "pipe/p_defines.h" enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c index 685be92..38a2c4b 100644 --- a/src/gallium/tests/graw/fs-test.c +++ b/src/gallium/tests/graw/fs-test.c @@ -31,8 +31,8 @@ static void usage(char *name) enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; diff --git a/src/gallium/tests/graw/graw_util.h b/src/gallium/tests/graw/graw_util.h index 84456b4..8557285 100644 --- a/src/gallium/tests/graw/graw_util.h +++ b/src/gallium/tests/graw/graw_util.h @@ -32,8 +32,8 @@ graw_util_create_window(struct graw_info *info, int num_cbufs, bool zstencil_buf) { static const enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; enum pipe_format format; @@ -226,7 +226,7 @@ graw_util_create_tex2d(const struct graw_info *info, struct pipe_box box; temp.target = PIPE_TEXTURE_2D; - temp.format = PIPE_FORMAT_B8G8R8A8_UNORM; + temp.format = format; temp.width0 = width; temp.height0 = height; temp.depth0 = 1; diff --git a/src/gallium/tests/graw/quad-sample.c b/src/gallium/tests/graw/quad-sample.c index 9100272..969ffa7 100644 --- a/src/gallium/tests/graw/quad-sample.c +++ b/src/gallium/tests/graw/quad-sample.c @@ -18,8 +18,8 @@ #include enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c index 014e0cc..3076210 100644 --- a/src/gallium/tests/graw/shader-leak.c +++ b/src/gallium/tests/graw/shader-leak.c @@ -18,8 +18,8 @@ static int num_iters = 100; enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGR_UNORM, PIPE_FORMAT_NONE }; diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c index 535825e..37323aa 100644 --- a/src/gallium/tests/graw/tri-gs.c +++ b/src/gallium/tests/graw/tri-gs.c @@ -14,8 +14,8 @@ #include "util/u_inlines.h" enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; diff --git a/src/gallium/tests/graw/tri-instanced.c b/src/gallium/tests/graw/tri-instanced.c index d00e7e9..f84463d 100644 --- a/src/gallium/tests/graw/tri-instanced.c +++ b/src/gallium/tests/graw/tri-instanced.c @@ -17,8 +17,8 @@ enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c index bfb40be..5a7d0a0 100644 --- a/src/gallium/tests/graw/vs-test.c +++ b/src/gallium/tests/graw/vs-test.c @@ -32,8 +32,8 @@ static void usage(char *name) enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA_UNORM, + PIPE_FORMAT_BGRA_UNORM, PIPE_FORMAT_NONE }; -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/14] gbm: Convert to packed formats
From: Richard Sandiford Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/state_trackers/gbm/gbm_drm.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/gbm/gbm_drm.c b/src/gallium/state_trackers/gbm/gbm_drm.c index 8490480..725f12f 100644 --- a/src/gallium/state_trackers/gbm/gbm_drm.c +++ b/src/gallium/state_trackers/gbm/gbm_drm.c @@ -45,9 +45,9 @@ gbm_format_to_gallium(enum gbm_bo_format format) { switch (format) { case GBM_BO_FORMAT_XRGB: - return PIPE_FORMAT_B8G8R8X8_UNORM; + return PIPE_FORMAT_BGRX_UNORM; case GBM_BO_FORMAT_ARGB: - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_BGRA_UNORM; default: return PIPE_FORMAT_NONE; } @@ -145,10 +145,10 @@ gbm_gallium_drm_bo_import(struct gbm_device *gbm, bo->base.base.height = resource->height0; switch (resource->format) { - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_BGRX_UNORM: bo->base.base.format = GBM_BO_FORMAT_XRGB; break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_BGRA_UNORM: bo->base.base.format = GBM_BO_FORMAT_ARGB; break; default: -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/14] st/xlib: Convert to packed formats
From: Richard Sandiford Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/state_trackers/glx/xlib/xm_api.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index daf5ad4..bb2dd8e 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -328,10 +328,10 @@ choose_pixel_format(XMesaVisual v) && v->BitsPerPixel == 32) { if (native_byte_order) { /* no byteswapping needed */ - return PIPE_FORMAT_R8G8B8A8_UNORM; + return PIPE_FORMAT_RGBA_UNORM; } else { - return PIPE_FORMAT_A8B8G8R8_UNORM; + return PIPE_FORMAT_ABGR_UNORM; } } else if ( GET_REDMASK(v) == 0xff @@ -340,10 +340,10 @@ choose_pixel_format(XMesaVisual v) && v->BitsPerPixel == 32) { if (native_byte_order) { /* no byteswapping needed */ - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_BGRA_UNORM; } else { - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_ARGB_UNORM; } } else if ( GET_REDMASK(v) == 0xff00 @@ -352,10 +352,10 @@ choose_pixel_format(XMesaVisual v) && v->BitsPerPixel == 32) { if (native_byte_order) { /* no byteswapping needed */ - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_ARGB_UNORM; } else { - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_BGRA_UNORM; } } else if ( GET_REDMASK(v) == 0xf800 -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/14] st/dri: Convert to packed formats
Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/state_trackers/dri/common/dri_screen.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index e09fe1d..6a037c4 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -87,8 +87,8 @@ dri_fill_in_modes(struct dri_screen *screen) MESA_FORMAT_RGB565, }; static const enum pipe_format pipe_formats[3] = { - PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_BGRA_UNORM, + PIPE_FORMAT_BGRX_UNORM, PIPE_FORMAT_B5G6R5_UNORM, }; gl_format format; @@ -250,9 +250,9 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, if (mode->redBits == 8) { if (mode->alphaBits == 8) - stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; + stvis->color_format = PIPE_FORMAT_BGRA_UNORM; else - stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; + stvis->color_format = PIPE_FORMAT_BGRX_UNORM; } else { stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; } -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/14] graw-xlib: Convert to packed formats
From: Richard Sandiford Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/targets/graw-xlib/graw_xlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c index 2827747..148837c 100644 --- a/src/gallium/targets/graw-xlib/graw_xlib.c +++ b/src/gallium/targets/graw-xlib/graw_xlib.c @@ -89,13 +89,13 @@ graw_create_window_and_screen( int x, if (visinfo->red_mask == 0xff && visinfo->green_mask == 0xff00 && visinfo->blue_mask == 0xff) { - if (format != PIPE_FORMAT_B8G8R8A8_UNORM) + if (format != PIPE_FORMAT_BGRA_UNORM) goto fail; } else if (visinfo->red_mask == 0xff && visinfo->green_mask == 0xff00 && visinfo->blue_mask == 0xff) { - if (format != PIPE_FORMAT_R8G8B8A8_UNORM) + if (format != PIPE_FORMAT_RGBA_UNORM) goto fail; } else { -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/14] util: Convert color pack to packed formats
From: Richard Sandiford This fixes them on big-endian. Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/auxiliary/util/u_pack_color.h | 36 +++ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 1f6a56a..102ad60 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -65,32 +65,32 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, enum pipe_format format, union util_color *uc) { switch (format) { - case PIPE_FORMAT_A8B8G8R8_UNORM: + case PIPE_FORMAT_ABGR_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | a; } return; - case PIPE_FORMAT_X8B8G8R8_UNORM: + case PIPE_FORMAT_XBGR_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_BGRA_UNORM: { uc->ui = (a << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_BGRX_UNORM: { uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_ARGB_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | a; } return; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_XRGB_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; } @@ -166,7 +166,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, ubyte *r, ubyte *g, ubyte *b, ubyte *a) { switch (format) { - case PIPE_FORMAT_A8B8G8R8_UNORM: + case PIPE_FORMAT_ABGR_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 24) & 0xff); @@ -175,7 +175,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) ((p >> 0) & 0xff); } return; - case PIPE_FORMAT_X8B8G8R8_UNORM: + case PIPE_FORMAT_XBGR_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 24) & 0xff); @@ -184,7 +184,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_BGRA_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 16) & 0xff); @@ -193,7 +193,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) ((p >> 24) & 0xff); } return; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_BGRX_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 16) & 0xff); @@ -202,7 +202,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_ARGB_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 8) & 0xff); @@ -211,7 +211,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) ((p >> 0) & 0xff); } return; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_XRGB_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 8) & 0xff); @@ -350,32 +350,32 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * } switch (format) { - case PIPE_FORMAT_A8B8G8R8_UNORM: + case PIPE_FORMAT_ABGR_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | a; } return; - case PIPE_FORMAT_X8B8G8R8_UNORM: + case PIPE_FORMAT_XBGR_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_BGRA_UNORM: { uc->ui = (a << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_BGRX_UNORM: { uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_ARGB_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | a; } return; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_XRGB_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; } -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/14] llvmpipe: Fix convert_to_blend_type on big-endian
From: Richard Sandiford Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index fc2ba5e..38e9fc7 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1015,12 +1015,17 @@ convert_to_blend_type(struct gallivm_state *gallivm, for (i = 0; i < num_srcs; ++i) { LLVMValueRef chans[4]; LLVMValueRef res = NULL; - unsigned sa = 0; dst[i] = LLVMBuildZExt(builder, src[i], lp_build_vec_type(gallivm, src_type), ""); for (j = 0; j < src_fmt->nr_channels; ++j) { unsigned mask = 0; + unsigned sa = src_fmt->channel[j].shift; +#ifdef PIPE_ARCH_LITTLE_ENDIAN + unsigned from_lsb = j; +#else + unsigned from_lsb = src_fmt->nr_channels - j - 1; +#endif for (k = 0; k < src_fmt->channel[j].size; ++k) { mask |= 1 << k; @@ -1046,11 +1051,9 @@ convert_to_blend_type(struct gallivm_state *gallivm, /* Insert bits into correct position */ chans[j] = LLVMBuildShl(builder, chans[j], - lp_build_const_int_vec(gallivm, src_type, j * blend_type.width), + lp_build_const_int_vec(gallivm, src_type, from_lsb * blend_type.width), ""); - sa += src_fmt->channel[j].size; - if (j == 0) { res = chans[j]; } else { @@ -1166,12 +1169,17 @@ convert_from_blend_type(struct gallivm_state *gallivm, for (i = 0; i < num_srcs; ++i) { LLVMValueRef chans[4]; LLVMValueRef res = NULL; - unsigned sa = 0; dst[i] = LLVMBuildBitCast(builder, src[i], lp_build_vec_type(gallivm, src_type), ""); for (j = 0; j < src_fmt->nr_channels; ++j) { unsigned mask = 0; + unsigned sa = src_fmt->channel[j].shift; +#ifdef PIPE_ARCH_LITTLE_ENDIAN + unsigned from_lsb = j; +#else + unsigned from_lsb = src_fmt->nr_channels - j - 1; +#endif assert(blend_type.width > src_fmt->channel[j].size); @@ -1182,7 +1190,7 @@ convert_from_blend_type(struct gallivm_state *gallivm, /* Extract bits */ chans[j] = LLVMBuildLShr(builder, dst[i], - lp_build_const_int_vec(gallivm, src_type, j * blend_type.width), + lp_build_const_int_vec(gallivm, src_type, from_lsb * blend_type.width), ""); chans[j] = LLVMBuildAnd(builder, -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/14] gallivm: Fix big-endian machines
From: Richard Sandiford This adds a bit-shift count to the format table, and adds the concept of vector or bitwise alignment on gathers. Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/auxiliary/gallivm/lp_bld_format_aos.c | 22 +++ src/gallium/auxiliary/gallivm/lp_bld_format_soa.c | 17 +++-- src/gallium/auxiliary/gallivm/lp_bld_format_yuv.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_gather.c | 25 +-- src/gallium/auxiliary/gallivm/lp_bld_gather.h | 6 +- src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c | 4 +- src/gallium/auxiliary/gallivm/lp_bld_swizzle.c| 80 --- src/gallium/auxiliary/util/u_format.h | 25 ++- src/gallium/auxiliary/util/u_format_pack.py | 8 +-- src/gallium/auxiliary/util/u_format_parse.py | 10 +++ src/gallium/auxiliary/util/u_format_table.py | 4 +- src/gallium/drivers/llvmpipe/lp_bld_depth.c | 29 ++-- 12 files changed, 145 insertions(+), 87 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c index 3675e68..af755d4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c @@ -139,12 +139,12 @@ format_matches_type(const struct util_format_description *desc, /** - * Unpack a single pixel into its RGBA components. + * Unpack a single pixel into its XYZW components. * * @param desc the pixel format for the packed pixel value * @param packed integer pixel in a format such as PIPE_FORMAT_B8G8R8A8_UNORM * - * @return RGBA in a float[4] or ubyte[4] or ushort[4] vector. + * @return XYZW in a float[4] or ubyte[4] or ushort[4] vector. */ static INLINE LLVMValueRef lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm, @@ -159,7 +159,6 @@ lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm, boolean normalized; boolean needs_uitofp; - unsigned shift; unsigned i; /* TODO: Support more formats */ @@ -190,11 +189,11 @@ lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm, /* Initialize vector constants */ normalized = FALSE; needs_uitofp = FALSE; - shift = 0; /* Loop over 4 color components */ for (i = 0; i < 4; ++i) { unsigned bits = desc->channel[i].size; + unsigned shift = desc->channel[i].shift; if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID) { shifts[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context)); @@ -220,12 +219,10 @@ lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm, else scales[i] = lp_build_const_float(gallivm, 1.0); } - - shift += bits; } - /* Ex: convert packed = {BGRA, BGRA, BGRA, BGRA} -* into masked = {B, G, R, A} + /* Ex: convert packed = {XYZW, XYZW, XYZW, XYZW} +* into masked = {X, Y, Z, W} */ shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), ""); masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), ""); @@ -272,7 +269,6 @@ lp_build_pack_rgba_aos(struct gallivm_state *gallivm, LLVMValueRef shifts[4]; LLVMValueRef scales[4]; boolean normalized; - unsigned shift; unsigned i, j; assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); @@ -298,9 +294,9 @@ lp_build_pack_rgba_aos(struct gallivm_state *gallivm, LLVMConstVector(swizzles, 4), ""); normalized = FALSE; - shift = 0; for (i = 0; i < 4; ++i) { unsigned bits = desc->channel[i].size; + unsigned shift = desc->channel[i].shift; if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID) { shifts[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context)); @@ -321,8 +317,6 @@ lp_build_pack_rgba_aos(struct gallivm_state *gallivm, else scales[i] = lp_build_const_float(gallivm, 1.0); } - - shift += bits; } if (normalized) @@ -406,7 +400,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, packed = lp_build_gather(gallivm, type.length/4, format_desc->block.bits, type.width*4, - base_ptr, offset); + base_ptr, offset, TRUE); assert(format_desc->block.bits <= vec_len); @@ -444,7 +438,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm, packed = lp_build_gather_elem(gallivm, num_pixels, format_desc->block.bits, 32, - base_ptr, offset, k); + base_ptr, offset, k, FALSE); tmps[k] = lp_build_unpack_arith_rgba_aos(gallivm, format_desc, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index edc2442..a822e1a 100644 --- a/src/gallium/a
[Mesa-dev] [PATCH 14/14] gallivm: Fix lp_build_rgba8_to_fi32_soa for big endian
From: Richard Sandiford Reviewed-by: Adam Jackson Signed-off-by: Richard Sandiford --- src/gallium/auxiliary/gallivm/lp_bld_format_soa.c | 4 1 file changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index a822e1a..4c6bd81 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c @@ -288,7 +288,11 @@ lp_build_rgba8_to_fi32_soa(struct gallivm_state *gallivm, /* Decode the input vector components */ for (chan = 0; chan < 4; ++chan) { +#ifdef PIPE_ARCH_LITTLE_ENDIAN unsigned start = chan*8; +#else + unsigned start = (3-chan)*8; +#endif unsigned stop = start + 8; LLVMValueRef input; -- 1.8.2.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 04/14] gallium: Document packed formats
On Die, 2013-06-18 at 13:28 -0400, Adam Jackson wrote: > Signed-off-by: Adam Jackson > --- > src/gallium/docs/format.rst | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/src/gallium/docs/format.rst b/src/gallium/docs/format.rst > index 2514656..e270d93 100644 > --- a/src/gallium/docs/format.rst > +++ b/src/gallium/docs/format.rst > @@ -6,7 +6,14 @@ Gallium format names mostly follow D3D10 conventions, with > some extensions. > Format names like XnYnZnWn have the X component in the lowest-address n bits > and the W component in the highest-address n bits; for B8G8R8A8, byte 0 is > blue and byte 3 is alpha. Note that platform endianness is not considered > -in this definition. > +in this definition. In C: > + > +struct xyzw { uint8_t x, y, z, w; }; It seems a tad confusing to call this xyzw, as opposed to x8y8z8w8. Other than that, the series looks good to me. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] glsl: Add simple vector type accessor helpers.
On 06/18/2013 06:47 AM, Ian Romanick wrote: On 06/18/2013 04:22 AM, Kenneth Graunke wrote: This patch introduces new functions to quickly grab a pointer to a vector type. For example: glsl_type::bvec(4) returns glsl_type::bvec4_type glsl_type::ivec(3) returns glsl_type::ivec3_type glsl_type::uvec(2) returns glsl_type::uvec2_type glsl_type::vec(1)returns glsl_type::float_type This is less wordy than glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1), which can help avoid extra word wrapping. One thing that's annoying about this code is that we have so many ways to get at types. You can get them from a symbol table, you can get them from the direct pointers, you can get them from pointer math, or you can get them from get_instance. I'm not sure replacing one with another makes it much better. I remember considering having separate overloads of get_instance for vectors and matrices. I don't recall why I didn't do it that way. Signed-off-by: Kenneth Graunke --- src/glsl/glsl_types.cpp | 52 + src/glsl/glsl_types.h | 9 + 2 files changed, 61 insertions(+) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index df9c5d3..a5491c5 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -534,6 +534,58 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : } +const glsl_type *const +glsl_type::vec(unsigned components) +{ + if (components == 0 || components > 4) + return error_type; + + static const glsl_type *const ts[] = { + float_type, vec2_type, vec3_type, vec4_type + }; + return ts[components - 1]; We could just embed this code in get_instance. That seems better than adding new methods that are only used in method that's part of the same class. They're also used in patch 3, outside the class. That was the motivation for adding them...and I thought it was a bit tidier this way. But if you'd prefer just putting this in get_instance, that's fine by me...it's what I originally did in v0 of this series anyway. --Ken ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/6] mesa: Use shared code for converting shader targets to short strings.
Kenneth Graunke writes: > On 06/17/2013 04:10 PM, Eric Anholt wrote: >> We were duplicating this code all over the place, and they all would need >> updating for the next set of shader targets. >> --- >> src/glsl/glsl_parser_extras.cpp| 35 >> ++ >> src/glsl/glsl_parser_extras.h | 3 +++ >> src/glsl/link_varyings.cpp | 15 - >> src/glsl/linker.cpp| 4 ++-- >> src/mesa/drivers/dri/i965/brw_shader.cpp | 9 >> src/mesa/main/shaderapi.c | 17 ++- >> src/mesa/main/uniform_query.cpp| 9 ++-- >> src/mesa/program/ir_to_mesa.cpp| 5 + >> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 ++ >> 9 files changed, 61 insertions(+), 43 deletions(-) >> >> diff --git a/src/glsl/glsl_parser_extras.cpp >> b/src/glsl/glsl_parser_extras.cpp >> index 9862714..7b827ba 100644 >> --- a/src/glsl/glsl_parser_extras.cpp >> +++ b/src/glsl/glsl_parser_extras.cpp >> @@ -302,6 +302,41 @@ >> _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version, >> } >> } >> >> +extern "C" { >> + >> +/** >> + * The most common use of _mesa_glsl_shader_target_name(), which is >> + * shared with C code in Mesa core to translate a GLenum to a short >> + * shader stage name in debug printouts. >> + * >> + * It recognizes the PROGRAM variants of the names so it can be used >> + * with a struct gl_program->Target, not just a struct >> + * gl_shader->Type. >> + */ >> +const char * >> +_mesa_glsl_shader_target_name(GLenum type) >> +{ >> + switch (type) { >> + case GL_VERTEX_SHADER: >> + case GL_VERTEX_PROGRAM_ARB: >> + return "vertex"; >> + case GL_FRAGMENT_SHADER: >> + case GL_FRAGMENT_PROGRAM_ARB: >> + return "fragment"; >> + case GL_GEOMETRY_SHADER: >> + return "geometry"; >> + default: >> + assert(!"Should not get here."); >> + return "unknown"; >> + } >> +} >> + >> +} /* extern "C" */ >> + >> +/** >> + * Overloaded C++ variant usable within the compiler for translating >> + * our internal enum into short stage names. >> + */ >> const char * >> _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) >> { > > I'm kind of wary of having an overloaded function where the > distinguisher is GLenum (int) vs. enum (basically int). I think the C > vs. C++ enum rules save us here, but still not something I'm crazy about. > > Still, this is a really nice cleanup. I'm glad to see this centralized, > as well as the vertex/fragment hardcoding going away. Yeah, I wasn't really happy with it either, but I was having a hell of a time coming up with names to distinguish the two that weren't ridiculously verbose. I'd much rather see us consistently use either the enum or the GLenum throughout mesa. The GL_VERTEX_PROGRAM vs GL_VERTEX_SHADER is the worst, though. pgplDOO6g1Yxr.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 65898] Low(er) FPS in Half-Life 2 on Arch Linux
https://bugs.freedesktop.org/show_bug.cgi?id=65898 --- Comment #2 from Eric Anholt --- If you're interested in investigating on your own, there is information at http://dri.freedesktop.org/wiki/IntelPerformanceTuning/ for how we go about investigating things. There is also a TODO list of likely things at http://dri.freedesktop.org/wiki/I965Todo/ -- You are receiving this mail because: 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 4/6] mesa: Use shared code for converting shader targets to short strings.
On 06/18/2013 12:12 PM, Eric Anholt wrote: Kenneth Graunke writes: On 06/17/2013 04:10 PM, Eric Anholt wrote: We were duplicating this code all over the place, and they all would need updating for the next set of shader targets. --- src/glsl/glsl_parser_extras.cpp| 35 ++ src/glsl/glsl_parser_extras.h | 3 +++ src/glsl/link_varyings.cpp | 15 - src/glsl/linker.cpp| 4 ++-- src/mesa/drivers/dri/i965/brw_shader.cpp | 9 src/mesa/main/shaderapi.c | 17 ++- src/mesa/main/uniform_query.cpp| 9 ++-- src/mesa/program/ir_to_mesa.cpp| 5 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 ++ 9 files changed, 61 insertions(+), 43 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 9862714..7b827ba 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -302,6 +302,41 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version, } } +extern "C" { + +/** + * The most common use of _mesa_glsl_shader_target_name(), which is + * shared with C code in Mesa core to translate a GLenum to a short + * shader stage name in debug printouts. + * + * It recognizes the PROGRAM variants of the names so it can be used + * with a struct gl_program->Target, not just a struct + * gl_shader->Type. + */ +const char * +_mesa_glsl_shader_target_name(GLenum type) +{ + switch (type) { + case GL_VERTEX_SHADER: + case GL_VERTEX_PROGRAM_ARB: + return "vertex"; + case GL_FRAGMENT_SHADER: + case GL_FRAGMENT_PROGRAM_ARB: + return "fragment"; + case GL_GEOMETRY_SHADER: + return "geometry"; + default: + assert(!"Should not get here."); + return "unknown"; + } +} + +} /* extern "C" */ + +/** + * Overloaded C++ variant usable within the compiler for translating + * our internal enum into short stage names. + */ const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) { I'm kind of wary of having an overloaded function where the distinguisher is GLenum (int) vs. enum (basically int). I think the C vs. C++ enum rules save us here, but still not something I'm crazy about. Still, this is a really nice cleanup. I'm glad to see this centralized, as well as the vertex/fragment hardcoding going away. Yeah, I wasn't really happy with it either, but I was having a hell of a time coming up with names to distinguish the two that weren't ridiculously verbose. I'd much rather see us consistently use either the enum or the GLenum throughout mesa. The GL_VERTEX_PROGRAM vs GL_VERTEX_SHADER is the worst, though. Yeah, I agree - it's not obvious which are the MESA_SHADER_VERTEX enums and which are the GL_VERTEX_SHADER enums. I do like how you handle both GL enums in this function. I think this is sensible and we can tidy up the enums in the future. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gen7: fix GPU hang on WebGL texture-size test
Paul Berry writes: > On 18 June 2013 01:09, Jordan Justen wrote: > >> When rendering to a texture with BaseLevel set, the miptree may be laid >> out such that BaseLevel is in level 0 of the miptree (to avoid wasting >> memory on unused levels between 0 and BaseLevel-1). In that case, we >> have to shift our render target's level down to the appropriate level of >> the smaller miptree. >> >> The WebGL test in combination with a meta code relating to >> glGenerateMipmap also triggered a similar failure scenario. >> >> This GPU hang regression was introduced by c754f7a8. >> >> Bugzilla: http://bugs.freedesktop.org/show_bug.cgi?id=65324 >> Signed-off-by: Jordan Justen >> Cc: Eric Anholt >> Cc: Kenneth Graunke >> Cc: Paul Berry >> --- >> Given all of Eric's help, this is probably more his patch than mine... :) >> >> src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c >> b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c >> index 22ceaa5..620eafe 100644 >> --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c >> +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c >> @@ -595,7 +595,7 @@ gen7_update_renderbuffer_surface(struct brw_context >> *brw, >> >> assert(brw->has_surface_tile_offset); >> >> - surf[5] = irb->mt_level; >> + surf[5] = irb->mt_level - irb->mt->first_level; >> >> surf[2] = SET_FIELD(irb->mt->logical_width0 - 1, GEN7_SURFACE_WIDTH) | >> SET_FIELD(irb->mt->logical_height0 - 1, GEN7_SURFACE_HEIGHT); >> -- >> 1.7.10.4 >> >> > How difficult would it be to make a Piglit test to validate this, > preferably one that verifies that depth/stencil rendering properly accounts > for first_level != 0? I want to make sure that when we make the > corresponding changes to depth/stencil rendering we don't accidentally > introduce the same bug. > > In any case, this patch is: > > Reviwed-by: Paul Berry There's this really twitchy code for guessing an appropriate first_level based on various GL state set at the moment you glTexImage() (or similar calls, such as those baked into GenerateMipmaps()). I found a field in i915's HW state that I think I'd missed before when I tried to rip this crap out, and there's a similar one in 855+, so I think I can go kill it. I think a test that would have broken would be: gen the texture, set the base level to >0, set the filters to NEAREST, then TexImage(), then render to that teximage using an FBO, then texture out of it to the screen. pgp9AKEGC3Ttm.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 65898] Low(er) FPS in Half-Life 2 on Arch Linux
https://bugs.freedesktop.org/show_bug.cgi?id=65898 --- Comment #3 from Chris Forbes --- > motion blur enabled If that's correct, you probably want to get rid of it. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] gallium: fix PIPE_QUERY_TIMESTAMP_DISJOINT
From: Roland Scheidegger The semantics didn't really make sense, not really matching neither d3d9 (though the docs are all broken there) nor d3d10. So make it match d3d10 semantics, which actually gives meaning to the "disjoint" part. Drivers are fixed up in a very primitive way, I have no idea what could actually cause the counter to become unreliable so just always return FALSE for the disjoint part. --- src/gallium/docs/source/context.rst | 10 ++ src/gallium/drivers/nv50/nv50_query.c |5 +++-- src/gallium/drivers/nvc0/nvc0_query.c |4 +--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index ede89be..bfd58a4 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -330,11 +330,13 @@ scaled to nanoseconds, recorded after all commands issued prior to This query does not require a call to ``begin_query``. The result is an unsigned 64-bit integer. -``PIPE_QUERY_TIMESTAMP_DISJOINT`` can be used to check whether the -internal timer resolution is good enough to distinguish between the -events at ``begin_query`` and ``end_query``. +``PIPE_QUERY_TIMESTAMP_DISJOINT`` can be used to check the +internal timer resolution and whether the timestamp counter has become +unreliable due to things like throttling etc. - only if this is FALSE +a timestamp query (within the timestamp_disjoint query) should be trusted. The result is a 64-bit integer specifying the timer resolution in Hz, -followed by a boolean value indicating whether the timer has incremented. +followed by a boolean value indicating whether the timestamp counter +is discontinuous or disjoint. ``PIPE_QUERY_PRIMITIVES_GENERATED`` returns a 64-bit integer indicating the number of primitives processed by the pipeline (regardless of whether diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index 656ff9d..b97eff2 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -181,7 +181,6 @@ nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq) nv50_query_get(push, q, 0x20, 0x05805002); nv50_query_get(push, q, 0x30, 0x06805002); break; - case PIPE_QUERY_TIMESTAMP_DISJOINT: case PIPE_QUERY_TIME_ELAPSED: nv50_query_get(push, q, 0x10, 0x5002); break; @@ -229,6 +228,8 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) case NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET: nv50_query_get(push, q, 0, 0x0d005002 | (q->index << 5)); break; + case PIPE_QUERY_TIMESTAMP_DISJOINT: + break; default: assert(0); break; @@ -289,7 +290,7 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, break; case PIPE_QUERY_TIMESTAMP_DISJOINT: /* u32 sequence, u32 0, u64 time */ res64[0] = 10; - res8[8] = (data64[1] == data64[3]) ? FALSE : TRUE; + res8[8] = FALSE; break; case PIPE_QUERY_TIME_ELAPSED: res64[0] = data64[1] - data64[3]; diff --git a/src/gallium/drivers/nvc0/nvc0_query.c b/src/gallium/drivers/nvc0/nvc0_query.c index 8e584c9..3f5a9fb 100644 --- a/src/gallium/drivers/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nvc0/nvc0_query.c @@ -285,7 +285,6 @@ nvc0_query_begin(struct pipe_context *pipe, struct pipe_query *pq) case PIPE_QUERY_SO_OVERFLOW_PREDICATE: nvc0_query_get(push, q, 0x10, 0x03005002 | (q->index << 5)); break; - case PIPE_QUERY_TIMESTAMP_DISJOINT: case PIPE_QUERY_TIME_ELAPSED: nvc0_query_get(push, q, 0x10, 0x5002); break; @@ -360,7 +359,6 @@ nvc0_query_end(struct pipe_context *pipe, struct pipe_query *pq) nvc0_query_get(push, q, 0x20, 0x5002); break; case PIPE_QUERY_TIMESTAMP: - case PIPE_QUERY_TIMESTAMP_DISJOINT: case PIPE_QUERY_TIME_ELAPSED: nvc0_query_get(push, q, 0, 0x5002); break; @@ -478,7 +476,7 @@ nvc0_query_result(struct pipe_context *pipe, struct pipe_query *pq, break; case PIPE_QUERY_TIMESTAMP_DISJOINT: /* u32 sequence, u32 0, u64 time */ res64[0] = 10; - res8[8] = (data64[1] == data64[3]) ? FALSE : TRUE; + res8[8] = FALSE; break; case PIPE_QUERY_TIME_ELAPSED: res64[0] = data64[1] - data64[3]; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] softpipe: handle all queries, and change for the new disjoint semantics
From: Roland Scheidegger The driver can do render_condition but wasn't handling the occlusion and so_overflow predicates (though the latter might not work yet due to gs support). --- src/gallium/drivers/softpipe/sp_query.c | 39 ++- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index b5bc0db..daeef53 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -60,8 +60,10 @@ softpipe_create_query(struct pipe_context *pipe, struct softpipe_query* sq; assert(type == PIPE_QUERY_OCCLUSION_COUNTER || + type == PIPE_QUERY_OCCLUSION_PREDICATE || type == PIPE_QUERY_TIME_ELAPSED || type == PIPE_QUERY_SO_STATISTICS || + type == PIPE_QUERY_SO_OVERFLOW_PREDICATE || type == PIPE_QUERY_PRIMITIVES_EMITTED || type == PIPE_QUERY_PRIMITIVES_GENERATED || type == PIPE_QUERY_PIPELINE_STATISTICS || @@ -90,9 +92,9 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) switch (sq->type) { case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: sq->start = softpipe->occlusion_count; break; - case PIPE_QUERY_TIMESTAMP_DISJOINT: case PIPE_QUERY_TIME_ELAPSED: sq->start = os_time_get_nano(); break; @@ -102,6 +104,10 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) softpipe->num_primitives_generated = 0; sq->so.num_primitives_written = 0; softpipe->so_stats.num_primitives_written = 0; + break; + case PIPE_QUERY_SO_OVERFLOW_PREDICATE: + sq->end = FALSE; + break; case PIPE_QUERY_PRIMITIVES_EMITTED: sq->so.num_primitives_written = 0; softpipe->so_stats.num_primitives_written = 0; @@ -112,6 +118,7 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) break; case PIPE_QUERY_TIMESTAMP: case PIPE_QUERY_GPU_FINISHED: + case PIPE_QUERY_TIMESTAMP_DISJOINT: break; case PIPE_QUERY_PIPELINE_STATISTICS: /* reset our cache */ @@ -141,15 +148,19 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) softpipe->active_query_count--; switch (sq->type) { case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: sq->end = softpipe->occlusion_count; break; case PIPE_QUERY_TIMESTAMP: sq->start = 0; /* fall through */ - case PIPE_QUERY_TIMESTAMP_DISJOINT: case PIPE_QUERY_TIME_ELAPSED: sq->end = os_time_get_nano(); break; + case PIPE_QUERY_SO_OVERFLOW_PREDICATE: + sq->end = (softpipe->num_primitives_generated > + softpipe->so_stats.num_primitives_written); + break; case PIPE_QUERY_SO_STATISTICS: sq->num_primitives_generated = softpipe->num_primitives_generated; @@ -164,6 +175,7 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) sq->num_primitives_generated = softpipe->num_primitives_generated; break; case PIPE_QUERY_GPU_FINISHED: + case PIPE_QUERY_TIMESTAMP_DISJOINT: break; case PIPE_QUERY_PIPELINE_STATISTICS: sq->stats.ia_vertices = @@ -195,9 +207,9 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) static boolean softpipe_get_query_result(struct pipe_context *pipe, - struct pipe_query *q, - boolean wait, - union pipe_query_result *vresult) + struct pipe_query *q, + boolean wait, + union pipe_query_result *vresult) { struct softpipe_query *sq = softpipe_query(q); uint64_t *result = (uint64_t*)vresult; @@ -215,15 +227,17 @@ softpipe_get_query_result(struct pipe_context *pipe, sizeof(struct pipe_query_data_pipeline_statistics));; break; case PIPE_QUERY_GPU_FINISHED: - *result = TRUE; + vresult->b = TRUE; + break; + case PIPE_QUERY_SO_OVERFLOW_PREDICATE: + vresult->b = sq->end != 0; break; case PIPE_QUERY_TIMESTAMP_DISJOINT: { - struct pipe_query_data_timestamp_disjoint td; + struct pipe_query_data_timestamp_disjoint *td = + (struct pipe_query_data_timestamp_disjoint *)vresult; /* os_get_time_nano return nanoseconds */ - td.frequency = UINT64_C(10); - td.disjoint = sq->end != sq->start; - memcpy(vresult, &td, - sizeof(struct pipe_query_data_timestamp_disjoint)); + td->frequency = UINT64_C(10); + td->disjoint = FALSE; } break; case PIPE_QUERY_PRIMITIVES_EMITTED: @@ -232,6 +246,9 @@ softpipe_get_query_result(struct pipe_context *pipe, case PIPE_QUERY_PRIMITIVES_GENERATED: *result = sq->num_primitives_generated; break; + case PIPE_QUERY_OCCLUSIO
[Mesa-dev] [Bug 65910] Killing weston-launch causes segv in desktop-shell
https://bugs.freedesktop.org/show_bug.cgi?id=65910 Kristian Høgsberg changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Assignee|wayland-bugs@lists.freedesk |mesa-dev@lists.freedesktop. |top.org |org Product|Wayland |Mesa Version|unspecified |git Component|weston |Other --- Comment #3 from Kristian Høgsberg --- This was a mesa bug: commit 712269d6744a8849d1d0cf01fa0132d969b79ed4 Author: Kristian Høgsberg Date: Tue Jun 18 16:53:46 2013 -0400 wayland: Handle global_remove event as well We need to set up a handler for the global_remove event that gets sent out when a global gets removed. Without the handler we end up calling a NULL pointer. https://bugs.freedesktop.org/show_bug.cgi?id=65910 NOTE: This is a candidate for the stable branches. Signed-off-by: Kristian Høgsberg -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 65910] Killing weston-launch causes segv in desktop-shell
https://bugs.freedesktop.org/show_bug.cgi?id=65910 Kristian Høgsberg changed: What|Removed |Added Component|Other |EGL --- Comment #4 from Kristian Høgsberg --- (added EGL component for mesa, moved bug there) -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 65910] Killing weston-launch causes segv in desktop-shell
https://bugs.freedesktop.org/show_bug.cgi?id=65910 Joe Konno changed: What|Removed |Added Status|RESOLVED|VERIFIED --- Comment #5 from Joe Konno --- Thanks krh! I can verify your fix corrects the reported issue, so I'm setting status to "verified." (In reply to comment #3) > This was a mesa bug: > > commit 712269d6744a8849d1d0cf01fa0132d969b79ed4 > Author: Kristian Høgsberg > Date: Tue Jun 18 16:53:46 2013 -0400 > > wayland: Handle global_remove event as well > > We need to set up a handler for the global_remove event that gets sent > out when a global gets removed. Without the handler we end up calling > a NULL pointer. > > https://bugs.freedesktop.org/show_bug.cgi?id=65910 > > NOTE: This is a candidate for the stable branches. > > Signed-off-by: Kristian Høgsberg -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] R600/SI: Add support for v4i32 and v4f32 kernel args
From: Tom Stellard --- lib/Target/R600/AMDGPUCallingConv.td| 9 + test/CodeGen/R600/128bit-kernel-args.ll | 16 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/Target/R600/AMDGPUCallingConv.td b/lib/Target/R600/AMDGPUCallingConv.td index 84e4f3a..826932b 100644 --- a/lib/Target/R600/AMDGPUCallingConv.td +++ b/lib/Target/R600/AMDGPUCallingConv.td @@ -38,10 +38,11 @@ def CC_SI : CallingConv<[ // Calling convention for SI compute kernels def CC_SI_Kernel : CallingConv<[ - CCIfType<[i64], CCAssignToStack <8, 4>>, - CCIfType<[i32, f32], CCAssignToStack <4, 4>>, - CCIfType<[i16], CCAssignToStack <2, 4>>, - CCIfType<[i8], CCAssignToStack <1, 4>> + CCIfType<[v4i32, v4f32], CCAssignToStack <16, 4>>, + CCIfType<[i64], CCAssignToStack < 8, 4>>, + CCIfType<[i32, f32], CCAssignToStack < 4, 4>>, + CCIfType<[i16], CCAssignToStack < 2, 4>>, + CCIfType<[i8], CCAssignToStack < 1, 4>> ]>; def CC_AMDGPU : CallingConv<[ diff --git a/test/CodeGen/R600/128bit-kernel-args.ll b/test/CodeGen/R600/128bit-kernel-args.ll index 114f9e7..bd60385 100644 --- a/test/CodeGen/R600/128bit-kernel-args.ll +++ b/test/CodeGen/R600/128bit-kernel-args.ll @@ -1,16 +1,20 @@ -;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s - -; CHECK: @v4i32_kernel_arg -; CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 +; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=R600-CHECK +; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s --check-prefix=SI-CHECK +; R600-CHECK: @v4i32_kernel_arg +; R600-CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 +; SI-CHECK: @v4i32_kernel_arg +; SI-CHECK: BUFFER_STORE_DWORDX4 define void @v4i32_kernel_arg(<4 x i32> addrspace(1)* %out, <4 x i32> %in) { entry: store <4 x i32> %in, <4 x i32> addrspace(1)* %out ret void } -; CHECK: @v4f32_kernel_arg -; CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 +; R600-CHECK: @v4f32_kernel_arg +; R600-CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 +; SI-CHECK: @v4f32_kernel_arg +; SI-CHECK: BUFFER_STORE_DWORDX4 define void @v4f32_kernel_args(<4 x float> addrspace(1)* %out, <4 x float> %in) { entry: store <4 x float> %in, <4 x float> addrspace(1)* %out -- 1.7.11.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] R600/SI: Add support for v4i32 and v4f32 kernel args
Tested on Pitcairn by: Aaron Watry Follow-up question: Would it be as easy as it looks to add v2i32 right away? On Tue, Jun 18, 2013 at 6:21 PM, Tom Stellard wrote: > From: Tom Stellard > > --- > lib/Target/R600/AMDGPUCallingConv.td| 9 + > test/CodeGen/R600/128bit-kernel-args.ll | 16 ++-- > 2 files changed, 15 insertions(+), 10 deletions(-) > > diff --git a/lib/Target/R600/AMDGPUCallingConv.td > b/lib/Target/R600/AMDGPUCallingConv.td > index 84e4f3a..826932b 100644 > --- a/lib/Target/R600/AMDGPUCallingConv.td > +++ b/lib/Target/R600/AMDGPUCallingConv.td > @@ -38,10 +38,11 @@ def CC_SI : CallingConv<[ > > // Calling convention for SI compute kernels > def CC_SI_Kernel : CallingConv<[ > - CCIfType<[i64], CCAssignToStack <8, 4>>, > - CCIfType<[i32, f32], CCAssignToStack <4, 4>>, > - CCIfType<[i16], CCAssignToStack <2, 4>>, > - CCIfType<[i8], CCAssignToStack <1, 4>> > + CCIfType<[v4i32, v4f32], CCAssignToStack <16, 4>>, > + CCIfType<[i64], CCAssignToStack < 8, 4>>, > + CCIfType<[i32, f32], CCAssignToStack < 4, 4>>, > + CCIfType<[i16], CCAssignToStack < 2, 4>>, > + CCIfType<[i8], CCAssignToStack < 1, 4>> > ]>; > > def CC_AMDGPU : CallingConv<[ > diff --git a/test/CodeGen/R600/128bit-kernel-args.ll > b/test/CodeGen/R600/128bit-kernel-args.ll > index 114f9e7..bd60385 100644 > --- a/test/CodeGen/R600/128bit-kernel-args.ll > +++ b/test/CodeGen/R600/128bit-kernel-args.ll > @@ -1,16 +1,20 @@ > -;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s > - > -; CHECK: @v4i32_kernel_arg > -; CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 > +; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s > --check-prefix=R600-CHECK > +; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s --check-prefix=SI-CHECK > > +; R600-CHECK: @v4i32_kernel_arg > +; R600-CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 > +; SI-CHECK: @v4i32_kernel_arg > +; SI-CHECK: BUFFER_STORE_DWORDX4 > define void @v4i32_kernel_arg(<4 x i32> addrspace(1)* %out, <4 x i32> %in) { > entry: >store <4 x i32> %in, <4 x i32> addrspace(1)* %out >ret void > } > > -; CHECK: @v4f32_kernel_arg > -; CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 > +; R600-CHECK: @v4f32_kernel_arg > +; R600-CHECK: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 40 > +; SI-CHECK: @v4f32_kernel_arg > +; SI-CHECK: BUFFER_STORE_DWORDX4 > define void @v4f32_kernel_args(<4 x float> addrspace(1)* %out, <4 x float> > %in) { > entry: >store <4 x float> %in, <4 x float> addrspace(1)* %out > -- > 1.7.11.4 > > ___ > llvm-commits mailing list > llvm-comm...@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] llvmpipe: handle more queries
From: Roland Scheidegger Handle PIPE_QUERY_GPU_FINISHED and PIPE_QUERY_TIMESTAMP_DISJOINT, and also fill out the ps_invocations and c_primitives from the PIPE_QUERY_PIPELINE_STATISTICS (the others in there should already be handled). Note that ps_invocations isn't pixel exact, just 16 pixel exact but I guess it's better than nothing. Doesn't really seem to work correctly but there's probably bugs elsewhere. Also use a 64bit counter for occlusion queries. --- src/gallium/drivers/llvmpipe/lp_bld_depth.c | 11 --- src/gallium/drivers/llvmpipe/lp_jit.c |2 +- src/gallium/drivers/llvmpipe/lp_jit.h |2 +- src/gallium/drivers/llvmpipe/lp_query.c | 23 --- src/gallium/drivers/llvmpipe/lp_rast.c| 19 --- src/gallium/drivers/llvmpipe/lp_rast_priv.h |6 +- src/gallium/drivers/llvmpipe/lp_setup.c |4 ++-- src/gallium/drivers/llvmpipe/lp_setup_line.c | 13 - src/gallium/drivers/llvmpipe/lp_setup_point.c | 10 +- src/gallium/drivers/llvmpipe/lp_setup_tri.c |8 10 files changed, 78 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c index edb59cc..79891cf 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c @@ -429,7 +429,7 @@ get_s_shift_and_mask(const struct util_format_description *format_desc, * Test the depth mask. Add the number of channel which has none zero mask * into the occlusion counter. e.g. maskvalue is {-1, -1, -1, -1}. * The counter will add 4. - * TODO: could get that out of the loop, and need to use 64bit counter. + * TODO: could get that out of the fs loop. * * \param type holds element type of the mask vector. * \param maskvalue is the depth test mask. @@ -458,6 +458,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm, LLVMInt32TypeInContext(context), bits); count = lp_build_intrinsic_unary(builder, popcntintr, LLVMInt32TypeInContext(context), bits); + count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), ""); } else if(util_cpu_caps.has_avx && type.length == 8) { const char *movmskintr = "llvm.x86.avx.movmsk.ps.256"; @@ -468,6 +469,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm, LLVMInt32TypeInContext(context), bits); count = lp_build_intrinsic_unary(builder, popcntintr, LLVMInt32TypeInContext(context), bits); + count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), ""); } else { unsigned i; @@ -510,8 +512,11 @@ lp_build_occlusion_count(struct gallivm_state *gallivm, } count = lp_build_intrinsic_unary(builder, popcntintr, counttype, countd); - if (type.length > 4) { - count = LLVMBuildTrunc(builder, count, LLVMIntTypeInContext(context, 32), ""); + if (type.length > 8) { + count = LLVMBuildTrunc(builder, count, LLVMIntTypeInContext(context, 64), ""); + } + else if (type.length < 8) { + count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), ""); } } newcount = LLVMBuildLoad(builder, counter, "origcount"); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index f517b67..fa0f128 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -195,7 +195,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LLVMTypeRef elem_types[LP_JIT_THREAD_DATA_COUNT]; LLVMTypeRef thread_data_type; - elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt32TypeInContext(lc); + elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt64TypeInContext(lc); thread_data_type = LLVMStructTypeInContext(lc, elem_types, Elements(elem_types), 0); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 2ecfde7..30cfaae 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -164,7 +164,7 @@ enum { struct lp_jit_thread_data { - uint32_t vis_counter; + uint64_t vis_counter; }; diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c index 922913d..7fbf5f7 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.c +++ b/src/gallium/drivers/llvmpipe/lp_query.c @@ -40,6 +40,7 @@ #include "lp_query.h" #include "lp_screen.h" #include "lp_state.h" +#include "lp_rast.h" static struct llvmpipe_query *llvmpipe_query( struct pipe_query *p ) @@ -128,7 +129,7 @@ llvmpipe_get_query_result(struct pipe_context *pipe, case PIPE_QUERY_OCCLUSION_PREDICATE: for (i = 0; i < num_thre