mesa/st: adapt to interface changes

adapt to blit changes, and also handle a bit more msaa state in theory
(incomplete, doesn't handle resolves in any way for now).
This commit is contained in:
Roland Scheidegger
2010-05-17 21:19:03 +02:00
parent 815b75705f
commit 127328bfad
23 changed files with 314 additions and 192 deletions

View File

@@ -151,6 +151,7 @@ if env['platform'] != 'winddk':
'state_tracker/st_atom_constbuf.c', 'state_tracker/st_atom_constbuf.c',
'state_tracker/st_atom_depth.c', 'state_tracker/st_atom_depth.c',
'state_tracker/st_atom_framebuffer.c', 'state_tracker/st_atom_framebuffer.c',
'state_tracker/st_atom_msaa.c',
'state_tracker/st_atom_pixeltransfer.c', 'state_tracker/st_atom_pixeltransfer.c',
'state_tracker/st_atom_sampler.c', 'state_tracker/st_atom_sampler.c',
'state_tracker/st_atom_scissor.c', 'state_tracker/st_atom_scissor.c',

View File

@@ -195,6 +195,7 @@ STATETRACKER_SOURCES = \
state_tracker/st_atom_constbuf.c \ state_tracker/st_atom_constbuf.c \
state_tracker/st_atom_depth.c \ state_tracker/st_atom_depth.c \
state_tracker/st_atom_framebuffer.c \ state_tracker/st_atom_framebuffer.c \
state_tracker/st_atom_msaa.c \
state_tracker/st_atom_pixeltransfer.c \ state_tracker/st_atom_pixeltransfer.c \
state_tracker/st_atom_sampler.c \ state_tracker/st_atom_sampler.c \
state_tracker/st_atom_scissor.c \ state_tracker/st_atom_scissor.c \

View File

@@ -57,6 +57,7 @@ static const struct st_tracked_state *atoms[] =
&st_update_sampler, &st_update_sampler,
&st_update_texture, &st_update_texture,
&st_update_framebuffer, &st_update_framebuffer,
&st_update_msaa,
&st_update_vs_constants, &st_update_vs_constants,
&st_update_fs_constants, &st_update_fs_constants,
&st_update_pixel_transfer &st_update_pixel_transfer

View File

@@ -54,6 +54,7 @@ extern const struct st_tracked_state st_update_polygon_stipple;
extern const struct st_tracked_state st_update_viewport; 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_scissor;
extern const struct st_tracked_state st_update_blend; 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_sampler;
extern const struct st_tracked_state st_update_texture; extern const struct st_tracked_state st_update_texture;
extern const struct st_tracked_state st_finalize_textures; extern const struct st_tracked_state st_finalize_textures;

View File

@@ -257,6 +257,15 @@ update_blend( struct st_context *st )
if (st->ctx->Color.DitherFlag) if (st->ctx->Color.DitherFlag)
blend->dither = 1; 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); cso_set_blend(st->cso_context, blend);
{ {
@@ -270,7 +279,7 @@ update_blend( struct st_context *st )
const struct st_tracked_state st_update_blend = { const struct st_tracked_state st_update_blend = {
"st_update_blend", /* name */ "st_update_blend", /* name */
{ /* dirty */ { /* dirty */
(_NEW_COLOR), /* XXX _NEW_BLEND someday? */ /* mesa */ (_NEW_COLOR | _NEW_MULTISAMPLE), /* XXX _NEW_BLEND someday? */ /* mesa */
0, /* st */ 0, /* st */
}, },
update_blend, /* update */ update_blend, /* update */

View File

@@ -73,9 +73,7 @@ update_renderbuffer_surface(struct st_context *st,
strb->rtt_face, strb->rtt_face,
level, level,
strb->rtt_slice, strb->rtt_slice,
PIPE_BIND_RENDER_TARGET | PIPE_BIND_RENDER_TARGET);
PIPE_BIND_BLIT_SOURCE |
PIPE_BIND_BLIT_DESTINATION );
#if 0 #if 0
printf("-- alloc new surface %d x %d into tex %p\n", printf("-- alloc new surface %d x %d into tex %p\n",
strb->surface->width, strb->surface->height, strb->surface->width, strb->surface->height,

View File

@@ -0,0 +1,83 @@
/**************************************************************************
*
* 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 */
};

View File

@@ -123,7 +123,7 @@ create_color_map_texture(GLcontext *ctx)
/* find an RGBA texture format */ /* find an RGBA texture format */
format = st_choose_format(pipe->screen, GL_RGBA, 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 */ /* create texture for color map/table */
pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,

View File

@@ -807,15 +807,15 @@ st_init_bitmap(struct st_context *st)
st->bitmap.rasterizer.gl_rasterization_rules = 1; st->bitmap.rasterizer.gl_rasterization_rules = 1;
/* find a usable texture format */ /* 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)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM; 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)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM; 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)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM; st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
} }

View File

@@ -112,33 +112,23 @@ st_BlitFramebuffer(GLcontext *ctx,
&readFB->Attachment[readFB->_ColorReadBufferIndex]; &readFB->Attachment[readFB->_ColorReadBufferIndex];
if(srcAtt->Type == GL_TEXTURE) { if(srcAtt->Type == GL_TEXTURE) {
struct pipe_screen *screen = pipe->screen;
struct st_texture_object *srcObj = struct st_texture_object *srcObj =
st_texture_object(srcAtt->Texture); st_texture_object(srcAtt->Texture);
struct st_renderbuffer *dstRb = struct st_renderbuffer *dstRb =
st_renderbuffer(drawFB->_ColorDrawBuffers[0]); st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
struct pipe_surface *srcSurf; struct pipe_subresource srcSub;
struct pipe_surface *dstSurf = dstRb->surface; struct pipe_surface *dstSurf = dstRb->surface;
if (!srcObj->pt) if (!srcObj->pt)
return; return;
srcSurf = screen->get_tex_surface(screen, srcSub.face = srcAtt->CubeMapFace;
srcObj->pt, srcSub.level = srcAtt->TextureLevel;
srcAtt->CubeMapFace,
srcAtt->TextureLevel,
srcAtt->Zoffset,
PIPE_BIND_BLIT_SOURCE);
if(!srcSurf)
return;
util_blit_pixels(st->blit, util_blit_pixels(st->blit, srcObj->pt, srcSub,
srcSurf, st_get_texture_sampler_view(srcObj, pipe), srcX0, srcY0, srcX1, srcY1, srcAtt->Zoffset,
srcX0, srcY0, srcX1, srcY1,
dstSurf, dstX0, dstY0, dstX1, dstY1, dstSurf, dstX0, dstY0, dstX1, dstY1,
0.0, pFilter); 0.0, pFilter);
pipe_surface_reference(&srcSurf, NULL);
} }
else { else {
struct st_renderbuffer *srcRb = struct st_renderbuffer *srcRb =
@@ -146,11 +136,15 @@ st_BlitFramebuffer(GLcontext *ctx,
struct st_renderbuffer *dstRb = struct st_renderbuffer *dstRb =
st_renderbuffer(drawFB->_ColorDrawBuffers[0]); st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
struct pipe_surface *srcSurf = srcRb->surface; 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_surface *dstSurf = dstRb->surface;
struct pipe_subresource srcSub;
srcSub.face = srcSurf->face;
srcSub.level = srcSurf->level;
util_blit_pixels(st->blit, 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, dstSurf, dstX0, dstY0, dstX1, dstY1,
0.0, pFilter); 0.0, pFilter);
} }
@@ -182,13 +176,17 @@ st_BlitFramebuffer(GLcontext *ctx,
if ((mask & depthStencil) == depthStencil && if ((mask & depthStencil) == depthStencil &&
srcDepthSurf == srcStencilSurf && srcDepthSurf == srcStencilSurf &&
dstDepthSurf == dstStencilSurf) { 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 /* Blitting depth and stencil values between combined
* depth/stencil buffers. This is the ideal case for such buffers. * depth/stencil buffers. This is the ideal case for such buffers.
*/ */
util_blit_pixels(st->blit, 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, dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
0.0, pFilter); 0.0, pFilter);
} }

View File

@@ -180,9 +180,7 @@ st_bufferobj_data(GLcontext *ctx,
switch(target) { switch(target) {
case GL_PIXEL_PACK_BUFFER_ARB: case GL_PIXEL_PACK_BUFFER_ARB:
case GL_PIXEL_UNPACK_BUFFER_ARB: case GL_PIXEL_UNPACK_BUFFER_ARB:
buffer_usage = (PIPE_BIND_RENDER_TARGET | buffer_usage = PIPE_BIND_RENDER_TARGET;
PIPE_BIND_BLIT_SOURCE |
PIPE_BIND_BLIT_DESTINATION);
break; break;
case GL_ARRAY_BUFFER_ARB: case GL_ARRAY_BUFFER_ARB:
buffer_usage = PIPE_BIND_VERTEX_BUFFER; buffer_usage = PIPE_BIND_VERTEX_BUFFER;

View File

@@ -968,6 +968,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
enum pipe_format srcFormat, texFormat; enum pipe_format srcFormat, texFormat;
GLboolean invertTex = GL_FALSE; GLboolean invertTex = GL_FALSE;
GLint readX, readY, readW, readH; GLint readX, readY, readW, readH;
GLuint sample_count;
struct gl_pixelstore_attrib pack = ctx->DefaultPacking; struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
@@ -994,9 +995,15 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
driver_vp = make_passthrough_vertex_shader(st, GL_TRUE); 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; 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)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
texFormat = srcFormat; texFormat = srcFormat;
} }
@@ -1004,14 +1011,14 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* srcFormat can't be used as a texture format */ /* srcFormat can't be used as a texture format */
if (type == GL_DEPTH) { if (type == GL_DEPTH) {
texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT, texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, sample_count,
PIPE_BIND_DEPTH_STENCIL); PIPE_BIND_DEPTH_STENCIL);
assert(texFormat != PIPE_FORMAT_NONE); assert(texFormat != PIPE_FORMAT_NONE);
} }
else { else {
/* default color format */ /* default color format */
texFormat = st_choose_format(screen, GL_RGBA, PIPE_TEXTURE_2D, 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); assert(texFormat != PIPE_FORMAT_NONE);
} }
} }
@@ -1050,27 +1057,20 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* Make temporary texture which is a copy of the src region. /* Make temporary texture which is a copy of the src region.
*/ */
if (srcFormat == texFormat) { 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 */ /* copy source framebuffer surface into mipmap/texture */
struct pipe_surface *psRead = screen->get_tex_surface(screen, pipe->resource_copy_region(pipe,
rbRead->texture, 0, 0, 0, pt, /* dest tex */
PIPE_BIND_BLIT_SOURCE); dstsub,
struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, pack.SkipPixels, pack.SkipRows, 0, /* dest pos */
PIPE_BIND_RENDER_TARGET | rbRead->texture, /* src tex */
PIPE_BIND_BLIT_DESTINATION); srcsub,
pipe->surface_copy(pipe, readX, readY, 0, readW, readH); /* src region */
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_surface_reference(&psRead, NULL);
pipe_surface_reference(&psTex, NULL);
} }
else { else {
/* CPU-based fallback/conversion */ /* CPU-based fallback/conversion */

View File

@@ -79,7 +79,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx,
struct pipe_surface *ps; struct pipe_surface *ps;
unsigned usage; 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); ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
if (ps) { if (ps) {
strb->Base.Width = ps->width; strb->Base.Width = ps->width;
@@ -142,7 +142,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target,
struct pipe_surface *ps; struct pipe_surface *ps;
unsigned usage; 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); ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
if (ps) { if (ps) {
st_bind_surface(ctx, target, texObj, texImage, ps); st_bind_surface(ctx, target, texObj, texImage, ps);

View File

@@ -72,7 +72,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
if (strb->format != PIPE_FORMAT_NONE) if (strb->format != PIPE_FORMAT_NONE)
format = strb->format; format = strb->format;
else else
format = st_choose_renderbuffer_format(screen, internalFormat); format = st_choose_renderbuffer_format(screen, internalFormat, rb->NumSamples);
/* init renderbuffer fields */ /* init renderbuffer fields */
strb->Base.Width = width; strb->Base.Width = width;
@@ -441,7 +441,7 @@ st_validate_attachment(struct pipe_screen *screen,
if (!stObj) if (!stObj)
return GL_FALSE; return GL_FALSE;
return screen->is_format_supported(screen, stObj->pt->format, return screen->is_format_supported(screen, stObj->pt->format, stObj->pt->nr_samples,
PIPE_TEXTURE_2D, bindings, 0); PIPE_TEXTURE_2D, bindings, 0);
} }
@@ -545,6 +545,7 @@ void st_init_fbo_functions(struct dd_function_table *functions)
functions->ReadBuffer = st_ReadBuffer; functions->ReadBuffer = st_ReadBuffer;
} }
/* XXX unused ? */
struct pipe_sampler_view * struct pipe_sampler_view *
st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb, st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb,
struct pipe_context *pipe) struct pipe_context *pipe)

