Ejemplo n.º 1
0
static struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
					  struct st_texture_object *stObj,
                                          const struct gl_sampler_object *samp,
					  enum pipe_format format)
{
   struct pipe_sampler_view templ;
   GLuint swizzle = apply_depthmode(stObj->pt->format,
                                    stObj->base._Swizzle,
                                    samp->DepthMode);

   u_sampler_view_default_template(&templ,
                                   stObj->pt,
                                   format);
   templ.u.tex.first_level = stObj->base.BaseLevel;

   if (swizzle != SWIZZLE_NOOP) {
      templ.swizzle_r = GET_SWZ(swizzle, 0);
      templ.swizzle_g = GET_SWZ(swizzle, 1);
      templ.swizzle_b = GET_SWZ(swizzle, 2);
      templ.swizzle_a = GET_SWZ(swizzle, 3);
   }

   return pipe->create_sampler_view(pipe, stObj->pt, &templ);
}
Ejemplo n.º 2
0
/**
 * Return TRUE if the swizzling described by "swizzle" and
 * "depthmode" (for depth textures only) is different from the swizzling
 * set in the given sampler view.
 *
 * \param sv         A sampler view.
 * \param swizzle    Texture swizzle, a bitmask computed using MAKE_SWIZZLE4.
 * \param depthmode  One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA.
 */
static boolean
check_sampler_swizzle(struct pipe_sampler_view *sv,
                      GLuint swizzle, GLenum depthmode)
{
    swizzle = apply_depthmode(sv->texture->format, swizzle, depthmode);

    if ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
            (sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
            (sv->swizzle_b != GET_SWZ(swizzle, 2)) ||
            (sv->swizzle_a != GET_SWZ(swizzle, 3)))
        return TRUE;
    return FALSE;
}
Ejemplo n.º 3
0
static struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
        struct st_texture_object *stObj,
        const struct gl_sampler_object *samp,
        enum pipe_format format)
{
    struct pipe_sampler_view templ;
    GLuint swizzle = apply_depthmode(stObj->pt->format,
                                     stObj->base._Swizzle,
                                     stObj->base.DepthMode);

    u_sampler_view_default_template(&templ,
                                    stObj->pt,
                                    format);

    if (stObj->pt->target == PIPE_BUFFER) {
        unsigned base, size;
        unsigned f, n;
        const struct util_format_description *desc
            = util_format_description(templ.format);

        base = stObj->base.BufferOffset;
        if (base >= stObj->pt->width0)
            return NULL;
        size = MIN2(stObj->pt->width0 - base, (unsigned)stObj->base.BufferSize);

        f = ((base * 8) / desc->block.bits) * desc->block.width;
        n = ((size * 8) / desc->block.bits) * desc->block.width;
        if (!n)
            return NULL;
        templ.u.buf.first_element = f;
        templ.u.buf.last_element  = f + (n - 1);
    } else {
        templ.u.tex.first_level = stObj->base.BaseLevel;
    }

    if (swizzle != SWIZZLE_NOOP) {
        templ.swizzle_r = GET_SWZ(swizzle, 0);
        templ.swizzle_g = GET_SWZ(swizzle, 1);
        templ.swizzle_b = GET_SWZ(swizzle, 2);
        templ.swizzle_a = GET_SWZ(swizzle, 3);
    }

    return pipe->create_sampler_view(pipe, stObj->pt, &templ);
}