#include "main/macros.h"
#include "main/texformat.h"
#include "main/texstore.h"
-#include "main/state.h"
#include "shader/program.h"
-#include "shader/prog_parameter.h"
#include "shader/prog_print.h"
#include "st_debug.h"
#include "st_context.h"
#include "st_atom.h"
#include "st_atom_constbuf.h"
-#include "st_draw.h"
#include "st_program.h"
#include "st_cb_drawpixels.h"
#include "st_cb_readpixels.h"
#include "st_cb_fbo.h"
-#include "st_cb_texture.h"
-#include "st_draw.h"
#include "st_format.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"
+#include "util/u_inlines.h"
#include "tgsi/tgsi_ureg.h"
#include "util/u_tile.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_rect.h"
#include "shader/prog_instruction.h"
/**
* Make fragment shader for glDraw/CopyPixels. This shader is made
* by combining the pixel transfer shader with the user-defined shader.
+ * \return pointer to Gallium driver fragment shader
*/
-static struct st_fragment_program *
+static void *
combined_drawpix_fragment_program(GLcontext *ctx)
{
struct st_context *st = st_context(ctx);
*/
if (is_passthrough_program(&st->fp->Base)) {
stfp = (struct st_fragment_program *)
- _mesa_clone_program(ctx, &st->pixel_xfer.program->Base.Base);
+ _mesa_clone_fragment_program(ctx, &st->pixel_xfer.program->Base);
}
else {
#if 0
#endif
/* translate to TGSI tokens */
- st_translate_fragment_program(st, stfp, NULL);
+ st_translate_fragment_program(st, stfp);
/* save new program, update serial numbers */
st->pixel_xfer.xfer_prog_sn = st->pixel_xfer.program->serialNo;
*/
st_upload_constants(st, stfp->Base.Base.Parameters, PIPE_SHADER_FRAGMENT);
- return stfp;
+ return stfp->driver_shader;
}
* Create fragment shader that does a TEX() instruction to get a Z
* value, then writes to FRAG_RESULT_DEPTH.
* Pass fragment color through as-is.
+ * \return pointer to the Gallium driver fragment shader
*/
-static struct st_fragment_program *
+static void *
make_fragment_shader_z(struct st_context *st)
{
GLcontext *ctx = st->ctx;
GLuint ic = 0;
if (st->drawpix.z_shader) {
- return st->drawpix.z_shader;
+ return st->drawpix.z_shader->driver_shader;
}
/*
p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
st->drawpix.z_shader = (struct st_fragment_program *) p;
- st_translate_fragment_program(st, st->drawpix.z_shader, NULL);
+ st_translate_fragment_program(st, st->drawpix.z_shader);
- return st->drawpix.z_shader;
+ return st->drawpix.z_shader->driver_shader;
}
struct pipe_texture *textures[2];
textures[0] = pt;
textures[1] = st->pixel_xfer.pixelmap_texture;
- pipe->set_sampler_textures(pipe, 2, textures);
+ pipe->set_fragment_sampler_textures(pipe, 2, textures);
}
else {
- pipe->set_sampler_textures(pipe, 1, &pt);
+ pipe->set_fragment_sampler_textures(pipe, 1, &pt);
}
/* Compute window coords (y=0=bottom) with pixel zoom.
y1 = y + height * ctx->Pixel.ZoomY;
draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex,
- (GLfloat) width / pt->width[0],
- (GLfloat) height / pt->height[0]);
+ (GLfloat) width / pt->width0,
+ (GLfloat) height / pt->height0);
/* restore state */
cso_restore_rasterizer(cso);
}
if(format != GL_DEPTH_STENCIL &&
- pf_get_component_bits( strb->format, PIPE_FORMAT_COMP_Z ) != 0)
+ util_format_get_component_bits(strb->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
usage = PIPE_TRANSFER_READ_WRITE;
else
usage = PIPE_TRANSFER_WRITE;
}
/* now pack the stencil (and Z) values in the dest format */
- switch (pt->format) {
+ switch (pt->texture->format) {
case PIPE_FORMAT_S8_UNORM:
{
ubyte *dest = stmap + spanY * pt->stride + spanX;
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels)
{
- struct st_fragment_program *stfp;
- void *driver_vp;
+ void *driver_vp, *driver_fp;
struct st_context *st = st_context(ctx);
- struct pipe_surface *ps;
const GLfloat *color;
if (format == GL_STENCIL_INDEX ||
st_validate_state(st);
if (format == GL_DEPTH_COMPONENT) {
- ps = st->state.framebuffer.zsbuf;
- stfp = make_fragment_shader_z(st);
+ driver_fp = make_fragment_shader_z(st);
driver_vp = st_make_passthrough_vertex_shader(st, GL_TRUE);
color = ctx->Current.RasterColor;
}
else {
- ps = st->state.framebuffer.cbufs[0];
- stfp = combined_drawpix_fragment_program(ctx);
+ driver_fp = combined_drawpix_fragment_program(ctx);
driver_vp = st_make_passthrough_vertex_shader(st, GL_FALSE);
color = NULL;
}
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
pt,
driver_vp,
- stfp->driver_shader,
+ driver_fp,
color, GL_FALSE);
pipe_texture_reference(&pt, NULL);
}
GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
&ctx->DefaultPacking, buffer);
- if(pf_get_component_bits( rbDraw->format, PIPE_FORMAT_COMP_Z ) != 0)
+ if(util_format_get_component_bits(rbDraw->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
usage = PIPE_TRANSFER_READ_WRITE;
else
usage = PIPE_TRANSFER_WRITE;
usage, dstx, dsty,
width, height);
- assert(ptDraw->block.width == 1);
- assert(ptDraw->block.height == 1);
+ assert(util_format_get_blockwidth(ptDraw->texture->format) == 1);
+ assert(util_format_get_blockheight(ptDraw->texture->format) == 1);
/* map the stencil buffer */
drawMap = screen->transfer_map(screen, ptDraw);
dst = drawMap + y * ptDraw->stride;
src = buffer + i * width;
- switch (ptDraw->format) {
+ switch (ptDraw->texture->format) {
case PIPE_FORMAT_S8Z24_UNORM:
{
uint *dst4 = (uint *) dst;
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct st_renderbuffer *rbRead;
- void *driver_vp;
- struct st_fragment_program *stfp;
+ void *driver_vp, *driver_fp;
struct pipe_texture *pt;
GLfloat *color;
enum pipe_format srcFormat, texFormat;
if (type == GL_COLOR) {
rbRead = st_get_color_read_renderbuffer(ctx);
color = NULL;
- stfp = combined_drawpix_fragment_program(ctx);
+ driver_fp = combined_drawpix_fragment_program(ctx);
driver_vp = st_make_passthrough_vertex_shader(st, GL_FALSE);
}
else {
assert(type == GL_DEPTH);
rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
- stfp = make_fragment_shader_z(st);
+ driver_fp = make_fragment_shader_z(st);
driver_vp = st_make_passthrough_vertex_shader(st, GL_TRUE);
}
if (ST_DEBUG & DEBUG_FALLBACK)
debug_printf("%s: fallback processing\n", __FUNCTION__);
- if (type == GL_DEPTH && pf_is_depth_and_stencil(pt->format))
+ if (type == GL_DEPTH && util_format_is_depth_and_stencil(pt->format))
transfer_usage = PIPE_TRANSFER_READ_WRITE;
else
transfer_usage = PIPE_TRANSFER_WRITE;
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
pt,
driver_vp,
- stfp->driver_shader,
+ driver_fp,
color, GL_TRUE);
pipe_texture_reference(&pt, NULL);
{
st_reference_fragprog(st, &st->drawpix.z_shader, NULL);
st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
- st_reference_vertprog(st, &st->drawpix.vert_shaders[0], NULL);
- st_reference_vertprog(st, &st->drawpix.vert_shaders[1], NULL);
+ if (st->drawpix.vert_shaders[0])
+ free(st->drawpix.vert_shaders[0]);
+ if (st->drawpix.vert_shaders[1])
+ free(st->drawpix.vert_shaders[1]);
}