Conflicts: src/gallium/auxiliary/Makefile src/gallium/auxiliary/util/u_blit.c src/gallium/auxiliary/util/u_blit.h src/gallium/auxiliary/util/u_gen_mipmap.c src/gallium/auxiliary/util/u_gen_mipmap.h src/mesa/state_tracker/st_cb_texture.c src/mesa/state_tracker/st_gen_mipmap.cgallium-resources
@@ -6,7 +6,7 @@ CONFIG_NAME = linux-cell | |||
# Omiting other gallium drivers: | |||
GALLIUM_DRIVERS_DIRS = cell softpipe trace | |||
GALLIUM_DRIVERS_DIRS = cell softpipe trace identity | |||
# Compiler and flags |
@@ -393,6 +393,8 @@ | |||
#define glEdgeFlagPointerListIBM MANGLE(EdgeFlagPointerListIBM) | |||
#define glEdgeFlagPointer MANGLE(EdgeFlagPointer) | |||
#define glEdgeFlagv MANGLE(EdgeFlagv) | |||
#define glEGLImageTargetRenderbufferStorageOES MANGLE(EGLImageTargetRenderbufferStorageOES) | |||
#define glEGLImageTargetTexture2DOES MANGLE(EGLImageTargetTexture2DOES) | |||
#define glElementPointerAPPLE MANGLE(ElementPointerAPPLE) | |||
#define glElementPointerATI MANGLE(ElementPointerATI) | |||
#define glEnableClientStateIndexedEXT MANGLE(EnableClientStateIndexedEXT) |
@@ -131,6 +131,7 @@ C_SOURCES = \ | |||
util/u_resource.c \ | |||
util/u_upload_mgr.c \ | |||
target-helpers/wrap_screen.c | |||
# Disabling until pipe-video branch gets merged in | |||
#vl/vl_bitstream_parser.c \ | |||
#vl/vl_mpeg12_mc_renderer.c \ |
@@ -555,21 +555,23 @@ void util_blit_flush( struct blit_state *ctx ) | |||
*/ | |||
void | |||
util_blit_pixels_tex(struct blit_state *ctx, | |||
struct pipe_resource *tex, | |||
int srcX0, int srcY0, | |||
int srcX1, int srcY1, | |||
struct pipe_surface *dst, | |||
int dstX0, int dstY0, | |||
int dstX1, int dstY1, | |||
float z, uint filter) | |||
struct pipe_sampler_view *src_sampler_view, | |||
int srcX0, int srcY0, | |||
int srcX1, int srcY1, | |||
struct pipe_surface *dst, | |||
int dstX0, int dstY0, | |||
int dstX1, int dstY1, | |||
float z, uint filter) | |||
{ | |||
struct pipe_framebuffer_state fb; | |||
float s0, t0, s1, t1; | |||
unsigned offset; | |||
struct pipe_texture *tex = src_sampler_view->texture; | |||
assert(filter == PIPE_TEX_MIPFILTER_NEAREST || | |||
filter == PIPE_TEX_MIPFILTER_LINEAR); | |||
assert(tex); | |||
assert(tex->width0 != 0); | |||
assert(tex->height0 != 0); | |||
@@ -588,7 +590,7 @@ util_blit_pixels_tex(struct blit_state *ctx, | |||
cso_save_depth_stencil_alpha(ctx->cso); | |||
cso_save_rasterizer(ctx->cso); | |||
cso_save_samplers(ctx->cso); | |||
cso_save_sampler_textures(ctx->cso); | |||
cso_save_fragment_sampler_views(ctx->cso); | |||
cso_save_framebuffer(ctx->cso); | |||
cso_save_fragment_shader(ctx->cso); | |||
cso_save_vertex_shader(ctx->cso); | |||
@@ -620,7 +622,7 @@ util_blit_pixels_tex(struct blit_state *ctx, | |||
cso_set_viewport(ctx->cso, &ctx->viewport); | |||
/* texture */ | |||
cso_set_sampler_textures(ctx->cso, 1, &tex); | |||
cso_set_fragment_sampler_views(ctx->cso, 1, &src_sampler_view); | |||
/* shaders */ | |||
cso_set_fragment_shader_handle(ctx->cso, ctx->fs[TGSI_WRITEMASK_XYZW]); | |||
@@ -654,7 +656,7 @@ util_blit_pixels_tex(struct blit_state *ctx, | |||
cso_restore_depth_stencil_alpha(ctx->cso); | |||
cso_restore_rasterizer(ctx->cso); | |||
cso_restore_samplers(ctx->cso); | |||
cso_restore_sampler_textures(ctx->cso); | |||
cso_restore_fragment_sampler_views(ctx->cso); | |||
cso_restore_framebuffer(ctx->cso); | |||
cso_restore_fragment_shader(ctx->cso); | |||
cso_restore_vertex_shader(ctx->cso); |
@@ -75,7 +75,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, | |||
extern void | |||
util_blit_pixels_tex(struct blit_state *ctx, | |||
struct pipe_resource *tex, | |||
struct pipe_sampler_view *src_sampler_view, | |||
int srcX0, int srcY0, | |||
int srcX1, int srcY1, | |||
struct pipe_surface *dst, |
@@ -1460,7 +1460,7 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) | |||
* Generate mipmap images. It's assumed all needed texture memory is | |||
* already allocated. | |||
* | |||
* \param pt the texture to generate mipmap levels for | |||
* \param psv the sampler view to the texture to generate mipmap levels for | |||
* \param face which cube face to generate mipmaps for (0 for non-cube maps) | |||
* \param baseLevel the first mipmap level to use as a src | |||
* \param lastLevel the last mipmap level to generate | |||
@@ -1469,12 +1469,13 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) | |||
*/ | |||
void | |||
util_gen_mipmap(struct gen_mipmap_state *ctx, | |||
struct pipe_resource *pt, | |||
struct pipe_sampler_view *psv, | |||
uint face, uint baseLevel, uint lastLevel, uint filter) | |||
{ | |||
struct pipe_context *pipe = ctx->pipe; | |||
struct pipe_screen *screen = pipe->screen; | |||
struct pipe_framebuffer_state fb; | |||
struct pipe_texture *pt = psv->texture; | |||
void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d; | |||
uint dstLevel; | |||
uint zslice = 0; | |||
@@ -1492,7 +1493,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, | |||
filter == PIPE_TEX_FILTER_NEAREST); | |||
/* check if we can render in the texture's format */ | |||
if (!screen->is_format_supported(screen, pt->format, PIPE_TEXTURE_2D, | |||
if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D, | |||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { | |||
fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel); | |||
return; | |||
@@ -1503,7 +1504,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, | |||
cso_save_depth_stencil_alpha(ctx->cso); | |||
cso_save_rasterizer(ctx->cso); | |||
cso_save_samplers(ctx->cso); | |||
cso_save_sampler_textures(ctx->cso); | |||
cso_save_fragment_sampler_views(ctx->cso); | |||
cso_save_framebuffer(ctx->cso); | |||
cso_save_fragment_shader(ctx->cso); | |||
cso_save_vertex_shader(ctx->cso); | |||
@@ -1572,7 +1573,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, | |||
cso_single_sampler(ctx->cso, 0, &ctx->sampler); | |||
cso_single_sampler_done(ctx->cso); | |||
cso_set_sampler_textures(ctx->cso, 1, &pt); | |||
cso_set_fragment_sampler_views(ctx->cso, 1, &psv); | |||
/* quad coords in clip coords */ | |||
offset = set_vertex_data(ctx, | |||
@@ -1597,7 +1598,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, | |||
cso_restore_depth_stencil_alpha(ctx->cso); | |||
cso_restore_rasterizer(ctx->cso); | |||
cso_restore_samplers(ctx->cso); | |||
cso_restore_sampler_textures(ctx->cso); | |||
cso_restore_fragment_sampler_views(ctx->cso); | |||
cso_restore_framebuffer(ctx->cso); | |||
cso_restore_fragment_shader(ctx->cso); | |||
cso_restore_vertex_shader(ctx->cso); |
@@ -59,7 +59,7 @@ util_gen_mipmap_flush( struct gen_mipmap_state *ctx ); | |||
extern void | |||
util_gen_mipmap(struct gen_mipmap_state *ctx, | |||
struct pipe_resource *pt, | |||
struct pipe_sampler_view *psv, | |||
uint face, uint baseLevel, uint lastLevel, uint filter); | |||
@@ -41,23 +41,6 @@ buffers, surfaces) are bound to the driver. | |||
* ``set_framebuffer_state`` | |||
* ``set_fragment_sampler_views`` binds an array of sampler views to | |||
fragment shader stage. Every binding point acquires a reference | |||
to a respective sampler view and releases a reference to the previous | |||
sampler view. | |||
* ``set_vertex_sampler_views`` binds an array of sampler views to vertex | |||
shader stage. Every binding point acquires a reference to a respective | |||
sampler view and releases a reference to the previous sampler view. | |||
* ``create_sampler_view`` creates a new sampler view. texture is associated | |||
with the sampler view which results in sampler view holding a reference | |||
to the texture. Format specified in template must be compatible | |||
with texture format. | |||
* ``sampler_view_destroy`` destroys a sampler view and releases its reference | |||
to associated texture. | |||
* ``set_vertex_buffers`` | |||
@@ -79,6 +62,41 @@ objects. They all follow simple, one-method binding calls, e.g. | |||
* ``set_viewport_state`` | |||
Sampler Views | |||
^^^^^^^^^^^^^ | |||
These are the means to bind textures to shader stages. To create one, specify | |||
its format, swizzle and LOD range in sampler view template. | |||
If texture format is different than template format, it is said the texture | |||
is being cast to another format. Casting can be done only between compatible | |||
formats, that is formats that have matching component order and sizes. | |||
Swizzle fields specify they way in which fetched texel components are placed | |||
in the result register. For example, swizzle_r specifies what is going to be | |||
placed in destination register x (AKA r). | |||
first_level and last_level fields of sampler view template specify the LOD | |||
range the texture is going to be constrained to. | |||
* ``set_fragment_sampler_views`` binds an array of sampler views to | |||
fragment shader stage. Every binding point acquires a reference | |||
to a respective sampler view and releases a reference to the previous | |||
sampler view. | |||
* ``set_vertex_sampler_views`` binds an array of sampler views to vertex | |||
shader stage. Every binding point acquires a reference to a respective | |||
sampler view and releases a reference to the previous sampler view. | |||
* ``create_sampler_view`` creates a new sampler view. texture is associated | |||
with the sampler view which results in sampler view holding a reference | |||
to the texture. Format specified in template must be compatible | |||
with texture format. | |||
* ``sampler_view_destroy`` destroys a sampler view and releases its reference | |||
to associated texture. | |||
Clearing | |||
^^^^^^^^ | |||
@@ -97,7 +97,7 @@ struct cell_velems_state | |||
{ | |||
unsigned count; | |||
struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; | |||
} | |||
}; | |||
/** | |||
* Per-context state, subclass of pipe_context. |
@@ -28,6 +28,7 @@ | |||
#include "util/u_inlines.h" | |||
#include "util/u_tile.h" | |||
#include "util/u_format.h" | |||
static INLINE int | |||
nv50_format(enum pipe_format format) | |||
@@ -37,10 +38,35 @@ nv50_format(enum pipe_format format) | |||
return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM; | |||
case PIPE_FORMAT_B8G8R8X8_UNORM: | |||
return NV50_2D_DST_FORMAT_X8R8G8B8_UNORM; | |||
case PIPE_FORMAT_B8G8R8A8_SRGB: | |||
return NV50_2D_DST_FORMAT_A8R8G8B8_SRGB; | |||
case PIPE_FORMAT_B8G8R8X8_SRGB: | |||
return NV50_2D_DST_FORMAT_X8R8G8B8_SRGB; | |||
case PIPE_FORMAT_B5G6R5_UNORM: | |||
return NV50_2D_DST_FORMAT_R5G6B5_UNORM; | |||
case PIPE_FORMAT_B5G5R5A1_UNORM: | |||
return NV50_2D_DST_FORMAT_A1R5G5B5_UNORM; | |||
case PIPE_FORMAT_A8_UNORM: | |||
case PIPE_FORMAT_I8_UNORM: | |||
case PIPE_FORMAT_L8_UNORM: | |||
return NV50_2D_DST_FORMAT_R8_UNORM; | |||
case PIPE_FORMAT_R32G32B32A32_FLOAT: | |||
return NV50_2D_DST_FORMAT_R32G32B32A32_FLOAT; | |||
case PIPE_FORMAT_R32G32B32_FLOAT: | |||
return NV50_2D_DST_FORMAT_R32G32B32X32_FLOAT; | |||
case PIPE_FORMAT_Z32_FLOAT: | |||
return NV50_2D_DST_FORMAT_R32_FLOAT; | |||
/* only because we require src format == dst format: */ | |||
case PIPE_FORMAT_R16G16_SNORM: | |||
case PIPE_FORMAT_R16G16_UNORM: | |||
case PIPE_FORMAT_S8Z24_UNORM: | |||
case PIPE_FORMAT_Z24S8_UNORM: | |||
return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM; | |||
case PIPE_FORMAT_L8A8_UNORM: | |||
case PIPE_FORMAT_B4G4R4A4_UNORM: | |||
return NV50_2D_DST_FORMAT_R16_UNORM; | |||
default: | |||
return -1; | |||
} | |||
@@ -57,8 +83,11 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) | |||
int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD); | |||
format = nv50_format(ps->format); | |||
if (format < 0) | |||
if (format < 0) { | |||
NOUVEAU_ERR("invalid/unsupported surface format: %s\n", | |||
util_format_name(ps->format)); | |||
return 1; | |||
} | |||
if (!bo->tile_flags) { | |||
MARK_RING (chan, 9, 2); /* flush on lack of space or relocs */ |
@@ -47,6 +47,7 @@ extern "C" { | |||
struct winsys_handle; | |||
struct pipe_screen; | |||
struct pipe_context; | |||
struct pipe_texture; | |||
/** |
@@ -4,6 +4,7 @@ | |||
#include "xorg_exa_tgsi.h" | |||
#include "cso_cache/cso_context.h" | |||
#include "util/u_sampler.h" | |||
/*XXX also in Xrender.h but the including it here breaks compilition */ | |||
@@ -356,6 +357,9 @@ bind_samplers(struct exa_context *exa, int op, | |||
{ | |||
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; | |||
struct pipe_sampler_state src_sampler, mask_sampler; | |||
struct pipe_sampler_view view_templ; | |||
struct pipe_sampler_view *src_view; | |||
struct pipe_context *pipe = exa->pipe; | |||
exa->num_bound_samplers = 0; | |||
@@ -366,7 +370,7 @@ bind_samplers(struct exa_context *exa, int op, | |||
if (exa->has_solid_color) { | |||
debug_assert(!"solid color with textures"); | |||
samplers[0] = NULL; | |||
exa->bound_textures[0] = NULL; | |||
pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); | |||
} else { | |||
unsigned src_wrap = render_repeat_to_gallium( | |||
pSrcPicture->repeatType); | |||
@@ -381,8 +385,13 @@ bind_samplers(struct exa_context *exa, int op, | |||
src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; | |||
src_sampler.normalized_coords = 1; | |||
samplers[0] = &src_sampler; | |||
exa->bound_textures[0] = pSrc->tex; | |||
exa->num_bound_samplers = 1; | |||
u_sampler_view_default_template(&view_templ, | |||
pSrc->tex, | |||
pSrc->tex->format); | |||
src_view = pipe->create_sampler_view(pipe, pSrc->tex, &view_templ); | |||
pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); | |||
exa->bound_sampler_views[0] = src_view; | |||
} | |||
} | |||
@@ -400,14 +409,19 @@ bind_samplers(struct exa_context *exa, int op, | |||
src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; | |||
mask_sampler.normalized_coords = 1; | |||
samplers[1] = &mask_sampler; | |||
exa->bound_textures[1] = pMask->tex; | |||
exa->num_bound_samplers = 2; | |||
u_sampler_view_default_template(&view_templ, | |||
pMask->tex, | |||
pMask->tex->format); | |||
src_view = pipe->create_sampler_view(pipe, pMask->tex, &view_templ); | |||
pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL); | |||
exa->bound_sampler_views[1] = src_view; | |||
} | |||
cso_set_samplers(exa->renderer->cso, exa->num_bound_samplers, | |||
(const struct pipe_sampler_state **)samplers); | |||
cso_set_sampler_textures(exa->renderer->cso, exa->num_bound_samplers, | |||
exa->bound_textures); | |||
cso_set_fragment_sampler_views(exa->renderer->cso, exa->num_bound_samplers, | |||
exa->bound_sampler_views); | |||
} | |||
@@ -476,7 +490,6 @@ boolean xorg_composite_bind_state(struct exa_context *exa, | |||
renderer_begin_solid(exa->renderer); | |||
} else { | |||
renderer_begin_textures(exa->renderer, | |||
exa->bound_textures, | |||
exa->num_bound_samplers); | |||
} | |||
@@ -506,7 +519,7 @@ void xorg_composite(struct exa_context *exa, | |||
renderer_texture(exa->renderer, | |||
pos, width, height, | |||
exa->bound_textures, | |||
exa->bound_sampler_views, | |||
exa->num_bound_samplers, | |||
src_matrix, mask_matrix); | |||
} | |||
@@ -538,7 +551,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa, | |||
pixmap->width, pixmap->height); | |||
bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL); | |||
cso_set_samplers(exa->renderer->cso, 0, NULL); | |||
cso_set_sampler_textures(exa->renderer->cso, 0, NULL); | |||
cso_set_fragment_sampler_views(exa->renderer->cso, 0, NULL); | |||
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); | |||
cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs); |
@@ -980,6 +980,9 @@ xorg_exa_close(ScrnInfoPtr pScrn) | |||
modesettingPtr ms = modesettingPTR(pScrn); | |||
struct exa_context *exa = ms->exa; | |||
pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); | |||
pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL); | |||
renderer_destroy(exa->renderer); | |||
if (exa->pipe) |
@@ -18,7 +18,7 @@ struct exa_context | |||
struct pipe_screen *scrn; | |||
struct xorg_renderer *renderer; | |||
struct pipe_texture *bound_textures[MAX_EXA_SAMPLERS]; | |||
struct pipe_sampler_view *bound_sampler_views[MAX_EXA_SAMPLERS]; | |||
int num_bound_samplers; | |||
float solid_color[4]; |
@@ -8,6 +8,7 @@ | |||
#include "util/u_math.h" | |||
#include "util/u_memory.h" | |||
#include "util/u_rect.h" | |||
#include "util/u_sampler.h" | |||
#include "util/u_inlines.h" | |||
@@ -482,8 +483,17 @@ void renderer_copy_prepare(struct xorg_renderer *r, | |||
dst_surface->width, | |||
dst_surface->height); | |||
/* texture */ | |||
cso_set_sampler_textures(r->cso, 1, &src_texture); | |||
/* texture/sampler view */ | |||
{ | |||
struct pipe_sampler_view templ; | |||
struct pipe_sampler_view *src_view; | |||
u_sampler_view_default_template(&templ, | |||
src_texture, | |||
src_texture->format); | |||
src_view = pipe->create_sampler_view(pipe, src_texture, &templ); | |||
cso_set_fragment_sampler_views(r->cso, 1, &src_view); | |||
pipe_sampler_view_reference(&src_view, NULL); | |||
} | |||
/* shaders */ | |||
shader = xorg_shaders_get(r->shaders, | |||
@@ -655,7 +665,6 @@ void renderer_draw_flush(struct xorg_renderer *r) | |||
} | |||
void renderer_begin_textures(struct xorg_renderer *r, | |||
struct pipe_texture **textures, | |||
int num_textures) | |||
{ | |||
r->attrs_per_vertex = 1 + num_textures; | |||
@@ -665,7 +674,7 @@ void renderer_begin_textures(struct xorg_renderer *r, | |||
void renderer_texture(struct xorg_renderer *r, | |||
int *pos, | |||
int width, int height, | |||
struct pipe_texture **textures, | |||
struct pipe_sampler_view **sampler_view, | |||
int num_textures, | |||
float *src_matrix, | |||
float *mask_matrix) | |||
@@ -693,7 +702,7 @@ void renderer_texture(struct xorg_renderer *r, | |||
pos[0], pos[1], /* src */ | |||
pos[4], pos[5], /* dst */ | |||
width, height, | |||
textures[0], src_matrix); | |||
sampler_view[0]->texture, src_matrix); | |||
break; | |||
case 3: | |||
renderer_draw_conditional(r, 4 * 12); | |||
@@ -702,7 +711,7 @@ void renderer_texture(struct xorg_renderer *r, | |||
pos[2], pos[3], /* mask */ | |||
pos[4], pos[5], /* dst */ | |||
width, height, | |||
textures[0], textures[1], | |||
sampler_view[0]->texture, sampler_view[1]->texture, | |||
src_matrix, mask_matrix); | |||
break; | |||
default: |
@@ -65,12 +65,12 @@ void renderer_solid(struct xorg_renderer *r, | |||
float *color); | |||
void renderer_begin_textures(struct xorg_renderer *r, | |||
struct pipe_texture **textures, | |||
int num_textures); | |||
void renderer_texture(struct xorg_renderer *r, | |||
int *pos, | |||
int width, int height, | |||
struct pipe_texture **textures, | |||
struct pipe_sampler_view **textures, | |||
int num_textures, | |||
float *src_matrix, | |||
float *mask_matrix); |
@@ -9,6 +9,7 @@ | |||
#include "xorg_exa_tgsi.h" | |||
#include "cso_cache/cso_context.h" | |||
#include "util/u_sampler.h" | |||
#include "pipe/p_screen.h" | |||
@@ -91,6 +92,7 @@ struct xorg_xv_port_priv { | |||
/* juggle two sets of seperate Y, U and V | |||
* textures */ | |||
struct pipe_texture *yuv[2][3]; | |||
struct pipe_sampler_view *yuv_views[2][3]; | |||
}; | |||
@@ -180,32 +182,60 @@ static int | |||
check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height) | |||
{ | |||
struct pipe_texture **dst = priv->yuv[priv->current_set]; | |||
struct pipe_sampler_view **dst_view = priv->yuv_views[priv->current_set]; | |||
struct pipe_sampler_view view_templ; | |||
struct pipe_context *pipe = priv->r->pipe; | |||
if (!dst[0] || | |||
dst[0]->width0 != width || | |||
dst[0]->height0 != height) { | |||
pipe_texture_reference(&dst[0], NULL); | |||
pipe_sampler_view_reference(&dst_view[0], NULL); | |||
} | |||
if (!dst[1] || | |||
dst[1]->width0 != width || | |||
dst[1]->height0 != height) { | |||
pipe_texture_reference(&dst[1], NULL); | |||
pipe_sampler_view_reference(&dst_view[1], NULL); | |||
} | |||
if (!dst[2] || | |||
dst[2]->width0 != width || | |||
dst[2]->height0 != height) { | |||
pipe_texture_reference(&dst[2], NULL); | |||
pipe_sampler_view_reference(&dst_view[2], NULL); | |||
} | |||
if (!dst[0]) | |||
if (!dst[0]) { | |||
dst[0] = create_component_texture(priv->r->pipe, width, height); | |||
if (dst[0]) { | |||
u_sampler_view_default_template(&view_templ, | |||
dst[0], | |||
dst[0]->format); | |||
dst_view[0] = pipe->create_sampler_view(pipe, dst[0], &view_templ); | |||
} | |||
} | |||
if (!dst[1]) | |||
if (!dst[1]) { | |||
dst[1] = create_component_texture(priv->r->pipe, width, height); | |||
if (dst[1]) { | |||
u_sampler_view_default_template(&view_templ, | |||
dst[1], | |||
dst[1]->format); | |||
dst_view[1] = pipe->create_sampler_view(pipe, dst[1], &view_templ); | |||
} | |||
} | |||
if (!dst[2]) | |||
if (!dst[2]) { | |||
dst[2] = create_component_texture(priv->r->pipe, width, height); | |||
if (dst[2]) { | |||
u_sampler_view_default_template(&view_templ, | |||
dst[2], | |||
dst[2]->format); | |||
dst_view[2] = pipe->create_sampler_view(pipe, dst[2], &view_templ); | |||
} | |||
} | |||
if (!dst[0] || !dst[1] || !dst[2]) | |||
if (!dst[0] || !dst[1] || !dst[2] || !dst_view[0] || !dst_view[1] || !dst_view[2] ) | |||
return BadAlloc; | |||
return Success; | |||
@@ -450,6 +480,7 @@ bind_samplers(struct xorg_xv_port_priv *port) | |||
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; | |||
struct pipe_sampler_state sampler; | |||
struct pipe_texture **dst = port->yuv[port->current_set]; | |||
struct pipe_sampler_view **dst_views = port->yuv_views[port->current_set]; | |||
memset(&sampler, 0, sizeof(struct pipe_sampler_state)); | |||
@@ -469,8 +500,7 @@ bind_samplers(struct xorg_xv_port_priv *port) | |||
cso_set_samplers(port->r->cso, 3, | |||
(const struct pipe_sampler_state **)samplers); | |||
cso_set_sampler_textures(port->r->cso, 3, | |||
dst); | |||
cso_set_fragment_sampler_views(port->r->cso, 3, dst_views); | |||
} | |||
static int |
@@ -63,6 +63,8 @@ PUBLIC const struct st_module st_module_OpenGL = { | |||
static struct pipe_screen * | |||
swrast_xlib_create_screen( Display *display ) | |||
{ | |||
const char *default_driver; | |||
const char *driver; | |||
struct sw_winsys *winsys; | |||
struct pipe_screen *screen = NULL; | |||
@@ -73,17 +75,29 @@ swrast_xlib_create_screen( Display *display ) | |||
if (winsys == NULL) | |||
return NULL; | |||
#if defined(GALLIUM_CELL) | |||
default_driver = "cell"; | |||
#elif defined(GALLIUM_LLVMPIPE) | |||
default_driver = "llvmpipe"; | |||
#elif defined(GALLIUM_SOFTPIPE) | |||
default_driver = "softpipe"; | |||
#else | |||
default_driver = ""; | |||
#endif | |||
driver = debug_get_option("GALLIUM_DRIVER", default_driver); | |||
/* Create a software rasterizer on top of that winsys: | |||
*/ | |||
#if defined(GALLIUM_CELL) | |||
if (screen == NULL && | |||
!debug_get_bool_option("GALLIUM_NO_CELL", FALSE)) | |||
strcmp(driver, "cell") == 0) | |||
screen = cell_create_screen( winsys ); | |||
#endif | |||
#if defined(GALLIUM_LLVMPIPE) | |||
if (screen == NULL && | |||
!debug_get_bool_option("GALLIUM_NO_LLVM", FALSE)) | |||
strcmp(driver, "llvmpipe") == 0) | |||
screen = llvmpipe_create_screen( winsys ); | |||
#endif | |||
@@ -429,13 +429,15 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) | |||
if (state & META_SHADER) { | |||
if (ctx->Extensions.ARB_vertex_program) { | |||
save->VertexProgramEnabled = ctx->VertexProgram.Enabled; | |||
save->VertexProgram = ctx->VertexProgram.Current; | |||
_mesa_reference_vertprog(ctx, &save->VertexProgram, | |||
ctx->VertexProgram.Current); | |||
_mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); | |||
} | |||
if (ctx->Extensions.ARB_fragment_program) { | |||
save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; | |||
save->FragmentProgram = ctx->FragmentProgram.Current; | |||
_mesa_reference_fragprog(ctx, &save->FragmentProgram, | |||
ctx->FragmentProgram.Current); | |||
_mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE); | |||
} | |||
@@ -663,6 +665,7 @@ _mesa_meta_end(GLcontext *ctx) | |||
save->VertexProgramEnabled); | |||
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, | |||
save->VertexProgram); | |||
_mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); | |||
} | |||
if (ctx->Extensions.ARB_fragment_program) { | |||
@@ -670,6 +673,7 @@ _mesa_meta_end(GLcontext *ctx) | |||
save->FragmentProgramEnabled); | |||
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, | |||
save->FragmentProgram); | |||
_mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL); | |||
} | |||
if (ctx->Extensions.ARB_shader_objects) { | |||
@@ -720,6 +724,7 @@ _mesa_meta_end(GLcontext *ctx) | |||
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { | |||
_mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt], | |||
save->CurrentTexture[tgt]); | |||
_mesa_reference_texobj(&save->CurrentTexture[tgt], NULL); | |||
} | |||
/* Re-enable textures, texgen */ | |||
@@ -2062,8 +2067,10 @@ _mesa_meta_Bitmap(GLcontext *ctx, | |||
} | |||
bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1); | |||
if (!bitmap1) | |||
if (!bitmap1) { | |||
_mesa_meta_end(ctx); | |||
return; | |||
} | |||
bitmap8 = (GLubyte *) calloc(1, width * height); | |||
if (bitmap8) { |
@@ -384,8 +384,9 @@ static void emit_sop( struct brw_vs_compile *c, | |||
{ | |||
struct brw_compile *p = &c->func; | |||
brw_CMP(p, brw_null_reg(), cond, arg1, arg0); | |||
brw_SEL(p, dst, brw_null_reg(), brw_imm_f(1.0f)); | |||
brw_MOV(p, dst, brw_imm_f(0.0f)); | |||
brw_CMP(p, brw_null_reg(), cond, arg0, arg1); | |||
brw_MOV(p, dst, brw_imm_f(1.0f)); | |||
brw_set_predicate_control_flag_value(p, 0xff); | |||
} | |||
@@ -545,8 +545,11 @@ void emit_sop(struct brw_compile *p, | |||
for (i = 0; i < 4; i++) { | |||
if (mask & (1<<i)) { | |||
brw_push_insn_state(p); | |||
brw_CMP(p, brw_null_reg(), cond, arg1[i], arg0[i]); | |||
brw_SEL(p, dst[i], brw_null_reg(), brw_imm_f(1.0)); | |||
brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]); | |||
brw_set_predicate_control(p, BRW_PREDICATE_NONE); | |||
brw_MOV(p, dst[i], brw_imm_f(0)); | |||
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL); | |||
brw_MOV(p, dst[i], brw_imm_f(1.0)); | |||
brw_pop_insn_state(p); | |||
} | |||
} |
@@ -525,7 +525,8 @@ intel_miptree_image_copy(struct intel_context *intel, | |||
intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); | |||
success = intel_region_copy(intel, | |||
dst->region, 0, dst_x, dst_y, | |||
src->region, 0, src_x, src_y, width, height, | |||
src->region, 0, src_x, src_y, | |||
width, height, GL_FALSE, | |||
GL_COPY); | |||
if (!success) { | |||
GLubyte *src_ptr, *dst_ptr; |
@@ -116,6 +116,7 @@ do_blit_copypixels(GLcontext * ctx, | |||
GLint orig_dsty; | |||
GLint orig_srcx; | |||
GLint orig_srcy; | |||
GLboolean flip = GL_FALSE; | |||
if (type == GL_DEPTH || type == GL_STENCIL) { | |||
if (INTEL_DEBUG & DEBUG_FALLBACKS) | |||
@@ -140,8 +141,6 @@ do_blit_copypixels(GLcontext * ctx, | |||
intel_prepare_render(intel); | |||
/* XXX: We fail to handle different inversion between read and draw framebuffer. */ | |||
/* Clip to destination buffer. */ | |||
orig_dstx = dstx; | |||
orig_dsty = dsty; | |||
@@ -164,23 +163,23 @@ do_blit_copypixels(GLcontext * ctx, | |||
dstx += srcx - orig_srcx; | |||
dsty += srcy - orig_srcy; | |||
/* Convert from GL to hardware coordinates: */ | |||
/* Flip dest Y if it's a window system framebuffer. */ | |||
if (fb->Name == 0) { | |||
/* copypixels to a system framebuffer */ | |||
/* copypixels to a window system framebuffer */ | |||
dsty = fb->Height - dsty - height; | |||
} else { | |||
/* copypixels to a user framebuffer object */ | |||
dsty = dsty; | |||
flip = !flip; | |||
} | |||
/* Flip source Y if it's a system framebuffer. */ | |||
if (read_fb->Name == 0) | |||
srcy = fb->Height - srcy - height; | |||
/* Flip source Y if it's a window system framebuffer. */ | |||
if (read_fb->Name == 0) { | |||
srcy = read_fb->Height - srcy - height; | |||
flip = !flip; | |||
} | |||
if (!intel_region_copy(intel, | |||
dst, 0, dstx, dsty, | |||
src, 0, srcx, srcy, | |||
width, height, | |||
width, height, flip, | |||
ctx->Color.ColorLogicOpEnabled ? | |||
ctx->Color.LogicOp : GL_COPY)) { | |||
DBG("%s: blit failure\n", __FUNCTION__); |
@@ -380,8 +380,11 @@ intel_region_copy(struct intel_context *intel, | |||
struct intel_region *src, | |||
GLuint src_offset, | |||
GLuint srcx, GLuint srcy, GLuint width, GLuint height, | |||
GLboolean flip, | |||
GLenum logicop) | |||
{ | |||
uint32_t src_pitch = src->pitch; | |||
_DBG("%s\n", __FUNCTION__); | |||
if (intel == NULL) | |||
@@ -397,9 +400,12 @@ intel_region_copy(struct intel_context *intel, | |||
assert(src->cpp == dst->cpp); | |||
if (flip) | |||
src_pitch = -src_pitch; | |||
return intelEmitCopyBlit(intel, | |||
dst->cpp, | |||
src->pitch, src->buffer, src_offset, src->tiling, | |||
src_pitch, src->buffer, src_offset, src->tiling, | |||
dst->pitch, dst->buffer, dst_offset, dst->tiling, | |||
srcx, srcy, dstx, dsty, width, height, | |||
logicop); |
@@ -122,6 +122,7 @@ intel_region_copy(struct intel_context *intel, | |||
struct intel_region *src, | |||
GLuint src_offset, | |||
GLuint srcx, GLuint srcy, GLuint width, GLuint height, | |||
GLboolean flip, | |||
GLenum logicop); | |||
/* Helpers for zerocopy uploads, particularly texture image uploads: |
@@ -312,18 +312,13 @@ intelCreateBuffer(__DRIscreen * driScrnPriv, | |||
} | |||
if (mesaVis->depthBits == 24) { | |||
if (mesaVis->stencilBits == 8) { | |||
/* combined depth/stencil buffer */ | |||
struct intel_renderbuffer *depthStencilRb | |||
= intel_create_renderbuffer(MESA_FORMAT_S8_Z24); | |||
/* note: bind RB to two attachment points */ | |||
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base); | |||
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base); | |||
} else { | |||
struct intel_renderbuffer *depthRb | |||
= intel_create_renderbuffer(MESA_FORMAT_X8_Z24); | |||
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); | |||
} | |||
assert(mesaVis->stencilBits == 8); | |||
/* combined depth/stencil buffer */ | |||
struct intel_renderbuffer *depthStencilRb | |||
= intel_create_renderbuffer(MESA_FORMAT_S8_Z24); | |||
/* note: bind RB to two attachment points */ | |||
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base); | |||
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base); | |||
} | |||
else if (mesaVis->depthBits == 16) { | |||
/* just 16-bit depth buffer, no hw stencil */ |
@@ -48,11 +48,11 @@ intel_set_span_functions(struct intel_context *intel, | |||
#define LOCAL_VARS \ | |||
struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ | |||
const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ | |||
const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ | |||
const GLint yScale = rb->Name ? 1 : -1; \ | |||
const GLint yBias = rb->Name ? 0 : rb->Height - 1; \ | |||
int minx = 0, miny = 0; \ | |||
int maxx = ctx->DrawBuffer->Width; \ | |||
int maxy = ctx->DrawBuffer->Height; \ | |||
int maxx = rb->Width; \ | |||
int maxy = rb->Height; \ | |||
int pitch = irb->region->pitch * irb->region->cpp; \ | |||
void *buf = irb->region->buffer->virtual; \ | |||
GLuint p; \ | |||
@@ -108,11 +108,11 @@ intel_set_span_functions(struct intel_context *intel, | |||
#define LOCAL_DEPTH_VARS \ | |||
struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ | |||
const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ | |||
const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ | |||
const GLint yScale = rb->Name ? 1 : -1; \ | |||
const GLint yBias = rb->Name ? 0 : rb->Height - 1; \ | |||
int minx = 0, miny = 0; \ | |||
int maxx = ctx->DrawBuffer->Width; \ | |||
int maxy = ctx->DrawBuffer->Height; \ | |||
int maxx = rb->Width; \ | |||
int maxy = rb->Height; \ | |||
int pitch = irb->region->pitch * irb->region->cpp; \ | |||
void *buf = irb->region->buffer->virtual; \ | |||
(void)buf; (void)pitch; /* unused for non-gttmap. */ \ |
@@ -63,6 +63,7 @@ | |||
#include "util/u_blit.h" | |||
#include "util/u_format.h" | |||
#include "util/u_surface.h" | |||
#include "util/u_sampler.h" | |||
#include "util/u_math.h" | |||
@@ -380,6 +381,8 @@ compress_with_blit(GLcontext * ctx, | |||
gl_format mesa_format; | |||
struct pipe_resource templ; | |||
struct pipe_resource *src_tex; | |||
struct pipe_sampler_view view_templ; | |||
struct pipe_sampler_view *src_view; | |||
struct pipe_surface *dst_surface; | |||
struct pipe_transfer *tex_xfer; | |||
void *map; | |||
@@ -441,9 +444,16 @@ compress_with_blit(GLcontext * ctx, | |||
pipe_transfer_unmap(pipe, tex_xfer); | |||
pipe->transfer_destroy(pipe, tex_xfer); | |||
/* Create temporary sampler view */ | |||
u_sampler_view_default_template(&view_templ, | |||
src_tex, | |||
src_tex->format); | |||
src_view = pipe->create_sampler_view(pipe, src_tex, &view_templ); | |||
/* copy / compress image */ | |||
util_blit_pixels_tex(ctx->st->blit, | |||
src_tex, /* pipe_resource (src) */ | |||
src_view, /* sampler view (src) */ | |||
0, 0, /* src x0, y0 */ | |||
width, height, /* src x1, y1 */ | |||
dst_surface, /* pipe_surface (dst) */ | |||
@@ -455,6 +465,7 @@ compress_with_blit(GLcontext * ctx, | |||
pipe_surface_reference(&dst_surface, NULL); | |||
pipe_resource_reference(&src_tex, NULL); | |||
pipe_sampler_view_reference(&src_view, NULL); | |||
return GL_TRUE; | |||
} | |||
@@ -560,6 +571,7 @@ st_TexImage(GLcontext * ctx, | |||
DBG("release it\n"); | |||
pipe_resource_reference(&stObj->pt, NULL); | |||
assert(!stObj->pt); | |||
pipe_sampler_view_reference(&stObj->sampler_view, NULL); | |||
stObj->teximage_realloc = FALSE; | |||
} | |||
} | |||
@@ -817,6 +829,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, | |||
struct pipe_context *pipe = ctx->st->pipe; | |||
struct pipe_screen *screen = pipe->screen; | |||
struct st_texture_image *stImage = st_texture_image(texImage); | |||
struct st_texture_object *stObj = st_texture_object(texObj); | |||
struct pipe_sampler_view *src_view = st_get_stobj_sampler_view(stObj); | |||
const GLuint width = texImage->Width; | |||
const GLuint height = texImage->Height; | |||
struct pipe_surface *dst_surface; | |||
@@ -833,7 +847,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, | |||
/* blit/render/decompress */ | |||
util_blit_pixels_tex(ctx->st->blit, | |||
stImage->pt, /* pipe_resource (src) */ | |||
src_view, /* pipe_texture (src) */ | |||
0, 0, /* src x0, y0 */ | |||
width, height, /* src x1, y1 */ | |||
dst_surface, /* pipe_surface (dst) */ | |||
@@ -1457,7 +1471,6 @@ st_copy_texsubimage(GLcontext *ctx, | |||
&ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | |||
struct gl_texture_object *texObj = | |||
_mesa_select_tex_object(ctx, texUnit, target); | |||
struct st_texture_object *stObj = st_texture_object(texObj); | |||
struct gl_texture_image *texImage = | |||
_mesa_select_tex_image(ctx, texObj, target, level); | |||
struct st_texture_image *stImage = st_texture_image(texImage); | |||
@@ -1795,6 +1808,7 @@ st_finalize_texture(GLcontext *ctx, | |||
firstImage->pt != stObj->pt && | |||
firstImage->pt->last_level >= stObj->lastLevel) { | |||
pipe_resource_reference(&stObj->pt, firstImage->pt); | |||
pipe_sampler_view_reference(&stObj->sampler_view, NULL); | |||
} | |||
/* bytes per pixel block (blocks are usually 1x1) */ | |||
@@ -1814,6 +1828,7 @@ st_finalize_texture(GLcontext *ctx, | |||
stObj->pt->depth0 != firstImage->base.Depth2) | |||
{ | |||
pipe_resource_reference(&stObj->pt, NULL); | |||
pipe_sampler_view_reference(&stObj->sampler_view, NULL); | |||
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; | |||
} | |||
} |
@@ -79,22 +79,23 @@ st_destroy_generate_mipmap(struct st_context *st) | |||
static boolean | |||
st_render_mipmap(struct st_context *st, | |||
GLenum target, | |||
struct pipe_resource *pt, | |||
struct st_texture_object *stObj, | |||
uint baseLevel, uint lastLevel) | |||
{ | |||
struct pipe_context *pipe = st->pipe; | |||
struct pipe_screen *screen = pipe->screen; | |||
struct pipe_sampler_view *psv = st_get_stobj_sampler_view(stObj); | |||
const uint face = _mesa_tex_target_to_face(target); | |||
assert(target != GL_TEXTURE_3D); /* not done yet */ | |||
/* check if we can render in the texture's format */ | |||
if (!screen->is_format_supported(screen, pt->format, pt->target, | |||
if (!screen->is_format_supported(screen, psv->format, psv->texture->target, | |||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { | |||
return FALSE; | |||
} | |||
util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel, | |||
util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel, | |||
PIPE_TEX_FILTER_LINEAR); | |||
return TRUE; | |||
@@ -211,6 +212,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, | |||
struct gl_texture_object *texObj) | |||
{ | |||
struct st_context *st = ctx->st; | |||
struct st_texture_object *stObj = st_texture_object(texObj); | |||
struct pipe_resource *pt = st_get_texobj_texture(texObj); | |||
const uint baseLevel = texObj->BaseLevel; | |||
uint lastLevel; | |||
@@ -229,7 +231,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, | |||
/* The current gallium texture doesn't have space for all the | |||
* mipmap levels we need to generate. So allocate a new texture. | |||
*/ | |||
struct st_texture_object *stObj = st_texture_object(texObj); | |||
struct pipe_resource *oldTex = stObj->pt; | |||
GLboolean needFlush; | |||
@@ -255,6 +256,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, | |||
/* release the old tex (will likely be freed too) */ | |||
pipe_resource_reference(&oldTex, NULL); | |||
pipe_sampler_view_reference(&stObj->sampler_view, NULL); | |||
pt = stObj->pt; | |||
} | |||
@@ -264,7 +266,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, | |||
/* Recall that the Mesa BaseLevel image is stored in the gallium | |||
* texture's level[0] position. So pass baseLevel=0 here. | |||
*/ | |||
if (!st_render_mipmap(st, target, pt, 0, lastLevel)) { | |||
if (!st_render_mipmap(st, target, stObj, 0, lastLevel)) { | |||
fallback_generate_mipmap(ctx, target, texObj); | |||
} | |||