#include "main/image.h"
#include "main/bufferobj.h"
#include "main/macros.h"
+#include "main/mfeatures.h"
+#include "main/pbo.h"
#include "program/program.h"
#include "program/prog_print.h"
}
+static struct gl_program *
+make_bitmap_fragment_program_glsl(struct st_context *st,
+ struct st_fragment_program *orig,
+ GLuint samplerIndex)
+{
+ struct gl_context *ctx = st->ctx;
+ struct st_fragment_program *fp = (struct st_fragment_program *)
+ ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+
+ if (!fp)
+ return NULL;
+
+ get_bitmap_visitor(fp, orig->glsl_to_tgsi, samplerIndex);
+ return &fp->Base.Base;
+}
+
+
static int
find_free_bit(uint bitfield)
{
GLuint *bitmap_sampler)
{
struct st_fragment_program *bitmap_prog;
+ struct st_fragment_program *stfpIn = (struct st_fragment_program *) fpIn;
struct gl_program *newProg;
uint sampler;
* with the bitmap sampler/kill instructions.
*/
sampler = find_free_bit(fpIn->Base.SamplersUsed);
- bitmap_prog = make_bitmap_fragment_program(st->ctx, sampler);
+
+ if (stfpIn->glsl_to_tgsi)
+ newProg = make_bitmap_fragment_program_glsl(st, stfpIn, sampler);
+ else {
+ bitmap_prog = make_bitmap_fragment_program(st->ctx, sampler);
- newProg = _mesa_combine_programs(st->ctx,
- &bitmap_prog->Base.Base,
- &fpIn->Base);
- /* done with this after combining */
- st_reference_fragprog(st, &bitmap_prog, NULL);
+ newProg = _mesa_combine_programs(st->ctx,
+ &bitmap_prog->Base.Base,
+ &fpIn->Base);
+ /* done with this after combining */
+ st_reference_fragprog(st, &bitmap_prog, NULL);
+ }
#if 0
{
* Create texture to hold bitmap pattern.
*/
pt = st_texture_create(st, st->internal_target, st->bitmap.tex_format,
- 0, width, height, 1,
+ 0, width, height, 1, 1,
PIPE_BIND_SAMPLER_VIEW);
if (!pt) {
_mesa_unmap_pbo_source(ctx, unpack);
if(!normalized)
{
- sRight = width;
- tBot = height;
+ sRight = (GLfloat) width;
+ tBot = (GLfloat) height;
}
/* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
if (!st->bitmap.vbuf) {
st->bitmap.vbuf = pipe_buffer_create(pipe->screen,
PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STREAM,
max_slots *
sizeof(st->bitmap.vertices));
}
/* same for all verts: */
for (i = 0; i < 4; i++) {
st->bitmap.vertices[i][0][2] = z;
- st->bitmap.vertices[i][0][3] = 1.0;
+ st->bitmap.vertices[i][0][3] = 1.0f;
st->bitmap.vertices[i][1][0] = color[0];
st->bitmap.vertices[i][1][1] = color[1];
st->bitmap.vertices[i][1][2] = color[2];
cso_save_fragment_shader(cso);
cso_save_vertex_shader(cso);
cso_save_vertex_elements(cso);
+ cso_save_vertex_buffers(cso);
/* rasterizer state: just scissor */
st->bitmap.rasterizer.scissor = ctx->Scissor.Enabled;
cso_set_vertex_elements(cso, 3, st->velems_util_draw);
/* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */
- z = z * 2.0 - 1.0;
+ z = z * 2.0f - 1.0f;
/* draw textured quad */
offset = setup_bitmap_vertex_data(st,
sv->texture->target != PIPE_TEXTURE_RECT,
x, y, width, height, z, color);
- util_draw_vertex_buffer(pipe, st->bitmap.vbuf, offset,
+ util_draw_vertex_buffer(pipe, st->cso_context, st->bitmap.vbuf, offset,
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
3); /* attribs/vert */
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
cso_restore_vertex_elements(cso);
+ cso_restore_vertex_buffers(cso);
}
cache->texture = st_texture_create(st, PIPE_TEXTURE_2D,
st->bitmap.tex_format, 0,
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
- 1,
+ 1, 1,
PIPE_BIND_SAMPLER_VIEW);
}
/* find a usable texture format */
if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM,
PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
+ PIPE_BIND_SAMPLER_VIEW)) {
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
}
else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM,
PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
+ PIPE_BIND_SAMPLER_VIEW)) {
st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM;
}
else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM,
PIPE_TEXTURE_2D, 0,
- PIPE_BIND_SAMPLER_VIEW, 0)) {
+ PIPE_BIND_SAMPLER_VIEW)) {
st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
}
else {