diff options
author | marha <marha@users.sourceforge.net> | 2011-08-29 08:51:20 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-08-29 08:51:20 +0200 |
commit | 01df5d59e56a1b060568f8cad2e89f7eea22fc70 (patch) | |
tree | 9db83037fd85d0974b60fc1a05e0665083f26000 /mesalib/src/gallium/auxiliary | |
parent | fd1f4d9fe3ea67fa6def8ee4927a8f71e0440f12 (diff) | |
download | vcxsrv-01df5d59e56a1b060568f8cad2e89f7eea22fc70.tar.gz vcxsrv-01df5d59e56a1b060568f8cad2e89f7eea22fc70.tar.bz2 vcxsrv-01df5d59e56a1b060568f8cad2e89f7eea22fc70.zip |
xwininfo libX11 libXmu libxcb mesa xserver xkeyboard-config git update 29
aug 2011
Diffstat (limited to 'mesalib/src/gallium/auxiliary')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_blitter.c | 45 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_blitter.h | 679 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 12 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c | 46 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.h | 17 |
5 files changed, 409 insertions, 390 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index 528f344a0..d8e46f07c 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -26,8 +26,8 @@ /** * @file - * Blitter utility to facilitate acceleration of the clear, clear_render_target, clear_depth_stencil - * resource_copy_region functions. + * Blitter utility to facilitate acceleration of the clear, clear_render_target, + * clear_depth_stencil, and resource_copy_region functions. * * @author Marek Olšák */ @@ -197,8 +197,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) memset(&velem[0], 0, sizeof(velem[0]) * 2); for (i = 0; i < 2; i++) { velem[i].src_offset = i * 4 * sizeof(float); - velem[i].instance_divisor = 0; - velem[i].vertex_buffer_index = 0; velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; } ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]); @@ -288,26 +286,33 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx) unsigned i; /* restore the state objects which are always required to be saved */ - pipe->bind_blend_state(pipe, ctx->base.saved_blend_state); - pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state); pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state); - pipe->bind_fs_state(pipe, ctx->base.saved_fs); pipe->bind_vs_state(pipe, ctx->base.saved_vs); pipe->bind_vertex_elements_state(pipe, ctx->base.saved_velem_state); - ctx->base.saved_blend_state = INVALID_PTR; - ctx->base.saved_dsa_state = INVALID_PTR; ctx->base.saved_rs_state = INVALID_PTR; - ctx->base.saved_fs = INVALID_PTR; ctx->base.saved_vs = INVALID_PTR; ctx->base.saved_velem_state = INVALID_PTR; + /* restore the state objects which are required to be saved for clear/copy + */ + if (ctx->base.saved_blend_state != INVALID_PTR) { + pipe->bind_blend_state(pipe, ctx->base.saved_blend_state); + ctx->base.saved_blend_state = INVALID_PTR; + } + if (ctx->base.saved_dsa_state != INVALID_PTR) { + pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state); + ctx->base.saved_dsa_state = INVALID_PTR; + } + if (ctx->base.saved_fs != INVALID_PTR) { + pipe->bind_fs_state(pipe, ctx->base.saved_fs); + ctx->base.saved_fs = INVALID_PTR; + } + pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref); pipe->set_viewport_state(pipe, &ctx->base.saved_viewport); pipe->set_clip_state(pipe, &ctx->base.saved_clip); - /* restore the state objects which are required to be saved before copy/fill - */ if (ctx->base.saved_fb_state.nr_cbufs != ~0) { pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state); util_unreference_framebuffer_state(&ctx->base.saved_fb_state); @@ -724,14 +729,14 @@ boolean is_overlap(unsigned sx1, unsigned sx2, unsigned sy1, unsigned sy2, return sx1 < dx2 && sx2 > dx1 && sy1 < dy2 && sy2 > dy1; } -void util_blitter_copy_region(struct blitter_context *blitter, - struct pipe_resource *dst, - unsigned dstlevel, - unsigned dstx, unsigned dsty, unsigned dstz, - struct pipe_resource *src, - unsigned srclevel, - const struct pipe_box *srcbox, - boolean ignore_stencil) +void util_blitter_copy_texture(struct blitter_context *blitter, + struct pipe_resource *dst, + unsigned dstlevel, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + unsigned srclevel, + const struct pipe_box *srcbox, + boolean ignore_stencil) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h index e59fe6b51..df6f023a6 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.h +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h @@ -1,338 +1,341 @@ -/**************************************************************************
- *
- * Copyright 2009 Marek Olšák <maraeo@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef U_BLITTER_H
-#define U_BLITTER_H
-
-#include "util/u_framebuffer.h"
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-
-#include "pipe/p_state.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct pipe_context;
-
-enum blitter_attrib_type {
- UTIL_BLITTER_ATTRIB_NONE,
- UTIL_BLITTER_ATTRIB_COLOR,
- UTIL_BLITTER_ATTRIB_TEXCOORD
-};
-
-struct blitter_context
-{
- /**
- * Draw a rectangle.
- *
- * \param x1 An X coordinate of the top-left corner.
- * \param y1 A Y coordinate of the top-left corner.
- * \param x2 An X coordinate of the bottom-right corner.
- * \param y2 A Y coordinate of the bottom-right corner.
- * \param depth A depth which the rectangle is rendered at.
- *
- * \param type Semantics of the attributes "attrib".
- * If type is UTIL_BLITTER_ATTRIB_NONE, ignore them.
- * If type is UTIL_BLITTER_ATTRIB_COLOR, the attributes
- * make up a constant RGBA color, and should go
- * to the GENERIC0 varying slot of a fragment shader.
- * If type is UTIL_BLITTER_ATTRIB_TEXCOORD, {a1, a2} and
- * {a3, a4} specify top-left and bottom-right texture
- * coordinates of the rectangle, respectively, and should go
- * to the GENERIC0 varying slot of a fragment shader.
- *
- * \param attrib See type.
- *
- * \note A driver may optionally override this callback to implement
- * a specialized hardware path for drawing a rectangle, e.g. using
- * a rectangular point sprite.
- */
- void (*draw_rectangle)(struct blitter_context *blitter,
- unsigned x1, unsigned y1, unsigned x2, unsigned y2,
- float depth,
- enum blitter_attrib_type type,
- const float attrib[4]);
-
- /* Whether the blitter is running. */
- boolean running;
-
- /* Private members, really. */
- struct pipe_context *pipe; /**< pipe context */
-
- void *saved_blend_state; /**< blend state */
- void *saved_dsa_state; /**< depth stencil alpha state */
- void *saved_velem_state; /**< vertex elements state */
- void *saved_rs_state; /**< rasterizer state */
- void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */
-
- struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
- struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */
- struct pipe_viewport_state saved_viewport;
- struct pipe_clip_state saved_clip;
-
- int saved_num_sampler_states;
- void *saved_sampler_states[PIPE_MAX_SAMPLERS];
-
- int saved_num_sampler_views;
- struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
-
- int saved_num_vertex_buffers;
- struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS];
-};
-
-/**
- * Create a blitter context.
- */
-struct blitter_context *util_blitter_create(struct pipe_context *pipe);
-
-/**
- * Destroy a blitter context.
- */
-void util_blitter_destroy(struct blitter_context *blitter);
-
-/**
- * Return the pipe context associated with a blitter context.
- */
-static INLINE
-struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
-{
- return blitter->pipe;
-}
-
-/*
- * These CSOs must be saved before any of the following functions is called:
- * - blend state
- * - depth stencil alpha state
- * - rasterizer state
- * - vertex shader
- * - fragment shader
- */
-
-/**
- * Clear a specified set of currently bound buffers to specified values.
- */
-void util_blitter_clear(struct blitter_context *blitter,
- unsigned width, unsigned height,
- unsigned num_cbufs,
- unsigned clear_buffers,
- const float *rgba,
- double depth, unsigned stencil);
-
-void util_blitter_clear_depth_custom(struct blitter_context *blitter,
- unsigned width, unsigned height,
- double depth, void *custom_dsa);
-
-/**
- * Copy a block of pixels from one surface to another.
- *
- * You can copy from any color format to any other color format provided
- * the former can be sampled and the latter can be rendered to. Otherwise,
- * a software fallback path is taken and both surfaces must be of the same
- * format.
- *
- * The same holds for depth-stencil formats with the exception that stencil
- * cannot be copied unless you set ignore_stencil to FALSE. In that case,
- * a software fallback path is taken and both surfaces must be of the same
- * format.
- *
- * Use pipe_screen->is_format_supported to know your options.
- *
- * These states must be saved in the blitter in addition to the state objects
- * already required to be saved:
- * - framebuffer state
- * - fragment sampler states
- * - fragment sampler textures
- */
-void util_blitter_copy_region(struct blitter_context *blitter,
- struct pipe_resource *dst,
- unsigned dstlevel,
- unsigned dstx, unsigned dsty, unsigned dstz,
- struct pipe_resource *src,
- unsigned srclevel,
- const struct pipe_box *srcbox,
- boolean ignore_stencil);
-
-/**
- * Clear a region of a (color) surface to a constant value.
- *
- * These states must be saved in the blitter in addition to the state objects
- * already required to be saved:
- * - framebuffer state
- */
-void util_blitter_clear_render_target(struct blitter_context *blitter,
- struct pipe_surface *dst,
- const float *rgba,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height);
-
-/**
- * Clear a region of a depth-stencil surface, both stencil and depth
- * or only one of them if this is a combined depth-stencil surface.
- *
- * These states must be saved in the blitter in addition to the state objects
- * already required to be saved:
- * - framebuffer state
- */
-void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
- struct pipe_surface *dst,
- unsigned clear_flags,
- double depth,
- unsigned stencil,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height);
-
-void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
- struct pipe_surface *zsurf,
- struct pipe_surface *cbsurf,
- void *dsa_stage, float depth);
-
-/* The functions below should be used to save currently bound constant state
- * objects inside a driver. The objects are automatically restored at the end
- * of the util_blitter_{clear, copy_region, fill_region} functions and then
- * forgotten.
- *
- * CSOs not listed here are not affected by util_blitter. */
-
-static INLINE
-void util_blitter_save_blend(struct blitter_context *blitter,
- void *state)
-{
- blitter->saved_blend_state = state;
-}
-
-static INLINE
-void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
- void *state)
-{
- blitter->saved_dsa_state = state;
-}
-
-static INLINE
-void util_blitter_save_vertex_elements(struct blitter_context *blitter,
- void *state)
-{
- blitter->saved_velem_state = state;
-}
-
-static INLINE
-void util_blitter_save_stencil_ref(struct blitter_context *blitter,
- const struct pipe_stencil_ref *state)
-{
- blitter->saved_stencil_ref = *state;
-}
-
-static INLINE
-void util_blitter_save_rasterizer(struct blitter_context *blitter,
- void *state)
-{
- blitter->saved_rs_state = state;
-}
-
-static INLINE
-void util_blitter_save_fragment_shader(struct blitter_context *blitter,
- void *fs)
-{
- blitter->saved_fs = fs;
-}
-
-static INLINE
-void util_blitter_save_vertex_shader(struct blitter_context *blitter,
- void *vs)
-{
- blitter->saved_vs = vs;
-}
-
-static INLINE
-void util_blitter_save_framebuffer(struct blitter_context *blitter,
- const struct pipe_framebuffer_state *state)
-{
- blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */
- util_copy_framebuffer_state(&blitter->saved_fb_state, state);
-}
-
-static INLINE
-void util_blitter_save_viewport(struct blitter_context *blitter,
- struct pipe_viewport_state *state)
-{
- blitter->saved_viewport = *state;
-}
-
-static INLINE
-void util_blitter_save_clip(struct blitter_context *blitter,
- struct pipe_clip_state *state)
-{
- blitter->saved_clip = *state;
-}
-
-static INLINE
-void util_blitter_save_fragment_sampler_states(
- struct blitter_context *blitter,
- int num_sampler_states,
- void **sampler_states)
-{
- assert(num_sampler_states <= Elements(blitter->saved_sampler_states));
-
- blitter->saved_num_sampler_states = num_sampler_states;
- memcpy(blitter->saved_sampler_states, sampler_states,
- num_sampler_states * sizeof(void *));
-}
-
-static INLINE void
-util_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
- int num_views,
- struct pipe_sampler_view **views)
-{
- unsigned i;
- assert(num_views <= Elements(blitter->saved_sampler_views));
-
- blitter->saved_num_sampler_views = num_views;
- for (i = 0; i < num_views; i++)
- pipe_sampler_view_reference(&blitter->saved_sampler_views[i],
- views[i]);
-}
-
-static INLINE void
-util_blitter_save_vertex_buffers(struct blitter_context *blitter,
- int num_vertex_buffers,
- struct pipe_vertex_buffer *vertex_buffers)
-{
- assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers));
-
- blitter->saved_num_vertex_buffers = 0;
- util_copy_vertex_buffers(blitter->saved_vertex_buffers,
- (unsigned*)&blitter->saved_num_vertex_buffers,
- vertex_buffers,
- num_vertex_buffers);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/************************************************************************** + * + * Copyright 2009 Marek Olšák <maraeo@gmail.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef U_BLITTER_H +#define U_BLITTER_H + +#include "util/u_framebuffer.h" +#include "util/u_inlines.h" +#include "util/u_memory.h" + +#include "pipe/p_state.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +struct pipe_context; + +enum blitter_attrib_type { + UTIL_BLITTER_ATTRIB_NONE, + UTIL_BLITTER_ATTRIB_COLOR, + UTIL_BLITTER_ATTRIB_TEXCOORD +}; + +struct blitter_context +{ + /** + * Draw a rectangle. + * + * \param x1 An X coordinate of the top-left corner. + * \param y1 A Y coordinate of the top-left corner. + * \param x2 An X coordinate of the bottom-right corner. + * \param y2 A Y coordinate of the bottom-right corner. + * \param depth A depth which the rectangle is rendered at. + * + * \param type Semantics of the attributes "attrib". + * If type is UTIL_BLITTER_ATTRIB_NONE, ignore them. + * If type is UTIL_BLITTER_ATTRIB_COLOR, the attributes + * make up a constant RGBA color, and should go + * to the GENERIC0 varying slot of a fragment shader. + * If type is UTIL_BLITTER_ATTRIB_TEXCOORD, {a1, a2} and + * {a3, a4} specify top-left and bottom-right texture + * coordinates of the rectangle, respectively, and should go + * to the GENERIC0 varying slot of a fragment shader. + * + * \param attrib See type. + * + * \note A driver may optionally override this callback to implement + * a specialized hardware path for drawing a rectangle, e.g. using + * a rectangular point sprite. + */ + void (*draw_rectangle)(struct blitter_context *blitter, + unsigned x1, unsigned y1, unsigned x2, unsigned y2, + float depth, + enum blitter_attrib_type type, + const float attrib[4]); + + /* Whether the blitter is running. */ + boolean running; + + /* Private members, really. */ + struct pipe_context *pipe; /**< pipe context */ + + void *saved_blend_state; /**< blend state */ + void *saved_dsa_state; /**< depth stencil alpha state */ + void *saved_velem_state; /**< vertex elements state */ + void *saved_rs_state; /**< rasterizer state */ + void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */ + + struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */ + struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ + struct pipe_viewport_state saved_viewport; + struct pipe_clip_state saved_clip; + + int saved_num_sampler_states; + void *saved_sampler_states[PIPE_MAX_SAMPLERS]; + + int saved_num_sampler_views; + struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS]; + + int saved_num_vertex_buffers; + struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS]; +}; + +/** + * Create a blitter context. + */ +struct blitter_context *util_blitter_create(struct pipe_context *pipe); + +/** + * Destroy a blitter context. + */ +void util_blitter_destroy(struct blitter_context *blitter); + +/** + * Return the pipe context associated with a blitter context. + */ +static INLINE +struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter) +{ + return blitter->pipe; +} + +/* + * These states must be saved before any of the following functions is called: + * - blend state + * - depth stencil alpha state + * - rasterizer state + * - vertex shader + * - any other shader??? (XXX) + * - fragment shader + * - vertex buffers + * - vertex elements + */ + +/** + * Clear a specified set of currently bound buffers to specified values. + */ +void util_blitter_clear(struct blitter_context *blitter, + unsigned width, unsigned height, + unsigned num_cbufs, + unsigned clear_buffers, + const float *rgba, + double depth, unsigned stencil); + +void util_blitter_clear_depth_custom(struct blitter_context *blitter, + unsigned width, unsigned height, + double depth, void *custom_dsa); + +/** + * Copy a block of pixels from one surface to another. + * + * You can copy from any color format to any other color format provided + * the former can be sampled and the latter can be rendered to. Otherwise, + * a software fallback path is taken and both surfaces must be of the same + * format. + * + * The same holds for depth-stencil formats with the exception that stencil + * cannot be copied unless you set ignore_stencil to FALSE. In that case, + * a software fallback path is taken and both surfaces must be of the same + * format. + * + * Use pipe_screen->is_format_supported to know your options. + * + * These states must be saved in the blitter in addition to the state objects + * already required to be saved: + * - framebuffer state + * - fragment sampler states + * - fragment sampler textures + */ +void util_blitter_copy_texture(struct blitter_context *blitter, + struct pipe_resource *dst, + unsigned dstlevel, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + unsigned srclevel, + const struct pipe_box *srcbox, + boolean ignore_stencil); + +/** + * Clear a region of a (color) surface to a constant value. + * + * These states must be saved in the blitter in addition to the state objects + * already required to be saved: + * - framebuffer state + */ +void util_blitter_clear_render_target(struct blitter_context *blitter, + struct pipe_surface *dst, + const float *rgba, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height); + +/** + * Clear a region of a depth-stencil surface, both stencil and depth + * or only one of them if this is a combined depth-stencil surface. + * + * These states must be saved in the blitter in addition to the state objects + * already required to be saved: + * - framebuffer state + */ +void util_blitter_clear_depth_stencil(struct blitter_context *blitter, + struct pipe_surface *dst, + unsigned clear_flags, + double depth, + unsigned stencil, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height); + +void util_blitter_custom_depth_stencil(struct blitter_context *blitter, + struct pipe_surface *zsurf, + struct pipe_surface *cbsurf, + void *dsa_stage, float depth); + +/* The functions below should be used to save currently bound constant state + * objects inside a driver. The objects are automatically restored at the end + * of the util_blitter_{clear, copy_region, fill_region} functions and then + * forgotten. + * + * CSOs not listed here are not affected by util_blitter. */ + +static INLINE +void util_blitter_save_blend(struct blitter_context *blitter, + void *state) +{ + blitter->saved_blend_state = state; +} + +static INLINE +void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter, + void *state) +{ + blitter->saved_dsa_state = state; +} + +static INLINE +void util_blitter_save_vertex_elements(struct blitter_context *blitter, + void *state) +{ + blitter->saved_velem_state = state; +} + +static INLINE +void util_blitter_save_stencil_ref(struct blitter_context *blitter, + const struct pipe_stencil_ref *state) +{ + blitter->saved_stencil_ref = *state; +} + +static INLINE +void util_blitter_save_rasterizer(struct blitter_context *blitter, + void *state) +{ + blitter->saved_rs_state = state; +} + +static INLINE +void util_blitter_save_fragment_shader(struct blitter_context *blitter, + void *fs) +{ + blitter->saved_fs = fs; +} + +static INLINE +void util_blitter_save_vertex_shader(struct blitter_context *blitter, + void *vs) +{ + blitter->saved_vs = vs; +} + +static INLINE +void util_blitter_save_framebuffer(struct blitter_context *blitter, + const struct pipe_framebuffer_state *state) +{ + blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */ + util_copy_framebuffer_state(&blitter->saved_fb_state, state); +} + +static INLINE +void util_blitter_save_viewport(struct blitter_context *blitter, + struct pipe_viewport_state *state) +{ + blitter->saved_viewport = *state; +} + +static INLINE +void util_blitter_save_clip(struct blitter_context *blitter, + struct pipe_clip_state *state) +{ + blitter->saved_clip = *state; +} + +static INLINE +void util_blitter_save_fragment_sampler_states( + struct blitter_context *blitter, + int num_sampler_states, + void **sampler_states) +{ + assert(num_sampler_states <= Elements(blitter->saved_sampler_states)); + + blitter->saved_num_sampler_states = num_sampler_states; + memcpy(blitter->saved_sampler_states, sampler_states, + num_sampler_states * sizeof(void *)); +} + +static INLINE void +util_blitter_save_fragment_sampler_views(struct blitter_context *blitter, + int num_views, + struct pipe_sampler_view **views) +{ + unsigned i; + assert(num_views <= Elements(blitter->saved_sampler_views)); + + blitter->saved_num_sampler_views = num_views; + for (i = 0; i < num_views; i++) + pipe_sampler_view_reference(&blitter->saved_sampler_views[i], + views[i]); +} + +static INLINE void +util_blitter_save_vertex_buffers(struct blitter_context *blitter, + int num_vertex_buffers, + struct pipe_vertex_buffer *vertex_buffers) +{ + assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers)); + + blitter->saved_num_vertex_buffers = 0; + util_copy_vertex_buffers(blitter->saved_vertex_buffers, + (unsigned*)&blitter->saved_num_vertex_buffers, + vertex_buffers, + num_vertex_buffers); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index 0b5284428..46d932293 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -199,6 +199,16 @@ roundf(float x) #endif /* _MSC_VER */ +#ifdef PIPE_OS_ANDROID + +static INLINE +double log2(double d) +{ + return log(d) * (1.0 / M_LN2); +} + +#endif + @@ -409,7 +419,7 @@ unsigned ffs( unsigned u ) return i; } -#elif defined(__MINGW32__) +#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID) #define ffs __builtin_ffs #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c index 19eb689cf..d9b39e528 100644 --- a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c +++ b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c @@ -34,21 +34,6 @@ #include "translate/translate.h" #include "translate/translate_cache.h" -/* Hardware vertex fetcher limitations can be described by this structure. */ -struct u_vbuf_caps { - /* Vertex format CAPs. */ - /* TRUE if hardware supports it. */ - unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */ - unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */ - unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */ - unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */ - unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */ - - /* Whether vertex fetches don't have to be dword-aligned. */ - /* TRUE if hardware supports it. */ - unsigned fetch_dword_unaligned:1; -}; - struct u_vbuf_mgr_elements { unsigned count; struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS]; @@ -69,7 +54,6 @@ struct u_vbuf_mgr_elements { struct u_vbuf_mgr_priv { struct u_vbuf_mgr b; - struct u_vbuf_caps caps; struct pipe_context *pipe; struct translate_cache *translate_cache; @@ -89,25 +73,25 @@ static void u_vbuf_mgr_init_format_caps(struct u_vbuf_mgr_priv *mgr) { struct pipe_screen *screen = mgr->pipe->screen; - mgr->caps.format_fixed32 = + mgr->b.caps.format_fixed32 = screen->is_format_supported(screen, PIPE_FORMAT_R32_FIXED, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER); - mgr->caps.format_float16 = + mgr->b.caps.format_float16 = screen->is_format_supported(screen, PIPE_FORMAT_R16_FLOAT, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER); - mgr->caps.format_float64 = + mgr->b.caps.format_float64 = screen->is_format_supported(screen, PIPE_FORMAT_R64_FLOAT, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER); - mgr->caps.format_norm32 = + mgr->b.caps.format_norm32 = screen->is_format_supported(screen, PIPE_FORMAT_R32_UNORM, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER) && screen->is_format_supported(screen, PIPE_FORMAT_R32_SNORM, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER); - mgr->caps.format_scaled32 = + mgr->b.caps.format_scaled32 = screen->is_format_supported(screen, PIPE_FORMAT_R32_USCALED, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER) && screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER, @@ -130,7 +114,7 @@ u_vbuf_mgr_create(struct pipe_context *pipe, upload_buffer_alignment, upload_buffer_bind); - mgr->caps.fetch_dword_unaligned = + mgr->b.caps.fetch_dword_unaligned = fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED; u_vbuf_mgr_init_format_caps(mgr); @@ -184,7 +168,7 @@ u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr, /* Check for support. */ if (mgr->ve->ve[i].src_format == mgr->ve->native_format[i] && - (mgr->caps.fetch_dword_unaligned || + (mgr->b.caps.fetch_dword_unaligned || (vb->buffer_offset % 4 == 0 && vb->stride % 4 == 0 && mgr->ve->ve[i].src_offset % 4 == 0))) { @@ -365,7 +349,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, /* Choose a native format. * For now we don't care about the alignment, that's going to * be sorted out later. */ - if (!mgr->caps.format_fixed32) { + if (!mgr->b.caps.format_fixed32) { switch (format) { FORMAT_REPLACE(R32_FIXED, R32_FLOAT); FORMAT_REPLACE(R32G32_FIXED, R32G32_FLOAT); @@ -374,7 +358,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, default:; } } - if (!mgr->caps.format_float16) { + if (!mgr->b.caps.format_float16) { switch (format) { FORMAT_REPLACE(R16_FLOAT, R32_FLOAT); FORMAT_REPLACE(R16G16_FLOAT, R32G32_FLOAT); @@ -383,7 +367,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, default:; } } - if (!mgr->caps.format_float64) { + if (!mgr->b.caps.format_float64) { switch (format) { FORMAT_REPLACE(R64_FLOAT, R32_FLOAT); FORMAT_REPLACE(R64G64_FLOAT, R32G32_FLOAT); @@ -392,7 +376,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, default:; } } - if (!mgr->caps.format_norm32) { + if (!mgr->b.caps.format_norm32) { switch (format) { FORMAT_REPLACE(R32_UNORM, R32_FLOAT); FORMAT_REPLACE(R32G32_UNORM, R32G32_FLOAT); @@ -405,7 +389,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, default:; } } - if (!mgr->caps.format_scaled32) { + if (!mgr->b.caps.format_scaled32) { switch (format) { FORMAT_REPLACE(R32_USCALED, R32_FLOAT); FORMAT_REPLACE(R32G32_USCALED, R32G32_FLOAT); @@ -427,11 +411,11 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, ve->incompatible_layout = ve->incompatible_layout || ve->ve[i].src_format != ve->native_format[i] || - (!mgr->caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0); + (!mgr->b.caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0); } /* Align the formats to the size of DWORD if needed. */ - if (!mgr->caps.fetch_dword_unaligned) { + if (!mgr->b.caps.fetch_dword_unaligned) { for (i = 0; i < count; i++) { ve->native_format_size[i] = align(ve->native_format_size[i], 4); } @@ -472,7 +456,7 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb, mgr->any_user_vbs = FALSE; mgr->incompatible_vb_layout = FALSE; - if (!mgr->caps.fetch_dword_unaligned) { + if (!mgr->b.caps.fetch_dword_unaligned) { /* Check if the strides and offsets are aligned to the size of DWORD. */ for (i = 0; i < count; i++) { if (bufs[i].buffer) { diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.h b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.h index 4e6372435..c653ca434 100644 --- a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.h +++ b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.h @@ -37,6 +37,21 @@ #include "pipe/p_state.h" #include "util/u_transfer.h" +/* Hardware vertex fetcher limitations can be described by this structure. */ +struct u_vbuf_caps { + /* Vertex format CAPs. */ + /* TRUE if hardware supports it. */ + unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */ + unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */ + unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */ + unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */ + unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */ + + /* Whether vertex fetches don't have to be dword-aligned. */ + /* TRUE if hardware supports it. */ + unsigned fetch_dword_unaligned:1; +}; + /* The manager. * This structure should also be used to access vertex buffers * from a driver. */ @@ -63,6 +78,8 @@ struct u_vbuf_mgr { * - u_upload_buffer * - u_upload_flush */ struct u_upload_mgr *uploader; + + struct u_vbuf_caps caps; }; struct u_vbuf_resource { |