mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-07 03:40:27 +01:00
Merge branch 'upstream-gallium-0.1' into darktama-gallium-0.1
This commit is contained in:
commit
b397a2bb20
53 changed files with 3311 additions and 2105 deletions
|
|
@ -159,6 +159,18 @@ static void Key( unsigned char key, int x, int y )
|
|||
case 'B':
|
||||
Bias += 10;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
Bias = 100.0 * (key - '0');
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -113,44 +113,67 @@ static void Init( void )
|
|||
minDim = imgWidth < imgHeight ? imgWidth : imgHeight;
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
|
||||
/*
|
||||
* 1D Texture. Test proxy first, if that works, test non-proxy target.
|
||||
*/
|
||||
glTexImage1D(GL_PROXY_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
assert(w == imgWidth);
|
||||
assert(w == imgWidth || w == 0);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
if (w) {
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 2D Texture
|
||||
*/
|
||||
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
assert(w == imgWidth);
|
||||
assert(w == imgWidth || w == 0);
|
||||
|
||||
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
if (w) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 3D Texture
|
||||
*/
|
||||
glTexImage3D(GL_PROXY_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &w);
|
||||
assert(w == imgWidth);
|
||||
assert(w == imgWidth || w == 0);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB,
|
||||
minDim, minDim, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
if (w) {
|
||||
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cube Texture
|
||||
*/
|
||||
glTexImage2D(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_RGB,
|
||||
minDim, minDim, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_WIDTH, &w);
|
||||
assert(w == minDim);
|
||||
assert(w == minDim || w == 0);
|
||||
|
||||
if (w) {
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB,
|
||||
minDim, minDim, 0,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
|
|
|||
|
|
@ -131,8 +131,8 @@ static void display(void)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
|
||||
|
||||
if (NearestFilter) {
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
|
@ -194,22 +194,22 @@ key(unsigned char k, int x, int y)
|
|||
MaxLevel = 10;
|
||||
break;
|
||||
case 'l':
|
||||
LodBias -= 0.02;
|
||||
LodBias -= 0.25;
|
||||
break;
|
||||
case 'L':
|
||||
LodBias += 0.02;
|
||||
LodBias += 0.25;
|
||||
break;
|
||||
case 'n':
|
||||
MinLod -= 0.02;
|
||||
MinLod -= 0.25;
|
||||
break;
|
||||
case 'N':
|
||||
MinLod += 0.02;
|
||||
MinLod += 0.25;
|
||||
break;
|
||||
case 'x':
|
||||
MaxLod -= 0.02;
|
||||
MaxLod -= 0.25;
|
||||
break;
|
||||
case 'X':
|
||||
MaxLod += 0.02;
|
||||
MaxLod += 0.25;
|
||||
break;
|
||||
case 'f':
|
||||
NearestFilter = !NearestFilter;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -28,6 +28,19 @@
|
|||
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_generate_mipmap_level(GLenum target,
|
||||
GLenum datatype, GLuint comps,
|
||||
GLint border,
|
||||
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
||||
GLint srcRowStride,
|
||||
const GLubyte *srcData,
|
||||
GLint dstWidth, GLint dstHeight, GLint dstDepth,
|
||||
GLint dstRowStride,
|
||||
GLubyte *dstData);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj);
|
||||
|
|
|
|||
|
|
@ -1569,3 +1569,174 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
|||
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return datatype and number of components per texel for the
|
||||
* given gl_texture_format.
|
||||
*/
|
||||
void
|
||||
_mesa_format_to_type_and_comps(const struct gl_texture_format *format,
|
||||
GLenum *datatype, GLuint *comps)
|
||||
{
|
||||
switch (format->MesaFormat) {
|
||||
case MESA_FORMAT_RGBA8888:
|
||||
case MESA_FORMAT_RGBA8888_REV:
|
||||
case MESA_FORMAT_ARGB8888:
|
||||
case MESA_FORMAT_ARGB8888_REV:
|
||||
*datatype = CHAN_TYPE;
|
||||
*comps = 4;
|
||||
return;
|
||||
case MESA_FORMAT_RGB888:
|
||||
case MESA_FORMAT_BGR888:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 3;
|
||||
return;
|
||||
case MESA_FORMAT_RGB565:
|
||||
case MESA_FORMAT_RGB565_REV:
|
||||
*datatype = GL_UNSIGNED_SHORT_5_6_5;
|
||||
*comps = 3;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_ARGB4444:
|
||||
case MESA_FORMAT_ARGB4444_REV:
|
||||
*datatype = GL_UNSIGNED_SHORT_4_4_4_4;
|
||||
*comps = 4;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_ARGB1555:
|
||||
case MESA_FORMAT_ARGB1555_REV:
|
||||
*datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||
*comps = 3;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_AL88:
|
||||
case MESA_FORMAT_AL88_REV:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 2;
|
||||
return;
|
||||
case MESA_FORMAT_RGB332:
|
||||
*datatype = GL_UNSIGNED_BYTE_3_3_2;
|
||||
*comps = 3;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_A8:
|
||||
case MESA_FORMAT_L8:
|
||||
case MESA_FORMAT_I8:
|
||||
case MESA_FORMAT_CI8:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_YCBCR:
|
||||
case MESA_FORMAT_YCBCR_REV:
|
||||
*datatype = GL_UNSIGNED_SHORT;
|
||||
*comps = 2;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_Z24_S8:
|
||||
*datatype = GL_UNSIGNED_INT;
|
||||
*comps = 1; /* XXX OK? */
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_Z16:
|
||||
*datatype = GL_UNSIGNED_SHORT;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_Z32:
|
||||
*datatype = GL_UNSIGNED_INT;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_SRGB8:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 3;
|
||||
return;
|
||||
case MESA_FORMAT_SRGBA8:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 4;
|
||||
return;
|
||||
case MESA_FORMAT_SL8:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 1;
|
||||
return;
|
||||
case MESA_FORMAT_SLA8:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 2;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_RGB_FXT1:
|
||||
case MESA_FORMAT_RGBA_FXT1:
|
||||
case MESA_FORMAT_RGB_DXT1:
|
||||
case MESA_FORMAT_RGBA_DXT1:
|
||||
case MESA_FORMAT_RGBA_DXT3:
|
||||
case MESA_FORMAT_RGBA_DXT5:
|
||||
/* XXX generate error instead? */
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 0;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_RGBA:
|
||||
*datatype = CHAN_TYPE;
|
||||
*comps = 4;
|
||||
return;
|
||||
case MESA_FORMAT_RGB:
|
||||
*datatype = CHAN_TYPE;
|
||||
*comps = 3;
|
||||
return;
|
||||
case MESA_FORMAT_LUMINANCE_ALPHA:
|
||||
*datatype = CHAN_TYPE;
|
||||
*comps = 2;
|
||||
return;
|
||||
case MESA_FORMAT_ALPHA:
|
||||
case MESA_FORMAT_LUMINANCE:
|
||||
case MESA_FORMAT_INTENSITY:
|
||||
*datatype = CHAN_TYPE;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_RGBA_FLOAT32:
|
||||
*datatype = GL_FLOAT;
|
||||
*comps = 4;
|
||||
return;
|
||||
case MESA_FORMAT_RGBA_FLOAT16:
|
||||
*datatype = GL_HALF_FLOAT_ARB;
|
||||
*comps = 4;
|
||||
return;
|
||||
case MESA_FORMAT_RGB_FLOAT32:
|
||||
*datatype = GL_FLOAT;
|
||||
*comps = 3;
|
||||
return;
|
||||
case MESA_FORMAT_RGB_FLOAT16:
|
||||
*datatype = GL_HALF_FLOAT_ARB;
|
||||
*comps = 3;
|
||||
return;
|
||||
case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
|
||||
*datatype = GL_FLOAT;
|
||||
*comps = 2;
|
||||
return;
|
||||
case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
|
||||
*datatype = GL_HALF_FLOAT_ARB;
|
||||
*comps = 2;
|
||||
return;
|
||||
case MESA_FORMAT_ALPHA_FLOAT32:
|
||||
case MESA_FORMAT_LUMINANCE_FLOAT32:
|
||||
case MESA_FORMAT_INTENSITY_FLOAT32:
|
||||
*datatype = GL_FLOAT;
|
||||
*comps = 1;
|
||||
return;
|
||||
case MESA_FORMAT_ALPHA_FLOAT16:
|
||||
case MESA_FORMAT_LUMINANCE_FLOAT16:
|
||||
case MESA_FORMAT_INTENSITY_FLOAT16:
|
||||
*datatype = GL_HALF_FLOAT_ARB;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
default:
|
||||
_mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
|
||||
*datatype = 0;
|
||||
*comps = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,4 +239,10 @@ extern const struct gl_texture_format *
|
|||
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
||||
GLenum format, GLenum type );
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_format_to_type_and_comps(const struct gl_texture_format *format,
|
||||
GLenum *datatype, GLuint *comps);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -595,8 +595,12 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat)
|
|||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
texture_face(GLenum target)
|
||||
/**
|
||||
* For cube map faces, return a face index in [0,5].
|
||||
* For other targets return 0;
|
||||
*/
|
||||
GLuint
|
||||
_mesa_tex_target_to_face(GLenum target)
|
||||
{
|
||||
if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
|
||||
target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)
|
||||
|
|
@ -625,6 +629,7 @@ _mesa_set_tex_image(struct gl_texture_object *tObj,
|
|||
{
|
||||
ASSERT(tObj);
|
||||
ASSERT(texImage);
|
||||
/* XXX simplify this with _mesa_tex_target_to_face() */
|
||||
switch (target) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_2D:
|
||||
|
|
@ -828,6 +833,7 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_object *texObj,
|
|||
if (level < 0 || level >= MAX_TEXTURE_LEVELS)
|
||||
return NULL;
|
||||
|
||||
/* XXX simplify this with _mesa_tex_target_to_face() */
|
||||
switch (target) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_PROXY_TEXTURE_1D:
|
||||
|
|
@ -2424,7 +2430,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
|
|||
struct gl_texture_unit *texUnit;
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
const GLuint face = texture_face(target);
|
||||
const GLuint face = _mesa_tex_target_to_face(target);
|
||||
|
||||
if (texture_error_check(ctx, target, level, internalFormat,
|
||||
format, type, 1, postConvWidth, 1, 1, border)) {
|
||||
|
|
@ -2527,7 +2533,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
|
|||
struct gl_texture_unit *texUnit;
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
const GLuint face = texture_face(target);
|
||||
const GLuint face = _mesa_tex_target_to_face(target);
|
||||
|
||||
if (texture_error_check(ctx, target, level, internalFormat,
|
||||
format, type, 2, postConvWidth, postConvHeight,
|
||||
|
|
@ -2629,7 +2635,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
|
|||
struct gl_texture_unit *texUnit;
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
const GLuint face = texture_face(target);
|
||||
const GLuint face = _mesa_tex_target_to_face(target);
|
||||
|
||||
if (texture_error_check(ctx, target, level, (GLint) internalFormat,
|
||||
format, type, 3, width, height, depth, border)) {
|
||||
|
|
@ -2897,7 +2903,7 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
|
|||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
GLsizei postConvWidth = width;
|
||||
const GLuint face = texture_face(target);
|
||||
const GLuint face = _mesa_tex_target_to_face(target);
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||
|
||||
|
|
@ -2960,7 +2966,7 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
|
|||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
GLsizei postConvWidth = width, postConvHeight = height;
|
||||
const GLuint face = texture_face(target);
|
||||
const GLuint face = _mesa_tex_target_to_face(target);
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,11 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
|
|||
GLint width, GLint height, GLint depth, GLint border);
|
||||
|
||||
|
||||
extern GLuint
|
||||
_mesa_tex_target_to_face(GLenum target);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lock a texture for updating. See also _mesa_lock_context_textures().
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ cell_create_fs_state(struct pipe_context *pipe,
|
|||
#endif
|
||||
|
||||
#ifdef MESA_LLVM
|
||||
state->llvm_prog = gallivm_from_tgsi(state->shader.tokens, GALLIVM_FS);
|
||||
state->llvm_prog = 0;
|
||||
if (!gallivm_global_cpu_engine()) {
|
||||
gallivm_cpu_engine_create(state->llvm_prog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,15 @@ run_vertex_program(struct draw_context *draw,
|
|||
draw->vertex_fetch.fetch_func( draw, machine, elts, count );
|
||||
|
||||
/* run shader */
|
||||
#if defined(__i386__) || defined(__386__)
|
||||
#ifdef MESA_LLVM
|
||||
if (1) {
|
||||
struct gallivm_prog *prog = draw->vertex_shader->llvm_prog;
|
||||
gallivm_cpu_vs_exec(prog,
|
||||
machine->Inputs,
|
||||
machine->Outputs,
|
||||
machine->Consts);
|
||||
} else
|
||||
#elif defined(__i386__) || defined(__386__)
|
||||
if (draw->use_sse) {
|
||||
/* SSE */
|
||||
/* cast away const */
|
||||
|
|
@ -212,13 +220,7 @@ draw_vertex_shader_queue_flush(struct draw_context *draw)
|
|||
*/
|
||||
draw_update_vertex_fetch( draw );
|
||||
|
||||
// debug_printf( " q(%d) ", draw->vs.queue_nr );
|
||||
#ifdef MESA_LLVM
|
||||
if (draw->vertex_shader->llvm_prog) {
|
||||
draw_vertex_shader_queue_flush_llvm(draw);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// fprintf(stderr, " q(%d) ", draw->vs.queue_nr );
|
||||
|
||||
/* run vertex shader on vertex cache entries, four per invokation */
|
||||
for (i = 0; i < draw->vs.queue_nr; i += 4) {
|
||||
|
|
@ -260,7 +262,13 @@ draw_create_vertex_shader(struct draw_context *draw,
|
|||
vs->state = shader;
|
||||
|
||||
#ifdef MESA_LLVM
|
||||
vs->llvm_prog = gallivm_from_tgsi(shader->tokens, GALLIVM_VS);
|
||||
struct gallivm_ir *ir = gallivm_ir_new(GALLIVM_VS);
|
||||
gallivm_ir_set_layout(ir, GALLIVM_SOA);
|
||||
gallivm_ir_set_components(ir, 4);
|
||||
gallivm_ir_fill_from_tgsi(ir, shader->tokens);
|
||||
vs->llvm_prog = gallivm_ir_compile(ir);
|
||||
gallivm_ir_delete(ir);
|
||||
|
||||
draw->engine = gallivm_global_cpu_engine();
|
||||
if (!draw->engine) {
|
||||
draw->engine = gallivm_cpu_engine_create(vs->llvm_prog);
|
||||
|
|
@ -296,7 +304,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
|
|||
draw->vertex_shader = dvs;
|
||||
draw->num_vs_outputs = dvs->state->num_outputs;
|
||||
|
||||
/* specify the fragment program to interpret/execute */
|
||||
/* specify the vertex program to interpret/execute */
|
||||
tgsi_exec_machine_init(&draw->machine,
|
||||
draw->vertex_shader->state->tokens,
|
||||
PIPE_MAX_SAMPLERS,
|
||||
|
|
|
|||
|
|
@ -1,194 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Zack Rusin zack@tungstengraphics.com
|
||||
*/
|
||||
|
||||
#include "pipe/p_util.h"
|
||||
#include "draw_private.h"
|
||||
#include "draw_context.h"
|
||||
|
||||
#ifdef MESA_LLVM
|
||||
|
||||
#include "pipe/llvm/gallivm.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
|
||||
#define DBG 0
|
||||
|
||||
static INLINE void
|
||||
fetch_attrib4(const void *ptr, enum pipe_format format, float attrib[4])
|
||||
{
|
||||
/* defaults */
|
||||
attrib[1] = 0.0;
|
||||
attrib[2] = 0.0;
|
||||
attrib[3] = 1.0;
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_R32G32B32A32_FLOAT:
|
||||
attrib[3] = ((float *) ptr)[3];
|
||||
/* fall-through */
|
||||
case PIPE_FORMAT_R32G32B32_FLOAT:
|
||||
attrib[2] = ((float *) ptr)[2];
|
||||
/* fall-through */
|
||||
case PIPE_FORMAT_R32G32_FLOAT:
|
||||
attrib[1] = ((float *) ptr)[1];
|
||||
/* fall-through */
|
||||
case PIPE_FORMAT_R32_FLOAT:
|
||||
attrib[0] = ((float *) ptr)[0];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch vertex attributes for 'count' vertices.
|
||||
*/
|
||||
static INLINE
|
||||
void vertex_fetch(struct draw_context *draw,
|
||||
const unsigned elt,
|
||||
float (*inputs)[4])
|
||||
{
|
||||
uint attr;
|
||||
|
||||
/* loop over vertex attributes (vertex shader inputs) */
|
||||
for (attr = 0; attr < draw->vertex_shader->state->num_inputs; attr++) {
|
||||
|
||||
unsigned buf = draw->vertex_element[attr].vertex_buffer_index;
|
||||
const void *src
|
||||
= (const void *) ((const ubyte *) draw->user.vbuffer[buf]
|
||||
+ draw->vertex_buffer[buf].buffer_offset
|
||||
+ draw->vertex_element[attr].src_offset
|
||||
+ elt * draw->vertex_buffer[buf].pitch);
|
||||
fetch_attrib4(src, draw->vertex_element[attr].src_format, inputs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE unsigned
|
||||
compute_clipmask(const float *clip, const float (*plane)[4], unsigned nr)
|
||||
{
|
||||
unsigned mask = 0;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
if (dot4(clip, plane[i]) < 0)
|
||||
mask |= (1<<i);
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by the draw module when the vertx cache needs to be flushed.
|
||||
* This involves running the vertex shader.
|
||||
*/
|
||||
void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
struct vertex_header *dests[VS_QUEUE_LENGTH];
|
||||
float inputs[VS_QUEUE_LENGTH][PIPE_MAX_SHADER_INPUTS][4] ALIGN16_ATTRIB;
|
||||
float outputs[VS_QUEUE_LENGTH][PIPE_MAX_SHADER_INPUTS][4] ALIGN16_ATTRIB;
|
||||
float (*consts)[4] = (float (*)[4]) draw->user.constants;
|
||||
struct gallivm_prog *prog = draw->vertex_shader->llvm_prog;
|
||||
const float *scale = draw->viewport.scale;
|
||||
const float *trans = draw->viewport.translate;
|
||||
/* fetch the inputs */
|
||||
for (i = 0; i < draw->vs.queue_nr; ++i) {
|
||||
unsigned elt = draw->vs.queue[i].elt;
|
||||
dests[i] = draw->vs.queue[i].dest;
|
||||
vertex_fetch(draw, elt, inputs[i]);
|
||||
}
|
||||
|
||||
/* batch execute the shaders on all the vertices */
|
||||
gallivm_prog_exec(prog, inputs, outputs, consts,
|
||||
draw->vs.queue_nr,
|
||||
draw->vertex_shader->state->num_inputs,
|
||||
draw->vertex_shader->state->num_outputs);
|
||||
|
||||
|
||||
/* store machine results */
|
||||
for (int i = 0; i < draw->vs.queue_nr; ++i) {
|
||||
unsigned slot;
|
||||
float x, y, z, w;
|
||||
struct vertex_header *vOut = draw->vs.queue[i].dest;
|
||||
float (*dests)[4] = outputs[i];
|
||||
|
||||
/* Handle attr[0] (position) specially:
|
||||
*
|
||||
* XXX: Computing the clipmask should be done in the vertex
|
||||
* program as a set of DP4 instructions appended to the
|
||||
* user-provided code.
|
||||
*/
|
||||
x = vOut->clip[0] = dests[0][0];
|
||||
y = vOut->clip[1] = dests[0][1];
|
||||
z = vOut->clip[2] = dests[0][2];
|
||||
w = vOut->clip[3] = dests[0][3];
|
||||
#if DBG
|
||||
debug_printf("output %d: %f %f %f %f\n", 0, x, y, z, w);
|
||||
#endif
|
||||
|
||||
vOut->clipmask = compute_clipmask(vOut->clip, draw->plane, draw->nr_planes);
|
||||
vOut->edgeflag = 1;
|
||||
/* divide by w */
|
||||
w = 1.0f / w;
|
||||
x *= w;
|
||||
y *= w;
|
||||
z *= w;
|
||||
|
||||
/* Viewport mapping */
|
||||
vOut->data[0][0] = x * scale[0] + trans[0];
|
||||
vOut->data[0][1] = y * scale[1] + trans[1];
|
||||
vOut->data[0][2] = z * scale[2] + trans[2];
|
||||
vOut->data[0][3] = w;
|
||||
|
||||
/* Remaining attributes are packed into sequential post-transform
|
||||
* vertex attrib slots.
|
||||
*/
|
||||
for (slot = 1; slot < draw->num_vs_outputs; slot++) {
|
||||
vOut->data[slot][0] = dests[slot][0];
|
||||
vOut->data[slot][1] = dests[slot][1];
|
||||
vOut->data[slot][2] = dests[slot][2];
|
||||
vOut->data[slot][3] = dests[slot][3];
|
||||
|
||||
#if DBG
|
||||
debug_printf("output %d: %f %f %f %f\n", slot,
|
||||
vOut->data[slot][0],
|
||||
vOut->data[slot][1],
|
||||
vOut->data[slot][2],
|
||||
vOut->data[slot][3]);
|
||||
#endif
|
||||
}
|
||||
} /* loop over vertices */
|
||||
|
||||
draw->vs.queue_nr = 0;
|
||||
}
|
||||
|
||||
#endif /* MESA_LLVM */
|
||||
|
|
@ -76,7 +76,6 @@ static void passthrough_tri( struct draw_stage *stage,
|
|||
|
||||
/**
|
||||
* Draw a wide line by drawing a quad (two triangles).
|
||||
* XXX still need line stipple.
|
||||
* XXX need to disable polygon stipple.
|
||||
*/
|
||||
static void wide_line( struct draw_stage *stage,
|
||||
|
|
@ -103,12 +102,9 @@ static void wide_line( struct draw_stage *stage,
|
|||
/*
|
||||
* Draw wide line as a quad (two tris) by "stretching" the line along
|
||||
* X or Y.
|
||||
* XXX For AA lines, the quad corners have to be computed in a
|
||||
* more sophisticated way.
|
||||
* We need to tweak coords in several ways to be conformant here.
|
||||
*/
|
||||
|
||||
/* need to tweak coords in several ways to be conformant here */
|
||||
|
||||
if (dx > dy) {
|
||||
/* x-major line */
|
||||
pos0[1] = pos0[1] - half_width - 0.25f;
|
||||
|
|
@ -165,6 +161,70 @@ static void wide_line( struct draw_stage *stage,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw a wide line by drawing a quad, using geometry which will
|
||||
* fullfill GL's antialiased line requirements.
|
||||
*/
|
||||
static void wide_line_aa(struct draw_stage *stage,
|
||||
struct prim_header *header)
|
||||
{
|
||||
const struct wide_stage *wide = wide_stage(stage);
|
||||
const float half_width = wide->half_line_width;
|
||||
struct prim_header tri;
|
||||
struct vertex_header *v[4];
|
||||
float *pos;
|
||||
float dx = header->v[1]->data[0][0] - header->v[0]->data[0][0];
|
||||
float dy = header->v[1]->data[0][1] - header->v[0]->data[0][1];
|
||||
const float len = sqrt(dx * dx + dy * dy);
|
||||
uint i;
|
||||
|
||||
dx = dx * half_width / len;
|
||||
dy = dy * half_width / len;
|
||||
|
||||
/* allocate/dup new verts */
|
||||
for (i = 0; i < 4; i++) {
|
||||
v[i] = dup_vert(stage, header->v[i/2], i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Quad for line from v0 to v1:
|
||||
*
|
||||
* 1 3
|
||||
* +-------------------------+
|
||||
* | |
|
||||
* *v0 v1*
|
||||
* | |
|
||||
* +-------------------------+
|
||||
* 0 2
|
||||
*/
|
||||
|
||||
pos = v[0]->data[0];
|
||||
pos[0] += dy;
|
||||
pos[1] -= dx;
|
||||
|
||||
pos = v[1]->data[0];
|
||||
pos[0] -= dy;
|
||||
pos[1] += dx;
|
||||
|
||||
pos = v[2]->data[0];
|
||||
pos[0] += dy;
|
||||
pos[1] -= dx;
|
||||
|
||||
pos = v[3]->data[0];
|
||||
pos[0] -= dy;
|
||||
pos[1] += dx;
|
||||
|
||||
tri.det = header->det; /* only the sign matters */
|
||||
|
||||
tri.v[0] = v[2]; tri.v[1] = v[1]; tri.v[2] = v[0];
|
||||
stage->next->tri( stage->next, &tri );
|
||||
|
||||
tri.v[0] = v[3]; tri.v[1] = v[1]; tri.v[2] = v[2];
|
||||
stage->next->tri( stage->next, &tri );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the vertex texcoords for sprite mode.
|
||||
* Coords may be left untouched or set to a right-side-up or upside-down
|
||||
|
|
@ -319,7 +379,10 @@ static void wide_first_line( struct draw_stage *stage,
|
|||
wide->half_line_width = 0.5f * draw->rasterizer->line_width;
|
||||
|
||||
if (draw->rasterizer->line_width != 1.0) {
|
||||
wide->stage.line = wide_line;
|
||||
if (draw->rasterizer->line_smooth)
|
||||
wide->stage.line = wide_line_aa;
|
||||
else
|
||||
wide->stage.line = wide_line;
|
||||
}
|
||||
else {
|
||||
wide->stage.line = passthrough_line;
|
||||
|
|
|
|||
|
|
@ -250,6 +250,13 @@ i915_create_sampler_state(struct pipe_context *pipe,
|
|||
if (sampler->normalized_coords)
|
||||
cso->state[1] |= SS3_NORMALIZED_COORDS;
|
||||
|
||||
if (0) /* XXX not tested yet */
|
||||
{
|
||||
int minlod = (int) (16.0 * sampler->min_lod);
|
||||
minlod = CLAMP(minlod, 0, 16 * 11);
|
||||
cso->state[1] |= (minlod << SS3_MIN_LOD_SHIFT);
|
||||
}
|
||||
|
||||
{
|
||||
ubyte r = float_to_ubyte(sampler->border_color[0]);
|
||||
ubyte g = float_to_ubyte(sampler->border_color[1]);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ i915_update_texture(struct i915_context *i915, uint unit,
|
|||
const struct pipe_texture *pt = &tex->base;
|
||||
uint format, pitch;
|
||||
const uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
|
||||
const uint num_levels = pt->last_level - pt->first_level;
|
||||
const uint num_levels = pt->last_level;
|
||||
|
||||
assert(tex);
|
||||
assert(width);
|
||||
|
|
|
|||
|
|
@ -118,11 +118,11 @@ i945_miptree_layout_2d( struct i915_texture *tex )
|
|||
tex->pitch = pt->width[0];
|
||||
|
||||
/* May need to adjust pitch to accomodate the placement of
|
||||
* the 2nd mipmap. This occurs when the alignment
|
||||
* the 2nd mipmap level. This occurs when the alignment
|
||||
* constraints of mipmap placement push the right edge of the
|
||||
* 2nd mipmap out past the width of its parent.
|
||||
* 2nd mipmap level out past the width of its parent.
|
||||
*/
|
||||
if (pt->first_level != pt->last_level) {
|
||||
if (pt->last_level > 0) {
|
||||
unsigned mip1_width = align_int(minify(pt->width[0]), align_w)
|
||||
+ minify(minify(pt->width[0]));
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
|
|||
tex->pitch = align_int(tex->pitch * pt->cpp, 4) / pt->cpp;
|
||||
tex->total_height = 0;
|
||||
|
||||
for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
unsigned img_height;
|
||||
|
||||
i915_miptree_set_level_info(tex, level, 1, x, y, width, height, 1);
|
||||
|
|
@ -152,9 +152,9 @@ i945_miptree_layout_2d( struct i915_texture *tex )
|
|||
*/
|
||||
tex->total_height = MAX2(tex->total_height, y + img_height);
|
||||
|
||||
/* Layout_below: step right after second mipmap.
|
||||
/* Layout_below: step right after second mipmap level.
|
||||
*/
|
||||
if (level == pt->first_level + 1) {
|
||||
if (level == 1) {
|
||||
x += align_int(width, align_w);
|
||||
}
|
||||
else {
|
||||
|
|
@ -204,7 +204,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
tex->pitch = ((dim * pt->cpp * 2 + 3) & ~3) / pt->cpp;
|
||||
tex->total_height = dim * 4;
|
||||
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
i915_miptree_set_level_info(tex, level, 6,
|
||||
0, 0,
|
||||
/*OLD: tex->pitch, tex->total_height,*/
|
||||
|
|
@ -219,7 +219,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
unsigned y = initial_offsets[face][1] * dim;
|
||||
unsigned d = dim;
|
||||
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
i915_miptree_set_image_offset(tex, level, face, x, y);
|
||||
d >>= 1;
|
||||
x += step_offsets[face][0] * d;
|
||||
|
|
@ -240,7 +240,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
|
||||
/* XXX: hardware expects/requires 9 levels at minimum.
|
||||
*/
|
||||
for (level = pt->first_level; level <= MAX2(8, pt->last_level);
|
||||
for (level = 0; level <= MAX2(8, pt->last_level);
|
||||
level++) {
|
||||
i915_miptree_set_level_info(tex, level, depth, 0, tex->total_height,
|
||||
width, height, depth);
|
||||
|
|
@ -256,7 +256,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
/* Fixup depth image_offsets:
|
||||
*/
|
||||
depth = pt->depth[0];
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
unsigned i;
|
||||
for (i = 0; i < depth; i++)
|
||||
i915_miptree_set_image_offset(tex, level, i,
|
||||
|
|
@ -282,7 +282,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
tex->pitch = ((pt->width[0] * pt->cpp + 3) & ~3) / pt->cpp;
|
||||
tex->total_height = 0;
|
||||
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
i915_miptree_set_level_info(tex, level, 1,
|
||||
0, tex->total_height,
|
||||
width, height, 1);
|
||||
|
|
@ -337,7 +337,7 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
|
||||
/* Set all the levels to effectively occupy the whole rectangular region.
|
||||
*/
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
i915_miptree_set_level_info(tex, level, 6,
|
||||
0, 0,
|
||||
lvlWidth, lvlHeight, 1);
|
||||
|
|
@ -355,12 +355,12 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
y = tex->total_height - 4;
|
||||
x = (face - 4) * 8;
|
||||
}
|
||||
else if (dim < 4 && (face > 0 || pt->first_level > 0)) {
|
||||
else if (dim < 4 && (face > 0)) {
|
||||
y = tex->total_height - 4;
|
||||
x = face * 8;
|
||||
}
|
||||
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
i915_miptree_set_image_offset(tex, level, face, x, y);
|
||||
|
||||
d >>= 1;
|
||||
|
|
@ -418,7 +418,7 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||
pack_x_pitch = tex->pitch;
|
||||
pack_x_nr = 1;
|
||||
|
||||
for (level = pt->first_level; level <= pt->last_level; level++) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
|
|||
* constraints of mipmap placement push the right edge of the
|
||||
* 2nd mipmap out past the width of its parent.
|
||||
*/
|
||||
if (pt->first_level != pt->last_level) {
|
||||
if (pt->last_level > 0) {
|
||||
unsigned mip1_width;
|
||||
|
||||
if (pt->compressed) {
|
||||
|
|
@ -168,7 +168,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
|
|||
tex->pitch = align(tex->pitch * pt->cpp, 4) / pt->cpp;
|
||||
tex->total_height = 0;
|
||||
|
||||
for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
unsigned img_height;
|
||||
|
||||
intel_miptree_set_level_info(tex, level, 1, x, y, width,
|
||||
|
|
@ -187,7 +187,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
|
|||
|
||||
/* Layout_below: step right after second mipmap.
|
||||
*/
|
||||
if (level == pt->first_level + 1) {
|
||||
if (level == 1) {
|
||||
x += align(width, align_w);
|
||||
}
|
||||
else {
|
||||
|
|
@ -234,7 +234,7 @@ static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture
|
|||
pack_x_pitch = tex->pitch;
|
||||
pack_x_nr = 1;
|
||||
|
||||
for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void brw_update_texture_surface( struct brw_context *brw,
|
|||
/* Updated in emit_reloc */
|
||||
surf.ss1.base_addr = brw_buffer_offset( brw, tObj->buffer );
|
||||
|
||||
surf.ss2.mip_count = tObj->base.last_level - tObj->base.first_level;
|
||||
surf.ss2.mip_count = tObj->base.last_level;
|
||||
surf.ss2.width = tObj->base.width[0] - 1;
|
||||
surf.ss2.height = tObj->base.height[0] - 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,13 @@ LIBNAME = gallivm
|
|||
|
||||
GALLIVM_SOURCES = \
|
||||
gallivm.cpp \
|
||||
gallivm_cpu.cpp \
|
||||
instructions.cpp \
|
||||
storage.cpp
|
||||
loweringpass.cpp \
|
||||
tgsitollvm.cpp \
|
||||
storage.cpp \
|
||||
storagesoa.cpp \
|
||||
instructionssoa.cpp
|
||||
|
||||
INC_SOURCES = gallivm_builtins.cpp llvm_base_shader.cpp
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -43,31 +43,34 @@ extern "C" {
|
|||
|
||||
struct tgsi_token;
|
||||
|
||||
struct gallivm_ir;
|
||||
struct gallivm_prog;
|
||||
struct gallivm_cpu_engine;
|
||||
struct tgsi_interp_coef;
|
||||
struct tgsi_sampler;
|
||||
struct tgsi_exec_vector;
|
||||
|
||||
enum gallivm_shader_type {
|
||||
GALLIVM_VS,
|
||||
GALLIVM_FS
|
||||
};
|
||||
|
||||
struct gallivm_prog *gallivm_from_tgsi(const struct tgsi_token *tokens, enum gallivm_shader_type type);
|
||||
void gallivm_prog_delete(struct gallivm_prog *prog);
|
||||
int gallivm_prog_exec(struct gallivm_prog *prog,
|
||||
float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
float (*consts)[4],
|
||||
int num_vertices,
|
||||
int num_inputs,
|
||||
int num_attribs);
|
||||
int gallivm_fragment_shader_exec(struct gallivm_prog *prog,
|
||||
float x, float y,
|
||||
float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
float (*consts)[4],
|
||||
struct tgsi_sampler *samplers);
|
||||
enum gallivm_vector_layout {
|
||||
GALLIVM_AOS,
|
||||
GALLIVM_SOA
|
||||
};
|
||||
|
||||
struct gallivm_ir *gallivm_ir_new(enum gallivm_shader_type type);
|
||||
void gallivm_ir_set_layout(struct gallivm_ir *ir,
|
||||
enum gallivm_vector_layout layout);
|
||||
void gallivm_ir_set_components(struct gallivm_ir *ir, int num);
|
||||
void gallivm_ir_fill_from_tgsi(struct gallivm_ir *ir,
|
||||
const struct tgsi_token *tokens);
|
||||
void gallivm_ir_delete(struct gallivm_ir *ir);
|
||||
|
||||
|
||||
struct gallivm_prog *gallivm_ir_compile(struct gallivm_ir *ir);
|
||||
|
||||
void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
|
||||
float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
const struct tgsi_interp_coef *coefs);
|
||||
|
|
@ -76,9 +79,20 @@ void gallivm_prog_dump(struct gallivm_prog *prog, const char *file_prefix);
|
|||
|
||||
struct gallivm_cpu_engine *gallivm_cpu_engine_create(struct gallivm_prog *prog);
|
||||
struct gallivm_cpu_engine *gallivm_global_cpu_engine();
|
||||
int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
|
||||
struct tgsi_exec_vector *inputs,
|
||||
struct tgsi_exec_vector *dests,
|
||||
float (*consts)[4]);
|
||||
int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
|
||||
float x, float y,
|
||||
float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
|
||||
float (*consts)[4],
|
||||
struct tgsi_sampler *samplers);
|
||||
void gallivm_cpu_jit_compile(struct gallivm_cpu_engine *ee, struct gallivm_prog *prog);
|
||||
void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *ee);
|
||||
|
||||
|
||||
#endif /* MESA_LLVM */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
|
|
|||
204
src/mesa/pipe/llvm/gallivm_cpu.cpp
Normal file
204
src/mesa/pipe/llvm/gallivm_cpu.cpp
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Zack Rusin zack@tungstengraphics.com
|
||||
*/
|
||||
#ifdef MESA_LLVM
|
||||
|
||||
#include "gallivm.h"
|
||||
#include "gallivm_p.h"
|
||||
|
||||
#include "instructions.h"
|
||||
#include "loweringpass.h"
|
||||
#include "storage.h"
|
||||
#include "tgsitollvm.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
|
||||
#include "pipe/tgsi/exec/tgsi_exec.h"
|
||||
#include "pipe/tgsi/util/tgsi_dump.h"
|
||||
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/CallingConv.h>
|
||||
#include <llvm/Constants.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/ModuleProvider.h>
|
||||
#include <llvm/Pass.h>
|
||||
#include <llvm/PassManager.h>
|
||||
#include <llvm/ParameterAttributes.h>
|
||||
#include <llvm/Support/PatternMatch.h>
|
||||
#include <llvm/ExecutionEngine/JIT.h>
|
||||
#include <llvm/ExecutionEngine/Interpreter.h>
|
||||
#include <llvm/ExecutionEngine/GenericValue.h>
|
||||
#include <llvm/Support/MemoryBuffer.h>
|
||||
#include <llvm/LinkAllPasses.h>
|
||||
#include <llvm/Analysis/Verifier.h>
|
||||
#include <llvm/Analysis/LoopPass.h>
|
||||
#include <llvm/Target/TargetData.h>
|
||||
#include <llvm/Bitcode/ReaderWriter.h>
|
||||
#include <llvm/Transforms/Utils/Cloning.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
struct gallivm_cpu_engine {
|
||||
llvm::ExecutionEngine *engine;
|
||||
};
|
||||
|
||||
static struct gallivm_cpu_engine *CPU = 0;
|
||||
|
||||
typedef int (*fragment_shader_runner)(float x, float y,
|
||||
float (*dests)[16][4],
|
||||
float (*inputs)[16][4],
|
||||
int num_attribs,
|
||||
float (*consts)[4], int num_consts,
|
||||
struct tgsi_sampler *samplers);
|
||||
|
||||
int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
|
||||
float fx, float fy,
|
||||
float (*dests)[16][4],
|
||||
float (*inputs)[16][4],
|
||||
float (*consts)[4],
|
||||
struct tgsi_sampler *samplers)
|
||||
{
|
||||
fragment_shader_runner runner = reinterpret_cast<fragment_shader_runner>(prog->function);
|
||||
assert(runner);
|
||||
|
||||
return runner(fx, fy, dests, inputs, prog->num_interp,
|
||||
consts, prog->num_consts,
|
||||
samplers);
|
||||
}
|
||||
|
||||
static inline llvm::Function *func_for_shader(struct gallivm_prog *prog)
|
||||
{
|
||||
llvm::Module *mod = prog->module;
|
||||
llvm::Function *func = 0;
|
||||
|
||||
switch (prog->type) {
|
||||
case GALLIVM_VS:
|
||||
func = mod->getFunction("run_vertex_shader");
|
||||
break;
|
||||
case GALLIVM_FS:
|
||||
func = mod->getFunction("run_fragment_shader");
|
||||
break;
|
||||
default:
|
||||
assert(!"Unknown shader type!");
|
||||
break;
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
/*!
|
||||
This function creates a CPU based execution engine for the given gallivm_prog.
|
||||
gallivm_cpu_engine should be used as a singleton throughout the library. Before
|
||||
executing gallivm_prog_exec one needs to call gallivm_cpu_jit_compile.
|
||||
The gallivm_prog instance which is being passed to the constructor is being
|
||||
automatically JIT compiled so one shouldn't call gallivm_cpu_jit_compile
|
||||
with it again.
|
||||
*/
|
||||
struct gallivm_cpu_engine * gallivm_cpu_engine_create(struct gallivm_prog *prog)
|
||||
{
|
||||
struct gallivm_cpu_engine *cpu = (struct gallivm_cpu_engine *)
|
||||
calloc(1, sizeof(struct gallivm_cpu_engine));
|
||||
llvm::Module *mod = static_cast<llvm::Module*>(prog->module);
|
||||
llvm::ExistingModuleProvider *mp = new llvm::ExistingModuleProvider(mod);
|
||||
llvm::ExecutionEngine *ee = llvm::ExecutionEngine::create(mp, false);
|
||||
ee->DisableLazyCompilation();
|
||||
cpu->engine = ee;
|
||||
|
||||
llvm::Function *func = func_for_shader(prog);
|
||||
|
||||
prog->function = ee->getPointerToFunction(func);
|
||||
CPU = cpu;
|
||||
return cpu;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
This function JIT compiles the given gallivm_prog with the given cpu based execution engine.
|
||||
The reference to the generated machine code entry point will be stored
|
||||
in the gallivm_prog program. After executing this function one can call gallivm_prog_exec
|
||||
in order to execute the gallivm_prog on the CPU.
|
||||
*/
|
||||
void gallivm_cpu_jit_compile(struct gallivm_cpu_engine *cpu, struct gallivm_prog *prog)
|
||||
{
|
||||
llvm::Module *mod = static_cast<llvm::Module*>(prog->module);
|
||||
llvm::ExistingModuleProvider *mp = new llvm::ExistingModuleProvider(mod);
|
||||
llvm::ExecutionEngine *ee = cpu->engine;
|
||||
assert(ee);
|
||||
/*FIXME : remove */
|
||||
ee->DisableLazyCompilation();
|
||||
ee->addModuleProvider(mp);
|
||||
|
||||
llvm::Function *func = func_for_shader(prog);
|
||||
prog->function = ee->getPointerToFunction(func);
|
||||
}
|
||||
|
||||
void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *cpu)
|
||||
{
|
||||
free(cpu);
|
||||
}
|
||||
|
||||
struct gallivm_cpu_engine * gallivm_global_cpu_engine()
|
||||
{
|
||||
return CPU;
|
||||
}
|
||||
|
||||
|
||||
typedef void (*vertex_shader_runner)(void *ainputs,
|
||||
void *dests,
|
||||
float (*aconsts)[4],
|
||||
int num_vertices,
|
||||
int num_inputs,
|
||||
int num_attribs,
|
||||
int num_consts);
|
||||
|
||||
|
||||
/*!
|
||||
This function is used to execute the gallivm_prog in software. Before calling
|
||||
this function the gallivm_prog has to be JIT compiled with the gallivm_cpu_jit_compile
|
||||
function.
|
||||
*/
|
||||
int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
|
||||
struct tgsi_exec_vector *inputs,
|
||||
struct tgsi_exec_vector *dests,
|
||||
float (*consts)[4])
|
||||
{
|
||||
vertex_shader_runner runner = reinterpret_cast<vertex_shader_runner>(prog->function);
|
||||
assert(runner);
|
||||
/*FIXME*/
|
||||
runner(inputs, dests, consts, 4, 4, 4, prog->num_consts);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
56
src/mesa/pipe/llvm/gallivm_p.h
Normal file
56
src/mesa/pipe/llvm/gallivm_p.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef GALLIVM_P_H
|
||||
#define GALLIVM_P_H
|
||||
|
||||
#ifdef MESA_LLVM
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
}
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum gallivm_shader_type;
|
||||
enum gallivm_vector_layout;
|
||||
|
||||
struct gallivm_interpolate {
|
||||
int attrib;
|
||||
int chan;
|
||||
int type;
|
||||
};
|
||||
|
||||
struct gallivm_ir {
|
||||
llvm::Module *module;
|
||||
int id;
|
||||
enum gallivm_shader_type type;
|
||||
enum gallivm_vector_layout layout;
|
||||
int num_components;
|
||||
int num_consts;
|
||||
|
||||
//FIXME: this might not be enough for some shaders
|
||||
struct gallivm_interpolate interpolators[32*4];
|
||||
int num_interp;
|
||||
};
|
||||
|
||||
struct gallivm_prog {
|
||||
llvm::Module *module;
|
||||
void *function;
|
||||
|
||||
int id;
|
||||
enum gallivm_shader_type type;
|
||||
|
||||
int num_consts;
|
||||
|
||||
//FIXME: this might not be enough for some shaders
|
||||
struct gallivm_interpolate interpolators[32*4];
|
||||
int num_interp;
|
||||
};
|
||||
|
||||
#endif /* MESA_LLVM */
|
||||
|
||||
#if defined __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
26
src/mesa/pipe/llvm/instructionssoa.cpp
Normal file
26
src/mesa/pipe/llvm/instructionssoa.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "instructionssoa.h"
|
||||
|
||||
InstructionsSoa::InstructionsSoa(llvm::Module *mod, llvm::Function *func,
|
||||
llvm::BasicBlock *block, StorageSoa *storage)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> InstructionsSoa::add(const std::vector<llvm::Value*> in1,
|
||||
const std::vector<llvm::Value*> in2)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> InstructionsSoa::mul(const std::vector<llvm::Value*> in1,
|
||||
const std::vector<llvm::Value*> in2)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void InstructionsSoa::end()
|
||||
{
|
||||
}
|
||||
55
src/mesa/pipe/llvm/instructionssoa.h
Normal file
55
src/mesa/pipe/llvm/instructionssoa.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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 INSTRUCTIONSSOA_H
|
||||
#define INSTRUCTIONSSOA_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
class Function;
|
||||
class BasicBlock;
|
||||
class Value;
|
||||
}
|
||||
class StorageSoa;
|
||||
|
||||
class InstructionsSoa
|
||||
{
|
||||
public:
|
||||
InstructionsSoa(llvm::Module *mod, llvm::Function *func,
|
||||
llvm::BasicBlock *block, StorageSoa *storage);
|
||||
|
||||
std::vector<llvm::Value*> add(const std::vector<llvm::Value*> in1,
|
||||
const std::vector<llvm::Value*> in2);
|
||||
std::vector<llvm::Value*> mul(const std::vector<llvm::Value*> in1,
|
||||
const std::vector<llvm::Value*> in2);
|
||||
void end();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -104,8 +104,8 @@ Module* createBaseShader() {
|
|||
/*isVarArg=*/false);
|
||||
|
||||
std::vector<const Type*>FuncTy_18_args;
|
||||
FuncTy_18_args.push_back(PointerTy_12);
|
||||
FuncTy_18_args.push_back(PointerTy_12);
|
||||
FuncTy_18_args.push_back(PointerTy_9);
|
||||
FuncTy_18_args.push_back(PointerTy_9);
|
||||
FuncTy_18_args.push_back(PointerTy_7);
|
||||
FuncTy_18_args.push_back(IntegerType::get(32));
|
||||
FuncTy_18_args.push_back(IntegerType::get(32));
|
||||
|
|
@ -526,14 +526,23 @@ Module* createBaseShader() {
|
|||
BasicBlock* label_forbody_preheader_i = new BasicBlock("forbody.preheader.i",func_run_vertex_shader,0);
|
||||
BasicBlock* label_forbody_i = new BasicBlock("forbody.i",func_run_vertex_shader,0);
|
||||
BasicBlock* label_from_consts_exit = new BasicBlock("from_consts.exit",func_run_vertex_shader,0);
|
||||
BasicBlock* label_forbody_preheader_91 = new BasicBlock("forbody.preheader",func_run_vertex_shader,0);
|
||||
BasicBlock* label_forbody_92 = new BasicBlock("forbody",func_run_vertex_shader,0);
|
||||
BasicBlock* label_afterfor_93 = new BasicBlock("afterfor",func_run_vertex_shader,0);
|
||||
|
||||
// Block entry (label_entry_90)
|
||||
AllocaInst* ptr_consts = new AllocaInst(ArrayTy_20, "consts", label_entry_90);
|
||||
AllocaInst* ptr_temps = new AllocaInst(ArrayTy_22, "temps", label_entry_90);
|
||||
AllocaInst* ptr_args = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_90);
|
||||
std::vector<Value*> ptr_tmp_indices;
|
||||
ptr_tmp_indices.push_back(const_int32_29);
|
||||
ptr_tmp_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_tmp = new GetElementPtrInst(ptr_args, ptr_tmp_indices.begin(), ptr_tmp_indices.end(), "tmp", label_entry_90);
|
||||
CastInst* ptr_conv = new BitCastInst(ptr_results, PointerTy_0, "conv", label_entry_90);
|
||||
StoreInst* void_91 = new StoreInst(ptr_conv, ptr_tmp, false, label_entry_90);
|
||||
std::vector<Value*> ptr_tmp2_indices;
|
||||
ptr_tmp2_indices.push_back(const_int32_29);
|
||||
ptr_tmp2_indices.push_back(const_int32_31);
|
||||
Instruction* ptr_tmp2 = new GetElementPtrInst(ptr_args, ptr_tmp2_indices.begin(), ptr_tmp2_indices.end(), "tmp2", label_entry_90);
|
||||
CastInst* ptr_conv4 = new BitCastInst(ptr_inputs, PointerTy_0, "conv4", label_entry_90);
|
||||
StoreInst* void_92 = new StoreInst(ptr_conv4, ptr_tmp2, false, label_entry_90);
|
||||
ICmpInst* int1_cmp_i = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts, const_int32_29, "cmp.i", label_entry_90);
|
||||
new BranchInst(label_forbody_preheader_i, label_from_consts_exit, int1_cmp_i, label_entry_90);
|
||||
|
||||
|
|
@ -544,17 +553,17 @@ Module* createBaseShader() {
|
|||
new BranchInst(label_forbody_i, label_forbody_preheader_i);
|
||||
|
||||
// Block forbody.i (label_forbody_i)
|
||||
Argument* fwdref_96 = new Argument(IntegerType::get(32));
|
||||
Argument* fwdref_95 = new Argument(IntegerType::get(32));
|
||||
PHINode* int32_i_0_reg2mem_0_i = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i);
|
||||
int32_i_0_reg2mem_0_i->reserveOperandSpace(2);
|
||||
int32_i_0_reg2mem_0_i->addIncoming(const_int32_29, label_forbody_preheader_i);
|
||||
int32_i_0_reg2mem_0_i->addIncoming(fwdref_96, label_forbody_i);
|
||||
int32_i_0_reg2mem_0_i->addIncoming(fwdref_95, label_forbody_i);
|
||||
|
||||
Argument* fwdref_97 = new Argument(VectorTy_1);
|
||||
Argument* fwdref_96 = new Argument(VectorTy_1);
|
||||
PHINode* packed_vec_0_reg2mem_0_i = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i);
|
||||
packed_vec_0_reg2mem_0_i->reserveOperandSpace(2);
|
||||
packed_vec_0_reg2mem_0_i->addIncoming(const_packed_32, label_forbody_preheader_i);
|
||||
packed_vec_0_reg2mem_0_i->addIncoming(fwdref_97, label_forbody_i);
|
||||
packed_vec_0_reg2mem_0_i->addIncoming(fwdref_96, label_forbody_i);
|
||||
|
||||
std::vector<Value*> ptr_arraydecay_i_indices;
|
||||
ptr_arraydecay_i_indices.push_back(int32_i_0_reg2mem_0_i);
|
||||
|
|
@ -584,80 +593,40 @@ Module* createBaseShader() {
|
|||
ptr_arrayidx34_i_indices.push_back(const_int32_29);
|
||||
ptr_arrayidx34_i_indices.push_back(int32_i_0_reg2mem_0_i);
|
||||
Instruction* ptr_arrayidx34_i = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i_indices.begin(), ptr_arrayidx34_i_indices.end(), "arrayidx34.i", label_forbody_i);
|
||||
StoreInst* void_98 = new StoreInst(packed_tmp31_i, ptr_arrayidx34_i, false, label_forbody_i);
|
||||
BinaryOperator* int32_indvar_next8 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i, const_int32_31, "indvar.next8", label_forbody_i);
|
||||
ICmpInst* int1_exitcond9 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next8, int32_tmp10_i, "exitcond9", label_forbody_i);
|
||||
new BranchInst(label_from_consts_exit, label_forbody_i, int1_exitcond9, label_forbody_i);
|
||||
StoreInst* void_97 = new StoreInst(packed_tmp31_i, ptr_arrayidx34_i, false, label_forbody_i);
|
||||
BinaryOperator* int32_indvar_next_98 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i, const_int32_31, "indvar.next", label_forbody_i);
|
||||
ICmpInst* int1_exitcond_99 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_98, int32_tmp10_i, "exitcond", label_forbody_i);
|
||||
new BranchInst(label_from_consts_exit, label_forbody_i, int1_exitcond_99, label_forbody_i);
|
||||
|
||||
// Block from_consts.exit (label_from_consts_exit)
|
||||
std::vector<Value*> ptr_tmp2_indices;
|
||||
ptr_tmp2_indices.push_back(const_int32_29);
|
||||
ptr_tmp2_indices.push_back(const_int32_34);
|
||||
Instruction* ptr_tmp2 = new GetElementPtrInst(ptr_args, ptr_tmp2_indices.begin(), ptr_tmp2_indices.end(), "tmp2", label_from_consts_exit);
|
||||
std::vector<Value*> ptr_arraydecay3_indices;
|
||||
ptr_arraydecay3_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay3_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay3 = new GetElementPtrInst(ptr_consts, ptr_arraydecay3_indices.begin(), ptr_arraydecay3_indices.end(), "arraydecay3", label_from_consts_exit);
|
||||
StoreInst* void_100 = new StoreInst(ptr_arraydecay3, ptr_tmp2, false, label_from_consts_exit);
|
||||
std::vector<Value*> ptr_tmp4_indices;
|
||||
ptr_tmp4_indices.push_back(const_int32_29);
|
||||
ptr_tmp4_indices.push_back(const_int32_33);
|
||||
Instruction* ptr_tmp4 = new GetElementPtrInst(ptr_args, ptr_tmp4_indices.begin(), ptr_tmp4_indices.end(), "tmp4", label_from_consts_exit);
|
||||
std::vector<Value*> ptr_arraydecay5_indices;
|
||||
ptr_arraydecay5_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay5_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay5 = new GetElementPtrInst(ptr_temps, ptr_arraydecay5_indices.begin(), ptr_arraydecay5_indices.end(), "arraydecay5", label_from_consts_exit);
|
||||
StoreInst* void_101 = new StoreInst(ptr_arraydecay5, ptr_tmp4, false, label_from_consts_exit);
|
||||
ICmpInst* int1_cmp_102 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_vertices, const_int32_29, "cmp", label_from_consts_exit);
|
||||
new BranchInst(label_forbody_preheader_91, label_afterfor_93, int1_cmp_102, label_from_consts_exit);
|
||||
std::vector<Value*> ptr_tmp7_indices;
|
||||
ptr_tmp7_indices.push_back(const_int32_29);
|
||||
ptr_tmp7_indices.push_back(const_int32_34);
|
||||
Instruction* ptr_tmp7 = new GetElementPtrInst(ptr_args, ptr_tmp7_indices.begin(), ptr_tmp7_indices.end(), "tmp7", label_from_consts_exit);
|
||||
std::vector<Value*> ptr_arraydecay8_indices;
|
||||
ptr_arraydecay8_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay8_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay8 = new GetElementPtrInst(ptr_consts, ptr_arraydecay8_indices.begin(), ptr_arraydecay8_indices.end(), "arraydecay8", label_from_consts_exit);
|
||||
StoreInst* void_101 = new StoreInst(ptr_arraydecay8, ptr_tmp7, false, label_from_consts_exit);
|
||||
std::vector<Value*> ptr_tmp9_indices;
|
||||
ptr_tmp9_indices.push_back(const_int32_29);
|
||||
ptr_tmp9_indices.push_back(const_int32_33);
|
||||
Instruction* ptr_tmp9 = new GetElementPtrInst(ptr_args, ptr_tmp9_indices.begin(), ptr_tmp9_indices.end(), "tmp9", label_from_consts_exit);
|
||||
std::vector<Value*> ptr_arraydecay10_indices;
|
||||
ptr_arraydecay10_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay10_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay10 = new GetElementPtrInst(ptr_temps, ptr_arraydecay10_indices.begin(), ptr_arraydecay10_indices.end(), "arraydecay10", label_from_consts_exit);
|
||||
StoreInst* void_102 = new StoreInst(ptr_arraydecay10, ptr_tmp9, false, label_from_consts_exit);
|
||||
CallInst* void_103 = new CallInst(func_execute_shader, ptr_args, "", label_from_consts_exit);
|
||||
void_103->setCallingConv(CallingConv::C);
|
||||
void_103->setTailCall(false);const ParamAttrsList *void_103_PAL = 0;
|
||||
void_103->setParamAttrs(void_103_PAL);
|
||||
|
||||
// Block forbody.preheader (label_forbody_preheader_91)
|
||||
std::vector<Value*> ptr_tmp8_indices;
|
||||
ptr_tmp8_indices.push_back(const_int32_29);
|
||||
ptr_tmp8_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_tmp8 = new GetElementPtrInst(ptr_args, ptr_tmp8_indices.begin(), ptr_tmp8_indices.end(), "tmp8", label_forbody_preheader_91);
|
||||
std::vector<Value*> ptr_tmp12_indices;
|
||||
ptr_tmp12_indices.push_back(const_int32_29);
|
||||
ptr_tmp12_indices.push_back(const_int32_31);
|
||||
Instruction* ptr_tmp12 = new GetElementPtrInst(ptr_args, ptr_tmp12_indices.begin(), ptr_tmp12_indices.end(), "tmp12", label_forbody_preheader_91);
|
||||
BinaryOperator* int32_tmp_104 = BinaryOperator::create(Instruction::Add, int32_num_vertices, const_int32_30, "tmp", label_forbody_preheader_91);
|
||||
ICmpInst* int1_tmp6 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_104, const_int32_29, "tmp6", label_forbody_preheader_91);
|
||||
SelectInst* int32_tmp7 = new SelectInst(int1_tmp6, const_int32_31, int32_num_vertices, "tmp7", label_forbody_preheader_91);
|
||||
new BranchInst(label_forbody_92, label_forbody_preheader_91);
|
||||
|
||||
// Block forbody (label_forbody_92)
|
||||
Argument* fwdref_107 = new Argument(IntegerType::get(32));
|
||||
PHINode* int32_i_0_reg2mem_0_106 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody_92);
|
||||
int32_i_0_reg2mem_0_106->reserveOperandSpace(2);
|
||||
int32_i_0_reg2mem_0_106->addIncoming(const_int32_29, label_forbody_preheader_91);
|
||||
int32_i_0_reg2mem_0_106->addIncoming(fwdref_107, label_forbody_92);
|
||||
|
||||
std::vector<Value*> ptr_arraydecay11_108_indices;
|
||||
ptr_arraydecay11_108_indices.push_back(int32_i_0_reg2mem_0_106);
|
||||
ptr_arraydecay11_108_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay11_108 = new GetElementPtrInst(ptr_results, ptr_arraydecay11_108_indices.begin(), ptr_arraydecay11_108_indices.end(), "arraydecay11", label_forbody_92);
|
||||
StoreInst* void_109 = new StoreInst(ptr_arraydecay11_108, ptr_tmp8, false, label_forbody_92);
|
||||
std::vector<Value*> ptr_arraydecay16_indices;
|
||||
ptr_arraydecay16_indices.push_back(int32_i_0_reg2mem_0_106);
|
||||
ptr_arraydecay16_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay16 = new GetElementPtrInst(ptr_inputs, ptr_arraydecay16_indices.begin(), ptr_arraydecay16_indices.end(), "arraydecay16", label_forbody_92);
|
||||
StoreInst* void_110 = new StoreInst(ptr_arraydecay16, ptr_tmp12, false, label_forbody_92);
|
||||
CallInst* void_111 = new CallInst(func_execute_shader, ptr_args, "", label_forbody_92);
|
||||
void_111->setCallingConv(CallingConv::C);
|
||||
void_111->setTailCall(false);const ParamAttrsList *void_111_PAL = 0;
|
||||
void_111->setParamAttrs(void_111_PAL);
|
||||
|
||||
BinaryOperator* int32_indvar_next_112 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_106, const_int32_31, "indvar.next", label_forbody_92);
|
||||
ICmpInst* int1_exitcond_113 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_112, int32_tmp7, "exitcond", label_forbody_92);
|
||||
new BranchInst(label_afterfor_93, label_forbody_92, int1_exitcond_113, label_forbody_92);
|
||||
|
||||
// Block afterfor (label_afterfor_93)
|
||||
new ReturnInst(label_afterfor_93);
|
||||
new ReturnInst(label_from_consts_exit);
|
||||
|
||||
// Resolve Forward References
|
||||
fwdref_107->replaceAllUsesWith(int32_indvar_next_112); delete fwdref_107;
|
||||
fwdref_97->replaceAllUsesWith(packed_tmp31_i); delete fwdref_97;
|
||||
fwdref_96->replaceAllUsesWith(int32_indvar_next8); delete fwdref_96;
|
||||
fwdref_96->replaceAllUsesWith(packed_tmp31_i); delete fwdref_96;
|
||||
fwdref_95->replaceAllUsesWith(int32_indvar_next_98); delete fwdref_95;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -668,195 +637,195 @@ Module* createBaseShader() {
|
|||
float_x->setName("x");
|
||||
Value* float_y = args++;
|
||||
float_y->setName("y");
|
||||
Value* ptr_results_116 = args++;
|
||||
ptr_results_116->setName("results");
|
||||
Value* ptr_inputs_117 = args++;
|
||||
ptr_inputs_117->setName("inputs");
|
||||
Value* int32_num_inputs_118 = args++;
|
||||
int32_num_inputs_118->setName("num_inputs");
|
||||
Value* ptr_aconsts_119 = args++;
|
||||
ptr_aconsts_119->setName("aconsts");
|
||||
Value* int32_num_consts_120 = args++;
|
||||
int32_num_consts_120->setName("num_consts");
|
||||
Value* ptr_results_105 = args++;
|
||||
ptr_results_105->setName("results");
|
||||
Value* ptr_inputs_106 = args++;
|
||||
ptr_inputs_106->setName("inputs");
|
||||
Value* int32_num_inputs_107 = args++;
|
||||
int32_num_inputs_107->setName("num_inputs");
|
||||
Value* ptr_aconsts_108 = args++;
|
||||
ptr_aconsts_108->setName("aconsts");
|
||||
Value* int32_num_consts_109 = args++;
|
||||
int32_num_consts_109->setName("num_consts");
|
||||
Value* ptr_samplers = args++;
|
||||
ptr_samplers->setName("samplers");
|
||||
|
||||
BasicBlock* label_entry_121 = new BasicBlock("entry",func_run_fragment_shader,0);
|
||||
BasicBlock* label_forbody_preheader_i_122 = new BasicBlock("forbody.preheader.i",func_run_fragment_shader,0);
|
||||
BasicBlock* label_forbody_i_123 = new BasicBlock("forbody.i",func_run_fragment_shader,0);
|
||||
BasicBlock* label_from_consts_exit_124 = new BasicBlock("from_consts.exit",func_run_fragment_shader,0);
|
||||
BasicBlock* label_entry_110 = new BasicBlock("entry",func_run_fragment_shader,0);
|
||||
BasicBlock* label_forbody_preheader_i_111 = new BasicBlock("forbody.preheader.i",func_run_fragment_shader,0);
|
||||
BasicBlock* label_forbody_i_112 = new BasicBlock("forbody.i",func_run_fragment_shader,0);
|
||||
BasicBlock* label_from_consts_exit_113 = new BasicBlock("from_consts.exit",func_run_fragment_shader,0);
|
||||
|
||||
// Block entry (label_entry_121)
|
||||
AllocaInst* ptr_consts_125 = new AllocaInst(ArrayTy_20, "consts", label_entry_121);
|
||||
AllocaInst* ptr_temps_126 = new AllocaInst(ArrayTy_22, "temps", label_entry_121);
|
||||
AllocaInst* ptr_args_127 = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_121);
|
||||
std::vector<Value*> ptr_tmp_indices;
|
||||
ptr_tmp_indices.push_back(const_int32_29);
|
||||
ptr_tmp_indices.push_back(const_int32_35);
|
||||
Instruction* ptr_tmp = new GetElementPtrInst(ptr_args_127, ptr_tmp_indices.begin(), ptr_tmp_indices.end(), "tmp", label_entry_121);
|
||||
StoreInst* void_128 = new StoreInst(const_int32_29, ptr_tmp, false, label_entry_121);
|
||||
ICmpInst* int1_cmp_i_129 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts_120, const_int32_29, "cmp.i", label_entry_121);
|
||||
new BranchInst(label_forbody_preheader_i_122, label_from_consts_exit_124, int1_cmp_i_129, label_entry_121);
|
||||
// Block entry (label_entry_110)
|
||||
AllocaInst* ptr_consts_114 = new AllocaInst(ArrayTy_20, "consts", label_entry_110);
|
||||
AllocaInst* ptr_temps_115 = new AllocaInst(ArrayTy_22, "temps", label_entry_110);
|
||||
AllocaInst* ptr_args_116 = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_110);
|
||||
std::vector<Value*> ptr_tmp_117_indices;
|
||||
ptr_tmp_117_indices.push_back(const_int32_29);
|
||||
ptr_tmp_117_indices.push_back(const_int32_35);
|
||||
Instruction* ptr_tmp_117 = new GetElementPtrInst(ptr_args_116, ptr_tmp_117_indices.begin(), ptr_tmp_117_indices.end(), "tmp", label_entry_110);
|
||||
StoreInst* void_118 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_entry_110);
|
||||
ICmpInst* int1_cmp_i_119 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts_109, const_int32_29, "cmp.i", label_entry_110);
|
||||
new BranchInst(label_forbody_preheader_i_111, label_from_consts_exit_113, int1_cmp_i_119, label_entry_110);
|
||||
|
||||
// Block forbody.preheader.i (label_forbody_preheader_i_122)
|
||||
BinaryOperator* int32_tmp_i_131 = BinaryOperator::create(Instruction::Add, int32_num_consts_120, const_int32_30, "tmp.i", label_forbody_preheader_i_122);
|
||||
ICmpInst* int1_tmp9_i_132 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_i_131, const_int32_29, "tmp9.i", label_forbody_preheader_i_122);
|
||||
SelectInst* int32_tmp10_i_133 = new SelectInst(int1_tmp9_i_132, const_int32_31, int32_num_consts_120, "tmp10.i", label_forbody_preheader_i_122);
|
||||
new BranchInst(label_forbody_i_123, label_forbody_preheader_i_122);
|
||||
// Block forbody.preheader.i (label_forbody_preheader_i_111)
|
||||
BinaryOperator* int32_tmp_i_121 = BinaryOperator::create(Instruction::Add, int32_num_consts_109, const_int32_30, "tmp.i", label_forbody_preheader_i_111);
|
||||
ICmpInst* int1_tmp9_i_122 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_i_121, const_int32_29, "tmp9.i", label_forbody_preheader_i_111);
|
||||
SelectInst* int32_tmp10_i_123 = new SelectInst(int1_tmp9_i_122, const_int32_31, int32_num_consts_109, "tmp10.i", label_forbody_preheader_i_111);
|
||||
new BranchInst(label_forbody_i_112, label_forbody_preheader_i_111);
|
||||
|
||||
// Block forbody.i (label_forbody_i_123)
|
||||
Argument* fwdref_136 = new Argument(IntegerType::get(32));
|
||||
PHINode* int32_i_0_reg2mem_0_i_135 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i_123);
|
||||
int32_i_0_reg2mem_0_i_135->reserveOperandSpace(2);
|
||||
int32_i_0_reg2mem_0_i_135->addIncoming(const_int32_29, label_forbody_preheader_i_122);
|
||||
int32_i_0_reg2mem_0_i_135->addIncoming(fwdref_136, label_forbody_i_123);
|
||||
// Block forbody.i (label_forbody_i_112)
|
||||
Argument* fwdref_126 = new Argument(IntegerType::get(32));
|
||||
PHINode* int32_i_0_reg2mem_0_i_125 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i_112);
|
||||
int32_i_0_reg2mem_0_i_125->reserveOperandSpace(2);
|
||||
int32_i_0_reg2mem_0_i_125->addIncoming(const_int32_29, label_forbody_preheader_i_111);
|
||||
int32_i_0_reg2mem_0_i_125->addIncoming(fwdref_126, label_forbody_i_112);
|
||||
|
||||
Argument* fwdref_138 = new Argument(VectorTy_1);
|
||||
PHINode* packed_vec_0_reg2mem_0_i_137 = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i_123);
|
||||
packed_vec_0_reg2mem_0_i_137->reserveOperandSpace(2);
|
||||
packed_vec_0_reg2mem_0_i_137->addIncoming(const_packed_32, label_forbody_preheader_i_122);
|
||||
packed_vec_0_reg2mem_0_i_137->addIncoming(fwdref_138, label_forbody_i_123);
|
||||
Argument* fwdref_128 = new Argument(VectorTy_1);
|
||||
PHINode* packed_vec_0_reg2mem_0_i_127 = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i_112);
|
||||
packed_vec_0_reg2mem_0_i_127->reserveOperandSpace(2);
|
||||
packed_vec_0_reg2mem_0_i_127->addIncoming(const_packed_32, label_forbody_preheader_i_111);
|
||||
packed_vec_0_reg2mem_0_i_127->addIncoming(fwdref_128, label_forbody_i_112);
|
||||
|
||||
std::vector<Value*> ptr_arraydecay_i_139_indices;
|
||||
ptr_arraydecay_i_139_indices.push_back(int32_i_0_reg2mem_0_i_135);
|
||||
ptr_arraydecay_i_139_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay_i_139 = new GetElementPtrInst(ptr_aconsts_119, ptr_arraydecay_i_139_indices.begin(), ptr_arraydecay_i_139_indices.end(), "arraydecay.i", label_forbody_i_123);
|
||||
LoadInst* float_tmp5_i_140 = new LoadInst(ptr_arraydecay_i_139, "tmp5.i", false, label_forbody_i_123);
|
||||
InsertElementInst* packed_tmp7_i_141 = new InsertElementInst(packed_vec_0_reg2mem_0_i_137, float_tmp5_i_140, const_int32_29, "tmp7.i", label_forbody_i_123);
|
||||
std::vector<Value*> ptr_arrayidx12_i_142_indices;
|
||||
ptr_arrayidx12_i_142_indices.push_back(int32_i_0_reg2mem_0_i_135);
|
||||
ptr_arrayidx12_i_142_indices.push_back(const_int32_31);
|
||||
Instruction* ptr_arrayidx12_i_142 = new GetElementPtrInst(ptr_aconsts_119, ptr_arrayidx12_i_142_indices.begin(), ptr_arrayidx12_i_142_indices.end(), "arrayidx12.i", label_forbody_i_123);
|
||||
LoadInst* float_tmp13_i_143 = new LoadInst(ptr_arrayidx12_i_142, "tmp13.i", false, label_forbody_i_123);
|
||||
InsertElementInst* packed_tmp15_i_144 = new InsertElementInst(packed_tmp7_i_141, float_tmp13_i_143, const_int32_31, "tmp15.i", label_forbody_i_123);
|
||||
std::vector<Value*> ptr_arrayidx20_i_145_indices;
|
||||
ptr_arrayidx20_i_145_indices.push_back(int32_i_0_reg2mem_0_i_135);
|
||||
ptr_arrayidx20_i_145_indices.push_back(const_int32_33);
|
||||
Instruction* ptr_arrayidx20_i_145 = new GetElementPtrInst(ptr_aconsts_119, ptr_arrayidx20_i_145_indices.begin(), ptr_arrayidx20_i_145_indices.end(), "arrayidx20.i", label_forbody_i_123);
|
||||
LoadInst* float_tmp21_i_146 = new LoadInst(ptr_arrayidx20_i_145, "tmp21.i", false, label_forbody_i_123);
|
||||
InsertElementInst* packed_tmp23_i_147 = new InsertElementInst(packed_tmp15_i_144, float_tmp21_i_146, const_int32_33, "tmp23.i", label_forbody_i_123);
|
||||
std::vector<Value*> ptr_arrayidx28_i_148_indices;
|
||||
ptr_arrayidx28_i_148_indices.push_back(int32_i_0_reg2mem_0_i_135);
|
||||
ptr_arrayidx28_i_148_indices.push_back(const_int32_34);
|
||||
Instruction* ptr_arrayidx28_i_148 = new GetElementPtrInst(ptr_aconsts_119, ptr_arrayidx28_i_148_indices.begin(), ptr_arrayidx28_i_148_indices.end(), "arrayidx28.i", label_forbody_i_123);
|
||||
LoadInst* float_tmp29_i_149 = new LoadInst(ptr_arrayidx28_i_148, "tmp29.i", false, label_forbody_i_123);
|
||||
InsertElementInst* packed_tmp31_i_150 = new InsertElementInst(packed_tmp23_i_147, float_tmp29_i_149, const_int32_34, "tmp31.i", label_forbody_i_123);
|
||||
std::vector<Value*> ptr_arrayidx34_i_151_indices;
|
||||
ptr_arrayidx34_i_151_indices.push_back(const_int32_29);
|
||||
ptr_arrayidx34_i_151_indices.push_back(int32_i_0_reg2mem_0_i_135);
|
||||
Instruction* ptr_arrayidx34_i_151 = new GetElementPtrInst(ptr_consts_125, ptr_arrayidx34_i_151_indices.begin(), ptr_arrayidx34_i_151_indices.end(), "arrayidx34.i", label_forbody_i_123);
|
||||
StoreInst* void_152 = new StoreInst(packed_tmp31_i_150, ptr_arrayidx34_i_151, false, label_forbody_i_123);
|
||||
BinaryOperator* int32_indvar_next7 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i_135, const_int32_31, "indvar.next7", label_forbody_i_123);
|
||||
ICmpInst* int1_exitcond8 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next7, int32_tmp10_i_133, "exitcond8", label_forbody_i_123);
|
||||
new BranchInst(label_from_consts_exit_124, label_forbody_i_123, int1_exitcond8, label_forbody_i_123);
|
||||
std::vector<Value*> ptr_arraydecay_i_129_indices;
|
||||
ptr_arraydecay_i_129_indices.push_back(int32_i_0_reg2mem_0_i_125);
|
||||
ptr_arraydecay_i_129_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay_i_129 = new GetElementPtrInst(ptr_aconsts_108, ptr_arraydecay_i_129_indices.begin(), ptr_arraydecay_i_129_indices.end(), "arraydecay.i", label_forbody_i_112);
|
||||
LoadInst* float_tmp5_i_130 = new LoadInst(ptr_arraydecay_i_129, "tmp5.i", false, label_forbody_i_112);
|
||||
InsertElementInst* packed_tmp7_i_131 = new InsertElementInst(packed_vec_0_reg2mem_0_i_127, float_tmp5_i_130, const_int32_29, "tmp7.i", label_forbody_i_112);
|
||||
std::vector<Value*> ptr_arrayidx12_i_132_indices;
|
||||
ptr_arrayidx12_i_132_indices.push_back(int32_i_0_reg2mem_0_i_125);
|
||||
ptr_arrayidx12_i_132_indices.push_back(const_int32_31);
|
||||
Instruction* ptr_arrayidx12_i_132 = new GetElementPtrInst(ptr_aconsts_108, ptr_arrayidx12_i_132_indices.begin(), ptr_arrayidx12_i_132_indices.end(), "arrayidx12.i", label_forbody_i_112);
|
||||
LoadInst* float_tmp13_i_133 = new LoadInst(ptr_arrayidx12_i_132, "tmp13.i", false, label_forbody_i_112);
|
||||
InsertElementInst* packed_tmp15_i_134 = new InsertElementInst(packed_tmp7_i_131, float_tmp13_i_133, const_int32_31, "tmp15.i", label_forbody_i_112);
|
||||
std::vector<Value*> ptr_arrayidx20_i_135_indices;
|
||||
ptr_arrayidx20_i_135_indices.push_back(int32_i_0_reg2mem_0_i_125);
|
||||
ptr_arrayidx20_i_135_indices.push_back(const_int32_33);
|
||||
Instruction* ptr_arrayidx20_i_135 = new GetElementPtrInst(ptr_aconsts_108, ptr_arrayidx20_i_135_indices.begin(), ptr_arrayidx20_i_135_indices.end(), "arrayidx20.i", label_forbody_i_112);
|
||||
LoadInst* float_tmp21_i_136 = new LoadInst(ptr_arrayidx20_i_135, "tmp21.i", false, label_forbody_i_112);
|
||||
InsertElementInst* packed_tmp23_i_137 = new InsertElementInst(packed_tmp15_i_134, float_tmp21_i_136, const_int32_33, "tmp23.i", label_forbody_i_112);
|
||||
std::vector<Value*> ptr_arrayidx28_i_138_indices;
|
||||
ptr_arrayidx28_i_138_indices.push_back(int32_i_0_reg2mem_0_i_125);
|
||||
ptr_arrayidx28_i_138_indices.push_back(const_int32_34);
|
||||
Instruction* ptr_arrayidx28_i_138 = new GetElementPtrInst(ptr_aconsts_108, ptr_arrayidx28_i_138_indices.begin(), ptr_arrayidx28_i_138_indices.end(), "arrayidx28.i", label_forbody_i_112);
|
||||
LoadInst* float_tmp29_i_139 = new LoadInst(ptr_arrayidx28_i_138, "tmp29.i", false, label_forbody_i_112);
|
||||
InsertElementInst* packed_tmp31_i_140 = new InsertElementInst(packed_tmp23_i_137, float_tmp29_i_139, const_int32_34, "tmp31.i", label_forbody_i_112);
|
||||
std::vector<Value*> ptr_arrayidx34_i_141_indices;
|
||||
ptr_arrayidx34_i_141_indices.push_back(const_int32_29);
|
||||
ptr_arrayidx34_i_141_indices.push_back(int32_i_0_reg2mem_0_i_125);
|
||||
Instruction* ptr_arrayidx34_i_141 = new GetElementPtrInst(ptr_consts_114, ptr_arrayidx34_i_141_indices.begin(), ptr_arrayidx34_i_141_indices.end(), "arrayidx34.i", label_forbody_i_112);
|
||||
StoreInst* void_142 = new StoreInst(packed_tmp31_i_140, ptr_arrayidx34_i_141, false, label_forbody_i_112);
|
||||
BinaryOperator* int32_indvar_next7 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i_125, const_int32_31, "indvar.next7", label_forbody_i_112);
|
||||
ICmpInst* int1_exitcond8 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next7, int32_tmp10_i_123, "exitcond8", label_forbody_i_112);
|
||||
new BranchInst(label_from_consts_exit_113, label_forbody_i_112, int1_exitcond8, label_forbody_i_112);
|
||||
|
||||
// Block from_consts.exit (label_from_consts_exit_124)
|
||||
// Block from_consts.exit (label_from_consts_exit_113)
|
||||
std::vector<Value*> ptr_tmp3_indices;
|
||||
ptr_tmp3_indices.push_back(const_int32_29);
|
||||
ptr_tmp3_indices.push_back(const_int32_34);
|
||||
Instruction* ptr_tmp3 = new GetElementPtrInst(ptr_args_127, ptr_tmp3_indices.begin(), ptr_tmp3_indices.end(), "tmp3", label_from_consts_exit_124);
|
||||
Instruction* ptr_tmp3 = new GetElementPtrInst(ptr_args_116, ptr_tmp3_indices.begin(), ptr_tmp3_indices.end(), "tmp3", label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay4_indices;
|
||||
ptr_arraydecay4_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay4_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay4 = new GetElementPtrInst(ptr_consts_125, ptr_arraydecay4_indices.begin(), ptr_arraydecay4_indices.end(), "arraydecay4", label_from_consts_exit_124);
|
||||
StoreInst* void_154 = new StoreInst(ptr_arraydecay4, ptr_tmp3, false, label_from_consts_exit_124);
|
||||
Instruction* ptr_arraydecay4 = new GetElementPtrInst(ptr_consts_114, ptr_arraydecay4_indices.begin(), ptr_arraydecay4_indices.end(), "arraydecay4", label_from_consts_exit_113);
|
||||
StoreInst* void_144 = new StoreInst(ptr_arraydecay4, ptr_tmp3, false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_tmp5_indices;
|
||||
ptr_tmp5_indices.push_back(const_int32_29);
|
||||
ptr_tmp5_indices.push_back(const_int32_33);
|
||||
Instruction* ptr_tmp5 = new GetElementPtrInst(ptr_args_127, ptr_tmp5_indices.begin(), ptr_tmp5_indices.end(), "tmp5", label_from_consts_exit_124);
|
||||
Instruction* ptr_tmp5 = new GetElementPtrInst(ptr_args_116, ptr_tmp5_indices.begin(), ptr_tmp5_indices.end(), "tmp5", label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay6_indices;
|
||||
ptr_arraydecay6_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay6_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay6 = new GetElementPtrInst(ptr_temps_126, ptr_arraydecay6_indices.begin(), ptr_arraydecay6_indices.end(), "arraydecay6", label_from_consts_exit_124);
|
||||
StoreInst* void_155 = new StoreInst(ptr_arraydecay6, ptr_tmp5, false, label_from_consts_exit_124);
|
||||
std::vector<Value*> ptr_tmp8_156_indices;
|
||||
ptr_tmp8_156_indices.push_back(const_int32_29);
|
||||
ptr_tmp8_156_indices.push_back(const_int32_31);
|
||||
Instruction* ptr_tmp8_156 = new GetElementPtrInst(ptr_args_127, ptr_tmp8_156_indices.begin(), ptr_tmp8_156_indices.end(), "tmp8", label_from_consts_exit_124);
|
||||
std::vector<Value*> ptr_tmp12_157_indices;
|
||||
ptr_tmp12_157_indices.push_back(const_int32_29);
|
||||
ptr_tmp12_157_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_tmp12_157 = new GetElementPtrInst(ptr_args_127, ptr_tmp12_157_indices.begin(), ptr_tmp12_157_indices.end(), "tmp12", label_from_consts_exit_124);
|
||||
std::vector<Value*> ptr_arraydecay11_158_indices;
|
||||
ptr_arraydecay11_158_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay11_158_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay11_158 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_158_indices.begin(), ptr_arraydecay11_158_indices.end(), "arraydecay11", label_from_consts_exit_124);
|
||||
StoreInst* void_159 = new StoreInst(ptr_arraydecay11_158, ptr_tmp8_156, false, label_from_consts_exit_124);
|
||||
std::vector<Value*> ptr_arraydecay16_160_indices;
|
||||
ptr_arraydecay16_160_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay16_160_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay16_160 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_160_indices.begin(), ptr_arraydecay16_160_indices.end(), "arraydecay16", label_from_consts_exit_124);
|
||||
StoreInst* void_161 = new StoreInst(ptr_arraydecay16_160, ptr_tmp12_157, false, label_from_consts_exit_124);
|
||||
StoreInst* void_162 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124);
|
||||
CallInst* void_163 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124);
|
||||
void_163->setCallingConv(CallingConv::C);
|
||||
void_163->setTailCall(false);const ParamAttrsList *void_163_PAL = 0;
|
||||
void_163->setParamAttrs(void_163_PAL);
|
||||
Instruction* ptr_arraydecay6 = new GetElementPtrInst(ptr_temps_115, ptr_arraydecay6_indices.begin(), ptr_arraydecay6_indices.end(), "arraydecay6", label_from_consts_exit_113);
|
||||
StoreInst* void_145 = new StoreInst(ptr_arraydecay6, ptr_tmp5, false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_tmp8_indices;
|
||||
ptr_tmp8_indices.push_back(const_int32_29);
|
||||
ptr_tmp8_indices.push_back(const_int32_31);
|
||||
Instruction* ptr_tmp8 = new GetElementPtrInst(ptr_args_116, ptr_tmp8_indices.begin(), ptr_tmp8_indices.end(), "tmp8", label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_tmp12_indices;
|
||||
ptr_tmp12_indices.push_back(const_int32_29);
|
||||
ptr_tmp12_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_tmp12 = new GetElementPtrInst(ptr_args_116, ptr_tmp12_indices.begin(), ptr_tmp12_indices.end(), "tmp12", label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay11_146_indices;
|
||||
ptr_arraydecay11_146_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay11_146_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay11_146 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_146_indices.begin(), ptr_arraydecay11_146_indices.end(), "arraydecay11", label_from_consts_exit_113);
|
||||
StoreInst* void_147 = new StoreInst(ptr_arraydecay11_146, ptr_tmp8, false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay16_indices;
|
||||
ptr_arraydecay16_indices.push_back(const_int32_29);
|
||||
ptr_arraydecay16_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay16 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_indices.begin(), ptr_arraydecay16_indices.end(), "arraydecay16", label_from_consts_exit_113);
|
||||
StoreInst* void_148 = new StoreInst(ptr_arraydecay16, ptr_tmp12, false, label_from_consts_exit_113);
|
||||
StoreInst* void_149 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
|
||||
CallInst* void_150 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
|
||||
void_150->setCallingConv(CallingConv::C);
|
||||
void_150->setTailCall(false);const ParamAttrsList *void_150_PAL = 0;
|
||||
void_150->setParamAttrs(void_150_PAL);
|
||||
|
||||
LoadInst* int32_tmp23 = new LoadInst(ptr_tmp, "tmp23", false, label_from_consts_exit_124);
|
||||
LoadInst* int32_tmp23 = new LoadInst(ptr_tmp_117, "tmp23", false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay11_1_indices;
|
||||
ptr_arraydecay11_1_indices.push_back(const_int32_31);
|
||||
ptr_arraydecay11_1_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay11_1 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_1_indices.begin(), ptr_arraydecay11_1_indices.end(), "arraydecay11.1", label_from_consts_exit_124);
|
||||
StoreInst* void_164 = new StoreInst(ptr_arraydecay11_1, ptr_tmp8_156, false, label_from_consts_exit_124);
|
||||
Instruction* ptr_arraydecay11_1 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_1_indices.begin(), ptr_arraydecay11_1_indices.end(), "arraydecay11.1", label_from_consts_exit_113);
|
||||
StoreInst* void_151 = new StoreInst(ptr_arraydecay11_1, ptr_tmp8, false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay16_1_indices;
|
||||
ptr_arraydecay16_1_indices.push_back(const_int32_31);
|
||||
ptr_arraydecay16_1_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay16_1 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_1_indices.begin(), ptr_arraydecay16_1_indices.end(), "arraydecay16.1", label_from_consts_exit_124);
|
||||
StoreInst* void_165 = new StoreInst(ptr_arraydecay16_1, ptr_tmp12_157, false, label_from_consts_exit_124);
|
||||
StoreInst* void_166 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124);
|
||||
CallInst* void_167 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124);
|
||||
void_167->setCallingConv(CallingConv::C);
|
||||
void_167->setTailCall(false);const ParamAttrsList *void_167_PAL = 0;
|
||||
void_167->setParamAttrs(void_167_PAL);
|
||||
Instruction* ptr_arraydecay16_1 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_1_indices.begin(), ptr_arraydecay16_1_indices.end(), "arraydecay16.1", label_from_consts_exit_113);
|
||||
StoreInst* void_152 = new StoreInst(ptr_arraydecay16_1, ptr_tmp12, false, label_from_consts_exit_113);
|
||||
StoreInst* void_153 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
|
||||
CallInst* void_154 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
|
||||
void_154->setCallingConv(CallingConv::C);
|
||||
void_154->setTailCall(false);const ParamAttrsList *void_154_PAL = 0;
|
||||
void_154->setParamAttrs(void_154_PAL);
|
||||
|
||||
LoadInst* int32_tmp23_1 = new LoadInst(ptr_tmp, "tmp23.1", false, label_from_consts_exit_124);
|
||||
BinaryOperator* int32_shl_1 = BinaryOperator::create(Instruction::Shl, int32_tmp23_1, const_int32_31, "shl.1", label_from_consts_exit_124);
|
||||
BinaryOperator* int32_or_1 = BinaryOperator::create(Instruction::Or, int32_shl_1, int32_tmp23, "or.1", label_from_consts_exit_124);
|
||||
LoadInst* int32_tmp23_1 = new LoadInst(ptr_tmp_117, "tmp23.1", false, label_from_consts_exit_113);
|
||||
BinaryOperator* int32_shl_1 = BinaryOperator::create(Instruction::Shl, int32_tmp23_1, const_int32_31, "shl.1", label_from_consts_exit_113);
|
||||
BinaryOperator* int32_or_1 = BinaryOperator::create(Instruction::Or, int32_shl_1, int32_tmp23, "or.1", label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay11_2_indices;
|
||||
ptr_arraydecay11_2_indices.push_back(const_int32_33);
|
||||
ptr_arraydecay11_2_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay11_2 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_2_indices.begin(), ptr_arraydecay11_2_indices.end(), "arraydecay11.2", label_from_consts_exit_124);
|
||||
StoreInst* void_168 = new StoreInst(ptr_arraydecay11_2, ptr_tmp8_156, false, label_from_consts_exit_124);
|
||||
Instruction* ptr_arraydecay11_2 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_2_indices.begin(), ptr_arraydecay11_2_indices.end(), "arraydecay11.2", label_from_consts_exit_113);
|
||||
StoreInst* void_155 = new StoreInst(ptr_arraydecay11_2, ptr_tmp8, false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay16_2_indices;
|
||||
ptr_arraydecay16_2_indices.push_back(const_int32_33);
|
||||
ptr_arraydecay16_2_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay16_2 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_2_indices.begin(), ptr_arraydecay16_2_indices.end(), "arraydecay16.2", label_from_consts_exit_124);
|
||||
StoreInst* void_169 = new StoreInst(ptr_arraydecay16_2, ptr_tmp12_157, false, label_from_consts_exit_124);
|
||||
StoreInst* void_170 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124);
|
||||
CallInst* void_171 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124);
|
||||
void_171->setCallingConv(CallingConv::C);
|
||||
void_171->setTailCall(false);const ParamAttrsList *void_171_PAL = 0;
|
||||
void_171->setParamAttrs(void_171_PAL);
|
||||
Instruction* ptr_arraydecay16_2 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_2_indices.begin(), ptr_arraydecay16_2_indices.end(), "arraydecay16.2", label_from_consts_exit_113);
|
||||
StoreInst* void_156 = new StoreInst(ptr_arraydecay16_2, ptr_tmp12, false, label_from_consts_exit_113);
|
||||
StoreInst* void_157 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
|
||||
CallInst* void_158 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
|
||||
void_158->setCallingConv(CallingConv::C);
|
||||
void_158->setTailCall(false);const ParamAttrsList *void_158_PAL = 0;
|
||||
void_158->setParamAttrs(void_158_PAL);
|
||||
|
||||
LoadInst* int32_tmp23_2 = new LoadInst(ptr_tmp, "tmp23.2", false, label_from_consts_exit_124);
|
||||
BinaryOperator* int32_shl_2 = BinaryOperator::create(Instruction::Shl, int32_tmp23_2, const_int32_33, "shl.2", label_from_consts_exit_124);
|
||||
BinaryOperator* int32_or_2 = BinaryOperator::create(Instruction::Or, int32_shl_2, int32_or_1, "or.2", label_from_consts_exit_124);
|
||||
LoadInst* int32_tmp23_2 = new LoadInst(ptr_tmp_117, "tmp23.2", false, label_from_consts_exit_113);
|
||||
BinaryOperator* int32_shl_2 = BinaryOperator::create(Instruction::Shl, int32_tmp23_2, const_int32_33, "shl.2", label_from_consts_exit_113);
|
||||
BinaryOperator* int32_or_2 = BinaryOperator::create(Instruction::Or, int32_shl_2, int32_or_1, "or.2", label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay11_3_indices;
|
||||
ptr_arraydecay11_3_indices.push_back(const_int32_34);
|
||||
ptr_arraydecay11_3_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay11_3 = new GetElementPtrInst(ptr_inputs_117, ptr_arraydecay11_3_indices.begin(), ptr_arraydecay11_3_indices.end(), "arraydecay11.3", label_from_consts_exit_124);
|
||||
StoreInst* void_172 = new StoreInst(ptr_arraydecay11_3, ptr_tmp8_156, false, label_from_consts_exit_124);
|
||||
Instruction* ptr_arraydecay11_3 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_3_indices.begin(), ptr_arraydecay11_3_indices.end(), "arraydecay11.3", label_from_consts_exit_113);
|
||||
StoreInst* void_159 = new StoreInst(ptr_arraydecay11_3, ptr_tmp8, false, label_from_consts_exit_113);
|
||||
std::vector<Value*> ptr_arraydecay16_3_indices;
|
||||
ptr_arraydecay16_3_indices.push_back(const_int32_34);
|
||||
ptr_arraydecay16_3_indices.push_back(const_int32_29);
|
||||
Instruction* ptr_arraydecay16_3 = new GetElementPtrInst(ptr_results_116, ptr_arraydecay16_3_indices.begin(), ptr_arraydecay16_3_indices.end(), "arraydecay16.3", label_from_consts_exit_124);
|
||||
StoreInst* void_173 = new StoreInst(ptr_arraydecay16_3, ptr_tmp12_157, false, label_from_consts_exit_124);
|
||||
StoreInst* void_174 = new StoreInst(const_int32_29, ptr_tmp, false, label_from_consts_exit_124);
|
||||
CallInst* void_175 = new CallInst(func_execute_shader, ptr_args_127, "", label_from_consts_exit_124);
|
||||
void_175->setCallingConv(CallingConv::C);
|
||||
void_175->setTailCall(false);const ParamAttrsList *void_175_PAL = 0;
|
||||
void_175->setParamAttrs(void_175_PAL);
|
||||
Instruction* ptr_arraydecay16_3 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_3_indices.begin(), ptr_arraydecay16_3_indices.end(), "arraydecay16.3", label_from_consts_exit_113);
|
||||
StoreInst* void_160 = new StoreInst(ptr_arraydecay16_3, ptr_tmp12, false, label_from_consts_exit_113);
|
||||
StoreInst* void_161 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
|
||||
CallInst* void_162 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
|
||||
void_162->setCallingConv(CallingConv::C);
|
||||
void_162->setTailCall(false);const ParamAttrsList *void_162_PAL = 0;
|
||||
void_162->setParamAttrs(void_162_PAL);
|
||||
|
||||
LoadInst* int32_tmp23_3 = new LoadInst(ptr_tmp, "tmp23.3", false, label_from_consts_exit_124);
|
||||
BinaryOperator* int32_shl_3 = BinaryOperator::create(Instruction::Shl, int32_tmp23_3, const_int32_34, "shl.3", label_from_consts_exit_124);
|
||||
BinaryOperator* int32_or_3 = BinaryOperator::create(Instruction::Or, int32_shl_3, int32_or_2, "or.3", label_from_consts_exit_124);
|
||||
BinaryOperator* int32_neg = BinaryOperator::create(Instruction::Xor, int32_or_3, const_int32_30, "neg", label_from_consts_exit_124);
|
||||
new ReturnInst(int32_neg, label_from_consts_exit_124);
|
||||
LoadInst* int32_tmp23_3 = new LoadInst(ptr_tmp_117, "tmp23.3", false, label_from_consts_exit_113);
|
||||
BinaryOperator* int32_shl_3 = BinaryOperator::create(Instruction::Shl, int32_tmp23_3, const_int32_34, "shl.3", label_from_consts_exit_113);
|
||||
BinaryOperator* int32_or_3 = BinaryOperator::create(Instruction::Or, int32_shl_3, int32_or_2, "or.3", label_from_consts_exit_113);
|
||||
BinaryOperator* int32_neg = BinaryOperator::create(Instruction::Xor, int32_or_3, const_int32_30, "neg", label_from_consts_exit_113);
|
||||
new ReturnInst(int32_neg, label_from_consts_exit_113);
|
||||
|
||||
// Resolve Forward References
|
||||
fwdref_138->replaceAllUsesWith(packed_tmp31_i_150); delete fwdref_138;
|
||||
fwdref_136->replaceAllUsesWith(int32_indvar_next7); delete fwdref_136;
|
||||
fwdref_128->replaceAllUsesWith(packed_tmp31_i_140); delete fwdref_128;
|
||||
fwdref_126->replaceAllUsesWith(int32_indvar_next7); delete fwdref_126;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ struct ShaderInput
|
|||
|
||||
extern void execute_shader(struct ShaderInput *input);
|
||||
|
||||
void run_vertex_shader(float4 (*inputs)[16],
|
||||
float4 (*results)[16],
|
||||
void run_vertex_shader(void *inputs,
|
||||
void *results,
|
||||
float (*aconsts)[4],
|
||||
int num_vertices,
|
||||
int num_inputs,
|
||||
|
|
@ -98,16 +98,16 @@ void run_vertex_shader(float4 (*inputs)[16],
|
|||
float4 temps[128];//MAX_PROGRAM_TEMPS
|
||||
|
||||
struct ShaderInput args;
|
||||
args.dests = results;
|
||||
args.inputs = inputs;
|
||||
|
||||
/*printf("XXX LLVM run_vertex_shader vertices = %d, inputs = %d, attribs = %d, consts = %d\n",
|
||||
num_vertices, num_inputs, num_attribs, num_consts);*/
|
||||
from_consts(consts, aconsts, num_consts);
|
||||
args.consts = consts;
|
||||
args.temps = temps;
|
||||
for (int i = 0; i < num_vertices; ++i) {
|
||||
args.dests = results[i];
|
||||
args.inputs = inputs[i];
|
||||
execute_shader(&args);
|
||||
}
|
||||
|
||||
execute_shader(&args);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
17
src/mesa/pipe/llvm/loweringpass.cpp
Normal file
17
src/mesa/pipe/llvm/loweringpass.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include "loweringpass.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
char LoweringPass::ID = 0;
|
||||
RegisterPass<LoweringPass> X("lowering", "Lowering Pass");
|
||||
|
||||
LoweringPass::LoweringPass()
|
||||
: ModulePass((intptr_t)&ID)
|
||||
{
|
||||
}
|
||||
|
||||
bool LoweringPass::runOnModule(Module &m)
|
||||
{
|
||||
llvm::cerr << "Hello: " << m.getModuleIdentifier() << "\n";
|
||||
return false;
|
||||
}
|
||||
15
src/mesa/pipe/llvm/loweringpass.h
Normal file
15
src/mesa/pipe/llvm/loweringpass.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef LOWERINGPASS_H
|
||||
#define LOWERINGPASS_H
|
||||
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Module.h"
|
||||
|
||||
struct LoweringPass : public llvm::ModulePass
|
||||
{
|
||||
static char ID;
|
||||
LoweringPass();
|
||||
|
||||
virtual bool runOnModule(llvm::Module &m);
|
||||
};
|
||||
|
||||
#endif
|
||||
117
src/mesa/pipe/llvm/storagesoa.cpp
Normal file
117
src/mesa/pipe/llvm/storagesoa.cpp
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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 "storagesoa.h"
|
||||
|
||||
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include <llvm/BasicBlock.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Value.h>
|
||||
|
||||
#include <llvm/CallingConv.h>
|
||||
#include <llvm/Constants.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/InstrTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
StorageSoa::StorageSoa(llvm::BasicBlock *block,
|
||||
llvm::Value *input,
|
||||
llvm::Value *output,
|
||||
llvm::Value *consts)
|
||||
{
|
||||
}
|
||||
|
||||
void StorageSoa::addImmediate(float *vec)
|
||||
{
|
||||
}
|
||||
|
||||
llvm::Value *StorageSoa::addrElement(int idx) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> StorageSoa::inputElement(int idx, int swizzle,
|
||||
llvm::Value *indIdx)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> StorageSoa::constElement(int idx, int swizzle,
|
||||
llvm::Value *indIdx)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> StorageSoa::outputElement(int idx, int swizzle,
|
||||
llvm::Value *indIdx)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> StorageSoa::tempElement(int idx, int swizzle,
|
||||
llvm::Value *indIdx)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<llvm::Value*> StorageSoa::immediateElement(int idx, int swizzle)
|
||||
{
|
||||
std::vector<llvm::Value*> res(4);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
llvm::Value * StorageSoa::extractIndex(llvm::Value *vec)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void StorageSoa::storeOutput(int dstIdx, const std::vector<llvm::Value*> &val,
|
||||
int mask)
|
||||
{
|
||||
}
|
||||
|
||||
void StorageSoa::storeTemp(int idx, const std::vector<llvm::Value*> &val,
|
||||
int mask)
|
||||
{
|
||||
}
|
||||
|
||||
void StorageSoa::storeAddress(int idx, const std::vector<llvm::Value*> &val,
|
||||
int mask)
|
||||
{
|
||||
}
|
||||
71
src/mesa/pipe/llvm/storagesoa.h
Normal file
71
src/mesa/pipe/llvm/storagesoa.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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 STORAGESOA_H
|
||||
#define STORAGESOA_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class BasicBlock;
|
||||
class Constant;
|
||||
class ConstantInt;
|
||||
class LoadInst;
|
||||
class Value;
|
||||
class VectorType;
|
||||
}
|
||||
|
||||
class StorageSoa
|
||||
{
|
||||
public:
|
||||
StorageSoa(llvm::BasicBlock *block,
|
||||
llvm::Value *input,
|
||||
llvm::Value *output,
|
||||
llvm::Value *consts);
|
||||
|
||||
void addImmediate(float *vec);
|
||||
|
||||
llvm::Value * addrElement(int idx) const;
|
||||
|
||||
std::vector<llvm::Value*> inputElement(int idx, int swizzle, llvm::Value *indIdx =0);
|
||||
std::vector<llvm::Value*> constElement(int idx, int swizzle, llvm::Value *indIdx =0);
|
||||
std::vector<llvm::Value*> outputElement(int idx, int swizzle, llvm::Value *indIdx =0);
|
||||
std::vector<llvm::Value*> tempElement(int idx, int swizzle, llvm::Value *indIdx =0);
|
||||
std::vector<llvm::Value*> immediateElement(int idx, int swizzle);
|
||||
|
||||
llvm::Value *extractIndex(llvm::Value *vec);
|
||||
|
||||
void storeOutput(int dstIdx, const std::vector<llvm::Value*> &val,
|
||||
int mask);
|
||||
void storeTemp(int idx, const std::vector<llvm::Value*> &val,
|
||||
int mask);
|
||||
void storeAddress(int idx, const std::vector<llvm::Value*> &val,
|
||||
int mask);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
1174
src/mesa/pipe/llvm/tgsitollvm.cpp
Normal file
1174
src/mesa/pipe/llvm/tgsitollvm.cpp
Normal file
File diff suppressed because it is too large
Load diff
20
src/mesa/pipe/llvm/tgsitollvm.h
Normal file
20
src/mesa/pipe/llvm/tgsitollvm.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef TGSITOLLVM_H
|
||||
#define TGSITOLLVM_H
|
||||
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
}
|
||||
|
||||
struct gallivm_ir;
|
||||
struct tgsi_token;
|
||||
|
||||
|
||||
llvm::Module * tgsi_to_llvm(struct gallivm_ir *ir,
|
||||
const struct tgsi_token *tokens);
|
||||
|
||||
|
||||
llvm::Module * tgsi_to_llvmir(struct gallivm_ir *ir,
|
||||
const struct tgsi_token *tokens);
|
||||
|
||||
#endif
|
||||
|
|
@ -234,14 +234,9 @@ struct pipe_sampler_state
|
|||
unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */
|
||||
unsigned compare_func:3; /**< PIPE_FUNC_x */
|
||||
unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
|
||||
float shadow_ambient; /**< shadow test fail color/intensity */
|
||||
float min_lod;
|
||||
float max_lod;
|
||||
float lod_bias;
|
||||
#if 0 /* need these? */
|
||||
int BaseLevel; /**< min mipmap level, OpenGL 1.2 */
|
||||
int MaxLevel; /**< max mipmap level, OpenGL 1.2 */
|
||||
#endif
|
||||
float shadow_ambient; /**< shadow test fail color/intensity */
|
||||
float lod_bias; /**< LOD/lambda bias */
|
||||
float min_lod, max_lod; /**< LOD clamp range, after bias */
|
||||
float border_color[4];
|
||||
float max_anisotropy;
|
||||
};
|
||||
|
|
@ -277,8 +272,7 @@ struct pipe_texture
|
|||
enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
|
||||
enum pipe_format format; /**< PIPE_FORMAT_x */
|
||||
|
||||
unsigned first_level;
|
||||
unsigned last_level;
|
||||
unsigned last_level; /**< Index of last mipmap level present/defined */
|
||||
|
||||
unsigned width[PIPE_MAX_TEXTURE_LEVELS];
|
||||
unsigned height[PIPE_MAX_TEXTURE_LEVELS];
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ struct pipe_winsys
|
|||
|
||||
/**
|
||||
* 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 PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
|
||||
*/
|
||||
void *(*buffer_map)( struct pipe_winsys *sws,
|
||||
struct pipe_buffer *buf,
|
||||
|
|
|
|||
|
|
@ -61,12 +61,16 @@ softpipe_create_fs_state(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
#ifdef MESA_LLVM
|
||||
state->llvm_prog = gallivm_from_tgsi(state->shader.tokens, GALLIVM_FS);
|
||||
state->llvm_prog = 0;
|
||||
|
||||
#if 0
|
||||
if (!gallivm_global_cpu_engine()) {
|
||||
gallivm_cpu_engine_create(state->llvm_prog);
|
||||
}
|
||||
else
|
||||
gallivm_cpu_jit_compile(gallivm_global_cpu_engine(), state->llvm_prog);
|
||||
#endif
|
||||
|
||||
#elif defined(__i386__) || defined(__386__)
|
||||
if (softpipe->use_sse) {
|
||||
x86_init_func( &state->sse2_program );
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include "sp_state.h"
|
||||
#include "sp_texture.h"
|
||||
#include "sp_tile_cache.h"
|
||||
#include "pipe/draw/draw_context.h"
|
||||
|
||||
|
||||
|
||||
void *
|
||||
|
|
@ -73,6 +75,8 @@ softpipe_set_sampler_texture(struct pipe_context *pipe,
|
|||
{
|
||||
struct softpipe_context *softpipe = softpipe_context(pipe);
|
||||
|
||||
draw_flush(softpipe->draw);
|
||||
|
||||
assert(unit < PIPE_MAX_SAMPLERS);
|
||||
softpipe->texture[unit] = softpipe_texture(texture); /* ptr, not struct */
|
||||
|
||||
|
|
|
|||
|
|
@ -449,7 +449,6 @@ compute_lambda(struct tgsi_sampler *sampler,
|
|||
}
|
||||
|
||||
lambda = LOG2(rho);
|
||||
|
||||
lambda += lodbias + sampler->state->lod_bias;
|
||||
lambda = CLAMP(lambda, sampler->state->min_lod, sampler->state->max_lod);
|
||||
|
||||
|
|
@ -457,7 +456,6 @@ compute_lambda(struct tgsi_sampler *sampler,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Do several things here:
|
||||
* 1. Compute lambda from the texcoords, if needed
|
||||
|
|
@ -477,7 +475,7 @@ choose_mipmap_levels(struct tgsi_sampler *sampler,
|
|||
if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) {
|
||||
/* no mipmap selection needed */
|
||||
*imgFilter = sampler->state->mag_img_filter;
|
||||
*level0 = *level1 = sampler->texture->first_level;
|
||||
*level0 = *level1 = (int) sampler->state->min_lod;
|
||||
}
|
||||
else {
|
||||
float lambda;
|
||||
|
|
@ -492,7 +490,7 @@ choose_mipmap_levels(struct tgsi_sampler *sampler,
|
|||
if (lambda < 0.0) { /* XXX threshold depends on the filter */
|
||||
/* magnifying */
|
||||
*imgFilter = sampler->state->mag_img_filter;
|
||||
*level0 = *level1 = sampler->texture->first_level;
|
||||
*level0 = *level1 = 0;
|
||||
}
|
||||
else {
|
||||
/* minifying */
|
||||
|
|
@ -503,19 +501,13 @@ choose_mipmap_levels(struct tgsi_sampler *sampler,
|
|||
/* Nearest mipmap level */
|
||||
const int lvl = (int) (lambda + 0.5);
|
||||
*level0 =
|
||||
*level1 = CLAMP(lvl,
|
||||
(int) sampler->texture->first_level,
|
||||
(int) sampler->texture->last_level);
|
||||
*level1 = CLAMP(lvl, 0, (int) sampler->texture->last_level);
|
||||
}
|
||||
else {
|
||||
/* Linear interpolation between mipmap levels */
|
||||
const int lvl = (int) lambda;
|
||||
*level0 = CLAMP(lvl,
|
||||
(int) sampler->texture->first_level,
|
||||
(int) sampler->texture->last_level);
|
||||
*level1 = CLAMP(lvl + 1,
|
||||
(int) sampler->texture->first_level,
|
||||
(int) sampler->texture->last_level);
|
||||
*level0 = CLAMP(lvl, 0, (int) sampler->texture->last_level);
|
||||
*level1 = CLAMP(lvl + 1, 0, (int) sampler->texture->last_level);
|
||||
*levelBlend = FRAC(lambda); /* blending weight between levels */
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ softpipe_texture_layout(struct softpipe_texture * spt)
|
|||
|
||||
spt->buffer_size = 0;
|
||||
|
||||
for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
|
||||
for (level = 0; level <= pt->last_level; level++) {
|
||||
pt->width[level] = width;
|
||||
pt->height[level] = height;
|
||||
pt->depth[level] = depth;
|
||||
|
|
@ -139,6 +139,8 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
|
|||
struct softpipe_texture *spt = softpipe_texture(pt);
|
||||
struct pipe_surface *ps;
|
||||
|
||||
assert(level <= pt->last_level);
|
||||
|
||||
ps = pipe->winsys->surface_alloc(pipe->winsys);
|
||||
if (ps) {
|
||||
assert(ps->refcount);
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ DRAW_SOURCES = \
|
|||
pipe/draw/draw_vertex_cache.c \
|
||||
pipe/draw/draw_vertex_fetch.c \
|
||||
pipe/draw/draw_vertex_shader.c \
|
||||
pipe/draw/draw_vertex_shader_llvm.c \
|
||||
pipe/draw/draw_vf.c \
|
||||
pipe/draw/draw_vf_generic.c \
|
||||
pipe/draw/draw_vf_sse.c \
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ update_samplers(struct st_context *st)
|
|||
|
||||
sampler.lod_bias = st->ctx->Texture.Unit[su].LodBias;
|
||||
#if 1
|
||||
sampler.min_lod = texobj->MinLod;
|
||||
sampler.min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod;
|
||||
sampler.max_lod = texobj->MaxLod;
|
||||
#else
|
||||
/* min/max lod should really be as follows (untested).
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ find_translated_vp(struct st_context *st,
|
|||
/*
|
||||
* Translate fragment program if needed.
|
||||
*/
|
||||
if (!stfp->fs) {
|
||||
if (!stfp->cso) {
|
||||
GLuint inAttr, numIn = 0;
|
||||
|
||||
for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) {
|
||||
|
|
@ -179,7 +179,7 @@ find_translated_vp(struct st_context *st,
|
|||
stfp->input_to_slot,
|
||||
stfp->tokens,
|
||||
ST_MAX_SHADER_TOKENS);
|
||||
assert(stfp->fs);
|
||||
assert(stfp->cso);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ find_translated_vp(struct st_context *st,
|
|||
if (fpInAttrib >= 0) {
|
||||
GLuint fpInSlot = stfp->input_to_slot[fpInAttrib];
|
||||
if (fpInSlot != ~0) {
|
||||
GLuint vpOutSlot = stfp->fs->state.input_map[fpInSlot];
|
||||
GLuint vpOutSlot = stfp->cso->state.input_map[fpInSlot];
|
||||
xvp->output_to_slot[outAttr] = vpOutSlot;
|
||||
numVpOuts++;
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ update_linkage( struct st_context *st )
|
|||
st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data);
|
||||
|
||||
st->fp = stfp;
|
||||
st->state.fs = stfp->fs;
|
||||
st->state.fs = stfp->cso;
|
||||
st->pipe->bind_fs_state(st->pipe, st->state.fs->data);
|
||||
|
||||
st->vertex_result_to_slot = xvp->output_to_slot;
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ clear_with_quad(GLcontext *ctx,
|
|||
if (!stfp) {
|
||||
stfp = make_frag_shader(st);
|
||||
}
|
||||
pipe->bind_fs_state(pipe, stfp->fs->data);
|
||||
pipe->bind_fs_state(pipe, stfp->cso->data);
|
||||
}
|
||||
|
||||
/* vertex shader state: color/position pass-through */
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ make_texture(struct st_context *st,
|
|||
assert(pipeFormat);
|
||||
cpp = st_sizeof_format(pipeFormat);
|
||||
|
||||
pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, 0, width, height,
|
||||
pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, width, height,
|
||||
1, 0);
|
||||
if (!pt)
|
||||
return NULL;
|
||||
|
|
@ -665,7 +665,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
|
|||
}
|
||||
|
||||
/* fragment shader state: TEX lookup program */
|
||||
pipe->bind_fs_state(pipe, stfp->fs->data);
|
||||
pipe->bind_fs_state(pipe, stfp->cso->data);
|
||||
|
||||
/* vertex shader state: position + texcoord pass-through */
|
||||
pipe->bind_vs_state(pipe, stvp->cso->data);
|
||||
|
|
@ -1017,7 +1017,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
|
|||
/**
|
||||
* Create a texture.
|
||||
*/
|
||||
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, 0, width, height,
|
||||
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, width, height,
|
||||
1, 0);
|
||||
if (!pt)
|
||||
return NULL;
|
||||
|
|
@ -1241,7 +1241,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||
psRead = rbRead->surface;
|
||||
format = psRead->format;
|
||||
|
||||
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, 0, width, height,
|
||||
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, width, height,
|
||||
1, 0);
|
||||
if (!pt)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -168,10 +168,10 @@ static void st_program_string_notify( GLcontext *ctx,
|
|||
|
||||
stfp->serialNo++;
|
||||
|
||||
if (stfp->fs) {
|
||||
if (stfp->cso) {
|
||||
/* free the TGSI code */
|
||||
// cso_delete(stfp->vs);
|
||||
stfp->fs = NULL;
|
||||
stfp->cso = NULL;
|
||||
}
|
||||
|
||||
stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
|
||||
|
|
|
|||
|
|
@ -180,20 +180,13 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
|||
if (!strb)
|
||||
return;
|
||||
|
||||
|
||||
if (format == GL_RGBA && type == GL_FLOAT) {
|
||||
/* write tile(row) directly into user's buffer */
|
||||
df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
|
||||
height, format, type, 0, 0);
|
||||
dfStride = width * 4;
|
||||
}
|
||||
#if 0
|
||||
else if (format == GL_DEPTH_COMPONENT && type == GL_FLOAT) {
|
||||
/* write tile(row) directly into user's buffer */
|
||||
df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
|
||||
height, format, type, 0, 0);
|
||||
dfStride = width;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
/* write tile(row) into temp row buffer */
|
||||
df = (GLfloat *) temp;
|
||||
|
|
@ -209,22 +202,86 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
|||
yStep = 1;
|
||||
}
|
||||
|
||||
/* Do a row at a time to flip image data vertically */
|
||||
for (i = 0; i < height; i++) {
|
||||
pipe_get_tile_rgba(pipe, strb->surface, x, y, width, 1, df);
|
||||
y += yStep;
|
||||
df += dfStride;
|
||||
if (!dfStride) {
|
||||
/* convert GLfloat to user's format/type */
|
||||
GLvoid *dst = _mesa_image_address2d(&clippedPacking, dest, width,
|
||||
height, format, type, i, 0);
|
||||
/*
|
||||
* Copy pixels from pipe_surface to user memory
|
||||
*/
|
||||
{
|
||||
/* dest of first pixel in client memory */
|
||||
GLubyte *dst = _mesa_image_address2d(&clippedPacking, dest, width,
|
||||
height, format, type, 0, 0);
|
||||
/* dest row stride */
|
||||
const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width,
|
||||
format, type);
|
||||
|
||||
if (strb->surface->format == PIPE_FORMAT_S8Z24_UNORM) {
|
||||
if (format == GL_DEPTH_COMPONENT) {
|
||||
_mesa_pack_depth_span(ctx, width, dst, type,
|
||||
(GLfloat *) temp, &clippedPacking);
|
||||
for (i = 0; i < height; i++) {
|
||||
GLuint ztemp[MAX_WIDTH], j;
|
||||
GLfloat zfloat[MAX_WIDTH];
|
||||
const double scale = 1.0 / ((1 << 24) - 1);
|
||||
pipe_get_tile_raw(pipe, strb->surface, x, y,
|
||||
width, 1, ztemp, 0);
|
||||
y += yStep;
|
||||
for (j = 0; j < width; j++) {
|
||||
zfloat[j] = (float) (scale * (ztemp[j] & 0xffffff));
|
||||
}
|
||||
_mesa_pack_depth_span(ctx, width, dst, type,
|
||||
zfloat, &clippedPacking);
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_mesa_pack_rgba_span_float(ctx, width, temp, format, type, dst,
|
||||
&clippedPacking, transferOps);
|
||||
/* untested, but simple: */
|
||||
assert(format == GL_DEPTH_STENCIL_EXT);
|
||||
for (i = 0; i < height; i++) {
|
||||
pipe_get_tile_raw(pipe, strb->surface, x, y, width, 1, dst, 0);
|
||||
y += yStep;
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strb->surface->format == PIPE_FORMAT_Z16_UNORM) {
|
||||
for (i = 0; i < height; i++) {
|
||||
GLshort ztemp[MAX_WIDTH], j;
|
||||
GLfloat zfloat[MAX_WIDTH];
|
||||
const double scale = 1.0 / 0xffff;
|
||||
pipe_get_tile_raw(pipe, strb->surface, x, y, width, 1, ztemp, 0);
|
||||
y += yStep;
|
||||
for (j = 0; j < width; j++) {
|
||||
zfloat[j] = (float) (scale * ztemp[j]);
|
||||
}
|
||||
_mesa_pack_depth_span(ctx, width, dst, type,
|
||||
zfloat, &clippedPacking);
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
else if (strb->surface->format == PIPE_FORMAT_Z32_UNORM) {
|
||||
for (i = 0; i < height; i++) {
|
||||
GLuint ztemp[MAX_WIDTH], j;
|
||||
GLfloat zfloat[MAX_WIDTH];
|
||||
const double scale = 1.0 / 0xffffffff;
|
||||
pipe_get_tile_raw(pipe, strb->surface, x, y, width, 1, ztemp, 0);
|
||||
y += yStep;
|
||||
for (j = 0; j < width; j++) {
|
||||
zfloat[j] = (float) (scale * ztemp[j]);
|
||||
}
|
||||
_mesa_pack_depth_span(ctx, width, dst, type,
|
||||
zfloat, &clippedPacking);
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* RGBA format */
|
||||
/* Do a row at a time to flip image data vertically */
|
||||
for (i = 0; i < height; i++) {
|
||||
pipe_get_tile_rgba(pipe, strb->surface, x, y, width, 1, df);
|
||||
y += yStep;
|
||||
df += dfStride;
|
||||
if (!dfStride) {
|
||||
_mesa_pack_rgba_span_float(ctx, width, temp, format, type, dst,
|
||||
&clippedPacking, transferOps);
|
||||
dst += dstStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,15 +57,10 @@ struct st_texture_object
|
|||
{
|
||||
struct gl_texture_object base; /* The "parent" object */
|
||||
|
||||
/* The texture must include at least these levels once validated:
|
||||
/* The texture must include at levels [0..lastLevel] once validated:
|
||||
*/
|
||||
GLuint firstLevel;
|
||||
GLuint lastLevel;
|
||||
|
||||
/* Offset for firstLevel image:
|
||||
*/
|
||||
GLuint textureOffset;
|
||||
|
||||
/* On validation any active images held in main memory or in other
|
||||
* textures will be copied to this texture and the old storage freed.
|
||||
*/
|
||||
|
|
@ -368,7 +363,6 @@ guess_and_alloc_texture(struct st_context *st,
|
|||
stObj->pt = st_texture_create(st,
|
||||
gl_target_to_pipe(stObj->base.Target),
|
||||
st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat),
|
||||
firstLevel,
|
||||
lastLevel,
|
||||
width,
|
||||
height,
|
||||
|
|
@ -379,26 +373,6 @@ guess_and_alloc_texture(struct st_context *st,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static GLuint
|
||||
target_to_face(GLenum target)
|
||||
{
|
||||
switch (target) {
|
||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
|
||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
|
||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
|
||||
return ((GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* There are actually quite a few combinations this will work for,
|
||||
* more than what I've listed here.
|
||||
*/
|
||||
|
|
@ -487,6 +461,43 @@ try_pbo_upload(GLcontext *ctx,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adjust pixel unpack params and image dimensions to strip off the
|
||||
* texture border.
|
||||
* Gallium doesn't support texture borders. They've seldem been used
|
||||
* and seldom been implemented correctly anyway.
|
||||
* \param unpackNew returns the new pixel unpack parameters
|
||||
*/
|
||||
static void
|
||||
strip_texture_border(GLint border,
|
||||
GLint *width, GLint *height, GLint *depth,
|
||||
const struct gl_pixelstore_attrib *unpack,
|
||||
struct gl_pixelstore_attrib *unpackNew)
|
||||
{
|
||||
assert(border > 0); /* sanity check */
|
||||
|
||||
*unpackNew = *unpack;
|
||||
|
||||
if (unpackNew->RowLength == 0)
|
||||
unpackNew->RowLength = *width;
|
||||
|
||||
if (depth && unpackNew->ImageHeight == 0)
|
||||
unpackNew->ImageHeight = *height;
|
||||
|
||||
unpackNew->SkipPixels += border;
|
||||
if (height)
|
||||
unpackNew->SkipRows += border;
|
||||
if (depth)
|
||||
unpackNew->SkipImages += border;
|
||||
|
||||
assert(*width >= 3);
|
||||
*width = *width - 2 * border;
|
||||
if (height && *height >= 3)
|
||||
*height = *height - 2 * border;
|
||||
if (depth && *depth >= 3)
|
||||
*depth = *depth - 2 * border;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_TexImage(GLcontext * ctx,
|
||||
|
|
@ -503,16 +514,26 @@ st_TexImage(GLcontext * ctx,
|
|||
{
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
GLint postConvWidth = width;
|
||||
GLint postConvHeight = height;
|
||||
GLint postConvWidth, postConvHeight;
|
||||
GLint texelBytes, sizeInBytes;
|
||||
GLuint dstRowStride;
|
||||
|
||||
struct gl_pixelstore_attrib unpackNB;
|
||||
|
||||
DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
|
||||
_mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
|
||||
|
||||
stImage->face = target_to_face(target);
|
||||
/* gallium does not support texture borders, strip it off */
|
||||
if (border) {
|
||||
strip_texture_border(border, &width, &height, &depth,
|
||||
unpack, &unpackNB);
|
||||
unpack = &unpackNB;
|
||||
border = 0;
|
||||
}
|
||||
|
||||
postConvWidth = width;
|
||||
postConvHeight = height;
|
||||
|
||||
stImage->face = _mesa_tex_target_to_face(target);
|
||||
stImage->level = level;
|
||||
|
||||
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
|
||||
|
|
@ -558,12 +579,12 @@ st_TexImage(GLcontext * ctx,
|
|||
_mesa_align_free(texImage->Data);
|
||||
}
|
||||
|
||||
/* If this is the only texture image in the texture, could call
|
||||
/* If this is the only mipmap level in the texture, could call
|
||||
* bmBufferData with NULL data to free the old block and avoid
|
||||
* waiting on any outstanding fences.
|
||||
*/
|
||||
if (stObj->pt &&
|
||||
stObj->pt->first_level == level &&
|
||||
/*stObj->pt->first_level == level &&*/
|
||||
stObj->pt->last_level == level &&
|
||||
stObj->pt->target != PIPE_TEXTURE_CUBE &&
|
||||
!st_texture_match_image(stObj->pt, &stImage->base,
|
||||
|
|
@ -1336,13 +1357,8 @@ calculate_first_last_level(struct st_texture_object *stObj)
|
|||
firstLevel = lastLevel = tObj->BaseLevel;
|
||||
}
|
||||
else {
|
||||
firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
|
||||
firstLevel = MAX2(firstLevel, tObj->BaseLevel);
|
||||
lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
|
||||
lastLevel = MAX2(lastLevel, tObj->BaseLevel);
|
||||
lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
|
||||
lastLevel = MIN2(lastLevel, tObj->MaxLevel);
|
||||
lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
|
||||
firstLevel = 0;
|
||||
lastLevel = MIN2(tObj->MaxLevel - tObj->BaseLevel, baseImage->MaxLog2);
|
||||
}
|
||||
break;
|
||||
case GL_TEXTURE_RECTANGLE_NV:
|
||||
|
|
@ -1353,8 +1369,6 @@ calculate_first_last_level(struct st_texture_object *stObj)
|
|||
return;
|
||||
}
|
||||
|
||||
/* save these values */
|
||||
stObj->firstLevel = firstLevel;
|
||||
stObj->lastLevel = lastLevel;
|
||||
}
|
||||
|
||||
|
|
@ -1362,15 +1376,16 @@ calculate_first_last_level(struct st_texture_object *stObj)
|
|||
static void
|
||||
copy_image_data_to_texture(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
GLuint dstLevel,
|
||||
struct st_texture_image *stImage)
|
||||
{
|
||||
if (stImage->pt) {
|
||||
/* Copy potentially with the blitter:
|
||||
*/
|
||||
st_texture_image_copy(st->pipe,
|
||||
stObj->pt, /* dest texture */
|
||||
stImage->face, stImage->level,
|
||||
stImage->pt /* src texture */
|
||||
stObj->pt, dstLevel, /* dest texture, level */
|
||||
stImage->pt, /* src texture */
|
||||
stImage->face
|
||||
);
|
||||
|
||||
st->pipe->texture_release(st->pipe, &stImage->pt);
|
||||
|
|
@ -1411,7 +1426,7 @@ st_finalize_texture(GLcontext *ctx,
|
|||
const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
|
||||
int comp_byte = 0;
|
||||
int cpp;
|
||||
GLuint face, i;
|
||||
GLuint face;
|
||||
struct st_texture_image *firstImage;
|
||||
|
||||
*needFlush = GL_FALSE;
|
||||
|
|
@ -1423,7 +1438,7 @@ st_finalize_texture(GLcontext *ctx,
|
|||
/* What levels must the texture include at a minimum?
|
||||
*/
|
||||
calculate_first_last_level(stObj);
|
||||
firstImage = st_texture_image(stObj->base.Image[0][stObj->firstLevel]);
|
||||
firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
|
||||
|
||||
/* Fallback case:
|
||||
*/
|
||||
|
|
@ -1442,7 +1457,6 @@ st_finalize_texture(GLcontext *ctx,
|
|||
*/
|
||||
if (firstImage->pt &&
|
||||
firstImage->pt != stObj->pt &&
|
||||
firstImage->pt->first_level <= stObj->firstLevel &&
|
||||
firstImage->pt->last_level >= stObj->lastLevel) {
|
||||
|
||||
if (stObj->pt)
|
||||
|
|
@ -1461,18 +1475,11 @@ st_finalize_texture(GLcontext *ctx,
|
|||
|
||||
/* Check texture can hold all active levels. Check texture matches
|
||||
* target, imageFormat, etc.
|
||||
*
|
||||
* XXX: For some layouts (eg i945?), the test might have to be
|
||||
* first_level == firstLevel, as the texture isn't valid except at the
|
||||
* original start level. Hope to get around this by
|
||||
* programming minLod, maxLod, baseLevel into the hardware and
|
||||
* leaving the texture alone.
|
||||
*/
|
||||
if (stObj->pt &&
|
||||
(stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
|
||||
stObj->pt->format !=
|
||||
st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat) ||
|
||||
stObj->pt->first_level != stObj->firstLevel ||
|
||||
stObj->pt->last_level != stObj->lastLevel ||
|
||||
stObj->pt->width[0] != firstImage->base.Width ||
|
||||
stObj->pt->height[0] != firstImage->base.Height ||
|
||||
|
|
@ -1489,7 +1496,6 @@ st_finalize_texture(GLcontext *ctx,
|
|||
stObj->pt = st_texture_create(ctx->st,
|
||||
gl_target_to_pipe(stObj->base.Target),
|
||||
st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat),
|
||||
stObj->firstLevel,
|
||||
stObj->lastLevel,
|
||||
firstImage->base.Width,
|
||||
firstImage->base.Height,
|
||||
|
|
@ -1500,14 +1506,15 @@ st_finalize_texture(GLcontext *ctx,
|
|||
/* Pull in any images not in the object's texture:
|
||||
*/
|
||||
for (face = 0; face < nr_faces; face++) {
|
||||
for (i = stObj->firstLevel; i <= stObj->lastLevel; i++) {
|
||||
GLuint level;
|
||||
for (level = 0; level <= stObj->lastLevel; level++) {
|
||||
struct st_texture_image *stImage =
|
||||
st_texture_image(stObj->base.Image[face][i]);
|
||||
st_texture_image(stObj->base.Image[face][stObj->base.BaseLevel + level]);
|
||||
|
||||
/* Need to import images in main memory or held in other textures.
|
||||
*/
|
||||
if (stObj->pt != stImage->pt) {
|
||||
copy_image_data_to_texture(ctx->st, stObj, stImage);
|
||||
if (stImage && stObj->pt != stImage->pt) {
|
||||
copy_image_data_to_texture(ctx->st, stObj, level, stImage);
|
||||
*needFlush = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,15 @@ struct st_context
|
|||
struct st_fragment_program *combined_prog;
|
||||
} bitmap;
|
||||
|
||||
/** For gen/render mipmap feature */
|
||||
struct {
|
||||
void *blend_cso;
|
||||
void *depthstencil_cso;
|
||||
void *rasterizer_cso;
|
||||
struct st_fragment_program *stfp;
|
||||
struct st_vertex_program *stvp;
|
||||
} gen_mipmap;
|
||||
|
||||
struct cso_cache *cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,14 @@
|
|||
#include "main/imports.h"
|
||||
#include "main/mipmap.h"
|
||||
#include "main/teximage.h"
|
||||
#include "main/texformat.h"
|
||||
|
||||
#include "shader/prog_instruction.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
#include "pipe/cso_cache/cso_cache.h"
|
||||
|
||||
#include "st_context.h"
|
||||
|
|
@ -45,16 +48,6 @@
|
|||
|
||||
|
||||
|
||||
static void *blend_cso = NULL;
|
||||
static void *depthstencil_cso = NULL;
|
||||
static void *rasterizer_cso = NULL;
|
||||
static void *sampler_cso = NULL;
|
||||
|
||||
static struct st_fragment_program *stfp = NULL;
|
||||
static struct st_vertex_program *stvp = NULL;
|
||||
|
||||
|
||||
|
||||
static struct st_fragment_program *
|
||||
make_tex_fragment_program(GLcontext *ctx)
|
||||
{
|
||||
|
|
@ -115,33 +108,20 @@ st_init_generate_mipmap(struct st_context *st)
|
|||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_blend_state blend;
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
struct pipe_sampler_state sampler;
|
||||
struct pipe_depth_stencil_alpha_state depthstencil;
|
||||
|
||||
assert(!blend_cso);
|
||||
|
||||
memset(&blend, 0, sizeof(blend));
|
||||
blend.colormask = PIPE_MASK_RGBA;
|
||||
blend_cso = pipe->create_blend_state(pipe, &blend);
|
||||
st->gen_mipmap.blend_cso = pipe->create_blend_state(pipe, &blend);
|
||||
|
||||
memset(&depthstencil, 0, sizeof(depthstencil));
|
||||
depthstencil_cso = pipe->create_depth_stencil_alpha_state(pipe, &depthstencil);
|
||||
st->gen_mipmap.depthstencil_cso = pipe->create_depth_stencil_alpha_state(pipe, &depthstencil);
|
||||
|
||||
memset(&rasterizer, 0, sizeof(rasterizer));
|
||||
rasterizer_cso = pipe->create_rasterizer_state(pipe, &rasterizer);
|
||||
st->gen_mipmap.rasterizer_cso = pipe->create_rasterizer_state(pipe, &rasterizer);
|
||||
|
||||
memset(&sampler, 0, sizeof(sampler));
|
||||
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_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampler.normalized_coords = 1;
|
||||
sampler_cso = pipe->create_sampler_state(pipe, &sampler);
|
||||
|
||||
stfp = make_tex_fragment_program(st->ctx);
|
||||
stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
|
||||
st->gen_mipmap.stfp = make_tex_fragment_program(st->ctx);
|
||||
st->gen_mipmap.stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -150,17 +130,11 @@ st_destroy_generate_mipmpap(struct st_context *st)
|
|||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
pipe->delete_blend_state(pipe, blend_cso);
|
||||
pipe->delete_depth_stencil_alpha_state(pipe, depthstencil_cso);
|
||||
pipe->delete_rasterizer_state(pipe, rasterizer_cso);
|
||||
pipe->delete_sampler_state(pipe, sampler_cso);
|
||||
pipe->delete_blend_state(pipe, st->gen_mipmap.blend_cso);
|
||||
pipe->delete_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso);
|
||||
pipe->delete_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso);
|
||||
|
||||
/* XXX free stfp, stvp */
|
||||
|
||||
blend_cso = NULL;
|
||||
depthstencil_cso = NULL;
|
||||
rasterizer_cso = NULL;
|
||||
sampler_cso = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -239,15 +213,20 @@ draw_quad(GLcontext *ctx)
|
|||
*/
|
||||
static boolean
|
||||
st_render_mipmap(struct st_context *st,
|
||||
GLenum target,
|
||||
struct pipe_texture *pt,
|
||||
uint baseLevel, uint lastLevel)
|
||||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_framebuffer_state fb;
|
||||
const uint face = 0, zslice = 0;
|
||||
const uint first_level_save = pt->first_level;
|
||||
struct pipe_sampler_state sampler;
|
||||
void *sampler_cso;
|
||||
const uint face = _mesa_tex_target_to_face(target), zslice = 0;
|
||||
/*const uint first_level_save = pt->first_level;*/
|
||||
uint dstLevel;
|
||||
|
||||
assert(target != GL_TEXTURE_3D); /* not done yet */
|
||||
|
||||
/* check if we can render in the texture's format */
|
||||
if (!pipe->is_format_supported(pipe, pt->format, PIPE_SURFACE)) {
|
||||
return FALSE;
|
||||
|
|
@ -257,16 +236,30 @@ st_render_mipmap(struct st_context *st,
|
|||
memset(&fb, 0, sizeof(fb));
|
||||
fb.num_cbufs = 1;
|
||||
|
||||
/* sampler state */
|
||||
memset(&sampler, 0, sizeof(sampler));
|
||||
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_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampler.normalized_coords = 1;
|
||||
|
||||
|
||||
/* bind CSOs */
|
||||
pipe->bind_blend_state(pipe, blend_cso);
|
||||
pipe->bind_depth_stencil_alpha_state(pipe, depthstencil_cso);
|
||||
pipe->bind_rasterizer_state(pipe, rasterizer_cso);
|
||||
pipe->bind_sampler_state(pipe, 0, sampler_cso);
|
||||
pipe->bind_blend_state(pipe, st->gen_mipmap.blend_cso);
|
||||
pipe->bind_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso);
|
||||
pipe->bind_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso);
|
||||
|
||||
/* bind shaders */
|
||||
pipe->bind_fs_state(pipe, stfp->fs->data);
|
||||
pipe->bind_vs_state(pipe, stvp->cso->data);
|
||||
pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->cso->data);
|
||||
pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->cso->data);
|
||||
|
||||
/*
|
||||
* XXX for small mipmap levels, it may be faster to use the software
|
||||
* fallback path...
|
||||
*/
|
||||
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
||||
const uint srcLevel = dstLevel - 1;
|
||||
|
||||
|
|
@ -276,20 +269,29 @@ st_render_mipmap(struct st_context *st,
|
|||
fb.cbufs[0] = pipe->get_tex_surface(pipe, pt, face, dstLevel, zslice);
|
||||
pipe->set_framebuffer_state(pipe, &fb);
|
||||
|
||||
/*
|
||||
* Setup sampler state
|
||||
*/
|
||||
sampler.min_lod = sampler.max_lod = srcLevel;
|
||||
sampler_cso = pipe->create_sampler_state(pipe, &sampler);
|
||||
pipe->bind_sampler_state(pipe, 0, sampler_cso);
|
||||
|
||||
simple_viewport(pipe, pt->width[dstLevel], pt->height[dstLevel]);
|
||||
|
||||
/*
|
||||
* Setup src texture, override pt->first_level so we sample from
|
||||
* the right mipmap level.
|
||||
*/
|
||||
pt->first_level = srcLevel;
|
||||
/*pt->first_level = srcLevel;*/
|
||||
pipe->set_sampler_texture(pipe, 0, pt);
|
||||
|
||||
draw_quad(st->ctx);
|
||||
|
||||
pipe->delete_sampler_state(pipe, sampler_cso);
|
||||
}
|
||||
|
||||
/* restore first_level */
|
||||
pt->first_level = first_level_save;
|
||||
/*pt->first_level = first_level_save;*/
|
||||
|
||||
/* restore pipe state */
|
||||
if (st->state.rasterizer)
|
||||
|
|
@ -307,6 +309,58 @@ st_render_mipmap(struct st_context *st,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
fallback_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj)
|
||||
{
|
||||
struct pipe_context *pipe = ctx->st->pipe;
|
||||
struct pipe_winsys *ws = pipe->winsys;
|
||||
struct pipe_texture *pt = st_get_texobj_texture(texObj);
|
||||
const uint baseLevel = texObj->BaseLevel;
|
||||
const uint lastLevel = pt->last_level;
|
||||
const uint face = _mesa_tex_target_to_face(target), zslice = 0;
|
||||
uint dstLevel;
|
||||
GLenum datatype;
|
||||
GLuint comps;
|
||||
|
||||
assert(target != GL_TEXTURE_3D); /* not done yet */
|
||||
|
||||
_mesa_format_to_type_and_comps(texObj->Image[face][baseLevel]->TexFormat,
|
||||
&datatype, &comps);
|
||||
|
||||
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
||||
const uint srcLevel = dstLevel - 1;
|
||||
struct pipe_surface *srcSurf, *dstSurf;
|
||||
const ubyte *srcData;
|
||||
ubyte *dstData;
|
||||
|
||||
srcSurf = pipe->get_tex_surface(pipe, pt, face, srcLevel, zslice);
|
||||
dstSurf = pipe->get_tex_surface(pipe, pt, face, dstLevel, zslice);
|
||||
|
||||
srcData = (ubyte *) ws->buffer_map(ws, srcSurf->buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ)
|
||||
+ srcSurf->offset;
|
||||
dstData = (ubyte *) ws->buffer_map(ws, dstSurf->buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_WRITE)
|
||||
+ dstSurf->offset;
|
||||
|
||||
_mesa_generate_mipmap_level(target, datatype, comps,
|
||||
0 /*border*/,
|
||||
pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel],
|
||||
srcSurf->pitch * srcSurf->cpp, /* stride in bytes */
|
||||
srcData,
|
||||
pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel],
|
||||
dstSurf->pitch * dstSurf->cpp, /* stride in bytes */
|
||||
dstData);
|
||||
|
||||
ws->buffer_unmap(ws, srcSurf->buffer);
|
||||
ws->buffer_unmap(ws, dstSurf->buffer);
|
||||
|
||||
pipe_surface_reference(&srcSurf, NULL);
|
||||
pipe_surface_reference(&dstSurf, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
st_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
|
|
@ -318,13 +372,11 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
|
|||
const uint lastLevel = pt->last_level;
|
||||
uint dstLevel;
|
||||
|
||||
if (!st_render_mipmap(st, pt, baseLevel, lastLevel)) {
|
||||
abort();
|
||||
/* XXX the following won't really work at this time */
|
||||
_mesa_generate_mipmap(ctx, target, texObj);
|
||||
return;
|
||||
if (!st_render_mipmap(st, target, pt, baseLevel, lastLevel)) {
|
||||
fallback_generate_mipmap(ctx, target, texObj);
|
||||
}
|
||||
|
||||
/* Fill in the Mesa gl_texture_image fields */
|
||||
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
||||
const uint srcLevel = dstLevel - 1;
|
||||
const struct gl_texture_image *srcImage
|
||||
|
|
@ -336,7 +388,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
|
|||
uint dstDepth = pt->depth[dstLevel];
|
||||
uint border = srcImage->Border;
|
||||
|
||||
|
||||
dstImage = _mesa_get_tex_image(ctx, texObj, target, dstLevel);
|
||||
if (!dstImage) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
|
||||
|
|
@ -359,5 +410,4 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
|
|||
stImage = (struct st_texture_image *) dstImage;
|
||||
stImage->pt = pt;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ st_translate_fragment_program(struct st_context *st,
|
|||
fs.tokens = tokensOut;
|
||||
|
||||
cso = st_cached_fs_state(st, &fs);
|
||||
stfp->fs = cso;
|
||||
stfp->cso = cso;
|
||||
|
||||
if (0)
|
||||
_mesa_print_program(&stfp->Base.Base);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct st_fragment_program
|
|||
struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
|
||||
|
||||
/** Pointer to the corresponding cached shader */
|
||||
const struct cso_fragment_shader *fs;
|
||||
const struct cso_fragment_shader *cso;
|
||||
|
||||
GLuint param_state;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,12 +62,14 @@ target_to_target(GLenum target)
|
|||
|
||||
/**
|
||||
* Allocate a new pipe_texture object
|
||||
* width0, height0, depth0 are the dimensions of the level 0 image
|
||||
* (the highest resolution). last_level indicates how many mipmap levels
|
||||
* to allocate storage for. For non-mipmapped textures, this will be zero.
|
||||
*/
|
||||
struct pipe_texture *
|
||||
st_texture_create(struct st_context *st,
|
||||
enum pipe_texture_target target,
|
||||
enum pipe_format format,
|
||||
GLuint first_level,
|
||||
GLuint last_level,
|
||||
GLuint width0,
|
||||
GLuint height0,
|
||||
|
|
@ -78,15 +80,15 @@ st_texture_create(struct st_context *st,
|
|||
|
||||
assert(target <= PIPE_TEXTURE_CUBE);
|
||||
|
||||
DBG("%s target %s format %s level %d..%d\n", __FUNCTION__,
|
||||
DBG("%s target %s format %s last_level %d\n", __FUNCTION__,
|
||||
_mesa_lookup_enum_by_nr(target),
|
||||
_mesa_lookup_enum_by_nr(format), first_level, last_level);
|
||||
_mesa_lookup_enum_by_nr(format), last_level);
|
||||
|
||||
assert(format);
|
||||
|
||||
memset(&pt, 0, sizeof(pt));
|
||||
pt.target = target;
|
||||
pt.format = format;
|
||||
pt.first_level = first_level;
|
||||
pt.last_level = last_level;
|
||||
pt.width[0] = width0;
|
||||
pt.height[0] = height0;
|
||||
|
|
@ -266,23 +268,36 @@ st_texture_image_data(struct pipe_context *pipe,
|
|||
*/
|
||||
void
|
||||
st_texture_image_copy(struct pipe_context *pipe,
|
||||
struct pipe_texture *dst,
|
||||
GLuint face, GLuint level,
|
||||
struct pipe_texture *src)
|
||||
struct pipe_texture *dst, GLuint dstLevel,
|
||||
struct pipe_texture *src,
|
||||
GLuint face)
|
||||
{
|
||||
GLuint width = src->width[level];
|
||||
GLuint height = src->height[level];
|
||||
GLuint depth = src->depth[level];
|
||||
GLuint width = dst->width[dstLevel];
|
||||
GLuint height = dst->height[dstLevel];
|
||||
GLuint depth = dst->depth[dstLevel];
|
||||
struct pipe_surface *src_surface;
|
||||
struct pipe_surface *dst_surface;
|
||||
GLuint i;
|
||||
|
||||
/* XXX this is a hack */
|
||||
if (dst->compressed)
|
||||
height /= 4;
|
||||
|
||||
for (i = 0; i < depth; i++) {
|
||||
dst_surface = pipe->get_tex_surface(pipe, dst, face, level, i);
|
||||
src_surface = pipe->get_tex_surface(pipe, src, face, level, i);
|
||||
GLuint srcLevel;
|
||||
|
||||
/* find src texture level of needed size */
|
||||
for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) {
|
||||
if (src->width[srcLevel] == width &&
|
||||
src->height[srcLevel] == height) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(src->width[srcLevel] == width);
|
||||
assert(src->height[srcLevel] == height);
|
||||
|
||||
dst_surface = pipe->get_tex_surface(pipe, dst, face, dstLevel, i);
|
||||
src_surface = pipe->get_tex_surface(pipe, src, face, srcLevel, i);
|
||||
|
||||
pipe->surface_copy(pipe,
|
||||
dst_surface,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ extern struct pipe_texture *
|
|||
st_texture_create(struct st_context *st,
|
||||
enum pipe_texture_target target,
|
||||
enum pipe_format format,
|
||||
GLuint first_level,
|
||||
GLuint last_level,
|
||||
GLuint width0,
|
||||
GLuint height0,
|
||||
|
|
@ -98,9 +97,9 @@ st_texture_image_data(struct pipe_context *pipe,
|
|||
*/
|
||||
extern void
|
||||
st_texture_image_copy(struct pipe_context *pipe,
|
||||
struct pipe_texture *dst,
|
||||
GLuint face, GLuint level,
|
||||
struct pipe_texture *src);
|
||||
struct pipe_texture *dst, GLuint dstLevel,
|
||||
struct pipe_texture *src,
|
||||
GLuint face);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue