struct pipe_framebuffer_state fb, fb_saved;
struct pipe_viewport_state vp, vp_saved;
struct pipe_blend_color blend_color;
+ unsigned sample_mask;
struct pipe_stencil_ref stencil_ref, stencil_ref_saved;
};
return PIPE_OK;
}
+enum pipe_error cso_set_sample_mask(struct cso_context *ctx,
+ unsigned sample_mask)
+{
+ if (ctx->sample_mask != sample_mask) {
+ ctx->sample_mask = sample_mask;
+ ctx->pipe->set_sample_mask(ctx->pipe, sample_mask);
+ }
+ return PIPE_OK;
+}
+
enum pipe_error cso_set_stencil_ref(struct cso_context *ctx,
const struct pipe_stencil_ref *sr)
{
enum pipe_error cso_set_blend_color(struct cso_context *cso,
const struct pipe_blend_color *bc);
+enum pipe_error cso_set_sample_mask(struct cso_context *cso,
+ unsigned stencil_mask);
enum pipe_error cso_set_stencil_ref(struct cso_context *cso,
const struct pipe_stencil_ref *sr);
return ctx->vbuf_slot++ * sizeof ctx->vertices;
}
-
*/
void
util_blit_pixels_writemask(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ0,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_sampler_view *sampler_view = NULL;
+ struct pipe_sampler_view sv_templ;
struct pipe_framebuffer_state fb;
const int srcW = abs(srcX1 - srcX0);
const int srcH = abs(srcY1 - srcY0);
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
filter == PIPE_TEX_MIPFILTER_LINEAR);
- assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
- PIPE_BIND_SAMPLER_VIEW, 0));
- assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0));
+ assert(srcsub.level <= src_tex->last_level);
/* do the regions overlap? */
- overlap = util_same_surface(src, dst) &&
+ overlap = src_tex == dst->texture &&
+ dst->face == srcsub.face &&
+ dst->level == srcsub.level &&
+ dst->zslice == srcZ0 &&
regions_overlap(srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1);
* no overlapping.
* Filter mode should not matter since there's no stretching.
*/
- if (pipe->surface_copy &&
- dst->format == src->format &&
+ if (dst->format == src_tex->format &&
srcX0 < srcX1 &&
dstX0 < dstX1 &&
srcY0 < srcY1 &&
(dstX1 - dstX0) == (srcX1 - srcX0) &&
(dstY1 - dstY0) == (srcY1 - srcY0) &&
!overlap) {
- pipe->surface_copy(pipe,
- dst, dstX0, dstY0, /* dest */
- src, srcX0, srcY0, /* src */
- srcW, srcH); /* size */
+ struct pipe_subresource subdst;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ pipe->resource_copy_region(pipe,
+ dst->texture, subdst,
+ dstX0, dstY0, dst->zslice,/* dest */
+ src_tex, srcsub,
+ srcX0, srcY0, srcZ0,/* src */
+ srcW, srcH); /* size */
return;
}
-
- assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0));
+
/* Create a temporary texture when src and dest alias or when src
- * is anything other than a single-level 2d texture.
+ * is anything other than a 2d texture.
+ * XXX should just use appropriate shader to access 1d / 3d slice / cube face,
+ * much like the u_blitter code does (should be pretty trivial).
*
* This can still be improved upon.
*/
- if (util_same_surface(src, dst) ||
- src->texture->target != PIPE_TEXTURE_2D ||
- src->texture->last_level != 0)
+ if ((src_tex == dst->texture &&
+ dst->face == srcsub.face &&
+ dst->level == srcsub.level &&
+ dst->zslice == srcZ0) ||
+ src_tex->target != PIPE_TEXTURE_2D)
{
struct pipe_resource texTemp;
struct pipe_resource *tex;
struct pipe_sampler_view sv_templ;
- struct pipe_surface *texSurf;
+ struct pipe_subresource texsub;
const int srcLeft = MIN2(srcX0, srcX1);
const int srcTop = MIN2(srcY0, srcY1);
/* create temp texture */
memset(&texTemp, 0, sizeof(texTemp));
texTemp.target = PIPE_TEXTURE_2D;
- texTemp.format = src->format;
+ texTemp.format = src_tex->format;
texTemp.last_level = 0;
texTemp.width0 = srcW;
texTemp.height0 = srcH;
if (!tex)
return;
- u_sampler_view_default_template(&sv_templ, tex, tex->format);
-
- sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ);
- if (!sampler_view) {
- pipe_resource_reference(&tex, NULL);
- return;
- }
-
- texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION);
-
+ texsub.face = 0;
+ texsub.level = 0;
/* load temp texture */
- if (pipe->surface_copy) {
- pipe->surface_copy(pipe,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
- } else {
- util_surface_copy(pipe, FALSE,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
- }
+ pipe->resource_copy_region(pipe,
+ tex, texsub, 0, 0, 0, /* dest */
+ src_tex, srcsub, srcLeft, srcTop, srcZ0, /* src */
+ srcW, srcH); /* size */
- /* free the surface, update the texture if necessary.
- */
- pipe_surface_reference(&texSurf, NULL);
s0 = 0.0f;
s1 = 1.0f;
t0 = 0.0f;
t1 = 1.0f;
+ u_sampler_view_default_template(&sv_templ, tex, tex->format);
+ sampler_view = pipe->create_sampler_view(pipe, tex, &sv_templ);
+
+ if (!sampler_view) {
+ pipe_resource_reference(&tex, NULL);
+ return;
+ }
pipe_resource_reference(&tex, NULL);
}
else {
- pipe_sampler_view_reference(&sampler_view, src_sampler_view);
- s0 = srcX0 / (float)src->texture->width0;
- s1 = srcX1 / (float)src->texture->width0;
- t0 = srcY0 / (float)src->texture->height0;
- t1 = srcY1 / (float)src->texture->height0;
+ u_sampler_view_default_template(&sv_templ, src_tex, src_tex->format);
+ sv_templ.first_level = sv_templ.last_level = srcsub.level;
+ sampler_view = pipe->create_sampler_view(pipe, src_tex, &sv_templ);
+
+ if (!sampler_view) {
+ return;
+ }
+
+ s0 = srcX0 / (float)(u_minify(sampler_view->texture->width0, srcsub.level));
+ s1 = srcX1 / (float)(u_minify(sampler_view->texture->width0, srcsub.level));
+ t0 = srcY0 / (float)(u_minify(sampler_view->texture->height0, srcsub.level));
+ t1 = srcY1 / (float)(u_minify(sampler_view->texture->height0, srcsub.level));
}
-
+
+ assert(screen->is_format_supported(screen, sampler_view->format, PIPE_TEXTURE_2D,
+ sampler_view->texture->nr_samples,
+ PIPE_BIND_SAMPLER_VIEW, 0));
+ assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+ dst->texture->nr_samples,
+ PIPE_BIND_RENDER_TARGET, 0));
/* save state (restored below) */
cso_save_blend(ctx->cso);
/* sampler */
ctx->sampler.min_img_filter = filter;
ctx->sampler.mag_img_filter = filter;
+ /* we've limited this already with the sampler view but you never know... */
+ ctx->sampler.min_lod = srcsub.level;
+ ctx->sampler.max_lod = srcsub.level;
cso_single_sampler(ctx->cso, 0, &ctx->sampler);
cso_single_sampler_done(ctx->cso);
void
util_blit_pixels(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
float z, uint filter )
{
- util_blit_pixels_writemask( ctx, src, src_sampler_view,
+ util_blit_pixels_writemask( ctx, src_tex,
+ srcsub,
srcX0, srcY0,
srcX1, srcY1,
+ srcZ,
dst,
dstX0, dstY0,
dstX1, dstY1,
/**
* Copy pixel block from src texture to dst surface.
- * Overlapping regions are acceptable.
*
* XXX Should support selection of level.
* XXX need some control over blitting Z and/or stencil.
assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
PIPE_TEXTURE_2D,
+ dst->texture->nr_samples,
PIPE_BIND_RENDER_TARGET,
0));
extern void
util_blit_pixels(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ0,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
void
util_blit_pixels_writemask(struct blit_state *ctx,
- struct pipe_surface *src,
- struct pipe_sampler_view *src_sampler_view,
+ struct pipe_resource *src_tex,
+ struct pipe_subresource srcsub,
int srcX0, int srcY0,
int srcX1, int srcY1,
+ int srcZ0,
struct pipe_surface *dst,
int dstX0, int dstY0,
int dstX1, int dstY1,
/**
* @file
- * Blitter utility to facilitate acceleration of the clear, surface_copy,
- * and surface_fill functions.
+ * Blitter utility to facilitate acceleration of the clear, resource_copy_region,
+ * and resource_fill_region functions.
*
* @author Marek Olšák
*/
}
-static void util_blitter_overlap_copy(struct blitter_context *blitter,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
- struct pipe_context *pipe = ctx->pipe;
- struct pipe_screen *screen = pipe->screen;
-
- struct pipe_resource texTemp;
- struct pipe_resource *texture;
- struct pipe_surface *tex_surf;
-
- /* check whether the states are properly saved */
- blitter_check_saved_CSOs(ctx);
-
- memset(&texTemp, 0, sizeof(texTemp));
- texTemp.target = PIPE_TEXTURE_2D;
- texTemp.format = dst->texture->format; /* XXX verify supported by driver! */
- texTemp.last_level = 0;
- texTemp.width0 = width;
- texTemp.height0 = height;
- texTemp.depth0 = 1;
-
- texture = screen->resource_create(screen, &texTemp);
- if (!texture)
- return;
-
- tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
-
- /* blit from the src to the temp */
- util_blitter_do_copy(blitter, tex_surf, 0, 0,
- src, srcx, srcy,
- width, height,
- FALSE);
- util_blitter_do_copy(blitter, dst, dstx, dsty,
- tex_surf, 0, 0,
- width, height,
- FALSE);
- pipe_surface_reference(&tex_surf, NULL);
- pipe_resource_reference(&texture, NULL);
- blitter_restore_CSOs(ctx);
-}
void util_blitter_copy(struct blitter_context *blitter,
struct pipe_surface *dst,
return;
if (dst->texture == src->texture) {
- if (is_overlap(srcx, srcx + width, srcy, srcy + height,
- dstx, dstx + width, dsty, dsty + height)) {
- util_blitter_overlap_copy(blitter, dst, dstx, dsty, src, srcx, srcy,
- width, height);
- return;
- }
+ assert(!is_overlap(srcx, srcx + width, srcy, srcy + height,
+ dstx, dstx + width, dsty, dsty + height));
}
-
+
is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
dst_tex_usage = is_depth || is_stencil ? PIPE_BIND_DEPTH_STENCIL :
/* (assuming copying a stencil buffer is not possible) */
if ((!ignore_stencil && is_stencil) ||
!screen->is_format_supported(screen, dst->format, dst->texture->target,
- dst_tex_usage, 0) ||
+ dst->texture->nr_samples, dst_tex_usage, 0) ||
!screen->is_format_supported(screen, src->format, src->texture->target,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
- util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
- width, height);
+ src->texture->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) {
+ struct pipe_subresource subdst, subsrc;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ subsrc.face = src->face;
+ subsrc.level = src->level;
+ util_resource_copy_region(pipe, dst->texture, subdst, dstx, dsty, dst->zslice,
+ src->texture, subsrc, srcx, srcy, src->zslice,
+ width, height);
return;
}
/* check if we can render to the surface */
if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
!screen->is_format_supported(screen, dst->format, dst->texture->target,
+ dst->texture->nr_samples,
PIPE_BIND_RENDER_TARGET, 0)) {
- util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
+ struct pipe_subresource subdst;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ util_resource_fill_region(pipe, dst->texture, subdst, dstx, dsty,
+ dst->zslice, width, height, value);
return;
}
if (!screen->is_format_supported(screen,
list[i++],
PIPE_TEXTURE_2D,
+ 0,
PIPE_BIND_SAMPLER_VIEW,
0)) {
*out = i - 2;
{
if (buffers & PIPE_CLEAR_COLOR) {
struct pipe_surface *ps = framebuffer->cbufs[0];
+ struct pipe_subresource subdst;
union util_color uc;
+ subdst.face = ps->face;
+ subdst.level = ps->level;
util_pack_color(rgba, ps->format, &uc);
- if (pipe->surface_fill) {
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
- } else {
- util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui);
- }
+ pipe->resource_fill_region(pipe, ps->texture, subdst, 0, 0, ps->zslice,
+ ps->width, ps->height, uc.ui);
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *ps = framebuffer->zsbuf;
+ struct pipe_subresource subdst;
- if (pipe->surface_fill) {
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
- util_pack_z_stencil(ps->format, depth, stencil));
- } else {
- util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
- util_pack_z_stencil(ps->format, depth, stencil));
- }
+ subdst.face = ps->face;
+ subdst.level = ps->level;
+ pipe->resource_fill_region(pipe, ps->texture, subdst, 0, 0, ps->zslice,
+ ps->width, ps->height,
+ util_pack_z_stencil(ps->format, depth, stencil));
}
}
/* check if we can render in the texture's format */
if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0)) {
+ pt->nr_samples, PIPE_BIND_RENDER_TARGET, 0)) {
fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
return;
}
/* Choose surface format */
for (i = 0; rgbaFormats[i]; i++) {
if (screen->is_format_supported(screen, rgbaFormats[i],
- target, bind, 0)) {
+ target, 0, bind, 0)) {
format = rgbaFormats[i];
break;
}
/**
- * Fallback function for pipe->surface_copy().
+ * Fallback function for pipe->resource_copy_region().
* Note: (X,Y)=(0,0) is always the upper-left corner.
- * if do_flip, flip the image vertically on its way from src rect to dst rect.
*/
void
-util_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
- struct pipe_surface *dst,
- unsigned dst_x, unsigned dst_y,
- struct pipe_surface *src,
- unsigned src_x, unsigned src_y,
- unsigned w, unsigned h)
+util_resource_copy_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ unsigned w, unsigned h)
{
struct pipe_transfer *src_trans, *dst_trans;
void *dst_map;
const void *src_map;
enum pipe_format src_format, dst_format;
- assert(src->texture && dst->texture);
- if (!src->texture || !dst->texture)
+ assert(src && dst);
+ if (!src || !dst)
return;
- src_format = src->texture->format;
- dst_format = dst->texture->format;
+ src_format = src->format;
+ dst_format = dst->format;
src_trans = pipe_get_transfer(pipe,
- src->texture,
- src->face,
- src->level,
- src->zslice,
+ src,
+ subsrc.face,
+ subsrc.level,
+ src_z,
PIPE_TRANSFER_READ,
src_x, src_y, w, h);
dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
+ dst,
+ subdst.face,
+ subdst.level,
+ src_z,
PIPE_TRANSFER_WRITE,
dst_x, dst_y, w, h);
assert(dst_map);
if (src_map && dst_map) {
- /* If do_flip, invert src_y position and pass negative src stride */
util_copy_rect(dst_map,
dst_format,
dst_trans->stride,
0, 0,
w, h,
src_map,
- do_flip ? -(int) src_trans->stride : src_trans->stride,
+ src_trans->stride,
0,
- do_flip ? h - 1 : 0);
+ 0);
}
pipe->transfer_unmap(pipe, src_trans);
/**
- * Fallback for pipe->surface_fill() function.
+ * Fallback for pipe->resource_fill_region() function.
*/
void
-util_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
+util_resource_fill_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ unsigned width, unsigned height, unsigned value)
{
struct pipe_transfer *dst_trans;
void *dst_map;
- assert(dst->texture);
- if (!dst->texture)
+ assert(dst);
+ if (!dst)
return;
dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
+ dst,
+ subdst.face,
+ subdst.level,
+ dstz,
PIPE_TRANSFER_WRITE,
dstx, dsty, width, height);
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (util_format_get_blocksize(dst->texture->format)) {
+ switch (util_format_get_blocksize(dst->format)) {
case 1:
case 2:
case 4:
- util_fill_rect(dst_map, dst->texture->format,
+ util_fill_rect(dst_map, dst->format,
dst_trans->stride,
0, 0, width, height, value);
break;
#include "pipe/p_state.h"
-/**
- * Are s1 and s2 the same surface?
- * Surfaces are basically views into textures so check if the two surfaces
- * name the same part of the same texture.
- */
-static INLINE boolean
-util_same_surface(const struct pipe_surface *s1, const struct pipe_surface *s2)
-{
- return (s1->texture == s2->texture &&
- s1->face == s2->face &&
- s1->level == s2->level &&
- s1->zslice == s2->zslice);
-}
-
-
-
-
extern boolean
util_create_rgba_surface(struct pipe_screen *screen,
uint width, uint height, uint bind,
extern void
-util_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
- struct pipe_surface *dst,
- unsigned dst_x, unsigned dst_y,
- struct pipe_surface *src,
- unsigned src_x, unsigned src_y,
- unsigned w, unsigned h);
+util_resource_copy_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ unsigned w, unsigned h);
extern void
-util_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value);
+util_resource_fill_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ unsigned width, unsigned height, unsigned value);
set_polygon_stipple
+ Gallium supports polygon stipple
-surface_fill
+resource_fill_region
+ Gallium supports subrectangle fills of surfaces, D3D10 only supports full clears of views
* DirectX 10/11 DDI functions and Gallium equivalents
CheckFormatSupport -> screen->is_format_supported
! Gallium passes usages to this function, D3D11 returns them
- Gallium does not differentiate between blendable and non-blendable render targets
- - Gallium lacks multisampled-texture and multisampled-render-target usages
+ ! Gallium includes sample count directly, D3D11 uses additional query
CheckMultisampleQualityLevels
- * could merge this with is_format_supported
- - Gallium lacks multisampling support
+ ! is merged with is_format_supported
CommandListExecute (D3D11 only)
- Gallium does not support command lists
CreateBlendState (extended in D3D10.1) -> create_blend_state
# D3D10 does not support per-RT blend modes (but per-RT blending), only D3D10.1 does
- - Gallium lacks alpha-to-coverage
+ Gallium supports logic ops
+ Gallium supports dithering
+ Gallium supports using the broadcast alpha component of the blend constant color
CreateRasterizerState
- Gallium lacks clamping of polygon offset depth biases
- Gallium lacks support to disable depth clipping
- - Gallium lacks multisampling
+ Gallium, like OpenGL, supports PIPE_POLYGON_MODE_POINT
+ Gallium, like OpenGL, supports per-face polygon fill modes
+ Gallium, like OpenGL, supports culling everything
! D3D11 specifies mapping flags (i.e. read/write/discard);:it's unclear what they are used for here
- D3D11 supports odd things in the D3D10_DDI_RESOURCE_MISC_FLAG enum (D3D10_DDI_RESOURCE_MISC_DISCARD_ON_PRESENT, D3D11_DDI_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, D3D11_DDI_RESOURCE_MISC_BUFFER_STRUCTURED)
- Gallium does not support indirect draw call parameter buffers
- - Gallium lacks multisampling
- Gallium lacks array textures
! D3D11 supports specifying hardware modes and other stuff here for scanout resources
+ Gallium allows specifying minimum buffer alignment
ResourceCopyRegion
ResourceConvert (D3D10.1+ only)
ResourceConvertRegion (D3D10.1+ only)
- -> surface_copy
+ -> resource_copy_region
- Gallium does not support hardware buffer copies
- Gallium does not support copying 3D texture subregions in a single call
ResourceReadAfterWriteHazard
! Gallium specifies hides this, except for the render and texture caches
-ResourceResolveSubresource
- - Gallium does not support multisample sample resolution
+ResourceResolveSubresource -> resource_resolve
ResourceMap
ResourceUnmap
ResourceUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources
DefaultConstantBufferUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources
-SetBlendState -> bind_blend_state and set_blend_color
- ! D3D11 fuses bind_blend_state and set_blend_color in a single function
- - Gallium lacks the sample mask
+SetBlendState -> bind_blend_state, set_blend_color and set_sample_mask
+ ! D3D11 fuses bind_blend_state, set_blend_color and set_sample_mask in a single function
SetDepthStencilState -> bind_depth_stencil_alpha_state and set_stencil_ref
! D3D11 fuses bind_depth_stencil_alpha_state and set_stencil_ref in a single function
* ``set_stencil_ref`` sets the stencil front and back reference values
which are used as comparison values in stencil test.
* ``set_blend_color``
+* ``set_sample_mask``
* ``set_clip_state``
* ``set_polygon_stipple``
* ``set_scissor_state`` sets the bounds for the scissor test, which culls
Blitting
^^^^^^^^
-These methods emulate classic blitter controls. They are not guaranteed to be
-available; if they are set to NULL, then they are not present.
+These methods emulate classic blitter controls.
-These methods operate directly on ``pipe_surface`` objects, and stand
+These methods operate directly on ``pipe_resource`` objects, and stand
apart from any 3D state in the context. Blitting functionality may be
moved to a separate abstraction at some point in the future.
-``surface_fill`` performs a fill operation on a section of a surface.
+``resource_fill_region`` performs a fill operation on a section of a resource.
-``surface_copy`` blits a region of a surface to a region of another surface,
-provided that both surfaces are the same format. The source and destination
-may be the same surface, and overlapping blits are permitted.
+``resource_copy_region`` blits a region of a subresource of a resource to a
+region of another subresource of a resource, provided that both resources have the
+same format. The source and destination may be the same resource, but overlapping
+blits are not permitted.
+
+``resource_resolve`` resolves a multisampled resource into a non-multisampled
+one. Formats and dimensions must match. This function must be present if a driver
+supports multisampling.
The interfaces to these calls are likely to change to make it easier
for a driver to batch multiple blits with the same source and
* ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer.
* ``PIPE_BIND_INDEX_BUFFER``: An vertex index/element buffer.
* ``PIPE_BIND_CONSTANT_BUFFER``: A buffer of shader constants.
-* ``PIPE_BIND_BLIT_SOURCE``: A blit source, as given to surface_copy.
-* ``PIPE_BIND_BLIT_DESTINATION``: A blit destination, as given to surface_copy
- and surface_fill.
* ``PIPE_BIND_TRANSFER_WRITE``: A transfer object which will be written to.
* ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from.
* ``PIPE_BIND_CUSTOM``:
**target** one of the PIPE_TEXTURE_x flags
+**sample_count** the number of samples. 0 and 1 mean no multisampling,
+the maximum allowed legal value is 32.
+
**bindings** is a bitmask of :ref:`PIPE_BIND` flags.
**geom_flags** is a bitmask of PIPE_TEXTURE_GEOM_x flags.
Returns TRUE if all usages can be satisfied.
-
.. _resource_create:
resource_create
cell->dirty |= CELL_NEW_DEPTH_STENCIL;
}
+
static void
cell_set_clip_state(struct pipe_context *pipe,
const struct pipe_clip_state *clip)
}
+static void
+cell_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
/* Called when driver state tracker notices changes to the viewport
* matrix:
}
-
void
cell_init_state_functions(struct cell_context *cell)
{
cell->pipe.set_blend_color = cell_set_blend_color;
cell->pipe.set_stencil_ref = cell_set_stencil_ref;
cell->pipe.set_clip_state = cell_set_clip_state;
+ cell->pipe.set_sample_mask = cell_set_sample_mask;
cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
static boolean
cell_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format,
+ enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags )
{
struct sw_winsys *winsys = cell_screen(screen)->winsys;
+ if (sample_count > 1)
+ return FALSE;
+
if (tex_usage & (PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SCANOUT |
PIPE_BIND_SHARED)) {
#include "cell_surface.h"
-static void
-cell_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- util_surface_copy(pipe, FALSE,
- dest, destx, desty,
- src, srcx, srcy,
- width, height);
-}
-
void
cell_init_surface_functions(struct cell_context *cell)
{
- cell->pipe.surface_copy = cell_surface_copy;
- cell->pipe.surface_fill = util_surface_fill;
+ cell->pipe.resource_copy_region = util_resource_copy_region;
+ cell->pipe.resource_fill_region = util_resource_fill_region;
}
failover_init_state_functions( failover );
- failover->pipe.surface_copy = hw->surface_copy;
- failover->pipe.surface_fill = hw->surface_fill;
+ failover->pipe.resource_copy_region = hw->resource_copy_region;
+ failover->pipe.resource_fill_region = hw->resource_fill_region;
#if 0
failover->pipe.texture_create = hw->texture_create;
#define FO_NEW_CLEAR_COLOR 0x20000
#define FO_NEW_VERTEX_BUFFER 0x40000
#define FO_NEW_VERTEX_ELEMENT 0x80000
+#define FO_NEW_SAMPLE_MASK 0x100000
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
+ unsigned sample_mask;
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
failover->hw->set_clip_state( failover->hw, clip );
}
+static void
+failover_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+ struct failover_context *failover = failover_context(pipe);
+
+ failover->sample_mask = sample_mask;
+ failover->dirty |= FO_NEW_SAMPLE_MASK;
+ failover->sw->set_sample_mask( failover->sw, sample_mask );
+ failover->hw->set_sample_mask( failover->hw, sample_mask );
+
+}
+
static void *
failover_create_depth_stencil_state(struct pipe_context *pipe,
failover->pipe.set_blend_color = failover_set_blend_color;
failover->pipe.set_stencil_ref = failover_set_stencil_ref;
failover->pipe.set_clip_state = failover_set_clip_state;
+ failover->pipe.set_sample_mask = failover_set_sample_mask;
failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
failover->pipe.set_scissor_state = failover_set_scissor_state;
if (failover->dirty & FO_NEW_CLIP)
failover->sw->set_clip_state( failover->sw, &failover->clip );
+ if (failover->dirty & FO_NEW_SAMPLE_MASK)
+ failover->sw->set_sample_mask( failover->sw, failover->sample_mask );
+
if (failover->dirty & FO_NEW_DEPTH_STENCIL)
failover->sw->bind_depth_stencil_alpha_state( failover->sw,
failover->depth_stencil->sw_state );
void
i915_copy_blit(struct i915_context *i915,
- unsigned do_flip,
unsigned cpp,
unsigned short src_pitch,
struct i915_winsys_buffer *src_buffer,
#include "i915_context.h"
extern void i915_copy_blit(struct i915_context *i915,
- unsigned do_flip,
unsigned cpp,
unsigned short src_pitch,
struct i915_winsys_buffer *src_buffer,
static boolean
i915_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format,
+ enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags)
{
static const enum pipe_format tex_supported[] = {
PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_FORMAT_NONE /* list terminator */
};
- static const enum pipe_format surface_supported[] = {
+ static const enum pipe_format render_supported[] = {
PIPE_FORMAT_B8G8R8A8_UNORM,
PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_FORMAT_NONE /* list terminator */
+ };
+ static const enum pipe_format depth_supported[] = {
PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_FORMAT_NONE /* list terminator */
};
const enum pipe_format *list;
uint i;
- if(tex_usage & PIPE_BIND_RENDER_TARGET)
- list = surface_supported;
+ if (sample_count > 1)
+ return FALSE;
+
+ if(tex_usage & PIPE_BIND_DEPTH_STENCIL)
+ list = depth_supported;
+ else if (tex_usage & PIPE_BIND_RENDER_TARGET)
+ list = render_supported;
else
list = tex_supported;
FREE( velems );
}
+static void
+i915_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
void
i915_init_state_functions( struct i915_context *i915 )
{
i915->base.set_blend_color = i915_set_blend_color;
i915->base.set_stencil_ref = i915_set_stencil_ref;
i915->base.set_clip_state = i915_set_clip_state;
+ i915->base.set_sample_mask = i915_set_sample_mask;
i915->base.set_constant_buffer = i915_set_constant_buffer;
i915->base.set_framebuffer_state = i915_set_framebuffer_state;
*/
static void
i915_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy, unsigned width, unsigned height)
+ struct pipe_resource *dst, struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource *src, struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
+ unsigned width, unsigned height)
{
- struct i915_texture *dst_tex = i915_texture(dst->texture);
- struct i915_texture *src_tex = i915_texture(src->texture);
+ struct i915_texture *dst_tex = i915_texture(dst);
+ struct i915_texture *src_tex = i915_texture(src);
struct pipe_resource *dpt = &dst_tex->b.b;
struct pipe_resource *spt = &src_tex->b.b;
+ unsigned dst_offset, src_offset; /* in bytes */
+
+ if (dst->target == PIPE_TEXTURE_CUBE) {
+ dst_offset = dst_tex->image_offset[subdst.level][subdst.face];
+ }
+ else if (dst->target == PIPE_TEXTURE_3D) {
+ dst_offset = dst_tex->image_offset[subdst.level][dstz];
+ }
+ else {
+ dst_offset = dst_tex->image_offset[subdst.level][0];
+ assert(subdst.face == 0);
+ assert(dstz == 0);
+ }
+ if (src->target == PIPE_TEXTURE_CUBE) {
+ src_offset = src_tex->image_offset[subsrc.level][subsrc.face];
+ }
+ else if (src->target == PIPE_TEXTURE_3D) {
+ src_offset = src_tex->image_offset[subsrc.level][srcz];
+ }
+ else {
+ src_offset = src_tex->image_offset[subsrc.level][0];
+ assert(subsrc.face == 0);
+ assert(srcz == 0);
+ }
+
assert( dst != src );
assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) );
assert( util_format_get_blockheight(dpt->format) == 1 );
i915_copy_blit( i915_context(pipe),
- FALSE,
util_format_get_blocksize(dpt->format),
- (unsigned short) src_tex->stride, src_tex->buffer, src->offset,
- (unsigned short) dst_tex->stride, dst_tex->buffer, dst->offset,
+ (unsigned short) src_tex->stride, src_tex->buffer, src_offset,
+ (unsigned short) dst_tex->stride, dst_tex->buffer, dst_offset,
(short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
}
static void
i915_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
+ struct pipe_resource *dst, struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
unsigned width, unsigned height, unsigned value)
{
- struct i915_texture *tex = i915_texture(dst->texture);
+ struct i915_texture *tex = i915_texture(dst);
struct pipe_resource *pt = &tex->b.b;
+ unsigned dst_offset; /* in bytes */
+
+ if (dst->target == PIPE_TEXTURE_CUBE) {
+ dst_offset = tex->image_offset[subdst.level][subdst.face];
+ }
+ else if (dst->target == PIPE_TEXTURE_3D) {
+ dst_offset = tex->image_offset[subdst.level][dstz];
+ }
+ else {
+ dst_offset = tex->image_offset[subdst.level][0];
+ assert(subdst.face == 0);
+ assert(dstz == 0);
+ }
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
i915_fill_blit( i915_context(pipe),
util_format_get_blocksize(pt->format),
(unsigned short) tex->stride,
- tex->buffer, dst->offset,
+ tex->buffer, dst_offset,
(short) dstx, (short) dsty,
(short) width, (short) height,
value );
}
-/* Probably going to make blits work on textures rather than surfaces.
- */
void
i915_init_surface_functions(struct i915_context *i915)
{
- i915->base.surface_copy = i915_surface_copy;
- i915->base.surface_fill = i915_surface_fill;
+ i915->base.resource_copy_region = i915_surface_copy;
+ i915->base.resource_fill_region = i915_surface_fill;
}
/* No good reason for these to be in the screen.
brw->state.dirty.mesa |= PIPE_NEW_DEPTH_STENCIL_ALPHA;
}
+static void
+brw_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
void brw_pipe_depth_stencil_init( struct brw_context *brw )
{
brw->base.set_stencil_ref = brw_set_stencil_ref;
brw->base.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
brw->base.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state;
brw->base.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state;
+ brw->base.set_sample_mask = brw_set_sample_mask;
}
void brw_pipe_depth_stencil_cleanup( struct brw_context *brw )
#include "util/u_debug.h"
+#include "util/u_surface.h"
#include "brw_resource.h"
#include "brw_context.h"
brw->base.transfer_unmap = u_transfer_unmap_vtbl;
brw->base.transfer_destroy = u_transfer_destroy_vtbl;
brw->base.transfer_inline_write = u_transfer_inline_write_vtbl;
+ brw->base.resource_copy_region = util_resource_copy_region;
+ brw->base.resource_fill_region = util_resource_fill_region;
}
void
brw_is_format_supported( struct pipe_screen *screen,
enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags );
*/
boolean brw_is_format_supported( struct pipe_screen *screen,
enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags )
{
return translate_tex_format(format) != BRW_SURFACEFORMAT_INVALID;
static boolean
brw_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format,
+ enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags)
{
static const enum pipe_format tex_supported[] = {
const enum pipe_format *list;
uint i;
+ if (sample_count > 1)
+ return FALSE;
+
if (tex_usage & PIPE_BIND_DEPTH_STENCIL)
list = depth_supported;
else if (tex_usage & PIPE_BIND_RENDER_TARGET)
clip);
}
+static void
+identity_set_sample_mask(struct pipe_context *_pipe,
+ unsigned sample_mask)
+{
+ struct identity_context *id_pipe = identity_context(_pipe);
+ struct pipe_context *pipe = id_pipe->pipe;
+
+ pipe->set_sample_mask(pipe,
+ sample_mask);
+}
+
static void
identity_set_constant_buffer(struct pipe_context *_pipe,
uint shader,
buffers);
}
static void
-identity_surface_copy(struct pipe_context *_pipe,
- struct pipe_surface *_dst,
- unsigned dstx,
- unsigned dsty,
- struct pipe_surface *_src,
- unsigned srcx,
- unsigned srcy,
- unsigned width,
- unsigned height)
+identity_resource_copy_region(struct pipe_context *_pipe,
+ struct pipe_resource *_dst,
+ struct pipe_subresource subdst,
+ unsigned dstx,
+ unsigned dsty,
+ unsigned dstz,
+ struct pipe_resource *_src,
+ struct pipe_subresource subsrc,
+ unsigned srcx,
+ unsigned srcy,
+ unsigned srcz,
+ unsigned width,
+ unsigned height)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_surface *id_surface_dst = identity_surface(_dst);
- struct identity_surface *id_surface_src = identity_surface(_src);
+ struct identity_resource *id_resource_dst = identity_resource(_dst);
+ struct identity_resource *id_resource_src = identity_resource(_src);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_surface *dst = id_surface_dst->surface;
- struct pipe_surface *src = id_surface_src->surface;
+ struct pipe_resource *dst = id_resource_dst->resource;
+ struct pipe_resource *src = id_resource_src->resource;
- pipe->surface_copy(pipe,
- dst,
- dstx,
- dsty,
- src,
- srcx,
- srcy,
- width,
- height);
+ pipe->resource_copy_region(pipe,
+ dst,
+ subdst,
+ dstx,
+ dsty,
+ dstz,
+ src,
+ subsrc,
+ srcx,
+ srcy,
+ srcz,
+ width,
+ height);
}
static void
-identity_surface_fill(struct pipe_context *_pipe,
- struct pipe_surface *_dst,
- unsigned dstx,
- unsigned dsty,
- unsigned width,
- unsigned height,
- unsigned value)
+identity_resource_fill_region(struct pipe_context *_pipe,
+ struct pipe_resource *_dst,
+ struct pipe_subresource subdst,
+ unsigned dstx,
+ unsigned dsty,
+ unsigned dstz,
+ unsigned width,
+ unsigned height,
+ unsigned value)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_surface *id_surface_dst = identity_surface(_dst);
+ struct identity_resource *id_resource_dst = identity_resource(_dst);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_surface *dst = id_surface_dst->surface;
+ struct pipe_resource *dst = id_resource_dst->resource;
- pipe->surface_fill(pipe,
- dst,
- dstx,
- dsty,
- width,
- height,
- value);
+ pipe->resource_fill_region(pipe,
+ dst,
+ subdst,
+ dstx,
+ dsty,
+ dstz,
+ width,
+ height,
+ value);
}
static void
id_pipe->base.set_blend_color = identity_set_blend_color;
id_pipe->base.set_stencil_ref = identity_set_stencil_ref;
id_pipe->base.set_clip_state = identity_set_clip_state;
+ id_pipe->base.set_sample_mask = identity_set_sample_mask;
id_pipe->base.set_constant_buffer = identity_set_constant_buffer;
id_pipe->base.set_framebuffer_state = identity_set_framebuffer_state;
id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple;
id_pipe->base.set_fragment_sampler_views = identity_set_fragment_sampler_views;
id_pipe->base.set_vertex_sampler_views = identity_set_vertex_sampler_views;
id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers;
- id_pipe->base.surface_copy = identity_surface_copy;
- id_pipe->base.surface_fill = identity_surface_fill;
+ id_pipe->base.resource_copy_region = identity_resource_copy_region;
+ id_pipe->base.resource_fill_region = identity_resource_fill_region;
id_pipe->base.clear = identity_clear;
id_pipe->base.flush = identity_flush;
id_pipe->base.is_resource_referenced = identity_is_resource_referenced;
identity_screen_is_format_supported(struct pipe_screen *_screen,
enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned tex_usage,
unsigned geom_flags)
{
return screen->is_format_supported(screen,
format,
target,
+ sample_count,
tex_usage,
geom_flags);
}
*/
static boolean
llvmpipe_is_format_supported( struct pipe_screen *_screen,
- enum pipe_format format,
+ enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned bind,
unsigned geom_flags )
{
target == PIPE_TEXTURE_3D ||
target == PIPE_TEXTURE_CUBE);
+ if (sample_count > 1)
+ return FALSE;
+
if (bind & PIPE_BIND_RENDER_TARGET) {
if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
return FALSE;
llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;
}
+static void
+llvmpipe_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
void
llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe)
llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color;
llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref;
+ llvmpipe->pipe.set_sample_mask = llvmpipe_set_sample_mask;
}
static void
-lp_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dst, unsigned dstx, unsigned dsty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
+lp_resource_copy(struct pipe_context *pipe,
+ struct pipe_resource *dst, struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource *src, struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
+ unsigned width, unsigned height)
{
- struct llvmpipe_resource *src_tex = llvmpipe_resource(src->texture);
- struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst->texture);
+ /* XXX what about the dstz/srcz parameters - zslice wasn't used... */
+ struct llvmpipe_resource *src_tex = llvmpipe_resource(src);
+ struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst);
const enum pipe_format format = src_tex->base.format;
llvmpipe_flush_resource(pipe,
- dst->texture, dst->face, dst->level,
+ dst, subdst.face, subdst.level,
0, /* flush_flags */
FALSE, /* read_only */
FALSE, /* cpu_access */
FALSE); /* do_not_block */
llvmpipe_flush_resource(pipe,
- src->texture, src->face, src->level,
+ src, subsrc.face, subsrc.level,
0, /* flush_flags */
TRUE, /* read_only */
FALSE, /* cpu_access */
for (y = 0; y < th; y += TILE_SIZE) {
for (x = 0; x < tw; x += TILE_SIZE) {
(void) llvmpipe_get_texture_tile_linear(src_tex,
- src->face, src->level,
- LP_TEX_USAGE_READ,
+ subsrc.face, subsrc.level,
+ LP_TEX_USAGE_READ,
tx + x, ty + y);
}
}
for (y = 0; y < th; y += TILE_SIZE) {
for (x = 0; x < tw; x += TILE_SIZE) {
(void) llvmpipe_get_texture_tile_linear(dst_tex,
- dst->face, dst->level,
+ subdst.face, subdst.level,
usage,
tx + x, ty + y);
}
/* copy */
{
const ubyte *src_linear_ptr
- = llvmpipe_get_texture_image_address(src_tex, src->face,
- src->level,
+ = llvmpipe_get_texture_image_address(src_tex, subsrc.face,
+ subsrc.level,
LP_TEX_LAYOUT_LINEAR);
ubyte *dst_linear_ptr
- = llvmpipe_get_texture_image_address(dst_tex, dst->face,
- dst->level,
+ = llvmpipe_get_texture_image_address(dst_tex, subdst.face,
+ subdst.level,
LP_TEX_LAYOUT_LINEAR);
util_copy_rect(dst_linear_ptr, format,
- llvmpipe_resource_stride(&dst_tex->base, dst->level),
+ llvmpipe_resource_stride(&dst_tex->base, subdst.level),
dstx, dsty,
width, height,
src_linear_ptr,
- llvmpipe_resource_stride(&src_tex->base, src->level),
+ llvmpipe_resource_stride(&src_tex->base, subsrc.level),
srcx, srcy);
}
}
void
llvmpipe_init_surface_functions(struct llvmpipe_context *lp)
{
- lp->pipe.surface_copy = lp_surface_copy;
- lp->pipe.surface_fill = util_surface_fill;
+ lp->pipe.resource_copy_region = lp_resource_copy;
+ lp->pipe.resource_fill_region = util_resource_fill_region;
}
if (bind & (PIPE_BIND_RENDER_TARGET |
PIPE_BIND_DEPTH_STENCIL |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION |
PIPE_BIND_SCANOUT |
PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SAMPLER_VIEW))
nv50_screen_is_format_supported(struct pipe_screen *pscreen,
enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned tex_usage, unsigned geom_flags)
{
+ if (sample_count > 1)
+ return FALSE;
+
if (tex_usage & PIPE_BIND_RENDER_TARGET) {
switch (format) {
case PIPE_FORMAT_B8G8R8X8_UNORM:
{
}
+static void
+nv50_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
static void
nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
struct pipe_resource *buf )
nv50->pipe.set_blend_color = nv50_set_blend_color;
nv50->pipe.set_stencil_ref = nv50_set_stencil_ref;
nv50->pipe.set_clip_state = nv50_set_clip_state;
+ nv50->pipe.set_sample_mask = nv50_set_sample_mask;
nv50->pipe.set_constant_buffer = nv50_set_constant_buffer;
nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state;
nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple;
static void
nv50_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
+ struct pipe_resource *dest, struct pipe_subresource subdst,
+ unsigned destx, unsigned desty, unsigned destz,
+ struct pipe_resource *src, struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height)
{
struct nv50_context *nv50 = nv50_context(pipe);
struct nv50_screen *screen = nv50->screen;
+ struct pipe_surface *ps_dst, *ps_src;
assert((src->format == dest->format) ||
(nv50_2d_format_faithful(src->format) &&
nv50_2d_format_faithful(dest->format)));
- nv50_surface_do_copy(screen, dest, destx, desty, src, srcx,
- srcy, width, height);
+ ps_src = nv50_miptree_surface_new(pipe->screen, dest, subsrc.face,
+ subsrc.level, srcz, 0 /* bind flags */);
+ ps_dst = nv50_miptree_surface_new(pipe->screen, dest, subdst.face,
+ subdst.level, destz, 0 /* bindflags */);
+
+ nv50_surface_do_copy(screen, ps_dst, destx, desty, ps_src, srcx,
+ srcy, width, height);
+
+ nv50_miptree_surface_del(ps_src);
+ nv50_miptree_surface_del(ps_dst);
}
static void
-nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
- unsigned destx, unsigned desty, unsigned width,
- unsigned height, unsigned value)
+nv50_surface_fill(struct pipe_context *pipe, struct pipe_resource *dest,
+ struct pipe_subresource subdst,
+ unsigned destx, unsigned desty, unsigned destz,
+ unsigned width, unsigned height, unsigned value)
{
struct nv50_context *nv50 = nv50_context(pipe);
+ struct pipe_surface *ps;
struct nv50_screen *screen = nv50->screen;
struct nouveau_channel *chan = screen->eng2d->channel;
struct nouveau_grobj *eng2d = screen->eng2d;
if (format < 0)
return;
+ ps = nv50_miptree_surface_new(pipe->screen, dest, subdst.face,
+ subdst.level, destz, 0 /* bind flags */);
+
WAIT_RING (chan, 32);
- ret = nv50_surface_set(screen, dest, 1);
+ ret = nv50_surface_set(screen, ps, 1);
if (ret)
return;
OUT_RING (chan, desty);
OUT_RING (chan, width);
OUT_RING (chan, height);
+
+ nv50_miptree_surface_del(ps);
}
void
nv50_init_surface_functions(struct nv50_context *nv50)
{
- nv50->pipe.surface_copy = nv50_surface_copy;
- nv50->pipe.surface_fill = nv50_surface_fill;
+ nv50->pipe.resource_copy_region = nv50_surface_copy;
+ nv50->pipe.resource_fill_region = nv50_surface_fill;
}
struct nv04_surface* temp_ns;
int temp_flags;
- temp_flags = (ns->base.usage |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
+ temp_flags = ns->base.usage;
- ns->base.usage = (PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
+ ns->base.usage = 0;
memset(&templ, 0, sizeof(templ));
templ.format = ns->base.texture->format;
temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
temp_ns->backing = ns;
- if(ns->base.usage & PIPE_BIND_BLIT_SOURCE)
+ if(1) /* hmm */
eng2d->copy(eng2d, &temp_ns->backing->base,
0, 0, &ns->base,
0, 0, ns->base.width, ns->base.height);
if(ns->backing)
{
struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
- if(ns->backing->base.usage & PIPE_BIND_BLIT_DESTINATION)
+ if(1 /*ns->backing->base.usage & PIPE_BIND_BLIT_DESTINATION*/)
screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
nvfx_miptree_surface_del(&ns->backing->base);
}
nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned tex_usage, unsigned geom_flags)
{
struct nvfx_screen *screen = nvfx_screen(pscreen);
struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
+ if (sample_count > 1)
+ return FALSE;
+
if (tex_usage & PIPE_BIND_RENDER_TARGET) {
switch (format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
nvfx->draw_dirty |= NVFX_NEW_UCP;
}
+static void
+nvfx_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
static void
nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
struct pipe_resource *buf )
nvfx->pipe.set_blend_color = nvfx_set_blend_color;
nvfx->pipe.set_stencil_ref = nvfx_set_stencil_ref;
nvfx->pipe.set_clip_state = nvfx_set_clip_state;
+ nvfx->pipe.set_sample_mask = nvfx_set_sample_mask;
nvfx->pipe.set_constant_buffer = nvfx_set_constant_buffer;
nvfx->pipe.set_framebuffer_state = nvfx_set_framebuffer_state;
nvfx->pipe.set_polygon_stipple = nvfx_set_polygon_stipple;
**************************************************************************/
#include "nvfx_context.h"
+#include "nvfx_resource.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
static void
nvfx_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
+ struct pipe_resource *dest, struct pipe_subresource subdst,
+ unsigned destx, unsigned desty, unsigned destz,
+ struct pipe_resource *src, struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height)
{
struct nvfx_context *nvfx = nvfx_context(pipe);
struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
+ struct pipe_surface *ps_dst, *ps_src;
- eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
+ ps_src = nvfx_miptree_surface_new(pipe->screen, dest, subsrc.face,
+ subsrc.level, srcz, 0 /* bind flags */);
+ ps_dst = nvfx_miptree_surface_new(pipe->screen, dest, subdst.face,
+ subdst.level, destz, 0 /* bindflags */);
+
+ eng2d->copy(eng2d, ps_dst, destx, desty, ps_src, srcx, srcy, width, height);
+
+ nvfx_miptree_surface_del(ps_src);
+ nvfx_miptree_surface_del(ps_dst);
}
static void
-nvfx_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
- unsigned destx, unsigned desty, unsigned width,
- unsigned height, unsigned value)
+nvfx_surface_fill(struct pipe_context *pipe, struct pipe_resource *dest,
+ struct pipe_subresource subdst,
+ unsigned destx, unsigned desty, unsigned destz,
+ unsigned width, unsigned height, unsigned value)
{
struct nvfx_context *nvfx = nvfx_context(pipe);
+ struct pipe_surface *ps;
struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
- eng2d->fill(eng2d, dest, destx, desty, width, height, value);
+ ps = nvfx_miptree_surface_new(pipe->screen, dest, subdst.face,
+ subdst.level, destz, 0 /* bind flags */);
+
+ eng2d->fill(eng2d, ps, destx, desty, width, height, value);
+
+ nvfx_miptree_surface_del(ps);
}
void
nvfx_init_surface_functions(struct nvfx_context *nvfx)
{
- nvfx->pipe.surface_copy = nvfx_surface_copy;
- nvfx->pipe.surface_fill = nvfx_surface_fill;
+ nvfx->pipe.resource_copy_region = nvfx_surface_copy;
+ nvfx->pipe.resource_fill_region = nvfx_surface_fill;
}
{
unsigned bind = 0;
+#if 0
if (transfer_usage & PIPE_TRANSFER_WRITE)
bind |= PIPE_BIND_BLIT_SOURCE;
if (transfer_usage & PIPE_TRANSFER_READ)
bind |= PIPE_BIND_BLIT_DESTINATION;
+#endif
return bind;
}
src = pscreen->get_tex_surface(pscreen, pt,
sr.face, sr.level, box->z,
- PIPE_BIND_BLIT_SOURCE);
+ 0 /*PIPE_BIND_BLIT_SOURCE*/);
/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
/* TODO: Check if SIFM can un-swizzle */
ptx->sr.face,
ptx->sr.level,
ptx->box.z,
- PIPE_BIND_BLIT_DESTINATION);
+ 0 /*PIPE_BIND_BLIT_DESTINATION*/);
/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
nvscreen->eng2d->copy(nvscreen->eng2d,
/* Copy a block of pixels from one surface to another. */
void r300_surface_copy(struct pipe_context* pipe,
- struct pipe_surface* dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface* src,
- unsigned srcx, unsigned srcy,
+ struct pipe_resource* dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource* src,
+ struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height)
{
- enum pipe_format old_format = dst->texture->format;
+ struct pipe_screen *screen = pipe->screen;
+ enum pipe_format old_format = dst->format;
enum pipe_format new_format = old_format;
+ struct pipe_surface *srcsurf, *dstsurf;
+ unsigned bind;
- if (dst->texture->format != src->texture->format) {
+ if (util_format_is_depth_or_stencil(dst->format))
+ bind = PIPE_BIND_DEPTH_STENCIL;
+ else
+ bind = PIPE_BIND_RENDER_TARGET;
+
+ if (dst->format != src->format) {
debug_printf("r300: Implementation error: Format mismatch in %s\n"
" : src: %s dst: %s\n", __FUNCTION__,
- util_format_short_name(src->texture->format),
- util_format_short_name(dst->texture->format));
+ util_format_short_name(src->format),
+ util_format_short_name(dst->format));
debug_assert(0);
}
if (!pipe->screen->is_format_supported(pipe->screen,
- old_format, src->texture->target,
+ old_format, src->target,
+ src->nr_samples,
PIPE_BIND_RENDER_TARGET |
PIPE_BIND_SAMPLER_VIEW, 0) &&
util_format_is_plain(old_format)) {
src->format = new_format;
r300_texture_reinterpret_format(pipe->screen,
- dst->texture, new_format);
+ dst, new_format);
r300_texture_reinterpret_format(pipe->screen,
- src->texture, new_format);
+ src, new_format);
}
- r300_hw_copy(pipe, dst, dstx, dsty, src, srcx, srcy, width, height);
+ srcsurf = screen->get_tex_surface(screen, src,
+ subsrc.face, subsrc.level, srcz,
+ PIPE_BIND_SAMPLER_VIEW);
+
+ dstsurf = screen->get_tex_surface(screen, dst,
+ subdst.face, subdst.level, dstz,
+ bind);
+
+ r300_hw_copy(pipe, dstsurf, dstx, dsty, srcsurf, srcx, srcy, width, height);
+
+ pipe_surface_reference(&srcsurf, NULL);
+ pipe_surface_reference(&dstsurf, NULL);
if (old_format != new_format) {
dst->format = old_format;
src->format = old_format;
r300_texture_reinterpret_format(pipe->screen,
- dst->texture, old_format);
+ dst, old_format);
r300_texture_reinterpret_format(pipe->screen,
- src->texture, old_format);
+ src, old_format);
}
}
/* Fill a region of a surface with a constant value. */
void r300_surface_fill(struct pipe_context* pipe,
- struct pipe_surface* dst,
- unsigned dstx, unsigned dsty,
+ struct pipe_resource* dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
unsigned width, unsigned height,
unsigned value)
{
+ struct pipe_screen *screen = pipe->screen;
struct r300_context* r300 = r300_context(pipe);
+ struct pipe_surface *dstsurf;
+ unsigned bind;
+
+ if (util_format_is_depth_or_stencil(dst->format))
+ bind = PIPE_BIND_DEPTH_STENCIL;
+ else
+ bind = PIPE_BIND_RENDER_TARGET;
+
+ dstsurf = screen->get_tex_surface(screen, dst,
+ subdst.face,
+ subdst.level,
+ dstz,
+ bind);
r300_blitter_save_states(r300);
util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state);
util_blitter_fill(r300->blitter,
- dst, dstx, dsty, width, height, value);
+ dstsurf, dstx, dsty, width, height, value);
+
+ pipe_surface_reference(&dstsurf, NULL);
}
#define R300_BLIT_H
struct pipe_context;
-struct pipe_surface;
+struct pipe_resource;
+struct pipe_subresource;
void r300_clear(struct pipe_context* pipe,
unsigned buffers,
unsigned stencil);
void r300_surface_copy(struct pipe_context* pipe,
- struct pipe_surface* dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface* src,
- unsigned srcx, unsigned srcy,
+ struct pipe_resource* dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource* src,
+ struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height);
void r300_surface_fill(struct pipe_context* pipe,
- struct pipe_surface* dst,
- unsigned dstx, unsigned dsty,
+ struct pipe_resource* dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
unsigned width, unsigned height,
unsigned value);
r300->context.destroy = r300_destroy_context;
r300->context.clear = r300_clear;
- r300->context.surface_copy = r300_surface_copy;
- r300->context.surface_fill = r300_surface_fill;
+ r300->context.resource_copy_region = r300_surface_copy;
+ r300->context.resource_fill_region = r300_surface_fill;
if (r300screen->caps.has_tcl) {
r300->context.draw_arrays = r300_draw_arrays;
static boolean r300_is_format_supported(struct pipe_screen* screen,
enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned usage,
unsigned geom_flags)
{
return FALSE;
}
+ if (sample_count > 1)
+ return FALSE;
+
/* Check sampler format support. */
if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
/* Z24 cannot be sampled from on non-r5xx. */
}
}
+static void
+r300_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
+
/* Create a new depth, stencil, and alpha state based on the CSO dsa state.
*
* This contains the depth buffer, stencil buffer, alpha test, and such.
r300->context.set_blend_color = r300_set_blend_color;
r300->context.set_clip_state = r300_set_clip_state;
+ r300->context.set_sample_mask = r300_set_sample_mask;
r300->context.set_constant_buffer = r300_set_constant_buffer;
static void r300_copy_from_tiled_texture(struct pipe_context *ctx,
struct r300_transfer *r300transfer)
{
- struct pipe_screen *screen = ctx->screen;
struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer;
struct pipe_resource *tex = transfer->resource;
- struct pipe_surface *src, *dst;
+ struct pipe_subresource subdst;
- src = screen->get_tex_surface(screen, tex,
- transfer->sr.face,
- transfer->sr.level,
- transfer->box.z,
- PIPE_BIND_BLIT_SOURCE);
+ subdst.face = 0;
+ subdst.level = 0;
- dst = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b,
- 0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION);
-
- ctx->surface_copy(ctx, dst, 0, 0, src,
- transfer->box.x, transfer->box.y,
- transfer->box.width, transfer->box.height);
-
- pipe_surface_reference(&src, NULL);
- pipe_surface_reference(&dst, NULL);
+ ctx->resource_copy_region(ctx, &r300transfer->detiled_texture->b.b, subdst,
+ 0, 0, 0,
+ tex, transfer->sr,
+ transfer->box.x, transfer->box.y, transfer->box.z,
+ transfer->box.width, transfer->box.height);
}
/* Copy a detiled texture to a tiled one. */
static void r300_copy_into_tiled_texture(struct pipe_context *ctx,
struct r300_transfer *r300transfer)
{
- struct pipe_screen *screen = ctx->screen;
struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer;
struct pipe_resource *tex = transfer->resource;
- struct pipe_surface *src, *dst;
+ struct pipe_subresource subsrc;
- src = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b,
- 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE);
-
- dst = screen->get_tex_surface(screen, tex,
- transfer->sr.face,
- transfer->sr.level,
- transfer->box.z,
- PIPE_BIND_BLIT_DESTINATION);
+ subsrc.face = 0;
+ subsrc.level = 0;
/* XXX this flush prevents the following DRM error from occuring:
* [drm:radeon_cs_ioctl] *ERROR* Failed to parse relocation !
* Reproducible with perf/copytex. */
ctx->flush(ctx, 0, NULL);
- ctx->surface_copy(ctx, dst,
- transfer->box.x, transfer->box.y,
- src, 0, 0,
- transfer->box.width, transfer->box.height);
+ ctx->resource_copy_region(ctx, tex, transfer->sr,
+ transfer->box.x, transfer->box.y, transfer->box.z,
+ &r300transfer->detiled_texture->b.b, subsrc,
+ 0, 0, 0,
+ transfer->box.width, transfer->box.height);
/* XXX this flush fixes a few piglit tests (e.g. glean/pixelFormats). */
ctx->flush(ctx, 0, NULL);
-
- pipe_surface_reference(&src, NULL);
- pipe_surface_reference(&dst, NULL);
}
struct pipe_transfer*
softpipe->pipe.set_blend_color = softpipe_set_blend_color;
softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref;
softpipe->pipe.set_clip_state = softpipe_set_clip_state;
+ softpipe->pipe.set_sample_mask = softpipe_set_sample_mask;
softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
*/
static boolean
softpipe_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format,
+ enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned bind,
unsigned geom_flags )
{
if (!format_desc)
return FALSE;
+ if (sample_count > 1)
+ return FALSE;
+
if (bind & (PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SCANOUT |
PIPE_BIND_SHARED)) {
void softpipe_set_clip_state( struct pipe_context *,
const struct pipe_clip_state * );
+void softpipe_set_sample_mask( struct pipe_context *,
+ unsigned sample_mask );
+
void softpipe_set_constant_buffer(struct pipe_context *,
uint shader, uint index,
struct pipe_resource *buf);
softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;
}
+
+void
+softpipe_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
#include "sp_context.h"
#include "sp_surface.h"
-
-static void
-sp_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- util_surface_copy(pipe, FALSE,
- dest, destx, desty,
- src, srcx, srcy,
- width, height);
-}
-
void
sp_init_surface_functions(struct softpipe_context *sp)
{
- sp->pipe.surface_copy = sp_surface_copy;
- sp->pipe.surface_fill = util_surface_fill;
+ sp->pipe.resource_copy_region = util_resource_copy_region;
+ sp->pipe.resource_fill_region = util_resource_fill_region;
}
#include "svga_debug.h"
#include "svga_cmd.h"
#include "svga_surface.h"
+#include "util/u_surface.h"
#define FILE_DEBUG_FLAG DEBUG_BLIT
+/* XXX I got my doubts about this, should maybe use svga_texture_copy_handle directly? */
static void svga_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest,
- unsigned destx, unsigned desty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy,
+ struct pipe_resource* dst_tex,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource* src_tex,
+ struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height)
{
struct svga_context *svga = svga_context(pipe);
+ struct pipe_screen *screen = pipe->screen;
SVGA3dCopyBox *box;
enum pipe_error ret;
+ struct pipe_surface *srcsurf, *dstsurf;
svga_hwtnl_flush_retry( svga );
+ srcsurf = screen->get_tex_surface(screen, src_tex,
+ subsrc.face, subsrc.level, srcz,
+ PIPE_BIND_SAMPLER_VIEW);
+
+ dstsurf = screen->get_tex_surface(screen, dst_tex,
+ subdst.face, subdst.level, dstz,
+ PIPE_BIND_RENDER_TARGET);
+
SVGA_DBG(DEBUG_DMA, "blit to sid %p (%d,%d), from sid %p (%d,%d) sz %dx%d\n",
- svga_surface(dest)->handle,
- destx, desty,
- svga_surface(src)->handle,
+ svga_surface(dstsurf)->handle,
+ dstx, dsty,
+ svga_surface(srcsurf)->handle,
srcx, srcy,
width, height);
ret = SVGA3D_BeginSurfaceCopy(svga->swc,
- src,
- dest,
+ srcsurf,
+ dstsurf,
&box,
1);
if(ret != PIPE_OK) {
svga_context_flush(svga, NULL);
ret = SVGA3D_BeginSurfaceCopy(svga->swc,
- src,
- dest,
+ srcsurf,
+ dstsurf,
&box,
1);
assert(ret == PIPE_OK);
}
- box->x = destx;
- box->y = desty;
+ box->x = dstx;
+ box->y = dsty;
box->z = 0;
box->w = width;
box->h = height;
SVGA_FIFOCommitAll(svga->swc);
- svga_surface(dest)->dirty = TRUE;
- svga_propagate_surface(pipe, dest);
+ svga_surface(dstsurf)->dirty = TRUE;
+ svga_propagate_surface(pipe, dstsurf);
+
+ pipe_surface_reference(&srcsurf, NULL);
+ pipe_surface_reference(&dstsurf, NULL);
+
}
void
svga_init_blit_functions(struct svga_context *svga)
{
- svga->pipe.surface_copy = svga_surface_copy;
+ svga->pipe.resource_copy_region = svga_surface_copy;
+ svga->pipe.resource_fill_region = util_resource_fill_region;
}
svga->dirty |= SVGA_NEW_STENCIL_REF;
}
+static void
+svga_set_sample_mask(struct pipe_context *pipe,
+ unsigned sample_mask)
+{
+}
+
void svga_init_depth_stencil_functions( struct svga_context *svga )
{
svga->pipe.delete_depth_stencil_alpha_state = svga_delete_depth_stencil_state;
svga->pipe.set_stencil_ref = svga_set_stencil_ref;
+ svga->pipe.set_sample_mask = svga_set_sample_mask;
}
static boolean
svga_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format,
+ enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags )
{
struct svga_winsys_screen *sws = svga_screen(screen)->sws;
SVGA3dDevCapIndex index;
SVGA3dDevCapResult result;
-
+
assert(tex_usage);
+ if (sample_count > 1)
+ return FALSE;
+
/* Override host capabilities */
if (tex_usage & PIPE_BIND_RENDER_TARGET) {
switch(format) {
trace_dump_call_end();
}
+static INLINE void
+trace_context_set_sample_mask(struct pipe_context *_pipe,
+ unsigned sample_mask)
+{
+ struct trace_context *tr_ctx = trace_context(_pipe);
+ struct pipe_context *pipe = tr_ctx->pipe;
+
+ trace_dump_call_begin("pipe_context", "set_sample_mask");
+
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, sample_mask);
+
+ pipe->set_sample_mask(pipe, sample_mask);
+
+ trace_dump_call_end();
+}
static INLINE void
trace_context_set_constant_buffer(struct pipe_context *_pipe,
static INLINE void
-trace_context_surface_copy(struct pipe_context *_pipe,
- struct pipe_surface *dest,
- unsigned destx, unsigned desty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
+trace_context_resource_copy_region(struct pipe_context *_pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
+ unsigned width, unsigned height)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- dest = trace_surface_unwrap(tr_ctx, dest);
- src = trace_surface_unwrap(tr_ctx, src);
+ dst = trace_resource_unwrap(tr_ctx, dst);
+ src = trace_resource_unwrap(tr_ctx, src);
- trace_dump_call_begin("pipe_context", "surface_copy");
+ trace_dump_call_begin("pipe_context", "resource_copy_region");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(ptr, dest);
- trace_dump_arg(uint, destx);
- trace_dump_arg(uint, desty);
+ trace_dump_arg(ptr, dst);
+ trace_dump_arg_struct(subresource, subdst);
+ trace_dump_arg(uint, dstx);
+ trace_dump_arg(uint, dsty);
+ trace_dump_arg(uint, dstz);
trace_dump_arg(ptr, src);
+ trace_dump_arg_struct(subresource, subsrc);
trace_dump_arg(uint, srcx);
trace_dump_arg(uint, srcy);
+ trace_dump_arg(uint, srcz);
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
- pipe->surface_copy(pipe,
- dest, destx, desty,
- src, srcx, srcy, width, height);
+ pipe->resource_copy_region(pipe,
+ dst, subdst, dstx, dsty, dstz,
+ src, subsrc, srcx, srcy, srcz, width, height);
trace_dump_call_end();
}
static INLINE void
-trace_context_surface_fill(struct pipe_context *_pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height,
- unsigned value)
+trace_context_resource_fill_region(struct pipe_context *_pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ unsigned width, unsigned height,
+ unsigned value)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- dst = trace_surface_unwrap(tr_ctx, dst);
+ dst = trace_resource_unwrap(tr_ctx, dst);
- trace_dump_call_begin("pipe_context", "surface_fill");
+ trace_dump_call_begin("pipe_context", "resource_fill_region");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, dst);
+ trace_dump_arg_struct(subresource, subdst);
trace_dump_arg(uint, dstx);
trace_dump_arg(uint, dsty);
+ trace_dump_arg(uint, dstz);
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
+ trace_dump_arg(uint, value);
- pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);
+ pipe->resource_fill_region(pipe, dst, subdst, dstx, dsty, dstz,
+ width, height, value);
trace_dump_call_end();
}
tr_ctx->base.set_blend_color = trace_context_set_blend_color;
tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref;
tr_ctx->base.set_clip_state = trace_context_set_clip_state;
+ tr_ctx->base.set_sample_mask = trace_context_set_sample_mask;
tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer;
tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state;
tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;
tr_ctx->base.create_sampler_view = trace_create_sampler_view;
tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy;
tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers;
- if (pipe->surface_copy)
- tr_ctx->base.surface_copy = trace_context_surface_copy;
- if (pipe->surface_fill)
- tr_ctx->base.surface_fill = trace_context_surface_fill;
+ tr_ctx->base.resource_copy_region = trace_context_resource_copy_region;
+ tr_ctx->base.resource_fill_region = trace_context_resource_fill_region;
tr_ctx->base.clear = trace_context_clear;
tr_ctx->base.flush = trace_context_flush;
tr_ctx->base.is_resource_referenced = trace_is_resource_referenced;
trace_screen_is_format_supported(struct pipe_screen *_screen,
enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned tex_usage,
unsigned geom_flags)
{
trace_dump_arg(ptr, screen);
trace_dump_arg(format, format);
trace_dump_arg(int, target);
+ trace_dump_arg(uint, sample_count);
trace_dump_arg(uint, tex_usage);
trace_dump_arg(uint, geom_flags);
- result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
+ result = screen->is_format_supported(screen, format, target, sample_count,
+ tex_usage, geom_flags);
trace_dump_ret(bool, result);
void (*set_stencil_ref)( struct pipe_context *,
const struct pipe_stencil_ref * );
+ void (*set_sample_mask)( struct pipe_context *,
+ unsigned sample_mask );
+
void (*set_clip_state)( struct pipe_context *,
const struct pipe_clip_state * );
/**
- * Surface functions
+ * Resource functions for blit-like functionality
*
- * The pipe driver is allowed to set these functions to NULL, and in that
- * case, they will not be available.
+ * If a driver supports multisampling, resource_resolve must be available.
*/
/*@{*/
/**
- * Copy a block of pixels from one surface to another.
- * The surfaces must be of the same format.
+ * Copy a block of pixels from one resource to another.
+ * The resource must be of the same format.
+ * Resources with nr_samples > 1 are not allowed.
*/
- void (*surface_copy)(struct pipe_context *pipe,
- struct pipe_surface *dest,
- unsigned destx, unsigned desty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height);
+ void (*resource_copy_region)(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc,
+ unsigned srcx, unsigned srcy, unsigned srcz,
+ unsigned width, unsigned height);
/**
- * Fill a region of a surface with a constant value.
+ * Fill a region of a resource with a constant value.
+ * Resources with nr_samples > 1 are not allowed.
*/
- void (*surface_fill)(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height,
- unsigned value);
+ void (*resource_fill_region)(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ unsigned dstx, unsigned dsty, unsigned dstz,
+ unsigned width, unsigned height,
+ unsigned value);
+
+ /**
+ * Resolve a multisampled resource into a non-multisampled one.
+ * Source and destination must have the same size and same format.
+ */
+ void (*resource_resolve)(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ struct pipe_subresource subdst,
+ struct pipe_resource *src,
+ struct pipe_subresource subsrc);
+
/*@}*/
/**
#define PIPE_BIND_VERTEX_BUFFER (1 << 3) /* set_vertex_buffers */
#define PIPE_BIND_INDEX_BUFFER (1 << 4) /* draw_elements */
#define PIPE_BIND_CONSTANT_BUFFER (1 << 5) /* set_constant_buffer */
-#define PIPE_BIND_BLIT_SOURCE (1 << 6) /* surface_copy */
-#define PIPE_BIND_BLIT_DESTINATION (1 << 7) /* surface_copy, fill */
#define PIPE_BIND_DISPLAY_TARGET (1 << 8) /* flush_front_buffer */
#define PIPE_BIND_TRANSFER_WRITE (1 << 9) /* get_transfer */
#define PIPE_BIND_TRANSFER_READ (1 << 10) /* get_transfer */
struct pipe_context * (*context_create)( struct pipe_screen *,
void *priv );
-
+
/**
* Check if the given pipe_format is supported as a texture or
* drawing surface.
boolean (*is_format_supported)( struct pipe_screen *,
enum pipe_format format,
enum pipe_texture_target target,
- unsigned bindings,
+ unsigned sample_count,
+ unsigned bindings,
unsigned geom_flags );
/**
unsigned logicop_enable:1;
unsigned logicop_func:4; /**< PIPE_LOGICOP_x */
unsigned dither:1;
+ unsigned alpha_to_coverage:1;
+ unsigned alpha_to_one:1;
struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
};
pipe_surface_reference(&drawable->dri1_surface, NULL);
drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen,
- ptex, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
+ ptex, 0, 0, 0, 0/* no bind flag???*/);
psurf = drawable->dri1_surface;
}
__DRIconfig **configs_r5g6b5 = NULL;
__DRIconfig **configs_a8r8g8b8 = NULL;
__DRIconfig **configs_x8r8g8b8 = NULL;
- unsigned num_modes;
uint8_t depth_bits_array[5];
uint8_t stencil_bits_array[5];
- uint8_t msaa_samples_array[2];
+ uint8_t msaa_samples_array[5];
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
unsigned msaa_samples_factor;
+ unsigned i;
struct pipe_screen *p_screen = screen->base.screen;
boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8;
boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
depth_buffer_factor = 1;
pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0);
pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0);
pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0);
pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0);
pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET, 0);
pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET, 0);
pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET, 0);
/* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
if (dri_with_format(screen->sPriv)) {
pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0);
pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0);
} else {
pf_z16 = FALSE;
}
msaa_samples_array[0] = 0;
- msaa_samples_array[1] = 4;
back_buffer_factor = 3;
- msaa_samples_factor = 2;
- num_modes =
- depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
+ /* also test color for msaa 2/4/6/8 - just assume it'll work for all depth buffers */
+ if (pf_r5g6b5) {
+ msaa_samples_factor = 1;
+ for (i = 1; i < 5; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_TEXTURE_2D, i*2,
+ PIPE_BIND_RENDER_TARGET, 0)) {
+ msaa_samples_array[msaa_samples_factor] = i * 2;
+ msaa_samples_factor++;
+ }
+ }
- if (pf_r5g6b5)
configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
depth_bits_array, stencil_bits_array,
depth_buffer_factor, back_buffer_modes,
back_buffer_factor,
msaa_samples_array, msaa_samples_factor,
GL_TRUE);
+ }
+
+ if (pf_a8r8g8b8) {
+ msaa_samples_factor = 1;
+ for (i = 1; i < 5; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_TEXTURE_2D, i*2,
+ PIPE_BIND_RENDER_TARGET, 0)) {
+ msaa_samples_array[msaa_samples_factor] = i * 2;
+ msaa_samples_factor++;
+ }
+ }
- if (pf_a8r8g8b8)
configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
stencil_bits_array,
msaa_samples_array,
msaa_samples_factor,
GL_TRUE);
+ }
+
+ if (pf_x8r8g8b8) {
+ msaa_samples_factor = 1;
+ for (i = 1; i < 5; i++) {
+ if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_TEXTURE_2D, i*2,
+ PIPE_BIND_RENDER_TARGET, 0)) {
+ msaa_samples_array[msaa_samples_factor] = i * 2;
+ msaa_samples_factor++;
+ }
+ }
- if (pf_x8r8g8b8)
configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
stencil_bits_array,
msaa_samples_array,
msaa_samples_factor,
GL_TRUE);
+ }
if (pixel_bits == 16) {
configs = configs_r5g6b5;
struct drm_clip_rect clip;
struct drm_clip_rect *cur;
int i;
+ struct pipe_subresource subdst, subsrc;
+ subsrc.face = 0;
+ subsrc.level = 0;
+ subdst.face = 0;
+ subdst.level = 0;
cur = dPriv->pClipRects;
for (i = 0; i < dPriv->numClipRects; ++i) {
if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
- if (pipe->surface_copy) {
- pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
- src,
- (int)clip.x1 - dPriv->x,
- (int)clip.y1 - dPriv->y,
- clip.x2 - clip.x1, clip.y2 - clip.y1);
- } else {
- util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
- src,
- (int)clip.x1 - dPriv->x,
- (int)clip.y1 - dPriv->y,
- clip.x2 - clip.x1, clip.y2 - clip.y1);
- }
+ pipe->resource_copy_region(pipe, dst->texture, subdst,
+ clip.x1, clip.y1, 0,
+ src->texture, subsrc,
+ (int)clip.x1 - dPriv->x,
+ (int)clip.y1 - dPriv->y, 0,
+ clip.x2 - clip.x1, clip.y2 - clip.y1);
}
}
}
return;
pipe = dri1_get_pipe_context(screen);
+ /* XXX should probably use resources instead of surfaces in the api
+ - we get surface but only use the texture from it it seems... */
psurf = dri1_get_pipe_surface(drawable, ptex);
if (!pipe || !psurf)
return;
/* pick the first supported format */
for (i = 0; i < n; i++) {
if (screen->is_format_supported(screen, fmt[i],
- PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL, 0)) {
+ PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0)) {
formats[count++] = fmt[i];
break;
}
/**
* Get the pipe surface of the given attachment of the native surface.
*/
-static struct pipe_surface *
-get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf,
- enum native_attachment natt,
- unsigned bind)
+static struct pipe_resource *
+get_pipe_resource(struct native_display *ndpy, struct native_surface *nsurf,
+ enum native_attachment natt)
{
struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
- struct pipe_surface *psurf;
textures[natt] = NULL;
nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL);
- if (!textures[natt])
- return NULL;
-
- psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt],
- 0, 0, 0, bind);
- pipe_resource_reference(&textures[natt], NULL);
- return psurf;
+ return textures[natt];
}
static EGLBoolean
struct egl_g3d_config *gconf;
struct native_surface *nsurf;
struct pipe_screen *screen = gdpy->native->screen;
- struct pipe_surface *psurf;
+ struct pipe_resource *ptex;
if (!gsurf->render_texture)
return EGL_TRUE;
return EGL_FALSE;
}
- psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT,
- PIPE_BIND_BLIT_DESTINATION);
- if (psurf) {
+ ptex = get_pipe_resource(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
+ if (ptex) {
struct pipe_surface *psrc;
+ struct pipe_subresource subsrc, subdst;
+ subsrc.face = 0;
+ subsrc.level = 0;
+ subdst.face = 0;
+ subdst.level = 0;
- psrc = screen->get_tex_surface(screen, gsurf->render_texture,
- 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
if (psrc) {
- gdpy->pipe->surface_copy(gdpy->pipe, psurf, 0, 0,
- psrc, 0, 0, psurf->width, psurf->height);
- pipe_surface_reference(&psrc, NULL);
+ gdpy->pipe->resource_copy_region(gdpy->pipe, ptex, subdst, 0, 0, 0,
+ gsurf->render_texture, subsrc, 0, 0, 0, ptex->width0, ptex->height0);
nsurf->flush_frontbuffer(nsurf);
}
- pipe_surface_reference(&psurf, NULL);
+ pipe_resource_reference(&ptex, NULL);
}
nsurf->destroy(nsurf);
enum pipe_format fmt, boolean is_color)
{
return ndpy->screen->is_format_supported(ndpy->screen,
- fmt, PIPE_TEXTURE_2D,
+ fmt, PIPE_TEXTURE_2D, 0,
(is_color) ? PIPE_BIND_RENDER_TARGET :
PIPE_BIND_DEPTH_STENCIL, 0);
}
static boolean
is_format_supported(struct pipe_screen *screen,
- enum pipe_format fmt, boolean is_color)
+ enum pipe_format fmt, unsigned sample_count, boolean is_color)
{
- return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D,
+ return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, sample_count,
(is_color) ? PIPE_BIND_RENDER_TARGET :
PIPE_BIND_DEPTH_STENCIL, 0);
}
{
enum pipe_format formats[32];
int num_formats, i;
+ int sample_count = 0;
if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode)
return FALSE;
/* choose color format */
num_formats = choose_color_format(mode, formats);
for (i = 0; i < num_formats; i++) {
- if (is_format_supported(ndpy->screen, formats[i], TRUE)) {
+ if (is_format_supported(ndpy->screen, formats[i], sample_count, TRUE)) {
nconf->color_format = formats[i];
break;
}
const unsigned tex_usage = PIPE_BIND_DEPTH_STENCIL;
const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE |
PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO);
+ const unsigned sample_count = 0;
enum pipe_format formats[8], fmt;
int count, i;
fmt = PIPE_FORMAT_NONE;
for (i = 0; i < count; i++) {
if (xmdpy->screen->is_format_supported(xmdpy->screen, formats[i],
- target, tex_usage, geom_flags)) {
+ target, sample_count,
+ tex_usage, geom_flags)) {
fmt = formats[i];
break;
}
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
struct pipe_resource *src_ptex = xstfb->textures[src_statt];
struct pipe_resource *dst_ptex = xstfb->textures[dst_statt];
- struct pipe_surface *src, *dst;
+ struct pipe_subresource subsrc, subdst;
struct pipe_context *pipe;
if (!src_ptex || !dst_ptex)
xstfb->display->pipe = pipe;
}
- src = xstfb->screen->get_tex_surface(xstfb->screen,
- src_ptex, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
- dst = xstfb->screen->get_tex_surface(xstfb->screen,
- dst_ptex, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION);
+ subsrc.face = 0;
+ subsrc.level = 0;
+ subdst.face = 0;
+ subdst.level = 0;
- if (src && dst)
- pipe->surface_copy(pipe, dst, x, y, src, x, y, width, height);
-
- pipe_surface_reference(&src, NULL);
- pipe_surface_reference(&dst, NULL);
+ if (src_ptex && dst_ptex)
+ pipe->resource_copy_region(pipe, dst_ptex, subdst, x, y, 0,
+ src_ptex, subsrc, x, y, 0, width, height);
}
/**
/*
* Surface functions
*/
-
+
void surface_copy(struct st_surface *dst,
unsigned destx, unsigned desty,
struct st_surface *src,
unsigned srcx, unsigned srcy,
unsigned width, unsigned height)
{
+/* XXX
struct pipe_surface *_dst = NULL;
struct pipe_surface *_src = NULL;
-
+
_dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION);
if(!_dst)
SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing");
_src = st_pipe_surface(src, PIPE_BIND_BLIT_SOURCE);
if(!_src)
SWIG_exception(SWIG_ValueError, "couldn't acquire source surface for reading");
-
+
$self->pipe->surface_copy($self->pipe, _dst, destx, desty, _src, srcx, srcy, width, height);
-
+
fail:
pipe_surface_reference(&_src, NULL);
pipe_surface_reference(&_dst, NULL);
+*/
+ struct pipe_subresource subdst, subsrc;
+ subsrc.face = src->face;
+ subsrc.level = src->level;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ $self->pipe->resource_copy_region($self->pipe, dst->texture, subdst, destx, desty, dst->zslice,
+ src->texture, subsrc, srcx, srcy, src->zslice, width, height);
}
void surface_fill(struct st_surface *dst,
unsigned width, unsigned height,
unsigned value)
{
+/* XXX
struct pipe_surface *_dst = NULL;
-
- _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION);
+
+ _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION);
if(!_dst)
SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing");
$self->pipe->surface_fill($self->pipe, _dst, x, y, width, height, value);
-
+
fail:
pipe_surface_reference(&_dst, NULL);
+*/
+ struct pipe_subresource subdst;
+ subdst.face = dst->face;
+ subdst.level = dst->level;
+ $self->pipe->resource_fill_region($self->pipe, dst->texture, subdst, x, y, dst->zslice,
+ width, height, value);
}
%cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
*/
int is_format_supported( enum pipe_format format,
enum pipe_texture_target target,
+ unsigned sample_count,
unsigned bind,
unsigned geom_flags ) {
/* We can't really display surfaces with the python statetracker so mask
* out that usage */
bind &= ~PIPE_BIND_DISPLAY_TARGET;
- return $self->screen->is_format_supported( $self->screen,
- format,
- target,
- bind,
+ return $self->screen->is_format_supported( $self->screen,
+ format,
+ target,
+ sample_count,
+ bind,
geom_flags );
}
image->sampler.normalized_coords = 1;
assert(screen->is_format_supported(screen, pformat, PIPE_TEXTURE_2D,
- PIPE_BIND_SAMPLER_VIEW, 0));
+ 0, PIPE_BIND_SAMPLER_VIEW, 0));
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
surf = screen->get_tex_surface(screen, image_texture(src), 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE);
+ 0 /* no bind flags as surf isn't actually used??? */);
vg_copy_surface(ctx, strb->surface, dx, dy,
surf, sx+src->x, sy+src->y, width, height);
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
surf = screen->get_tex_surface(screen, image_texture(dst), 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE);
+ 0 /* no bind flags as surf isn't actually used??? */);
vg_copy_surface(ctx, surf, dst->x + dx, dst->y + dy,
strb->surface, sx, sy, width, height);
#endif
assert(screen->is_format_supported(screen, dst_surf->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0));
+ 0, PIPE_BIND_RENDER_TARGET, 0));
/* save state (restored below) */
cso_save_blend(ctx->cso);
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
struct pipe_resource texTemp, *tex;
- struct pipe_surface *texSurf;
+ struct pipe_subresource subsrc, subdst;
struct pipe_framebuffer_state fb;
struct st_framebuffer *stfb = ctx->owner->draw_buffer;
const int srcW = abs(srcX1 - srcX0);
}
assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
- PIPE_BIND_SAMPLER_VIEW, 0));
+ 0, PIPE_BIND_SAMPLER_VIEW, 0));
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_BIND_SAMPLER_VIEW, 0));
+ 0, PIPE_BIND_SAMPLER_VIEW, 0));
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET, 0));
+ 0, PIPE_BIND_RENDER_TARGET, 0));
/*
* XXX for now we're always creating a temporary texture.
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
+ texTemp.bind = PIPE_BIND_SAMPLER_VIEW;
tex = screen->resource_create(screen, &texTemp);
if (!tex)
if (!view)
return;
- texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
- PIPE_BIND_RENDER_TARGET);
-
- /* load temp texture */
- if (pipe->surface_copy) {
- pipe->surface_copy(pipe,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
- } else {
- util_surface_copy(pipe, FALSE,
- texSurf, 0, 0, /* dest */
- src, srcLeft, srcTop, /* src */
- srcW, srcH); /* size */
- }
+ subdst.face = 0;
+ subdst.level = 0;
+ subsrc.face = src->face;
+ subsrc.level = src->level;
- /* free the surface, update the texture if necessary.*/
- screen->tex_surface_destroy(texSurf);
+ pipe->resource_copy_region(pipe,
+ tex, subdst, 0, 0, 0, /* dest */
+ src->texture, subsrc, srcLeft, srcTop, src->zslice, /* src */
+ srcW, srcH); /* size */
/* save state (restored below) */
cso_save_blend(ctx->cso);
dest_surface = pipe->screen->get_tex_surface(pipe->screen,
stfb->blend_texture_view->texture,
0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION |
- PIPE_BIND_RENDER_TARGET);
+ PIPE_BIND_RENDER_TARGET);
/* flip it, because we want to use it as a sampler */
util_blit_pixels_tex(ctx->blit,
view,
dest_surface = pipe->screen->get_tex_surface(pipe->screen,
stfb->blend_texture_view->texture,
0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION |
- PIPE_BIND_RENDER_TARGET);
+ PIPE_BIND_RENDER_TARGET);
/* flip it, because we want to use it as a sampler */
util_blit_pixels_tex(ctx->blit,
/* if we had an old surface copy it over */
if (old_sampler_view) {
- struct pipe_surface *surface = pipe->screen->get_tex_surface(
- pipe->screen,
- stfb->alpha_mask_view->texture,
- 0, 0, 0,
- PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_BLIT_DESTINATION);
- struct pipe_surface *old_surface = pipe->screen->get_tex_surface(
- pipe->screen,
- old_sampler_view->texture,
- 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE);
- pipe->surface_copy(pipe,
- surface,
- 0, 0,
- old_surface,
- 0, 0,
- MIN2(old_surface->width, surface->width),
- MIN2(old_surface->height, surface->height));
- if (surface)
- pipe_surface_reference(&surface, NULL);
- if (old_surface)
- pipe_surface_reference(&old_surface, NULL);
+ struct pipe_subresource subsurf, subold_surf;
+ subsurf.face = 0;
+ subsurf.level = 0;
+ subold_surf.face = 0;
+ subold_surf.level = 0;
+ pipe->resource_copy_region(pipe,
+ stfb->alpha_mask_view->texture,
+ subsurf,
+ 0, 0, 0,
+ old_sampler_view->texture,
+ subold_surf,
+ 0, 0, 0,
+ MIN2(old_sampler_view->texture->width0,
+ stfb->alpha_mask_view->texture->width0),
+ MIN2(old_sampler_view->texture->height0,
+ stfb->alpha_mask_view->texture->height0));
}
/* Free the old texture
/* Probably need dedicated flags for surface usage too:
*/
- surface_usage = (PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
+ surface_usage = PIPE_BIND_DEPTH_STENCIL; /* XXX: was: RENDER_TARGET */
dsrb->texture = create_texture(pipe, dsrb->format, width, height);
if (!dsrb->texture)
strb->texture = pt;
strb->surface = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
- PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
+ PIPE_BIND_RENDER_TARGET);
if (!strb->surface) {
pipe_resource_reference(&strb->texture, NULL);
return TRUE;
for(j = 0; j < Elements(stw_pf_color); ++j) {
const struct stw_pf_color_info *color = &stw_pf_color[j];
- if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
- PIPE_BIND_RENDER_TARGET |
+ if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
+ 0, PIPE_BIND_RENDER_TARGET |
PIPE_BIND_DISPLAY_TARGET, 0))
continue;
const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
- PIPE_BIND_DEPTH_STENCIL, 0))
+ 0, PIPE_BIND_DEPTH_STENCIL, 0))
continue;
stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples );
ms->d_depth_bits_last =
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM,
PIPE_TEXTURE_2D,
+ 0,
PIPE_BIND_DEPTH_STENCIL, 0);
ms->ds_depth_bits_last =
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_TEXTURE_2D,
+ 0,
PIPE_BIND_DEPTH_STENCIL, 0);
return DRI2ScreenInit(pScreen, &dri2info);
XORG_FALLBACK("not GXcopy");
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
- priv->tex->target,
+ priv->tex->target, 0,
PIPE_BIND_RENDER_TARGET, 0)) {
XORG_FALLBACK("format %s", util_format_name(priv->tex->format));
}
XORG_FALLBACK("alu not GXcopy");
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
- priv->tex->target,
+ priv->tex->target, 0,
PIPE_BIND_RENDER_TARGET, 0))
XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format));
if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format,
- src_priv->tex->target,
+ src_priv->tex->target, 0,
PIPE_BIND_SAMPLER_VIEW, 0))
XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format));
exa->copy.src = src_priv;
exa->copy.dst = priv;
- /* For same-surface copies, the pipe->surface_copy path is clearly
- * superior, providing it is implemented. In other cases it's not
- * clear what the better path would be, and eventually we'd
- * probably want to gather timings and choose dynamically.
+ /* XXX this used to use resource_copy_region for same-surface copies,
+ * but they were redefined to not allow overlaps (some of the util code
+ * always assumed this anyway).
+ * Drivers should implement accelerated resource_copy_region or it will
+ * be slow - disable for now.
*/
- if (exa->pipe->surface_copy &&
- exa->copy.src == exa->copy.dst) {
-
+ if (0 && exa->copy.src != exa->copy.dst) {
exa->copy.use_surface_copy = TRUE;
-
- exa->copy.src_surface =
- exa->scrn->get_tex_surface( exa->scrn,
- exa->copy.src->tex,
- 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE);
-
- exa->copy.dst_surface =
- exa->scrn->get_tex_surface( exa->scrn,
- exa->copy.dst->tex,
- 0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION );
}
else {
exa->copy.use_surface_copy = FALSE;
exa->scrn->get_tex_surface(exa->scrn,
exa->copy.dst->tex,
0, 0, 0,
- PIPE_BIND_BLIT_DESTINATION);
+ PIPE_BIND_RENDER_TARGET);
renderer_copy_prepare(exa->renderer,
(void) priv;
if (exa->copy.use_surface_copy) {
- /* XXX: consider exposing >1 box in surface_copy interface.
- */
- exa->pipe->surface_copy( exa->pipe,
- exa->copy.dst_surface,
- dstX, dstY,
- exa->copy.src_surface,
- srcX, srcY,
- width, height );
+ struct pipe_subresource subdst, subsrc;
+ subdst.face = 0;
+ subdst.level = 0;
+ subsrc.face = 0;
+ subsrc.level = 0;
+ exa->pipe->resource_copy_region( exa->pipe,
+ exa->copy.dst->tex,
+ subdst,
+ dstX, dstY, 0,
+ exa->copy.src->tex,
+ subsrc,
+ srcX, srcY, 0,
+ width, height );
}
else {
renderer_copy_pixmap(exa->renderer,
exa->copy.src = NULL;
exa->copy.dst = NULL;
- pipe_surface_reference(&exa->copy.src_surface, NULL);
pipe_surface_reference(&exa->copy.dst_surface, NULL);
pipe_resource_reference(&exa->copy.src_texture, NULL);
}
XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex");
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
- priv->tex->target,
+ priv->tex->target, 0,
PIPE_BIND_RENDER_TARGET, 0))
XORG_FALLBACK("pDst format: %s", util_format_name(priv->tex->format));
XORG_FALLBACK("pSrc %s", !priv ? "!priv" : "!priv->tex");
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
- priv->tex->target,
+ priv->tex->target, 0,
PIPE_BIND_SAMPLER_VIEW, 0))
XORG_FALLBACK("pSrc format: %s", util_format_name(priv->tex->format));
XORG_FALLBACK("pMask %s", !priv ? "!priv" : "!priv->tex");
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
- priv->tex->target,
+ priv->tex->target, 0,
PIPE_BIND_SAMPLER_VIEW, 0))
XORG_FALLBACK("pMask format: %s", util_format_name(priv->tex->format));
texture = exa->scrn->resource_create(exa->scrn, &template);
if (priv->tex) {
- struct pipe_surface *dst_surf;
+ struct pipe_subresource subdst, subsrc;
struct pipe_surface *src_surf;
- dst_surf = exa->scrn->get_tex_surface(
- exa->scrn, texture, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION);
- src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
- if (exa->pipe->surface_copy) {
- exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width0),
- min(height, texture->height0));
- } else {
- util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width0),
- min(height, texture->height0));
- }
- exa->scrn->tex_surface_destroy(dst_surf);
- exa->scrn->tex_surface_destroy(src_surf);
+ subdst.face = 0;
+ subdst.level = 0;
+ subsrc.face = 0;
+ subsrc.level = 0;
+ exa->pipe->resource_copy_region(exa->pipe, texture,
+ subdst, 0, 0, 0,
+ priv->tex,
+ subsrc, 0, 0, 0,
+ min(width, texture->width0),
+ min(height, texture->height0));
}
pipe_resource_reference(&priv->tex, texture);
struct pipe_surface *
xorg_gpu_surface(struct pipe_screen *scrn, struct exa_pixmap_priv *priv)
{
-
- /* seems to get called both for blits and render target usage */
return scrn->get_tex_surface(scrn, priv->tex, 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION |
PIPE_BIND_RENDER_TARGET);
}
struct exa_pixmap_priv *src;
struct exa_pixmap_priv *dst;
- struct pipe_surface *src_surface;
struct pipe_surface *dst_surface;
struct pipe_resource *src_texture;
struct xorg_shader shader;
assert(screen->is_format_supported(screen, dst_surface->format,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET,
0));
(void) screen;
/* the coming in texture should already have that invariance */
debug_assert(screen->is_format_supported(screen, src->format,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0));
format = src->format;
{
/* copy source framebuffer surface into texture */
- struct pipe_surface *ps_read = screen->get_tex_surface(
- screen, src, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
- struct pipe_surface *ps_tex = screen->get_tex_surface(
- screen, pt, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION );
- if (pipe->surface_copy) {
- pipe->surface_copy(pipe,
- ps_tex, /* dest */
- 0, 0, /* destx/y */
- ps_read,
- 0, 0, src->width0, src->height0);
- } else {
- util_surface_copy(pipe, FALSE,
- ps_tex, /* dest */
- 0, 0, /* destx/y */
- ps_read,
- 0, 0, src->width0, src->height0);
- }
- pipe_surface_reference(&ps_read, NULL);
- pipe_surface_reference(&ps_tex, NULL);
+ struct pipe_subresource subsrc, subdst;
+ subsrc.face = 0;
+ subsrc.level = 0;
+ subdst.face = 0;
+ subdst.level = 0;
+ pipe->resource_copy_region(pipe,
+ pt, /* dest */
+ subdst,
+ 0, 0, 0, /* destx/y/z */
+ src,
+ subsrc,
+ 0, 0, 0,
+ src->width0, src->height0);
}
return pt;
context = self.real.context_create()
return Context(self.interpreter, context)
- def is_format_supported(self, format, target, bind, geom_flags):
- return self.real.is_format_supported(format, target, bind, geom_flags)
+ def is_format_supported(self, format, target, sample_count, bind, geom_flags):
+ return self.real.is_format_supported(format, target, sample_count, bind, geom_flags)
def resource_create(self, templat):
return self.real.resource_create(
face = self.face
level = self.level
zslice = self.zslice
-
+
bind = PIPE_BIND_SAMPLER_VIEW
geom_flags = 0
- if not dev.is_format_supported(format, target, bind, geom_flags):
+ sample_count = 0
+ if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
raise TestSkip
- if not dev.is_format_supported(format, target, bind, geom_flags):
+ if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
raise TestSkip
# textures
zslice = self.zslice
minz = 0.0
maxz = 1.0
-
+
bind = PIPE_BIND_SAMPLER_VIEW
geom_flags = 0
+ sample_count = 0
if width != height:
geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE
if not is_pot(width) or not is_pot(height) or not is_pot(depth):
geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO
-
- if not dev.is_format_supported(format, target, bind, geom_flags):
+
+ if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
raise TestSkip
-
+
# disabled blending/masking
blend = Blend()
blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
zslice = self.zslice
minz = 0.0
maxz = 1.0
-
+
bind = PIPE_BIND_SAMPLER_VIEW
geom_flags = 0
+ sample_count = 0
if width != height:
geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE
if not is_pot(width) or not is_pot(height) or not is_pot(depth):
geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO
-
- if not dev.is_format_supported(format, target, bind, geom_flags):
+
+ if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
raise TestSkip
-
+
# disabled blending/masking
blend = Blend()
blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
face = self.face
level = self.level
zslice = self.zslice
-
+
bind = PIPE_BIND_SAMPLER_VIEW
geom_flags = 0
- if not dev.is_format_supported(format, target, bind, geom_flags):
+ sample_count = 0
+ if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
raise TestSkip
-
+
# textures
texture = dev.resource_create(
target = target,
'state_tracker/st_atom_constbuf.c',
'state_tracker/st_atom_depth.c',
'state_tracker/st_atom_framebuffer.c',
+ 'state_tracker/st_atom_msaa.c',
'state_tracker/st_atom_pixeltransfer.c',
'state_tracker/st_atom_sampler.c',
'state_tracker/st_atom_scissor.c',
state_tracker/st_atom_constbuf.c \
state_tracker/st_atom_depth.c \
state_tracker/st_atom_framebuffer.c \
+ state_tracker/st_atom_msaa.c \
state_tracker/st_atom_pixeltransfer.c \
state_tracker/st_atom_sampler.c \
state_tracker/st_atom_scissor.c \
&st_update_sampler,
&st_update_texture,
&st_update_framebuffer,
+ &st_update_msaa,
&st_update_vs_constants,
&st_update_fs_constants,
&st_update_pixel_transfer
extern const struct st_tracked_state st_update_viewport;
extern const struct st_tracked_state st_update_scissor;
extern const struct st_tracked_state st_update_blend;
+extern const struct st_tracked_state st_update_msaa;
extern const struct st_tracked_state st_update_sampler;
extern const struct st_tracked_state st_update_texture;
extern const struct st_tracked_state st_finalize_textures;
if (st->ctx->Color.DitherFlag)
blend->dither = 1;
+ if (st->ctx->Multisample.Enabled) {
+ /* unlike in gallium/d3d10 these operations are only performed
+ if msaa is enabled */
+ if (st->ctx->Multisample.SampleAlphaToCoverage)
+ blend->alpha_to_coverage = 1;
+ if (st->ctx->Multisample.SampleAlphaToOne)
+ blend->alpha_to_one = 1;
+ }
+
cso_set_blend(st->cso_context, blend);
{
const struct st_tracked_state st_update_blend = {
"st_update_blend", /* name */
{ /* dirty */
- (_NEW_COLOR), /* XXX _NEW_BLEND someday? */ /* mesa */
+ (_NEW_COLOR | _NEW_MULTISAMPLE), /* XXX _NEW_BLEND someday? */ /* mesa */
0, /* st */
},
update_blend, /* update */
strb->rtt_face,
level,
strb->rtt_slice,
- PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION );
+ PIPE_BIND_RENDER_TARGET);
#if 0
printf("-- alloc new surface %d x %d into tex %p\n",
strb->surface->width, strb->surface->height,
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "st_context.h"
+#include "pipe/p_context.h"
+#include "st_atom.h"
+
+#include "cso_cache/cso_context.h"
+
+
+/* Second state atom for user clip planes:
+ */
+static void update_sample_mask( struct st_context *st )
+{
+ unsigned sample_mask = 0xffffffff;
+ unsigned sample_count = 1;
+ struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
+
+ /* dependency here on bound surface (or rather, sample count) is worrying */
+ if (framebuffer->zsbuf)
+ sample_count = framebuffer->zsbuf->texture->nr_samples;
+ else if (framebuffer->cbufs[0])
+ sample_count = framebuffer->cbufs[0]->texture->nr_samples;
+
+ if (st->ctx->Multisample.Enabled && sample_count > 1) {
+ /* unlike in gallium/d3d10 the mask is only active if msaa is enabled */
+ if (st->ctx->Multisample.SampleCoverage) {
+ unsigned nr_bits;
+ nr_bits = st->ctx->Multisample.SampleCoverageValue * (float)sample_count;
+ /* there's lot of ways how to do this. We just use first few bits,
+ since we have no knowledge of sample positions here. When
+ app-supplied mask though is used too might need to be smarter.
+ Also, there's a interface restriction here in theory it is
+ encouraged this mask not be the same at each pixel. */
+ sample_mask = (1 << nr_bits) - 1;
+ if (st->ctx->Multisample.SampleCoverageInvert)
+ sample_mask = ~sample_mask;
+ }
+ /* TODO merge with app-supplied sample mask */
+ }
+
+ /* mask off unused bits or don't care? */
+
+ if (sample_mask != st->state.sample_mask) {
+ st->state.sample_mask = sample_mask;
+ cso_set_sample_mask(st->cso_context, sample_mask);
+ }
+}
+
+
+const struct st_tracked_state st_update_msaa = {
+ "st_update_msaa", /* name */
+ { /* dirty */
+ (_NEW_MULTISAMPLE | _NEW_BUFFERS), /* mesa */
+ ST_NEW_FRAMEBUFFER, /* st */
+ },
+ update_sample_mask /* update */
+};
/* find an RGBA texture format */
format = st_choose_format(pipe->screen, GL_RGBA,
- PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
+ PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
/* create texture for color map/table */
pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
st->bitmap.rasterizer.gl_rasterization_rules = 1;
/* find a usable texture format */
- if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D,
+ if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
}
- else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D,
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM;
}
- else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D,
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
}
&readFB->Attachment[readFB->_ColorReadBufferIndex];
if(srcAtt->Type == GL_TEXTURE) {
- struct pipe_screen *screen = pipe->screen;
struct st_texture_object *srcObj =
st_texture_object(srcAtt->Texture);
struct st_renderbuffer *dstRb =
st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
- struct pipe_surface *srcSurf;
+ struct pipe_subresource srcSub;
struct pipe_surface *dstSurf = dstRb->surface;
if (!srcObj->pt)
return;
- srcSurf = screen->get_tex_surface(screen,
- srcObj->pt,
- srcAtt->CubeMapFace,
- srcAtt->TextureLevel,
- srcAtt->Zoffset,
- PIPE_BIND_BLIT_SOURCE);
- if(!srcSurf)
- return;
+ srcSub.face = srcAtt->CubeMapFace;
+ srcSub.level = srcAtt->TextureLevel;
- util_blit_pixels(st->blit,
- srcSurf, st_get_texture_sampler_view(srcObj, pipe),
- srcX0, srcY0, srcX1, srcY1,
+ util_blit_pixels(st->blit, srcObj->pt, srcSub,
+ srcX0, srcY0, srcX1, srcY1, srcAtt->Zoffset,
dstSurf, dstX0, dstY0, dstX1, dstY1,
0.0, pFilter);
-
- pipe_surface_reference(&srcSurf, NULL);
}
else {
struct st_renderbuffer *srcRb =
struct st_renderbuffer *dstRb =
st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
struct pipe_surface *srcSurf = srcRb->surface;
- struct pipe_sampler_view *srcView = st_get_renderbuffer_sampler_view(srcRb, pipe);
struct pipe_surface *dstSurf = dstRb->surface;
+ struct pipe_subresource srcSub;
+
+ srcSub.face = srcSurf->face;
+ srcSub.level = srcSurf->level;
util_blit_pixels(st->blit,
- srcSurf, srcView, srcX0, srcY0, srcX1, srcY1,
+ srcRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1,
+ srcSurf->zslice,
dstSurf, dstX0, dstY0, dstX1, dstY1,
0.0, pFilter);
}
if ((mask & depthStencil) == depthStencil &&
srcDepthSurf == srcStencilSurf &&
dstDepthSurf == dstStencilSurf) {
- struct pipe_sampler_view *srcView = st_get_renderbuffer_sampler_view(srcDepthRb, pipe);
+ struct pipe_subresource srcSub;
+
+ srcSub.face = srcDepthRb->surface->face;
+ srcSub.level = srcDepthRb->surface->level;
/* Blitting depth and stencil values between combined
* depth/stencil buffers. This is the ideal case for such buffers.
*/
util_blit_pixels(st->blit,
- srcDepthSurf, srcView, srcX0, srcY0, srcX1, srcY1,
+ srcDepthRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1,
+ srcDepthRb->surface->zslice,
dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
0.0, pFilter);
}
switch(target) {
case GL_PIXEL_PACK_BUFFER_ARB:
case GL_PIXEL_UNPACK_BUFFER_ARB:
- buffer_usage = (PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION);
+ buffer_usage = PIPE_BIND_RENDER_TARGET;
break;
case GL_ARRAY_BUFFER_ARB:
buffer_usage = PIPE_BIND_VERTEX_BUFFER;
enum pipe_format srcFormat, texFormat;
GLboolean invertTex = GL_FALSE;
GLint readX, readY, readW, readH;
+ GLuint sample_count;
struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
st_validate_state(st);
driver_vp = make_passthrough_vertex_shader(st, GL_TRUE);
}
+ sample_count = rbRead->texture->nr_samples;
+ /* I believe this would be legal, presumably would need to do a resolve
+ for color, and for depth/stencil spec says to just use one of the
+ depth/stencil samples per pixel? Need some transfer clarifications. */
+ assert(sample_count < 2);
+
srcFormat = rbRead->texture->format;
- if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D,
+ if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, sample_count,
PIPE_BIND_SAMPLER_VIEW, 0)) {
texFormat = srcFormat;
}
/* srcFormat can't be used as a texture format */
if (type == GL_DEPTH) {
texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, sample_count,
PIPE_BIND_DEPTH_STENCIL);
assert(texFormat != PIPE_FORMAT_NONE);
}
else {
/* default color format */
texFormat = st_choose_format(screen, GL_RGBA, PIPE_TEXTURE_2D,
- PIPE_BIND_SAMPLER_VIEW);
+ sample_count, PIPE_BIND_SAMPLER_VIEW);
assert(texFormat != PIPE_FORMAT_NONE);
}
}
/* Make temporary texture which is a copy of the src region.
*/
if (srcFormat == texFormat) {
+ struct pipe_subresource srcsub, dstsub;
+ srcsub.face = 0;
+ srcsub.level = 0;
+ dstsub.face = 0;
+ dstsub.level = 0;
/* copy source framebuffer surface into mipmap/texture */
- struct pipe_surface *psRead = screen->get_tex_surface(screen,
- rbRead->texture, 0, 0, 0,
- PIPE_BIND_BLIT_SOURCE);
- struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_BLIT_DESTINATION);
- pipe->surface_copy(pipe,
- psTex, /* dest surf */
- pack.SkipPixels, pack.SkipRows, /* dest pos */
- psRead, /* src surf */
- readX, readY, readW, readH); /* src region */
-
- if (0) {
- /* debug */
- debug_dump_surface(pipe, "copypixsrcsurf", psRead);
- debug_dump_surface(pipe, "copypixtemptex", psTex);
- }
+ pipe->resource_copy_region(pipe,
+ pt, /* dest tex */
+ dstsub,
+ pack.SkipPixels, pack.SkipRows, 0, /* dest pos */
+ rbRead->texture, /* src tex */
+ srcsub,
+ readX, readY, 0, readW, readH); /* src region */
- pipe_surface_reference(&psRead, NULL);
- pipe_surface_reference(&psTex, NULL);
}
else {
/* CPU-based fallback/conversion */
struct pipe_surface *ps;
unsigned usage;
- usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLIT_SOURCE | PIPE_BIND_BLIT_DESTINATION;
+ usage = PIPE_BIND_RENDER_TARGET;
ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
if (ps) {
strb->Base.Width = ps->width;
struct pipe_surface *ps;
unsigned usage;
- usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_BLIT_SOURCE;
+ usage = PIPE_BIND_SAMPLER_VIEW;
ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
if (ps) {
st_bind_surface(ctx, target, texObj, texImage, ps);
if (strb->format != PIPE_FORMAT_NONE)
format = strb->format;
else
- format = st_choose_renderbuffer_format(screen, internalFormat);
+ format = st_choose_renderbuffer_format(screen, internalFormat, rb->NumSamples);
/* init renderbuffer fields */
strb->Base.Width = width;
return GL_FALSE;
return screen->is_format_supported(screen, stObj->pt->format,
- PIPE_TEXTURE_2D, bindings, 0);
+ PIPE_TEXTURE_2D,
+ stObj->pt->nr_samples, bindings, 0);
}
functions->ReadBuffer = st_ReadBuffer;
}
+/* XXX unused ? */
struct pipe_sampler_view *
st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb,
struct pipe_context *pipe)
extern void
st_init_fbo_functions(struct dd_function_table *functions);
+/* XXX unused ? */
extern struct pipe_sampler_view *
st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb,
struct pipe_context *pipe);
else
bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- if (screen->is_format_supported(screen, format, target, bindings, geom))
+ if (screen->is_format_supported(screen, format, target, 0, bindings, geom))
return bindings;
else
return PIPE_BIND_SAMPLER_VIEW;
/* get destination surface (in the compressed texture) */
dst_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level, 0,
- PIPE_BIND_BLIT_DESTINATION);
+ 0 /* flags */);
if (!dst_surface) {
/* can't render into this format (or other problem) */
return GL_FALSE;
_mesa_is_format_compressed(texImage->TexFormat) &&
screen->is_format_supported(screen,
stImage->pt->format,
- stImage->pt->target,
+ stImage->pt->target, 0,
PIPE_BIND_RENDER_TARGET, 0)) {
if (!pixels)
goto done;
struct pipe_surface *dst_surface;
struct pipe_resource *dst_texture;
struct pipe_transfer *tex_xfer;
- unsigned bind = (PIPE_BIND_BLIT_DESTINATION |
- PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
+ unsigned bind = (PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
PIPE_BIND_TRANSFER_READ);
/* create temp / dest surface */
_mesa_is_format_compressed(texImage->TexFormat) &&
screen->is_format_supported(screen,
stImage->pt->format,
- stImage->pt->target,
+ stImage->pt->target, 0,
PIPE_BIND_RENDER_TARGET, 0)) {
if (compress_with_blit(ctx, target, level,
xoffset, yoffset, zoffset,
enum pipe_format dest_format, src_format;
GLboolean use_fallback = GL_TRUE;
GLboolean matching_base_formats;
- GLuint format_writemask;
+ GLuint format_writemask, sample_count;
struct pipe_surface *dest_surface = NULL;
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
return;
}
+ sample_count = strb->surface->texture->nr_samples;
+ /* I believe this would be legal, presumably would need to do a resolve
+ for color, and for depth/stencil spec says to just use one of the
+ depth/stencil samples per pixel? Need some transfer clarifications. */
+ assert(sample_count < 2);
+
if (srcX < 0) {
width -= -srcX;
destX += -srcX;
!do_flip)
{
/* use surface_copy() / blit */
-
- dest_surface = screen->get_tex_surface(screen, stImage->pt,
- stImage->face, stImage->level,
- destZ,
- PIPE_BIND_BLIT_DESTINATION);
-
- /* for surface_copy(), y=0=top, always */
- pipe->surface_copy(pipe,
- /* dest */
- dest_surface,
- destX, destY,
- /* src */
- strb->surface,
- srcX, srcY,
- /* size */
- width, height);
+ struct pipe_subresource subdst, subsrc;
+ subdst.face = stImage->face;
+ subdst.level = stImage->level;
+ subsrc.face = strb->surface->face;
+ subsrc.level = strb->surface->level;
+
+ /* for resource_copy_region(), y=0=top, always */
+ pipe->resource_copy_region(pipe,
+ /* dest */
+ stImage->pt,
+ subdst,
+ destX, destY, destZ,
+ /* src */
+ strb->texture,
+ subsrc,
+ srcX, srcY, strb->surface->zslice,
+ /* size */
+ width, height);
use_fallback = GL_FALSE;
}
else if (format_writemask &&
texBaseFormat != GL_DEPTH_COMPONENT &&
texBaseFormat != GL_DEPTH_STENCIL &&
screen->is_format_supported(screen, src_format,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, sample_count,
PIPE_BIND_SAMPLER_VIEW,
0) &&
screen->is_format_supported(screen, dest_format,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET,
0)) {
/* draw textured quad to do the copy */
GLint srcY0, srcY1;
+ struct pipe_subresource subsrc;
dest_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level,
destZ,
- PIPE_BIND_BLIT_DESTINATION);
+ PIPE_BIND_RENDER_TARGET);
if (do_flip) {
srcY1 = strb->Base.Height - srcY - height;
srcY0 = srcY;
srcY1 = srcY0 + height;
}
+ subsrc.face = strb->surface->face;
+ subsrc.level = strb->surface->level;
+
util_blit_pixels_writemask(st->blit,
- strb->surface,
- st_get_renderbuffer_sampler_view(strb, pipe),
+ strb->texture,
+ subsrc,
srcX, srcY0,
srcX + width, srcY1,
+ strb->surface->zslice,
dest_surface,
destX, destY,
destX + width, destY + height,
}
-/** Default method for pipe_context::surface_copy() */
-static void
-st_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dst_x, unsigned dst_y,
- struct pipe_surface *src,
- unsigned src_x, unsigned src_y,
- unsigned w, unsigned h)
-{
- util_surface_copy(pipe, FALSE, dst, dst_x, dst_y, src, src_x, src_y, w, h);
-}
-
-
static struct st_context *
st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
{
st_init_limits(st);
st_init_extensions(st);
- /* plug in helper driver functions if needed */
- if (!pipe->surface_copy)
- pipe->surface_copy = st_surface_copy;
-
return st;
}
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;
+ unsigned sample_mask;
GLuint num_samplers;
GLuint num_textures;
* a depth/stencil buffer and texture from depth/stencil source.
*/
if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0) &&
screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
}
else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0) &&
screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
}
/* sRGB support */
if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0) ||
screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
}
/* s3tc support */
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0) &&
(ctx->Mesa_DXTn ||
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET, 0))) {
ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
ctx->Extensions.S3_s3tc = GL_TRUE;
/* ycbcr support */
if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0) ||
screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
- PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
}
const enum pipe_format formats[],
uint num_formats,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags)
{
uint i;
for (i = 0; i < num_formats; i++) {
if (screen->is_format_supported(screen, formats[i], target,
- tex_usage, geom_flags)) {
+ sample_count, tex_usage, geom_flags)) {
return formats[i];
}
}
static enum pipe_format
default_rgba_format(struct pipe_screen *screen,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags)
{
static const enum pipe_format colorFormats[] = {
PIPE_FORMAT_B5G6R5_UNORM
};
return find_supported_format(screen, colorFormats, Elements(colorFormats),
- target, tex_usage, geom_flags);
+ target, sample_count, tex_usage, geom_flags);
}
static enum pipe_format
default_rgb_format(struct pipe_screen *screen,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags)
{
static const enum pipe_format colorFormats[] = {
PIPE_FORMAT_B5G6R5_UNORM
};
return find_supported_format(screen, colorFormats, Elements(colorFormats),
- target, tex_usage, geom_flags);
+ target, sample_count, tex_usage, geom_flags);
}
/**
static enum pipe_format
default_srgba_format(struct pipe_screen *screen,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned sample_count,
+ unsigned tex_usage,
unsigned geom_flags)
{
static const enum pipe_format colorFormats[] = {
PIPE_FORMAT_A8B8G8R8_SRGB,
};
return find_supported_format(screen, colorFormats, Elements(colorFormats),
- target, tex_usage, geom_flags);
+ target, sample_count, tex_usage, geom_flags);
}
*/
enum pipe_format
st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
- enum pipe_texture_target target, unsigned bindings)
+ enum pipe_texture_target target, unsigned sample_count,
+ unsigned bindings)
{
unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case 3:
case GL_RGB:
- return default_rgb_format( screen, target, bindings, geom_flags );
+ return default_rgb_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_RGBA16:
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_RGBA4:
case GL_RGBA2:
if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM,
- target, bindings, geom_flags ))
+ target, sample_count, bindings,
+ geom_flags ))
return PIPE_FORMAT_B4G4R4A4_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_RGB5_A1:
if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM,
- target, bindings, geom_flags ))
+ target, sample_count, bindings,
+ geom_flags ))
return PIPE_FORMAT_B5G5R5A1_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return default_rgb_format( screen, target, bindings, geom_flags );
+ return default_rgb_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM,
- target, bindings, geom_flags ))
+ target, sample_count, bindings,
+ geom_flags ))
return PIPE_FORMAT_B5G6R5_UNORM;
if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM,
- target, bindings, geom_flags ))
+ target, sample_count, bindings,
+ geom_flags ))
return PIPE_FORMAT_B5G5R5A1_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target,
- bindings, geom_flags ))
+ sample_count, bindings, geom_flags ))
return PIPE_FORMAT_A8_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target,
- bindings, geom_flags ))
+ sample_count, bindings, geom_flags ))
return PIPE_FORMAT_L8_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target,
- bindings, geom_flags ))
+ sample_count, bindings, geom_flags ))
return PIPE_FORMAT_L8A8_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target,
- bindings, geom_flags ))
+ sample_count, bindings, geom_flags ))
return PIPE_FORMAT_I8_UNORM;
- return default_rgba_format( screen, target, bindings, geom_flags );
+ return default_rgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_YCBCR_MESA:
- if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
- target, bindings, geom_flags)) {
+ if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target,
+ sample_count, bindings, geom_flags)) {
return PIPE_FORMAT_UYVY;
}
- if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
- target, bindings, geom_flags)) {
+ if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target,
+ sample_count, bindings, geom_flags)) {
return PIPE_FORMAT_YUYV;
}
return PIPE_FORMAT_NONE;
if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
return PIPE_FORMAT_NONE;
else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
- target, bindings, geom_flags))
+ target, sample_count, bindings,
+ geom_flags))
return PIPE_FORMAT_DXT1_RGB;
else
- return default_rgb_format(screen, target, bindings, geom_flags);
+ return default_rgb_format(screen, target, sample_count, bindings,
+ geom_flags);
case GL_COMPRESSED_RGBA:
/* can only sample from compressed formats */
if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
return PIPE_FORMAT_NONE;
else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
- target, bindings, geom_flags))
+ target, sample_count, bindings,
+ geom_flags))
return PIPE_FORMAT_DXT3_RGBA;
else
- return default_rgba_format(screen, target, bindings, geom_flags);
+ return default_rgba_format(screen, target, sample_count, bindings,
+ geom_flags);
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
- target, bindings, geom_flags))
+ target, sample_count, bindings,
+ geom_flags))
return PIPE_FORMAT_DXT1_RGB;
else
return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA,
- target, bindings, geom_flags))
+ target, sample_count, bindings,
+ geom_flags))
return PIPE_FORMAT_DXT1_RGBA;
else
return PIPE_FORMAT_NONE;
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
- target, bindings, geom_flags))
+ target, sample_count, bindings,
+ geom_flags))
return PIPE_FORMAT_DXT3_RGBA;
else
return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
- target, bindings, geom_flags))
+ target, sample_count, bindings,
+ geom_flags))
return PIPE_FORMAT_DXT5_RGBA;
else
return PIPE_FORMAT_NONE;
case GL_DEPTH_COMPONENT16:
if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target,
- bindings, geom_flags))
+ sample_count, bindings, geom_flags))
return PIPE_FORMAT_Z16_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT24:
if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- target, bindings, geom_flags))
+ target, sample_count, bindings, geom_flags))
return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- target, bindings, geom_flags))
+ target, sample_count, bindings, geom_flags))
return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT32:
- if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM,
- target, bindings, geom_flags))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, target,
+ sample_count, bindings, geom_flags))
return PIPE_FORMAT_Z32_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT:
PIPE_FORMAT_S8_USCALED_Z24_UNORM
};
return find_supported_format(screen, formats, Elements(formats),
- target, bindings, geom_flags);
+ target, sample_count, bindings, geom_flags);
}
case GL_STENCIL_INDEX:
PIPE_FORMAT_S8_USCALED_Z24_UNORM
};
return find_supported_format(screen, formats, Elements(formats),
- target, bindings, geom_flags);
+ target, sample_count, bindings, geom_flags);
}
case GL_DEPTH_STENCIL_EXT:
PIPE_FORMAT_S8_USCALED_Z24_UNORM
};
return find_supported_format(screen, formats, Elements(formats),
- target, bindings, geom_flags);
+ target, sample_count, bindings, geom_flags);
}
case GL_SRGB_EXT:
case GL_COMPRESSED_SRGB_ALPHA_EXT:
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_EXT:
- return default_srgba_format( screen, target, bindings, geom_flags );
+ return default_srgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
return PIPE_FORMAT_DXT1_SRGB;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_SLUMINANCE8_ALPHA8_EXT:
case GL_COMPRESSED_SLUMINANCE_EXT:
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB,
- target, bindings, geom_flags))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, target,
+ sample_count, bindings, geom_flags))
return PIPE_FORMAT_L8A8_SRGB;
- return default_srgba_format( screen, target, bindings, geom_flags );
+ return default_srgba_format( screen, target, sample_count, bindings,
+ geom_flags );
case GL_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB,
- target, bindings, geom_flags))
+ if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, target,
+ sample_count, bindings, geom_flags))
return PIPE_FORMAT_L8_SRGB;
- return default_srgba_format( screen, target, bindings, geom_flags );
+ return default_srgba_format( screen, target, sample_count, bindings,
+ geom_flags );
default:
return PIPE_FORMAT_NONE;
*/
enum pipe_format
st_choose_renderbuffer_format(struct pipe_screen *screen,
- GLenum internalFormat)
+ GLenum internalFormat, unsigned sample_count)
{
uint usage;
if (_mesa_is_depth_or_stencil_format(internalFormat))
usage = PIPE_BIND_DEPTH_STENCIL;
else
usage = PIPE_BIND_RENDER_TARGET;
- return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, usage);
+ return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D,
+ sample_count, usage);
}
bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
pFormat = st_choose_format(screen, internalFormat,
- PIPE_TEXTURE_2D, bindings);
+ PIPE_TEXTURE_2D, 0, bindings);
if (pFormat == PIPE_FORMAT_NONE) {
/* try choosing format again, this time without render target bindings */
pFormat = st_choose_format(screen, internalFormat,
- PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
+ PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
}
if (pFormat == PIPE_FORMAT_NONE) {
extern enum pipe_format
st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
- enum pipe_texture_target target, unsigned tex_usage);
+ enum pipe_texture_target target, unsigned sample_count,
+ unsigned tex_usage);
extern enum pipe_format
st_choose_renderbuffer_format(struct pipe_screen *screen,
- GLenum internalFormat);
+ GLenum internalFormat, unsigned sample_count);
extern gl_format
assert(target != GL_TEXTURE_3D); /* not done yet */
/* check if we can render in the texture's format */
- if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
+ if (!screen->is_format_supported(screen, psv->format, psv->texture->target, 0,
PIPE_BIND_RENDER_TARGET, 0)) {
return FALSE;
}
if (!pt)
return;
- /* find expected last mipmap level to generate */
+ /* not sure if this ultimately actually should work,
+ but we're not supporting multisampled textures yet. */
+ assert(pt->nr_samples < 2);
+
+ /* find expected last mipmap level to generate*/
lastLevel = compute_num_levels(ctx, texObj, target) - 1;
if (lastLevel == 0)
_mesa_lookup_enum_by_nr(format), last_level);
assert(format);
- assert(screen->is_format_supported(screen, format, target,
+ assert(screen->is_format_supported(screen, format, target, 0,
PIPE_BIND_SAMPLER_VIEW, 0));
memset(&pt, 0, sizeof(pt));
struct pipe_resource *src, GLuint srcLevel,
GLuint face)
{
- struct pipe_screen *screen = pipe->screen;
GLuint width = u_minify(dst->width0, dstLevel);
GLuint height = u_minify(dst->height0, dstLevel);
GLuint depth = u_minify(dst->depth0, dstLevel);
- struct pipe_surface *src_surface;
- struct pipe_surface *dst_surface;
+ struct pipe_subresource dstsub, srcsub;
GLuint i;
assert(u_minify(src->width0, srcLevel) == width);
assert(u_minify(src->height0, srcLevel) == height);
assert(u_minify(src->depth0, srcLevel) == depth);
+ dstsub.face = face;
+ dstsub.level = dstLevel;
+ srcsub.face = face;
+ srcsub.level = srcLevel;
/* Loop over 3D image slices */
for (i = 0; i < depth; i++) {
print_center_pixel(pipe, src);
}
- dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i,
- PIPE_BIND_BLIT_DESTINATION);
-
- src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
- PIPE_BIND_BLIT_SOURCE);
-
- pipe->surface_copy(pipe,
- dst_surface,
- 0, 0, /* destX, Y */
- src_surface,
- 0, 0, /* srcX, Y */
- width, height);
-
- pipe_surface_reference(&src_surface, NULL);
- pipe_surface_reference(&dst_surface, NULL);
+ pipe->resource_copy_region(pipe,
+ dst,
+ dstsub,
+ 0, 0, i,/* destX, Y, Z */
+ src,
+ srcsub,
+ 0, 0, i,/* srcX, Y, Z */
+ width, height);
}
}