#include "st_cb_program.h"
#include "st_mesa_to_tgsi.h"
#include "st_texture.h"
+#include "st_inlines.h"
+
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
GLfloat color[4];
struct pipe_texture *texture;
- struct pipe_surface *surf;
+ struct pipe_transfer *trans;
GLboolean empty;
/* KIL if -tmp0 < 0 # texel=0 -> keep / texel=0 -> discard */
p->Instructions[ic].Opcode = OPCODE_KIL;
p->Instructions[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
+
+ if (ctx->st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM)
+ p->Instructions[ic].SrcReg[0].Swizzle = SWIZZLE_XXXX;
+
p->Instructions[ic].SrcReg[0].Index = 0;
- p->Instructions[ic].SrcReg[0].NegateBase = NEGATE_XYZW;
+ p->Instructions[ic].SrcReg[0].Negate = NEGATE_XYZW;
ic++;
/* END; */
stfp = (struct st_fragment_program *) p;
stfp->Base.UsesKill = GL_TRUE;
- st_translate_fragment_program(ctx->st, stfp, NULL);
+
+ /* No need to send this incomplete program down to hardware:
+ *
+ * st_translate_fragment_program(ctx->st, stfp, NULL);
+ */
return stfp;
}
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
ubyte *dest;
struct pipe_texture *pt;
* Create texture to hold bitmap pattern.
*/
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format,
- 0, width, height, 1, 0,
+ 0, width, height, 1,
PIPE_TEXTURE_USAGE_SAMPLER);
if (!pt) {
_mesa_unmap_bitmap_pbo(ctx, unpack);
return NULL;
}
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = st_no_flush_get_tex_transfer(st_context(ctx), pt, 0, 0, 0,
+ PIPE_TRANSFER_WRITE,
+ 0, 0, width, height);
- /* map texture surface */
- dest = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
+ dest = screen->transfer_map(screen, transfer);
- /* Put image into texture surface */
- memset(dest, 0xff, height * surface->stride);
+ /* Put image into texture transfer */
+ memset(dest, 0xff, height * transfer->stride);
unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap,
- dest, surface->stride);
+ dest, transfer->stride);
_mesa_unmap_bitmap_pbo(ctx, unpack);
- /* Release surface */
- screen->surface_unmap(screen, surface);
- pipe_surface_reference(&surface, NULL);
+ /* Release transfer */
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_destroy(transfer);
return pt;
}
GLuint i;
if (st->bitmap.vbuf_slot >= max_slots) {
- pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL);
+ pipe_buffer_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf_slot = 0;
}
}
/* put vertex data into vbuf */
- {
- char *buf = pipe_buffer_map(pipe->screen,
- st->bitmap.vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- memcpy(buf + st->bitmap.vbuf_slot * sizeof st->bitmap.vertices,
- st->bitmap.vertices,
- sizeof st->bitmap.vertices);
-
- pipe_buffer_unmap(pipe->screen, st->bitmap.vbuf);
- }
+ st_no_flush_pipe_buffer_write(st,
+ st->bitmap.vbuf,
+ st->bitmap.vbuf_slot * sizeof st->bitmap.vertices,
+ sizeof st->bitmap.vertices,
+ st->bitmap.vertices);
return st->bitmap.vbuf_slot++ * sizeof st->bitmap.vertices;
}
cache->ymin = 1000000;
cache->ymax = -1000000;
- if (cache->surf)
- screen->tex_surface_release(screen, &cache->surf);
+ if (cache->trans) {
+ screen->tex_transfer_destroy(cache->trans);
+ cache->trans = NULL;
+ }
assert(!cache->texture);
cache->texture = st_texture_create(st, PIPE_TEXTURE_2D,
st->bitmap.tex_format, 0,
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
- 1, 0,
- PIPE_TEXTURE_USAGE_SAMPLER);
+ 1, PIPE_TEXTURE_USAGE_SAMPLER);
+
+}
+
+static void
+create_cache_trans(struct st_context *st)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ struct bitmap_cache *cache = st->bitmap.cache;
+
+ if (cache->trans)
+ return;
- /* Map the texture surface.
+ /* Map the texture transfer.
* Subsequent glBitmap calls will write into the texture image.
*/
- cache->surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- cache->buffer = screen->surface_map(screen, cache->surf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ cache->trans = st_no_flush_get_tex_transfer(st, cache->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ BITMAP_CACHE_WIDTH,
+ BITMAP_CACHE_HEIGHT);
+ cache->buffer = screen->transfer_map(screen, cache->trans);
/* init image to all 0xff */
- memset(cache->buffer, 0xff, BITMAP_CACHE_WIDTH * BITMAP_CACHE_HEIGHT);
+ memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
}
cache->xpos, cache->ypos);
*/
- /* The texture surface has been mapped until now.
- * So unmap and release the texture surface before drawing.
+ /* The texture transfer has been mapped until now.
+ * So unmap and release the texture transfer before drawing.
*/
- screen->surface_unmap(screen, cache->surf);
- cache->buffer = NULL;
+ if (cache->trans) {
+ screen->transfer_unmap(screen, cache->trans);
+ cache->buffer = NULL;
- screen->tex_surface_release(screen, &cache->surf);
+ screen->tex_transfer_destroy(cache->trans);
+ cache->trans = NULL;
+ }
draw_bitmap_quad(st->ctx,
cache->xpos,
/* Release vertex buffer to avoid synchronous rendering if we were
* to map it in the next frame.
*/
- pipe_buffer_reference(st->pipe->screen, &st->bitmap.vbuf, NULL);
+ pipe_buffer_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf_slot = 0;
}
if (y + height > cache->ymax)
cache->ymax = y + height;
+ /* create the transfer if needed */
+ create_cache_trans(st);
+
unpack_bitmap(st, px, py, width, height, unpack, bitmap,
cache->buffer, BITMAP_CACHE_WIDTH);
const uint semantic_indexes[] = { 0, 0, 0 };
st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3,
semantic_names,
- semantic_indexes,
- &st->bitmap.vert_shader);
+ semantic_indexes);
}
if (UseBitmapCache && accum_bitmap(st, x, y, width, height, unpack, bitmap))
/* init baseline rasterizer state once */
memset(&st->bitmap.rasterizer, 0, sizeof(st->bitmap.rasterizer));
st->bitmap.rasterizer.gl_rasterization_rules = 1;
- st->bitmap.rasterizer.bypass_vs = 1;
/* find a usable texture format */
if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
}
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM;
+ }
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
+ }
else {
/* XXX support more formats */
assert(0);
struct pipe_screen *screen = pipe->screen;
struct bitmap_cache *cache = st->bitmap.cache;
- screen->surface_unmap(screen, cache->surf);
- screen->tex_surface_release(screen, &cache->surf);
+
if (st->bitmap.vs) {
cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
}
if (st->bitmap.vbuf) {
- pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL);
+ pipe_buffer_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf = NULL;
}
- if (st->bitmap.cache) {
- pipe_texture_release(&st->bitmap.cache->texture);
+ if (cache) {
+ if (cache->trans) {
+ screen->transfer_unmap(screen, cache->trans);
+ screen->tex_transfer_destroy(cache->trans);
+ }
+ pipe_texture_reference(&st->bitmap.cache->texture, NULL);
_mesa_free(st->bitmap.cache);
st->bitmap.cache = NULL;
}