View File

@@ -73,6 +73,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw);
extern void extern void
st_init_fbo_functions(struct dd_function_table *functions); st_init_fbo_functions(struct dd_function_table *functions);
/* XXX unused ? */
extern struct pipe_sampler_view * extern struct pipe_sampler_view *
st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb, st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb,
struct pipe_context *pipe); struct pipe_context *pipe);

View File

@@ -221,7 +221,7 @@ default_bindings(struct st_context *st, enum pipe_format format)
else else
bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; 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; return bindings;
else else
return PIPE_BIND_SAMPLER_VIEW; return PIPE_BIND_SAMPLER_VIEW;
@@ -428,7 +428,7 @@ compress_with_blit(GLcontext * ctx,
/* get destination surface (in the compressed texture) */ /* get destination surface (in the compressed texture) */
dst_surface = screen->get_tex_surface(screen, stImage->pt, dst_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level, 0, stImage->face, stImage->level, 0,
PIPE_BIND_BLIT_DESTINATION); 0 /* flags */);
if (!dst_surface) { if (!dst_surface) {
/* can't render into this format (or other problem) */ /* can't render into this format (or other problem) */
return GL_FALSE; return GL_FALSE;
@@ -652,7 +652,7 @@ st_TexImage(GLcontext * ctx,
_mesa_is_format_compressed(texImage->TexFormat) && _mesa_is_format_compressed(texImage->TexFormat) &&
screen->is_format_supported(screen, screen->is_format_supported(screen,
stImage->pt->format, stImage->pt->format,
stImage->pt->target, stImage->pt->target, 0,
PIPE_BIND_RENDER_TARGET, 0)) { PIPE_BIND_RENDER_TARGET, 0)) {
if (!pixels) if (!pixels)
goto done; goto done;
@@ -848,8 +848,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
struct pipe_surface *dst_surface; struct pipe_surface *dst_surface;
struct pipe_resource *dst_texture; struct pipe_resource *dst_texture;
struct pipe_transfer *tex_xfer; struct pipe_transfer *tex_xfer;
unsigned bind = (PIPE_BIND_BLIT_DESTINATION | unsigned bind = (PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
PIPE_BIND_TRANSFER_READ); PIPE_BIND_TRANSFER_READ);
/* create temp / dest surface */ /* create temp / dest surface */
@@ -1080,7 +1079,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
_mesa_is_format_compressed(texImage->TexFormat) && _mesa_is_format_compressed(texImage->TexFormat) &&
screen->is_format_supported(screen, screen->is_format_supported(screen,
stImage->pt->format, stImage->pt->format,
stImage->pt->target, stImage->pt->target, 0,
PIPE_BIND_RENDER_TARGET, 0)) { PIPE_BIND_RENDER_TARGET, 0)) {
if (compress_with_blit(ctx, target, level, if (compress_with_blit(ctx, target, level,
xoffset, yoffset, zoffset, xoffset, yoffset, zoffset,
@@ -1508,7 +1507,7 @@ st_copy_texsubimage(GLcontext *ctx,
enum pipe_format dest_format, src_format; enum pipe_format dest_format, src_format;
GLboolean use_fallback = GL_TRUE; GLboolean use_fallback = GL_TRUE;
GLboolean matching_base_formats; GLboolean matching_base_formats;
GLuint format_writemask; GLuint format_writemask, sample_count;
struct pipe_surface *dest_surface = NULL; struct pipe_surface *dest_surface = NULL;
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
@@ -1534,6 +1533,12 @@ st_copy_texsubimage(GLcontext *ctx,
return; 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) { if (srcX < 0) {
width -= -srcX; width -= -srcX;
destX += -srcX; destX += -srcX;
@@ -1589,20 +1594,22 @@ st_copy_texsubimage(GLcontext *ctx,
!do_flip) !do_flip)
{ {
/* use surface_copy() / blit */ /* use surface_copy() / blit */
struct pipe_subresource subdst, subsrc;
subdst.face = stImage->face;
subdst.level = stImage->level;
subsrc.face = strb->surface->face;
subsrc.level = strb->surface->level;
dest_surface = screen->get_tex_surface(screen, stImage->pt, /* for resource_copy_region(), y=0=top, always */
stImage->face, stImage->level, pipe->resource_copy_region(pipe,
destZ,
PIPE_BIND_BLIT_DESTINATION);
/* for surface_copy(), y=0=top, always */
pipe->surface_copy(pipe,
/* dest */ /* dest */
dest_surface, stImage->pt,
destX, destY, subdst,
destX, destY, destZ,
/* src */ /* src */
strb->surface, strb->texture,
srcX, srcY, subsrc,
srcX, srcY, strb->surface->zslice,
/* size */ /* size */
width, height); width, height);
use_fallback = GL_FALSE; use_fallback = GL_FALSE;
@@ -1611,20 +1618,21 @@ st_copy_texsubimage(GLcontext *ctx,
texBaseFormat != GL_DEPTH_COMPONENT && texBaseFormat != GL_DEPTH_COMPONENT &&
texBaseFormat != GL_DEPTH_STENCIL && texBaseFormat != GL_DEPTH_STENCIL &&
screen->is_format_supported(screen, src_format, screen->is_format_supported(screen, src_format,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, sample_count,
PIPE_BIND_SAMPLER_VIEW, PIPE_BIND_SAMPLER_VIEW,
0) && 0) &&
screen->is_format_supported(screen, dest_format, screen->is_format_supported(screen, dest_format,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET, PIPE_BIND_RENDER_TARGET,
0)) { 0)) {
/* draw textured quad to do the copy */ /* draw textured quad to do the copy */
GLint srcY0, srcY1; GLint srcY0, srcY1;
struct pipe_subresource subsrc;
dest_surface = screen->get_tex_surface(screen, stImage->pt, dest_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level, stImage->face, stImage->level,
destZ, destZ,
PIPE_BIND_BLIT_DESTINATION); PIPE_BIND_RENDER_TARGET);
if (do_flip) { if (do_flip) {
srcY1 = strb->Base.Height - srcY - height; srcY1 = strb->Base.Height - srcY - height;
@@ -1634,11 +1642,15 @@ st_copy_texsubimage(GLcontext *ctx,
srcY0 = srcY; srcY0 = srcY;
srcY1 = srcY0 + height; srcY1 = srcY0 + height;
} }
subsrc.face = strb->surface->face;
subsrc.level = strb->surface->level;
util_blit_pixels_writemask(st->blit, util_blit_pixels_writemask(st->blit,
strb->surface, strb->texture,
st_get_renderbuffer_sampler_view(strb, pipe), subsrc,
srcX, srcY0, srcX, srcY0,
srcX + width, srcY1, srcX + width, srcY1,
strb->surface->zslice,
dest_surface, dest_surface,
destX, destY, destX, destY,
destX + width, destY + height, destX + width, destY + height,

View File

@@ -99,19 +99,6 @@ st_get_msaa(void)
} }
/** 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 * static struct st_context *
st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
{ {
@@ -181,10 +168,6 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
st_init_limits(st); st_init_limits(st);
st_init_extensions(st); st_init_extensions(st);
/* plug in helper driver functions if needed */
if (!pipe->surface_copy)
pipe->surface_copy = st_surface_copy;
return st; return st;
} }

View File

@@ -94,6 +94,7 @@ struct st_context
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_scissor_state scissor; struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport; struct pipe_viewport_state viewport;
unsigned sample_mask;
GLuint num_samplers; GLuint num_samplers;
GLuint num_textures; GLuint num_textures;

View File

@@ -287,39 +287,39 @@ void st_init_extensions(struct st_context *st)
* a depth/stencil buffer and texture from depth/stencil source. * a depth/stencil buffer and texture from depth/stencil source.
*/ */
if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_DEPTH_STENCIL, 0) && PIPE_BIND_DEPTH_STENCIL, 0) &&
screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
} }
else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, 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) && PIPE_BIND_DEPTH_STENCIL, 0) &&
screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
} }
/* sRGB support */ /* sRGB support */
if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0) || PIPE_BIND_SAMPLER_VIEW, 0) ||
screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_texture_sRGB = GL_TRUE; ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
} }
/* s3tc support */ /* s3tc support */
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0) && PIPE_BIND_SAMPLER_VIEW, 0) &&
(ctx->Mesa_DXTn || (ctx->Mesa_DXTn ||
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET, 0))) { PIPE_BIND_RENDER_TARGET, 0))) {
ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
ctx->Extensions.S3_s3tc = GL_TRUE; ctx->Extensions.S3_s3tc = GL_TRUE;
@@ -327,10 +327,10 @@ void st_init_extensions(struct st_context *st)
/* ycbcr support */ /* ycbcr support */
if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0) || PIPE_BIND_SAMPLER_VIEW, 0) ||
screen->is_format_supported(screen, PIPE_FORMAT_YUYV, screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
PIPE_TEXTURE_2D, PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW, 0)) { PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
} }

