'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;
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
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;
if (!stObj)
return GL_FALSE;
- return screen->is_format_supported(screen, stObj->pt->format,
- PIPE_TEXTURE_2D, bindings, 0);
+ return screen->is_format_supported(screen, stObj->pt->format, stObj->pt->nr_samples,
+ PIPE_TEXTURE_2D, 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;
+ /* 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 */
lastLevel = compute_num_levels(ctx, texObj, target) - 1;
_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 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(src->width0 == dst->width0);
assert(src->height0 == dst->height0);
+ dstsub.face = face;
+ dstsub.level = dstLevel;
+ srcsub.face = face;
+
for (i = 0; i < depth; i++) {
GLuint srcLevel;
#if 0
{
+ struct pipe_screen *screen = pipe->screen;
src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
PIPE_BUFFER_USAGE_CPU_READ);
ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ);
pipe_surface_reference(&src_surface, NULL);
}
#endif
-
- 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);
+ srcsub.level = srcLevel;
+
+ pipe->resource_copy_region(pipe,
+ dst,
+ dstsub,
+ 0, 0, i,/* destX, Y, Z */
+ src,
+ srcsub,
+ 0, 0, i,/* srcX, Y, Z */
+ width, height);
}
}