summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/Makefile4
-rw-r--r--src/gallium/auxiliary/SConscript4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c21
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c14
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h44
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c34
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c10
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.c6
-rw-r--r--src/gallium/auxiliary/util/u_blit.c33
-rw-r--r--src/gallium/auxiliary/util/u_blit.h2
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c29
-rw-r--r--src/gallium/auxiliary/util/u_box.h73
-rw-r--r--src/gallium/auxiliary/util/u_debug.c37
-rw-r--r--src/gallium/auxiliary/util/u_debug.h4
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.c106
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.h4
-rw-r--r--src/gallium/auxiliary/util/u_dump.h2
-rw-r--r--src/gallium/auxiliary/util/u_dump_state.c19
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c69
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.h2
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h292
-rw-r--r--src/gallium/auxiliary/util/u_rect.c102
-rw-r--r--src/gallium/auxiliary/util/u_resource.c97
-rw-r--r--src/gallium/auxiliary/util/u_sampler.c6
-rw-r--r--src/gallium/auxiliary/util/u_sampler.h4
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.c137
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.h23
-rw-r--r--src/gallium/auxiliary/util/u_surface.c23
-rw-r--r--src/gallium/auxiliary/util/u_surface.h6
-rw-r--r--src/gallium/auxiliary/util/u_tile.c32
-rw-r--r--src/gallium/auxiliary/util/u_tile.h18
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.c312
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.h41
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c110
-rw-r--r--src/gallium/auxiliary/util/u_transfer.h145
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.c75
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.h10
-rw-r--r--src/gallium/auxiliary/vl/vl_bitstream_parser.c167
-rw-r--r--src/gallium/auxiliary/vl/vl_bitstream_parser.h63
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c536
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h77
-rw-r--r--src/gallium/auxiliary/vl/vl_csc.c206
-rw-r--r--src/gallium/auxiliary/vl/vl_csc.h53
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c1672
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h121
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.c243
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.h88
57 files changed, 992 insertions, 4214 deletions
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 050c7043c3..c4d6b528b7 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -131,9 +131,9 @@ C_SOURCES = \
util/u_surface.c \
util/u_texture.c \
util/u_tile.c \
- util/u_timed_winsys.c \
+ util/u_transfer.c \
+ util/u_resource.c \
util/u_upload_mgr.c \
- util/u_simple_screen.c \
target-helpers/wrap_screen.c
# Disabling until pipe-video branch gets merged in
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index c23fbdf70a..bd8139f1de 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -172,6 +172,7 @@ source = [
'util/u_math.c',
'util/u_mm.c',
'util/u_rect.c',
+ 'util/u_resource.c',
'util/u_ringbuffer.c',
'util/u_sampler.c',
'util/u_simple_shaders.c',
@@ -179,9 +180,8 @@ source = [
'util/u_surface.c',
'util/u_texture.c',
'util/u_tile.c',
- 'util/u_timed_winsys.c',
+ 'util/u_transfer.c',
'util/u_upload_mgr.c',
- 'util/u_simple_screen.c',
# Disabling until pipe-video branch gets merged in
#'vl/vl_bitstream_parser.c',
#'vl/vl_mpeg12_mc_renderer.c',
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index f4615064e6..3844c04dd3 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -88,7 +88,7 @@ struct aaline_stage
uint pos_slot;
void *sampler_cso;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view *sampler_view;
uint num_samplers;
uint num_sampler_views;
@@ -396,7 +396,7 @@ aaline_create_texture(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture texTemp;
+ struct pipe_resource texTemp;
struct pipe_sampler_view viewTempl;
uint level;
@@ -408,7 +408,7 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
- aaline->texture = screen->texture_create(screen, &texTemp);
+ aaline->texture = screen->resource_create(screen, &texTemp);
if (!aaline->texture)
return FALSE;
@@ -428,16 +428,23 @@ aaline_create_texture(struct aaline_stage *aaline)
*/
for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
struct pipe_transfer *transfer;
+ struct pipe_box box;
const uint size = u_minify(aaline->texture->width0, level);
ubyte *data;
uint i, j;
assert(aaline->texture->width0 == aaline->texture->height0);
+ u_box_origin_2d( size, size, &box );
+
/* This texture is new, no need to flush.
*/
- transfer = pipe->get_tex_transfer(pipe, aaline->texture, 0, level, 0,
- PIPE_TRANSFER_WRITE, 0, 0, size, size);
+ transfer = pipe->get_transfer(pipe,
+ aaline->texture,
+ u_subresource(0, level),
+ PIPE_TRANSFER_WRITE,
+ &box);
+
data = pipe->transfer_map(pipe, transfer);
if (data == NULL)
return FALSE;
@@ -463,7 +470,7 @@ aaline_create_texture(struct aaline_stage *aaline)
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
return TRUE;
}
@@ -746,7 +753,7 @@ aaline_destroy(struct draw_stage *stage)
aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso);
if (aaline->texture)
- pipe_texture_reference(&aaline->texture, NULL);
+ pipe_resource_reference(&aaline->texture, NULL);
if (aaline->sampler_view) {
pipe_sampler_view_reference(&aaline->sampler_view, NULL);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 794fd81d70..bd433deeca 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -75,7 +75,7 @@ struct pstip_stage
struct draw_stage stage;
void *sampler_cso;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view *sampler_view;
uint num_samplers;
uint num_sampler_views;
@@ -389,8 +389,8 @@ pstip_update_texture(struct pstip_stage *pstip)
*/
pipe->flush( pipe, PIPE_FLUSH_TEXTURE_CACHE, NULL );
- transfer = pipe->get_tex_transfer(pipe, pstip->texture, 0, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
+ transfer = pipe_get_transfer(pipe, pstip->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
data = pipe->transfer_map(pipe, transfer);
/*
@@ -414,7 +414,7 @@ pstip_update_texture(struct pstip_stage *pstip)
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
@@ -426,7 +426,7 @@ pstip_create_texture(struct pstip_stage *pstip)
{
struct pipe_context *pipe = pstip->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture texTemp;
+ struct pipe_resource texTemp;
struct pipe_sampler_view viewTempl;
memset(&texTemp, 0, sizeof(texTemp));
@@ -437,7 +437,7 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.height0 = 32;
texTemp.depth0 = 1;
- pstip->texture = screen->texture_create(screen, &texTemp);
+ pstip->texture = screen->resource_create(screen, &texTemp);
if (pstip->texture == NULL)
return FALSE;
@@ -591,7 +591,7 @@ pstip_destroy(struct draw_stage *stage)
pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso);
- pipe_texture_reference(&pstip->texture, NULL);
+ pipe_resource_reference(&pstip->texture, NULL);
if (pstip->sampler_view) {
pipe_sampler_view_reference(&pstip->sampler_view, NULL);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 0744be6b41..4004741c19 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -51,7 +51,7 @@
*/
void
lp_sampler_static_state(struct lp_sampler_static_state *state,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
const struct pipe_sampler_state *sampler)
{
memset(state, 0, sizeof *state);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 92f3c57435..fcbf084baf 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -38,7 +38,7 @@
#include "gallivm/lp_bld.h"
-struct pipe_texture;
+struct pipe_resource;
struct pipe_sampler_state;
struct util_format_description;
struct lp_type;
@@ -48,7 +48,7 @@ struct lp_build_context;
/**
* Sampler static state.
*
- * These are the bits of state from pipe_texture and pipe_sampler_state that
+ * These are the bits of state from pipe_resource and pipe_sampler_state that
* are embedded in the generated code.
*/
struct lp_sampler_static_state
@@ -78,7 +78,7 @@ struct lp_sampler_static_state
/**
* Sampler dynamic state.
*
- * These are the bits of state from pipe_texture and pipe_sampler_state that
+ * These are the bits of state from pipe_resource and pipe_sampler_state that
* are computed in runtime.
*
* There are obtained through callbacks, as we don't want to tie the texture
@@ -130,7 +130,7 @@ struct lp_sampler_dynamic_state
*/
void
lp_sampler_static_state(struct lp_sampler_static_state *state,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
const struct pipe_sampler_state *sampler);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 34b1b77df4..a6c50dcf0c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -48,7 +48,6 @@
#include "util/u_debug.h"
#include "util/u_inlines.h"
#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
#ifdef __cplusplus
@@ -58,8 +57,23 @@ extern "C" {
struct pb_vtbl;
struct pb_validate;
+struct pipe_fence_handle;
+#define PB_USAGE_CPU_READ (1 << 0)
+#define PB_USAGE_CPU_WRITE (1 << 1)
+#define PB_USAGE_GPU_READ (1 << 2)
+#define PB_USAGE_GPU_WRITE (1 << 3)
+#define PB_USAGE_UNSYNCHRONIZED (1 << 10)
+#define PB_USAGE_DONTBLOCK (1 << 9)
+
+#define PB_USAGE_CPU_READ_WRITE \
+ ( PB_USAGE_CPU_READ | PB_USAGE_CPU_WRITE )
+#define PB_USAGE_GPU_READ_WRITE \
+ ( PB_USAGE_GPU_READ | PB_USAGE_GPU_WRITE )
+#define PB_USAGE_WRITE \
+ ( PB_USAGE_CPU_WRITE | PB_USAGE_GPU_WRITE )
+
/**
* Buffer description.
*
@@ -83,7 +97,14 @@ typedef unsigned pb_size;
*/
struct pb_buffer
{
- struct pipe_buffer base;
+ /* This used to be a pipe_buffer struct:
+ */
+ struct {
+ struct pipe_reference reference;
+ unsigned size;
+ unsigned alignment;
+ unsigned usage;
+ } base;
/**
* Pointer to the virtual function table.
@@ -106,7 +127,7 @@ struct pb_vtbl
/**
* Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
+ * flags is bitmask of PB_USAGE_CPU_READ/WRITE.
*/
void *(*map)( struct pb_buffer *buf,
unsigned flags );
@@ -138,23 +159,6 @@ struct pb_vtbl
};
-static INLINE struct pipe_buffer *
-pb_pipe_buffer( struct pb_buffer *pbuf )
-{
- assert(pbuf);
- return &pbuf->base;
-}
-
-
-static INLINE struct pb_buffer *
-pb_buffer( struct pipe_buffer *buf )
-{
- assert(buf);
- /* Could add a magic cookie check on debug builds.
- */
- return (struct pb_buffer *)buf;
-}
-
/* Accessor functions for pb->vtbl:
*/
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index d97f749b6e..d6cf640582 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -135,7 +135,7 @@ struct fenced_buffer
void *data;
/**
- * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current
+ * A bitmask of PB_USAGE_CPU/GPU_READ/WRITE describing the current
* buffer usage.
*/
unsigned flags;
@@ -270,7 +270,7 @@ fenced_buffer_add_locked(struct fenced_manager *fenced_mgr,
struct fenced_buffer *fenced_buf)
{
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
- assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
+ assert(fenced_buf->flags & PB_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
p_atomic_inc(&fenced_buf->base.base.reference.count);
@@ -299,7 +299,7 @@ fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr,
assert(fenced_buf->mgr == fenced_mgr);
ops->fence_reference(ops, &fenced_buf->fence, NULL);
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE;
assert(fenced_buf->head.prev);
assert(fenced_buf->head.next);
@@ -377,7 +377,7 @@ fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr,
assert(!destroyed);
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE;
ret = PIPE_OK;
}
@@ -624,7 +624,7 @@ fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf)
assert(fenced_buf->data);
assert(fenced_buf->buffer);
- map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pb_map(fenced_buf->buffer, PB_USAGE_CPU_WRITE);
if(!map)
return PIPE_ERROR;
@@ -644,7 +644,7 @@ fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf)
assert(fenced_buf->data);
assert(fenced_buf->buffer);
- map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pb_map(fenced_buf->buffer, PB_USAGE_CPU_READ);
if(!map)
return PIPE_ERROR;
@@ -683,24 +683,24 @@ fenced_buffer_map(struct pb_buffer *buf,
pipe_mutex_lock(fenced_mgr->mutex);
- assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
+ assert(!(flags & PB_USAGE_GPU_READ_WRITE));
/*
* Serialize writes.
*/
- while((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
- ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) &&
- (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
+ while((fenced_buf->flags & PB_USAGE_GPU_WRITE) ||
+ ((fenced_buf->flags & PB_USAGE_GPU_READ) &&
+ (flags & PB_USAGE_CPU_WRITE))) {
/*
* Don't wait for the GPU to finish accessing it, if blocking is forbidden.
*/
- if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) &&
+ if((flags & PB_USAGE_DONTBLOCK) &&
ops->fence_signalled(ops, fenced_buf->fence, 0) != 0) {
goto done;
}
- if (flags & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) {
+ if (flags & PB_USAGE_UNSYNCHRONIZED) {
break;
}
@@ -721,7 +721,7 @@ fenced_buffer_map(struct pb_buffer *buf,
if(map) {
++fenced_buf->mapcount;
- fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ fenced_buf->flags |= flags & PB_USAGE_CPU_READ_WRITE;
}
done:
@@ -745,7 +745,7 @@ fenced_buffer_unmap(struct pb_buffer *buf)
pb_unmap(fenced_buf->buffer);
--fenced_buf->mapcount;
if(!fenced_buf->mapcount)
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ fenced_buf->flags &= ~PB_USAGE_CPU_READ_WRITE;
}
pipe_mutex_unlock(fenced_mgr->mutex);
@@ -771,9 +771,9 @@ fenced_buffer_validate(struct pb_buffer *buf,
goto done;
}
- assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
- assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ assert(flags & PB_USAGE_GPU_READ_WRITE);
+ assert(!(flags & ~PB_USAGE_GPU_READ_WRITE));
+ flags &= PB_USAGE_GPU_READ_WRITE;
/* Buffer cannot be validated in two different lists */
if(fenced_buf->vl && fenced_buf->vl != vl) {
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
index 0372f81d0a..004c2b939a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
@@ -59,7 +59,6 @@ extern "C" {
#endif
-struct pipe_buffer;
struct pipe_fence_handle;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index 6bdce5fcb0..b706f429be 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -135,9 +135,9 @@ pb_malloc_buffer_create(pb_size size,
return NULL;
pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
buf->base.base.size = size;
+ buf->base.base.alignment = desc->alignment;
buf->base.vtbl = &malloc_buffer_vtbl;
buf->data = align_malloc(size, desc->alignment < sizeof(void*) ? sizeof(void*) : desc->alignment);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index 06669917ff..cec2524da2 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -60,7 +60,6 @@ extern "C" {
struct pb_desc;
-struct pipe_buffer;
/**
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 0f2ae05dae..88501e8d72 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -242,7 +242,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
if(!pb_check_usage(desc->usage, buf->base.base.usage))
return FALSE;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_DONTBLOCK);
+ map = pb_map(buf->buffer, PB_USAGE_DONTBLOCK);
if (!map) {
return FALSE;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index a5dbded2bc..0dc5b31a75 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -158,7 +158,7 @@ pb_debug_buffer_fill(struct pb_debug_buffer *buf)
{
uint8_t *map;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pb_map(buf->buffer, PB_USAGE_CPU_WRITE);
assert(map);
if(map) {
fill_random_pattern(map, buf->underflow_size);
@@ -180,8 +180,8 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
uint8_t *map;
map = pb_map(buf->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_UNSYNCHRONIZED);
assert(map);
if(map) {
boolean underflow, overflow;
@@ -382,8 +382,8 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
real_size = mgr->underflow_size + size + mgr->overflow_size;
real_desc = *desc;
- real_desc.usage |= PIPE_BUFFER_USAGE_CPU_WRITE;
- real_desc.usage |= PIPE_BUFFER_USAGE_CPU_READ;
+ real_desc.usage |= PB_USAGE_CPU_WRITE;
+ real_desc.usage |= PB_USAGE_CPU_READ;
buf->buffer = mgr->provider->create_buffer(mgr->provider,
real_size,
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 63195715d6..faf7c35267 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -268,8 +268,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
mm->buffer = buffer;
mm->map = pb_map(mm->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_CPU_WRITE);
if(!mm->map)
goto failure;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
index cb32d25136..31f1ebbeb7 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
@@ -150,7 +150,7 @@ pb_ondemand_buffer_instantiate(struct pb_ondemand_buffer *buf)
if(!buf->buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pb_map(buf->buffer, PB_USAGE_CPU_READ);
if(!map) {
pb_reference(&buf->buffer, NULL);
return PIPE_ERROR;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index fea234ae8c..fdcce42878 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -284,8 +284,8 @@ pool_bufmgr_create(struct pb_manager *provider,
goto failure;
pool->map = pb_map(pool->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_CPU_WRITE);
if(!pool->map)
goto failure;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 24e2820f88..7a3305aaf3 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -315,8 +315,8 @@ pb_slab_create(struct pb_slab_manager *mgr)
/* Note down the slab virtual address. All mappings are accessed directly
* through this address so it is required that the buffer is pinned. */
slab->virtual = pb_map(slab->bo,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_CPU_WRITE);
if(!slab->virtual) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
goto out_err1;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 903afc749d..b585422460 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -69,9 +69,9 @@ pb_validate_add_buffer(struct pb_validate *vl,
if(!buf)
return PIPE_ERROR;
- assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
- assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ assert(flags & PB_USAGE_GPU_READ_WRITE);
+ assert(!(flags & ~PB_USAGE_GPU_READ_WRITE));
+ flags &= PB_USAGE_GPU_READ_WRITE;
/* We only need to store one reference for each buffer, so avoid storing
* consecutive references for the same buffer. It might not be the most
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index cd95f85b63..7850f81e58 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -69,7 +69,7 @@ struct blit_state
void *vs;
void *fs[TGSI_WRITEMASK_XYZW + 1];
- struct pipe_buffer *vbuf; /**< quad vertices */
+ struct pipe_resource *vbuf; /**< quad vertices */
unsigned vbuf_slot;
float vertices[4][2][4]; /**< vertex/texcoords for quad */
@@ -167,7 +167,7 @@ util_destroy_blit(struct blit_state *ctx)
if (ctx->fs[i])
pipe->delete_fs_state(pipe, ctx->fs[i]);
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -186,8 +186,7 @@ get_next_slot( struct blit_state *ctx )
if (!ctx->vbuf) {
ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
max_slots * sizeof ctx->vertices);
}
@@ -236,7 +235,7 @@ setup_vertex_data_tex(struct blit_state *ctx,
offset = get_next_slot( ctx );
- pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf,
+ pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
@@ -304,9 +303,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
filter == PIPE_TEX_MIPFILTER_LINEAR);
assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ PIPE_BIND_RENDER_TARGET, 0));
/* do the regions overlap? */
overlap = util_same_surface(src, dst) &&
@@ -335,7 +334,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
}
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ PIPE_BIND_RENDER_TARGET, 0));
/* Create a temporary texture when src and dest alias or when src
* is anything other than a single-level 2d texture.
@@ -346,8 +345,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
src->texture->target != PIPE_TEXTURE_2D ||
src->texture->last_level != 0)
{
- struct pipe_texture texTemp;
- struct pipe_texture *tex;
+ struct pipe_resource texTemp;
+ struct pipe_resource *tex;
struct pipe_sampler_view sv_templ;
struct pipe_surface *texSurf;
const int srcLeft = MIN2(srcX0, srcX1);
@@ -376,7 +375,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- tex = screen->texture_create(screen, &texTemp);
+ tex = screen->resource_create(screen, &texTemp);
if (!tex)
return;
@@ -384,12 +383,12 @@ util_blit_pixels_writemask(struct blit_state *ctx,
sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ);
if (!sampler_view) {
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
return;
}
texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
/* load temp texture */
if (pipe->surface_copy) {
@@ -412,7 +411,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
t0 = 0.0f;
t1 = 1.0f;
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
}
else {
pipe_sampler_view_reference(&sampler_view, src_sampler_view);
@@ -540,7 +539,7 @@ util_blit_pixels(struct blit_state *ctx,
*/
void util_blit_flush( struct blit_state *ctx )
{
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -566,7 +565,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
struct pipe_framebuffer_state fb;
float s0, t0, s1, t1;
unsigned offset;
- struct pipe_texture *tex = src_sampler_view->texture;
+ struct pipe_resource *tex = src_sampler_view->texture;
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
filter == PIPE_TEX_MIPFILTER_LINEAR);
@@ -582,7 +581,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ PIPE_BIND_RENDER_TARGET,
0));
/* save state (restored below) */
diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h
index 1ebe65b455..464ff9aace 100644
--- a/src/gallium/auxiliary/util/u_blit.h
+++ b/src/gallium/auxiliary/util/u_blit.h
@@ -37,7 +37,7 @@ extern "C" {
struct pipe_context;
struct pipe_surface;
-struct pipe_texture;
+struct pipe_resource;
struct cso_context;
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 1692987e8e..104cbf7f6c 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -56,7 +56,7 @@ struct blitter_context_priv
struct blitter_context blitter;
struct pipe_context *pipe; /**< pipe context */
- struct pipe_buffer *vbuf; /**< quad */
+ struct pipe_resource *vbuf; /**< quad */
float vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */
@@ -215,8 +215,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
/* create the vertex buffer */
ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
sizeof(ctx->vertices));
return &ctx->blitter;
@@ -259,7 +258,7 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe_sampler_view_reference(&ctx->sampler_view, NULL);
}
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -451,7 +450,7 @@ static void blitter_draw_quad(struct blitter_context_priv *ctx)
struct pipe_context *pipe = ctx->pipe;
/* write vertices and draw them */
- pipe_buffer_write(pipe->screen, ctx->vbuf,
+ pipe_buffer_write(pipe, ctx->vbuf,
0, sizeof(ctx->vertices), ctx->vertices);
util_draw_vertex_buffer(pipe, ctx->vbuf, 0, PIPE_PRIM_TRIANGLE_FAN,
@@ -714,8 +713,8 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture texTemp;
- struct pipe_texture *texture;
+ struct pipe_resource texTemp;
+ struct pipe_resource *texture;
struct pipe_surface *tex_surf;
/* check whether the states are properly saved */
@@ -729,13 +728,13 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
texTemp.height0 = height;
texTemp.depth0 = 1;
- texture = screen->texture_create(screen, &texTemp);
+ texture = screen->resource_create(screen, &texTemp);
if (!texture)
return;
tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
/* blit from the src to the temp */
util_blitter_do_copy(blitter, tex_surf, 0, 0,
@@ -747,7 +746,7 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
width, height,
FALSE);
pipe_surface_reference(&tex_surf, NULL);
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
blitter_restore_CSOs(ctx);
}
@@ -781,8 +780,8 @@ void util_blitter_copy(struct blitter_context *blitter,
is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
- dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ dst_tex_usage = is_depth || is_stencil ? PIPE_BIND_DEPTH_STENCIL :
+ PIPE_BIND_RENDER_TARGET;
/* check if we can sample from and render to the surfaces */
/* (assuming copying a stencil buffer is not possible) */
@@ -790,7 +789,7 @@ void util_blitter_copy(struct blitter_context *blitter,
!screen->is_format_supported(screen, dst->format, dst->texture->target,
dst_tex_usage, 0) ||
!screen->is_format_supported(screen, src->format, src->texture->target,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
width, height);
return;
@@ -827,7 +826,7 @@ void util_blitter_fill(struct blitter_context *blitter,
/* check if we can render to the surface */
if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
!screen->is_format_supported(screen, dst->format, dst->texture->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
return;
}
diff --git a/src/gallium/auxiliary/util/u_box.h b/src/gallium/auxiliary/util/u_box.h
new file mode 100644
index 0000000000..919967b55a
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_box.h
@@ -0,0 +1,73 @@
+#ifndef UTIL_BOX_INLINES_H
+#define UTIL_BOX_INLINES_H
+
+#include "pipe/p_state.h"
+
+static INLINE
+void u_box_1d( unsigned x,
+ unsigned w,
+ struct pipe_box *box )
+{
+ box->x = x;
+ box->y = 0;
+ box->z = 0;
+ box->width = w;
+ box->height = 1;
+ box->depth = 1;
+}
+
+static INLINE
+void u_box_2d( unsigned x,
+ unsigned y,
+ unsigned w,
+ unsigned h,
+ struct pipe_box *box )
+{
+ box->x = x;
+ box->y = y;
+ box->z = 0;
+ box->width = w;
+ box->height = h;
+ box->depth = 1;
+}
+
+static INLINE
+void u_box_origin_2d( unsigned w,
+ unsigned h,
+ struct pipe_box *box )
+{
+ box->x = 0;
+ box->y = 0;
+ box->z = 0;
+ box->width = w;
+ box->height = h;
+ box->depth = 1;
+}
+
+static INLINE
+void u_box_2d_zslice( unsigned x,
+ unsigned y,
+ unsigned z,
+ unsigned w,
+ unsigned h,
+ struct pipe_box *box )
+{
+ box->x = x;
+ box->y = y;
+ box->z = z;
+ box->width = w;
+ box->height = h;
+ box->depth = 1;
+}
+
+static INLINE
+struct pipe_subresource u_subresource( unsigned face,
+ unsigned level )
+{
+ struct pipe_subresource subresource;
+ subresource.face = face;
+ subresource.level = level;
+ return subresource;
+}
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index e997cfa8a3..dd044973f9 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -425,7 +425,7 @@ void debug_dump_surface(struct pipe_context *pipe,
const char *prefix,
struct pipe_surface *surface)
{
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_transfer *transfer;
void *data;
@@ -440,7 +440,7 @@ void debug_dump_surface(struct pipe_context *pipe,
*/
texture = surface->texture;
- transfer = pipe->get_tex_transfer(pipe, texture, surface->face,
+ transfer = pipe_get_transfer(pipe, texture, surface->face,
surface->level, surface->zslice,
PIPE_TRANSFER_READ, 0, 0, surface->width,
surface->height);
@@ -452,20 +452,20 @@ void debug_dump_surface(struct pipe_context *pipe,
debug_dump_image(prefix,
texture->format,
util_format_get_blocksize(texture->format),
- util_format_get_nblocksx(texture->format, transfer->width),
- util_format_get_nblocksy(texture->format, transfer->height),
+ util_format_get_nblocksx(texture->format, surface->width),
+ util_format_get_nblocksy(texture->format, surface->height),
transfer->stride,
data);
pipe->transfer_unmap(pipe, transfer);
error:
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
void debug_dump_texture(struct pipe_context *pipe,
const char *prefix,
- struct pipe_texture *texture)
+ struct pipe_resource *texture)
{
struct pipe_surface *surface;
struct pipe_screen *screen;
@@ -477,7 +477,7 @@ void debug_dump_texture(struct pipe_context *pipe,
/* XXX for now, just dump image for face=0, level=0 */
surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
- PIPE_TEXTURE_USAGE_SAMPLER);
+ PIPE_BIND_SAMPLER_VIEW);
if (surface) {
debug_dump_surface(pipe, prefix, surface);
screen->tex_surface_destroy(surface);
@@ -523,16 +523,16 @@ debug_dump_surface_bmp(struct pipe_context *pipe,
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
struct pipe_transfer *transfer;
- struct pipe_texture *texture = surface->texture;
+ struct pipe_resource *texture = surface->texture;
- transfer = pipe->get_tex_transfer(pipe, texture, surface->face,
- surface->level, surface->zslice,
- PIPE_TRANSFER_READ, 0, 0, surface->width,
- surface->height);
+ transfer = pipe_get_transfer(pipe, texture, surface->face,
+ surface->level, surface->zslice,
+ PIPE_TRANSFER_READ, 0, 0, surface->width,
+ surface->height);
debug_dump_transfer_bmp(pipe, filename, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
#endif
}
@@ -547,17 +547,20 @@ debug_dump_transfer_bmp(struct pipe_context *pipe,
if (!transfer)
goto error1;
- rgba = MALLOC(transfer->width*transfer->height*4*sizeof(float));
+ rgba = MALLOC(transfer->box.width *
+ transfer->box.height *
+ transfer->box.depth *
+ 4*sizeof(float));
if(!rgba)
goto error1;
pipe_get_tile_rgba(pipe, transfer, 0, 0,
- transfer->width, transfer->height,
+ transfer->box.width, transfer->box.height,
rgba);
debug_dump_float_rgba_bmp(filename,
- transfer->width, transfer->height,
- rgba, transfer->width);
+ transfer->box.width, transfer->box.height,
+ rgba, transfer->box.width);
FREE(rgba);
error1:
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 98addeb372..b6d0b508e3 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -315,7 +315,7 @@ debug_memory_end(unsigned long beginning);
struct pipe_context;
struct pipe_surface;
struct pipe_transfer;
-struct pipe_texture;
+struct pipe_resource;
void debug_dump_image(const char *prefix,
unsigned format, unsigned cpp,
@@ -327,7 +327,7 @@ void debug_dump_surface(struct pipe_context *pipe,
struct pipe_surface *surface);
void debug_dump_texture(struct pipe_context *pipe,
const char *prefix,
- struct pipe_texture *texture);
+ struct pipe_resource *texture);
void debug_dump_surface_bmp(struct pipe_context *pipe,
const char *filename,
struct pipe_surface *surface);
diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c
index 8c194102bf..b37b48b5ae 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/src/gallium/auxiliary/util/u_draw_quad.c
@@ -30,6 +30,7 @@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
+#include "util/u_memory.h"
/**
@@ -38,7 +39,7 @@
*/
void
util_draw_vertex_buffer(struct pipe_context *pipe,
- struct pipe_buffer *vbuf,
+ struct pipe_resource *vbuf,
uint offset,
uint prim_type,
uint num_verts,
@@ -66,60 +67,63 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
/**
* Draw screen-aligned textured quad.
- * Note: this function allocs/destroys a vertex buffer and isn't especially
- * efficient.
+ * Note: this isn't especially efficient.
*/
void
util_draw_texquad(struct pipe_context *pipe,
float x0, float y0, float x1, float y1, float z)
{
- struct pipe_buffer *vbuf;
- uint numAttribs = 2, vertexBytes, i, j;
-
- vertexBytes = 4 * (4 * numAttribs * sizeof(float));
-
- /* XXX create one-time */
- vbuf = pipe_buffer_create(pipe->screen, 32,
- PIPE_BUFFER_USAGE_VERTEX, vertexBytes);
- if (vbuf) {
- float *v = (float *) pipe_buffer_map(pipe->screen, vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- if (v) {
- /*
- * Load vertex buffer
- */
- for (i = j = 0; i < 4; i++) {
- v[j + 2] = z; /* z */
- v[j + 3] = 1.0; /* w */
- v[j + 6] = 0.0; /* r */
- v[j + 7] = 1.0; /* q */
- j += 8;
- }
-
- v[0] = x0;
- v[1] = y0;
- v[4] = 0.0; /*s*/
- v[5] = 0.0; /*t*/
-
- v[8] = x1;
- v[9] = y0;
- v[12] = 1.0;
- v[13] = 0.0;
-
- v[16] = x1;
- v[17] = y1;
- v[20] = 1.0;
- v[21] = 1.0;
-
- v[24] = x0;
- v[25] = y1;
- v[28] = 0.0;
- v[29] = 1.0;
-
- pipe_buffer_unmap(pipe->screen, vbuf);
- util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
- }
-
- pipe_buffer_reference(&vbuf, NULL);
+ uint numAttribs = 2, i, j;
+ uint vertexBytes = 4 * (4 * numAttribs * sizeof(float));
+ struct pipe_resource *vbuf = NULL;
+ uint *v = NULL;
+
+ v = MALLOC(vertexBytes);
+ if (v == NULL)
+ goto out;
+
+ /*
+ * Load vertex buffer
+ */
+ for (i = j = 0; i < 4; i++) {
+ v[j + 2] = z; /* z */
+ v[j + 3] = 1.0; /* w */
+ v[j + 6] = 0.0; /* r */
+ v[j + 7] = 1.0; /* q */
+ j += 8;
}
+
+ v[0] = x0;
+ v[1] = y0;
+ v[4] = 0.0; /*s*/
+ v[5] = 0.0; /*t*/
+
+ v[8] = x1;
+ v[9] = y0;
+ v[12] = 1.0;
+ v[13] = 0.0;
+
+ v[16] = x1;
+ v[17] = y1;
+ v[20] = 1.0;
+ v[21] = 1.0;
+
+ v[24] = x0;
+ v[25] = y1;
+ v[28] = 0.0;
+ v[29] = 1.0;
+
+ vbuf = pipe_user_buffer_create(pipe->screen, v, vertexBytes,
+ PIPE_BIND_VERTEX_BUFFER);
+ if (!vbuf)
+ goto out;
+
+ util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
+
+out:
+ if (vbuf)
+ pipe_resource_reference(&vbuf, NULL);
+
+ if (v)
+ FREE(v);
}
diff --git a/src/gallium/auxiliary/util/u_draw_quad.h b/src/gallium/auxiliary/util/u_draw_quad.h
index 00d3f5b715..42eb184428 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.h
+++ b/src/gallium/auxiliary/util/u_draw_quad.h
@@ -33,11 +33,11 @@
extern "C" {
#endif
-struct pipe_buffer;
+struct pipe_resource;
extern void
util_draw_vertex_buffer(struct pipe_context *pipe,
- struct pipe_buffer *vbuf, uint offset,
+ struct pipe_resource *vbuf, uint offset,
uint num_attribs, uint num_verts, uint prim_type);
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index 379f18ef38..bdc73ac47d 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -92,7 +92,7 @@ util_dump_tex_filter(unsigned value, boolean shortened);
void
util_dump_template(struct os_stream *stream,
- const struct pipe_texture *templat);
+ const struct pipe_resource *templat);
void
util_dump_rasterizer_state(struct os_stream *stream,
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 52cf3ef4ce..79fd38ef5c 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -255,14 +255,14 @@ util_dump_enum_func(struct os_stream *stream, unsigned value)
void
-util_dump_template(struct os_stream *stream, const struct pipe_texture *templat)
+util_dump_template(struct os_stream *stream, const struct pipe_resource *templat)
{
if(!templat) {
util_dump_null(stream);
return;
}
- util_dump_struct_begin(stream, "pipe_texture");
+ util_dump_struct_begin(stream, "pipe_resource");
util_dump_member(stream, int, templat, target);
util_dump_member(stream, format, templat, format);
@@ -280,7 +280,9 @@ util_dump_template(struct os_stream *stream, const struct pipe_texture *templat)
util_dump_member_end(stream);
util_dump_member(stream, uint, templat, last_level);
- util_dump_member(stream, uint, templat, tex_usage);
+ util_dump_member(stream, uint, templat, _usage);
+ util_dump_member(stream, uint, templat, bind);
+ util_dump_member(stream, uint, templat, flags);
util_dump_struct_end(stream);
}
@@ -653,16 +655,13 @@ util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state)
util_dump_struct_begin(stream, "pipe_transfer");
- util_dump_member(stream, uint, state, width);
- util_dump_member(stream, uint, state, height);
+ util_dump_member(stream, ptr, state, resource);
+// util_dump_member(stream, uint, state, box);
util_dump_member(stream, uint, state, stride);
- util_dump_member(stream, uint, state, usage);
+ util_dump_member(stream, uint, state, slice_stride);
- util_dump_member(stream, ptr, state, texture);
- util_dump_member(stream, uint, state, face);
- util_dump_member(stream, uint, state, level);
- util_dump_member(stream, uint, state, zslice);
+// util_dump_member(stream, ptr, state, data);
util_dump_struct_end(stream);
}
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 509d38754f..eee6030ddc 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -67,7 +67,7 @@ struct gen_mipmap_state
void *vs;
void *fs2d, *fsCube;
- struct pipe_buffer *vbuf; /**< quad vertices */
+ struct pipe_resource *vbuf; /**< quad vertices */
unsigned vbuf_slot;
float vertices[4][2][4]; /**< vertex/texcoords for quad */
@@ -1116,7 +1116,7 @@ reduce_3d(enum pipe_format pformat,
static void
make_1d_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
struct pipe_context *pipe = ctx->pipe;
@@ -1128,11 +1128,11 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_transfer *srcTrans, *dstTrans;
void *srcMap, *dstMap;
- srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice,
+ srcTrans = pipe_get_transfer(pipe, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
u_minify(pt->width0, srcLevel),
u_minify(pt->height0, srcLevel));
- dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice,
+ dstTrans = pipe_get_transfer(pipe, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
u_minify(pt->width0, dstLevel),
u_minify(pt->height0, dstLevel));
@@ -1141,21 +1141,21 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
reduce_1d(pt->format,
- srcTrans->width, srcMap,
- dstTrans->width, dstMap);
+ srcTrans->box.width, srcMap,
+ dstTrans->box.width, dstMap);
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
}
static void
make_2d_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
struct pipe_context *pipe = ctx->pipe;
@@ -1170,36 +1170,36 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice,
- PIPE_TRANSFER_READ, 0, 0,
- u_minify(pt->width0, srcLevel),
- u_minify(pt->height0, srcLevel));
- dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice,
- PIPE_TRANSFER_WRITE, 0, 0,
- u_minify(pt->width0, dstLevel),
- u_minify(pt->height0, dstLevel));
+ srcTrans = pipe_get_transfer(pipe, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel));
+ dstTrans = pipe_get_transfer(pipe, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel));
srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
reduce_2d(pt->format,
- srcTrans->width, srcTrans->height,
+ srcTrans->box.width, srcTrans->box.height,
srcTrans->stride, srcMap,
- dstTrans->width, dstTrans->height,
+ dstTrans->box.width, dstTrans->box.height,
dstTrans->stride, dstMap);
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
}
static void
make_3d_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
#if 0
@@ -1215,11 +1215,11 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice,
+ srcTrans = pipe->get_transfer(pipe, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
u_minify(pt->width0, srcLevel),
u_minify(pt->height0, srcLevel));
- dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice,
+ dstTrans = pipe->get_transfer(pipe, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
u_minify(pt->width0, dstLevel),
u_minify(pt->height0, dstLevel));
@@ -1236,8 +1236,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
#else
(void) reduce_3d;
@@ -1247,7 +1247,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
static void
fallback_gen_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
switch (pt->target) {
@@ -1358,8 +1358,7 @@ get_next_slot(struct gen_mipmap_state *ctx)
if (!ctx->vbuf) {
ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
max_slots * sizeof ctx->vertices);
}
@@ -1420,7 +1419,7 @@ set_vertex_data(struct gen_mipmap_state *ctx,
offset = get_next_slot( ctx );
- pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf,
+ pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
@@ -1440,7 +1439,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
pipe->delete_fs_state(pipe, ctx->fs2d);
pipe->delete_fs_state(pipe, ctx->fsCube);
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -1452,7 +1451,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
*/
void util_gen_mipmap_flush( struct gen_mipmap_state *ctx )
{
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -1476,7 +1475,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_framebuffer_state fb;
- struct pipe_texture *pt = psv->texture;
+ struct pipe_resource *pt = psv->texture;
void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d;
uint dstLevel;
uint zslice = 0;
@@ -1495,7 +1494,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
/* check if we can render in the texture's format */
if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
return;
}
@@ -1541,7 +1540,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
struct pipe_surface *surf =
screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
/*
* Setup framebuffer / dest surface
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.h b/src/gallium/auxiliary/util/u_gen_mipmap.h
index 35ac9daeaa..a7502b9982 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.h
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.h
@@ -37,7 +37,7 @@ extern "C" {
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
struct cso_context;
struct gen_mipmap_state;
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index e22ab188e1..c2f4f05990 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -34,6 +34,7 @@
#include "pipe/p_screen.h"
#include "util/u_debug.h"
#include "util/u_atomic.h"
+#include "util/u_box.h"
#ifdef __cplusplus
@@ -87,18 +88,6 @@ pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
return destroy;
}
-static INLINE void
-pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
-{
- struct pipe_buffer *old_buf;
-
- assert(ptr);
- old_buf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &buf->reference))
- old_buf->screen->buffer_destroy(old_buf);
- *ptr = buf;
-}
static INLINE void
pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
@@ -110,16 +99,18 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
*ptr = surf;
}
+
static INLINE void
-pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
+pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
{
- struct pipe_texture *old_tex = *ptr;
+ struct pipe_resource *old_tex = *ptr;
if (pipe_reference(&(*ptr)->reference, &tex->reference))
- old_tex->screen->texture_destroy(old_tex);
+ old_tex->screen->resource_destroy(old_tex->screen, old_tex);
*ptr = tex;
}
+
static INLINE void
pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view)
{
@@ -135,91 +126,135 @@ pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_
* Convenience wrappers for screen buffer functions.
*/
-static INLINE struct pipe_buffer *
+static INLINE struct pipe_resource *
pipe_buffer_create( struct pipe_screen *screen,
- unsigned alignment, unsigned usage, unsigned size )
+ unsigned bind,
+ unsigned size )
{
- return screen->buffer_create(screen, alignment, usage, size);
+ struct pipe_resource buffer;
+ memset(&buffer, 0, sizeof buffer);
+ buffer.target = PIPE_BUFFER;
+ buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */
+ buffer.bind = bind;
+ buffer._usage = PIPE_USAGE_DEFAULT;
+ buffer.flags = 0;
+ buffer.width0 = size;
+ buffer.height0 = 1;
+ buffer.depth0 = 1;
+ return screen->resource_create(screen, &buffer);
}
-static INLINE struct pipe_buffer *
-pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size )
+
+static INLINE struct pipe_resource *
+pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size,
+ unsigned usage )
{
- return screen->user_buffer_create(screen, ptr, size);
+ return screen->user_buffer_create(screen, ptr, size, usage);
}
static INLINE void *
-pipe_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage)
+pipe_buffer_map_range(struct pipe_context *pipe,
+ struct pipe_resource *buffer,
+ unsigned offset,
+ unsigned length,
+ unsigned usage,
+ struct pipe_transfer **transfer)
{
- if(screen->buffer_map_range) {
- unsigned offset = 0;
- unsigned length = buf->size;
- return screen->buffer_map_range(screen, buf, offset, length, usage);
+ struct pipe_box box;
+ void *map;
+
+ assert(offset < buffer->width0);
+ assert(offset + length <= buffer->width0);
+ assert(length);
+
+ u_box_1d(offset, length, &box);
+
+ *transfer = pipe->get_transfer( pipe,
+ buffer,
+ u_subresource(0, 0),
+ usage,
+ &box);
+
+ if (*transfer == NULL)
+ return NULL;
+
+ map = pipe->transfer_map( pipe, *transfer );
+ if (map == NULL) {
+ pipe->transfer_destroy( pipe, *transfer );
+ return NULL;
}
- else
- return screen->buffer_map(screen, buf, usage);
+
+ /* Match old screen->buffer_map_range() behaviour, return pointer
+ * to where the beginning of the buffer would be:
+ */
+ return (void *)((char *)map - offset);
}
-static INLINE void
-pipe_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
+
+static INLINE void *
+pipe_buffer_map(struct pipe_context *pipe,
+ struct pipe_resource *buffer,
+ unsigned usage,
+ struct pipe_transfer **transfer)
{
- screen->buffer_unmap(screen, buf);
+ return pipe_buffer_map_range(pipe, buffer, 0, buffer->width0, usage, transfer);
}
-static INLINE void *
-pipe_buffer_map_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset,
- unsigned length,
- unsigned usage)
+
+static INLINE void
+pipe_buffer_unmap(struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ struct pipe_transfer *transfer)
{
- assert(offset < buf->size);
- assert(offset + length <= buf->size);
- assert(length);
- if(screen->buffer_map_range)
- return screen->buffer_map_range(screen, buf, offset, length, usage);
- else
- return screen->buffer_map(screen, buf, usage);
+ if (transfer) {
+ pipe->transfer_unmap(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
+ }
}
static INLINE void
-pipe_buffer_flush_mapped_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+pipe_buffer_flush_mapped_range(struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
unsigned offset,
unsigned length)
{
- assert(offset < buf->size);
- assert(offset + length <= buf->size);
+ struct pipe_box box;
+ int transfer_offset;
+
assert(length);
- if(screen->buffer_flush_mapped_range)
- screen->buffer_flush_mapped_range(screen, buf, offset, length);
+ assert(transfer->box.x <= offset);
+ assert(offset + length <= transfer->box.x + transfer->box.width);
+
+ /* Match old screen->buffer_flush_mapped_range() behaviour, where
+ * offset parameter is relative to the start of the buffer, not the
+ * mapped range.
+ */
+ transfer_offset = offset - transfer->box.x;
+
+ u_box_1d(transfer_offset, length, &box);
+
+ pipe->transfer_flush_region(pipe, transfer, &box);
}
static INLINE void
-pipe_buffer_write(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
+pipe_buffer_write(struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ unsigned offset,
+ unsigned size,
const void *data)
{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD);
- assert(map);
- if(map) {
- memcpy((uint8_t *)map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, size);
- pipe_buffer_unmap(screen, buf);
- }
+ struct pipe_box box;
+
+ u_box_1d(offset, size, &box);
+
+ pipe->transfer_inline_write( pipe,
+ buf,
+ u_subresource(0,0),
+ PIPE_TRANSFER_WRITE,
+ &box,
+ data,
+ size,
+ 0);
}
/**
@@ -229,86 +264,87 @@ pipe_buffer_write(struct pipe_screen *screen,
* been written before.
*/
static INLINE void
-pipe_buffer_write_nooverlap(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+pipe_buffer_write_nooverlap(struct pipe_context *pipe,
+ struct pipe_resource *buf,
unsigned offset, unsigned size,
const void *data)
{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
- assert(map);
- if(map) {
- memcpy((uint8_t *)map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, size);
- pipe_buffer_unmap(screen, buf);
- }
+ struct pipe_box box;
+
+ u_box_1d(offset, size, &box);
+
+ pipe->transfer_inline_write(pipe,
+ buf,
+ u_subresource(0,0),
+ (PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_NOOVERWRITE),
+ &box,
+ data,
+ 0, 0);
}
static INLINE void
-pipe_buffer_read(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
+pipe_buffer_read(struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ unsigned offset,
+ unsigned size,
void *data)
{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
- assert(map);
- if(map) {
- memcpy(data, (const uint8_t *)map + offset, size);
- pipe_buffer_unmap(screen, buf);
- }
+ struct pipe_transfer *src_transfer;
+ ubyte *map;
+
+ map = (ubyte *) pipe_buffer_map_range(pipe,
+ buf,
+ offset, size,
+ PIPE_TRANSFER_READ,
+ &src_transfer);
+
+ if (map)
+ memcpy(data, map + offset, size);
+
+ pipe_buffer_unmap(pipe, buf, src_transfer);
+}
+
+static INLINE struct pipe_transfer *
+pipe_get_transfer( struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h)
+{
+ struct pipe_box box;
+ u_box_2d_zslice( x, y, zslice, w, h, &box );
+ return context->get_transfer( context,
+ resource,
+ u_subresource(face, level),
+ usage,
+ &box );
}
static INLINE void *
pipe_transfer_map( struct pipe_context *context,
- struct pipe_transfer *transf )
+ struct pipe_transfer *transfer )
{
- return context->transfer_map(context, transf);
+ return context->transfer_map( context, transfer );
}
static INLINE void
pipe_transfer_unmap( struct pipe_context *context,
- struct pipe_transfer *transf )
+ struct pipe_transfer *transfer )
{
- context->transfer_unmap(context, transf);
+ context->transfer_unmap( context, transfer );
}
+
static INLINE void
-pipe_transfer_destroy( struct pipe_context *context,
- struct pipe_transfer *transfer )
+pipe_transfer_destroy( struct pipe_context *context,
+ struct pipe_transfer *transfer )
{
- context->tex_transfer_destroy(context, transfer);
+ context->transfer_destroy(context, transfer);
}
-static INLINE unsigned
-pipe_transfer_buffer_flags( struct pipe_transfer *transf )
-{
- switch (transf->usage & PIPE_TRANSFER_READ_WRITE) {
- case PIPE_TRANSFER_READ_WRITE:
- return PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE;
- case PIPE_TRANSFER_READ:
- return PIPE_BUFFER_USAGE_CPU_READ;
- case PIPE_TRANSFER_WRITE:
- return PIPE_BUFFER_USAGE_CPU_WRITE;
- default:
- debug_assert(0);
- return 0;
- }
-}
#ifdef __cplusplus
}
diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c
index e73797f1b7..098cdfd58b 100644
--- a/src/gallium/auxiliary/util/u_rect.c
+++ b/src/gallium/auxiliary/util/u_rect.c
@@ -35,6 +35,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "util/u_format.h"
+#include "util/u_inlines.h"
#include "util/u_rect.h"
@@ -181,21 +182,21 @@ util_surface_copy(struct pipe_context *pipe,
src_format = src->texture->format;
dst_format = dst->texture->format;
- src_trans = pipe->get_tex_transfer(pipe,
- src->texture,
- src->face,
- src->level,
- src->zslice,
- PIPE_TRANSFER_READ,
- src_x, src_y, w, h);
-
- dst_trans = pipe->get_tex_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
- PIPE_TRANSFER_WRITE,
- dst_x, dst_y, w, h);
+ src_trans = pipe_get_transfer(pipe,
+ src->texture,
+ src->face,
+ src->level,
+ src->zslice,
+ PIPE_TRANSFER_READ,
+ src_x, src_y, w, h);
+
+ dst_trans = pipe_get_transfer(pipe,
+ dst->texture,
+ dst->face,
+ dst->level,
+ dst->zslice,
+ PIPE_TRANSFER_WRITE,
+ dst_x, dst_y, w, h);
assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
@@ -223,8 +224,8 @@ util_surface_copy(struct pipe_context *pipe,
pipe->transfer_unmap(pipe, src_trans);
pipe->transfer_unmap(pipe, dst_trans);
- pipe->tex_transfer_destroy(pipe, src_trans);
- pipe->tex_transfer_destroy(pipe, dst_trans);
+ pipe->transfer_destroy(pipe, src_trans);
+ pipe->transfer_destroy(pipe, dst_trans);
}
@@ -248,13 +249,13 @@ util_surface_fill(struct pipe_context *pipe,
assert(dst->texture);
if (!dst->texture)
return;
- dst_trans = pipe->get_tex_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
- PIPE_TRANSFER_WRITE,
- dstx, dsty, width, height);
+ dst_trans = pipe_get_transfer(pipe,
+ dst->texture,
+ dst->face,
+ dst->level,
+ dst->zslice,
+ PIPE_TRANSFER_WRITE,
+ dstx, dsty, width, height);
dst_map = pipe->transfer_map(pipe, dst_trans);
@@ -263,37 +264,38 @@ util_surface_fill(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (util_format_get_blocksize(dst_trans->texture->format)) {
+ switch (util_format_get_blocksize(dst->texture->format)) {
case 1:
case 2:
case 4:
- util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
+ util_fill_rect(dst_map, dst->texture->format,
+ dst_trans->stride,
0, 0, width, height, value);
break;
case 8:
- {
- /* expand the 4-byte clear value to an 8-byte value */
- ushort *row = (ushort *) dst_map;
- ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
- ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
- ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
- ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
- unsigned i, j;
- val0 = (val0 << 8) | val0;
- val1 = (val1 << 8) | val1;
- val2 = (val2 << 8) | val2;
- val3 = (val3 << 8) | val3;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- row[j*4+0] = val0;
- row[j*4+1] = val1;
- row[j*4+2] = val2;
- row[j*4+3] = val3;
- }
- row += dst_trans->stride/2;
- }
- }
- break;
+ {
+ /* expand the 4-byte clear value to an 8-byte value */
+ ushort *row = (ushort *) dst_map;
+ ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
+ ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
+ ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
+ ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
+ unsigned i, j;
+ val0 = (val0 << 8) | val0;
+ val1 = (val1 << 8) | val1;
+ val2 = (val2 << 8) | val2;
+ val3 = (val3 << 8) | val3;
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ row[j*4+0] = val0;
+ row[j*4+1] = val1;
+ row[j*4+2] = val2;
+ row[j*4+3] = val3;
+ }
+ row += dst_trans->stride/2;
+ }
+ }
+ break;
default:
assert(0);
break;
@@ -301,5 +303,5 @@ util_surface_fill(struct pipe_context *pipe,
}
pipe->transfer_unmap(pipe, dst_trans);
- pipe->tex_transfer_destroy(pipe, dst_trans);
+ pipe->transfer_destroy(pipe, dst_trans);
}
diff --git a/src/gallium/auxiliary/util/u_resource.c b/src/gallium/auxiliary/util/u_resource.c
new file mode 100644
index 0000000000..c37a68bc42
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_resource.c
@@ -0,0 +1,97 @@
+
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_transfer.h"
+
+static INLINE struct u_resource *
+u_resource( struct pipe_resource *res )
+{
+ return (struct u_resource *)res;
+}
+
+boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->resource_get_handle(screen, resource, handle);
+}
+
+void u_resource_destroy_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource)
+{
+ struct u_resource *ur = u_resource(resource);
+ ur->vtbl->resource_destroy(screen, resource);
+}
+
+unsigned u_is_resource_referenced_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->is_resource_referenced(pipe, resource, face, level);
+}
+
+struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ enum pipe_transfer_usage usage,
+ const struct pipe_box *box)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->get_transfer(context, resource, sr, usage, box);
+}
+
+void u_transfer_destroy_vtbl(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_destroy(pipe, transfer);
+}
+
+void *u_transfer_map_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ return ur->vtbl->transfer_map(pipe, transfer);
+}
+
+void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_flush_region(pipe, transfer, box);
+}
+
+void u_transfer_unmap_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_unmap(pipe, transfer);
+}
+
+void u_transfer_inline_write_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ struct u_resource *ur = u_resource(resource);
+ ur->vtbl->transfer_inline_write(pipe,
+ resource,
+ sr,
+ usage,
+ box,
+ data,
+ stride,
+ slice_stride);
+}
+
+
+
+
diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c
index 4d8f861ce4..e77f562ea2 100644
--- a/src/gallium/auxiliary/util/u_sampler.c
+++ b/src/gallium/auxiliary/util/u_sampler.c
@@ -32,7 +32,7 @@
static void
default_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format,
unsigned expand_green_blue)
{
@@ -77,7 +77,7 @@ default_template(struct pipe_sampler_view *view,
void
u_sampler_view_default_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format)
{
/* Expand to (0, 0, 0, 1) */
@@ -89,7 +89,7 @@ u_sampler_view_default_template(struct pipe_sampler_view *view,
void
u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format)
{
/* Expand to (1, 1, 1, 1) */
diff --git a/src/gallium/auxiliary/util/u_sampler.h b/src/gallium/auxiliary/util/u_sampler.h
index bdd061c851..f3dad7417e 100644
--- a/src/gallium/auxiliary/util/u_sampler.h
+++ b/src/gallium/auxiliary/util/u_sampler.h
@@ -41,12 +41,12 @@ extern "C" {
void
u_sampler_view_default_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format);
void
u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format);
diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c
deleted file mode 100644
index 9203cb6580..0000000000
--- a/src/gallium/auxiliary/util/u_simple_screen.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "u_simple_screen.h"
-
-#include "pipe/p_screen.h"
-#include "pipe/p_state.h"
-#include "util/u_simple_screen.h"
-
-
-static struct pipe_buffer *
-pass_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct pipe_buffer *buffer =
- screen->winsys->buffer_create(screen->winsys, alignment, usage, size);
-
- buffer->screen = screen;
-
- return buffer;
-}
-
-static struct pipe_buffer *
-pass_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct pipe_buffer *buffer =
- screen->winsys->user_buffer_create(screen->winsys, ptr, bytes);
-
- buffer->screen = screen;
-
- return buffer;
-}
-
-
-
-static void *
-pass_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage)
-{
- return screen->winsys->buffer_map(screen->winsys, buf, usage);
-}
-
-static void
-pass_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
- screen->winsys->buffer_unmap(screen->winsys, buf);
-}
-
-static void
-pass_buffer_destroy(struct pipe_buffer *buf)
-{
- buf->screen->winsys->buffer_destroy(buf);
-}
-
-
-static void
-pass_flush_frontbuffer(struct pipe_screen *screen,
- struct pipe_surface *surf,
- void *context_private)
-{
- screen->winsys->flush_frontbuffer(screen->winsys, surf, context_private);
-}
-
-static void
-pass_fence_reference(struct pipe_screen *screen,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- screen->winsys->fence_reference(screen->winsys, ptr, fence);
-}
-
-static int
-pass_fence_signalled(struct pipe_screen *screen,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return screen->winsys->fence_signalled(screen->winsys, fence, flag);
-}
-
-static int
-pass_fence_finish(struct pipe_screen *screen,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return screen->winsys->fence_finish(screen->winsys, fence, flag);
-}
-
-void
-u_simple_screen_init(struct pipe_screen *screen)
-{
- screen->buffer_create = pass_buffer_create;
- screen->user_buffer_create = pass_user_buffer_create;
-
- screen->buffer_map = pass_buffer_map;
- screen->buffer_unmap = pass_buffer_unmap;
- screen->buffer_destroy = pass_buffer_destroy;
- screen->flush_frontbuffer = pass_flush_frontbuffer;
- screen->fence_reference = pass_fence_reference;
- screen->fence_signalled = pass_fence_signalled;
- screen->fence_finish = pass_fence_finish;
-}
-
-const char *
-u_simple_screen_winsys_name(struct pipe_screen *screen)
-{
- return screen->winsys->get_name(screen->winsys);
-}
diff --git a/src/gallium/auxiliary/util/u_simple_screen.h b/src/gallium/auxiliary/util/u_simple_screen.h
index bb3f5ba102..de6325fe2a 100644
--- a/src/gallium/auxiliary/util/u_simple_screen.h
+++ b/src/gallium/auxiliary/util/u_simple_screen.h
@@ -33,7 +33,7 @@
struct pipe_screen;
struct pipe_fence_handle;
struct pipe_surface;
-struct pipe_buffer;
+struct pipe_resource;
/**
* Gallium3D drivers are (meant to be!) independent of both GL and the
@@ -73,14 +73,13 @@ struct pipe_winsys
* window systems must then implement that interface (rather than the
* other way around...).
*
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
+ * usage is a bitmask of PIPE_BIND_*.
+ * All possible usages must be present.
*
* alignment indicates the client's alignment requirements, eg for
* SSE instructions.
*/
- struct pipe_buffer *(*buffer_create)( struct pipe_winsys *ws,
+ struct pipe_resource *(*buffer_create)( struct pipe_winsys *ws,
unsigned alignment,
unsigned usage,
unsigned size );
@@ -106,7 +105,7 @@ struct pipe_winsys
* Note that ptr may be accessed at any time upto the time when the
* buffer is destroyed, so the data must not be freed before then.
*/
- struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *ws,
+ struct pipe_resource *(*user_buffer_create)(struct pipe_winsys *ws,
void *ptr,
unsigned bytes);
@@ -117,11 +116,11 @@ struct pipe_winsys
* display targets) must be allocated with special characteristics, memory
* pools, or obtained directly from the windowing system.
*
- * This callback is invoked by the pipe_screenwhen creating a texture marked
- * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
+ * This callback is invoked by the pipe_screen when creating a texture marked
+ * with the PIPE_BIND_DISPLAY_TARGET flag to get the underlying
* buffer storage.
*/
- struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws,
+ struct pipe_resource *(*surface_buffer_create)(struct pipe_winsys *ws,
unsigned width, unsigned height,
enum pipe_format format,
unsigned usage,
@@ -134,13 +133,13 @@ struct pipe_winsys
* flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
*/
void *(*buffer_map)( struct pipe_winsys *ws,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned usage );
void (*buffer_unmap)( struct pipe_winsys *ws,
- struct pipe_buffer *buf );
+ struct pipe_resource *buf );
- void (*buffer_destroy)( struct pipe_buffer *buf );
+ void (*buffer_destroy)( struct pipe_resource *buf );
/** Set ptr = fence, with reference counting */
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 33306bbc2a..42440d0d67 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -50,7 +50,8 @@
boolean
util_create_rgba_surface(struct pipe_screen *screen,
uint width, uint height,
- struct pipe_texture **textureOut,
+ uint bind,
+ struct pipe_resource **textureOut,
struct pipe_surface **surfaceOut)
{
static const enum pipe_format rgbaFormats[] = {
@@ -60,15 +61,14 @@ util_create_rgba_surface(struct pipe_screen *screen,
PIPE_FORMAT_NONE
};
const uint target = PIPE_TEXTURE_2D;
- const uint usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
enum pipe_format format = PIPE_FORMAT_NONE;
- struct pipe_texture templ;
+ struct pipe_resource templ;
uint i;
/* Choose surface format */
for (i = 0; rgbaFormats[i]; i++) {
if (screen->is_format_supported(screen, rgbaFormats[i],
- target, usage, 0)) {
+ target, bind, 0)) {
format = rgbaFormats[i];
break;
}
@@ -84,16 +84,19 @@ util_create_rgba_surface(struct pipe_screen *screen,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- templ.tex_usage = usage;
+ templ.bind = bind;
- *textureOut = screen->texture_create(screen, &templ);
+ *textureOut = screen->resource_create(screen, &templ);
if (!*textureOut)
return FALSE;
/* create surface / view into texture */
- *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+ *surfaceOut = screen->get_tex_surface(screen,
+ *textureOut,
+ 0, 0, 0,
+ bind);
if (!*surfaceOut) {
- pipe_texture_reference(textureOut, NULL);
+ pipe_resource_reference(textureOut, NULL);
return FALSE;
}
@@ -105,11 +108,11 @@ util_create_rgba_surface(struct pipe_screen *screen,
* Release the surface and texture from util_create_rgba_surface().
*/
void
-util_destroy_rgba_surface(struct pipe_texture *texture,
+util_destroy_rgba_surface(struct pipe_resource *texture,
struct pipe_surface *surface)
{
pipe_surface_reference(&surface, NULL);
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
}
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index 3c60df2c3e..119fcd4ce8 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -52,13 +52,13 @@ util_same_surface(const struct pipe_surface *s1, const struct pipe_surface *s2)
extern boolean
util_create_rgba_surface(struct pipe_screen *screen,
- uint width, uint height,
- struct pipe_texture **textureOut,
+ uint width, uint height, uint bind,
+ struct pipe_resource **textureOut,
struct pipe_surface **surfaceOut);
extern void
-util_destroy_rgba_surface(struct pipe_texture *texture,
+util_destroy_rgba_surface(struct pipe_resource *texture,
struct pipe_surface *surface);
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index 88a1424dff..fe327c302b 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -53,9 +53,9 @@ pipe_get_tile_raw(struct pipe_context *pipe,
const void *src;
if (dst_stride == 0)
- dst_stride = util_format_get_stride(pt->texture->format, w);
+ dst_stride = util_format_get_stride(pt->resource->format, w);
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
src = pipe->transfer_map(pipe, pt);
@@ -63,7 +63,7 @@ pipe_get_tile_raw(struct pipe_context *pipe,
if(!src)
return;
- util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
+ util_copy_rect(dst, pt->resource->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
pipe->transfer_unmap(pipe, pt);
}
@@ -79,12 +79,12 @@ pipe_put_tile_raw(struct pipe_context *pipe,
const void *src, int src_stride)
{
void *dst;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
if (src_stride == 0)
src_stride = util_format_get_stride(format, w);
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
dst = pipe->transfer_map(pipe, pt);
@@ -285,9 +285,9 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
{
unsigned dst_stride = w * 4;
void *packed;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
@@ -325,7 +325,7 @@ pipe_get_tile_swizzle(struct pipe_context *pipe,
uint iy;
float rgba01[6];
- if (pipe_clip_tile(x, y, &w, &h, pt)) {
+ if (u_clip_tile(x, y, &w, &h, &pt->box)) {
return;
}
@@ -383,9 +383,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
{
unsigned src_stride = w * 4;
void *packed;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
@@ -434,9 +434,9 @@ pipe_get_tile_z(struct pipe_context *pipe,
ubyte *map;
uint *pDest = z;
uint i, j;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
map = (ubyte *)pipe->transfer_map(pipe, pt);
@@ -519,9 +519,9 @@ pipe_put_tile_z(struct pipe_context *pipe,
const uint *ptrc = zSrc;
ubyte *map;
uint i, j;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
map = (ubyte *)pipe->transfer_map(pipe, pt);
@@ -544,7 +544,7 @@ pipe_put_tile_z(struct pipe_context *pipe,
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
{
uint *pDest = (uint *) (map + y * pt->stride + x*4);
- assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
+ //assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 24-bit Z, preserve stencil */
@@ -571,7 +571,7 @@ pipe_put_tile_z(struct pipe_context *pipe,
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
{
uint *pDest = (uint *) (map + y * pt->stride + x*4);
- assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
+ //assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 24-bit Z, preserve stencil */
diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h
index 1d8ce7d8cb..986eee0743 100644
--- a/src/gallium/auxiliary/util/u_tile.h
+++ b/src/gallium/auxiliary/util/u_tile.h
@@ -32,22 +32,24 @@
struct pipe_transfer;
-
/**
* Clip tile against transfer dims.
+ *
+ * XXX: this only clips width and height!
+ *
* \return TRUE if tile is totally clipped, FALSE otherwise
*/
static INLINE boolean
-pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_transfer *pt)
+u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box)
{
- if (x >= pt->width)
+ if (x >= box->width)
return TRUE;
- if (y >= pt->height)
+ if (y >= box->height)
return TRUE;
- if (x + *w > pt->width)
- *w = pt->width - x;
- if (y + *h > pt->height)
- *h = pt->height - y;
+ if (x + *w > box->width)
+ *w = box->width - x;
+ if (y + *h > box->height)
+ *h = box->height - y;
return FALSE;
}
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c
deleted file mode 100644
index d88298bc14..0000000000
--- a/src/gallium/auxiliary/util/u_timed_winsys.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * 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 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 COPYRIGHT HOLDERS, 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "pipe/p_state.h"
-#include "util/u_simple_screen.h"
-#include "u_timed_winsys.h"
-#include "util/u_memory.h"
-#include "os/os_time.h"
-
-
-struct timed_winsys {
- struct pipe_winsys base;
- struct pipe_winsys *backend;
- uint64_t last_dump;
- struct {
- const char *name_key;
- double total;
- unsigned calls;
- } funcs[13];
-};
-
-
-static struct timed_winsys *timed_winsys( struct pipe_winsys *winsys )
-{
- return (struct timed_winsys *)winsys;
-}
-
-
-static void time_display( struct pipe_winsys *winsys )
-{
- struct timed_winsys *tws = timed_winsys(winsys);
- unsigned i;
- double overall = 0;
-
- for (i = 0; i < Elements(tws->funcs); i++) {
- if (tws->funcs[i].name_key) {
- debug_printf("*** %-25s %5.3fms (%d calls, avg %.3fms)\n",
- tws->funcs[i].name_key,
- tws->funcs[i].total,
- tws->funcs[i].calls,
- tws->funcs[i].total / tws->funcs[i].calls);
- overall += tws->funcs[i].total;
- tws->funcs[i].calls = 0;
- tws->funcs[i].total = 0;
- }
- }
-
- debug_printf("*** %-25s %5.3fms\n",
- "OVERALL WINSYS",
- overall);
-}
-
-static void time_finish( struct pipe_winsys *winsys,
- long long startval,
- unsigned idx,
- const char *name )
-{
- struct timed_winsys *tws = timed_winsys(winsys);
- int64_t endval = os_time_get();
- double elapsed = (endval - startval)/1000.0;
-
- if (endval - startval > 1000LL)
- debug_printf("*** %s %.3f\n", name, elapsed );
-
- assert( tws->funcs[idx].name_key == name ||
- tws->funcs[idx].name_key == NULL);
-
- tws->funcs[idx].name_key = name;
- tws->funcs[idx].total += elapsed;
- tws->funcs[idx].calls++;
-
- if (endval - tws->last_dump > 10LL * 1000LL * 1000LL) {
- time_display( winsys );
- tws->last_dump = endval;
- }
-}
-
-
-/* Pipe has no concept of pools, but the psb driver passes a flag that
- * can be mapped onto pools in the backend.
- */
-static struct pipe_buffer *
-timed_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- struct pipe_buffer *buf =
- backend->buffer_create( backend, alignment, usage, size );
-
- time_finish(winsys, start, 0, __FUNCTION__);
-
- return buf;
-}
-
-
-
-
-static struct pipe_buffer *
-timed_user_buffer_create(struct pipe_winsys *winsys,
- void *data,
- unsigned bytes)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- struct pipe_buffer *buf = backend->user_buffer_create( backend, data, bytes );
-
- time_finish(winsys, start, 1, __FUNCTION__);
-
- return buf;
-}
-
-
-static void *
-timed_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- void *map = backend->buffer_map( backend, buf, flags );
-
- time_finish(winsys, start, 2, __FUNCTION__);
-
- return map;
-}
-
-
-static void
-timed_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->buffer_unmap( backend, buf );
-
- time_finish(winsys, start, 3, __FUNCTION__);
-}
-
-
-static void
-timed_buffer_destroy(struct pipe_buffer *buf)
-{
- struct pipe_winsys *winsys = buf->screen->winsys;
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->buffer_destroy( buf );
-
- time_finish(winsys, start, 4, __FUNCTION__);
-}
-
-
-static void
-timed_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->flush_frontbuffer( backend, surf, context_private );
-
- time_finish(winsys, start, 5, __FUNCTION__);
-}
-
-
-
-
-static struct pipe_buffer *
-timed_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- struct pipe_buffer *ret = backend->surface_buffer_create( backend, width, height,
- format, usage, tex_usage, stride );
-
- time_finish(winsys, start, 7, __FUNCTION__);
-
- return ret;
-}
-
-
-static const char *
-timed_get_name( struct pipe_winsys *winsys )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- const char *ret = backend->get_name( backend );
-
- time_finish(winsys, start, 9, __FUNCTION__);
-
- return ret;
-}
-
-static void
-timed_fence_reference(struct pipe_winsys *winsys,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->fence_reference( backend, ptr, fence );
-
- time_finish(winsys, start, 10, __FUNCTION__);
-}
-
-
-static int
-timed_fence_signalled( struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- int ret = backend->fence_signalled( backend, fence, flag );
-
- time_finish(winsys, start, 11, __FUNCTION__);
-
- return ret;
-}
-
-static int
-timed_fence_finish( struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- int ret = backend->fence_finish( backend, fence, flag );
-
- time_finish(winsys, start, 12, __FUNCTION__);
-
- return ret;
-}
-
-static void
-timed_winsys_destroy( struct pipe_winsys *winsys )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- backend->destroy( backend );
- FREE(winsys);
-}
-
-
-
-struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend )
-{
- struct timed_winsys *ws = CALLOC_STRUCT(timed_winsys);
-
- ws->base.user_buffer_create = timed_user_buffer_create;
- ws->base.buffer_map = timed_buffer_map;
- ws->base.buffer_unmap = timed_buffer_unmap;
- ws->base.buffer_destroy = timed_buffer_destroy;
- ws->base.buffer_create = timed_buffer_create;
- ws->base.surface_buffer_create = timed_surface_buffer_create;
- ws->base.flush_frontbuffer = timed_flush_frontbuffer;
- ws->base.get_name = timed_get_name;
- ws->base.fence_reference = timed_fence_reference;
- ws->base.fence_signalled = timed_fence_signalled;
- ws->base.fence_finish = timed_fence_finish;
- ws->base.destroy = timed_winsys_destroy;
-
- ws->backend = backend;
-
- return &ws->base;
-}
-
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.h b/src/gallium/auxiliary/util/u_timed_winsys.h
deleted file mode 100644
index 542365112d..0000000000
--- a/src/gallium/auxiliary/util/u_timed_winsys.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * 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 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 COPYRIGHT HOLDERS, 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-
-#ifndef U_TIMED_WINSYS_H
-#define U_TIMED_WINSYS_H
-
-
-struct pipe_winsys;
-struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend );
-
-
-#endif
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
new file mode 100644
index 0000000000..bedace3b1d
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -0,0 +1,110 @@
+#include "pipe/p_context.h"
+#include "util/u_rect.h"
+#include "util/u_inlines.h"
+#include "util/u_transfer.h"
+#include "util/u_memory.h"
+
+/* One-shot transfer operation with data supplied in a user
+ * pointer. XXX: strides??
+ */
+void u_default_transfer_inline_write( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ struct pipe_transfer *transfer = NULL;
+ uint8_t *map = NULL;
+
+ transfer = pipe->get_transfer(pipe,
+ resource,
+ sr,
+ usage,
+ box );
+ if (transfer == NULL)
+ goto out;
+
+ map = pipe_transfer_map(pipe, transfer);
+ if (map == NULL)
+ goto out;
+
+ assert(box->depth == 1); /* XXX: fix me */
+
+ util_copy_rect(map,
+ resource->format,
+ transfer->stride, /* bytes? */
+ 0, 0,
+ box->width,
+ box->height,
+ data,
+ box->width, /* bytes? texels? */
+ 0, 0);
+
+out:
+ if (map)
+ pipe_transfer_unmap(pipe, transfer);
+
+ if (transfer)
+ pipe_transfer_destroy(pipe, transfer);
+}
+
+
+boolean u_default_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ return FALSE;
+}
+
+
+
+void u_default_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ /* This is a no-op implementation, nothing to do.
+ */
+}
+
+unsigned u_default_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
+{
+ return 0;
+}
+
+struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->sr = sr;
+ transfer->usage = usage;
+ transfer->box = *box;
+
+ /* Note strides are zero, this is ok for buffers, but not for
+ * textures 2d & higher at least.
+ */
+ return transfer;
+}
+
+void u_default_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+}
+
+void u_default_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ FREE(transfer);
+}
+
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
new file mode 100644
index 0000000000..eb07945d15
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -0,0 +1,145 @@
+
+#ifndef U_TRANSFER_H
+#define U_TRANSFER_H
+
+/* Fallback implementations for inline read/writes which just go back
+ * to the regular transfer behaviour.
+ */
+#include "pipe/p_state.h"
+
+struct pipe_context;
+
+boolean u_default_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle);
+
+void u_default_transfer_inline_write( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride);
+
+void u_default_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box);
+
+unsigned u_default_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level);
+
+struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+
+void u_default_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer );
+
+void u_default_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer);
+
+
+
+/* Useful helper to allow >1 implementation of resource functionality
+ * to exist in a single driver. This is intended to be transitionary!
+ */
+struct u_resource_vtbl {
+
+ boolean (*resource_get_handle)(struct pipe_screen *,
+ struct pipe_resource *tex,
+ struct winsys_handle *handle);
+
+ void (*resource_destroy)(struct pipe_screen *,
+ struct pipe_resource *pt);
+
+ unsigned (*is_resource_referenced)(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ unsigned face, unsigned level);
+
+ struct pipe_transfer *(*get_transfer)(struct pipe_context *,
+ struct pipe_resource *resource,
+ struct pipe_subresource,
+ unsigned usage,
+ const struct pipe_box *);
+
+ void (*transfer_destroy)(struct pipe_context *,
+ struct pipe_transfer *);
+
+ void *(*transfer_map)( struct pipe_context *,
+ struct pipe_transfer *transfer );
+
+ void (*transfer_flush_region)( struct pipe_context *,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *);
+
+ void (*transfer_unmap)( struct pipe_context *,
+ struct pipe_transfer *transfer );
+
+ void (*transfer_inline_write)( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride);
+};
+
+
+struct u_resource {
+ struct pipe_resource b;
+ struct u_resource_vtbl *vtbl;
+};
+
+
+boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle);
+
+void u_resource_destroy_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource);
+
+unsigned u_is_resource_referenced_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level);
+
+struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+
+void u_transfer_destroy_vtbl(struct pipe_context *pipe,
+ struct pipe_transfer *transfer);
+
+void *u_transfer_map_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer );
+
+void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box);
+
+void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
+ struct pipe_transfer *transfer );
+
+void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride);
+
+
+
+
+
+
+
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index 012b2ae233..75d44432d9 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -31,7 +31,7 @@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
-#include "pipe/p_screen.h"
+#include "pipe/p_context.h"
#include "util/u_memory.h"
#include "util/u_math.h"
@@ -39,7 +39,7 @@
struct u_upload_mgr {
- struct pipe_screen *screen;
+ struct pipe_context *pipe;
unsigned default_size;
unsigned alignment;
@@ -47,21 +47,21 @@ struct u_upload_mgr {
/* The active buffer:
*/
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer;
unsigned size;
unsigned offset;
};
-struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
+struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
unsigned default_size,
unsigned alignment,
unsigned usage )
{
struct u_upload_mgr *upload = CALLOC_STRUCT( u_upload_mgr );
+ upload->pipe = pipe;
upload->default_size = default_size;
- upload->screen = screen;
upload->alignment = alignment;
upload->usage = usage;
upload->buffer = NULL;
@@ -69,31 +69,44 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
return upload;
}
-
+/* Slightly specialized version of buffer_write designed to maximize
+ * chances of the driver consolidating successive writes into a single
+ * upload.
+ *
+ * dirty_size may be slightly greater than size to cope with
+ * alignment. We don't want to leave holes between succesively mapped
+ * regions as that may prevent the driver from consolidating uploads.
+ *
+ * Note that the 'data' pointer has probably come from the application
+ * and we cannot read even a byte past its end without risking
+ * segfaults, or at least complaints from valgrind..
+ */
static INLINE enum pipe_error
-my_buffer_write(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+my_buffer_write(struct pipe_context *pipe,
+ struct pipe_resource *buf,
unsigned offset, unsigned size, unsigned dirty_size,
const void *data)
{
+ struct pipe_transfer *transfer = NULL;
uint8_t *map;
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
+ assert(offset < buf->width0);
+ assert(offset + size <= buf->width0);
assert(dirty_size >= size);
assert(size);
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
+ map = pipe_buffer_map_range(pipe, buf, offset, dirty_size,
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_FLUSH_EXPLICIT |
+ PIPE_TRANSFER_DISCARD |
+ PIPE_TRANSFER_UNSYNCHRONIZED,
+ &transfer);
if (map == NULL)
return PIPE_ERROR_OUT_OF_MEMORY;
memcpy(map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size);
- pipe_buffer_unmap(screen, buf);
+ pipe_buffer_flush_mapped_range(pipe, transfer, offset, dirty_size);
+ pipe_buffer_unmap(pipe, buf, transfer);
return PIPE_OK;
}
@@ -109,7 +122,7 @@ my_buffer_write(struct pipe_screen *screen,
*/
void u_upload_flush( struct u_upload_mgr *upload )
{
- pipe_buffer_reference( &upload->buffer, NULL );
+ pipe_resource_reference( &upload->buffer, NULL );
upload->size = 0;
}
@@ -135,9 +148,8 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
*/
size = align(MAX2(upload->default_size, min_size), 4096);
- upload->buffer = pipe_buffer_create( upload->screen,
- upload->alignment,
- upload->usage | PIPE_BUFFER_USAGE_CPU_WRITE,
+ upload->buffer = pipe_buffer_create( upload->pipe->screen,
+ upload->usage,
size );
if (upload->buffer == NULL)
goto fail;
@@ -149,7 +161,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
fail:
if (upload->buffer)
- pipe_buffer_reference( &upload->buffer, NULL );
+ pipe_resource_reference( &upload->buffer, NULL );
return PIPE_ERROR_OUT_OF_MEMORY;
}
@@ -159,7 +171,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
unsigned size,
const void *data,
unsigned *out_offset,
- struct pipe_buffer **outbuf )
+ struct pipe_resource **outbuf )
{
unsigned alloc_size = align( size, upload->alignment );
enum pipe_error ret = PIPE_OK;
@@ -172,7 +184,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
/* Copy the data, using map_range if available:
*/
- ret = my_buffer_write( upload->screen,
+ ret = my_buffer_write( upload->pipe,
upload->buffer,
upload->offset,
size,
@@ -183,7 +195,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
/* Emit the return values:
*/
- pipe_buffer_reference( outbuf, upload->buffer );
+ pipe_resource_reference( outbuf, upload->buffer );
*out_offset = upload->offset;
upload->offset += alloc_size;
return PIPE_OK;
@@ -198,15 +210,18 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
unsigned offset,
unsigned size,
- struct pipe_buffer *inbuf,
+ struct pipe_resource *inbuf,
unsigned *out_offset,
- struct pipe_buffer **outbuf )
+ struct pipe_resource **outbuf )
{
enum pipe_error ret = PIPE_OK;
+ struct pipe_transfer *transfer = NULL;
const char *map = NULL;
- map = (const char *)pipe_buffer_map(
- upload->screen, inbuf, PIPE_BUFFER_USAGE_CPU_READ );
+ map = (const char *)pipe_buffer_map(upload->pipe,
+ inbuf,
+ PIPE_TRANSFER_READ,
+ &transfer);
if (map == NULL) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
@@ -226,7 +241,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
done:
if (map)
- pipe_buffer_unmap( upload->screen, inbuf );
+ pipe_buffer_unmap( upload->pipe, inbuf, transfer );
return ret;
}
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h
index e158bed9d0..a124924fc8 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -35,11 +35,11 @@
#include "pipe/p_defines.h"
struct pipe_screen;
-struct pipe_buffer;
+struct pipe_resource;
struct u_upload_mgr;
-struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
+struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
unsigned default_size,
unsigned alignment,
unsigned usage );
@@ -61,15 +61,15 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
unsigned size,
const void *data,
unsigned *out_offset,
- struct pipe_buffer **outbuf );
+ struct pipe_resource **outbuf );
enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
unsigned offset,
unsigned size,
- struct pipe_buffer *inbuf,
+ struct pipe_resource *inbuf,
unsigned *out_offset,
- struct pipe_buffer **outbuf );
+ struct pipe_resource **outbuf );
diff --git a/src/gallium/auxiliary/vl/vl_bitstream_parser.c b/src/gallium/auxiliary/vl/vl_bitstream_parser.c
deleted file mode 100644
index 3193ea5f41..0000000000
--- a/src/gallium/auxiliary/vl/vl_bitstream_parser.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_bitstream_parser.h"
-#include <assert.h>
-#include <limits.h>
-#include <util/u_memory.h>
-
-static unsigned
-grab_bits(unsigned cursor, unsigned how_many_bits, unsigned bitstream_elt)
-{
- unsigned excess_bits = sizeof(unsigned) * CHAR_BIT - how_many_bits - cursor;
-
- assert(cursor < sizeof(unsigned) * CHAR_BIT);
- assert(how_many_bits > 0 && how_many_bits <= sizeof(unsigned) * CHAR_BIT);
- assert(cursor + how_many_bits <= sizeof(unsigned) * CHAR_BIT);
-
- return (bitstream_elt << excess_bits) >> (excess_bits + cursor);
-}
-
-static unsigned
-show_bits(unsigned cursor, unsigned how_many_bits, const unsigned *bitstream)
-{
- unsigned cur_int = cursor / (sizeof(unsigned) * CHAR_BIT);
- unsigned cur_bit = cursor % (sizeof(unsigned) * CHAR_BIT);
-
- assert(bitstream);
-
- if (cur_bit + how_many_bits > sizeof(unsigned) * CHAR_BIT) {
- unsigned lower = grab_bits(cur_bit, sizeof(unsigned) * CHAR_BIT - cur_bit,
- bitstream[cur_int]);
- unsigned upper = grab_bits(0, cur_bit + how_many_bits - sizeof(unsigned) * CHAR_BIT,
- bitstream[cur_int + 1]);
- return lower | upper << (sizeof(unsigned) * CHAR_BIT - cur_bit);
- }
- else
- return grab_bits(cur_bit, how_many_bits, bitstream[cur_int]);
-}
-
-bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser,
- unsigned num_bitstreams,
- const void **bitstreams,
- const unsigned *sizes)
-{
- assert(parser);
- assert(num_bitstreams);
- assert(bitstreams);
- assert(sizes);
-
- parser->num_bitstreams = num_bitstreams;
- parser->bitstreams = (const unsigned**)bitstreams;
- parser->sizes = sizes;
- parser->cur_bitstream = 0;
- parser->cursor = 0;
-
- return true;
-}
-
-void vl_bitstream_parser_cleanup(struct vl_bitstream_parser *parser)
-{
- assert(parser);
-}
-
-unsigned
-vl_bitstream_parser_get_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- unsigned bits;
-
- assert(parser);
-
- bits = vl_bitstream_parser_show_bits(parser, how_many_bits);
-
- vl_bitstream_parser_forward(parser, how_many_bits);
-
- return bits;
-}
-
-unsigned
-vl_bitstream_parser_show_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- unsigned bits = 0;
- unsigned shift = 0;
- unsigned cursor;
- unsigned cur_bitstream;
-
- assert(parser);
-
- cursor = parser->cursor;
- cur_bitstream = parser->cur_bitstream;
-
- while (1) {
- unsigned bits_left = parser->sizes[cur_bitstream] * CHAR_BIT - cursor;
- unsigned bits_to_show = how_many_bits > bits_left ? bits_left : how_many_bits;
-
- bits |= show_bits(cursor, bits_to_show,
- parser->bitstreams[cur_bitstream]) << shift;
-
- if (how_many_bits > bits_to_show) {
- how_many_bits -= bits_to_show;
- cursor = 0;
- ++cur_bitstream;
- shift += bits_to_show;
- }
- else
- break;
- }
-
- return bits;
-}
-
-void vl_bitstream_parser_forward(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- assert(parser);
- assert(how_many_bits);
-
- parser->cursor += how_many_bits;
-
- while (parser->cursor > parser->sizes[parser->cur_bitstream] * CHAR_BIT) {
- parser->cursor -= parser->sizes[parser->cur_bitstream++] * CHAR_BIT;
- assert(parser->cur_bitstream < parser->num_bitstreams);
- }
-}
-
-void vl_bitstream_parser_rewind(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- signed c;
-
- assert(parser);
- assert(how_many_bits);
-
- c = parser->cursor - how_many_bits;
-
- while (c < 0) {
- c += parser->sizes[parser->cur_bitstream--] * CHAR_BIT;
- assert(parser->cur_bitstream < parser->num_bitstreams);
- }
-
- parser->cursor = (unsigned)c;
-}
diff --git a/src/gallium/auxiliary/vl/vl_bitstream_parser.h b/src/gallium/auxiliary/vl/vl_bitstream_parser.h
deleted file mode 100644
index 30ec743fa7..0000000000
--- a/src/gallium/auxiliary/vl/vl_bitstream_parser.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_bitstream_parser_h
-#define vl_bitstream_parser_h
-
-#include "pipe/p_compiler.h"
-
-struct vl_bitstream_parser
-{
- unsigned num_bitstreams;
- const unsigned **bitstreams;
- const unsigned *sizes;
- unsigned cur_bitstream;
- unsigned cursor;
-};
-
-bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser,
- unsigned num_bitstreams,
- const void **bitstreams,
- const unsigned *sizes);
-
-void vl_bitstream_parser_cleanup(struct vl_bitstream_parser *parser);
-
-unsigned
-vl_bitstream_parser_get_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-unsigned
-vl_bitstream_parser_show_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-void vl_bitstream_parser_forward(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-void vl_bitstream_parser_rewind(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-#endif /* vl_bitstream_parser_h */
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
deleted file mode 100644
index 6d461cb880..0000000000
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_compositor.h"
-#include <assert.h>
-#include <pipe/p_context.h>
-#include <util/u_inlines.h>
-#include <tgsi/tgsi_parse.h>
-#include <tgsi/tgsi_build.h>
-#include <util/u_memory.h>
-#include "vl_csc.h"
-#include "vl_shader_build.h"
-
-struct vertex2f
-{
- float x, y;
-};
-
-struct vertex4f
-{
- float x, y, z, w;
-};
-
-struct vertex_shader_consts
-{
- struct vertex4f dst_scale;
- struct vertex4f dst_trans;
- struct vertex4f src_scale;
- struct vertex4f src_trans;
-};
-
-struct fragment_shader_consts
-{
- float matrix[16];
-};
-
-/*
- * Represents 2 triangles in a strip in normalized coords.
- * Used to render the surface onto the frame buffer.
- */
-static const struct vertex2f surface_verts[4] =
-{
- {0.0f, 0.0f},
- {0.0f, 1.0f},
- {1.0f, 0.0f},
- {1.0f, 1.0f}
-};
-
-/*
- * Represents texcoords for the above. We can use the position values directly.
- * TODO: Duplicate these in the shader, no need to create a buffer.
- */
-static const struct vertex2f *surface_texcoords = surface_verts;
-
-static void
-create_vert_shader(struct vl_compositor *c)
-{
- const unsigned max_tokens = 50;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(c);
-
- tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header*)&tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Vertex texcoords
- */
- for (i = 0; i < 2; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl c0 ; Scaling vector to scale vertex pos rect to destination size
- * decl c1 ; Translation vector to move vertex pos rect into position
- * decl c2 ; Scaling vector to scale texcoord rect to source size
- * decl c3 ; Translation vector to move texcoord rect into position
- */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 3);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Vertex texcoords
- */
- for (i = 0; i < 2; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /* decl t0, t1 */
- decl = vl_decl_temps(0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * mad o0, i0, c0, c1 ; Scale and translate unit output rect to destination size and pos
- * mad o1, i1, c2, c3 ; Scale and translate unit texcoord rect to source size and pos
- */
- for (i = 0; i < 2; ++i) {
- inst = vl_inst4(TGSI_OPCODE_MAD, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i, TGSI_FILE_CONSTANT, i * 2, TGSI_FILE_CONSTANT, i * 2 + 1);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- c->vertex_shader = c->pipe->create_vs_state(c->pipe, &vs);
- FREE(tokens);
-}
-
-static void
-create_frag_shader(struct vl_compositor *c)
-{
- const unsigned max_tokens = 50;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(c);
-
- tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header*)&tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /* decl i0 ; Texcoords for s0 */
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, 1, 0, 0, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl c0-c3 ; CSC matrix c0-c3
- */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 3);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0 */
- decl = vl_decl_temps(0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl s0 ; Sampler for tex containing picture to display */
- decl = vl_decl_samplers(0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* tex2d t0, i0, s0 ; Read src pixel */
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_INPUT, 0, TGSI_FILE_SAMPLER, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /*
- * dp4 o0.x, t0, c0 ; Multiply pixel by the color conversion matrix
- * dp4 o0.y, t0, c1
- * dp4 o0.z, t0, c2
- * dp4 o0.w, t0, c3
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst3(TGSI_OPCODE_DP4, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, i);
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- c->fragment_shader = c->pipe->create_fs_state(c->pipe, &fs);
- FREE(tokens);
-}
-
-static bool
-init_pipe_state(struct vl_compositor *c)
-{
- struct pipe_sampler_state sampler;
- struct pipe_vertex_element vertex_elems[2];
-
- assert(c);
-
- c->fb_state.nr_cbufs = 1;
- c->fb_state.zsbuf = NULL;
-
- sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
- sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
- sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
- sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
- sampler.compare_func = PIPE_FUNC_ALWAYS;
- sampler.normalized_coords = 1;
- /*sampler.lod_bias = ;*/
- /*sampler.min_lod = ;*/
- /*sampler.max_lod = ;*/
- /*sampler.border_color[i] = ;*/
- /*sampler.max_anisotropy = ;*/
- c->sampler = c->pipe->create_sampler_state(c->pipe, &sampler);
-
- vertex_elems[0].src_offset = 0;
- vertex_elems[0].instance_divisor = 0;
- vertex_elems[0].vertex_buffer_index = 0;
- vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
- vertex_elems[1].src_offset = 0;
- vertex_elems[1].instance_divisor = 0;
- vertex_elems[1].vertex_buffer_index = 1;
- vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
- c->vertex_elems = c->pipe->create_vertex_elements_state(c->pipe, 2, vertex_elems);
-
-
- return true;
-}
-
-static void cleanup_pipe_state(struct vl_compositor *c)
-{
- assert(c);
-
- c->pipe->delete_sampler_state(c->pipe, c->sampler);
- c->pipe->delete_vertex_elements_state(c->pipe, c->vertex_elems);
-}
-
-static bool
-init_shaders(struct vl_compositor *c)
-{
- assert(c);
-
- create_vert_shader(c);
- create_frag_shader(c);
-
- return true;
-}
-
-static void cleanup_shaders(struct vl_compositor *c)
-{
- assert(c);
-
- c->pipe->delete_vs_state(c->pipe, c->vertex_shader);
- c->pipe->delete_fs_state(c->pipe, c->fragment_shader);
-}
-
-static bool
-init_buffers(struct vl_compositor *c)
-{
- struct fragment_shader_consts fsc;
-
- assert(c);
-
- /*
- * Create our vertex buffer and vertex buffer element
- * VB contains 4 vertices that render a quad covering the entire window
- * to display a rendered surface
- * Quad is rendered as a tri strip
- */
- c->vertex_bufs[0].stride = sizeof(struct vertex2f);
- c->vertex_bufs[0].max_index = 3;
- c->vertex_bufs[0].buffer_offset = 0;
- c->vertex_bufs[0].buffer = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_VERTEX,
- sizeof(struct vertex2f) * 4
- );
-
- memcpy
- (
- pipe_buffer_map(c->pipe->screen, c->vertex_bufs[0].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- surface_verts,
- sizeof(struct vertex2f) * 4
- );
-
- pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[0].buffer);
-
- /*
- * Create our texcoord buffer and texcoord buffer element
- * Texcoord buffer contains the TCs for mapping the rendered surface to the 4 vertices
- */
- c->vertex_bufs[1].stride = sizeof(struct vertex2f);
- c->vertex_bufs[1].max_index = 3;
- c->vertex_bufs[1].buffer_offset = 0;
- c->vertex_bufs[1].buffer = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_VERTEX,
- sizeof(struct vertex2f) * 4
- );
-
- memcpy
- (
- pipe_buffer_map(c->pipe->screen, c->vertex_bufs[1].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- surface_texcoords,
- sizeof(struct vertex2f) * 4
- );
-
- pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[1].buffer);
-
- /*
- * Create our vertex shader's constant buffer
- * Const buffer contains scaling and translation vectors
- */
- c->vs_const_buf = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_CONSTANT | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex_shader_consts)
- );
-
- /*
- * Create our fragment shader's constant buffer
- * Const buffer contains the color conversion matrix and bias vectors
- */
- c->fs_const_buf = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_CONSTANT,
- sizeof(struct fragment_shader_consts)
- );
-
- vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, fsc.matrix);
-
- vl_compositor_set_csc_matrix(c, fsc.matrix);
-
- return true;
-}
-
-static void
-cleanup_buffers(struct vl_compositor *c)
-{
- unsigned i;
-
- assert(c);
-
- for (i = 0; i < 2; ++i)
- pipe_buffer_reference(&c->vertex_bufs[i].buffer, NULL);
-
- pipe_buffer_reference(&c->vs_const_buf, NULL);
- pipe_buffer_reference(&c->fs_const_buf, NULL);
-}
-
-bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe)
-{
- assert(compositor);
-
- memset(compositor, 0, sizeof(struct vl_compositor));
-
- compositor->pipe = pipe;
-
- if (!init_pipe_state(compositor))
- return false;
- if (!init_shaders(compositor)) {
- cleanup_pipe_state(compositor);
- return false;
- }
- if (!init_buffers(compositor)) {
- cleanup_shaders(compositor);
- cleanup_pipe_state(compositor);
- return false;
- }
-
- return true;
-}
-
-void vl_compositor_cleanup(struct vl_compositor *compositor)
-{
- assert(compositor);
-
- cleanup_buffers(compositor);
- cleanup_shaders(compositor);
- cleanup_pipe_state(compositor);
-}
-
-void vl_compositor_render(struct vl_compositor *compositor,
- /*struct pipe_texture *backround,
- struct pipe_video_rect *backround_area,*/
- struct pipe_texture *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_texture *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_texture *future_surfaces,*/
- struct pipe_video_rect *src_area,
- struct pipe_texture *dst_surface,
- struct pipe_video_rect *dst_area,
- /*unsigned num_layers,
- struct pipe_texture *layers,
- struct pipe_video_rect *layer_src_areas,
- struct pipe_video_rect *layer_dst_areas*/
- struct pipe_fence_handle **fence)
-{
- struct vertex_shader_consts *vs_consts;
-
- assert(compositor);
- assert(src_surface);
- assert(src_area);
- assert(dst_surface);
- assert(dst_area);
- assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
-
- compositor->fb_state.width = dst_surface->width0;
- compositor->fb_state.height = dst_surface->height0;
- compositor->fb_state.cbufs[0] = compositor->pipe->screen->get_tex_surface
- (
- compositor->pipe->screen,
- dst_surface,
- 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE
- );
-
- compositor->viewport.scale[0] = compositor->fb_state.width;
- compositor->viewport.scale[1] = compositor->fb_state.height;
- compositor->viewport.scale[2] = 1;
- compositor->viewport.scale[3] = 1;
- compositor->viewport.translate[0] = 0;
- compositor->viewport.translate[1] = 0;
- compositor->viewport.translate[2] = 0;
- compositor->viewport.translate[3] = 0;
-
- compositor->scissor.maxx = compositor->fb_state.width;
- compositor->scissor.maxy = compositor->fb_state.height;
-
- compositor->pipe->set_framebuffer_state(compositor->pipe, &compositor->fb_state);
- compositor->pipe->set_viewport_state(compositor->pipe, &compositor->viewport);
- compositor->pipe->set_scissor_state(compositor->pipe, &compositor->scissor);
- compositor->pipe->bind_fragment_sampler_states(compositor->pipe, 1, &compositor->sampler);
- compositor->pipe->set_fragment_sampler_textures(compositor->pipe, 1, &src_surface);
- compositor->pipe->bind_vs_state(compositor->pipe, compositor->vertex_shader);
- compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
- compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
- compositor->pipe->bind_vertex_elements_state(compositor->pipe, compositor->vertex_elems);
- compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, compositor->vs_const_buf);
- compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, compositor->fs_const_buf);
-
- vs_consts = pipe_buffer_map
- (
- compositor->pipe->screen,
- compositor->vs_const_buf,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- vs_consts->dst_scale.x = dst_area->w / (float)compositor->fb_state.cbufs[0]->width;
- vs_consts->dst_scale.y = dst_area->h / (float)compositor->fb_state.cbufs[0]->height;
- vs_consts->dst_scale.z = 1;
- vs_consts->dst_scale.w = 1;
- vs_consts->dst_trans.x = dst_area->x / (float)compositor->fb_state.cbufs[0]->width;
- vs_consts->dst_trans.y = dst_area->y / (float)compositor->fb_state.cbufs[0]->height;
- vs_consts->dst_trans.z = 0;
- vs_consts->dst_trans.w = 0;
-
- vs_consts->src_scale.x = src_area->w / (float)src_surface->width0;
- vs_consts->src_scale.y = src_area->h / (float)src_surface->height0;
- vs_consts->src_scale.z = 1;
- vs_consts->src_scale.w = 1;
- vs_consts->src_trans.x = src_area->x / (float)src_surface->width0;
- vs_consts->src_trans.y = src_area->y / (float)src_surface->height0;
- vs_consts->src_trans.z = 0;
- vs_consts->src_trans.w = 0;
-
- pipe_buffer_unmap(compositor->pipe->screen, compositor->vs_const_buf);
-
- compositor->pipe->draw_arrays(compositor->pipe, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
- compositor->pipe->flush(compositor->pipe, PIPE_FLUSH_RENDER_CACHE, fence);
-
- pipe_surface_reference(&compositor->fb_state.cbufs[0], NULL);
-}
-
-void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float *mat)
-{
- assert(compositor);
-
- memcpy
- (
- pipe_buffer_map(compositor->pipe->screen, compositor->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
- mat,
- sizeof(struct fragment_shader_consts)
- );
-
- pipe_buffer_unmap(compositor->pipe->screen, compositor->fs_const_buf);
-}
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
deleted file mode 100644
index 51755554da..0000000000
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_compositor_h
-#define vl_compositor_h
-
-#include <pipe/p_compiler.h>
-#include <pipe/p_state.h>
-#include <pipe/p_video_state.h>
-
-struct pipe_context;
-struct pipe_texture;
-
-struct vl_compositor
-{
- struct pipe_context *pipe;
-
- struct pipe_framebuffer_state fb_state;
- void *sampler;
- void *vertex_shader;
- void *fragment_shader;
- void *vertex_elems;
- struct pipe_viewport_state viewport;
- struct pipe_scissor_state scissor;
- struct pipe_vertex_buffer vertex_bufs[2];
- struct pipe_buffer *vs_const_buf, *fs_const_buf;
-};
-
-bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
-
-void vl_compositor_cleanup(struct vl_compositor *compositor);
-
-void vl_compositor_render(struct vl_compositor *compositor,
- /*struct pipe_texture *backround,
- struct pipe_video_rect *backround_area,*/
- struct pipe_texture *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_texture *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_texture *future_surfaces,*/
- struct pipe_video_rect *src_area,
- struct pipe_texture *dst_surface,
- struct pipe_video_rect *dst_area,
- /*unsigned num_layers,
- struct pipe_texture *layers,
- struct pipe_video_rect *layer_src_areas,
- struct pipe_video_rect *layer_dst_areas,*/
- struct pipe_fence_handle **fence);
-
-void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float *mat);
-
-#endif /* vl_compositor_h */
diff --git a/src/gallium/auxiliary/vl/vl_csc.c b/src/gallium/auxiliary/vl/vl_csc.c
deleted file mode 100644
index 5ecc43a5fa..0000000000
--- a/src/gallium/auxiliary/vl/vl_csc.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_csc.h"
-#include <util/u_math.h>
-#include <util/u_debug.h>
-
-/*
- * Color space conversion formulas
- *
- * To convert YCbCr to RGB,
- * vec4 ycbcr, rgb
- * mat44 csc
- * rgb = csc * ycbcr
- *
- * To calculate the color space conversion matrix csc with ProcAmp adjustments,
- * mat44 csc, cstd, procamp, bias
- * csc = cstd * (procamp * bias)
- *
- * Where cstd is a matrix corresponding to one of the color standards (BT.601, BT.709, etc)
- * adjusted for the kind of YCbCr -> RGB mapping wanted (1:1, full),
- * bias is a matrix corresponding to the kind of YCbCr -> RGB mapping wanted (1:1, full)
- *
- * To calculate procamp,
- * mat44 procamp, hue, saturation, brightness, contrast
- * procamp = brightness * (saturation * (contrast * hue))
- * Alternatively,
- * procamp = saturation * (brightness * (contrast * hue))
- *
- * contrast
- * [ c, 0, 0, 0]
- * [ 0, c, 0, 0]
- * [ 0, 0, c, 0]
- * [ 0, 0, 0, 1]
- *
- * brightness
- * [ 1, 0, 0, b]
- * [ 0, 1, 0, 0]
- * [ 0, 0, 1, 0]
- * [ 0, 0, 0, 1]
- *
- * saturation
- * [ 1, 0, 0, 0]
- * [ 0, s, 0, 0]
- * [ 0, 0, s, 0]
- * [ 0, 0, 0, 1]
- *
- * hue
- * [ 1, 0, 0, 0]
- * [ 0, cos(h), sin(h), 0]
- * [ 0, -sin(h), cos(h), 0]
- * [ 0, 0, 0, 1]
- *
- * procamp
- * [ c, 0, 0, b]
- * [ 0, c*s*cos(h), c*s*sin(h), 0]
- * [ 0, -c*s*sin(h), c*s*cos(h), 0]
- * [ 0, 0, 0, 1]
- *
- * bias
- * [ 1, 0, 0, ybias]
- * [ 0, 1, 0, cbbias]
- * [ 0, 0, 1, crbias]
- * [ 0, 0, 0, 1]
- *
- * csc
- * [ c*cstd[ 0], c*cstd[ 1]*s*cos(h) - c*cstd[ 2]*s*sin(h), c*cstd[ 2]*s*cos(h) + c*cstd[ 1]*s*sin(h), cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 2]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- * [ c*cstd[ 4], c*cstd[ 5]*s*cos(h) - c*cstd[ 6]*s*sin(h), c*cstd[ 6]*s*cos(h) + c*cstd[ 5]*s*sin(h), cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 6]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- * [ c*cstd[ 8], c*cstd[ 9]*s*cos(h) - c*cstd[10]*s*sin(h), c*cstd[10]*s*cos(h) + c*cstd[ 9]*s*sin(h), cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[10]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- * [ c*cstd[12], c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h), c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h), cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- */
-
-/*
- * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [16,235]
- */
-static const float bt_601[16] =
-{
- 1.0f, 0.0f, 1.371f, 0.0f,
- 1.0f, -0.336f, -0.698f, 0.0f,
- 1.0f, 1.732f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/*
- * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [0,255]
- */
-static const float bt_601_full[16] =
-{
- 1.164f, 0.0f, 1.596f, 0.0f,
- 1.164f, -0.391f, -0.813f, 0.0f,
- 1.164f, 2.018f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/*
- * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [16,235]
- */
-static const float bt_709[16] =
-{
- 1.0f, 0.0f, 1.540f, 0.0f,
- 1.0f, -0.183f, -0.459f, 0.0f,
- 1.0f, 1.816f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/*
- * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [0,255]
- */
-static const float bt_709_full[16] =
-{
- 1.164f, 0.0f, 1.793f, 0.0f,
- 1.164f, -0.213f, -0.534f, 0.0f,
- 1.164f, 2.115f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-static const float identity[16] =
-{
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
- struct vl_procamp *procamp,
- bool full_range,
- float *matrix)
-{
- float ybias = full_range ? -16.0f/255.0f : 0.0f;
- float cbbias = -128.0f/255.0f;
- float crbias = -128.0f/255.0f;
- float c = procamp ? procamp->contrast : 1.0f;
- float s = procamp ? procamp->saturation : 1.0f;
- float b = procamp ? procamp->brightness : 0.0f;
- float h = procamp ? procamp->hue : 0.0f;
- const float *cstd;
-
- assert(matrix);
-
- switch (cs) {
- case VL_CSC_COLOR_STANDARD_BT_601:
- cstd = full_range ? &bt_601_full[0] : &bt_601[0];
- break;
- case VL_CSC_COLOR_STANDARD_BT_709:
- cstd = full_range ? &bt_709_full[0] : &bt_709[0];
- break;
- case VL_CSC_COLOR_STANDARD_IDENTITY:
- default:
- assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
- memcpy(matrix, &identity[0], sizeof(float) * 16);
- return;
- }
-
- matrix[ 0] = c*cstd[ 0];
- matrix[ 1] = c*cstd[ 1]*s*cosf(h) - c*cstd[ 2]*s*sinf(h);
- matrix[ 2] = c*cstd[ 2]*s*cosf(h) + c*cstd[ 1]*s*sinf(h);
- matrix[ 3] = cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 2]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[ 4] = c*cstd[ 4];
- matrix[ 5] = c*cstd[ 5]*s*cosf(h) - c*cstd[ 6]*s*sinf(h);
- matrix[ 6] = c*cstd[ 6]*s*cosf(h) + c*cstd[ 5]*s*sinf(h);
- matrix[ 7] = cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 6]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[ 8] = c*cstd[ 8];
- matrix[ 9] = c*cstd[ 9]*s*cosf(h) - c*cstd[10]*s*sinf(h);
- matrix[10] = c*cstd[10]*s*cosf(h) + c*cstd[ 9]*s*sinf(h);
- matrix[11] = cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[10]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[12] = c*cstd[12];
- matrix[13] = c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h);
- matrix[14] = c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h);
- matrix[15] = cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h));
-}
diff --git a/src/gallium/auxiliary/vl/vl_csc.h b/src/gallium/auxiliary/vl/vl_csc.h
deleted file mode 100644
index 722ca35f33..0000000000
--- a/src/gallium/auxiliary/vl/vl_csc.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_csc_h
-#define vl_csc_h
-
-#include <pipe/p_compiler.h>
-
-struct vl_procamp
-{
- float brightness;
- float contrast;
- float saturation;
- float hue;
-};
-
-enum VL_CSC_COLOR_STANDARD
-{
- VL_CSC_COLOR_STANDARD_IDENTITY,
- VL_CSC_COLOR_STANDARD_BT_601,
- VL_CSC_COLOR_STANDARD_BT_709
-};
-
-void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
- struct vl_procamp *procamp,
- bool full_range,
- float *matrix);
-
-#endif /* vl_csc_h */
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
deleted file mode 100644
index beb4722901..0000000000
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ /dev/null
@@ -1,1672 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_mpeg12_mc_renderer.h"
-#include <assert.h>
-#include <pipe/p_context.h>
-#include <util/u_inlines.h>
-#include <util/u_format.h>
-#include <util/u_math.h>
-#include <util/u_memory.h>
-#include <tgsi/tgsi_parse.h>
-#include <tgsi/tgsi_build.h>
-#include "vl_shader_build.h"
-
-#define DEFAULT_BUF_ALIGNMENT 1
-#define MACROBLOCK_WIDTH 16
-#define MACROBLOCK_HEIGHT 16
-#define BLOCK_WIDTH 8
-#define BLOCK_HEIGHT 8
-#define ZERO_BLOCK_NIL -1.0f
-#define ZERO_BLOCK_IS_NIL(zb) ((zb).x < 0.0f)
-
-struct vertex2f
-{
- float x, y;
-};
-
-struct vertex4f
-{
- float x, y, z, w;
-};
-
-struct vertex_shader_consts
-{
- struct vertex4f denorm;
-};
-
-struct fragment_shader_consts
-{
- struct vertex4f multiplier;
- struct vertex4f div;
-};
-
-/*
- * Muliplier renormalizes block samples from 16 bits to 12 bits.
- * Divider is used when calculating Y % 2 for choosing top or bottom
- * field for P or B macroblocks.
- * TODO: Use immediates.
- */
-static const struct fragment_shader_consts fs_consts = {
- {32767.0f / 255.0f, 32767.0f / 255.0f, 32767.0f / 255.0f, 0.0f},
- {0.5f, 2.0f, 0.0f, 0.0f}
-};
-
-struct vert_stream_0
-{
- struct vertex2f pos;
- struct vertex2f luma_tc;
- struct vertex2f cb_tc;
- struct vertex2f cr_tc;
-};
-
-enum MACROBLOCK_TYPE
-{
- MACROBLOCK_TYPE_INTRA,
- MACROBLOCK_TYPE_FWD_FRAME_PRED,
- MACROBLOCK_TYPE_FWD_FIELD_PRED,
- MACROBLOCK_TYPE_BKWD_FRAME_PRED,
- MACROBLOCK_TYPE_BKWD_FIELD_PRED,
- MACROBLOCK_TYPE_BI_FRAME_PRED,
- MACROBLOCK_TYPE_BI_FIELD_PRED,
-
- NUM_MACROBLOCK_TYPES
-};
-
-static void
-create_intra_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 50;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Luma texcoords
- * decl i2 ; Chroma Cb texcoords
- * decl i3 ; Chroma Cr texcoords
- */
- for (i = 0; i < 4; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Luma texcoords
- * decl o2 ; Chroma Cb texcoords
- * decl o3 ; Chroma Cr texcoords
- */
- for (i = 0; i < 4; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * mov o0, i0 ; Move input vertex pos to output
- * mov o1, i1 ; Move input luma texcoords to output
- * mov o2, i2 ; Move input chroma Cb texcoords to output
- * mov o3, i3 ; Move input chroma Cr texcoords to output
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- r->i_vs = r->pipe->create_vs_state(r->pipe, &vs);
- free(tokens);
-}
-
-static void
-create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Luma texcoords
- * decl i1 ; Chroma Cb texcoords
- * decl i2 ; Chroma Cr texcoords
- */
- for (i = 0; i < 3; ++i) {
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /* decl c0 ; Scaling factor, rescales 16-bit snorm to 9-bit snorm */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0, t1 */
- decl = vl_decl_temps(0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl s0 ; Sampler for luma texture
- * decl s1 ; Sampler for chroma Cb texture
- * decl s2 ; Sampler for chroma Cr texture
- */
- for (i = 0; i < 3; ++i) {
- decl = vl_decl_samplers(i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * tex2d t1, i0, s0 ; Read texel from luma texture
- * mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
- * mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
- * mov t0.z, t1.x ; Move Cr sample into .z component
- */
- for (i = 0; i < 3; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* mul o0, t0, c0 ; Rescale texel to correct range */
- inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- r->i_fs = r->pipe->create_fs_state(r->pipe, &fs);
- free(tokens);
-}
-
-static void
-create_frame_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Luma texcoords
- * decl i2 ; Chroma Cb texcoords
- * decl i3 ; Chroma Cr texcoords
- * decl i4 ; Ref surface top field texcoords
- * decl i5 ; Ref surface bottom field texcoords (unused, packed in the same stream)
- */
- for (i = 0; i < 6; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Luma texcoords
- * decl o2 ; Chroma Cb texcoords
- * decl o3 ; Chroma Cr texcoords
- * decl o4 ; Ref macroblock texcoords
- */
- for (i = 0; i < 5; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * mov o0, i0 ; Move input vertex pos to output
- * mov o1, i1 ; Move input luma texcoords to output
- * mov o2, i2 ; Move input chroma Cb texcoords to output
- * mov o3, i3 ; Move input chroma Cr texcoords to output
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* add o4, i0, i4 ; Translate vertex pos by motion vec to form ref macroblock texcoords */
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 4, TGSI_FILE_INPUT, 0, TGSI_FILE_INPUT, 4);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- r->p_vs[0] = r->pipe->create_vs_state(r->pipe, &vs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Luma texcoords
- * decl i1 ; Chroma Cb texcoords
- * decl i2 ; Chroma Cr texcoords
- * decl i3 ; Ref macroblock texcoords
- */
- for (i = 0; i < 4; ++i) {
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /* decl c0 ; Scaling factor, rescales 16-bit snorm to 9-bit snorm */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0, t1 */
- decl = vl_decl_temps(0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl s0 ; Sampler for luma texture
- * decl s1 ; Sampler for chroma Cb texture
- * decl s2 ; Sampler for chroma Cr texture
- * decl s3 ; Sampler for ref surface texture
- */
- for (i = 0; i < 4; ++i) {
- decl = vl_decl_samplers(i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * tex2d t1, i0, s0 ; Read texel from luma texture
- * mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
- * mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
- * mov t0.z, t1.x ; Move Cr sample into .z component
- */
- for (i = 0; i < 3; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* mul t0, t0, c0 ; Rescale texel to correct range */
- inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* tex2d t1, i3, s3 ; Read texel from ref macroblock */
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, 3, TGSI_FILE_SAMPLER, 3);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* add o0, t0, t1 ; Add ref and differential to form final output */
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- r->p_fs[0] = r->pipe->create_fs_state(r->pipe, &fs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Luma texcoords
- * decl i2 ; Chroma Cb texcoords
- * decl i3 ; Chroma Cr texcoords
- * decl i4 ; First ref macroblock top field texcoords
- * decl i5 ; First ref macroblock bottom field texcoords (unused, packed in the same stream)
- * decl i6 ; Second ref macroblock top field texcoords
- * decl i7 ; Second ref macroblock bottom field texcoords (unused, packed in the same stream)
- */
- for (i = 0; i < 8; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Luma texcoords
- * decl o2 ; Chroma Cb texcoords
- * decl o3 ; Chroma Cr texcoords
- * decl o4 ; First ref macroblock texcoords
- * decl o5 ; Second ref macroblock texcoords
- */
- for (i = 0; i < 6; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * mov o0, i0 ; Move input vertex pos to output
- * mov o1, i1 ; Move input luma texcoords to output
- * mov o2, i2 ; Move input chroma Cb texcoords to output
- * mov o3, i3 ; Move input chroma Cr texcoords to output
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * add o4, i0, i4 ; Translate vertex pos by motion vec to form first ref macroblock texcoords
- * add o5, i0, i6 ; Translate vertex pos by motion vec to form second ref macroblock texcoords
- */
- for (i = 0; i < 2; ++i) {
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, i + 4, TGSI_FILE_INPUT, 0, TGSI_FILE_INPUT, (i + 2) * 2);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- r->b_vs[0] = r->pipe->create_vs_state(r->pipe, &vs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Luma texcoords
- * decl i1 ; Chroma Cb texcoords
- * decl i2 ; Chroma Cr texcoords
- * decl i3 ; First ref macroblock texcoords
- * decl i4 ; Second ref macroblock texcoords
- */
- for (i = 0; i < 5; ++i) {
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl c0 ; Scaling factor, rescales 16-bit snorm to 9-bit snorm
- * decl c1 ; Constant 1/2 in .x channel to use as weight to blend past and future texels
- */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0-t2 */
- decl = vl_decl_temps(0, 2);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl s0 ; Sampler for luma texture
- * decl s1 ; Sampler for chroma Cb texture
- * decl s2 ; Sampler for chroma Cr texture
- * decl s3 ; Sampler for first ref surface texture
- * decl s4 ; Sampler for second ref surface texture
- */
- for (i = 0; i < 5; ++i) {
- decl = vl_decl_samplers(i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * tex2d t1, i0, s0 ; Read texel from luma texture
- * mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
- * mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
- * mov t0.z, t1.x ; Move Cr sample into .z component
- */
- for (i = 0; i < 3; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* mul t0, t0, c0 ; Rescale texel to correct range */
- inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /*
- * tex2d t1, i3, s3 ; Read texel from first ref macroblock
- * tex2d t2, i4, s4 ; Read texel from second ref macroblock
- */
- for (i = 0; i < 2; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, i + 1, TGSI_FILE_INPUT, i + 3, TGSI_FILE_SAMPLER, i + 3);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* lerp t1, c1.x, t1, t2 ; Blend past and future texels */
- inst = vl_inst4(TGSI_OPCODE_LRP, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_CONSTANT, 1, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_TEMPORARY, 2);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_X;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* add o0, t0, t1 ; Add past/future ref and differential to form final output */
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- r->b_fs[0] = r->pipe->create_fs_state(r->pipe, &fs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-xfer_buffers_map(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- for (i = 0; i < 3; ++i) {
- r->tex_transfer[i] = r->pipe->get_tex_transfer
- (
- r->pipe, r->textures.all[i],
- 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0,
- r->textures.all[i]->width0, r->textures.all[i]->height0
- );
-
- r->texels[i] = r->pipe->transfer_map(r->pipe, r->tex_transfer[i]);
- }
-}
-
-static void
-xfer_buffers_unmap(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- for (i = 0; i < 3; ++i) {
- r->pipe->transfer_unmap(r->pipe, r->tex_transfer[i]);
- r->pipe->tex_transfer_destroy(r->pipe, r->tex_transfer[i]);
- }
-}
-
-static bool
-init_pipe_state(struct vl_mpeg12_mc_renderer *r)
-{
- struct pipe_sampler_state sampler;
- struct pipe_vertex_element vertex_elems[8];
- unsigned filters[5];
- unsigned i;
-
- assert(r);
-
- r->viewport.scale[0] = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- r->viewport.scale[1] = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
- r->viewport.scale[2] = 1;
- r->viewport.scale[3] = 1;
- r->viewport.translate[0] = 0;
- r->viewport.translate[1] = 0;
- r->viewport.translate[2] = 0;
- r->viewport.translate[3] = 0;
-
- r->scissor.maxx = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- r->scissor.maxy = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
-
- r->fb_state.width = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- r->fb_state.height = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
- r->fb_state.nr_cbufs = 1;
- r->fb_state.zsbuf = NULL;
-
- /* Luma filter */
- filters[0] = PIPE_TEX_FILTER_NEAREST;
- /* Chroma filters */
- if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444 ||
- r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE) {
- filters[1] = PIPE_TEX_FILTER_NEAREST;
- filters[2] = PIPE_TEX_FILTER_NEAREST;
- }
- else {
- filters[1] = PIPE_TEX_FILTER_LINEAR;
- filters[2] = PIPE_TEX_FILTER_LINEAR;
- }
- /* Fwd, bkwd ref filters */
- filters[3] = PIPE_TEX_FILTER_LINEAR;
- filters[4] = PIPE_TEX_FILTER_LINEAR;
-
- for (i = 0; i < 5; ++i) {
- sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.min_img_filter = filters[i];
- sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
- sampler.mag_img_filter = filters[i];
- sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
- sampler.compare_func = PIPE_FUNC_ALWAYS;
- sampler.normalized_coords = 1;
- /*sampler.shadow_ambient = ; */
- /*sampler.lod_bias = ; */
- sampler.min_lod = 0;
- /*sampler.max_lod = ; */
- /*sampler.border_color[i] = ; */
- /*sampler.max_anisotropy = ; */
- r->samplers.all[i] = r->pipe->create_sampler_state(r->pipe, &sampler);
- }
-
- /* Position element */
- vertex_elems[0].src_offset = 0;
- vertex_elems[0].instance_divisor = 0;
- vertex_elems[0].vertex_buffer_index = 0;
- vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Luma, texcoord element */
- vertex_elems[1].src_offset = sizeof(struct vertex2f);
- vertex_elems[1].instance_divisor = 0;
- vertex_elems[1].vertex_buffer_index = 0;
- vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Chroma Cr texcoord element */
- vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2;
- vertex_elems[2].instance_divisor = 0;
- vertex_elems[2].vertex_buffer_index = 0;
- vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Chroma Cb texcoord element */
- vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3;
- vertex_elems[3].instance_divisor = 0;
- vertex_elems[3].vertex_buffer_index = 0;
- vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* First ref surface top field texcoord element */
- vertex_elems[4].src_offset = 0;
- vertex_elems[4].instance_divisor = 0;
- vertex_elems[4].vertex_buffer_index = 1;
- vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* First ref surface bottom field texcoord element */
- vertex_elems[5].src_offset = sizeof(struct vertex2f);
- vertex_elems[5].instance_divisor = 0;
- vertex_elems[5].vertex_buffer_index = 1;
- vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Second ref surface top field texcoord element */
- vertex_elems[6].src_offset = 0;
- vertex_elems[6].instance_divisor = 0;
- vertex_elems[6].vertex_buffer_index = 2;
- vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Second ref surface bottom field texcoord element */
- vertex_elems[7].src_offset = sizeof(struct vertex2f);
- vertex_elems[7].instance_divisor = 0;
- vertex_elems[7].vertex_buffer_index = 2;
- vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* need versions with 4,6 and 8 vertex elems */
- r->vertex_elems[0] = r->pipe->create_vertex_elements_state(r->pipe, 4, vertex_elems);
- r->vertex_elems[1] = r->pipe->create_vertex_elements_state(r->pipe, 6, vertex_elems);
- r->vertex_elems[2] = r->pipe->create_vertex_elements_state(r->pipe, 8, vertex_elems);
-
- return true;
-}
-
-static void
-cleanup_pipe_state(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- for (i = 0; i < 5; ++i)
- r->pipe->delete_sampler_state(r->pipe, r->samplers.all[i]);
- for (i = 0; i < 3; i++)
- r->pipe->delete_vertex_elements_state(r->pipe, r->vertex_elems[i]);
-}
-
-static bool
-init_shaders(struct vl_mpeg12_mc_renderer *r)
-{
- assert(r);
-
- create_intra_vert_shader(r);
- create_intra_frag_shader(r);
- create_frame_pred_vert_shader(r);
- create_frame_pred_frag_shader(r);
- create_frame_bi_pred_vert_shader(r);
- create_frame_bi_pred_frag_shader(r);
-
- return true;
-}
-
-static void
-cleanup_shaders(struct vl_mpeg12_mc_renderer *r)
-{
- assert(r);
-
- r->pipe->delete_vs_state(r->pipe, r->i_vs);
- r->pipe->delete_fs_state(r->pipe, r->i_fs);
- r->pipe->delete_vs_state(r->pipe, r->p_vs[0]);
- r->pipe->delete_fs_state(r->pipe, r->p_fs[0]);
- r->pipe->delete_vs_state(r->pipe, r->b_vs[0]);
- r->pipe->delete_fs_state(r->pipe, r->b_fs[0]);
-}
-
-static bool
-init_buffers(struct vl_mpeg12_mc_renderer *r)
-{
- struct pipe_texture template;
-
- const unsigned mbw =
- align(r->picture_width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
- const unsigned mbh =
- align(r->picture_height, MACROBLOCK_HEIGHT) / MACROBLOCK_HEIGHT;
-
- unsigned i;
-
- assert(r);
-
- r->macroblocks_per_batch =
- mbw * (r->bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE ? mbh : 1);
- r->num_macroblocks = 0;
- r->macroblock_buf = MALLOC(r->macroblocks_per_batch * sizeof(struct pipe_mpeg12_macroblock));
-
- memset(&template, 0, sizeof(struct pipe_texture));
- template.target = PIPE_TEXTURE_2D;
- /* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
- template.format = PIPE_FORMAT_R16_SNORM;
- template.last_level = 0;
- template.width0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- template.height0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
- template.depth0 = 1;
- template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
-
- r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
-
- if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- template.width0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_width / 2) :
- r->picture_width / 2;
- template.height0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_height / 2) :
- r->picture_height / 2;
- }
- else if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422)
- template.height0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_height / 2) :
- r->picture_height / 2;
-
- r->textures.individual.cb =
- r->pipe->screen->texture_create(r->pipe->screen, &template);
- r->textures.individual.cr =
- r->pipe->screen->texture_create(r->pipe->screen, &template);
-
- r->vertex_bufs.individual.ycbcr.stride = sizeof(struct vertex2f) * 4;
- r->vertex_bufs.individual.ycbcr.max_index = 24 * r->macroblocks_per_batch - 1;
- r->vertex_bufs.individual.ycbcr.buffer_offset = 0;
- r->vertex_bufs.individual.ycbcr.buffer = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex2f) * 4 * 24 * r->macroblocks_per_batch
- );
-
- for (i = 1; i < 3; ++i) {
- r->vertex_bufs.all[i].stride = sizeof(struct vertex2f) * 2;
- r->vertex_bufs.all[i].max_index = 24 * r->macroblocks_per_batch - 1;
- r->vertex_bufs.all[i].buffer_offset = 0;
- r->vertex_bufs.all[i].buffer = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex2f) * 2 * 24 * r->macroblocks_per_batch
- );
- }
-
- r->vs_const_buf = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_CONSTANT | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex_shader_consts)
- );
-
- r->fs_const_buf = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_CONSTANT, sizeof(struct fragment_shader_consts)
- );
-
- memcpy
- (
- pipe_buffer_map(r->pipe->screen, r->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
- &fs_consts, sizeof(struct fragment_shader_consts)
- );
-
- pipe_buffer_unmap(r->pipe->screen, r->fs_const_buf);
-
- return true;
-}
-
-static void
-cleanup_buffers(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- pipe_buffer_reference(&r->vs_const_buf, NULL);
- pipe_buffer_reference(&r->fs_const_buf, NULL);
-
- for (i = 0; i < 3; ++i)
- pipe_buffer_reference(&r->vertex_bufs.all[i].buffer, NULL);
-
- for (i = 0; i < 3; ++i)
- pipe_texture_reference(&r->textures.all[i], NULL);
-
- FREE(r->macroblock_buf);
-}
-
-static enum MACROBLOCK_TYPE
-get_macroblock_type(struct pipe_mpeg12_macroblock *mb)
-{
- assert(mb);
-
- switch (mb->mb_type) {
- case PIPE_MPEG12_MACROBLOCK_TYPE_INTRA:
- return MACROBLOCK_TYPE_INTRA;
- case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
- return mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME ?
- MACROBLOCK_TYPE_FWD_FRAME_PRED : MACROBLOCK_TYPE_FWD_FIELD_PRED;
- case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
- return mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME ?
- MACROBLOCK_TYPE_BKWD_FRAME_PRED : MACROBLOCK_TYPE_BKWD_FIELD_PRED;
- case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
- return mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME ?
- MACROBLOCK_TYPE_BI_FRAME_PRED : MACROBLOCK_TYPE_BI_FIELD_PRED;
- default:
- assert(0);
- }
-
- /* Unreachable */
- return -1;
-}
-
-/* XXX: One of these days this will have to be killed with fire */
-#define SET_BLOCK(vb, cbp, mbx, mby, unitx, unity, ofsx, ofsy, hx, hy, lm, cbm, crm, use_zb, zb) \
- do { \
- (vb)[0].pos.x = (mbx) * (unitx) + (ofsx); (vb)[0].pos.y = (mby) * (unity) + (ofsy); \
- (vb)[1].pos.x = (mbx) * (unitx) + (ofsx); (vb)[1].pos.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].pos.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].pos.y = (mby) * (unity) + (ofsy); \
- (vb)[3].pos.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].pos.y = (mby) * (unity) + (ofsy); \
- (vb)[4].pos.x = (mbx) * (unitx) + (ofsx); (vb)[4].pos.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].pos.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].pos.y = (mby) * (unity) + (ofsy) + (hy); \
- \
- if (!use_zb || (cbp) & (lm)) \
- { \
- (vb)[0].luma_tc.x = (mbx) * (unitx) + (ofsx); (vb)[0].luma_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[1].luma_tc.x = (mbx) * (unitx) + (ofsx); (vb)[1].luma_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].luma_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].luma_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[3].luma_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].luma_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[4].luma_tc.x = (mbx) * (unitx) + (ofsx); (vb)[4].luma_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].luma_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].luma_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- } \
- else \
- { \
- (vb)[0].luma_tc.x = (zb)[0].x; (vb)[0].luma_tc.y = (zb)[0].y; \
- (vb)[1].luma_tc.x = (zb)[0].x; (vb)[1].luma_tc.y = (zb)[0].y + (hy); \
- (vb)[2].luma_tc.x = (zb)[0].x + (hx); (vb)[2].luma_tc.y = (zb)[0].y; \
- (vb)[3].luma_tc.x = (zb)[0].x + (hx); (vb)[3].luma_tc.y = (zb)[0].y; \
- (vb)[4].luma_tc.x = (zb)[0].x; (vb)[4].luma_tc.y = (zb)[0].y + (hy); \
- (vb)[5].luma_tc.x = (zb)[0].x + (hx); (vb)[5].luma_tc.y = (zb)[0].y + (hy); \
- } \
- \
- if (!use_zb || (cbp) & (cbm)) \
- { \
- (vb)[0].cb_tc.x = (mbx) * (unitx) + (ofsx); (vb)[0].cb_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[1].cb_tc.x = (mbx) * (unitx) + (ofsx); (vb)[1].cb_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].cb_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].cb_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[3].cb_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].cb_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[4].cb_tc.x = (mbx) * (unitx) + (ofsx); (vb)[4].cb_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].cb_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].cb_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- } \
- else \
- { \
- (vb)[0].cb_tc.x = (zb)[1].x; (vb)[0].cb_tc.y = (zb)[1].y; \
- (vb)[1].cb_tc.x = (zb)[1].x; (vb)[1].cb_tc.y = (zb)[1].y + (hy); \
- (vb)[2].cb_tc.x = (zb)[1].x + (hx); (vb)[2].cb_tc.y = (zb)[1].y; \
- (vb)[3].cb_tc.x = (zb)[1].x + (hx); (vb)[3].cb_tc.y = (zb)[1].y; \
- (vb)[4].cb_tc.x = (zb)[1].x; (vb)[4].cb_tc.y = (zb)[1].y + (hy); \
- (vb)[5].cb_tc.x = (zb)[1].x + (hx); (vb)[5].cb_tc.y = (zb)[1].y + (hy); \
- } \
- \
- if (!use_zb || (cbp) & (crm)) \
- { \
- (vb)[0].cr_tc.x = (mbx) * (unitx) + (ofsx); (vb)[0].cr_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[1].cr_tc.x = (mbx) * (unitx) + (ofsx); (vb)[1].cr_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].cr_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].cr_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[3].cr_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].cr_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[4].cr_tc.x = (mbx) * (unitx) + (ofsx); (vb)[4].cr_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].cr_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].cr_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- } \
- else \
- { \
- (vb)[0].cr_tc.x = (zb)[2].x; (vb)[0].cr_tc.y = (zb)[2].y; \
- (vb)[1].cr_tc.x = (zb)[2].x; (vb)[1].cr_tc.y = (zb)[2].y + (hy); \
- (vb)[2].cr_tc.x = (zb)[2].x + (hx); (vb)[2].cr_tc.y = (zb)[2].y; \
- (vb)[3].cr_tc.x = (zb)[2].x + (hx); (vb)[3].cr_tc.y = (zb)[2].y; \
- (vb)[4].cr_tc.x = (zb)[2].x; (vb)[4].cr_tc.y = (zb)[2].y + (hy); \
- (vb)[5].cr_tc.x = (zb)[2].x + (hx); (vb)[5].cr_tc.y = (zb)[2].y + (hy); \
- } \
- } while (0)
-
-static void
-gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r,
- struct pipe_mpeg12_macroblock *mb, unsigned pos,
- struct vert_stream_0 *ycbcr_vb, struct vertex2f **ref_vb)
-{
- struct vertex2f mo_vec[2];
-
- unsigned i;
-
- assert(r);
- assert(mb);
- assert(ycbcr_vb);
- assert(pos < r->macroblocks_per_batch);
-
- mo_vec[1].x = 0;
- mo_vec[1].y = 0;
-
- switch (mb->mb_type) {
- case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
- {
- struct vertex2f *vb;
-
- assert(ref_vb && ref_vb[1]);
-
- vb = ref_vb[1] + pos * 2 * 24;
-
- mo_vec[0].x = mb->pmv[0][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[0].y = mb->pmv[0][1][1] * 0.5f * r->surface_tex_inv_size.y;
-
- if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- }
- }
- else {
- mo_vec[1].x = mb->pmv[1][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[1].y = mb->pmv[1][1][1] * 0.5f * r->surface_tex_inv_size.y;
-
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- vb[i + 1].x = mo_vec[1].x;
- vb[i + 1].y = mo_vec[1].y;
- }
- }
-
- /* fall-through */
- }
- case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
- case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
- {
- struct vertex2f *vb;
-
- assert(ref_vb && ref_vb[0]);
-
- vb = ref_vb[0] + pos * 2 * 24;
-
- if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD) {
- mo_vec[0].x = mb->pmv[0][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[0].y = mb->pmv[0][1][1] * 0.5f * r->surface_tex_inv_size.y;
-
- if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FIELD) {
- mo_vec[1].x = mb->pmv[1][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[1].y = mb->pmv[1][1][1] * 0.5f * r->surface_tex_inv_size.y;
- }
- }
- else {
- mo_vec[0].x = mb->pmv[0][0][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[0].y = mb->pmv[0][0][1] * 0.5f * r->surface_tex_inv_size.y;
-
- if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FIELD) {
- mo_vec[1].x = mb->pmv[1][0][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[1].y = mb->pmv[1][0][1] * 0.5f * r->surface_tex_inv_size.y;
- }
- }
-
- if (mb->mb_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- }
- }
- else {
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- vb[i + 1].x = mo_vec[1].x;
- vb[i + 1].y = mo_vec[1].y;
- }
- }
-
- /* fall-through */
- }
- case PIPE_MPEG12_MACROBLOCK_TYPE_INTRA:
- {
- const struct vertex2f unit =
- {
- r->surface_tex_inv_size.x * MACROBLOCK_WIDTH,
- r->surface_tex_inv_size.y * MACROBLOCK_HEIGHT
- };
- const struct vertex2f half =
- {
- r->surface_tex_inv_size.x * (MACROBLOCK_WIDTH / 2),
- r->surface_tex_inv_size.y * (MACROBLOCK_HEIGHT / 2)
- };
- const bool use_zb = r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE;
-
- struct vert_stream_0 *vb = ycbcr_vb + pos * 24;
-
- SET_BLOCK(vb, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, 0, 0, half.x, half.y,
- 32, 2, 1, use_zb, r->zero_block);
-
- SET_BLOCK(vb + 6, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, half.x, 0, half.x, half.y,
- 16, 2, 1, use_zb, r->zero_block);
-
- SET_BLOCK(vb + 12, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, 0, half.y, half.x, half.y,
- 8, 2, 1, use_zb, r->zero_block);
-
- SET_BLOCK(vb + 18, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, half.x, half.y, half.x, half.y,
- 4, 2, 1, use_zb, r->zero_block);
-
- break;
- }
- default:
- assert(0);
- }
-}
-
-static void
-gen_macroblock_stream(struct vl_mpeg12_mc_renderer *r,
- unsigned *num_macroblocks)
-{
- unsigned offset[NUM_MACROBLOCK_TYPES];
- struct vert_stream_0 *ycbcr_vb;
- struct vertex2f *ref_vb[2];
- unsigned i;
-
- assert(r);
- assert(num_macroblocks);
-
- for (i = 0; i < r->num_macroblocks; ++i) {
- enum MACROBLOCK_TYPE mb_type = get_macroblock_type(&r->macroblock_buf[i]);
- ++num_macroblocks[mb_type];
- }
-
- offset[0] = 0;
-
- for (i = 1; i < NUM_MACROBLOCK_TYPES; ++i)
- offset[i] = offset[i - 1] + num_macroblocks[i - 1];
-
- ycbcr_vb = (struct vert_stream_0 *)pipe_buffer_map
- (
- r->pipe->screen,
- r->vertex_bufs.individual.ycbcr.buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- for (i = 0; i < 2; ++i)
- ref_vb[i] = (struct vertex2f *)pipe_buffer_map
- (
- r->pipe->screen,
- r->vertex_bufs.individual.ref[i].buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- for (i = 0; i < r->num_macroblocks; ++i) {
- enum MACROBLOCK_TYPE mb_type = get_macroblock_type(&r->macroblock_buf[i]);
-
- gen_macroblock_verts(r, &r->macroblock_buf[i], offset[mb_type],
- ycbcr_vb, ref_vb);
-
- ++offset[mb_type];
- }
-
- pipe_buffer_unmap(r->pipe->screen, r->vertex_bufs.individual.ycbcr.buffer);
- for (i = 0; i < 2; ++i)
- pipe_buffer_unmap(r->pipe->screen, r->vertex_bufs.individual.ref[i].buffer);
-}
-
-static void
-flush(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned num_macroblocks[NUM_MACROBLOCK_TYPES] = { 0 };
- unsigned vb_start = 0;
- struct vertex_shader_consts *vs_consts;
- unsigned i;
-
- assert(r);
- assert(r->num_macroblocks == r->macroblocks_per_batch);
-
- gen_macroblock_stream(r, num_macroblocks);
-
- r->fb_state.cbufs[0] = r->pipe->screen->get_tex_surface
- (
- r->pipe->screen, r->surface,
- 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE
- );
-
- r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
- r->pipe->set_viewport_state(r->pipe, &r->viewport);
- r->pipe->set_scissor_state(r->pipe, &r->scissor);
-
- vs_consts = pipe_buffer_map
- (
- r->pipe->screen, r->vs_const_buf,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- vs_consts->denorm.x = r->surface->width0;
- vs_consts->denorm.y = r->surface->height0;
-
- pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf);
-
- r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
- r->vs_const_buf);
- r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_FRAGMENT, 0,
- r->fs_const_buf);
-
- if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[0]);
- r->pipe->set_fragment_sampler_textures(r->pipe, 3, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 3, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->i_vs);
- r->pipe->bind_fs_state(r->pipe, r->i_fs);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24;
- }
-
- if (num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->past;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24;
- }
-
- if (false /*num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] > 0 */ ) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->past;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24;
- }
-
- if (num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24;
- }
-
- if (false /*num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] > 0 */ ) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24;
- }
-
- if (num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[2]);
- r->textures.individual.ref[0] = r->past;
- r->textures.individual.ref[1] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->b_vs[0]);
- r->pipe->bind_fs_state(r->pipe, r->b_fs[0]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24;
- }
-
- if (false /*num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] > 0 */ ) {
- r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[2]);
- r->textures.individual.ref[0] = r->past;
- r->textures.individual.ref[1] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->b_vs[1]);
- r->pipe->bind_fs_state(r->pipe, r->b_fs[1]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24;
- }
-
- r->pipe->flush(r->pipe, PIPE_FLUSH_RENDER_CACHE, r->fence);
- pipe_surface_reference(&r->fb_state.cbufs[0], NULL);
-
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE)
- for (i = 0; i < 3; ++i)
- r->zero_block[i].x = ZERO_BLOCK_NIL;
-
- r->num_macroblocks = 0;
-}
-
-static void
-grab_frame_coded_block(short *src, short *dst, unsigned dst_pitch)
-{
- unsigned y;
-
- assert(src);
- assert(dst);
-
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- memcpy(dst + y * dst_pitch, src + y * BLOCK_WIDTH, BLOCK_WIDTH * 2);
-}
-
-static void
-grab_field_coded_block(short *src, short *dst, unsigned dst_pitch)
-{
- unsigned y;
-
- assert(src);
- assert(dst);
-
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- memcpy(dst + y * dst_pitch * 2, src + y * BLOCK_WIDTH, BLOCK_WIDTH * 2);
-}
-
-static void
-fill_zero_block(short *dst, unsigned dst_pitch)
-{
- unsigned y;
-
- assert(dst);
-
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- memset(dst + y * dst_pitch, 0, BLOCK_WIDTH * 2);
-}
-
-static void
-grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
- enum pipe_mpeg12_dct_type dct_type, unsigned cbp, short *blocks)
-{
- unsigned tex_pitch;
- short *texels;
- unsigned tb = 0, sb = 0;
- unsigned mbpx = mbx * MACROBLOCK_WIDTH, mbpy = mby * MACROBLOCK_HEIGHT;
- unsigned x, y;
-
- assert(r);
- assert(blocks);
-
- tex_pitch = r->tex_transfer[0]->stride / util_format_get_blocksize(r->tex_transfer[0]->texture->format);
- texels = r->texels[0] + mbpy * tex_pitch + mbpx;
-
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x, ++tb) {
- if ((cbp >> (5 - tb)) & 1) {
- if (dct_type == PIPE_MPEG12_DCT_TYPE_FRAME) {
- grab_frame_coded_block(blocks + sb * BLOCK_WIDTH * BLOCK_HEIGHT,
- texels + y * tex_pitch * BLOCK_WIDTH +
- x * BLOCK_WIDTH, tex_pitch);
- }
- else {
- grab_field_coded_block(blocks + sb * BLOCK_WIDTH * BLOCK_HEIGHT,
- texels + y * tex_pitch + x * BLOCK_WIDTH,
- tex_pitch);
- }
-
- ++sb;
- }
- else if (r->eb_handling != VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE) {
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL ||
- ZERO_BLOCK_IS_NIL(r->zero_block[0])) {
- fill_zero_block(texels + y * tex_pitch * BLOCK_WIDTH + x * BLOCK_WIDTH, tex_pitch);
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE) {
- r->zero_block[0].x = (mbpx + x * 8) * r->surface_tex_inv_size.x;
- r->zero_block[0].y = (mbpy + y * 8) * r->surface_tex_inv_size.y;
- }
- }
- }
- }
- }
-
- /* TODO: Implement 422, 444 */
- assert(r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
-
- mbpx /= 2;
- mbpy /= 2;
-
- for (tb = 0; tb < 2; ++tb) {
- tex_pitch = r->tex_transfer[tb + 1]->stride / util_format_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
- texels = r->texels[tb + 1] + mbpy * tex_pitch + mbpx;
-
- if ((cbp >> (1 - tb)) & 1) {
- grab_frame_coded_block(blocks + sb * BLOCK_WIDTH * BLOCK_HEIGHT, texels, tex_pitch);
- ++sb;
- }
- else if (r->eb_handling != VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE) {
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL ||
- ZERO_BLOCK_IS_NIL(r->zero_block[tb + 1])) {
- fill_zero_block(texels, tex_pitch);
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE) {
- r->zero_block[tb + 1].x = (mbpx << 1) * r->surface_tex_inv_size.x;
- r->zero_block[tb + 1].y = (mbpy << 1) * r->surface_tex_inv_size.y;
- }
- }
- }
- }
-}
-
-static void
-grab_macroblock(struct vl_mpeg12_mc_renderer *r,
- struct pipe_mpeg12_macroblock *mb)
-{
- assert(r);
- assert(mb);
- assert(r->num_macroblocks < r->macroblocks_per_batch);
-
- memcpy(&r->macroblock_buf[r->num_macroblocks], mb,
- sizeof(struct pipe_mpeg12_macroblock));
-
- grab_blocks(r, mb->mbx, mb->mby, mb->dct_type, mb->cbp, mb->blocks);
-
- ++r->num_macroblocks;
-}
-
-bool
-vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
- struct pipe_context *pipe,
- unsigned picture_width,
- unsigned picture_height,
- enum pipe_video_chroma_format chroma_format,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
- enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
- bool pot_buffers)
-{
- unsigned i;
-
- assert(renderer);
- assert(pipe);
- /* TODO: Implement other policies */
- assert(bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE);
- /* TODO: Implement this */
- /* XXX: XFER_ALL sampling issue at block edges when using bilinear filtering */
- assert(eb_handling != VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE);
- /* TODO: Non-pot buffers untested, probably doesn't work without changes to texcoord generation, vert shader, etc */
- assert(pot_buffers);
-
- memset(renderer, 0, sizeof(struct vl_mpeg12_mc_renderer));
-
- renderer->pipe = pipe;
- renderer->picture_width = picture_width;
- renderer->picture_height = picture_height;
- renderer->chroma_format = chroma_format;
- renderer->bufmode = bufmode;
- renderer->eb_handling = eb_handling;
- renderer->pot_buffers = pot_buffers;
-
- if (!init_pipe_state(renderer))
- return false;
- if (!init_shaders(renderer)) {
- cleanup_pipe_state(renderer);
- return false;
- }
- if (!init_buffers(renderer)) {
- cleanup_shaders(renderer);
- cleanup_pipe_state(renderer);
- return false;
- }
-
- renderer->surface = NULL;
- renderer->past = NULL;
- renderer->future = NULL;
- for (i = 0; i < 3; ++i)
- renderer->zero_block[i].x = ZERO_BLOCK_NIL;
- renderer->num_macroblocks = 0;
-
- xfer_buffers_map(renderer);
-
- return true;
-}
-
-void
-vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer)
-{
- assert(renderer);
-
- xfer_buffers_unmap(renderer);
-
- cleanup_pipe_state(renderer);
- cleanup_shaders(renderer);
- cleanup_buffers(renderer);
-}
-
-void
-vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
- *renderer,
- struct pipe_texture *surface,
- struct pipe_texture *past,
- struct pipe_texture *future,
- unsigned num_macroblocks,
- struct pipe_mpeg12_macroblock
- *mpeg12_macroblocks,
- struct pipe_fence_handle **fence)
-{
- bool new_surface = false;
-
- assert(renderer);
- assert(surface);
- assert(num_macroblocks);
- assert(mpeg12_macroblocks);
-
- if (renderer->surface) {
- if (surface != renderer->surface) {
- if (renderer->num_macroblocks > 0) {
- xfer_buffers_unmap(renderer);
- flush(renderer);
- }
-
- new_surface = true;
- }
-
- /* If the surface we're rendering hasn't changed the ref frames shouldn't change. */
- assert(surface != renderer->surface || renderer->past == past);
- assert(surface != renderer->surface || renderer->future == future);
- }
- else
- new_surface = true;
-
- if (new_surface) {
- renderer->surface = surface;
- renderer->past = past;
- renderer->future = future;
- renderer->fence = fence;
- renderer->surface_tex_inv_size.x = 1.0f / surface->width0;
- renderer->surface_tex_inv_size.y = 1.0f / surface->height0;
- }
-
- while (num_macroblocks) {
- unsigned left_in_batch = renderer->macroblocks_per_batch - renderer->num_macroblocks;
- unsigned num_to_submit = MIN2(num_macroblocks, left_in_batch);
- unsigned i;
-
- for (i = 0; i < num_to_submit; ++i) {
- assert(mpeg12_macroblocks[i].base.codec == PIPE_VIDEO_CODEC_MPEG12);
- grab_macroblock(renderer, &mpeg12_macroblocks[i]);
- }
-
- num_macroblocks -= num_to_submit;
-
- if (renderer->num_macroblocks == renderer->macroblocks_per_batch) {
- xfer_buffers_unmap(renderer);
- flush(renderer);
- xfer_buffers_map(renderer);
- /* Next time we get this surface it may have new ref frames */
- renderer->surface = NULL;
- }
- }
-}
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
deleted file mode 100644
index a11a3e7307..0000000000
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_mpeg12_mc_renderer_h
-#define vl_mpeg12_mc_renderer_h
-
-#include <pipe/p_compiler.h>
-#include <pipe/p_state.h>
-#include <pipe/p_video_state.h>
-
-struct pipe_context;
-struct pipe_video_surface;
-struct pipe_macroblock;
-
-/* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
-enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
-{
- VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
- VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
-};
-
-enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK
-{
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL, /* Waste of memory bandwidth */
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE, /* Can only do point-filtering when interpolating subsampled chroma channels */
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE /* Needs conditional texel fetch! */
-};
-
-struct vl_mpeg12_mc_renderer
-{
- struct pipe_context *pipe;
- unsigned picture_width;
- unsigned picture_height;
- enum pipe_video_chroma_format chroma_format;
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
- enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling;
- bool pot_buffers;
- unsigned macroblocks_per_batch;
-
- struct pipe_viewport_state viewport;
- struct pipe_scissor_state scissor;
- struct pipe_buffer *vs_const_buf;
- struct pipe_buffer *fs_const_buf;
- struct pipe_framebuffer_state fb_state;
- void *vertex_elems[3];
-
- union
- {
- void *all[5];
- struct { void *y, *cb, *cr, *ref[2]; } individual;
- } samplers;
-
- void *i_vs, *p_vs[2], *b_vs[2];
- void *i_fs, *p_fs[2], *b_fs[2];
-
- union
- {
- struct pipe_texture *all[5];
- struct { struct pipe_texture *y, *cb, *cr, *ref[2]; } individual;
- } textures;
-
- union
- {
- struct pipe_vertex_buffer all[3];
- struct { struct pipe_vertex_buffer ycbcr, ref[2]; } individual;
- } vertex_bufs;
-
- struct pipe_texture *surface, *past, *future;
- struct pipe_fence_handle **fence;
- unsigned num_macroblocks;
- struct pipe_mpeg12_macroblock *macroblock_buf;
- struct pipe_transfer *tex_transfer[3];
- short *texels[3];
- struct { float x, y; } surface_tex_inv_size;
- struct { float x, y; } zero_block[3];
-};
-
-bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
- struct pipe_context *pipe,
- unsigned picture_width,
- unsigned picture_height,
- enum pipe_video_chroma_format chroma_format,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
- enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
- bool pot_buffers);
-
-void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
-
-void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
- struct pipe_texture *surface,
- struct pipe_texture *past,
- struct pipe_texture *future,
- unsigned num_macroblocks,
- struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
- struct pipe_fence_handle **fence);
-
-#endif /* vl_mpeg12_mc_renderer_h */
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.c b/src/gallium/auxiliary/vl/vl_shader_build.c
deleted file mode 100644
index d011ef97bd..0000000000
--- a/src/gallium/auxiliary/vl/vl_shader_build.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_shader_build.h"
-#include <assert.h>
-#include <tgsi/tgsi_parse.h>
-#include <tgsi/tgsi_build.h>
-
-struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_INPUT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_interpolated_input
-(
- unsigned int name,
- unsigned int index,
- unsigned int first,
- unsigned int last,
- int interpolation
-)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- assert
- (
- interpolation == TGSI_INTERPOLATE_CONSTANT ||
- interpolation == TGSI_INTERPOLATE_LINEAR ||
- interpolation == TGSI_INTERPOLATE_PERSPECTIVE
- );
-
- decl.Declaration.File = TGSI_FILE_INPUT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Declaration.Interpolate = interpolation;;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_CONSTANT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_OUTPUT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_instruction vl_inst2
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src_file,
- unsigned int src_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = opcode;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 1;
- inst.Src[0].Register.File = src_file;
- inst.Src[0].Register.Index = src_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_inst3
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = opcode;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 2;
- inst.Src[0].Register.File = src1_file;
- inst.Src[0].Register.Index = src1_index;
- inst.Src[1].Register.File = src2_file;
- inst.Src[1].Register.Index = src2_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_tex
-(
- int tex,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = TGSI_OPCODE_TEX;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 2;
- inst.Instruction.Texture = 1;
- inst.Texture.Texture = tex;
- inst.Src[0].Register.File = src1_file;
- inst.Src[0].Register.Index = src1_index;
- inst.Src[1].Register.File = src2_file;
- inst.Src[1].Register.Index = src2_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_inst4
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index,
- enum tgsi_file_type src3_file,
- unsigned int src3_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = opcode;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 3;
- inst.Src[0].Register.File = src1_file;
- inst.Src[0].Register.Index = src1_index;
- inst.Src[1].Register.File = src2_file;
- inst.Src[1].Register.Index = src2_index;
- inst.Src[2].Register.File = src3_file;
- inst.Src[2].Register.Index = src3_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_end(void)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = TGSI_OPCODE_END;
- inst.Instruction.NumDstRegs = 0;
- inst.Instruction.NumSrcRegs = 0;
-
- return inst;
-}
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.h b/src/gallium/auxiliary/vl/vl_shader_build.h
deleted file mode 100644
index 5da71f8e13..0000000000
--- a/src/gallium/auxiliary/vl/vl_shader_build.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_shader_build_h
-#define vl_shader_build_h
-
-#include <pipe/p_shader_tokens.h>
-
-struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_interpolated_input
-(
- unsigned int name,
- unsigned int index,
- unsigned int first,
- unsigned int last,
- int interpolation
-);
-struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last);
-struct tgsi_full_instruction vl_inst2
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src_file,
- unsigned int src_index
-);
-struct tgsi_full_instruction vl_inst3
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-);
-struct tgsi_full_instruction vl_tex
-(
- int tex,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-);
-struct tgsi_full_instruction vl_inst4
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index,
- enum tgsi_file_type src3_file,
- unsigned int src3_index
-);
-struct tgsi_full_instruction vl_end(void);
-
-#endif