View File

@@ -311,13 +311,14 @@ find_supported_format(struct pipe_screen *screen,
const enum pipe_format formats[], const enum pipe_format formats[],
uint num_formats, uint num_formats,
enum pipe_texture_target target, enum pipe_texture_target target,
unsigned sample_count,
unsigned tex_usage, unsigned tex_usage,
unsigned geom_flags) unsigned geom_flags)
{ {
uint i; uint i;
for (i = 0; i < num_formats; i++) { for (i = 0; i < num_formats; i++) {
if (screen->is_format_supported(screen, formats[i], target, if (screen->is_format_supported(screen, formats[i], target,
tex_usage, geom_flags)) { sample_count, tex_usage, geom_flags)) {
return formats[i]; return formats[i];
} }
} }
@@ -331,6 +332,7 @@ find_supported_format(struct pipe_screen *screen,
static enum pipe_format static enum pipe_format
default_rgba_format(struct pipe_screen *screen, default_rgba_format(struct pipe_screen *screen,
enum pipe_texture_target target, enum pipe_texture_target target,
unsigned sample_count,
unsigned tex_usage, unsigned tex_usage,
unsigned geom_flags) unsigned geom_flags)
{ {
@@ -341,7 +343,7 @@ default_rgba_format(struct pipe_screen *screen,
PIPE_FORMAT_B5G6R5_UNORM PIPE_FORMAT_B5G6R5_UNORM
}; };
return find_supported_format(screen, colorFormats, Elements(colorFormats), return find_supported_format(screen, colorFormats, Elements(colorFormats),
target, tex_usage, geom_flags); target, sample_count, tex_usage, geom_flags);
} }
@@ -351,6 +353,7 @@ default_rgba_format(struct pipe_screen *screen,
static enum pipe_format static enum pipe_format
default_rgb_format(struct pipe_screen *screen, default_rgb_format(struct pipe_screen *screen,
enum pipe_texture_target target, enum pipe_texture_target target,
unsigned sample_count,
unsigned tex_usage, unsigned tex_usage,
unsigned geom_flags) unsigned geom_flags)
{ {
@@ -364,7 +367,7 @@ default_rgb_format(struct pipe_screen *screen,
PIPE_FORMAT_B5G6R5_UNORM PIPE_FORMAT_B5G6R5_UNORM
}; };
return find_supported_format(screen, colorFormats, Elements(colorFormats), return find_supported_format(screen, colorFormats, Elements(colorFormats),
target, tex_usage, geom_flags); target, sample_count, tex_usage, geom_flags);
} }
/** /**
@@ -373,6 +376,7 @@ default_rgb_format(struct pipe_screen *screen,
static enum pipe_format static enum pipe_format
default_srgba_format(struct pipe_screen *screen, default_srgba_format(struct pipe_screen *screen,
enum pipe_texture_target target, enum pipe_texture_target target,
unsigned sample_count,
unsigned tex_usage, unsigned tex_usage,
unsigned geom_flags) unsigned geom_flags)
{ {
@@ -382,7 +386,7 @@ default_srgba_format(struct pipe_screen *screen,
PIPE_FORMAT_A8B8G8R8_SRGB, PIPE_FORMAT_A8B8G8R8_SRGB,
}; };
return find_supported_format(screen, colorFormats, Elements(colorFormats), return find_supported_format(screen, colorFormats, Elements(colorFormats),
target, tex_usage, geom_flags); target, sample_count, tex_usage, geom_flags);
} }
@@ -401,7 +405,8 @@ default_srgba_format(struct pipe_screen *screen,
*/ */
enum pipe_format enum pipe_format
st_choose_format(struct pipe_screen *screen, GLenum internalFormat, 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 */ unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */
@@ -411,42 +416,53 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_RGBA8: case GL_RGBA8:
case GL_RGB10_A2: case GL_RGB10_A2:
case GL_RGBA12: 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 3:
case GL_RGB: 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: 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_RGBA4:
case GL_RGBA2: case GL_RGBA2:
if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, 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 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: case GL_RGB5_A1:
if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_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 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_RGB8:
case GL_RGB10: case GL_RGB10:
case GL_RGB12: case GL_RGB12:
case GL_RGB16: 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_RGB5:
case GL_RGB4: case GL_RGB4:
case GL_R3_G3_B2: case GL_R3_G3_B2:
if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, 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; return PIPE_FORMAT_B5G6R5_UNORM;
if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_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 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_ALPHA:
case GL_ALPHA4: case GL_ALPHA4:
@@ -455,9 +471,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_ALPHA16: case GL_ALPHA16:
case GL_COMPRESSED_ALPHA: case GL_COMPRESSED_ALPHA:
if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, 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 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 1:
case GL_LUMINANCE: case GL_LUMINANCE:
@@ -467,9 +484,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_LUMINANCE16: case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE: case GL_COMPRESSED_LUMINANCE:
if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, 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 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 2:
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
@@ -481,9 +499,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_LUMINANCE16_ALPHA16: case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA: case GL_COMPRESSED_LUMINANCE_ALPHA:
if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, 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 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_INTENSITY:
case GL_INTENSITY4: case GL_INTENSITY4:
@@ -492,17 +511,18 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_INTENSITY16: case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY: case GL_COMPRESSED_INTENSITY:
if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, 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 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: case GL_YCBCR_MESA:
if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target,
target, bindings, geom_flags)) { sample_count, bindings, geom_flags)) {
return PIPE_FORMAT_UYVY; return PIPE_FORMAT_UYVY;
} }
if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target,
target, bindings, geom_flags)) { sample_count, bindings, geom_flags)) {
return PIPE_FORMAT_YUYV; return PIPE_FORMAT_YUYV;
} }
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
@@ -512,33 +532,39 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
if (bindings & ~PIPE_BIND_SAMPLER_VIEW) if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, 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; return PIPE_FORMAT_DXT1_RGB;
else 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: case GL_COMPRESSED_RGBA:
/* can only sample from compressed formats */ /* can only sample from compressed formats */
if (bindings & ~PIPE_BIND_SAMPLER_VIEW) if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, 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; return PIPE_FORMAT_DXT3_RGBA;
else 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_RGB_S3TC:
case GL_RGB4_S3TC: case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, 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; return PIPE_FORMAT_DXT1_RGB;
else else
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA, 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; return PIPE_FORMAT_DXT1_RGBA;
else else
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
@@ -547,14 +573,16 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_RGBA4_S3TC: case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, 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; return PIPE_FORMAT_DXT3_RGBA;
else else
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, 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; return PIPE_FORMAT_DXT5_RGBA;
else else
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
@@ -568,20 +596,20 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT16:
if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target, if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target,
bindings, geom_flags)) sample_count, bindings, geom_flags))
return PIPE_FORMAT_Z16_UNORM; return PIPE_FORMAT_Z16_UNORM;
/* fall-through */ /* fall-through */
case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT24:
if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, 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; return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, 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; return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
/* fall-through */ /* fall-through */
case GL_DEPTH_COMPONENT32: case GL_DEPTH_COMPONENT32:
if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, target,
target, bindings, geom_flags)) sample_count, bindings, geom_flags))
return PIPE_FORMAT_Z32_UNORM; return PIPE_FORMAT_Z32_UNORM;
/* fall-through */ /* fall-through */
case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT:
@@ -593,7 +621,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
PIPE_FORMAT_S8_USCALED_Z24_UNORM PIPE_FORMAT_S8_USCALED_Z24_UNORM
}; };
return find_supported_format(screen, formats, Elements(formats), return find_supported_format(screen, formats, Elements(formats),
target, bindings, geom_flags); target, sample_count, bindings, geom_flags);
} }
case GL_STENCIL_INDEX: case GL_STENCIL_INDEX:
@@ -608,7 +636,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
PIPE_FORMAT_S8_USCALED_Z24_UNORM PIPE_FORMAT_S8_USCALED_Z24_UNORM
}; };
return find_supported_format(screen, formats, Elements(formats), return find_supported_format(screen, formats, Elements(formats),
target, bindings, geom_flags); target, sample_count, bindings, geom_flags);
} }
case GL_DEPTH_STENCIL_EXT: case GL_DEPTH_STENCIL_EXT:
@@ -619,7 +647,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
PIPE_FORMAT_S8_USCALED_Z24_UNORM PIPE_FORMAT_S8_USCALED_Z24_UNORM
}; };
return find_supported_format(screen, formats, Elements(formats), return find_supported_format(screen, formats, Elements(formats),
target, bindings, geom_flags); target, sample_count, bindings, geom_flags);
} }
case GL_SRGB_EXT: case GL_SRGB_EXT:
@@ -628,7 +656,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_COMPRESSED_SRGB_ALPHA_EXT: case GL_COMPRESSED_SRGB_ALPHA_EXT:
case GL_SRGB_ALPHA_EXT: case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_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: case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
return PIPE_FORMAT_DXT1_SRGB; return PIPE_FORMAT_DXT1_SRGB;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
@@ -642,17 +671,19 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_SLUMINANCE8_ALPHA8_EXT: case GL_SLUMINANCE8_ALPHA8_EXT:
case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_EXT:
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, target,
target, bindings, geom_flags)) sample_count, bindings, geom_flags))
return PIPE_FORMAT_L8A8_SRGB; 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_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT: case GL_SLUMINANCE8_EXT:
if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, target,
target, bindings, geom_flags)) sample_count, bindings, geom_flags))
return PIPE_FORMAT_L8_SRGB; 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: default:
return PIPE_FORMAT_NONE; return PIPE_FORMAT_NONE;
@@ -665,14 +696,15 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
*/ */
enum pipe_format enum pipe_format
st_choose_renderbuffer_format(struct pipe_screen *screen, st_choose_renderbuffer_format(struct pipe_screen *screen,
GLenum internalFormat) GLenum internalFormat, unsigned sample_count)
{ {
uint usage; uint usage;
if (_mesa_is_depth_or_stencil_format(internalFormat)) if (_mesa_is_depth_or_stencil_format(internalFormat))
usage = PIPE_BIND_DEPTH_STENCIL; usage = PIPE_BIND_DEPTH_STENCIL;
else else
usage = PIPE_BIND_RENDER_TARGET; 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);
} }
@@ -700,12 +732,12 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
pFormat = st_choose_format(screen, internalFormat, pFormat = st_choose_format(screen, internalFormat,
PIPE_TEXTURE_2D, bindings); PIPE_TEXTURE_2D, 0, bindings);
if (pFormat == PIPE_FORMAT_NONE) { if (pFormat == PIPE_FORMAT_NONE) {
/* try choosing format again, this time without render target bindings */ /* try choosing format again, this time without render target bindings */
pFormat = st_choose_format(screen, internalFormat, 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) { if (pFormat == PIPE_FORMAT_NONE) {

View File

@@ -46,11 +46,12 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
extern enum pipe_format extern enum pipe_format
st_choose_format(struct pipe_screen *screen, GLenum internalFormat, 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 extern enum pipe_format
st_choose_renderbuffer_format(struct pipe_screen *screen, st_choose_renderbuffer_format(struct pipe_screen *screen,
GLenum internalFormat); GLenum internalFormat, unsigned sample_count);
extern gl_format extern gl_format

View File

@@ -82,7 +82,7 @@ st_render_mipmap(struct st_context *st,
assert(target != GL_TEXTURE_3D); /* not done yet */ assert(target != GL_TEXTURE_3D); /* not done yet */
/* check if we can render in the texture's format */ /* 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)) { PIPE_BIND_RENDER_TARGET, 0)) {
return FALSE; return FALSE;
} }
@@ -300,6 +300,10 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
if (!pt) if (!pt)
return; 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 */ /* find expected last mipmap level */
lastLevel = compute_num_levels(ctx, texObj, target) - 1; lastLevel = compute_num_levels(ctx, texObj, target) - 1;

View File

@@ -72,7 +72,7 @@ st_texture_create(struct st_context *st,
_mesa_lookup_enum_by_nr(format), last_level); _mesa_lookup_enum_by_nr(format), last_level);
assert(format); assert(format);
assert(screen->is_format_supported(screen, format, target, assert(screen->is_format_supported(screen, format, target, 0,
PIPE_BIND_SAMPLER_VIEW, 0)); PIPE_BIND_SAMPLER_VIEW, 0));
memset(&pt, 0, sizeof(pt)); memset(&pt, 0, sizeof(pt));
@@ -245,17 +245,19 @@ st_texture_image_copy(struct pipe_context *pipe,
struct pipe_resource *src, struct pipe_resource *src,
GLuint face) GLuint face)
{ {
struct pipe_screen *screen = pipe->screen;
GLuint width = u_minify(dst->width0, dstLevel); GLuint width = u_minify(dst->width0, dstLevel);
GLuint height = u_minify(dst->height0, dstLevel); GLuint height = u_minify(dst->height0, dstLevel);
GLuint depth = u_minify(dst->depth0, dstLevel); GLuint depth = u_minify(dst->depth0, dstLevel);
struct pipe_surface *src_surface; struct pipe_subresource dstsub, srcsub;
struct pipe_surface *dst_surface;
GLuint i; GLuint i;
assert(src->width0 == dst->width0); assert(src->width0 == dst->width0);
assert(src->height0 == dst->height0); assert(src->height0 == dst->height0);
dstsub.face = face;
dstsub.level = dstLevel;
srcsub.face = face;
for (i = 0; i < depth; i++) { for (i = 0; i < depth; i++) {
GLuint srcLevel; GLuint srcLevel;
@@ -271,6 +273,7 @@ st_texture_image_copy(struct pipe_context *pipe,
#if 0 #if 0
{ {
struct pipe_screen *screen = pipe->screen;
src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
PIPE_BUFFER_USAGE_CPU_READ); PIPE_BUFFER_USAGE_CPU_READ);
ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ); ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ);
@@ -284,22 +287,16 @@ st_texture_image_copy(struct pipe_context *pipe,
pipe_surface_reference(&src_surface, NULL); pipe_surface_reference(&src_surface, NULL);
} }
#endif #endif
srcsub.level = srcLevel;
dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i, pipe->resource_copy_region(pipe,
PIPE_BIND_BLIT_DESTINATION); dst,
dstsub,
src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, 0, 0, i,/* destX, Y, Z */
PIPE_BIND_BLIT_SOURCE); src,
srcsub,
pipe->surface_copy(pipe, 0, 0, i,/* srcX, Y, Z */
dst_surface,
0, 0, /* destX, Y */
src_surface,
0, 0, /* srcX, Y */
width, height); width, height);
pipe_surface_reference(&src_surface, NULL);
pipe_surface_reference(&dst_surface, NULL);
} }
} }